scb-wc-test 0.1.99 → 0.1.101
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 +76 -0
- package/index.d.ts +2 -0
- package/index.js +52 -48
- package/mvc/components/all.js +2 -0
- package/mvc/components/scb-app-bar/scb-app-bar.js +1 -1
- package/mvc/components/scb-calendar-card/scb-calendar-card.js +1 -1
- package/mvc/components/scb-dialog/scb-dialog.js +1 -1
- package/mvc/components/scb-drawer/scb-drawer-item.js +2 -2
- package/mvc/components/scb-fact-card/scb-fact-card.js +1 -1
- package/mvc/components/scb-header/scb-header.js +1 -1
- package/mvc/components/scb-horizontal-scroller/scb-horizontal-scroller.js +1 -1
- package/mvc/components/scb-icon-button/scb-icon-button.js +30 -41
- package/mvc/components/scb-notification-card/scb-notification-card.js +1 -1
- package/mvc/components/scb-pagination/scb-pagination.js +1 -1
- package/mvc/components/scb-select/scb-select-option.js +33 -0
- package/mvc/components/scb-select/scb-select.js +144 -0
- package/mvc/components/scb-snackbar/scb-snackbar.js +2 -2
- package/mvc/components/scb-toc/scb-toc-item.js +1 -1
- package/mvc/components/scb-toc/scb-toc.js +1 -1
- package/mvc/components/scb-viz/scb-viz.js +1 -1
- package/mvc/scb-wc-test.css +1 -1
- package/package.json +340 -307
- package/scb-calendar-card/scb-calendar-card.js +1 -1
- package/scb-icon-button/scb-icon-button.d.ts +23 -8
- package/scb-icon-button/scb-icon-button.js +106 -133
- package/scb-select/scb-select-option.d.ts +14 -0
- package/scb-select/scb-select-option.js +72 -0
- package/scb-select/scb-select.d.ts +32 -0
- package/scb-select/scb-select.js +258 -0
- package/scb-wc-test.bundle.js +837 -673
- package/scb-wc-test.css +1 -1
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import { css as p, LitElement as h, html as d } from "lit";
|
|
2
|
+
import { property as r, customElement as u } from "lit/decorators.js";
|
|
3
|
+
import "./scb-select-option.js";
|
|
4
|
+
import "@material/web/focus/md-focus-ring.js";
|
|
5
|
+
var v = Object.defineProperty, b = Object.getOwnPropertyDescriptor, n = (e, i, o, t) => {
|
|
6
|
+
for (var s = t > 1 ? void 0 : t ? b(i, o) : i, c = e.length - 1, l; c >= 0; c--)
|
|
7
|
+
(l = e[c]) && (s = (t ? l(i, o, s) : l(s)) || s);
|
|
8
|
+
return t && s && v(i, o, s), s;
|
|
9
|
+
};
|
|
10
|
+
let a = class extends h {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(...arguments), this.focusedIndex = -1, this.variant = "single-select", this.value = "", this.values = [], this.disabled = !1, this.open = !1, this.label = "", this.name = "", this.placeholder = "", this.supportingText = "", this.withRadiobuttons = !1, this._onDocumentClick = (e) => {
|
|
13
|
+
if (!this.open) return;
|
|
14
|
+
e.composedPath().includes(this) || (this.open = !1, this.removeAttribute("open"));
|
|
15
|
+
}, this._onSlotClick = (e) => {
|
|
16
|
+
var c;
|
|
17
|
+
const i = (c = this.shadowRoot) == null ? void 0 : c.querySelector("slot");
|
|
18
|
+
if (!i) return;
|
|
19
|
+
const o = i.assignedElements({ flatten: !0 }).filter((l) => l.tagName.toLowerCase() === "scb-select-option"), t = e.composedPath(), s = o.find((l) => t.includes(l));
|
|
20
|
+
s && (this._selectOption(s), e.stopPropagation());
|
|
21
|
+
}, this._onKeyDown = (e) => {
|
|
22
|
+
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), this._toggleOpen());
|
|
23
|
+
}, this._onOptionKeyDown = (e) => {
|
|
24
|
+
var i;
|
|
25
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
26
|
+
e.preventDefault();
|
|
27
|
+
const o = (i = this.shadowRoot) == null ? void 0 : i.querySelector("slot");
|
|
28
|
+
if (!o) return;
|
|
29
|
+
const t = o.assignedElements({ flatten: !0 }).filter((l) => l.tagName.toLowerCase() === "scb-select-option"), s = e.composedPath(), c = t.find((l) => s.includes(l));
|
|
30
|
+
c && this._selectOption(c);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
connectedCallback() {
|
|
35
|
+
super.connectedCallback(), document.addEventListener("mousedown", this._onDocumentClick);
|
|
36
|
+
}
|
|
37
|
+
disconnectedCallback() {
|
|
38
|
+
document.removeEventListener("mousedown", this._onDocumentClick), super.disconnectedCallback();
|
|
39
|
+
}
|
|
40
|
+
_toggleOpen() {
|
|
41
|
+
this.disabled || (this.open = !this.open, this.open ? (this.focusedIndex = 0, this.requestUpdate()) : this.focusedIndex = -1);
|
|
42
|
+
}
|
|
43
|
+
_selectOption(e) {
|
|
44
|
+
e.disabled || (this.variant === "multi-select" ? (this.values.indexOf(e.value) > -1 ? this.values = this.values.filter((o) => o !== e.value) : this.values = [...this.values, e.value], this.dispatchEvent(new CustomEvent("change", { detail: { values: this.values } }))) : this.variant === "single-select" && this.withRadiobuttons ? (this.value = e.value, this.dispatchEvent(new CustomEvent("change", { detail: { value: this.value } }))) : (this.value = e.value, this.open = !1, this.removeAttribute("open"), this.dispatchEvent(new CustomEvent("change", { detail: { value: this.value } }))), this._updateOptionsChecked(), this.requestUpdate());
|
|
45
|
+
}
|
|
46
|
+
_getSelectedLabel() {
|
|
47
|
+
var o;
|
|
48
|
+
const e = (o = this.shadowRoot) == null ? void 0 : o.querySelector("slot");
|
|
49
|
+
if (!e) return "";
|
|
50
|
+
const i = e.assignedElements({ flatten: !0 }).filter((t) => t.tagName.toLowerCase() === "scb-select-option");
|
|
51
|
+
if (this.variant === "multi-select") {
|
|
52
|
+
const t = i.filter((s) => this.values.includes(s.value));
|
|
53
|
+
return t && t.length > 0 ? t.map((s) => s.textContent).join(", ") : "";
|
|
54
|
+
} else {
|
|
55
|
+
const t = i.find((s) => s.value === this.value);
|
|
56
|
+
return t ? t.textContent : "";
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
firstUpdated() {
|
|
60
|
+
this._updateOptionsChecked();
|
|
61
|
+
}
|
|
62
|
+
updated() {
|
|
63
|
+
this._updateOptionsChecked();
|
|
64
|
+
}
|
|
65
|
+
_updateOptionsChecked() {
|
|
66
|
+
var o;
|
|
67
|
+
const e = (o = this.shadowRoot) == null ? void 0 : o.querySelector("slot");
|
|
68
|
+
if (!e) return;
|
|
69
|
+
e.assignedElements({ flatten: !0 }).filter((t) => t.tagName.toLowerCase() === "scb-select-option").forEach((t) => {
|
|
70
|
+
this.variant === "multi-select" ? (t.showCheckbox = !0, t.checked = this.values.includes(t.value), t.showRadio = !1) : (t.showCheckbox = !1, t.checked = this.value === t.value, this.withRadiobuttons && (t.showRadio = !0));
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
render() {
|
|
74
|
+
return d`
|
|
75
|
+
${this.label ? d`
|
|
76
|
+
<label class="select-label">${this.label}</label>
|
|
77
|
+
` : ""}
|
|
78
|
+
${this.supportingText ? d`
|
|
79
|
+
<div class="select-sub-label">${this.supportingText}</div>
|
|
80
|
+
` : ""}
|
|
81
|
+
<div class="select">
|
|
82
|
+
<div class="selected-value-container" tabindex="0" @click="${this._toggleOpen}" @keydown="${this._onKeyDown}">
|
|
83
|
+
<md-focus-ring inward></md-focus-ring>
|
|
84
|
+
<md-ripple></md-ripple>
|
|
85
|
+
<input tabindex="-1" class="selected-value" type="text" readonly .value="${this._getSelectedLabel() || this.placeholder}" name="${this.name}" />
|
|
86
|
+
<span class="arrow">
|
|
87
|
+
<md-icon>${this.open ? "expand_less" : "expand_more"}</md-icon>
|
|
88
|
+
</span>
|
|
89
|
+
</div>
|
|
90
|
+
<div class="options" @click=${this._onSlotClick} @keydown=${this._onOptionKeyDown}>
|
|
91
|
+
<slot @slotchange="${() => {
|
|
92
|
+
this.requestUpdate();
|
|
93
|
+
}}"></slot>
|
|
94
|
+
</div>
|
|
95
|
+
</div>
|
|
96
|
+
`;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
a.styles = p`
|
|
100
|
+
:host {
|
|
101
|
+
display: block;
|
|
102
|
+
color: var(--md-sys-color-on-surface-variant);
|
|
103
|
+
font-family: var(--brand-font);
|
|
104
|
+
--scb-select-max-width: 400px;
|
|
105
|
+
max-width: var(--scb-select-max-width);
|
|
106
|
+
width: 100%;
|
|
107
|
+
}
|
|
108
|
+
:host([disabled]) {
|
|
109
|
+
pointer-events: none;
|
|
110
|
+
opacity: 0.38;
|
|
111
|
+
}
|
|
112
|
+
.select {
|
|
113
|
+
position: relative;
|
|
114
|
+
|
|
115
|
+
background: var(--md-sys-color-surface);
|
|
116
|
+
cursor: pointer;
|
|
117
|
+
border-radius: var(--md-sys-shape-corner-small);
|
|
118
|
+
border: 1px solid var(--md-sys-color-outline);
|
|
119
|
+
outline: 1px solid transparent;
|
|
120
|
+
transition: border 0.2s;
|
|
121
|
+
|
|
122
|
+
}
|
|
123
|
+
:host .select:hover, :host([open]) .select {
|
|
124
|
+
outline: 1px solid var(--md-sys-color-outline);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.selected-value {
|
|
128
|
+
flex: 1 1 auto;
|
|
129
|
+
min-width: 0;
|
|
130
|
+
overflow: hidden;
|
|
131
|
+
text-overflow: ellipsis;
|
|
132
|
+
white-space: nowrap;
|
|
133
|
+
display: block;
|
|
134
|
+
border: none;
|
|
135
|
+
background: transparent;
|
|
136
|
+
font: inherit;
|
|
137
|
+
color: inherit;
|
|
138
|
+
padding: 0;
|
|
139
|
+
outline: none;
|
|
140
|
+
cursor: pointer;
|
|
141
|
+
font-size: var(--md-sys-typescale-body-large-size);
|
|
142
|
+
line-height: var(--md-sys-typescale-body-large-line-height);
|
|
143
|
+
letter-spacing: var(--md-sys-typescale-body-large-tracking);
|
|
144
|
+
}
|
|
145
|
+
.selected-value-container:focus-within {
|
|
146
|
+
outline: none;
|
|
147
|
+
}
|
|
148
|
+
.select-label{
|
|
149
|
+
font-size: var(--md-sys-typescale-label-large-size);
|
|
150
|
+
font-weight: var(--weight-semibold);
|
|
151
|
+
line-height: var(--md-sys-typescale-label-large-line-height);
|
|
152
|
+
letter-spacing: var(--md-sys-typescale-label-large-tracking);
|
|
153
|
+
}
|
|
154
|
+
.select-sub-label{
|
|
155
|
+
font-size: var(--md-sys-typescale-body-large-size);
|
|
156
|
+
line-height: var(--md-sys-typescale-body-large-line-height);
|
|
157
|
+
letter-spacing: var(--md-sys-typescale-body-large-tracking);
|
|
158
|
+
}
|
|
159
|
+
md-focus-ring {
|
|
160
|
+
position:absolute;
|
|
161
|
+
border-radius: 8px;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.arrow {
|
|
165
|
+
position: absolute;
|
|
166
|
+
right: 8px;
|
|
167
|
+
pointer-events: none;
|
|
168
|
+
}
|
|
169
|
+
.options {
|
|
170
|
+
position: absolute;
|
|
171
|
+
left: 0;
|
|
172
|
+
right: 0;
|
|
173
|
+
top: calc(100% + 3px);
|
|
174
|
+
z-index: 10;
|
|
175
|
+
max-height: 0;
|
|
176
|
+
overflow-y: hidden;
|
|
177
|
+
transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
178
|
+
visibility: hidden;
|
|
179
|
+
opacity: 0;
|
|
180
|
+
border-radius: var(--md-sys-shape-corner-small);
|
|
181
|
+
background: var(--md-sys-color-surface);
|
|
182
|
+
padding: 8px 0;
|
|
183
|
+
/* Drop Shadow/2 */
|
|
184
|
+
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.30), 0 2px 6px 2px rgba(0, 0, 0, 0.15);
|
|
185
|
+
}
|
|
186
|
+
.options::-webkit-scrollbar {
|
|
187
|
+
width: 12px;
|
|
188
|
+
background: var(--md-sys-color-surface);
|
|
189
|
+
border-radius: 8px;
|
|
190
|
+
}
|
|
191
|
+
.options::-webkit-scrollbar-thumb {
|
|
192
|
+
background: var(--md-sys-color-outline);
|
|
193
|
+
border-radius: 8px;
|
|
194
|
+
border: 4px solid var(--md-sys-color-surface);
|
|
195
|
+
|
|
196
|
+
}
|
|
197
|
+
.options::-webkit-scrollbar-track {
|
|
198
|
+
background: var(--md-sys-color-surface);
|
|
199
|
+
border-radius: 8px;
|
|
200
|
+
}
|
|
201
|
+
:host([open]) .options {
|
|
202
|
+
max-height: 240px;
|
|
203
|
+
overflow-y: auto;
|
|
204
|
+
visibility: visible;
|
|
205
|
+
opacity: 1;
|
|
206
|
+
}
|
|
207
|
+
.option[aria-selected="true"] {
|
|
208
|
+
background: #e6f0fa;
|
|
209
|
+
}
|
|
210
|
+
.option[aria-disabled="true"] {
|
|
211
|
+
color: #aaa;
|
|
212
|
+
pointer-events: none;
|
|
213
|
+
}
|
|
214
|
+
.selected-value-container {
|
|
215
|
+
height: 100%;
|
|
216
|
+
position: relative;
|
|
217
|
+
display: flex;
|
|
218
|
+
align-items: center;
|
|
219
|
+
padding: var(--spacing-6) 52px var(--spacing-6) var(--spacing-5);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
`;
|
|
223
|
+
n([
|
|
224
|
+
r({ type: String })
|
|
225
|
+
], a.prototype, "variant", 2);
|
|
226
|
+
n([
|
|
227
|
+
r({ type: String })
|
|
228
|
+
], a.prototype, "value", 2);
|
|
229
|
+
n([
|
|
230
|
+
r({ type: Array })
|
|
231
|
+
], a.prototype, "values", 2);
|
|
232
|
+
n([
|
|
233
|
+
r({ type: Boolean })
|
|
234
|
+
], a.prototype, "disabled", 2);
|
|
235
|
+
n([
|
|
236
|
+
r({ type: Boolean, reflect: !0 })
|
|
237
|
+
], a.prototype, "open", 2);
|
|
238
|
+
n([
|
|
239
|
+
r({ type: String })
|
|
240
|
+
], a.prototype, "label", 2);
|
|
241
|
+
n([
|
|
242
|
+
r({ type: String })
|
|
243
|
+
], a.prototype, "name", 2);
|
|
244
|
+
n([
|
|
245
|
+
r({ type: String })
|
|
246
|
+
], a.prototype, "placeholder", 2);
|
|
247
|
+
n([
|
|
248
|
+
r({ type: String, attribute: "supporting-text" })
|
|
249
|
+
], a.prototype, "supportingText", 2);
|
|
250
|
+
n([
|
|
251
|
+
r({ type: Boolean, attribute: "with-radiobuttons" })
|
|
252
|
+
], a.prototype, "withRadiobuttons", 2);
|
|
253
|
+
a = n([
|
|
254
|
+
u("scb-select")
|
|
255
|
+
], a);
|
|
256
|
+
export {
|
|
257
|
+
a as ScbSelect
|
|
258
|
+
};
|