scb-wc-test 0.1.106 → 0.1.107
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-icon-button/scb-icon-button.js +13 -12
- package/mvc/components/scb-segmented-button/scb-segmented-button.js +15 -14
- package/package.json +2 -2
- package/scb-icon-button/scb-icon-button.d.ts +4 -0
- package/scb-icon-button/scb-icon-button.js +46 -39
- package/scb-segmented-button/scb-segmented-button.d.ts +4 -0
- package/scb-segmented-button/scb-segmented-button.js +61 -54
- package/scb-wc-test.bundle.js +149 -147
|
@@ -1,8 +1,8 @@
|
|
|
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 h}from"../../vendor/preload-helper.js";import{a as
|
|
2
|
+
import{_ as h}from"../../vendor/preload-helper.js";import{a as g,n as a,i as m,x as r,t as f}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 e=customElements.define.bind(customElements);customElements.define=function(i,l,n){try{customElements.get(i)||e(i,l,n)}catch(c){var d=String(c||"");if(d.indexOf("already been used")===-1&&d.indexOf("NotSupportedError")===-1)throw c}}}}catch{}})();var v=Object.defineProperty,y=Object.getOwnPropertyDescriptor,b=t=>{throw TypeError(t)},s=(t,e,i,l)=>{for(var n=l>1?void 0:l?y(e,i):e,d=t.length-1,c;d>=0;d--)(c=t[d])&&(n=(l?c(e,i,n):c(n))||n);return l&&n&&v(e,i,n),n},A=(t,e,i)=>e.has(t)||b("Cannot "+i),$=(t,e,i)=>e.has(t)?b("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,i),p=(t,e,i)=>(A(t,e,"access private method"),i),_,u;let o=class extends m{constructor(){super(...arguments),$(this,_),this.icon="home",this.tooltip="",this.ariaLabel="",this.variant="standard",this.toggle=!1,this.selected=!1,this.toggleofficon="add",this.toggleonicon="remove",this.disabled=!1,this.spacing="",this.spacingTop="",this.spacingBottom="",this.__loadedVariants=new Set,this.__iconLoaded=!1,this.__lastMdHost=null,this.__onInnerChange=()=>{const e=!!this.__getMdHost()?.selected;this.toggle&&(this.selected=e),this.dispatchEvent(new CustomEvent("change",{detail:{selected:e},bubbles:!0,composed:!0}))}}async firstUpdated(){await this.__ensureDepsLoaded(),await this.updateComplete,this.__attachChangeListener(),this.__syncTitleAndAria(),p(this,_,u).call(this)}updated(t){if(super.updated(t),(t.has("spacing")||t.has("spacingTop")||t.has("spacingBottom"))&&p(this,_,u).call(this),t.has("variant")){this.__ensureDepsLoaded().then(()=>{queueMicrotask(()=>{this.__attachChangeListener(),this.__syncTitleAndAria()})});return}(t.has("toggle")||t.has("icon")||t.has("toggleofficon")||t.has("toggleonicon")||t.has("selected")||t.has("disabled")||t.has("tooltip")||t.has("ariaLabel"))&&queueMicrotask(()=>{this.__attachChangeListener(),this.__syncTitleAndAria()})}disconnectedCallback(){this.__lastMdHost?.removeEventListener?.("change",this.__onInnerChange),this.__lastMdHost=null,super.disconnectedCallback()}async __ensureDepsLoaded(){if(!this.__loadedVariants.has(this.variant)){switch(this.variant){case"filled":await h(()=>import("../../vendor/vendor-material.js").then(t=>t.f),__vite__mapDeps([0,1]),import.meta.url);break;case"outlined":await h(()=>import("../../vendor/vendor-material.js").then(t=>t.o),__vite__mapDeps([0,1]),import.meta.url);break;case"filled-tonal":await h(()=>import("../../vendor/vendor-material.js").then(t=>t.c),__vite__mapDeps([0,1]),import.meta.url);break;default:await h(()=>import("../../vendor/vendor-material.js").then(t=>t.d),__vite__mapDeps([0,1]),import.meta.url);break}this.__loadedVariants.add(this.variant)}this.__iconLoaded||(await h(()=>import("../../vendor/vendor-material.js").then(t=>t.i),__vite__mapDeps([0,1]),import.meta.url),this.__iconLoaded=!0)}__getMdHost(){return this.renderRoot.querySelector("md-filled-icon-button, md-outlined-icon-button, md-filled-tonal-icon-button, md-icon-button")}__attachChangeListener(){const t=this.__getMdHost();t&&t!==this.__lastMdHost&&(this.__lastMdHost?.removeEventListener?.("change",this.__onInnerChange),t.addEventListener("change",this.__onInnerChange),this.__lastMdHost=t),this.toggle&&t&&"selected"in t&&(t.selected=this.selected)}__syncTitleAndAria(){const t=this.__getMdHost();if(!t)return;const e=(this.tooltip||this.getAttribute("title")||"").trim(),i=(this.ariaLabel||this.getAttribute("aria-label")||"").trim(),l=this.getAttribute("aria-controls"),n=this.getAttribute("aria-expanded");this.tooltip&&this.setAttribute("title",e);const d=i||e||this.icon.trim()||void 0;d?t.setAttribute("aria-label",d):t.removeAttribute("aria-label"),e?t.setAttribute("title",e):t.removeAttribute("title"),l!==null?t.setAttribute("aria-controls",l):t.removeAttribute("aria-controls"),n!==null?t.setAttribute("aria-expanded",n):t.removeAttribute("aria-expanded")}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}__renderToggleIcons(){return r`
|
|
3
3
|
<md-icon aria-hidden="true">${this.toggleofficon}</md-icon>
|
|
4
4
|
<md-icon slot="selected" aria-hidden="true">${this.toggleonicon}</md-icon>
|
|
5
|
-
`}__renderSingleIcon(){return
|
|
5
|
+
`}__renderSingleIcon(){return r`<md-icon aria-hidden="true">${this.icon}</md-icon>`}__renderMd(){const t=this.toggle?this.__renderToggleIcons():this.__renderSingleIcon();if(this.toggle)switch(this.variant){case"filled":return r`
|
|
6
6
|
<md-filled-icon-button
|
|
7
7
|
toggle
|
|
8
8
|
?selected=${this.selected}
|
|
@@ -10,7 +10,7 @@ import{_ as h}from"../../vendor/preload-helper.js";import{a as f,n as r,i as g,x
|
|
|
10
10
|
>
|
|
11
11
|
${t}
|
|
12
12
|
</md-filled-icon-button>
|
|
13
|
-
`;case"outlined":return
|
|
13
|
+
`;case"outlined":return r`
|
|
14
14
|
<md-outlined-icon-button
|
|
15
15
|
toggle
|
|
16
16
|
?selected=${this.selected}
|
|
@@ -18,7 +18,7 @@ import{_ as h}from"../../vendor/preload-helper.js";import{a as f,n as r,i as g,x
|
|
|
18
18
|
>
|
|
19
19
|
${t}
|
|
20
20
|
</md-outlined-icon-button>
|
|
21
|
-
`;case"filled-tonal":return
|
|
21
|
+
`;case"filled-tonal":return r`
|
|
22
22
|
<md-filled-tonal-icon-button
|
|
23
23
|
toggle
|
|
24
24
|
?selected=${this.selected}
|
|
@@ -26,29 +26,30 @@ import{_ as h}from"../../vendor/preload-helper.js";import{a as f,n as r,i as g,x
|
|
|
26
26
|
>
|
|
27
27
|
${t}
|
|
28
28
|
</md-filled-tonal-icon-button>
|
|
29
|
-
`;default:return
|
|
29
|
+
`;default:return r`
|
|
30
30
|
<md-icon-button toggle ?selected=${this.selected} ?disabled=${this.disabled}>
|
|
31
31
|
${t}
|
|
32
32
|
</md-icon-button>
|
|
33
|
-
`}switch(this.variant){case"filled":return
|
|
33
|
+
`}switch(this.variant){case"filled":return r`
|
|
34
34
|
<md-filled-icon-button ?disabled=${this.disabled}>
|
|
35
35
|
${t}
|
|
36
36
|
</md-filled-icon-button>
|
|
37
|
-
`;case"outlined":return
|
|
37
|
+
`;case"outlined":return r`
|
|
38
38
|
<md-outlined-icon-button ?disabled=${this.disabled}>
|
|
39
39
|
${t}
|
|
40
40
|
</md-outlined-icon-button>
|
|
41
|
-
`;case"filled-tonal":return
|
|
41
|
+
`;case"filled-tonal":return r`
|
|
42
42
|
<md-filled-tonal-icon-button ?disabled=${this.disabled}>
|
|
43
43
|
${t}
|
|
44
44
|
</md-filled-tonal-icon-button>
|
|
45
|
-
`;default:return
|
|
45
|
+
`;default:return r`
|
|
46
46
|
<md-icon-button ?disabled=${this.disabled}>
|
|
47
47
|
${t}
|
|
48
48
|
</md-icon-button>
|
|
49
|
-
`}}render(){return this.__renderMd()}};_=new WeakSet;u=function(){const t=this.mapSpacingToken(this.spacing);
|
|
49
|
+
`}}render(){return this.__renderMd()}};_=new WeakSet;u=function(){const t=this.mapSpacingToken(this.spacing),e=this.mapSpacingToken(this.spacingTop)??t,i=this.mapSpacingToken(this.spacingBottom)??t;e?this.style.setProperty("--scb-icon-button-spacing-block-start",e):this.style.removeProperty("--scb-icon-button-spacing-block-start"),i?this.style.setProperty("--scb-icon-button-spacing-block-end",i):this.style.removeProperty("--scb-icon-button-spacing-block-end")};o.styles=g`
|
|
50
50
|
:host {
|
|
51
51
|
display: inline-flex;
|
|
52
|
-
margin-block: var(--scb-icon-button-spacing-block, 0);
|
|
52
|
+
margin-block-start: var(--scb-icon-button-spacing-block-start, 0);
|
|
53
|
+
margin-block-end: var(--scb-icon-button-spacing-block-end, 0);
|
|
53
54
|
}
|
|
54
|
-
`;
|
|
55
|
+
`;s([a({type:String})],o.prototype,"icon",2);s([a({type:String})],o.prototype,"tooltip",2);s([a({type:String,attribute:"aria-label"})],o.prototype,"ariaLabel",2);s([a({type:String})],o.prototype,"variant",2);s([a({type:Boolean,reflect:!0})],o.prototype,"toggle",2);s([a({type:Boolean,reflect:!0})],o.prototype,"selected",2);s([a({type:String})],o.prototype,"toggleofficon",2);s([a({type:String})],o.prototype,"toggleonicon",2);s([a({type:Boolean,reflect:!0})],o.prototype,"disabled",2);s([a({type:String,reflect:!0})],o.prototype,"spacing",2);s([a({type:String,attribute:"spacing-top",reflect:!0})],o.prototype,"spacingTop",2);s([a({type:String,attribute:"spacing-bottom",reflect:!0})],o.prototype,"spacingBottom",2);o=s([f("scb-icon-button")],o);export{o as ScbIconButton};
|
|
@@ -1,29 +1,30 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as p,n as l,i as f,x as b,t as v}from"../../vendor/vendor.js";import"./scb-segmented-item.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 e=customElements.define.bind(customElements);customElements.define=function(s,i,r){try{customElements.get(s)||e(s,i,r)}catch(u){var o=String(u||"");if(o.indexOf("already been used")===-1&&o.indexOf("NotSupportedError")===-1)throw u}}}}catch{}})();var g=Object.defineProperty,_=Object.getOwnPropertyDescriptor,m=t=>{throw TypeError(t)},n=(t,e,s,i)=>{for(var r=i>1?void 0:i?_(e,s):e,o=t.length-1,u;o>=0;o--)(u=t[o])&&(r=(i?u(e,s,r):u(r))||r);return i&&r&&g(e,s,r),r},y=(t,e,s)=>e.has(t)||m("Cannot "+s),S=(t,e,s)=>e.has(t)?m("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,s),h=(t,e,s)=>(y(t,e,"access private method"),s),d,c;let a=class extends f{constructor(){super(),S(this,d),this._internals=null,this.variant="single-select",this.value="",this.values=[],this.disabled=!1,this.name="",this.spacing="",this.spacingTop="",this.spacingBottom="",this._form=null,this._formResetHandler=null,this._initialValue="",this._initialValues=[],"attachInternals"in this&&(this._internals=this.attachInternals())}connectedCallback(){super.connectedCallback(),this._form=this.closest("form"),this._form&&(this._formResetHandler=()=>{this.value=this._initialValue,this.values=Array.isArray(this._initialValues)?[...this._initialValues]:[],this.updateSegments(),this._syncFormValue()},this._form.addEventListener("reset",this._formResetHandler,!0))}disconnectedCallback(){this._form&&this._formResetHandler&&this._form.removeEventListener("reset",this._formResetHandler,!0),super.disconnectedCallback()}firstUpdated(){this._initialValue=this.value,this._initialValues=Array.isArray(this.values)?[...this.values]:[],this.updateSegments();const t=this.shadowRoot?.querySelector("slot");t&&(t.addEventListener("click",e=>this.onSlotClick(e)),t.addEventListener("focus",()=>{this.dispatchEvent(new CustomEvent("focus",{detail:{},bubbles:!0,composed:!0}))},!0),t.addEventListener("blur",()=>{this.dispatchEvent(new CustomEvent("blur",{detail:{},bubbles:!0,composed:!0}))},!0),t.addEventListener("keydown",e=>{if(e.code==="Space"||e.code==="Enter"||e.code==="NumpadEnter"){const s=e.target;if(s&&s.closest){const i=s.closest("scb-segmented-item");i&&!i.hasAttribute("disabled")&&!this.disabled&&(this.onSlotClick(e),e.preventDefault())}}})),this._syncFormValue(),h(this,d,c).call(this)}updated(t){super.updated(t),this.updateSegments(),(t.has("value")||t.has("values")||t.has("disabled")||t.has("variant")||t.has("name"))&&this._syncFormValue(),(t.has("spacing")||t.has("spacingTop")||t.has("spacingBottom"))&&h(this,d,c).call(this)}onSlotClick(t){let e=t.target;if(!e||!e.closest)return;const s=e.closest("scb-segmented-item");if(!s||this.disabled||s.hasAttribute("disabled"))return;const i=s.getAttribute("value")||"";i&&(this.variant==="multi-select"?(this.values.indexOf(i)===-1?this.values=[...this.values,i]:this.values=this.values.filter(o=>o!==i),this.dispatchEvent(new CustomEvent("change",{detail:{values:this.values},bubbles:!0,composed:!0})),this.updateSegments()):i!==this.value&&(this.value=i,this.dispatchEvent(new CustomEvent("change",{detail:{value:i},bubbles:!0,composed:!0})),this.updateSegments()))}updateSegments(){const t=this.shadowRoot?.querySelector("slot");if(!t)return;t.assignedElements().forEach(s=>{if(s.tagName==="SCB-SEGMENTED-ITEM"){const i=s.getAttribute("value")||"";if(i){let r=!1;this.variant==="multi-select"?r=!!this.values&&this.values.includes(i):r=i===this.value,s.setAttribute("aria-pressed",r?"true":"false"),r?s.setAttribute("selected","true"):s.removeAttribute("selected")}this.disabled&&s.setAttribute("disabled","true")}})}formDisabledCallback(t){this.disabled=t}_syncFormValue(){if(this._internals){if(this.disabled||!this.name){this._internals.setFormValue(null);return}if(this.variant==="multi-select"){if(!this.values||this.values.length===0){this._internals.setFormValue(null);return}const t=new FormData;for(const e of this.values)t.append(this.name,e);this._internals.setFormValue(t)}else{if(!this.value){this._internals.setFormValue(null);return}this._internals.setFormValue(this.value)}}}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}render(){return b`<slot></slot>`}};d=new WeakSet;c=function(){const t=this.mapSpacingToken(this.spacing),e=this.mapSpacingToken(this.spacingTop)??t,s=this.mapSpacingToken(this.spacingBottom)??t;e?this.style.setProperty("--scb-segmented-button-spacing-block-start",e):this.style.removeProperty("--scb-segmented-button-spacing-block-start"),s?this.style.setProperty("--scb-segmented-button-spacing-block-end",s):this.style.removeProperty("--scb-segmented-button-spacing-block-end")};a.formAssociated=!0;a.styles=p`
|
|
2
2
|
:host {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
--scb-segmented-button-width: 100%;
|
|
4
|
+
--scb-segmented-button-height: 48px;
|
|
5
|
+
max-width: var(--scb-segmented-button-width);
|
|
6
|
+
height: var(--scb-segmented-button-height);
|
|
7
|
+
display: grid;
|
|
8
|
+
grid-auto-flow: column;
|
|
9
|
+
grid-auto-columns: 1fr;
|
|
10
|
+
font-family: var(--brand, Inter);
|
|
11
|
+
margin-block-start: var(--scb-segmented-button-spacing-block-start, 0);
|
|
12
|
+
margin-block-end: var(--scb-segmented-button-spacing-block-end, 0);
|
|
12
13
|
}
|
|
13
14
|
/* Border radius only on first and last button */
|
|
14
15
|
::slotted(scb-segmented-item:first-child .segmented-item),
|
|
15
|
-
::slotted([role=
|
|
16
|
+
::slotted([role='button']:first-child .segmented-item) {
|
|
16
17
|
border-top-left-radius: var(--md-sys-shape-corner-full);
|
|
17
18
|
border-bottom-left-radius: var(--md-sys-shape-corner-full);
|
|
18
19
|
}
|
|
19
20
|
::slotted(scb-segmented-item:last-child .segmented-item),
|
|
20
|
-
::slotted([role=
|
|
21
|
+
::slotted([role='button']:last-child .segmented-item) {
|
|
21
22
|
border-top-right-radius: var(--md-sys-shape-corner-full);
|
|
22
23
|
border-bottom-right-radius: var(--md-sys-shape-corner-full);
|
|
23
24
|
}
|
|
24
25
|
/* First button gets left border */
|
|
25
26
|
::slotted(scb-segmented-item:first-child .segmented-item),
|
|
26
|
-
::slotted([role=
|
|
27
|
+
::slotted([role='button']:first-child .segmented-item) {
|
|
27
28
|
border-left: 1px solid var(--md-sys-color-outline);
|
|
28
29
|
}
|
|
29
|
-
`;
|
|
30
|
+
`;n([l({type:String,reflect:!0})],a.prototype,"variant",2);n([l({type:String,reflect:!0})],a.prototype,"value",2);n([l({type:Array})],a.prototype,"values",2);n([l({type:Boolean,reflect:!0})],a.prototype,"disabled",2);n([l({type:String,reflect:!0})],a.prototype,"name",2);n([l({type:String,reflect:!0})],a.prototype,"spacing",2);n([l({type:String,attribute:"spacing-top",reflect:!0})],a.prototype,"spacingTop",2);n([l({type:String,attribute:"spacing-bottom",reflect:!0})],a.prototype,"spacingBottom",2);a=n([v("scb-segmented-button")],a);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "scb-wc-test",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.107",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.js",
|
|
@@ -337,5 +337,5 @@
|
|
|
337
337
|
},
|
|
338
338
|
"./mvc/*": "./mvc/*"
|
|
339
339
|
},
|
|
340
|
-
"buildHash": "
|
|
340
|
+
"buildHash": "9C8FDE229A6A7627895483B4195C5836D7D6E708679AC92B7306C433AB2EB029"
|
|
341
341
|
}
|
|
@@ -22,6 +22,10 @@ export declare class ScbIconButton extends LitElement {
|
|
|
22
22
|
disabled: boolean;
|
|
23
23
|
/** Vertikalt avstånd till omgivande innehåll. "N" mappar till var(--spacing-N). */
|
|
24
24
|
spacing: string;
|
|
25
|
+
/** Överkantens avstånd. Om satt går före spacing. 0–14 mappar till var(--spacing-N), annars CSS-värde. */
|
|
26
|
+
spacingTop: string;
|
|
27
|
+
/** Nederkantens avstånd. Om satt går före spacing. 0–14 mappar till var(--spacing-N), annars CSS-värde. */
|
|
28
|
+
spacingBottom: string;
|
|
25
29
|
private __loadedVariants;
|
|
26
30
|
private __iconLoaded;
|
|
27
31
|
private __lastMdHost;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { css as
|
|
2
|
-
import { property as
|
|
1
|
+
import { css as g, LitElement as _, html as r } from "lit";
|
|
2
|
+
import { property as n, customElement as m } from "lit/decorators.js";
|
|
3
3
|
import "@material/web/icon/icon.js";
|
|
4
|
-
var
|
|
4
|
+
var f = Object.defineProperty, y = Object.getOwnPropertyDescriptor, b = (t) => {
|
|
5
5
|
throw TypeError(t);
|
|
6
6
|
}, o = (t, e, i, l) => {
|
|
7
|
-
for (var
|
|
8
|
-
(h = t[d]) && (
|
|
9
|
-
return l &&
|
|
10
|
-
},
|
|
11
|
-
let s = class extends
|
|
7
|
+
for (var a = l > 1 ? void 0 : l ? y(e, i) : e, d = t.length - 1, h; d >= 0; d--)
|
|
8
|
+
(h = t[d]) && (a = (l ? h(e, i, a) : h(a)) || a);
|
|
9
|
+
return l && a && f(e, i, a), a;
|
|
10
|
+
}, v = (t, e, i) => e.has(t) || b("Cannot " + i), $ = (t, e, i) => e.has(t) ? b("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, i), u = (t, e, i) => (v(t, e, "access private method"), i), c, p;
|
|
11
|
+
let s = class extends _ {
|
|
12
12
|
constructor() {
|
|
13
|
-
super(...arguments), $(this, c), this.icon = "home", this.tooltip = "", this.ariaLabel = "", this.variant = "standard", this.toggle = !1, this.selected = !1, this.toggleofficon = "add", this.toggleonicon = "remove", this.disabled = !1, this.spacing = "", this.__loadedVariants = /* @__PURE__ */ new Set(), this.__iconLoaded = !1, this.__lastMdHost = null, this.__onInnerChange = () => {
|
|
13
|
+
super(...arguments), $(this, c), this.icon = "home", this.tooltip = "", this.ariaLabel = "", this.variant = "standard", this.toggle = !1, this.selected = !1, this.toggleofficon = "add", this.toggleonicon = "remove", this.disabled = !1, this.spacing = "", this.spacingTop = "", this.spacingBottom = "", this.__loadedVariants = /* @__PURE__ */ new Set(), this.__iconLoaded = !1, this.__lastMdHost = null, this.__onInnerChange = () => {
|
|
14
14
|
const t = this.__getMdHost(), e = !!(t != null && t.selected);
|
|
15
15
|
this.toggle && (this.selected = e), this.dispatchEvent(
|
|
16
16
|
new CustomEvent("change", {
|
|
@@ -22,10 +22,10 @@ let s = class extends g {
|
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
async firstUpdated() {
|
|
25
|
-
await this.__ensureDepsLoaded(), await this.updateComplete, this.__attachChangeListener(), this.__syncTitleAndAria(),
|
|
25
|
+
await this.__ensureDepsLoaded(), await this.updateComplete, this.__attachChangeListener(), this.__syncTitleAndAria(), u(this, c, p).call(this);
|
|
26
26
|
}
|
|
27
27
|
updated(t) {
|
|
28
|
-
if (super.updated(t), t.has("spacing") &&
|
|
28
|
+
if (super.updated(t), (t.has("spacing") || t.has("spacingTop") || t.has("spacingBottom")) && u(this, c, p).call(this), t.has("variant")) {
|
|
29
29
|
this.__ensureDepsLoaded().then(() => {
|
|
30
30
|
queueMicrotask(() => {
|
|
31
31
|
this.__attachChangeListener(), this.__syncTitleAndAria();
|
|
@@ -79,10 +79,10 @@ let s = class extends g {
|
|
|
79
79
|
__syncTitleAndAria() {
|
|
80
80
|
const t = this.__getMdHost();
|
|
81
81
|
if (!t) return;
|
|
82
|
-
const e = (this.tooltip || this.getAttribute("title") || "").trim(), i = (this.ariaLabel || this.getAttribute("aria-label") || "").trim(), l = this.getAttribute("aria-controls"),
|
|
82
|
+
const e = (this.tooltip || this.getAttribute("title") || "").trim(), i = (this.ariaLabel || this.getAttribute("aria-label") || "").trim(), l = this.getAttribute("aria-controls"), a = this.getAttribute("aria-expanded");
|
|
83
83
|
this.tooltip && this.setAttribute("title", e);
|
|
84
84
|
const d = i || e || this.icon.trim() || void 0;
|
|
85
|
-
d ? t.setAttribute("aria-label", d) : t.removeAttribute("aria-label"), e ? t.setAttribute("title", e) : t.removeAttribute("title"), l !== null ? t.setAttribute("aria-controls", l) : t.removeAttribute("aria-controls"),
|
|
85
|
+
d ? t.setAttribute("aria-label", d) : t.removeAttribute("aria-label"), e ? t.setAttribute("title", e) : t.removeAttribute("title"), l !== null ? t.setAttribute("aria-controls", l) : t.removeAttribute("aria-controls"), a !== null ? t.setAttribute("aria-expanded", a) : t.removeAttribute("aria-expanded");
|
|
86
86
|
}
|
|
87
87
|
mapSpacingToken(t) {
|
|
88
88
|
if (!t) return;
|
|
@@ -91,20 +91,20 @@ let s = class extends g {
|
|
|
91
91
|
return /^\d+$/.test(e) ? `var(--spacing-${Math.max(0, Math.min(14, parseInt(e, 10)))})` : e;
|
|
92
92
|
}
|
|
93
93
|
__renderToggleIcons() {
|
|
94
|
-
return
|
|
94
|
+
return r`
|
|
95
95
|
<md-icon aria-hidden="true">${this.toggleofficon}</md-icon>
|
|
96
96
|
<md-icon slot="selected" aria-hidden="true">${this.toggleonicon}</md-icon>
|
|
97
97
|
`;
|
|
98
98
|
}
|
|
99
99
|
__renderSingleIcon() {
|
|
100
|
-
return
|
|
100
|
+
return r`<md-icon aria-hidden="true">${this.icon}</md-icon>`;
|
|
101
101
|
}
|
|
102
102
|
__renderMd() {
|
|
103
103
|
const t = this.toggle ? this.__renderToggleIcons() : this.__renderSingleIcon();
|
|
104
104
|
if (this.toggle)
|
|
105
105
|
switch (this.variant) {
|
|
106
106
|
case "filled":
|
|
107
|
-
return
|
|
107
|
+
return r`
|
|
108
108
|
<md-filled-icon-button
|
|
109
109
|
toggle
|
|
110
110
|
?selected=${this.selected}
|
|
@@ -114,7 +114,7 @@ let s = class extends g {
|
|
|
114
114
|
</md-filled-icon-button>
|
|
115
115
|
`;
|
|
116
116
|
case "outlined":
|
|
117
|
-
return
|
|
117
|
+
return r`
|
|
118
118
|
<md-outlined-icon-button
|
|
119
119
|
toggle
|
|
120
120
|
?selected=${this.selected}
|
|
@@ -124,7 +124,7 @@ let s = class extends g {
|
|
|
124
124
|
</md-outlined-icon-button>
|
|
125
125
|
`;
|
|
126
126
|
case "filled-tonal":
|
|
127
|
-
return
|
|
127
|
+
return r`
|
|
128
128
|
<md-filled-tonal-icon-button
|
|
129
129
|
toggle
|
|
130
130
|
?selected=${this.selected}
|
|
@@ -134,7 +134,7 @@ let s = class extends g {
|
|
|
134
134
|
</md-filled-tonal-icon-button>
|
|
135
135
|
`;
|
|
136
136
|
default:
|
|
137
|
-
return
|
|
137
|
+
return r`
|
|
138
138
|
<md-icon-button toggle ?selected=${this.selected} ?disabled=${this.disabled}>
|
|
139
139
|
${t}
|
|
140
140
|
</md-icon-button>
|
|
@@ -142,25 +142,25 @@ let s = class extends g {
|
|
|
142
142
|
}
|
|
143
143
|
switch (this.variant) {
|
|
144
144
|
case "filled":
|
|
145
|
-
return
|
|
145
|
+
return r`
|
|
146
146
|
<md-filled-icon-button ?disabled=${this.disabled}>
|
|
147
147
|
${t}
|
|
148
148
|
</md-filled-icon-button>
|
|
149
149
|
`;
|
|
150
150
|
case "outlined":
|
|
151
|
-
return
|
|
151
|
+
return r`
|
|
152
152
|
<md-outlined-icon-button ?disabled=${this.disabled}>
|
|
153
153
|
${t}
|
|
154
154
|
</md-outlined-icon-button>
|
|
155
155
|
`;
|
|
156
156
|
case "filled-tonal":
|
|
157
|
-
return
|
|
157
|
+
return r`
|
|
158
158
|
<md-filled-tonal-icon-button ?disabled=${this.disabled}>
|
|
159
159
|
${t}
|
|
160
160
|
</md-filled-tonal-icon-button>
|
|
161
161
|
`;
|
|
162
162
|
default:
|
|
163
|
-
return
|
|
163
|
+
return r`
|
|
164
164
|
<md-icon-button ?disabled=${this.disabled}>
|
|
165
165
|
${t}
|
|
166
166
|
</md-icon-button>
|
|
@@ -172,48 +172,55 @@ let s = class extends g {
|
|
|
172
172
|
}
|
|
173
173
|
};
|
|
174
174
|
c = /* @__PURE__ */ new WeakSet();
|
|
175
|
-
|
|
176
|
-
const t = this.mapSpacingToken(this.spacing);
|
|
177
|
-
|
|
175
|
+
p = function() {
|
|
176
|
+
const t = this.mapSpacingToken(this.spacing), e = this.mapSpacingToken(this.spacingTop) ?? t, i = this.mapSpacingToken(this.spacingBottom) ?? t;
|
|
177
|
+
e ? this.style.setProperty("--scb-icon-button-spacing-block-start", e) : this.style.removeProperty("--scb-icon-button-spacing-block-start"), i ? this.style.setProperty("--scb-icon-button-spacing-block-end", i) : this.style.removeProperty("--scb-icon-button-spacing-block-end");
|
|
178
178
|
};
|
|
179
|
-
s.styles =
|
|
179
|
+
s.styles = g`
|
|
180
180
|
:host {
|
|
181
181
|
display: inline-flex;
|
|
182
|
-
margin-block: var(--scb-icon-button-spacing-block, 0);
|
|
182
|
+
margin-block-start: var(--scb-icon-button-spacing-block-start, 0);
|
|
183
|
+
margin-block-end: var(--scb-icon-button-spacing-block-end, 0);
|
|
183
184
|
}
|
|
184
185
|
`;
|
|
185
186
|
o([
|
|
186
|
-
|
|
187
|
+
n({ type: String })
|
|
187
188
|
], s.prototype, "icon", 2);
|
|
188
189
|
o([
|
|
189
|
-
|
|
190
|
+
n({ type: String })
|
|
190
191
|
], s.prototype, "tooltip", 2);
|
|
191
192
|
o([
|
|
192
|
-
|
|
193
|
+
n({ type: String, attribute: "aria-label" })
|
|
193
194
|
], s.prototype, "ariaLabel", 2);
|
|
194
195
|
o([
|
|
195
|
-
|
|
196
|
+
n({ type: String })
|
|
196
197
|
], s.prototype, "variant", 2);
|
|
197
198
|
o([
|
|
198
|
-
|
|
199
|
+
n({ type: Boolean, reflect: !0 })
|
|
199
200
|
], s.prototype, "toggle", 2);
|
|
200
201
|
o([
|
|
201
|
-
|
|
202
|
+
n({ type: Boolean, reflect: !0 })
|
|
202
203
|
], s.prototype, "selected", 2);
|
|
203
204
|
o([
|
|
204
|
-
|
|
205
|
+
n({ type: String })
|
|
205
206
|
], s.prototype, "toggleofficon", 2);
|
|
206
207
|
o([
|
|
207
|
-
|
|
208
|
+
n({ type: String })
|
|
208
209
|
], s.prototype, "toggleonicon", 2);
|
|
209
210
|
o([
|
|
210
|
-
|
|
211
|
+
n({ type: Boolean, reflect: !0 })
|
|
211
212
|
], s.prototype, "disabled", 2);
|
|
212
213
|
o([
|
|
213
|
-
|
|
214
|
+
n({ type: String, reflect: !0 })
|
|
214
215
|
], s.prototype, "spacing", 2);
|
|
216
|
+
o([
|
|
217
|
+
n({ type: String, attribute: "spacing-top", reflect: !0 })
|
|
218
|
+
], s.prototype, "spacingTop", 2);
|
|
219
|
+
o([
|
|
220
|
+
n({ type: String, attribute: "spacing-bottom", reflect: !0 })
|
|
221
|
+
], s.prototype, "spacingBottom", 2);
|
|
215
222
|
s = o([
|
|
216
|
-
|
|
223
|
+
m("scb-icon-button")
|
|
217
224
|
], s);
|
|
218
225
|
export {
|
|
219
226
|
s as ScbIconButton
|
|
@@ -30,6 +30,10 @@ export declare class ScbSegmentedButton extends LitElement {
|
|
|
30
30
|
* "N" (0–14) mappar till var(--spacing-N), annars valfritt CSS-värde.
|
|
31
31
|
*/
|
|
32
32
|
spacing: string;
|
|
33
|
+
/** Överkantens avstånd. Om satt går före spacing. 0–14 mappar till var(--spacing-N), annars valfritt CSS-värde. */
|
|
34
|
+
spacingTop: string;
|
|
35
|
+
/** Nederkantens avstånd. Om satt går före spacing. 0–14 mappar till var(--spacing-N), annars valfritt CSS-värde. */
|
|
36
|
+
spacingBottom: string;
|
|
33
37
|
private _form;
|
|
34
38
|
private _formResetHandler;
|
|
35
39
|
private _initialValue;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { css as p, LitElement as f, html as
|
|
2
|
-
import { property as
|
|
1
|
+
import { css as p, LitElement as f, html as b } from "lit";
|
|
2
|
+
import { property as l, customElement as v } from "lit/decorators.js";
|
|
3
3
|
import "./scb-segmented-item.js";
|
|
4
|
-
var g = Object.defineProperty,
|
|
4
|
+
var g = Object.defineProperty, y = Object.getOwnPropertyDescriptor, m = (t) => {
|
|
5
5
|
throw TypeError(t);
|
|
6
|
-
},
|
|
7
|
-
for (var r = i > 1 ? void 0 : i ?
|
|
8
|
-
(d = t[
|
|
6
|
+
}, o = (t, e, s, i) => {
|
|
7
|
+
for (var r = i > 1 ? void 0 : i ? y(e, s) : e, n = t.length - 1, d; n >= 0; n--)
|
|
8
|
+
(d = t[n]) && (r = (i ? d(e, s, r) : d(r)) || r);
|
|
9
9
|
return i && r && g(e, s, r), r;
|
|
10
|
-
},
|
|
11
|
-
let
|
|
10
|
+
}, _ = (t, e, s) => e.has(t) || m("Cannot " + s), S = (t, e, s) => e.has(t) ? m("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, s), h = (t, e, s) => (_(t, e, "access private method"), s), u, c;
|
|
11
|
+
let a = class extends f {
|
|
12
12
|
constructor() {
|
|
13
|
-
super(), S(this, u), this._internals = null, this.variant = "single-select", this.value = "", this.values = [], this.disabled = !1, this.name = "", this.spacing = "", this._form = null, this._formResetHandler = null, this._initialValue = "", this._initialValues = [], "attachInternals" in this && (this._internals = this.attachInternals());
|
|
13
|
+
super(), S(this, u), this._internals = null, this.variant = "single-select", this.value = "", this.values = [], this.disabled = !1, this.name = "", this.spacing = "", this.spacingTop = "", this.spacingBottom = "", this._form = null, this._formResetHandler = null, this._initialValue = "", this._initialValues = [], "attachInternals" in this && (this._internals = this.attachInternals());
|
|
14
14
|
}
|
|
15
15
|
connectedCallback() {
|
|
16
16
|
super.connectedCallback(), this._form = this.closest("form"), this._form && (this._formResetHandler = () => {
|
|
@@ -48,10 +48,10 @@ let n = class extends f {
|
|
|
48
48
|
r && !r.hasAttribute("disabled") && !this.disabled && (this.onSlotClick(s), s.preventDefault());
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
})), this._syncFormValue(),
|
|
51
|
+
})), this._syncFormValue(), h(this, u, c).call(this);
|
|
52
52
|
}
|
|
53
53
|
updated(t) {
|
|
54
|
-
super.updated(t), this.updateSegments(), (t.has("value") || t.has("values") || t.has("disabled") || t.has("variant") || t.has("name")) && this._syncFormValue(), t.has("spacing") &&
|
|
54
|
+
super.updated(t), this.updateSegments(), (t.has("value") || t.has("values") || t.has("disabled") || t.has("variant") || t.has("name")) && this._syncFormValue(), (t.has("spacing") || t.has("spacingTop") || t.has("spacingBottom")) && h(this, u, c).call(this);
|
|
55
55
|
}
|
|
56
56
|
onSlotClick(t) {
|
|
57
57
|
let e = t.target;
|
|
@@ -59,7 +59,7 @@ let n = class extends f {
|
|
|
59
59
|
const s = e.closest("scb-segmented-item");
|
|
60
60
|
if (!s || this.disabled || s.hasAttribute("disabled")) return;
|
|
61
61
|
const i = s.getAttribute("value") || "";
|
|
62
|
-
i && (this.variant === "multi-select" ? (this.values.indexOf(i) === -1 ? this.values = [...this.values, i] : this.values = this.values.filter((
|
|
62
|
+
i && (this.variant === "multi-select" ? (this.values.indexOf(i) === -1 ? this.values = [...this.values, i] : this.values = this.values.filter((n) => n !== i), this.dispatchEvent(
|
|
63
63
|
new CustomEvent("change", {
|
|
64
64
|
detail: { values: this.values },
|
|
65
65
|
bubbles: !0,
|
|
@@ -77,8 +77,8 @@ let n = class extends f {
|
|
|
77
77
|
if (i.tagName === "SCB-SEGMENTED-ITEM") {
|
|
78
78
|
const r = i.getAttribute("value") || "";
|
|
79
79
|
if (r) {
|
|
80
|
-
let
|
|
81
|
-
this.variant === "multi-select" ?
|
|
80
|
+
let n = !1;
|
|
81
|
+
this.variant === "multi-select" ? n = !!this.values && this.values.includes(r) : n = r === this.value, i.setAttribute("aria-pressed", n ? "true" : "false"), n ? i.setAttribute("selected", "true") : i.removeAttribute("selected");
|
|
82
82
|
}
|
|
83
83
|
this.disabled && i.setAttribute("disabled", "true");
|
|
84
84
|
}
|
|
@@ -126,65 +126,72 @@ let n = class extends f {
|
|
|
126
126
|
return /^\d+$/.test(e) ? `var(--spacing-${Math.max(0, Math.min(14, parseInt(e, 10)))})` : e;
|
|
127
127
|
}
|
|
128
128
|
render() {
|
|
129
|
-
return
|
|
129
|
+
return b`<slot></slot>`;
|
|
130
130
|
}
|
|
131
131
|
};
|
|
132
132
|
u = /* @__PURE__ */ new WeakSet();
|
|
133
|
-
|
|
134
|
-
const t = this.mapSpacingToken(this.spacing);
|
|
135
|
-
|
|
133
|
+
c = function() {
|
|
134
|
+
const t = this.mapSpacingToken(this.spacing), e = this.mapSpacingToken(this.spacingTop) ?? t, s = this.mapSpacingToken(this.spacingBottom) ?? t;
|
|
135
|
+
e ? this.style.setProperty("--scb-segmented-button-spacing-block-start", e) : this.style.removeProperty("--scb-segmented-button-spacing-block-start"), s ? this.style.setProperty("--scb-segmented-button-spacing-block-end", s) : this.style.removeProperty("--scb-segmented-button-spacing-block-end");
|
|
136
136
|
};
|
|
137
|
-
|
|
138
|
-
|
|
137
|
+
a.formAssociated = !0;
|
|
138
|
+
a.styles = p`
|
|
139
139
|
:host {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
140
|
+
--scb-segmented-button-width: 100%;
|
|
141
|
+
--scb-segmented-button-height: 48px;
|
|
142
|
+
max-width: var(--scb-segmented-button-width);
|
|
143
|
+
height: var(--scb-segmented-button-height);
|
|
144
|
+
display: grid;
|
|
145
|
+
grid-auto-flow: column;
|
|
146
|
+
grid-auto-columns: 1fr;
|
|
147
|
+
font-family: var(--brand, Inter);
|
|
148
|
+
margin-block-start: var(--scb-segmented-button-spacing-block-start, 0);
|
|
149
|
+
margin-block-end: var(--scb-segmented-button-spacing-block-end, 0);
|
|
149
150
|
}
|
|
150
151
|
/* Border radius only on first and last button */
|
|
151
152
|
::slotted(scb-segmented-item:first-child .segmented-item),
|
|
152
|
-
::slotted([role=
|
|
153
|
+
::slotted([role='button']:first-child .segmented-item) {
|
|
153
154
|
border-top-left-radius: var(--md-sys-shape-corner-full);
|
|
154
155
|
border-bottom-left-radius: var(--md-sys-shape-corner-full);
|
|
155
156
|
}
|
|
156
157
|
::slotted(scb-segmented-item:last-child .segmented-item),
|
|
157
|
-
::slotted([role=
|
|
158
|
+
::slotted([role='button']:last-child .segmented-item) {
|
|
158
159
|
border-top-right-radius: var(--md-sys-shape-corner-full);
|
|
159
160
|
border-bottom-right-radius: var(--md-sys-shape-corner-full);
|
|
160
161
|
}
|
|
161
162
|
/* First button gets left border */
|
|
162
163
|
::slotted(scb-segmented-item:first-child .segmented-item),
|
|
163
|
-
::slotted([role=
|
|
164
|
+
::slotted([role='button']:first-child .segmented-item) {
|
|
164
165
|
border-left: 1px solid var(--md-sys-color-outline);
|
|
165
166
|
}
|
|
166
167
|
`;
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
],
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
],
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
],
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
],
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
],
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
],
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
],
|
|
168
|
+
o([
|
|
169
|
+
l({ type: String, reflect: !0 })
|
|
170
|
+
], a.prototype, "variant", 2);
|
|
171
|
+
o([
|
|
172
|
+
l({ type: String, reflect: !0 })
|
|
173
|
+
], a.prototype, "value", 2);
|
|
174
|
+
o([
|
|
175
|
+
l({ type: Array })
|
|
176
|
+
], a.prototype, "values", 2);
|
|
177
|
+
o([
|
|
178
|
+
l({ type: Boolean, reflect: !0 })
|
|
179
|
+
], a.prototype, "disabled", 2);
|
|
180
|
+
o([
|
|
181
|
+
l({ type: String, reflect: !0 })
|
|
182
|
+
], a.prototype, "name", 2);
|
|
183
|
+
o([
|
|
184
|
+
l({ type: String, reflect: !0 })
|
|
185
|
+
], a.prototype, "spacing", 2);
|
|
186
|
+
o([
|
|
187
|
+
l({ type: String, attribute: "spacing-top", reflect: !0 })
|
|
188
|
+
], a.prototype, "spacingTop", 2);
|
|
189
|
+
o([
|
|
190
|
+
l({ type: String, attribute: "spacing-bottom", reflect: !0 })
|
|
191
|
+
], a.prototype, "spacingBottom", 2);
|
|
192
|
+
a = o([
|
|
193
|
+
v("scb-segmented-button")
|
|
194
|
+
], a);
|
|
188
195
|
export {
|
|
189
|
-
|
|
196
|
+
a as ScbSegmentedButton
|
|
190
197
|
};
|