scb-wc 0.1.69 → 0.1.70
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{_ as m,b as f,g as v,h as n,v as _,y as b}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import{t as r}from"../../vendor/decorate.js";import{n as z,t as y}from"../../vendor/assertClassBrand.js";import"../scb-divider/scb-divider.js";import"./scb-menu-item.js";import"./scb-menu-section.js";import"./scb-sub-menu.js";(function(){try{var c=typeof globalThis<"u"?globalThis:window;if(!c.__scb_ce_guard_installed__){c.__scb_ce_guard_installed__=!0;var e=customElements.define.bind(customElements);customElements.define=function(t,i,a){try{customElements.get(t)||e(t,i,a)}catch(o){var l=String(o||"");if(l.indexOf("already been used")===-1&&l.indexOf("NotSupportedError")===-1)throw o}}}}catch{}})();var h,u,s=(h=new WeakSet,u=class extends m{constructor(...e){super(...e),z(this,h),this.label="",this.subLabel="",this.noHighlightSelected=!1,this.lazySrc="",this.lazyIdParam="id",this.lazyChildrenField="",this.lazyIdField="id",this.lazyLabelField="label",this.lazyHrefField="href",this.lazyHasChildrenField="hasChildren",this.lazyHasLinkField="hasLink",this.spacing=void 0,this.spacingTop=void 0,this.spacingBottom=void 0,this.spacingLeft=void 0,this.spacingRight=void 0,this._lazyCache=new Map,this._onGlobalSelect=t=>{const i=t;this.querySelectorAll("scb-menu-item").forEach(a=>{a.selected=!1,this.noHighlightSelected?a.setAttribute("no-highlight-selected",""):a.removeAttribute("no-highlight-selected")}),this.contains(i.detail.item)&&(i.detail.item.selected=!0)},this._onMenuExpand=t=>{this._loadLazyChildren(t)}}render(){return b`
|
|
1
|
+
import{_ as m,b as f,g as v,h as n,v as _,y as b}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import{t as r}from"../../vendor/decorate.js";import{n as z,t as y}from"../../vendor/assertClassBrand.js";import"../scb-divider/scb-divider.js";import"./scb-menu-item.js";import"./scb-menu-section.js";import"./scb-sub-menu.js";(function(){try{var c=typeof globalThis<"u"?globalThis:window;if(!c.__scb_ce_guard_installed__){c.__scb_ce_guard_installed__=!0;var e=customElements.define.bind(customElements);customElements.define=function(t,i,a){try{customElements.get(t)||e(t,i,a)}catch(o){var l=String(o||"");if(l.indexOf("already been used")===-1&&l.indexOf("NotSupportedError")===-1)throw o}}}}catch{}})();var h,u,s=(h=new WeakSet,u=class extends m{constructor(...e){super(...e),z(this,h),this.label="",this.subLabel="",this.noHighlightSelected=!1,this.elevation=!1,this.lazySrc="",this.lazyIdParam="id",this.lazyChildrenField="",this.lazyIdField="id",this.lazyLabelField="label",this.lazyHrefField="href",this.lazyHasChildrenField="hasChildren",this.lazyHasLinkField="hasLink",this.spacing=void 0,this.spacingTop=void 0,this.spacingBottom=void 0,this.spacingLeft=void 0,this.spacingRight=void 0,this._lazyCache=new Map,this._onGlobalSelect=t=>{const i=t;this.querySelectorAll("scb-menu-item").forEach(a=>{a.selected=!1,this.noHighlightSelected?a.setAttribute("no-highlight-selected",""):a.removeAttribute("no-highlight-selected")}),this.contains(i.detail.item)&&(i.detail.item.selected=!0)},this._onMenuExpand=t=>{this._loadLazyChildren(t)}}render(){return b`
|
|
2
2
|
<nav
|
|
3
3
|
aria-label="${this.label}"
|
|
4
4
|
>
|
|
@@ -20,7 +20,7 @@ import{_ as m,b as f,g as v,h as n,v as _,y as b}from"../../vendor/vendor.js";im
|
|
|
20
20
|
display: block;
|
|
21
21
|
color: var(--md-sys-color-on-surface);
|
|
22
22
|
padding: var(--spacing-4, 12px);
|
|
23
|
-
background: var(--scb-menu-background, var(--md-sys-color-surface-container));
|
|
23
|
+
background: var(--scb-menu-background, var(--md-sys-color-surface-container-low));
|
|
24
24
|
font-family: var(--brand-font);
|
|
25
25
|
|
|
26
26
|
margin-block-start: var(--scb-menu-spacing-block-start, 0);
|
|
@@ -28,6 +28,11 @@ import{_ as m,b as f,g as v,h as n,v as _,y as b}from"../../vendor/vendor.js";im
|
|
|
28
28
|
margin-inline-start: var(--scb-menu-spacing-inline-start, 0);
|
|
29
29
|
margin-inline-end: var(--scb-menu-spacing-inline-end, 0);
|
|
30
30
|
}
|
|
31
|
+
|
|
32
|
+
:host([elevation]) {
|
|
33
|
+
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.30), 0 2px 6px 2px rgba(0, 0, 0, 0.15);
|
|
34
|
+
border-radius: 0 var(--radius-Large, 16px) var(--radius-Large, 16px) 0;
|
|
35
|
+
}
|
|
31
36
|
|
|
32
37
|
.scb-menu-label {
|
|
33
38
|
font-size: var(--md-sys-typescale-label-large-size);
|
|
@@ -78,4 +83,4 @@ import{_ as m,b as f,g as v,h as n,v as _,y as b}from"../../vendor/vendor.js";im
|
|
|
78
83
|
.panel {
|
|
79
84
|
contain: layout paint style;
|
|
80
85
|
}
|
|
81
|
-
`,u);function g(){const c=this.mapSpacingToken(this.spacing),e=this.mapSpacingToken(this.spacingTop)??c,t=this.mapSpacingToken(this.spacingBottom)??c,i=this.mapSpacingToken(this.spacingLeft),a=this.mapSpacingToken(this.spacingRight);e?this.style.setProperty("--scb-menu-spacing-block-start",e):this.style.removeProperty("--scb-menu-spacing-block-start"),t?this.style.setProperty("--scb-menu-spacing-block-end",t):this.style.removeProperty("--scb-menu-spacing-block-end"),i?this.style.setProperty("--scb-menu-spacing-inline-start",i):this.style.removeProperty("--scb-menu-spacing-inline-start"),a?this.style.setProperty("--scb-menu-spacing-inline-end",a):this.style.removeProperty("--scb-menu-spacing-inline-end")}r([n({type:String})],s.prototype,"label",void 0);r([n({type:String,attribute:"sub-label"})],s.prototype,"subLabel",void 0);r([n({type:Boolean,attribute:"no-highlight-selected",reflect:!0})],s.prototype,"noHighlightSelected",void 0);r([n({type:String,attribute:"lazy-src"})],s.prototype,"lazySrc",void 0);r([n({type:String,attribute:"lazy-id-param"})],s.prototype,"lazyIdParam",void 0);r([n({type:String,attribute:"lazy-children-field"})],s.prototype,"lazyChildrenField",void 0);r([n({type:String,attribute:"lazy-id-field"})],s.prototype,"lazyIdField",void 0);r([n({type:String,attribute:"lazy-label-field"})],s.prototype,"lazyLabelField",void 0);r([n({type:String,attribute:"lazy-href-field"})],s.prototype,"lazyHrefField",void 0);r([n({type:String,attribute:"lazy-has-children-field"})],s.prototype,"lazyHasChildrenField",void 0);r([n({type:String,attribute:"lazy-has-link-field"})],s.prototype,"lazyHasLinkField",void 0);r([n({type:String,reflect:!0})],s.prototype,"spacing",void 0);r([n({type:String,attribute:"spacing-top",reflect:!0})],s.prototype,"spacingTop",void 0);r([n({type:String,attribute:"spacing-bottom",reflect:!0})],s.prototype,"spacingBottom",void 0);r([n({type:String,attribute:"spacing-left",reflect:!0})],s.prototype,"spacingLeft",void 0);r([n({type:String,attribute:"spacing-right",reflect:!0})],s.prototype,"spacingRight",void 0);s=r([v("scb-menu")],s);export{s as ScbMenu};
|
|
86
|
+
`,u);function g(){const c=this.mapSpacingToken(this.spacing),e=this.mapSpacingToken(this.spacingTop)??c,t=this.mapSpacingToken(this.spacingBottom)??c,i=this.mapSpacingToken(this.spacingLeft),a=this.mapSpacingToken(this.spacingRight);e?this.style.setProperty("--scb-menu-spacing-block-start",e):this.style.removeProperty("--scb-menu-spacing-block-start"),t?this.style.setProperty("--scb-menu-spacing-block-end",t):this.style.removeProperty("--scb-menu-spacing-block-end"),i?this.style.setProperty("--scb-menu-spacing-inline-start",i):this.style.removeProperty("--scb-menu-spacing-inline-start"),a?this.style.setProperty("--scb-menu-spacing-inline-end",a):this.style.removeProperty("--scb-menu-spacing-inline-end")}r([n({type:String})],s.prototype,"label",void 0);r([n({type:String,attribute:"sub-label"})],s.prototype,"subLabel",void 0);r([n({type:Boolean,attribute:"no-highlight-selected",reflect:!0})],s.prototype,"noHighlightSelected",void 0);r([n({type:Boolean,reflect:!0})],s.prototype,"elevation",void 0);r([n({type:String,attribute:"lazy-src"})],s.prototype,"lazySrc",void 0);r([n({type:String,attribute:"lazy-id-param"})],s.prototype,"lazyIdParam",void 0);r([n({type:String,attribute:"lazy-children-field"})],s.prototype,"lazyChildrenField",void 0);r([n({type:String,attribute:"lazy-id-field"})],s.prototype,"lazyIdField",void 0);r([n({type:String,attribute:"lazy-label-field"})],s.prototype,"lazyLabelField",void 0);r([n({type:String,attribute:"lazy-href-field"})],s.prototype,"lazyHrefField",void 0);r([n({type:String,attribute:"lazy-has-children-field"})],s.prototype,"lazyHasChildrenField",void 0);r([n({type:String,attribute:"lazy-has-link-field"})],s.prototype,"lazyHasLinkField",void 0);r([n({type:String,reflect:!0})],s.prototype,"spacing",void 0);r([n({type:String,attribute:"spacing-top",reflect:!0})],s.prototype,"spacingTop",void 0);r([n({type:String,attribute:"spacing-bottom",reflect:!0})],s.prototype,"spacingBottom",void 0);r([n({type:String,attribute:"spacing-left",reflect:!0})],s.prototype,"spacingLeft",void 0);r([n({type:String,attribute:"spacing-right",reflect:!0})],s.prototype,"spacingRight",void 0);s=r([v("scb-menu")],s);export{s as ScbMenu};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "scb-wc",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.70",
|
|
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": "9F9D3CF4A7D9265669D7F18EB0DCCAFDA885D7DD64BF6E63A24022FE7F6D764D"
|
|
464
464
|
}
|
|
@@ -4,6 +4,7 @@ export declare class ScbMenu extends LitElement {
|
|
|
4
4
|
label: string;
|
|
5
5
|
subLabel: string;
|
|
6
6
|
noHighlightSelected: boolean;
|
|
7
|
+
elevation: boolean;
|
|
7
8
|
/**
|
|
8
9
|
* Endpoint för lazy-laddade barn. När den är satt hämtar menyn barn
|
|
9
10
|
* för scb-menu-item[data-node-id][has-children] när itemet expanderas.
|
package/scb-menu/scb-menu.js
CHANGED
|
@@ -8,7 +8,7 @@ import { customElement as a, property as o } from "lit/decorators.js";
|
|
|
8
8
|
//#region src/scb-components/scb-menu/scb-menu.ts
|
|
9
9
|
var s = class extends t {
|
|
10
10
|
constructor(...e) {
|
|
11
|
-
super(...e), this.label = "", this.subLabel = "", this.noHighlightSelected = !1, this.lazySrc = "", this.lazyIdParam = "id", this.lazyChildrenField = "", this.lazyIdField = "id", this.lazyLabelField = "label", this.lazyHrefField = "href", this.lazyHasChildrenField = "hasChildren", this.lazyHasLinkField = "hasLink", this.spacing = void 0, this.spacingTop = void 0, this.spacingBottom = void 0, this.spacingLeft = void 0, this.spacingRight = void 0, this._lazyCache = /* @__PURE__ */ new Map(), this._onGlobalSelect = (e) => {
|
|
11
|
+
super(...e), this.label = "", this.subLabel = "", this.noHighlightSelected = !1, this.elevation = !1, this.lazySrc = "", this.lazyIdParam = "id", this.lazyChildrenField = "", this.lazyIdField = "id", this.lazyLabelField = "label", this.lazyHrefField = "href", this.lazyHasChildrenField = "hasChildren", this.lazyHasLinkField = "hasLink", this.spacing = void 0, this.spacingTop = void 0, this.spacingBottom = void 0, this.spacingLeft = void 0, this.spacingRight = void 0, this._lazyCache = /* @__PURE__ */ new Map(), this._onGlobalSelect = (e) => {
|
|
12
12
|
let t = e;
|
|
13
13
|
this.querySelectorAll("scb-menu-item").forEach((e) => {
|
|
14
14
|
e.selected = !1, this.noHighlightSelected ? e.setAttribute("no-highlight-selected", "") : e.removeAttribute("no-highlight-selected");
|
|
@@ -23,7 +23,7 @@ var s = class extends t {
|
|
|
23
23
|
display: block;
|
|
24
24
|
color: var(--md-sys-color-on-surface);
|
|
25
25
|
padding: var(--spacing-4, 12px);
|
|
26
|
-
background: var(--scb-menu-background, var(--md-sys-color-surface-container));
|
|
26
|
+
background: var(--scb-menu-background, var(--md-sys-color-surface-container-low));
|
|
27
27
|
font-family: var(--brand-font);
|
|
28
28
|
|
|
29
29
|
margin-block-start: var(--scb-menu-spacing-block-start, 0);
|
|
@@ -31,6 +31,11 @@ var s = class extends t {
|
|
|
31
31
|
margin-inline-start: var(--scb-menu-spacing-inline-start, 0);
|
|
32
32
|
margin-inline-end: var(--scb-menu-spacing-inline-end, 0);
|
|
33
33
|
}
|
|
34
|
+
|
|
35
|
+
:host([elevation]) {
|
|
36
|
+
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.30), 0 2px 6px 2px rgba(0, 0, 0, 0.15);
|
|
37
|
+
border-radius: 0 var(--radius-Large, 16px) var(--radius-Large, 16px) 0;
|
|
38
|
+
}
|
|
34
39
|
|
|
35
40
|
.scb-menu-label {
|
|
36
41
|
font-size: var(--md-sys-typescale-label-large-size);
|
|
@@ -230,6 +235,9 @@ e([o({ type: String })], s.prototype, "label", void 0), e([o({
|
|
|
230
235
|
attribute: "no-highlight-selected",
|
|
231
236
|
reflect: !0
|
|
232
237
|
})], s.prototype, "noHighlightSelected", void 0), e([o({
|
|
238
|
+
type: Boolean,
|
|
239
|
+
reflect: !0
|
|
240
|
+
})], s.prototype, "elevation", void 0), e([o({
|
|
233
241
|
type: String,
|
|
234
242
|
attribute: "lazy-src"
|
|
235
243
|
})], s.prototype, "lazySrc", void 0), e([o({
|
package/scb-wc.bundle.js
CHANGED
|
@@ -8788,12 +8788,12 @@
|
|
|
8788
8788
|
<nav aria-label="${this.label}">
|
|
8789
8789
|
<slot></slot>
|
|
8790
8790
|
</nav>
|
|
8791
|
-
`}},P([g({type:String})],pu.prototype,`label`,void 0),pu=P([a(`scb-sub-menu`)],pu)})),hu=n({ScbMenu:()=>J}),J,gu=t((()=>{C(),y(),ml(),uu(),fu(),mu(),F(),J=class extends S{constructor(...e){super(...e),this.label=``,this.subLabel=``,this.noHighlightSelected=!1,this.lazySrc=``,this.lazyIdParam=`id`,this.lazyChildrenField=``,this.lazyIdField=`id`,this.lazyLabelField=`label`,this.lazyHrefField=`href`,this.lazyHasChildrenField=`hasChildren`,this.lazyHasLinkField=`hasLink`,this.spacing=void 0,this.spacingTop=void 0,this.spacingBottom=void 0,this.spacingLeft=void 0,this.spacingRight=void 0,this._lazyCache=new Map,this._onGlobalSelect=e=>{let t=e;this.querySelectorAll(`scb-menu-item`).forEach(e=>{e.selected=!1,this.noHighlightSelected?e.setAttribute(`no-highlight-selected`,``):e.removeAttribute(`no-highlight-selected`)}),this.contains(t.detail.item)&&(t.detail.item.selected=!0)},this._onMenuExpand=e=>{this._loadLazyChildren(e)}}static{this.styles=p`
|
|
8791
|
+
`}},P([g({type:String})],pu.prototype,`label`,void 0),pu=P([a(`scb-sub-menu`)],pu)})),hu=n({ScbMenu:()=>J}),J,gu=t((()=>{C(),y(),ml(),uu(),fu(),mu(),F(),J=class extends S{constructor(...e){super(...e),this.label=``,this.subLabel=``,this.noHighlightSelected=!1,this.elevation=!1,this.lazySrc=``,this.lazyIdParam=`id`,this.lazyChildrenField=``,this.lazyIdField=`id`,this.lazyLabelField=`label`,this.lazyHrefField=`href`,this.lazyHasChildrenField=`hasChildren`,this.lazyHasLinkField=`hasLink`,this.spacing=void 0,this.spacingTop=void 0,this.spacingBottom=void 0,this.spacingLeft=void 0,this.spacingRight=void 0,this._lazyCache=new Map,this._onGlobalSelect=e=>{let t=e;this.querySelectorAll(`scb-menu-item`).forEach(e=>{e.selected=!1,this.noHighlightSelected?e.setAttribute(`no-highlight-selected`,``):e.removeAttribute(`no-highlight-selected`)}),this.contains(t.detail.item)&&(t.detail.item.selected=!0)},this._onMenuExpand=e=>{this._loadLazyChildren(e)}}static{this.styles=p`
|
|
8792
8792
|
:host {
|
|
8793
8793
|
display: block;
|
|
8794
8794
|
color: var(--md-sys-color-on-surface);
|
|
8795
8795
|
padding: var(--spacing-4, 12px);
|
|
8796
|
-
background: var(--scb-menu-background, var(--md-sys-color-surface-container));
|
|
8796
|
+
background: var(--scb-menu-background, var(--md-sys-color-surface-container-low));
|
|
8797
8797
|
font-family: var(--brand-font);
|
|
8798
8798
|
|
|
8799
8799
|
margin-block-start: var(--scb-menu-spacing-block-start, 0);
|
|
@@ -8801,6 +8801,11 @@
|
|
|
8801
8801
|
margin-inline-start: var(--scb-menu-spacing-inline-start, 0);
|
|
8802
8802
|
margin-inline-end: var(--scb-menu-spacing-inline-end, 0);
|
|
8803
8803
|
}
|
|
8804
|
+
|
|
8805
|
+
:host([elevation]) {
|
|
8806
|
+
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.30), 0 2px 6px 2px rgba(0, 0, 0, 0.15);
|
|
8807
|
+
border-radius: 0 var(--radius-Large, 16px) var(--radius-Large, 16px) 0;
|
|
8808
|
+
}
|
|
8804
8809
|
|
|
8805
8810
|
.scb-menu-label {
|
|
8806
8811
|
font-size: var(--md-sys-typescale-label-large-size);
|
|
@@ -8868,7 +8873,7 @@
|
|
|
8868
8873
|
<slot></slot>
|
|
8869
8874
|
</div>
|
|
8870
8875
|
</nav>
|
|
8871
|
-
`}firstUpdated(e){super.firstUpdated(e),this.#e()}updated(e){super.updated(e),(e.has(`spacing`)||e.has(`spacingTop`)||e.has(`spacingBottom`)||e.has(`spacingLeft`)||e.has(`spacingRight`))&&this.#e()}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}#e(){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.setProperty(`--scb-menu-spacing-block-start`,t):this.style.removeProperty(`--scb-menu-spacing-block-start`),n?this.style.setProperty(`--scb-menu-spacing-block-end`,n):this.style.removeProperty(`--scb-menu-spacing-block-end`),r?this.style.setProperty(`--scb-menu-spacing-inline-start`,r):this.style.removeProperty(`--scb-menu-spacing-inline-start`),i?this.style.setProperty(`--scb-menu-spacing-inline-end`,i):this.style.removeProperty(`--scb-menu-spacing-inline-end`)}connectedCallback(){super.connectedCallback(),window.addEventListener(`scb-menu-select`,this._onGlobalSelect),this.addEventListener(`scb-menu-expand`,this._onMenuExpand)}disconnectedCallback(){window.removeEventListener(`scb-menu-select`,this._onGlobalSelect),this.removeEventListener(`scb-menu-expand`,this._onMenuExpand),super.disconnectedCallback()}async _loadLazyChildren(e){if(!this.lazySrc)return;let t=e.detail?.item;if(!t||!this.contains(t)||!e.detail?.expanded||t.hasAttribute(`data-loaded`)||!t.hasAttribute(`has-children`)||e.detail?.lazy===!1||this._hasSubMenu(t))return;let n=t.getAttribute(`data-node-id`)??t.dataset.nodeId;if(n){this._setItemLoading(t,!0),t.removeAttribute(`data-load-error`);try{let e=await this._fetchLazyChildren(n),r=this._createSubMenu(t,e);t.appendChild(r),t.setAttribute(`data-loaded`,``),this.dispatchEvent(new CustomEvent(`scb-menu-lazy-load`,{bubbles:!0,composed:!0,detail:{item:t,nodeId:n,children:e}}))}catch(e){t.setAttribute(`data-load-error`,``),this.dispatchEvent(new CustomEvent(`scb-menu-lazy-error`,{bubbles:!0,composed:!0,detail:{item:t,nodeId:n,error:e}}))}finally{this._setItemLoading(t,!1)}}}_setItemLoading(e,t){e.loading=t,e.toggleAttribute(`loading`,t),t?e.setAttribute(`aria-busy`,`true`):e.removeAttribute(`aria-busy`)}_hasSubMenu(e){return Array.from(e.children).some(e=>e.tagName===`SCB-SUB-MENU`)}_createSubMenu(e,t){let n=document.createElement(`scb-sub-menu`);n.setAttribute(`label`,e.getAttribute(`label`)??``);for(let e of t)n.appendChild(this._createLazyMenuItem(e));return n}_createLazyMenuItem(e){let t=document.createElement(`scb-menu-item`),n=this._getRecordValue(e,this.lazyIdField,[`id`,`Id`]),r=this._getRecordValue(e,this.lazyLabelField,[`label`,`Label`,`name`,`Name`]),i=this._getRecordValue(e,this.lazyHrefField,[`href`,`Href`,`url`,`Url`]),a=this._toBoolean(this._getRecordValue(e,this.lazyHasChildrenField,[`hasChildren`,`HasChildren`])),o=this._getRecordValue(e,this.lazyHasLinkField,[`hasLink`,`HasLink`]),s=o==null?!!i:this._toBoolean(o);return r!=null&&t.setAttribute(`label`,String(r)),n!=null&&t.setAttribute(`data-node-id`,String(n)),a&&t.setAttribute(`has-children`,``),s&&i!=null&&String(i).trim()&&t.setAttribute(`item-href`,String(i)),t}async _fetchLazyChildren(e){let t=`${this.lazySrc}|${this.lazyIdParam}|${e}`,n=this._lazyCache.get(t);return n||(n=fetch(this._createLazyUrl(e),{credentials:`same-origin`}).then(async e=>{if(!e.ok)throw Error(`Kunde inte ladda menybarn (${e.status}).`);let t=await e.json();return this._normalizeChildren(t)}).catch(e=>{throw this._lazyCache.delete(t),e}),this._lazyCache.set(t,n)),n}_createLazyUrl(e){if(this.lazySrc.includes(`{id}`))return this.lazySrc.split(`{id}`).join(encodeURIComponent(e));let t=new URL(this.lazySrc,document.baseURI);return this.lazyIdParam&&t.searchParams.set(this.lazyIdParam,e),t.toString()}_normalizeChildren(e){let t=Array.isArray(e)?e:this._getRecordValue(e,this.lazyChildrenField,[`children`,`Children`,`items`,`Items`,`data`,`Data`]);return Array.isArray(t)?t.filter(e=>!!e&&typeof e==`object`&&!Array.isArray(e)):[]}_getRecordValue(e,t,n=[]){if(!e||typeof e!=`object`||Array.isArray(e))return;let r=e,i=[t,...n].filter(Boolean);for(let e of i){if(e in r)return r[e];let t=Object.keys(r).find(t=>t.toLowerCase()===e.toLowerCase());if(t)return r[t]}}_toBoolean(e){return typeof e==`boolean`?e:typeof e==`number`?e!==0:typeof e==`string`?!/^(false|0|off|no|nej)$/i.test(e.trim()):!!e}},P([g({type:String})],J.prototype,`label`,void 0),P([g({type:String,attribute:`sub-label`})],J.prototype,`subLabel`,void 0),P([g({type:Boolean,attribute:`no-highlight-selected`,reflect:!0})],J.prototype,`noHighlightSelected`,void 0),P([g({type:String,attribute:`lazy-src`})],J.prototype,`lazySrc`,void 0),P([g({type:String,attribute:`lazy-id-param`})],J.prototype,`lazyIdParam`,void 0),P([g({type:String,attribute:`lazy-children-field`})],J.prototype,`lazyChildrenField`,void 0),P([g({type:String,attribute:`lazy-id-field`})],J.prototype,`lazyIdField`,void 0),P([g({type:String,attribute:`lazy-label-field`})],J.prototype,`lazyLabelField`,void 0),P([g({type:String,attribute:`lazy-href-field`})],J.prototype,`lazyHrefField`,void 0),P([g({type:String,attribute:`lazy-has-children-field`})],J.prototype,`lazyHasChildrenField`,void 0),P([g({type:String,attribute:`lazy-has-link-field`})],J.prototype,`lazyHasLinkField`,void 0),P([g({type:String,reflect:!0})],J.prototype,`spacing`,void 0),P([g({type:String,attribute:`spacing-top`,reflect:!0})],J.prototype,`spacingTop`,void 0),P([g({type:String,attribute:`spacing-bottom`,reflect:!0})],J.prototype,`spacingBottom`,void 0),P([g({type:String,attribute:`spacing-left`,reflect:!0})],J.prototype,`spacingLeft`,void 0),P([g({type:String,attribute:`spacing-right`,reflect:!0})],J.prototype,`spacingRight`,void 0),J=P([a(`scb-menu`)],J)}));C(),y(),w(),F();var _u,vu=0;(()=>{if(typeof window>`u`||typeof document>`u`||!(`customElements`in window)||document.head.querySelector(`style[data-scb-header-pre-upgrade]`))return;let e=document.createElement(`style`);e.setAttribute(`data-scb-header-pre-upgrade`,``),e.textContent=`
|
|
8876
|
+
`}firstUpdated(e){super.firstUpdated(e),this.#e()}updated(e){super.updated(e),(e.has(`spacing`)||e.has(`spacingTop`)||e.has(`spacingBottom`)||e.has(`spacingLeft`)||e.has(`spacingRight`))&&this.#e()}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}#e(){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.setProperty(`--scb-menu-spacing-block-start`,t):this.style.removeProperty(`--scb-menu-spacing-block-start`),n?this.style.setProperty(`--scb-menu-spacing-block-end`,n):this.style.removeProperty(`--scb-menu-spacing-block-end`),r?this.style.setProperty(`--scb-menu-spacing-inline-start`,r):this.style.removeProperty(`--scb-menu-spacing-inline-start`),i?this.style.setProperty(`--scb-menu-spacing-inline-end`,i):this.style.removeProperty(`--scb-menu-spacing-inline-end`)}connectedCallback(){super.connectedCallback(),window.addEventListener(`scb-menu-select`,this._onGlobalSelect),this.addEventListener(`scb-menu-expand`,this._onMenuExpand)}disconnectedCallback(){window.removeEventListener(`scb-menu-select`,this._onGlobalSelect),this.removeEventListener(`scb-menu-expand`,this._onMenuExpand),super.disconnectedCallback()}async _loadLazyChildren(e){if(!this.lazySrc)return;let t=e.detail?.item;if(!t||!this.contains(t)||!e.detail?.expanded||t.hasAttribute(`data-loaded`)||!t.hasAttribute(`has-children`)||e.detail?.lazy===!1||this._hasSubMenu(t))return;let n=t.getAttribute(`data-node-id`)??t.dataset.nodeId;if(n){this._setItemLoading(t,!0),t.removeAttribute(`data-load-error`);try{let e=await this._fetchLazyChildren(n),r=this._createSubMenu(t,e);t.appendChild(r),t.setAttribute(`data-loaded`,``),this.dispatchEvent(new CustomEvent(`scb-menu-lazy-load`,{bubbles:!0,composed:!0,detail:{item:t,nodeId:n,children:e}}))}catch(e){t.setAttribute(`data-load-error`,``),this.dispatchEvent(new CustomEvent(`scb-menu-lazy-error`,{bubbles:!0,composed:!0,detail:{item:t,nodeId:n,error:e}}))}finally{this._setItemLoading(t,!1)}}}_setItemLoading(e,t){e.loading=t,e.toggleAttribute(`loading`,t),t?e.setAttribute(`aria-busy`,`true`):e.removeAttribute(`aria-busy`)}_hasSubMenu(e){return Array.from(e.children).some(e=>e.tagName===`SCB-SUB-MENU`)}_createSubMenu(e,t){let n=document.createElement(`scb-sub-menu`);n.setAttribute(`label`,e.getAttribute(`label`)??``);for(let e of t)n.appendChild(this._createLazyMenuItem(e));return n}_createLazyMenuItem(e){let t=document.createElement(`scb-menu-item`),n=this._getRecordValue(e,this.lazyIdField,[`id`,`Id`]),r=this._getRecordValue(e,this.lazyLabelField,[`label`,`Label`,`name`,`Name`]),i=this._getRecordValue(e,this.lazyHrefField,[`href`,`Href`,`url`,`Url`]),a=this._toBoolean(this._getRecordValue(e,this.lazyHasChildrenField,[`hasChildren`,`HasChildren`])),o=this._getRecordValue(e,this.lazyHasLinkField,[`hasLink`,`HasLink`]),s=o==null?!!i:this._toBoolean(o);return r!=null&&t.setAttribute(`label`,String(r)),n!=null&&t.setAttribute(`data-node-id`,String(n)),a&&t.setAttribute(`has-children`,``),s&&i!=null&&String(i).trim()&&t.setAttribute(`item-href`,String(i)),t}async _fetchLazyChildren(e){let t=`${this.lazySrc}|${this.lazyIdParam}|${e}`,n=this._lazyCache.get(t);return n||(n=fetch(this._createLazyUrl(e),{credentials:`same-origin`}).then(async e=>{if(!e.ok)throw Error(`Kunde inte ladda menybarn (${e.status}).`);let t=await e.json();return this._normalizeChildren(t)}).catch(e=>{throw this._lazyCache.delete(t),e}),this._lazyCache.set(t,n)),n}_createLazyUrl(e){if(this.lazySrc.includes(`{id}`))return this.lazySrc.split(`{id}`).join(encodeURIComponent(e));let t=new URL(this.lazySrc,document.baseURI);return this.lazyIdParam&&t.searchParams.set(this.lazyIdParam,e),t.toString()}_normalizeChildren(e){let t=Array.isArray(e)?e:this._getRecordValue(e,this.lazyChildrenField,[`children`,`Children`,`items`,`Items`,`data`,`Data`]);return Array.isArray(t)?t.filter(e=>!!e&&typeof e==`object`&&!Array.isArray(e)):[]}_getRecordValue(e,t,n=[]){if(!e||typeof e!=`object`||Array.isArray(e))return;let r=e,i=[t,...n].filter(Boolean);for(let e of i){if(e in r)return r[e];let t=Object.keys(r).find(t=>t.toLowerCase()===e.toLowerCase());if(t)return r[t]}}_toBoolean(e){return typeof e==`boolean`?e:typeof e==`number`?e!==0:typeof e==`string`?!/^(false|0|off|no|nej)$/i.test(e.trim()):!!e}},P([g({type:String})],J.prototype,`label`,void 0),P([g({type:String,attribute:`sub-label`})],J.prototype,`subLabel`,void 0),P([g({type:Boolean,attribute:`no-highlight-selected`,reflect:!0})],J.prototype,`noHighlightSelected`,void 0),P([g({type:Boolean,reflect:!0})],J.prototype,`elevation`,void 0),P([g({type:String,attribute:`lazy-src`})],J.prototype,`lazySrc`,void 0),P([g({type:String,attribute:`lazy-id-param`})],J.prototype,`lazyIdParam`,void 0),P([g({type:String,attribute:`lazy-children-field`})],J.prototype,`lazyChildrenField`,void 0),P([g({type:String,attribute:`lazy-id-field`})],J.prototype,`lazyIdField`,void 0),P([g({type:String,attribute:`lazy-label-field`})],J.prototype,`lazyLabelField`,void 0),P([g({type:String,attribute:`lazy-href-field`})],J.prototype,`lazyHrefField`,void 0),P([g({type:String,attribute:`lazy-has-children-field`})],J.prototype,`lazyHasChildrenField`,void 0),P([g({type:String,attribute:`lazy-has-link-field`})],J.prototype,`lazyHasLinkField`,void 0),P([g({type:String,reflect:!0})],J.prototype,`spacing`,void 0),P([g({type:String,attribute:`spacing-top`,reflect:!0})],J.prototype,`spacingTop`,void 0),P([g({type:String,attribute:`spacing-bottom`,reflect:!0})],J.prototype,`spacingBottom`,void 0),P([g({type:String,attribute:`spacing-left`,reflect:!0})],J.prototype,`spacingLeft`,void 0),P([g({type:String,attribute:`spacing-right`,reflect:!0})],J.prototype,`spacingRight`,void 0),J=P([a(`scb-menu`)],J)}));C(),y(),w(),F();var _u,vu=0;(()=>{if(typeof window>`u`||typeof document>`u`||!(`customElements`in window)||document.head.querySelector(`style[data-scb-header-pre-upgrade]`))return;let e=document.createElement(`style`);e.setAttribute(`data-scb-header-pre-upgrade`,``),e.textContent=`
|
|
8872
8877
|
scb-header:not(:defined),
|
|
8873
8878
|
scb-header[data-upgrading] {
|
|
8874
8879
|
display: block;
|