scb-wc-test 0.1.63 → 0.1.64
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/all.js +4 -0
- package/index.d.ts +2 -0
- package/index.js +40 -36
- package/mvc/components/all.js +2 -0
- package/mvc/components/scb-segmented-button/scb-segmented-button.js +21 -0
- package/mvc/components/scb-segmented-button/scb-segmented-item.js +72 -0
- package/package.json +10 -2
- package/scb-segmented-button/scb-segmented-button.d.ts +25 -0
- package/scb-segmented-button/scb-segmented-button.js +87 -0
- package/scb-segmented-button/scb-segmented-item.d.ts +15 -0
- package/scb-segmented-button/scb-segmented-item.js +116 -0
- package/scb-wc-test.bundle.js +414 -323
package/all.js
CHANGED
|
@@ -46,6 +46,8 @@ import './mvc/components/scb-progress-indicator/scb-progress-indicator.js';
|
|
|
46
46
|
import './mvc/components/scb-radio-button/scb-radio-button.js';
|
|
47
47
|
import './mvc/components/scb-radio-button/scb-radio-group.js';
|
|
48
48
|
import './mvc/components/scb-search/scb-search.js';
|
|
49
|
+
import './mvc/components/scb-segmented-button/scb-segmented-button.js';
|
|
50
|
+
import './mvc/components/scb-segmented-button/scb-segmented-item.js';
|
|
49
51
|
import './mvc/components/scb-snackbar/scb-snackbar.js';
|
|
50
52
|
import './mvc/components/scb-status-pill/scb-status-pill.js';
|
|
51
53
|
import './mvc/components/scb-switch/scb-switch.js';
|
|
@@ -105,6 +107,8 @@ import './scb-progress-indicator/scb-progress-indicator.js';
|
|
|
105
107
|
import './scb-radio-button/scb-radio-button.js';
|
|
106
108
|
import './scb-radio-button/scb-radio-group.js';
|
|
107
109
|
import './scb-search/scb-search.js';
|
|
110
|
+
import './scb-segmented-button/scb-segmented-button.js';
|
|
111
|
+
import './scb-segmented-button/scb-segmented-item.js';
|
|
108
112
|
import './scb-snackbar/scb-snackbar.js';
|
|
109
113
|
import './scb-status-pill/scb-status-pill.js';
|
|
110
114
|
import './scb-switch/scb-switch.js';
|
package/index.d.ts
CHANGED
|
@@ -43,6 +43,8 @@ export * from './scb-progress-indicator/scb-progress-indicator';
|
|
|
43
43
|
export * from './scb-radio-button/scb-radio-button';
|
|
44
44
|
export * from './scb-radio-button/scb-radio-group';
|
|
45
45
|
export * from './scb-search/scb-search';
|
|
46
|
+
export * from './scb-segmented-button/scb-segmented-button';
|
|
47
|
+
export * from './scb-segmented-button/scb-segmented-item';
|
|
46
48
|
export * from './scb-snackbar/scb-snackbar';
|
|
47
49
|
export * from './scb-status-pill/scb-status-pill';
|
|
48
50
|
export * from './scb-switch/scb-switch';
|
package/index.js
CHANGED
|
@@ -6,13 +6,13 @@ import { SCBBreadcrumbItem as f } from "./scb-breadcrumb/scb-breadcrumb-item.js"
|
|
|
6
6
|
import { SCBBreadcrumb as i } from "./scb-breadcrumb/scb-breadcrumb.js";
|
|
7
7
|
import { ScbButton as n } from "./scb-button/scb-button.js";
|
|
8
8
|
import { ScbCalendarCard as C } from "./scb-calendar-card/scb-calendar-card.js";
|
|
9
|
-
import { ScbCard as
|
|
9
|
+
import { ScbCard as l } from "./scb-card/scb-card.js";
|
|
10
10
|
import { ScbCheckboxGroup as D } from "./scb-checkbox/scb-checkbox-group.js";
|
|
11
11
|
import { ScbCheckbox as w } from "./scb-checkbox/scb-checkbox.js";
|
|
12
12
|
import { ScbChip as F } from "./scb-chip/scb-chip.js";
|
|
13
|
-
import { ScbDialog as
|
|
14
|
-
import { ScbDivider as
|
|
15
|
-
import { ScbDrawerItem as
|
|
13
|
+
import { ScbDialog as g } from "./scb-dialog/scb-dialog.js";
|
|
14
|
+
import { ScbDivider as k } from "./scb-divider/scb-divider.js";
|
|
15
|
+
import { ScbDrawerItem as y } from "./scb-drawer/scb-drawer-item.js";
|
|
16
16
|
import { ScbDrawerSection as L } from "./scb-drawer/scb-drawer-section.js";
|
|
17
17
|
import { ScbDrawer as P } from "./scb-drawer/scb-drawer.js";
|
|
18
18
|
import { ScbSubDrawer as N } from "./scb-drawer/scb-sub-drawer.js";
|
|
@@ -33,26 +33,28 @@ import { ScbIconButton as fr } from "./scb-icon-button/scb-icon-button.js";
|
|
|
33
33
|
import { ScbKeyFigureCard as ir } from "./scb-keyfigure-card/scb-keyfigure-card.js";
|
|
34
34
|
import { ScbLink as nr } from "./scb-link/scb-link.js";
|
|
35
35
|
import { ScbListItem as Cr } from "./scb-list/scb-list-item.js";
|
|
36
|
-
import { ScbList as
|
|
36
|
+
import { ScbList as lr } from "./scb-list/scb-list.js";
|
|
37
37
|
import { ScbMenuItem as Dr } from "./scb-menu/scb-menu-item.js";
|
|
38
38
|
import { ScbMenu as wr } from "./scb-menu/scb-menu.js";
|
|
39
39
|
import { ScbSubMenu as Fr } from "./scb-menu/scb-sub-menu.js";
|
|
40
|
-
import { ScbNotification as
|
|
41
|
-
import { ScbNotificationCard as
|
|
42
|
-
import { ScbProgressIndicator as
|
|
40
|
+
import { ScbNotification as gr } from "./scb-notification/scb-notification.js";
|
|
41
|
+
import { ScbNotificationCard as kr } from "./scb-notification-card/scb-notification-card.js";
|
|
42
|
+
import { ScbProgressIndicator as yr } from "./scb-progress-indicator/scb-progress-indicator.js";
|
|
43
43
|
import { ScbRadioButton as Lr } from "./scb-radio-button/scb-radio-button.js";
|
|
44
44
|
import { ScbRadioGroup as Pr } from "./scb-radio-button/scb-radio-group.js";
|
|
45
45
|
import { ScbSearch as Nr } from "./scb-search/scb-search.js";
|
|
46
|
-
import {
|
|
47
|
-
import {
|
|
48
|
-
import {
|
|
49
|
-
import {
|
|
50
|
-
import {
|
|
51
|
-
import {
|
|
52
|
-
import {
|
|
53
|
-
import {
|
|
54
|
-
import {
|
|
55
|
-
import {
|
|
46
|
+
import { ScbSegmentedButton as zr } from "./scb-segmented-button/scb-segmented-button.js";
|
|
47
|
+
import { ScbSegmentedItem as Ur } from "./scb-segmented-button/scb-segmented-item.js";
|
|
48
|
+
import { ScbSnackbar as qr } from "./scb-snackbar/scb-snackbar.js";
|
|
49
|
+
import { ScbStatusPill as Jr } from "./scb-status-pill/scb-status-pill.js";
|
|
50
|
+
import { ScbSwitch as Qr } from "./scb-switch/scb-switch.js";
|
|
51
|
+
import { ScbPrimaryTab as Wr } from "./scb-tabs/scb-primary-tab.js";
|
|
52
|
+
import { ScbSecondaryTab as Yr } from "./scb-tabs/scb-secondary-tab.js";
|
|
53
|
+
import { ScbTabs as _r } from "./scb-tabs/scb-tabs.js";
|
|
54
|
+
import { ScbTextField2 as ro } from "./scb-textfield/scb-textfield.js";
|
|
55
|
+
import { ScbTocItem as eo } from "./scb-toc/scb-toc-item.js";
|
|
56
|
+
import { ScbToc as co } from "./scb-toc/scb-toc.js";
|
|
57
|
+
import { ScbTooltip as So } from "./scb-tooltip/scb-tooltip.js";
|
|
56
58
|
export {
|
|
57
59
|
i as SCBBreadcrumb,
|
|
58
60
|
f as SCBBreadcrumbItem,
|
|
@@ -62,14 +64,14 @@ export {
|
|
|
62
64
|
p as ScbAvatar,
|
|
63
65
|
n as ScbButton,
|
|
64
66
|
C as ScbCalendarCard,
|
|
65
|
-
|
|
67
|
+
l as ScbCard,
|
|
66
68
|
w as ScbCheckbox,
|
|
67
69
|
D as ScbCheckboxGroup,
|
|
68
70
|
F as ScbChip,
|
|
69
|
-
|
|
70
|
-
|
|
71
|
+
g as ScbDialog,
|
|
72
|
+
k as ScbDivider,
|
|
71
73
|
P as ScbDrawer,
|
|
72
|
-
|
|
74
|
+
y as ScbDrawerItem,
|
|
73
75
|
L as ScbDrawerSection,
|
|
74
76
|
U as ScbFactCard,
|
|
75
77
|
z as ScbFactCardContent,
|
|
@@ -86,27 +88,29 @@ export {
|
|
|
86
88
|
fr as ScbIconButton,
|
|
87
89
|
ir as ScbKeyFigureCard,
|
|
88
90
|
nr as ScbLink,
|
|
89
|
-
|
|
91
|
+
lr as ScbList,
|
|
90
92
|
Cr as ScbListItem,
|
|
91
93
|
wr as ScbMenu,
|
|
92
94
|
Dr as ScbMenuItem,
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
gr as ScbNotification,
|
|
96
|
+
kr as ScbNotificationCard,
|
|
97
|
+
Wr as ScbPrimaryTab,
|
|
98
|
+
yr as ScbProgressIndicator,
|
|
97
99
|
Lr as ScbRadioButton,
|
|
98
100
|
Pr as ScbRadioGroup,
|
|
99
101
|
Nr as ScbSearch,
|
|
100
|
-
|
|
101
|
-
zr as
|
|
102
|
+
Yr as ScbSecondaryTab,
|
|
103
|
+
zr as ScbSegmentedButton,
|
|
104
|
+
Ur as ScbSegmentedItem,
|
|
105
|
+
qr as ScbSnackbar,
|
|
102
106
|
Y as ScbStack,
|
|
103
|
-
|
|
107
|
+
Jr as ScbStatusPill,
|
|
104
108
|
N as ScbSubDrawer,
|
|
105
109
|
Fr as ScbSubMenu,
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
110
|
+
Qr as ScbSwitch,
|
|
111
|
+
_r as ScbTabs,
|
|
112
|
+
ro as ScbTextField2,
|
|
113
|
+
co as ScbToc,
|
|
114
|
+
eo as ScbTocItem,
|
|
115
|
+
So as ScbTooltip
|
|
112
116
|
};
|
package/mvc/components/all.js
CHANGED
|
@@ -43,6 +43,8 @@ import './scb-progress-indicator/scb-progress-indicator.js';
|
|
|
43
43
|
import './scb-radio-button/scb-radio-button.js';
|
|
44
44
|
import './scb-radio-button/scb-radio-group.js';
|
|
45
45
|
import './scb-search/scb-search.js';
|
|
46
|
+
import './scb-segmented-button/scb-segmented-button.js';
|
|
47
|
+
import './scb-segmented-button/scb-segmented-item.js';
|
|
46
48
|
import './scb-snackbar/scb-snackbar.js';
|
|
47
49
|
import './scb-status-pill/scb-status-pill.js';
|
|
48
50
|
import './scb-switch/scb-switch.js';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import{a as u,n,i as c,x as f,t as h}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 r=customElements.define.bind(customElements);customElements.define=function(t,e,s){try{customElements.get(t)||r(t,e,s)}catch(a){var l=String(a||"");if(l.indexOf("already been used")===-1&&l.indexOf("NotSupportedError")===-1)throw a}}}}catch{}})();var m=Object.defineProperty,b=Object.getOwnPropertyDescriptor,d=(i,r,t,e)=>{for(var s=e>1?void 0:e?b(r,t):r,l=i.length-1,a;l>=0;l--)(a=i[l])&&(s=(e?a(r,t,s):a(s))||s);return e&&s&&m(r,t,s),s};let o=class extends c{constructor(){super(...arguments),this.variant="single-select",this.value="",this.values=[],this.disabled=!1}onSlotClick(i){let r=i.target;if(!r||!r.closest)return;const t=r.closest("scb-segmented-item");if(!t||this.disabled||t.hasAttribute("disabled"))return;const e=t.getAttribute("value")||"";e&&(this.variant==="multi-select"?(this.values.indexOf(e)===-1?this.values=[...this.values,e]:this.values=this.values.filter(l=>l!==e),this.dispatchEvent(new CustomEvent("change",{detail:{values:this.values},bubbles:!0,composed:!0})),this.updateSegments()):e!==this.value&&(this.value=e,this.dispatchEvent(new CustomEvent("change",{detail:{value:e},bubbles:!0,composed:!0})),this.updateSegments()))}updateSegments(){const i=this.shadowRoot?.querySelector("slot");if(!i)return;i.assignedElements().forEach(t=>{if(t.tagName==="SCB-SEGMENTED-ITEM"){const e=t.getAttribute("value")||"";if(e){let s=!1;this.variant==="multi-select"?s=!!this.values&&this.values.includes(e):s=e===this.value,t.setAttribute("aria-pressed",s?"true":"false")}this.disabled&&t.setAttribute("disabled","true")}})}firstUpdated(){this.updateSegments();const i=this.shadowRoot?.querySelector("slot");i&&i.addEventListener("click",r=>this.onSlotClick(r))}updated(){this.updateSegments()}render(){return f`<slot></slot>`}};o.styles=u`
|
|
2
|
+
:host {
|
|
3
|
+
display: flex;
|
|
4
|
+
}
|
|
5
|
+
/* Border radius only on first and last button */
|
|
6
|
+
::slotted(scb-segmented-item:first-child .segmented-item),
|
|
7
|
+
::slotted([role="button"]:first-child .segmented-item) {
|
|
8
|
+
border-top-left-radius: var(--md-sys-shape-corner-full);
|
|
9
|
+
border-bottom-left-radius: var(--md-sys-shape-corner-full);
|
|
10
|
+
}
|
|
11
|
+
::slotted(scb-segmented-item:last-child .segmented-item),
|
|
12
|
+
::slotted([role="button"]:last-child .segmented-item) {
|
|
13
|
+
border-top-right-radius: var(--md-sys-shape-corner-full);
|
|
14
|
+
border-bottom-right-radius: var(--md-sys-shape-corner-full);
|
|
15
|
+
}
|
|
16
|
+
/* First button gets left border */
|
|
17
|
+
::slotted(scb-segmented-item:first-child .segmented-item),
|
|
18
|
+
::slotted([role="button"]:first-child .segmented-item) {
|
|
19
|
+
border-left: 1px solid var(--md-sys-color-outline);
|
|
20
|
+
}
|
|
21
|
+
`;d([n({type:String,reflect:!0})],o.prototype,"variant",2);d([n({type:String,reflect:!0})],o.prototype,"value",2);d([n({type:Array})],o.prototype,"values",2);d([n({type:Boolean,reflect:!0})],o.prototype,"disabled",2);o=d([h("scb-segmented-button")],o);
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import{a as p,n as l,i as u,x as c,t as m}from"../../vendor/vendor.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,o,t){try{customElements.get(e)||s(e,o,t)}catch(n){var a=String(n||"");if(a.indexOf("already been used")===-1&&a.indexOf("NotSupportedError")===-1)throw n}}}}catch{}})();var f=Object.defineProperty,h=Object.getOwnPropertyDescriptor,d=(i,s,e,o)=>{for(var t=o>1?void 0:o?h(s,e):s,a=i.length-1,n;a>=0;a--)(n=i[a])&&(t=(o?n(s,e,t):n(t))||t);return o&&t&&f(s,e,t),t};let r=class extends u{constructor(){super(...arguments),this.label="",this.value="",this.selected=!1,this.icon="",this.disabled=!1}render(){const s=this.parentElement?.hasAttribute?.("disabled"),e=this.disabled||s;return c`
|
|
2
|
+
<div class="segmented-item" aria-disabled="${e?"true":"false"}">
|
|
3
|
+
<md-ripple ?disabled="${e}"></md-ripple>
|
|
4
|
+
${this.icon?c`<md-icon>${this.icon}</md-icon>`:""}
|
|
5
|
+
<span>${this.label}</span>
|
|
6
|
+
<md-focus-ring inward></md-focus-ring>
|
|
7
|
+
</div>
|
|
8
|
+
`}firstUpdated(){this.setAttribute("tabindex",this.disabled?"-1":"0"),this.setAttribute("role","button")}};r.styles=p`
|
|
9
|
+
.segmented-item {
|
|
10
|
+
display: flex;
|
|
11
|
+
gap: var(--spacing-3);
|
|
12
|
+
border: 1px solid var(--md-sys-color-outline);
|
|
13
|
+
border-left: none;
|
|
14
|
+
background-color: var(--md-sys-color-surface);
|
|
15
|
+
padding: var(--spacing-3) var(--spacing-8);
|
|
16
|
+
font: inherit;
|
|
17
|
+
cursor: pointer;
|
|
18
|
+
position: relative;
|
|
19
|
+
font-size: var(--md-sys-typescale-label-medium-size);
|
|
20
|
+
line-height: var(--md-sys-typescale-label-medium-line-height);
|
|
21
|
+
font-weight: var(--md-sys-typescale-label-medium-weight);
|
|
22
|
+
letter-spacing: var(--md-sys-typescale-label-medium-tracking);
|
|
23
|
+
color: var(--md-sys-color-on-surface);
|
|
24
|
+
opacity: 1;
|
|
25
|
+
pointer-events: auto;
|
|
26
|
+
transition: opacity 0.2s;
|
|
27
|
+
|
|
28
|
+
}
|
|
29
|
+
md-icon {
|
|
30
|
+
font-size: 20px;
|
|
31
|
+
width: 18px;
|
|
32
|
+
height: 18px;
|
|
33
|
+
}
|
|
34
|
+
:host([disabled]) .segmented-item,
|
|
35
|
+
.segmented-item[aria-disabled="true"] {
|
|
36
|
+
opacity: 0.5;
|
|
37
|
+
cursor: not-allowed;
|
|
38
|
+
pointer-events: none;
|
|
39
|
+
filter: grayscale(0.5);
|
|
40
|
+
}
|
|
41
|
+
:host([aria-pressed="true"]) .segmented-item {
|
|
42
|
+
background-color: var(--md-sys-color-secondary-container);
|
|
43
|
+
color: var(--md-sys-color-primary);
|
|
44
|
+
}
|
|
45
|
+
:host(:focus){
|
|
46
|
+
outline: none;
|
|
47
|
+
}
|
|
48
|
+
md-focus-ring {
|
|
49
|
+
position: absolute;
|
|
50
|
+
inset: 0;
|
|
51
|
+
pointer-events: none;
|
|
52
|
+
display: none;
|
|
53
|
+
border-radius: inherit;
|
|
54
|
+
}
|
|
55
|
+
:host(:focus) md-focus-ring,
|
|
56
|
+
md-focus-ring[data-show="true"] {
|
|
57
|
+
display: block;
|
|
58
|
+
}
|
|
59
|
+
:host([disabled]):host(:focus) md-focus-ring,
|
|
60
|
+
:host([disabled]) md-focus-ring[data-show="true"] {
|
|
61
|
+
display: none;
|
|
62
|
+
}
|
|
63
|
+
:host(:first-child) .segmented-item{
|
|
64
|
+
border: 1px solid var(--md-sys-color-outline);
|
|
65
|
+
border-top-left-radius: var(--md-sys-shape-corner-full);
|
|
66
|
+
border-bottom-left-radius: var(--md-sys-shape-corner-full);
|
|
67
|
+
}
|
|
68
|
+
:host(:last-child) .segmented-item {
|
|
69
|
+
border-top-right-radius: var(--md-sys-shape-corner-full);
|
|
70
|
+
border-bottom-right-radius: var(--md-sys-shape-corner-full);
|
|
71
|
+
}
|
|
72
|
+
`;d([l({type:String,reflect:!0})],r.prototype,"label",2);d([l({type:String,reflect:!0})],r.prototype,"value",2);d([l({type:Boolean,reflect:!0})],r.prototype,"selected",2);d([l({type:String,reflect:!0})],r.prototype,"icon",2);d([l({type:Boolean,reflect:!0})],r.prototype,"disabled",2);r=d([m("scb-segmented-item")],r);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "scb-wc-test",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.64",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.js",
|
|
@@ -238,6 +238,14 @@
|
|
|
238
238
|
"import": "./scb-search/scb-search.js",
|
|
239
239
|
"require": "./scb-search/scb-search.js"
|
|
240
240
|
},
|
|
241
|
+
"./scb-segmented-button": {
|
|
242
|
+
"import": "./scb-segmented-button/scb-segmented-button.js",
|
|
243
|
+
"require": "./scb-segmented-button/scb-segmented-button.js"
|
|
244
|
+
},
|
|
245
|
+
"./scb-segmented-button/scb-segmented-item": {
|
|
246
|
+
"import": "./scb-segmented-button/scb-segmented-item.js",
|
|
247
|
+
"require": "./scb-segmented-button/scb-segmented-item.js"
|
|
248
|
+
},
|
|
241
249
|
"./scb-snackbar": {
|
|
242
250
|
"import": "./scb-snackbar/scb-snackbar.js",
|
|
243
251
|
"require": "./scb-snackbar/scb-snackbar.js"
|
|
@@ -280,5 +288,5 @@
|
|
|
280
288
|
},
|
|
281
289
|
"./mvc/*": "./mvc/*"
|
|
282
290
|
},
|
|
283
|
-
"buildHash": "
|
|
291
|
+
"buildHash": "196EA9D0A787C5364D547B6BC0D9A2F40B5BED4D0B8371787D7FF52C55981313"
|
|
284
292
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
/**
|
|
3
|
+
* En komponent för segmenterade knappar (segmented button).
|
|
4
|
+
*
|
|
5
|
+
* @slot - Plats för knappar eller segment.
|
|
6
|
+
* @fires change - När valt segment ändras (detail: { value })
|
|
7
|
+
*/
|
|
8
|
+
export declare class ScbSegmentedButton extends LitElement {
|
|
9
|
+
/**
|
|
10
|
+
* Variant: 'single-select' (default) eller 'multi-select'.
|
|
11
|
+
*/
|
|
12
|
+
variant: 'single-select' | 'multi-select';
|
|
13
|
+
/**
|
|
14
|
+
* Aktuellt valt värde (single) eller array av värden (multi)
|
|
15
|
+
*/
|
|
16
|
+
value: string;
|
|
17
|
+
values: string[];
|
|
18
|
+
disabled: boolean;
|
|
19
|
+
static styles: import('lit').CSSResult;
|
|
20
|
+
private onSlotClick;
|
|
21
|
+
private updateSegments;
|
|
22
|
+
firstUpdated(): void;
|
|
23
|
+
updated(): void;
|
|
24
|
+
render(): import('lit-html').TemplateResult<1>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { css as u, LitElement as c, html as m } from "lit";
|
|
2
|
+
import { property as d, customElement as h } from "lit/decorators.js";
|
|
3
|
+
import "./scb-segmented-item.js";
|
|
4
|
+
var f = Object.defineProperty, p = Object.getOwnPropertyDescriptor, a = (i, t, s, e) => {
|
|
5
|
+
for (var r = e > 1 ? void 0 : e ? p(t, s) : t, l = i.length - 1, n; l >= 0; l--)
|
|
6
|
+
(n = i[l]) && (r = (e ? n(t, s, r) : n(r)) || r);
|
|
7
|
+
return e && r && f(t, s, r), r;
|
|
8
|
+
};
|
|
9
|
+
let o = class extends c {
|
|
10
|
+
constructor() {
|
|
11
|
+
super(...arguments), this.variant = "single-select", this.value = "", this.values = [], this.disabled = !1;
|
|
12
|
+
}
|
|
13
|
+
onSlotClick(i) {
|
|
14
|
+
let t = i.target;
|
|
15
|
+
if (!t || !t.closest) return;
|
|
16
|
+
const s = t.closest("scb-segmented-item");
|
|
17
|
+
if (!s || this.disabled || s.hasAttribute("disabled")) return;
|
|
18
|
+
const e = s.getAttribute("value") || "";
|
|
19
|
+
e && (this.variant === "multi-select" ? (this.values.indexOf(e) === -1 ? this.values = [...this.values, e] : this.values = this.values.filter((l) => l !== e), this.dispatchEvent(new CustomEvent("change", { detail: { values: this.values }, bubbles: !0, composed: !0 })), this.updateSegments()) : e !== this.value && (this.value = e, this.dispatchEvent(new CustomEvent("change", { detail: { value: e }, bubbles: !0, composed: !0 })), this.updateSegments()));
|
|
20
|
+
}
|
|
21
|
+
updateSegments() {
|
|
22
|
+
var s;
|
|
23
|
+
const i = (s = this.shadowRoot) == null ? void 0 : s.querySelector("slot");
|
|
24
|
+
if (!i) return;
|
|
25
|
+
i.assignedElements().forEach((e) => {
|
|
26
|
+
if (e.tagName === "SCB-SEGMENTED-ITEM") {
|
|
27
|
+
const r = e.getAttribute("value") || "";
|
|
28
|
+
if (r) {
|
|
29
|
+
let l = !1;
|
|
30
|
+
this.variant === "multi-select" ? l = !!this.values && this.values.includes(r) : l = r === this.value, e.setAttribute("aria-pressed", l ? "true" : "false");
|
|
31
|
+
}
|
|
32
|
+
this.disabled && e.setAttribute("disabled", "true");
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
firstUpdated() {
|
|
37
|
+
var t;
|
|
38
|
+
this.updateSegments();
|
|
39
|
+
const i = (t = this.shadowRoot) == null ? void 0 : t.querySelector("slot");
|
|
40
|
+
i && i.addEventListener("click", (s) => this.onSlotClick(s));
|
|
41
|
+
}
|
|
42
|
+
updated() {
|
|
43
|
+
this.updateSegments();
|
|
44
|
+
}
|
|
45
|
+
render() {
|
|
46
|
+
return m`<slot></slot>`;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
o.styles = u`
|
|
50
|
+
:host {
|
|
51
|
+
display: flex;
|
|
52
|
+
}
|
|
53
|
+
/* Border radius only on first and last button */
|
|
54
|
+
::slotted(scb-segmented-item:first-child .segmented-item),
|
|
55
|
+
::slotted([role="button"]:first-child .segmented-item) {
|
|
56
|
+
border-top-left-radius: var(--md-sys-shape-corner-full);
|
|
57
|
+
border-bottom-left-radius: var(--md-sys-shape-corner-full);
|
|
58
|
+
}
|
|
59
|
+
::slotted(scb-segmented-item:last-child .segmented-item),
|
|
60
|
+
::slotted([role="button"]:last-child .segmented-item) {
|
|
61
|
+
border-top-right-radius: var(--md-sys-shape-corner-full);
|
|
62
|
+
border-bottom-right-radius: var(--md-sys-shape-corner-full);
|
|
63
|
+
}
|
|
64
|
+
/* First button gets left border */
|
|
65
|
+
::slotted(scb-segmented-item:first-child .segmented-item),
|
|
66
|
+
::slotted([role="button"]:first-child .segmented-item) {
|
|
67
|
+
border-left: 1px solid var(--md-sys-color-outline);
|
|
68
|
+
}
|
|
69
|
+
`;
|
|
70
|
+
a([
|
|
71
|
+
d({ type: String, reflect: !0 })
|
|
72
|
+
], o.prototype, "variant", 2);
|
|
73
|
+
a([
|
|
74
|
+
d({ type: String, reflect: !0 })
|
|
75
|
+
], o.prototype, "value", 2);
|
|
76
|
+
a([
|
|
77
|
+
d({ type: Array })
|
|
78
|
+
], o.prototype, "values", 2);
|
|
79
|
+
a([
|
|
80
|
+
d({ type: Boolean, reflect: !0 })
|
|
81
|
+
], o.prototype, "disabled", 2);
|
|
82
|
+
o = a([
|
|
83
|
+
h("scb-segmented-button")
|
|
84
|
+
], o);
|
|
85
|
+
export {
|
|
86
|
+
o as ScbSegmentedButton
|
|
87
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
/**
|
|
3
|
+
* Ett segment (option) i en segmented button.
|
|
4
|
+
* @slot - Label och ev. ikon
|
|
5
|
+
*/
|
|
6
|
+
export declare class ScbSegmentedItem extends LitElement {
|
|
7
|
+
label: string;
|
|
8
|
+
value: string;
|
|
9
|
+
selected: boolean;
|
|
10
|
+
icon: string;
|
|
11
|
+
disabled: boolean;
|
|
12
|
+
static styles: import('lit').CSSResult;
|
|
13
|
+
render(): import('lit-html').TemplateResult<1>;
|
|
14
|
+
firstUpdated(): void;
|
|
15
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { css as p, LitElement as m, html as c } from "lit";
|
|
2
|
+
import { property as l, customElement as u } from "lit/decorators.js";
|
|
3
|
+
import "@material/web/icon/icon.js";
|
|
4
|
+
import "@material/web/focus/md-focus-ring.js";
|
|
5
|
+
import "@material/web/ripple/ripple.js";
|
|
6
|
+
var h = Object.defineProperty, b = Object.getOwnPropertyDescriptor, a = (e, o, i, s) => {
|
|
7
|
+
for (var r = s > 1 ? void 0 : s ? b(o, i) : o, d = e.length - 1, n; d >= 0; d--)
|
|
8
|
+
(n = e[d]) && (r = (s ? n(o, i, r) : n(r)) || r);
|
|
9
|
+
return s && r && h(o, i, r), r;
|
|
10
|
+
};
|
|
11
|
+
let t = class extends m {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments), this.label = "", this.value = "", this.selected = !1, this.icon = "", this.disabled = !1;
|
|
14
|
+
}
|
|
15
|
+
render() {
|
|
16
|
+
var s;
|
|
17
|
+
const e = this.parentElement, o = (s = e == null ? void 0 : e.hasAttribute) == null ? void 0 : s.call(e, "disabled"), i = this.disabled || o;
|
|
18
|
+
return c`
|
|
19
|
+
<div class="segmented-item" aria-disabled="${i ? "true" : "false"}">
|
|
20
|
+
<md-ripple ?disabled="${i}"></md-ripple>
|
|
21
|
+
${this.icon ? c`<md-icon>${this.icon}</md-icon>` : ""}
|
|
22
|
+
<span>${this.label}</span>
|
|
23
|
+
<md-focus-ring inward></md-focus-ring>
|
|
24
|
+
</div>
|
|
25
|
+
`;
|
|
26
|
+
}
|
|
27
|
+
firstUpdated() {
|
|
28
|
+
this.setAttribute("tabindex", this.disabled ? "-1" : "0"), this.setAttribute("role", "button");
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
t.styles = p`
|
|
32
|
+
.segmented-item {
|
|
33
|
+
display: flex;
|
|
34
|
+
gap: var(--spacing-3);
|
|
35
|
+
border: 1px solid var(--md-sys-color-outline);
|
|
36
|
+
border-left: none;
|
|
37
|
+
background-color: var(--md-sys-color-surface);
|
|
38
|
+
padding: var(--spacing-3) var(--spacing-8);
|
|
39
|
+
font: inherit;
|
|
40
|
+
cursor: pointer;
|
|
41
|
+
position: relative;
|
|
42
|
+
font-size: var(--md-sys-typescale-label-medium-size);
|
|
43
|
+
line-height: var(--md-sys-typescale-label-medium-line-height);
|
|
44
|
+
font-weight: var(--md-sys-typescale-label-medium-weight);
|
|
45
|
+
letter-spacing: var(--md-sys-typescale-label-medium-tracking);
|
|
46
|
+
color: var(--md-sys-color-on-surface);
|
|
47
|
+
opacity: 1;
|
|
48
|
+
pointer-events: auto;
|
|
49
|
+
transition: opacity 0.2s;
|
|
50
|
+
|
|
51
|
+
}
|
|
52
|
+
md-icon {
|
|
53
|
+
font-size: 20px;
|
|
54
|
+
width: 18px;
|
|
55
|
+
height: 18px;
|
|
56
|
+
}
|
|
57
|
+
:host([disabled]) .segmented-item,
|
|
58
|
+
.segmented-item[aria-disabled="true"] {
|
|
59
|
+
opacity: 0.5;
|
|
60
|
+
cursor: not-allowed;
|
|
61
|
+
pointer-events: none;
|
|
62
|
+
filter: grayscale(0.5);
|
|
63
|
+
}
|
|
64
|
+
:host([aria-pressed="true"]) .segmented-item {
|
|
65
|
+
background-color: var(--md-sys-color-secondary-container);
|
|
66
|
+
color: var(--md-sys-color-primary);
|
|
67
|
+
}
|
|
68
|
+
:host(:focus){
|
|
69
|
+
outline: none;
|
|
70
|
+
}
|
|
71
|
+
md-focus-ring {
|
|
72
|
+
position: absolute;
|
|
73
|
+
inset: 0;
|
|
74
|
+
pointer-events: none;
|
|
75
|
+
display: none;
|
|
76
|
+
border-radius: inherit;
|
|
77
|
+
}
|
|
78
|
+
:host(:focus) md-focus-ring,
|
|
79
|
+
md-focus-ring[data-show="true"] {
|
|
80
|
+
display: block;
|
|
81
|
+
}
|
|
82
|
+
:host([disabled]):host(:focus) md-focus-ring,
|
|
83
|
+
:host([disabled]) md-focus-ring[data-show="true"] {
|
|
84
|
+
display: none;
|
|
85
|
+
}
|
|
86
|
+
:host(:first-child) .segmented-item{
|
|
87
|
+
border: 1px solid var(--md-sys-color-outline);
|
|
88
|
+
border-top-left-radius: var(--md-sys-shape-corner-full);
|
|
89
|
+
border-bottom-left-radius: var(--md-sys-shape-corner-full);
|
|
90
|
+
}
|
|
91
|
+
:host(:last-child) .segmented-item {
|
|
92
|
+
border-top-right-radius: var(--md-sys-shape-corner-full);
|
|
93
|
+
border-bottom-right-radius: var(--md-sys-shape-corner-full);
|
|
94
|
+
}
|
|
95
|
+
`;
|
|
96
|
+
a([
|
|
97
|
+
l({ type: String, reflect: !0 })
|
|
98
|
+
], t.prototype, "label", 2);
|
|
99
|
+
a([
|
|
100
|
+
l({ type: String, reflect: !0 })
|
|
101
|
+
], t.prototype, "value", 2);
|
|
102
|
+
a([
|
|
103
|
+
l({ type: Boolean, reflect: !0 })
|
|
104
|
+
], t.prototype, "selected", 2);
|
|
105
|
+
a([
|
|
106
|
+
l({ type: String, reflect: !0 })
|
|
107
|
+
], t.prototype, "icon", 2);
|
|
108
|
+
a([
|
|
109
|
+
l({ type: Boolean, reflect: !0 })
|
|
110
|
+
], t.prototype, "disabled", 2);
|
|
111
|
+
t = a([
|
|
112
|
+
u("scb-segmented-item")
|
|
113
|
+
], t);
|
|
114
|
+
export {
|
|
115
|
+
t as ScbSegmentedItem
|
|
116
|
+
};
|