scb-wc-test 0.1.65 → 0.1.67
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-accordion/scb-accordion-item.js +1 -1
- package/mvc/components/scb-segmented-button/scb-segmented-button.js +9 -3
- package/mvc/components/scb-segmented-button/scb-segmented-item.js +30 -27
- package/package.json +2 -2
- package/scb-accordion/scb-accordion-item.d.ts +1 -0
- package/scb-accordion/scb-accordion-item.js +7 -6
- package/scb-segmented-button/scb-segmented-button.js +62 -44
- package/scb-segmented-button/scb-segmented-item.js +46 -43
- package/scb-wc-test.bundle.js +36 -27
|
@@ -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"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{_ as g}from"../../vendor/preload-helper.js";import{a as u,n as s,i as m,E as p,x as l,t as v}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(o,r,n){try{customElements.get(o)||i(o,r,n)}catch(d){var c=String(d||"");if(c.indexOf("already been used")===-1&&c.indexOf("NotSupportedError")===-1)throw d}}}}catch{}})();var h=Object.defineProperty,b=Object.getOwnPropertyDescriptor,a=(t,i,o,r)=>{for(var n=r>1?void 0:r?b(i,o):i,c=t.length-1,d;c>=0;c--)(d=t[c])&&(n=(r?d(i,o,n):d(n))||n);return r&&n&&h(i,o,n),n};let e=class extends m{constructor(){super(...arguments),this.open=!1,this.title="",this.content="",this.overline="",this.supportingText="",this.leading=!1,this.leadingVariant="",this.leadingIcon="",this.imgHrefImage="",this.avatarLabel="",this.avatarAlt="",this.avatarVariant="icon",this.avatarSrc="",this.density=0,this._unique=e._uid(),this._onToggle=t=>{const i=t.currentTarget;this.open=!!i.open;const o=this.closest("scb-accordion");this.open&&o&&!o.hasAttribute("detached")&&o.querySelectorAll("scb-accordion-item").forEach(n=>{n!==this&&n.setOpen(!1)}),this._applyInertByOpen()
|
|
2
|
+
import{_ as g}from"../../vendor/preload-helper.js";import{a as u,n as s,i as m,E as p,x as l,t as v}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(o,r,n){try{customElements.get(o)||i(o,r,n)}catch(d){var c=String(d||"");if(c.indexOf("already been used")===-1&&c.indexOf("NotSupportedError")===-1)throw d}}}}catch{}})();var h=Object.defineProperty,b=Object.getOwnPropertyDescriptor,a=(t,i,o,r)=>{for(var n=r>1?void 0:r?b(i,o):i,c=t.length-1,d;c>=0;c--)(d=t[c])&&(n=(r?d(i,o,n):d(n))||n);return r&&n&&h(i,o,n),n};let e=class extends m{constructor(){super(...arguments),this.open=!1,this.title="",this.content="",this.overline="",this.supportingText="",this.leading=!1,this.leadingVariant="",this.leadingIcon="",this.imgHrefImage="",this.avatarLabel="",this.avatarAlt="",this.avatarVariant="icon",this.avatarSrc="",this.density=0,this._unique=e._uid(),this._onToggle=t=>{const i=t.currentTarget;this.open=!!i.open;const o=this.closest("scb-accordion");this.open&&o&&!o.hasAttribute("detached")&&o.querySelectorAll("scb-accordion-item").forEach(n=>{n!==this&&n.setOpen(!1)}),this._applyInertByOpen()}}static _uid(){return globalThis.crypto?.randomUUID?.()??`${e._uidPrefix}-${++e._uidSeq}`}async firstUpdated(){e._mdIconLoaded||(await g(()=>import("../../vendor/vendor-material.js").then(t=>t.i),__vite__mapDeps([0,1]),import.meta.url),e._mdIconLoaded=!0),e._mdRippleLoaded||(await g(()=>import("../../vendor/vendor-material.js").then(t=>t.r),__vite__mapDeps([0,1]),import.meta.url),e._mdRippleLoaded=!0),this._applyInertByOpen()}_applyInertByOpen(){const t=this.renderRoot.querySelector(".scb-accordion-bottom"),i=this.renderRoot.querySelector("details");!t||!i||(i.open?(t.removeAttribute("inert"),t.setAttribute("aria-hidden","false")):(t.setAttribute("inert",""),t.setAttribute("aria-hidden","true")))}_onKeyDown(t){const i=this.closest("scb-accordion"),r=Array.from(i?.querySelectorAll("scb-accordion-item")||[]).map(d=>d.renderRoot.querySelector("details")?.querySelector(".scb-accordion-top")||null).filter(d=>!!d),n=t.currentTarget,c=r.indexOf(n);switch(t.key){case"ArrowDown":t.preventDefault(),c<r.length-1&&r[c+1].focus();break;case"ArrowUp":t.preventDefault(),c>0&&r[c-1].focus();break;case"Home":t.preventDefault(),r.length&&r[0].focus();break;case"End":t.preventDefault(),r.length&&r[r.length-1].focus();break}}setOpen(t){this.open=!!t;const i=this.renderRoot.querySelector("details");i&&(i.open=this.open),this._applyInertByOpen()}updated(t){if(t.has("open")){const i=this.renderRoot.querySelector("details");i&&i.open!==this.open&&(i.open=this.open),this._applyInertByOpen(),this.dispatchEvent(new CustomEvent("open-changed",{detail:{open:this.open,title:this.title},bubbles:!0,composed:!0}))}}render(){const t=`bottom-${this._unique}`,i=`header-${this._unique}`,o=this.leading?this.leadingVariant==="image"&&this.imgHrefImage?l`<img part="leading-image" class="img" src="${this.imgHrefImage}" alt="" />`:this.leadingVariant==="avatar"?l`
|
|
3
3
|
<scb-avatar
|
|
4
4
|
label=${this.avatarLabel}
|
|
5
5
|
alt=${this.avatarAlt}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
import{a as u,n,i as c,x as
|
|
1
|
+
import{a as u,n as a,i as c,x as h,t as m}from"../../vendor/vendor.js";import"./scb-segmented-item.js";import"../../vendor/vendor-material.js";(function(){try{var i=typeof globalThis<"u"?globalThis:window;if(!i.__scb_ce_guard_installed__){i.__scb_ce_guard_installed__=!0;var s=customElements.define.bind(customElements);customElements.define=function(e,t,r){try{customElements.get(e)||s(e,t,r)}catch(l){var o=String(l||"");if(o.indexOf("already been used")===-1&&o.indexOf("NotSupportedError")===-1)throw l}}}}catch{}})();var b=Object.defineProperty,f=Object.getOwnPropertyDescriptor,n=(i,s,e,t)=>{for(var r=t>1?void 0:t?f(s,e):s,o=i.length-1,l;o>=0;o--)(l=i[o])&&(r=(t?l(s,e,r):l(r))||r);return t&&r&&b(s,e,r),r};let d=class extends c{constructor(){super(...arguments),this.variant="single-select",this.value="",this.values=[],this.disabled=!1}onSlotClick(i){let s=i.target;if(!s||!s.closest)return;const e=s.closest("scb-segmented-item");if(!e||this.disabled||e.hasAttribute("disabled"))return;const t=e.getAttribute("value")||"";t&&(this.variant==="multi-select"?(this.values.indexOf(t)===-1?this.values=[...this.values,t]:this.values=this.values.filter(o=>o!==t),this.dispatchEvent(new CustomEvent("change",{detail:{values:this.values},bubbles:!0,composed:!0})),this.updateSegments()):t!==this.value&&(this.value=t,this.dispatchEvent(new CustomEvent("change",{detail:{value:t},bubbles:!0,composed:!0})),this.updateSegments()))}updateSegments(){const i=this.shadowRoot?.querySelector("slot");if(!i)return;i.assignedElements().forEach(e=>{if(e.tagName==="SCB-SEGMENTED-ITEM"){const t=e.getAttribute("value")||"";if(t){let r=!1;this.variant==="multi-select"?r=!!this.values&&this.values.includes(t):r=t===this.value,e.setAttribute("aria-pressed",r?"true":"false"),r?e.setAttribute("selected","true"):e.removeAttribute("selected")}this.disabled&&e.setAttribute("disabled","true")}})}firstUpdated(){this.updateSegments();const i=this.shadowRoot?.querySelector("slot");i&&(i.addEventListener("click",s=>this.onSlotClick(s)),i.addEventListener("focus",()=>{this.dispatchEvent(new CustomEvent("focus",{detail:{},bubbles:!0,composed:!0}))},!0),i.addEventListener("blur",()=>{this.dispatchEvent(new CustomEvent("blur",{detail:{},bubbles:!0,composed:!0}))},!0),i.addEventListener("keydown",s=>{if(s.code==="Space"||s.code==="Enter"||s.code==="NumpadEnter"){const e=s.target;if(e&&e.closest){const t=e.closest("scb-segmented-item");t&&!t.hasAttribute("disabled")&&!this.disabled&&(this.onSlotClick(s),s.preventDefault())}}}))}updated(){this.updateSegments()}render(){return h`<slot></slot>`}};d.styles=u`
|
|
2
2
|
:host {
|
|
3
|
-
|
|
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;
|
|
4
10
|
}
|
|
5
11
|
/* Border radius only on first and last button */
|
|
6
12
|
::slotted(scb-segmented-item:first-child .segmented-item),
|
|
@@ -18,4 +24,4 @@ import{a as u,n,i as c,x as f,t as h}from"../../vendor/vendor.js";import"./scb-s
|
|
|
18
24
|
::slotted([role="button"]:first-child .segmented-item) {
|
|
19
25
|
border-left: 1px solid var(--md-sys-color-outline);
|
|
20
26
|
}
|
|
21
|
-
`;
|
|
27
|
+
`;n([a({type:String,reflect:!0})],d.prototype,"variant",2);n([a({type:String,reflect:!0})],d.prototype,"value",2);n([a({type:Array})],d.prototype,"values",2);n([a({type:Boolean,reflect:!0})],d.prototype,"disabled",2);d=n([m("scb-segmented-button")],d);
|
|
@@ -1,35 +1,38 @@
|
|
|
1
|
-
import{a as
|
|
2
|
-
<div class="segmented-item" aria-disabled="${
|
|
3
|
-
<md-ripple ?disabled="${
|
|
4
|
-
${this.icon?
|
|
5
|
-
|
|
1
|
+
import{a as m,n as c,i as p,x as d,t as u}from"../../vendor/vendor.js";import"../../vendor/vendor-material.js";(function(){try{var o=typeof globalThis<"u"?globalThis:window;if(!o.__scb_ce_guard_installed__){o.__scb_ce_guard_installed__=!0;var r=customElements.define.bind(customElements);customElements.define=function(s,t,e){try{customElements.get(s)||r(s,t,e)}catch(a){var n=String(a||"");if(n.indexOf("already been used")===-1&&n.indexOf("NotSupportedError")===-1)throw a}}}}catch{}})();var h=Object.defineProperty,b=Object.getOwnPropertyDescriptor,l=(o,r,s,t)=>{for(var e=t>1?void 0:t?b(r,s):r,n=o.length-1,a;n>=0;n--)(a=o[n])&&(e=(t?a(r,s,e):a(e))||e);return t&&e&&h(r,s,e),e};let i=class extends p{constructor(){super(...arguments),this.label="",this.value="",this.selected=!1,this.icon="",this.disabled=!1}render(){const r=this.parentElement?.hasAttribute?.("disabled"),s=this.disabled||r,t=!!this.icon,e=!!this.label;return d`
|
|
2
|
+
<div class="segmented-item${t||this.selected?" has-icon":""}${e?"":" no-label"}" aria-disabled="${s?"true":"false"}">
|
|
3
|
+
<md-ripple ?disabled="${s}"></md-ripple>
|
|
4
|
+
${this.selected?t&&e?d`<md-icon>check</md-icon>`:t?d`<md-icon>check</md-icon><md-icon>${this.icon}</md-icon>`:d`<md-icon>check</md-icon>`:t?d`<md-icon>${this.icon}</md-icon>`:""}
|
|
5
|
+
${e?d`<span>${this.label}</span>`:""}
|
|
6
6
|
<md-focus-ring inward></md-focus-ring>
|
|
7
7
|
</div>
|
|
8
|
-
`}firstUpdated(){this.setAttribute("tabindex",this.disabled?"-1":"0"),this.setAttribute("role","button")}};
|
|
8
|
+
`}firstUpdated(){this.setAttribute("tabindex",this.disabled?"-1":"0"),this.setAttribute("role","button")}};i.styles=m`
|
|
9
9
|
.segmented-item {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
10
|
+
display: flex;
|
|
11
|
+
gap: var(--spacing-3);
|
|
12
|
+
align-items: center;
|
|
13
|
+
border: 1px solid var(--md-sys-color-outline);
|
|
14
|
+
border-left: none;
|
|
15
|
+
background-color: var(--md-sys-color-surface);
|
|
16
|
+
padding: var(--spacing-3) var(--spacing-4);
|
|
17
|
+
font: inherit;
|
|
18
|
+
cursor: pointer;
|
|
19
|
+
position: relative;
|
|
20
|
+
font-size: var(--md-sys-typescale-label-medium-size);
|
|
21
|
+
line-height: var(--md-sys-typescale-label-medium-line-height);
|
|
22
|
+
font-weight: var(--md-sys-typescale-label-medium-weight);
|
|
23
|
+
letter-spacing: var(--md-sys-typescale-label-medium-tracking);
|
|
24
|
+
color: var(--md-sys-color-on-surface);
|
|
25
|
+
justify-content: center;
|
|
26
|
+
height: 100%;
|
|
27
|
+
box-sizing: border-box;
|
|
28
|
+
}
|
|
29
|
+
.segmented-item span {
|
|
30
|
+
white-space: nowrap;
|
|
28
31
|
}
|
|
29
32
|
md-icon {
|
|
30
33
|
font-size: 20px;
|
|
31
|
-
width:
|
|
32
|
-
height:
|
|
34
|
+
width: 20px;
|
|
35
|
+
height: 20px;
|
|
33
36
|
}
|
|
34
37
|
:host([disabled]) .segmented-item,
|
|
35
38
|
.segmented-item[aria-disabled="true"] {
|
|
@@ -69,4 +72,4 @@ import{a as p,n as l,i as u,x as c,t as m}from"../../vendor/vendor.js";import"..
|
|
|
69
72
|
border-top-right-radius: var(--md-sys-shape-corner-full);
|
|
70
73
|
border-bottom-right-radius: var(--md-sys-shape-corner-full);
|
|
71
74
|
}
|
|
72
|
-
`;
|
|
75
|
+
`;l([c({type:String,reflect:!0})],i.prototype,"label",2);l([c({type:String,reflect:!0})],i.prototype,"value",2);l([c({type:Boolean,reflect:!0})],i.prototype,"selected",2);l([c({type:String,reflect:!0})],i.prototype,"icon",2);l([c({type:Boolean,reflect:!0})],i.prototype,"disabled",2);i=l([u("scb-segmented-item")],i);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "scb-wc-test",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.67",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.js",
|
|
@@ -288,5 +288,5 @@
|
|
|
288
288
|
},
|
|
289
289
|
"./mvc/*": "./mvc/*"
|
|
290
290
|
},
|
|
291
|
-
"buildHash": "
|
|
291
|
+
"buildHash": "22C1A767F3E412A91BA814122D67B359348A1D40CCFAA832CE2025A7575E496F"
|
|
292
292
|
}
|
|
@@ -25,6 +25,7 @@ export declare class ScbAccordionItem extends LitElement {
|
|
|
25
25
|
private _applyInertByOpen;
|
|
26
26
|
private _onToggle;
|
|
27
27
|
private _onKeyDown;
|
|
28
|
+
/** Programmatisk uppdatering som även speglar <details>. */
|
|
28
29
|
setOpen(on: boolean): void;
|
|
29
30
|
protected updated(changed: Map<string, unknown>): void;
|
|
30
31
|
protected render(): TemplateResult;
|
|
@@ -14,11 +14,7 @@ let e = class extends v {
|
|
|
14
14
|
const s = this.closest("scb-accordion");
|
|
15
15
|
this.open && s && !s.hasAttribute("detached") && s.querySelectorAll("scb-accordion-item").forEach((n) => {
|
|
16
16
|
n !== this && n.setOpen(!1);
|
|
17
|
-
}), this._applyInertByOpen()
|
|
18
|
-
detail: { open: this.open, title: this.title },
|
|
19
|
-
bubbles: !0,
|
|
20
|
-
composed: !0
|
|
21
|
-
}));
|
|
17
|
+
}), this._applyInertByOpen();
|
|
22
18
|
};
|
|
23
19
|
}
|
|
24
20
|
static _uid() {
|
|
@@ -52,6 +48,7 @@ let e = class extends v {
|
|
|
52
48
|
break;
|
|
53
49
|
}
|
|
54
50
|
}
|
|
51
|
+
/** Programmatisk uppdatering som även speglar <details>. */
|
|
55
52
|
setOpen(t) {
|
|
56
53
|
this.open = !!t;
|
|
57
54
|
const i = this.renderRoot.querySelector("details");
|
|
@@ -60,7 +57,11 @@ let e = class extends v {
|
|
|
60
57
|
updated(t) {
|
|
61
58
|
if (t.has("open")) {
|
|
62
59
|
const i = this.renderRoot.querySelector("details");
|
|
63
|
-
i && i.open !== this.open && (i.open = this.open), this._applyInertByOpen()
|
|
60
|
+
i && i.open !== this.open && (i.open = this.open), this._applyInertByOpen(), this.dispatchEvent(new CustomEvent("open-changed", {
|
|
61
|
+
detail: { open: this.open, title: this.title },
|
|
62
|
+
bubbles: !0,
|
|
63
|
+
composed: !0
|
|
64
|
+
}));
|
|
64
65
|
}
|
|
65
66
|
}
|
|
66
67
|
render() {
|
|
@@ -1,43 +1,55 @@
|
|
|
1
|
-
import { css as
|
|
2
|
-
import { property as
|
|
1
|
+
import { css as a, LitElement as c, html as m } from "lit";
|
|
2
|
+
import { property as n, customElement as h } from "lit/decorators.js";
|
|
3
3
|
import "./scb-segmented-item.js";
|
|
4
|
-
var
|
|
5
|
-
for (var
|
|
6
|
-
(
|
|
7
|
-
return
|
|
4
|
+
var b = Object.defineProperty, f = Object.getOwnPropertyDescriptor, d = (r, i, e, t) => {
|
|
5
|
+
for (var s = t > 1 ? void 0 : t ? f(i, e) : i, o = r.length - 1, u; o >= 0; o--)
|
|
6
|
+
(u = r[o]) && (s = (t ? u(i, e, s) : u(s)) || s);
|
|
7
|
+
return t && s && b(i, e, s), s;
|
|
8
8
|
};
|
|
9
|
-
let
|
|
9
|
+
let l = class extends c {
|
|
10
10
|
constructor() {
|
|
11
11
|
super(...arguments), this.variant = "single-select", this.value = "", this.values = [], this.disabled = !1;
|
|
12
12
|
}
|
|
13
|
-
onSlotClick(
|
|
14
|
-
let
|
|
15
|
-
if (!
|
|
16
|
-
const
|
|
17
|
-
if (!
|
|
18
|
-
const
|
|
19
|
-
|
|
13
|
+
onSlotClick(r) {
|
|
14
|
+
let i = r.target;
|
|
15
|
+
if (!i || !i.closest) return;
|
|
16
|
+
const e = i.closest("scb-segmented-item");
|
|
17
|
+
if (!e || this.disabled || e.hasAttribute("disabled")) return;
|
|
18
|
+
const t = e.getAttribute("value") || "";
|
|
19
|
+
t && (this.variant === "multi-select" ? (this.values.indexOf(t) === -1 ? this.values = [...this.values, t] : this.values = this.values.filter((o) => o !== t), this.dispatchEvent(new CustomEvent("change", { detail: { values: this.values }, bubbles: !0, composed: !0 })), this.updateSegments()) : t !== this.value && (this.value = t, this.dispatchEvent(new CustomEvent("change", { detail: { value: t }, bubbles: !0, composed: !0 })), this.updateSegments()));
|
|
20
20
|
}
|
|
21
21
|
updateSegments() {
|
|
22
|
-
var
|
|
23
|
-
const
|
|
24
|
-
if (!
|
|
25
|
-
|
|
26
|
-
if (
|
|
27
|
-
const
|
|
28
|
-
if (
|
|
29
|
-
let
|
|
30
|
-
this.variant === "multi-select" ?
|
|
22
|
+
var e;
|
|
23
|
+
const r = (e = this.shadowRoot) == null ? void 0 : e.querySelector("slot");
|
|
24
|
+
if (!r) return;
|
|
25
|
+
r.assignedElements().forEach((t) => {
|
|
26
|
+
if (t.tagName === "SCB-SEGMENTED-ITEM") {
|
|
27
|
+
const s = t.getAttribute("value") || "";
|
|
28
|
+
if (s) {
|
|
29
|
+
let o = !1;
|
|
30
|
+
this.variant === "multi-select" ? o = !!this.values && this.values.includes(s) : o = s === this.value, t.setAttribute("aria-pressed", o ? "true" : "false"), o ? t.setAttribute("selected", "true") : t.removeAttribute("selected");
|
|
31
31
|
}
|
|
32
|
-
this.disabled &&
|
|
32
|
+
this.disabled && t.setAttribute("disabled", "true");
|
|
33
33
|
}
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
36
|
firstUpdated() {
|
|
37
|
-
var
|
|
37
|
+
var i;
|
|
38
38
|
this.updateSegments();
|
|
39
|
-
const
|
|
40
|
-
|
|
39
|
+
const r = (i = this.shadowRoot) == null ? void 0 : i.querySelector("slot");
|
|
40
|
+
r && (r.addEventListener("click", (e) => this.onSlotClick(e)), r.addEventListener("focus", () => {
|
|
41
|
+
this.dispatchEvent(new CustomEvent("focus", { detail: {}, bubbles: !0, composed: !0 }));
|
|
42
|
+
}, !0), r.addEventListener("blur", () => {
|
|
43
|
+
this.dispatchEvent(new CustomEvent("blur", { detail: {}, bubbles: !0, composed: !0 }));
|
|
44
|
+
}, !0), r.addEventListener("keydown", (e) => {
|
|
45
|
+
if (e.code === "Space" || e.code === "Enter" || e.code === "NumpadEnter") {
|
|
46
|
+
const t = e.target;
|
|
47
|
+
if (t && t.closest) {
|
|
48
|
+
const s = t.closest("scb-segmented-item");
|
|
49
|
+
s && !s.hasAttribute("disabled") && !this.disabled && (this.onSlotClick(e), e.preventDefault());
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}));
|
|
41
53
|
}
|
|
42
54
|
updated() {
|
|
43
55
|
this.updateSegments();
|
|
@@ -46,9 +58,15 @@ let o = class extends c {
|
|
|
46
58
|
return m`<slot></slot>`;
|
|
47
59
|
}
|
|
48
60
|
};
|
|
49
|
-
|
|
61
|
+
l.styles = a`
|
|
50
62
|
:host {
|
|
51
|
-
|
|
63
|
+
--scb-segmented-button-width: 100%;
|
|
64
|
+
--scb-segmented-button-height: 48px;
|
|
65
|
+
max-width: var(--scb-segmented-button-width);
|
|
66
|
+
height: var(--scb-segmented-button-height);
|
|
67
|
+
display: grid;
|
|
68
|
+
grid-auto-flow: column;
|
|
69
|
+
grid-auto-columns: 1fr;
|
|
52
70
|
}
|
|
53
71
|
/* Border radius only on first and last button */
|
|
54
72
|
::slotted(scb-segmented-item:first-child .segmented-item),
|
|
@@ -67,21 +85,21 @@ o.styles = u`
|
|
|
67
85
|
border-left: 1px solid var(--md-sys-color-outline);
|
|
68
86
|
}
|
|
69
87
|
`;
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
],
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
],
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
],
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
],
|
|
82
|
-
|
|
88
|
+
d([
|
|
89
|
+
n({ type: String, reflect: !0 })
|
|
90
|
+
], l.prototype, "variant", 2);
|
|
91
|
+
d([
|
|
92
|
+
n({ type: String, reflect: !0 })
|
|
93
|
+
], l.prototype, "value", 2);
|
|
94
|
+
d([
|
|
95
|
+
n({ type: Array })
|
|
96
|
+
], l.prototype, "values", 2);
|
|
97
|
+
d([
|
|
98
|
+
n({ type: Boolean, reflect: !0 })
|
|
99
|
+
], l.prototype, "disabled", 2);
|
|
100
|
+
l = d([
|
|
83
101
|
h("scb-segmented-button")
|
|
84
|
-
],
|
|
102
|
+
], l);
|
|
85
103
|
export {
|
|
86
|
-
|
|
104
|
+
l as ScbSegmentedButton
|
|
87
105
|
};
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { css as
|
|
2
|
-
import { property as l, customElement as
|
|
1
|
+
import { css as m, LitElement as p, html as d } from "lit";
|
|
2
|
+
import { property as l, customElement as h } from "lit/decorators.js";
|
|
3
3
|
import "@material/web/icon/icon.js";
|
|
4
4
|
import "@material/web/focus/md-focus-ring.js";
|
|
5
5
|
import "@material/web/ripple/ripple.js";
|
|
6
|
-
var
|
|
7
|
-
for (var
|
|
8
|
-
(
|
|
9
|
-
return
|
|
6
|
+
var u = Object.defineProperty, b = Object.getOwnPropertyDescriptor, a = (s, o, i, t) => {
|
|
7
|
+
for (var e = t > 1 ? void 0 : t ? b(o, i) : o, n = s.length - 1, c; n >= 0; n--)
|
|
8
|
+
(c = s[n]) && (e = (t ? c(o, i, e) : c(e)) || e);
|
|
9
|
+
return t && e && u(o, i, e), e;
|
|
10
10
|
};
|
|
11
|
-
let
|
|
11
|
+
let r = class extends p {
|
|
12
12
|
constructor() {
|
|
13
13
|
super(...arguments), this.label = "", this.value = "", this.selected = !1, this.icon = "", this.disabled = !1;
|
|
14
14
|
}
|
|
15
15
|
render() {
|
|
16
|
-
var
|
|
17
|
-
const
|
|
18
|
-
return
|
|
19
|
-
<div class="segmented-item" aria-disabled="${i ? "true" : "false"}">
|
|
16
|
+
var n;
|
|
17
|
+
const s = this.parentElement, o = (n = s == null ? void 0 : s.hasAttribute) == null ? void 0 : n.call(s, "disabled"), i = this.disabled || o, t = !!this.icon, e = !!this.label;
|
|
18
|
+
return d`
|
|
19
|
+
<div class="segmented-item${t || this.selected ? " has-icon" : ""}${e ? "" : " no-label"}" aria-disabled="${i ? "true" : "false"}">
|
|
20
20
|
<md-ripple ?disabled="${i}"></md-ripple>
|
|
21
|
-
${this.icon ?
|
|
22
|
-
|
|
21
|
+
${this.selected ? t && e ? d`<md-icon>check</md-icon>` : t ? d`<md-icon>check</md-icon><md-icon>${this.icon}</md-icon>` : d`<md-icon>check</md-icon>` : t ? d`<md-icon>${this.icon}</md-icon>` : ""}
|
|
22
|
+
${e ? d`<span>${this.label}</span>` : ""}
|
|
23
23
|
<md-focus-ring inward></md-focus-ring>
|
|
24
24
|
</div>
|
|
25
25
|
`;
|
|
@@ -28,31 +28,34 @@ let t = class extends m {
|
|
|
28
28
|
this.setAttribute("tabindex", this.disabled ? "-1" : "0"), this.setAttribute("role", "button");
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
|
-
|
|
31
|
+
r.styles = m`
|
|
32
32
|
.segmented-item {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
33
|
+
display: flex;
|
|
34
|
+
gap: var(--spacing-3);
|
|
35
|
+
align-items: center;
|
|
36
|
+
border: 1px solid var(--md-sys-color-outline);
|
|
37
|
+
border-left: none;
|
|
38
|
+
background-color: var(--md-sys-color-surface);
|
|
39
|
+
padding: var(--spacing-3) var(--spacing-4);
|
|
40
|
+
font: inherit;
|
|
41
|
+
cursor: pointer;
|
|
42
|
+
position: relative;
|
|
43
|
+
font-size: var(--md-sys-typescale-label-medium-size);
|
|
44
|
+
line-height: var(--md-sys-typescale-label-medium-line-height);
|
|
45
|
+
font-weight: var(--md-sys-typescale-label-medium-weight);
|
|
46
|
+
letter-spacing: var(--md-sys-typescale-label-medium-tracking);
|
|
47
|
+
color: var(--md-sys-color-on-surface);
|
|
48
|
+
justify-content: center;
|
|
49
|
+
height: 100%;
|
|
50
|
+
box-sizing: border-box;
|
|
51
|
+
}
|
|
52
|
+
.segmented-item span {
|
|
53
|
+
white-space: nowrap;
|
|
51
54
|
}
|
|
52
55
|
md-icon {
|
|
53
56
|
font-size: 20px;
|
|
54
|
-
width:
|
|
55
|
-
height:
|
|
57
|
+
width: 20px;
|
|
58
|
+
height: 20px;
|
|
56
59
|
}
|
|
57
60
|
:host([disabled]) .segmented-item,
|
|
58
61
|
.segmented-item[aria-disabled="true"] {
|
|
@@ -95,22 +98,22 @@ t.styles = p`
|
|
|
95
98
|
`;
|
|
96
99
|
a([
|
|
97
100
|
l({ type: String, reflect: !0 })
|
|
98
|
-
],
|
|
101
|
+
], r.prototype, "label", 2);
|
|
99
102
|
a([
|
|
100
103
|
l({ type: String, reflect: !0 })
|
|
101
|
-
],
|
|
104
|
+
], r.prototype, "value", 2);
|
|
102
105
|
a([
|
|
103
106
|
l({ type: Boolean, reflect: !0 })
|
|
104
|
-
],
|
|
107
|
+
], r.prototype, "selected", 2);
|
|
105
108
|
a([
|
|
106
109
|
l({ type: String, reflect: !0 })
|
|
107
|
-
],
|
|
110
|
+
], r.prototype, "icon", 2);
|
|
108
111
|
a([
|
|
109
112
|
l({ type: Boolean, reflect: !0 })
|
|
110
|
-
],
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
],
|
|
113
|
+
], r.prototype, "disabled", 2);
|
|
114
|
+
r = a([
|
|
115
|
+
h("scb-segmented-item")
|
|
116
|
+
], r);
|
|
114
117
|
export {
|
|
115
|
-
|
|
118
|
+
r as ScbSegmentedItem
|
|
116
119
|
};
|
package/scb-wc-test.bundle.js
CHANGED
|
@@ -1667,7 +1667,7 @@ var ScbWcTest=function(a){"use strict";var Ss;function d(o,e,t,r){var i=argument
|
|
|
1667
1667
|
* @license
|
|
1668
1668
|
* Copyright 2021 Google LLC
|
|
1669
1669
|
* SPDX-License-Identifier: Apache-2.0
|
|
1670
|
-
*/let vo=class extends _c{constructor(){super(...arguments),this.fieldTag=J`md-outlined-field`}};vo.styles=[Ga,yc],vo=d([g("md-outlined-text-field")],vo);var xc=Object.defineProperty,wc=Object.getOwnPropertyDescriptor,X=(o,e,t,r)=>{for(var i=r>1?void 0:r?wc(e,t):e,s=o.length-1,n;s>=0;s--)(n=o[s])&&(i=(r?n(e,t,i):n(i))||i);return r&&i&&xc(e,t,i),i};a.ScbAccordionItem=class extends y{constructor(){super(...arguments),this.open=!1,this.title="",this.content="",this.overline="",this.supportingText="",this.leading=!1,this.leadingVariant="",this.leadingIcon="",this.imgHrefImage="",this.avatarLabel="",this.avatarAlt="",this.avatarVariant="icon",this.avatarSrc="",this.density=0,this._unique=a.ScbAccordionItem._uid(),this._onToggle=e=>{const t=e.currentTarget;this.open=!!t.open;const r=this.closest("scb-accordion");this.open&&r&&!r.hasAttribute("detached")&&r.querySelectorAll("scb-accordion-item").forEach(s=>{s!==this&&s.setOpen(!1)}),this._applyInertByOpen()
|
|
1670
|
+
*/let vo=class extends _c{constructor(){super(...arguments),this.fieldTag=J`md-outlined-field`}};vo.styles=[Ga,yc],vo=d([g("md-outlined-text-field")],vo);var xc=Object.defineProperty,wc=Object.getOwnPropertyDescriptor,X=(o,e,t,r)=>{for(var i=r>1?void 0:r?wc(e,t):e,s=o.length-1,n;s>=0;s--)(n=o[s])&&(i=(r?n(e,t,i):n(i))||i);return r&&i&&xc(e,t,i),i};a.ScbAccordionItem=class extends y{constructor(){super(...arguments),this.open=!1,this.title="",this.content="",this.overline="",this.supportingText="",this.leading=!1,this.leadingVariant="",this.leadingIcon="",this.imgHrefImage="",this.avatarLabel="",this.avatarAlt="",this.avatarVariant="icon",this.avatarSrc="",this.density=0,this._unique=a.ScbAccordionItem._uid(),this._onToggle=e=>{const t=e.currentTarget;this.open=!!t.open;const r=this.closest("scb-accordion");this.open&&r&&!r.hasAttribute("detached")&&r.querySelectorAll("scb-accordion-item").forEach(s=>{s!==this&&s.setOpen(!1)}),this._applyInertByOpen()}}static _uid(){var e,t;return((t=(e=globalThis.crypto)==null?void 0:e.randomUUID)==null?void 0:t.call(e))??`${a.ScbAccordionItem._uidPrefix}-${++a.ScbAccordionItem._uidSeq}`}async firstUpdated(){a.ScbAccordionItem._mdIconLoaded||(await Promise.resolve().then(()=>Y),a.ScbAccordionItem._mdIconLoaded=!0),a.ScbAccordionItem._mdRippleLoaded||(await Promise.resolve().then(()=>br),a.ScbAccordionItem._mdRippleLoaded=!0),this._applyInertByOpen()}_applyInertByOpen(){const e=this.renderRoot.querySelector(".scb-accordion-bottom"),t=this.renderRoot.querySelector("details");!e||!t||(t.open?(e.removeAttribute("inert"),e.setAttribute("aria-hidden","false")):(e.setAttribute("inert",""),e.setAttribute("aria-hidden","true")))}_onKeyDown(e){const t=this.closest("scb-accordion"),i=Array.from((t==null?void 0:t.querySelectorAll("scb-accordion-item"))||[]).map(h=>{var p;return((p=h.renderRoot.querySelector("details"))==null?void 0:p.querySelector(".scb-accordion-top"))||null}).filter(h=>!!h),s=e.currentTarget,n=i.indexOf(s);switch(e.key){case"ArrowDown":e.preventDefault(),n<i.length-1&&i[n+1].focus();break;case"ArrowUp":e.preventDefault(),n>0&&i[n-1].focus();break;case"Home":e.preventDefault(),i.length&&i[0].focus();break;case"End":e.preventDefault(),i.length&&i[i.length-1].focus();break}}setOpen(e){this.open=!!e;const t=this.renderRoot.querySelector("details");t&&(t.open=this.open),this._applyInertByOpen()}updated(e){if(e.has("open")){const t=this.renderRoot.querySelector("details");t&&t.open!==this.open&&(t.open=this.open),this._applyInertByOpen(),this.dispatchEvent(new CustomEvent("open-changed",{detail:{open:this.open,title:this.title},bubbles:!0,composed:!0}))}}render(){const e=`bottom-${this._unique}`,t=`header-${this._unique}`,r=this.leading?this.leadingVariant==="image"&&this.imgHrefImage?c`<img part="leading-image" class="img" src="${this.imgHrefImage}" alt="" />`:this.leadingVariant==="avatar"?c`
|
|
1671
1671
|
<scb-avatar
|
|
1672
1672
|
label=${this.avatarLabel}
|
|
1673
1673
|
alt=${this.avatarAlt}
|
|
@@ -5918,38 +5918,41 @@ var ScbWcTest=function(a){"use strict";var Ss;function d(o,e,t,r){var i=argument
|
|
|
5918
5918
|
:host([spacing="group"]) ::slotted(scb-radio-button) {
|
|
5919
5919
|
--scb-radio-gap: 0;
|
|
5920
5920
|
}
|
|
5921
|
-
`,Et([l({type:String})],a.ScbRadioGroup.prototype,"name",2),Et([l({type:String,reflect:!0})],a.ScbRadioGroup.prototype,"orientation",2),Et([l({type:Boolean,reflect:!0})],a.ScbRadioGroup.prototype,"disabled",2),Et([l({type:String,attribute:"aria-label"})],a.ScbRadioGroup.prototype,"ariaLabel",2),Et([l({type:String,reflect:!0})],a.ScbRadioGroup.prototype,"spacing",2),a.ScbRadioGroup=Et([g("scb-radio-group")],a.ScbRadioGroup);var Ih=Object.defineProperty,zh=Object.getOwnPropertyDescriptor,At=(o,e,t,r)=>{for(var i=r>1?void 0:r?zh(e,t):e,s=o.length-1,n;s>=0;s--)(n=o[s])&&(i=(r?n(e,t,i):n(i))||i);return r&&i&&Ih(e,t,i),i};a.ScbSegmentedItem=class extends y{constructor(){super(...arguments),this.label="",this.value="",this.selected=!1,this.icon="",this.disabled=!1}render(){var
|
|
5922
|
-
<div class="segmented-item" aria-disabled="${r?"true":"false"}">
|
|
5921
|
+
`,Et([l({type:String})],a.ScbRadioGroup.prototype,"name",2),Et([l({type:String,reflect:!0})],a.ScbRadioGroup.prototype,"orientation",2),Et([l({type:Boolean,reflect:!0})],a.ScbRadioGroup.prototype,"disabled",2),Et([l({type:String,attribute:"aria-label"})],a.ScbRadioGroup.prototype,"ariaLabel",2),Et([l({type:String,reflect:!0})],a.ScbRadioGroup.prototype,"spacing",2),a.ScbRadioGroup=Et([g("scb-radio-group")],a.ScbRadioGroup);var Ih=Object.defineProperty,zh=Object.getOwnPropertyDescriptor,At=(o,e,t,r)=>{for(var i=r>1?void 0:r?zh(e,t):e,s=o.length-1,n;s>=0;s--)(n=o[s])&&(i=(r?n(e,t,i):n(i))||i);return r&&i&&Ih(e,t,i),i};a.ScbSegmentedItem=class extends y{constructor(){super(...arguments),this.label="",this.value="",this.selected=!1,this.icon="",this.disabled=!1}render(){var n;const e=this.parentElement,t=(n=e==null?void 0:e.hasAttribute)==null?void 0:n.call(e,"disabled"),r=this.disabled||t,i=!!this.icon,s=!!this.label;return c`
|
|
5922
|
+
<div class="segmented-item${i||this.selected?" has-icon":""}${s?"":" no-label"}" aria-disabled="${r?"true":"false"}">
|
|
5923
5923
|
<md-ripple ?disabled="${r}"></md-ripple>
|
|
5924
|
-
${this.icon?c`<md-icon>${this.icon}</md-icon>`:""}
|
|
5925
|
-
|
|
5924
|
+
${this.selected?i&&s?c`<md-icon>check</md-icon>`:i?c`<md-icon>check</md-icon><md-icon>${this.icon}</md-icon>`:c`<md-icon>check</md-icon>`:i?c`<md-icon>${this.icon}</md-icon>`:""}
|
|
5925
|
+
${s?c`<span>${this.label}</span>`:""}
|
|
5926
5926
|
<md-focus-ring inward></md-focus-ring>
|
|
5927
5927
|
</div>
|
|
5928
5928
|
`}firstUpdated(){this.setAttribute("tabindex",this.disabled?"-1":"0"),this.setAttribute("role","button")}},a.ScbSegmentedItem.styles=b`
|
|
5929
5929
|
.segmented-item {
|
|
5930
|
-
|
|
5931
|
-
|
|
5932
|
-
|
|
5933
|
-
|
|
5934
|
-
|
|
5935
|
-
|
|
5936
|
-
|
|
5937
|
-
|
|
5938
|
-
|
|
5939
|
-
|
|
5940
|
-
|
|
5941
|
-
|
|
5942
|
-
|
|
5943
|
-
|
|
5944
|
-
|
|
5945
|
-
|
|
5946
|
-
|
|
5947
|
-
|
|
5930
|
+
display: flex;
|
|
5931
|
+
gap: var(--spacing-3);
|
|
5932
|
+
align-items: center;
|
|
5933
|
+
border: 1px solid var(--md-sys-color-outline);
|
|
5934
|
+
border-left: none;
|
|
5935
|
+
background-color: var(--md-sys-color-surface);
|
|
5936
|
+
padding: var(--spacing-3) var(--spacing-4);
|
|
5937
|
+
font: inherit;
|
|
5938
|
+
cursor: pointer;
|
|
5939
|
+
position: relative;
|
|
5940
|
+
font-size: var(--md-sys-typescale-label-medium-size);
|
|
5941
|
+
line-height: var(--md-sys-typescale-label-medium-line-height);
|
|
5942
|
+
font-weight: var(--md-sys-typescale-label-medium-weight);
|
|
5943
|
+
letter-spacing: var(--md-sys-typescale-label-medium-tracking);
|
|
5944
|
+
color: var(--md-sys-color-on-surface);
|
|
5945
|
+
justify-content: center;
|
|
5946
|
+
height: 100%;
|
|
5947
|
+
box-sizing: border-box;
|
|
5948
|
+
}
|
|
5949
|
+
.segmented-item span {
|
|
5950
|
+
white-space: nowrap;
|
|
5948
5951
|
}
|
|
5949
5952
|
md-icon {
|
|
5950
5953
|
font-size: 20px;
|
|
5951
|
-
width:
|
|
5952
|
-
height:
|
|
5954
|
+
width: 20px;
|
|
5955
|
+
height: 20px;
|
|
5953
5956
|
}
|
|
5954
5957
|
:host([disabled]) .segmented-item,
|
|
5955
5958
|
.segmented-item[aria-disabled="true"] {
|
|
@@ -5989,9 +5992,15 @@ var ScbWcTest=function(a){"use strict";var Ss;function d(o,e,t,r){var i=argument
|
|
|
5989
5992
|
border-top-right-radius: var(--md-sys-shape-corner-full);
|
|
5990
5993
|
border-bottom-right-radius: var(--md-sys-shape-corner-full);
|
|
5991
5994
|
}
|
|
5992
|
-
`,At([l({type:String,reflect:!0})],a.ScbSegmentedItem.prototype,"label",2),At([l({type:String,reflect:!0})],a.ScbSegmentedItem.prototype,"value",2),At([l({type:Boolean,reflect:!0})],a.ScbSegmentedItem.prototype,"selected",2),At([l({type:String,reflect:!0})],a.ScbSegmentedItem.prototype,"icon",2),At([l({type:Boolean,reflect:!0})],a.ScbSegmentedItem.prototype,"disabled",2),a.ScbSegmentedItem=At([g("scb-segmented-item")],a.ScbSegmentedItem);var Th=Object.defineProperty,Oh=Object.getOwnPropertyDescriptor,lr=(o,e,t,r)=>{for(var i=r>1?void 0:r?Oh(e,t):e,s=o.length-1,n;s>=0;s--)(n=o[s])&&(i=(r?n(e,t,i):n(i))||i);return r&&i&&Th(e,t,i),i};a.ScbSegmentedButton=class extends y{constructor(){super(...arguments),this.variant="single-select",this.value="",this.values=[],this.disabled=!1}onSlotClick(e){let t=e.target;if(!t||!t.closest)return;const r=t.closest("scb-segmented-item");if(!r||this.disabled||r.hasAttribute("disabled"))return;const i=r.getAttribute("value")||"";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(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(){var r;const e=(r=this.shadowRoot)==null?void 0:r.querySelector("slot");if(!e)return;e.assignedElements().forEach(i=>{if(i.tagName==="SCB-SEGMENTED-ITEM"){const s=i.getAttribute("value")||"";if(s){let n=!1;this.variant==="multi-select"?n=!!this.values&&this.values.includes(s):n=s===this.value,i.setAttribute("aria-pressed",n?"true":"false")}this.disabled&&i.setAttribute("disabled","true")}})}firstUpdated(){var t;this.updateSegments();const e=(t=this.shadowRoot)==null?void 0:t.querySelector("slot");e&&e.addEventListener("click",r=>this.onSlotClick(r))}updated(){this.updateSegments()}render(){return c`<slot></slot>`}},a.ScbSegmentedButton.styles=b`
|
|
5995
|
+
`,At([l({type:String,reflect:!0})],a.ScbSegmentedItem.prototype,"label",2),At([l({type:String,reflect:!0})],a.ScbSegmentedItem.prototype,"value",2),At([l({type:Boolean,reflect:!0})],a.ScbSegmentedItem.prototype,"selected",2),At([l({type:String,reflect:!0})],a.ScbSegmentedItem.prototype,"icon",2),At([l({type:Boolean,reflect:!0})],a.ScbSegmentedItem.prototype,"disabled",2),a.ScbSegmentedItem=At([g("scb-segmented-item")],a.ScbSegmentedItem);var Th=Object.defineProperty,Oh=Object.getOwnPropertyDescriptor,lr=(o,e,t,r)=>{for(var i=r>1?void 0:r?Oh(e,t):e,s=o.length-1,n;s>=0;s--)(n=o[s])&&(i=(r?n(e,t,i):n(i))||i);return r&&i&&Th(e,t,i),i};a.ScbSegmentedButton=class extends y{constructor(){super(...arguments),this.variant="single-select",this.value="",this.values=[],this.disabled=!1}onSlotClick(e){let t=e.target;if(!t||!t.closest)return;const r=t.closest("scb-segmented-item");if(!r||this.disabled||r.hasAttribute("disabled"))return;const i=r.getAttribute("value")||"";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(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(){var r;const e=(r=this.shadowRoot)==null?void 0:r.querySelector("slot");if(!e)return;e.assignedElements().forEach(i=>{if(i.tagName==="SCB-SEGMENTED-ITEM"){const s=i.getAttribute("value")||"";if(s){let n=!1;this.variant==="multi-select"?n=!!this.values&&this.values.includes(s):n=s===this.value,i.setAttribute("aria-pressed",n?"true":"false"),n?i.setAttribute("selected","true"):i.removeAttribute("selected")}this.disabled&&i.setAttribute("disabled","true")}})}firstUpdated(){var t;this.updateSegments();const e=(t=this.shadowRoot)==null?void 0:t.querySelector("slot");e&&(e.addEventListener("click",r=>this.onSlotClick(r)),e.addEventListener("focus",()=>{this.dispatchEvent(new CustomEvent("focus",{detail:{},bubbles:!0,composed:!0}))},!0),e.addEventListener("blur",()=>{this.dispatchEvent(new CustomEvent("blur",{detail:{},bubbles:!0,composed:!0}))},!0),e.addEventListener("keydown",r=>{if(r.code==="Space"||r.code==="Enter"||r.code==="NumpadEnter"){const i=r.target;if(i&&i.closest){const s=i.closest("scb-segmented-item");s&&!s.hasAttribute("disabled")&&!this.disabled&&(this.onSlotClick(r),r.preventDefault())}}}))}updated(){this.updateSegments()}render(){return c`<slot></slot>`}},a.ScbSegmentedButton.styles=b`
|
|
5993
5996
|
:host {
|
|
5994
|
-
|
|
5997
|
+
--scb-segmented-button-width: 100%;
|
|
5998
|
+
--scb-segmented-button-height: 48px;
|
|
5999
|
+
max-width: var(--scb-segmented-button-width);
|
|
6000
|
+
height: var(--scb-segmented-button-height);
|
|
6001
|
+
display: grid;
|
|
6002
|
+
grid-auto-flow: column;
|
|
6003
|
+
grid-auto-columns: 1fr;
|
|
5995
6004
|
}
|
|
5996
6005
|
/* Border radius only on first and last button */
|
|
5997
6006
|
::slotted(scb-segmented-item:first-child .segmented-item),
|