scb-wc-test 0.1.21 → 0.1.22
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 -4
- package/mvc/components/scb-list/scb-list.js +11 -4
- package/package.json +2 -2
- package/scb-list/scb-list-item.d.ts +1 -0
- package/scb-list/scb-list-item.js +9 -3
- package/scb-list/scb-list.d.ts +6 -0
- package/scb-list/scb-list.js +48 -38
- package/scb-wc-test.bundle.js +140 -130
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["../../vendor/vendor-material.js","../../vendor/vendor.js","../scb-checkbox/scb-checkbox.js","../scb-switch/scb-switch.js","../../vendor/preload-helper.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{_ as m}from"../../vendor/preload-helper.js";import{n as s,t as $,i as V,a as I,E as d,x as l}from"../../vendor/vendor.js";import"../../vendor/vendor-material.js";(function(){try{var t=typeof globalThis<"u"?globalThis:window;if(!t.__scb_ce_guard_installed__){t.__scb_ce_guard_installed__=!0;var i=customElements.define.bind(customElements);customElements.define=function(e,n,c){try{customElements.get(e)||i(e,n,c)}catch(o){var p=String(o||"");if(p.indexOf("already been used")===-1&&p.indexOf("NotSupportedError")===-1)throw o}}}}catch{}})();var E=Object.defineProperty,L=Object.getOwnPropertyDescriptor,S=t=>{throw TypeError(t)},r=(t,i,e,n)=>{for(var c=n>1?void 0:n?L(i,e):i,p=t.length-1,o;p>=0;p--)(o=t[p])&&(c=(n?o(i,e,c):o(c))||c);return n&&c&&E(i,e,c),c},k=(t,i,e)=>i.has(t)||S("Cannot "+e),g=(t,i,e)=>(k(t,i,"read from private field"),e?e.call(t):i.get(t)),h=(t,i,e)=>i.has(t)?S("Cannot add the same private member more than once"):i instanceof WeakSet?i.add(t):i.set(t,e),b=(t,i,e,n)=>(k(t,i,"write to private field"),i.set(t,e),e),x=(t,i,e)=>(k(t,i,"access private method"),e),u,f,y,v,_,w;let a=class extends V{constructor(){super(...arguments),h(this,v),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.density=0,h(this,u,!1),h(this,f,!1),h(this,y,!1),this.onRowClick=()=>{if(this.type==="link"&&(this.href||this.itemHref))return;const t=this.shadowRoot?.querySelector("scb-checkbox"),i=this.shadowRoot?.querySelector("scb-switch");t&&(t.checked=!t.checked),i&&(i.selected=!i.selected)},h(this,w,t=>{if(!t.defaultPrevented&&(t.key==="Enter"||t.key===" ")){if(this.type==="link"){const i=this.shadowRoot?.querySelector("a[href]");if(i){t.preventDefault(),i.click();return}}t.preventDefault(),this.onRowClick()}})}static get styles(){return I`
|
|
2
|
+
import{_ as m}from"../../vendor/preload-helper.js";import{n as s,t as $,i as V,a as I,E as d,x as l}from"../../vendor/vendor.js";import"../../vendor/vendor-material.js";(function(){try{var t=typeof globalThis<"u"?globalThis:window;if(!t.__scb_ce_guard_installed__){t.__scb_ce_guard_installed__=!0;var i=customElements.define.bind(customElements);customElements.define=function(e,n,c){try{customElements.get(e)||i(e,n,c)}catch(o){var p=String(o||"");if(p.indexOf("already been used")===-1&&p.indexOf("NotSupportedError")===-1)throw o}}}}catch{}})();var E=Object.defineProperty,L=Object.getOwnPropertyDescriptor,S=t=>{throw TypeError(t)},r=(t,i,e,n)=>{for(var c=n>1?void 0:n?L(i,e):i,p=t.length-1,o;p>=0;p--)(o=t[p])&&(c=(n?o(i,e,c):o(c))||c);return n&&c&&E(i,e,c),c},k=(t,i,e)=>i.has(t)||S("Cannot "+e),g=(t,i,e)=>(k(t,i,"read from private field"),e?e.call(t):i.get(t)),h=(t,i,e)=>i.has(t)?S("Cannot add the same private member more than once"):i instanceof WeakSet?i.add(t):i.set(t,e),b=(t,i,e,n)=>(k(t,i,"write to private field"),i.set(t,e),e),x=(t,i,e)=>(k(t,i,"access private method"),e),u,f,y,v,_,w;let a=class extends V{constructor(){super(...arguments),h(this,v),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.density=0,this.noDivider=!1,h(this,u,!1),h(this,f,!1),h(this,y,!1),this.onRowClick=()=>{if(this.type==="link"&&(this.href||this.itemHref))return;const t=this.shadowRoot?.querySelector("scb-checkbox"),i=this.shadowRoot?.querySelector("scb-switch");t&&(t.checked=!t.checked),i&&(i.selected=!i.selected)},h(this,w,t=>{if(!t.defaultPrevented&&(t.key==="Enter"||t.key===" ")){if(this.type==="link"){const i=this.shadowRoot?.querySelector("a[href]");if(i){t.preventDefault(),i.click();return}}t.preventDefault(),this.onRowClick()}})}static get styles(){return I`
|
|
3
3
|
:host {
|
|
4
4
|
border-bottom: var(--stroke-border, 1px) solid var(--md-sys-color-outline-variant);
|
|
5
5
|
margin-bottom: calc(var(--stroke-border, 1px) * -1);
|
|
@@ -9,6 +9,9 @@ import{_ as m}from"../../vendor/preload-helper.js";import{n as s,t as $,i as V,a
|
|
|
9
9
|
font-family: var(--brand-font);
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
/* Per-item: ingen divider när attributet är satt */
|
|
13
|
+
:host([no-divider]) { --stroke-border: 0px; }
|
|
14
|
+
|
|
12
15
|
md-focus-ring {
|
|
13
16
|
position: absolute;
|
|
14
17
|
inset: 0;
|
|
@@ -93,11 +96,11 @@ import{_ as m}from"../../vendor/preload-helper.js";import{n as s,t as $,i as V,a
|
|
|
93
96
|
|
|
94
97
|
:host([trailing-variant="checkbox"]) .row,
|
|
95
98
|
:host([trailing-variant="switch"]) .row {
|
|
96
|
-
|
|
99
|
+
cursor: pointer;
|
|
97
100
|
}
|
|
98
101
|
|
|
99
102
|
:host([disabled]) .row {
|
|
100
|
-
|
|
103
|
+
cursor: default;
|
|
101
104
|
}
|
|
102
105
|
|
|
103
106
|
.link { text-decoration: none; color: inherit; display: contents; }
|
|
@@ -127,4 +130,4 @@ import{_ as m}from"../../vendor/preload-helper.js";import{n as s,t as $,i as V,a
|
|
|
127
130
|
</div>
|
|
128
131
|
|
|
129
132
|
<md-focus-ring></md-focus-ring>
|
|
130
|
-
`}};u=new WeakMap;f=new WeakMap;y=new WeakMap;v=new WeakSet;_=async function(){const t=this.type==="link"&&(!this.trailing||this.trailingVariant==="icon");(this.leading&&this.leadingVariant==="icon"||this.trailing&&this.trailingVariant==="icon"||t)&&!g(this,u)&&(await m(()=>import("../../vendor/vendor-material.js").then(e=>e.i),__vite__mapDeps([0,1]),import.meta.url),b(this,u,!0)),this.trailing&&this.trailingVariant==="checkbox"&&!g(this,f)&&(await m(()=>import("../scb-checkbox/scb-checkbox.js"),__vite__mapDeps([2,1,0]),import.meta.url),b(this,f,!0)),this.trailing&&this.trailingVariant==="switch"&&!g(this,y)&&(await m(()=>import("../scb-switch/scb-switch.js"),__vite__mapDeps([3,4,1]),import.meta.url),b(this,y,!0))};w=new WeakMap;r([s({type:String,reflect:!0,attribute:"type"})],a.prototype,"type",2);r([s({type:String})],a.prototype,"href",2);r([s({type:String,attribute:"item-href"})],a.prototype,"itemHref",2);r([s({type:String,attribute:"target"})],a.prototype,"target",2);r([s({type:Boolean,attribute:"disabled"})],a.prototype,"disabled",2);r([s({type:String,reflect:!0})],a.prototype,"label",2);r([s({type:String,attribute:"supporting-text"})],a.prototype,"supportingText",2);r([s({type:String,attribute:"overline"})],a.prototype,"overline",2);r([s({type:Boolean})],a.prototype,"leading",2);r([s({type:String,attribute:"leading-variant",reflect:!0})],a.prototype,"leadingVariant",2);r([s({type:String,attribute:"leading-icon"})],a.prototype,"leadingIcon",2);r([s({type:String,attribute:"avatar-label"})],a.prototype,"avatarLabel",2);r([s({type:String,attribute:"avatar-alt"})],a.prototype,"avatarAlt",2);r([s({type:String,attribute:"avatar-variant"})],a.prototype,"avatarVariant",2);r([s({type:String,attribute:"avatar-src"})],a.prototype,"avatarSrc",2);r([s({type:String,reflect:!0,attribute:"img-href-image"})],a.prototype,"imgHrefImage",2);r([s({type:Boolean})],a.prototype,"trailing",2);r([s({type:String,attribute:"trailing-variant",reflect:!0})],a.prototype,"trailingVariant",2);r([s({type:String,attribute:"trailing-icon"})],a.prototype,"trailingIcon",2);r([s({type:Number,reflect:!0})],a.prototype,"density",2);a=r([$("scb-list-item")],a);
|
|
133
|
+
`}};u=new WeakMap;f=new WeakMap;y=new WeakMap;v=new WeakSet;_=async function(){const t=this.type==="link"&&(!this.trailing||this.trailingVariant==="icon");(this.leading&&this.leadingVariant==="icon"||this.trailing&&this.trailingVariant==="icon"||t)&&!g(this,u)&&(await m(()=>import("../../vendor/vendor-material.js").then(e=>e.i),__vite__mapDeps([0,1]),import.meta.url),b(this,u,!0)),this.trailing&&this.trailingVariant==="checkbox"&&!g(this,f)&&(await m(()=>import("../scb-checkbox/scb-checkbox.js"),__vite__mapDeps([2,1,0]),import.meta.url),b(this,f,!0)),this.trailing&&this.trailingVariant==="switch"&&!g(this,y)&&(await m(()=>import("../scb-switch/scb-switch.js"),__vite__mapDeps([3,4,1]),import.meta.url),b(this,y,!0))};w=new WeakMap;r([s({type:String,reflect:!0,attribute:"type"})],a.prototype,"type",2);r([s({type:String})],a.prototype,"href",2);r([s({type:String,attribute:"item-href"})],a.prototype,"itemHref",2);r([s({type:String,attribute:"target"})],a.prototype,"target",2);r([s({type:Boolean,attribute:"disabled"})],a.prototype,"disabled",2);r([s({type:String,reflect:!0})],a.prototype,"label",2);r([s({type:String,attribute:"supporting-text"})],a.prototype,"supportingText",2);r([s({type:String,attribute:"overline"})],a.prototype,"overline",2);r([s({type:Boolean})],a.prototype,"leading",2);r([s({type:String,attribute:"leading-variant",reflect:!0})],a.prototype,"leadingVariant",2);r([s({type:String,attribute:"leading-icon"})],a.prototype,"leadingIcon",2);r([s({type:String,attribute:"avatar-label"})],a.prototype,"avatarLabel",2);r([s({type:String,attribute:"avatar-alt"})],a.prototype,"avatarAlt",2);r([s({type:String,attribute:"avatar-variant"})],a.prototype,"avatarVariant",2);r([s({type:String,attribute:"avatar-src"})],a.prototype,"avatarSrc",2);r([s({type:String,reflect:!0,attribute:"img-href-image"})],a.prototype,"imgHrefImage",2);r([s({type:Boolean})],a.prototype,"trailing",2);r([s({type:String,attribute:"trailing-variant",reflect:!0})],a.prototype,"trailingVariant",2);r([s({type:String,attribute:"trailing-icon"})],a.prototype,"trailingIcon",2);r([s({type:Number,reflect:!0})],a.prototype,"density",2);r([s({type:Boolean,attribute:"no-divider",reflect:!0})],a.prototype,"noDivider",2);a=r([$("scb-list-item")],a);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["../../vendor/vendor-material.js","../../vendor/vendor.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{_ as f}from"../../vendor/preload-helper.js";import{a as h,
|
|
2
|
+
import{_ as f}from"../../vendor/preload-helper.js";import{a as h,n as p,b as v,i as m,x as b,t as g}from"../../vendor/vendor.js";import"./scb-list-item.js";import"../../vendor/vendor-material.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(r,s,i){try{customElements.get(r)||t(r,s,i)}catch(a){var o=String(a||"");if(o.indexOf("already been used")===-1&&o.indexOf("NotSupportedError")===-1)throw a}}}}catch{}})();var y=Object.defineProperty,w=Object.getOwnPropertyDescriptor,c=e=>{throw TypeError(e)},l=(e,t,r,s)=>{for(var i=s>1?void 0:s?w(t,r):t,o=e.length-1,a;o>=0;o--)(a=e[o])&&(i=(s?a(t,r,i):a(i))||i);return s&&i&&y(t,r,i),i},_=(e,t,r)=>t.has(e)||c("Cannot "+r),E=(e,t,r)=>(_(e,t,"read from private field"),t.get(e)),A=(e,t,r)=>t.has(e)?c("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),k=(e,t,r,s)=>(_(e,t,"write to private field"),t.set(e,r),r),d;let n=class extends m{constructor(){super(...arguments),A(this,d,!1),this.noDivider=!1,this._onSlotChange=()=>this._setupItems()}async firstUpdated(){E(this,d)||(await f(()=>import("../../vendor/vendor-material.js").then(e=>e.l),__vite__mapDeps([0,1]),import.meta.url),k(this,d,!0)),this._setupItems()}_getItems(){return(this._slotEl?.assignedElements({flatten:!0})??[]).filter(t=>t instanceof HTMLElement)}_setupItems(){this._getItems().forEach((r,s)=>{r.hasAttribute("role")||r.setAttribute("role","listitem"),r.setAttribute("tabindex",s===0?"0":"-1")});const t=this.renderRoot?.querySelector("md-list");t&&!t.hasAttribute("data-kbd")&&(t.setAttribute("data-kbd","true"),t.addEventListener("keydown",r=>this._onKeyDown(r)))}_onKeyDown(e){const t=this._getItems();if(!t.length)return;const r=t.findIndex(i=>i.getAttribute("tabindex")==="0"),s=i=>{const o=(i%t.length+t.length)%t.length;t.forEach(u=>u.setAttribute("tabindex","-1"));const a=t[o];a.setAttribute("tabindex","0"),a.focus()};switch(e.key){case"ArrowDown":case"ArrowRight":e.preventDefault(),s(r<0?0:r+1);break;case"ArrowUp":case"ArrowLeft":e.preventDefault(),s(r<0?0:r-1);break;case"Home":e.preventDefault(),s(0);break;case"End":e.preventDefault(),s(t.length-1);break}}render(){return b`
|
|
3
3
|
<md-list role="list" @slotchange=${this._onSlotChange}>
|
|
4
4
|
<slot></slot>
|
|
5
5
|
</md-list>
|
|
6
|
-
`}};
|
|
6
|
+
`}};d=new WeakMap;n.styles=[h`
|
|
7
7
|
:host {
|
|
8
8
|
display: block;
|
|
9
9
|
--scb-list-bg: var(--md-sys-color-surface-container-lowest);
|
|
@@ -13,7 +13,14 @@ import{_ as f}from"../../vendor/preload-helper.js";import{a as h,b as p,i as m,x
|
|
|
13
13
|
background: var(--scb-list-bg);
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
/* Visa top-border på första raden endast när listan saknar no-divider
|
|
17
|
+
och endast om första item inte själv är markerad med no-divider. */
|
|
18
|
+
:host(:not([no-divider])) ::slotted(scb-list-item:first-of-type:not([no-divider])) {
|
|
17
19
|
border-top: 1px solid var(--md-sys-color-outline-variant);
|
|
18
20
|
}
|
|
19
|
-
|
|
21
|
+
|
|
22
|
+
/* När listan har no-divider, tryck ned variabeln till alla barn */
|
|
23
|
+
:host([no-divider]) ::slotted(scb-list-item) {
|
|
24
|
+
--stroke-border: 0px;
|
|
25
|
+
}
|
|
26
|
+
`];l([p({type:Boolean,attribute:"no-divider",reflect:!0})],n.prototype,"noDivider",2);l([v("slot")],n.prototype,"_slotEl",2);n=l([g("scb-list")],n);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "scb-wc-test",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.22",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.js",
|
|
@@ -277,5 +277,5 @@
|
|
|
277
277
|
},
|
|
278
278
|
"./mvc/*": "./mvc/*"
|
|
279
279
|
},
|
|
280
|
-
"buildHash": "
|
|
280
|
+
"buildHash": "D27E7601EBCF8143663394290D72984E6AE3B85033B2B0CAEB0FFB1E11A495BA"
|
|
281
281
|
}
|
|
@@ -21,6 +21,7 @@ export declare class ScbListItem extends LitElement {
|
|
|
21
21
|
trailingVariant: '' | 'icon' | 'checkbox' | 'switch';
|
|
22
22
|
trailingIcon: string;
|
|
23
23
|
density: -4 | -2 | 0;
|
|
24
|
+
noDivider: boolean;
|
|
24
25
|
static get styles(): import('lit').CSSResult;
|
|
25
26
|
protected firstUpdated(): Promise<void>;
|
|
26
27
|
protected updated(changed: PropertyValues): void;
|
|
@@ -11,7 +11,7 @@ var I = Object.defineProperty, L = Object.getOwnPropertyDescriptor, _ = (t) => {
|
|
|
11
11
|
}, w = (t, i, e) => i.has(t) || _("Cannot " + e), g = (t, i, e) => (w(t, i, "read from private field"), e ? e.call(t) : i.get(t)), h = (t, i, e) => i.has(t) ? _("Cannot add the same private member more than once") : i instanceof WeakSet ? i.add(t) : i.set(t, e), m = (t, i, e, n) => (w(t, i, "write to private field"), i.set(t, e), e), x = (t, i, e) => (w(t, i, "access private method"), e), y, f, u, v, b, k;
|
|
12
12
|
let a = class extends S {
|
|
13
13
|
constructor() {
|
|
14
|
-
super(...arguments), h(this, v), 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.density = 0, h(this, y, !1), h(this, f, !1), h(this, u, !1), this.onRowClick = () => {
|
|
14
|
+
super(...arguments), h(this, v), 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.density = 0, this.noDivider = !1, h(this, y, !1), h(this, f, !1), h(this, u, !1), this.onRowClick = () => {
|
|
15
15
|
var e, n;
|
|
16
16
|
if (this.type === "link" && (this.href || this.itemHref)) return;
|
|
17
17
|
const t = (e = this.shadowRoot) == null ? void 0 : e.querySelector("scb-checkbox"), i = (n = this.shadowRoot) == null ? void 0 : n.querySelector("scb-switch");
|
|
@@ -41,6 +41,9 @@ let a = class extends S {
|
|
|
41
41
|
font-family: var(--brand-font);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
/* Per-item: ingen divider när attributet är satt */
|
|
45
|
+
:host([no-divider]) { --stroke-border: 0px; }
|
|
46
|
+
|
|
44
47
|
md-focus-ring {
|
|
45
48
|
position: absolute;
|
|
46
49
|
inset: 0;
|
|
@@ -125,11 +128,11 @@ let a = class extends S {
|
|
|
125
128
|
|
|
126
129
|
:host([trailing-variant="checkbox"]) .row,
|
|
127
130
|
:host([trailing-variant="switch"]) .row {
|
|
128
|
-
|
|
131
|
+
cursor: pointer;
|
|
129
132
|
}
|
|
130
133
|
|
|
131
134
|
:host([disabled]) .row {
|
|
132
|
-
|
|
135
|
+
cursor: default;
|
|
133
136
|
}
|
|
134
137
|
|
|
135
138
|
.link { text-decoration: none; color: inherit; display: contents; }
|
|
@@ -260,6 +263,9 @@ r([
|
|
|
260
263
|
r([
|
|
261
264
|
s({ type: Number, reflect: !0 })
|
|
262
265
|
], a.prototype, "density", 2);
|
|
266
|
+
r([
|
|
267
|
+
s({ type: Boolean, attribute: "no-divider", reflect: !0 })
|
|
268
|
+
], a.prototype, "noDivider", 2);
|
|
263
269
|
a = r([
|
|
264
270
|
V("scb-list-item")
|
|
265
271
|
], a);
|
package/scb-list/scb-list.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { LitElement, TemplateResult } from 'lit';
|
|
2
2
|
export declare class ScbList extends LitElement {
|
|
3
3
|
#private;
|
|
4
|
+
noDivider: boolean;
|
|
4
5
|
private _slotEl;
|
|
5
6
|
protected firstUpdated(): Promise<void>;
|
|
6
7
|
private _onSlotChange;
|
|
@@ -10,3 +11,8 @@ export declare class ScbList extends LitElement {
|
|
|
10
11
|
static styles: import('lit').CSSResult[];
|
|
11
12
|
render(): TemplateResult;
|
|
12
13
|
}
|
|
14
|
+
declare global {
|
|
15
|
+
interface HTMLElementTagNameMap {
|
|
16
|
+
'scb-list': ScbList;
|
|
17
|
+
}
|
|
18
|
+
}
|
package/scb-list/scb-list.js
CHANGED
|
@@ -1,69 +1,69 @@
|
|
|
1
|
-
import { css as
|
|
2
|
-
import {
|
|
1
|
+
import { css as v, LitElement as f, html as u } from "lit";
|
|
2
|
+
import { property as m, query as _, customElement as b } from "lit/decorators.js";
|
|
3
3
|
import "./scb-list-item.js";
|
|
4
|
-
var g = Object.defineProperty,
|
|
4
|
+
var g = Object.defineProperty, y = Object.getOwnPropertyDescriptor, c = (e) => {
|
|
5
5
|
throw TypeError(e);
|
|
6
|
-
},
|
|
7
|
-
for (var
|
|
8
|
-
(
|
|
9
|
-
return
|
|
10
|
-
},
|
|
11
|
-
let
|
|
6
|
+
}, l = (e, t, r, s) => {
|
|
7
|
+
for (var i = s > 1 ? void 0 : s ? y(t, r) : t, a = e.length - 1, o; a >= 0; a--)
|
|
8
|
+
(o = e[a]) && (i = (s ? o(t, r, i) : o(i)) || i);
|
|
9
|
+
return s && i && g(t, r, i), i;
|
|
10
|
+
}, p = (e, t, r) => t.has(e) || c("Cannot " + r), w = (e, t, r) => (p(e, t, "read from private field"), t.get(e)), A = (e, t, r) => t.has(e) ? c("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, r), k = (e, t, r, s) => (p(e, t, "write to private field"), t.set(e, r), r), d;
|
|
11
|
+
let n = class extends f {
|
|
12
12
|
constructor() {
|
|
13
|
-
super(...arguments),
|
|
13
|
+
super(...arguments), A(this, d, !1), this.noDivider = !1, this._onSlotChange = () => this._setupItems();
|
|
14
14
|
}
|
|
15
15
|
async firstUpdated() {
|
|
16
|
-
w(this,
|
|
16
|
+
w(this, d) || (await import("@material/web/list/list.js"), k(this, d, !0)), this._setupItems();
|
|
17
17
|
}
|
|
18
18
|
_getItems() {
|
|
19
19
|
var t;
|
|
20
|
-
return (((t = this._slotEl) == null ? void 0 : t.assignedElements({ flatten: !0 })) ?? []).filter((
|
|
20
|
+
return (((t = this._slotEl) == null ? void 0 : t.assignedElements({ flatten: !0 })) ?? []).filter((r) => r instanceof HTMLElement);
|
|
21
21
|
}
|
|
22
22
|
_setupItems() {
|
|
23
|
-
var
|
|
24
|
-
this._getItems().forEach((
|
|
25
|
-
|
|
23
|
+
var r;
|
|
24
|
+
this._getItems().forEach((s, i) => {
|
|
25
|
+
s.hasAttribute("role") || s.setAttribute("role", "listitem"), s.setAttribute("tabindex", i === 0 ? "0" : "-1");
|
|
26
26
|
});
|
|
27
|
-
const t = (
|
|
28
|
-
t && !t.hasAttribute("data-kbd") && (t.setAttribute("data-kbd", "true"), t.addEventListener("keydown", (
|
|
27
|
+
const t = (r = this.renderRoot) == null ? void 0 : r.querySelector("md-list");
|
|
28
|
+
t && !t.hasAttribute("data-kbd") && (t.setAttribute("data-kbd", "true"), t.addEventListener("keydown", (s) => this._onKeyDown(s)));
|
|
29
29
|
}
|
|
30
30
|
_onKeyDown(e) {
|
|
31
31
|
const t = this._getItems();
|
|
32
32
|
if (!t.length) return;
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
t.forEach((
|
|
36
|
-
const
|
|
37
|
-
|
|
33
|
+
const r = t.findIndex((i) => i.getAttribute("tabindex") === "0"), s = (i) => {
|
|
34
|
+
const a = (i % t.length + t.length) % t.length;
|
|
35
|
+
t.forEach((h) => h.setAttribute("tabindex", "-1"));
|
|
36
|
+
const o = t[a];
|
|
37
|
+
o.setAttribute("tabindex", "0"), o.focus();
|
|
38
38
|
};
|
|
39
39
|
switch (e.key) {
|
|
40
40
|
case "ArrowDown":
|
|
41
41
|
case "ArrowRight":
|
|
42
|
-
e.preventDefault(), r
|
|
42
|
+
e.preventDefault(), s(r < 0 ? 0 : r + 1);
|
|
43
43
|
break;
|
|
44
44
|
case "ArrowUp":
|
|
45
45
|
case "ArrowLeft":
|
|
46
|
-
e.preventDefault(), r
|
|
46
|
+
e.preventDefault(), s(r < 0 ? 0 : r - 1);
|
|
47
47
|
break;
|
|
48
48
|
case "Home":
|
|
49
|
-
e.preventDefault(),
|
|
49
|
+
e.preventDefault(), s(0);
|
|
50
50
|
break;
|
|
51
51
|
case "End":
|
|
52
|
-
e.preventDefault(),
|
|
52
|
+
e.preventDefault(), s(t.length - 1);
|
|
53
53
|
break;
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
render() {
|
|
57
|
-
return
|
|
57
|
+
return u`
|
|
58
58
|
<md-list role="list" @slotchange=${this._onSlotChange}>
|
|
59
59
|
<slot></slot>
|
|
60
60
|
</md-list>
|
|
61
61
|
`;
|
|
62
62
|
}
|
|
63
63
|
};
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
d = /* @__PURE__ */ new WeakMap();
|
|
65
|
+
n.styles = [
|
|
66
|
+
v`
|
|
67
67
|
:host {
|
|
68
68
|
display: block;
|
|
69
69
|
--scb-list-bg: var(--md-sys-color-surface-container-lowest);
|
|
@@ -73,17 +73,27 @@ l.styles = [
|
|
|
73
73
|
background: var(--scb-list-bg);
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
/* Visa top-border på första raden endast när listan saknar no-divider
|
|
77
|
+
och endast om första item inte själv är markerad med no-divider. */
|
|
78
|
+
:host(:not([no-divider])) ::slotted(scb-list-item:first-of-type:not([no-divider])) {
|
|
77
79
|
border-top: 1px solid var(--md-sys-color-outline-variant);
|
|
78
80
|
}
|
|
81
|
+
|
|
82
|
+
/* När listan har no-divider, tryck ned variabeln till alla barn */
|
|
83
|
+
:host([no-divider]) ::slotted(scb-list-item) {
|
|
84
|
+
--stroke-border: 0px;
|
|
85
|
+
}
|
|
79
86
|
`
|
|
80
87
|
];
|
|
81
|
-
|
|
82
|
-
m("
|
|
83
|
-
],
|
|
84
|
-
l
|
|
85
|
-
|
|
86
|
-
],
|
|
88
|
+
l([
|
|
89
|
+
m({ type: Boolean, attribute: "no-divider", reflect: !0 })
|
|
90
|
+
], n.prototype, "noDivider", 2);
|
|
91
|
+
l([
|
|
92
|
+
_("slot")
|
|
93
|
+
], n.prototype, "_slotEl", 2);
|
|
94
|
+
n = l([
|
|
95
|
+
b("scb-list")
|
|
96
|
+
], n);
|
|
87
97
|
export {
|
|
88
|
-
|
|
98
|
+
n as ScbList
|
|
89
99
|
};
|