@statistikzh/leu 0.0.2 → 0.2.0
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/.github/workflows/release-please.yml +20 -1
- package/CHANGELOG.md +30 -0
- package/README.md +27 -2
- package/babel.config.json +3 -0
- package/dist/{Button-83c6df93.js → Button.js} +58 -50
- package/dist/ButtonGroup.js +75 -0
- package/dist/Checkbox.js +60 -57
- package/dist/CheckboxGroup.js +35 -41
- package/dist/{Chip-60af1402.js → Chip-389013ff.js} +12 -13
- package/dist/ChipGroup.js +27 -34
- package/dist/ChipLink.js +18 -19
- package/dist/ChipRemovable.js +9 -13
- package/dist/ChipSelectable.js +42 -44
- package/dist/Dropdown.js +75 -0
- package/dist/Input.js +120 -122
- package/dist/Menu.js +40 -0
- package/dist/MenuItem.js +171 -0
- package/dist/Pagination.js +193 -0
- package/dist/Radio.js +26 -22
- package/dist/RadioGroup.js +75 -105
- package/dist/Select.js +125 -343
- package/dist/Table.js +294 -8
- package/dist/defineElement-ba770aed.js +44 -0
- package/dist/icon-03e86700.js +136 -0
- package/dist/index.js +14 -9
- package/dist/leu-button-group.js +8 -0
- package/dist/leu-button.js +7 -0
- package/dist/leu-checkbox-group.js +1 -1
- package/dist/leu-checkbox.js +2 -2
- package/dist/leu-chip-group.js +1 -1
- package/dist/leu-chip-link.js +2 -2
- package/dist/leu-chip-removable.js +3 -3
- package/dist/leu-chip-selectable.js +2 -2
- package/dist/leu-dropdown.js +10 -0
- package/dist/leu-input.js +2 -2
- package/dist/leu-menu-item.js +6 -0
- package/dist/leu-menu.js +5 -0
- package/dist/leu-pagination.js +8 -0
- package/dist/leu-radio-group.js +1 -1
- package/dist/leu-radio.js +1 -1
- package/dist/leu-select.js +5 -3
- package/dist/leu-table.js +5 -4
- package/dist/theme.css +7 -7
- package/index.js +7 -3
- package/package.json +3 -1
- package/rollup.config.js +26 -9
- package/src/components/accordion/Accordion.js +102 -0
- package/src/components/accordion/accordion.css +160 -0
- package/src/components/accordion/leu-accordion.js +3 -0
- package/src/components/accordion/stories/accordion.stories.js +55 -0
- package/src/components/accordion/test/accordion.test.js +22 -0
- package/src/components/input/Input.js +10 -0
- package/src/components/menu/menu.css +9 -3
- package/src/components/select/Select.js +28 -8
- package/src/styles/custom-properties.css +7 -7
- package/.github/workflows/publish.yml +0 -19
- package/dist/Table-72d305d7.js +0 -506
- package/dist/defineElement-47d4f665.js +0 -15
- package/dist/icon-b68c7e1e.js +0 -202
package/dist/Select.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
import { _ as _defineProperty, d as defineElement } from './defineElement-ba770aed.js';
|
|
1
2
|
import { css, LitElement, html, nothing } from 'lit';
|
|
2
3
|
import { classMap } from 'lit/directives/class-map.js';
|
|
3
4
|
import { map } from 'lit/directives/map.js';
|
|
4
5
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
5
6
|
import { createRef, ref } from 'lit/directives/ref.js';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { I as Icon } from './icon-03e86700.js';
|
|
8
|
+
import { defineButtonElements } from './Button.js';
|
|
9
|
+
import { defineMenuElements } from './Menu.js';
|
|
10
|
+
import { defineMenuItemElements } from './MenuItem.js';
|
|
9
11
|
import { defineInputElements } from './Input.js';
|
|
10
12
|
|
|
11
13
|
/**
|
|
@@ -19,9 +21,18 @@ import { defineInputElements } from './Input.js';
|
|
|
19
21
|
*/
|
|
20
22
|
class HasSlotController {
|
|
21
23
|
constructor(host, slotNames) {
|
|
24
|
+
/**
|
|
25
|
+
* @private
|
|
26
|
+
* @param {Event} event
|
|
27
|
+
*/
|
|
28
|
+
_defineProperty(this, "handleSlotChange", event => {
|
|
29
|
+
const slot = event.target;
|
|
30
|
+
if (this.slotNames.includes("[default]") && !slot.name || slot.name && this.slotNames.includes(slot.name)) {
|
|
31
|
+
this.host.requestUpdate();
|
|
32
|
+
}
|
|
33
|
+
});
|
|
22
34
|
this.host = host;
|
|
23
35
|
host.addController(this);
|
|
24
|
-
|
|
25
36
|
this.slotNames = slotNames;
|
|
26
37
|
}
|
|
27
38
|
|
|
@@ -30,22 +41,20 @@ class HasSlotController {
|
|
|
30
41
|
* @returns {Boolean}
|
|
31
42
|
*/
|
|
32
43
|
hasDefaultSlot() {
|
|
33
|
-
return [...this.host.childNodes].some(
|
|
44
|
+
return [...this.host.childNodes].some(node => {
|
|
34
45
|
if (node.nodeType === node.TEXT_NODE && node.textContent.trim() !== "") {
|
|
35
|
-
return true
|
|
46
|
+
return true;
|
|
36
47
|
}
|
|
37
|
-
|
|
38
48
|
if (node.nodeType === node.ELEMENT_NODE) {
|
|
39
49
|
const el = node;
|
|
40
50
|
|
|
41
51
|
// If it doesn't have a slot attribute, it's part of the default slot
|
|
42
52
|
if (!el.hasAttribute("slot")) {
|
|
43
|
-
return true
|
|
53
|
+
return true;
|
|
44
54
|
}
|
|
45
55
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
})
|
|
56
|
+
return false;
|
|
57
|
+
});
|
|
49
58
|
}
|
|
50
59
|
|
|
51
60
|
/**
|
|
@@ -54,7 +63,7 @@ class HasSlotController {
|
|
|
54
63
|
* @returns {Boolean}
|
|
55
64
|
*/
|
|
56
65
|
hasNamedSlot(name) {
|
|
57
|
-
return this.host.querySelector(`:scope > [slot="${name}"]`) !== null
|
|
66
|
+
return this.host.querySelector(`:scope > [slot="${name}"]`) !== null;
|
|
58
67
|
}
|
|
59
68
|
|
|
60
69
|
/**
|
|
@@ -62,235 +71,16 @@ class HasSlotController {
|
|
|
62
71
|
* @returns {Boolean}
|
|
63
72
|
*/
|
|
64
73
|
test(slotName) {
|
|
65
|
-
return slotName === "[default]"
|
|
66
|
-
? this.hasDefaultSlot()
|
|
67
|
-
: this.hasNamedSlot(slotName)
|
|
74
|
+
return slotName === "[default]" ? this.hasDefaultSlot() : this.hasNamedSlot(slotName);
|
|
68
75
|
}
|
|
69
|
-
|
|
70
76
|
hostConnected() {
|
|
71
77
|
this.host.shadowRoot.addEventListener("slotchange", this.handleSlotChange);
|
|
72
78
|
}
|
|
73
|
-
|
|
74
79
|
hostDisconnected() {
|
|
75
|
-
this.host.shadowRoot.removeEventListener(
|
|
76
|
-
"slotchange",
|
|
77
|
-
this.handleSlotChange
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* @private
|
|
83
|
-
* @param {Event} event
|
|
84
|
-
*/
|
|
85
|
-
handleSlotChange = (event) => {
|
|
86
|
-
const slot = event.target;
|
|
87
|
-
|
|
88
|
-
if (
|
|
89
|
-
(this.slotNames.includes("[default]") && !slot.name) ||
|
|
90
|
-
(slot.name && this.slotNames.includes(slot.name))
|
|
91
|
-
) {
|
|
92
|
-
this.host.requestUpdate();
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
var css_248z$2 = css`:host,
|
|
98
|
-
:host * {
|
|
99
|
-
box-sizing: border-box;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
:host {
|
|
103
|
-
--menu-divider-color: var(--leu-color-black-transp-20);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
:host ::slotted(hr) {
|
|
107
|
-
border: 0;
|
|
108
|
-
border-top: 1px solid var(--menu-divider-color);
|
|
109
|
-
margin: 0.5rem 0;
|
|
110
|
-
}
|
|
111
|
-
`;
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* @tagname leu-menu
|
|
115
|
-
*/
|
|
116
|
-
class LeuMenu extends LitElement {
|
|
117
|
-
static styles = css_248z$2
|
|
118
|
-
|
|
119
|
-
render() {
|
|
120
|
-
return html`<slot></slot>`
|
|
80
|
+
this.host.shadowRoot.removeEventListener("slotchange", this.handleSlotChange);
|
|
121
81
|
}
|
|
122
82
|
}
|
|
123
83
|
|
|
124
|
-
function defineMenuElements() {
|
|
125
|
-
defineElement("menu", LeuMenu);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
var css_248z$1 = css`:host,
|
|
129
|
-
:host * {
|
|
130
|
-
box-sizing: border-box;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
:host {
|
|
134
|
-
--background: var(--leu-color-black-0);
|
|
135
|
-
--background-hover: var(--leu-color-black-10);
|
|
136
|
-
--background-active: var(--leu-color-func-cyan);
|
|
137
|
-
--background-disabled: var(--leu-color-black-0);
|
|
138
|
-
--color: var(--leu-color-black-transp-60);
|
|
139
|
-
--font-regular: var(--leu-font-regular);
|
|
140
|
-
--font-black: var(--leu-font-black);
|
|
141
|
-
|
|
142
|
-
font-family: var(--chip-font-regular);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
.button {
|
|
146
|
-
-webkit-appearance: none;
|
|
147
|
-
-moz-appearance: none;
|
|
148
|
-
appearance: none;
|
|
149
|
-
border: none;
|
|
150
|
-
cursor: pointer;
|
|
151
|
-
|
|
152
|
-
display: flex;
|
|
153
|
-
align-items: center;
|
|
154
|
-
gap: 0.5rem;
|
|
155
|
-
width: 100%;
|
|
156
|
-
|
|
157
|
-
padding: 0.75rem;
|
|
158
|
-
|
|
159
|
-
font-size: 1rem;
|
|
160
|
-
line-height: 1.5;
|
|
161
|
-
text-align: left;
|
|
162
|
-
|
|
163
|
-
background: var(--background);
|
|
164
|
-
color: var(--color);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
.button:focus-visible {
|
|
168
|
-
outline: 2px solid var(--leu-color-func-cyan);
|
|
169
|
-
outline-offset: 2px;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
.button:hover,
|
|
173
|
-
:host([highlighted]) .button {
|
|
174
|
-
--background: var(--background-hover);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
:host([active]) .button {
|
|
178
|
-
--background: var(--background-active);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
:host([disabled]) .button {
|
|
182
|
-
--background: var(--background-disabled);
|
|
183
|
-
cursor: default;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
.before svg, .after svg {
|
|
187
|
-
display: block;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
.label {
|
|
191
|
-
flex: 1;
|
|
192
|
-
overflow: hidden;
|
|
193
|
-
text-overflow: ellipsis;
|
|
194
|
-
white-space: nowrap;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
.icon-placeholder {
|
|
198
|
-
display: block;
|
|
199
|
-
width: 1.5rem;
|
|
200
|
-
aspect-ratio: 1;
|
|
201
|
-
}
|
|
202
|
-
`;
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* @tagname leu-menu-item
|
|
206
|
-
* @slot - The label of the menu item
|
|
207
|
-
*/
|
|
208
|
-
class LeuMenuItem extends LitElement {
|
|
209
|
-
static styles = css_248z$1
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* @internal
|
|
213
|
-
*/
|
|
214
|
-
static shadowRootOptions = {
|
|
215
|
-
...LitElement.shadowRootOptions,
|
|
216
|
-
delegatesFocus: true,
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
static properties = {
|
|
220
|
-
/**
|
|
221
|
-
* Can be either an icon name or a text
|
|
222
|
-
* If no icon with this value is found, it will be displayed as text.
|
|
223
|
-
* If the value is "EMPTY", an empty placeholder with the size of an icon will be displayed.
|
|
224
|
-
*/
|
|
225
|
-
before: { type: String },
|
|
226
|
-
/**
|
|
227
|
-
* Can be either an icon name or a text
|
|
228
|
-
* If no icon with this value is found, it will be displayed as text
|
|
229
|
-
* If the value is "EMPTY", an empty placeholder with the size of an icon will be displayed.
|
|
230
|
-
*/
|
|
231
|
-
after: { type: String },
|
|
232
|
-
active: { type: Boolean, reflect: true },
|
|
233
|
-
highlighted: { type: Boolean, reflect: true },
|
|
234
|
-
disabled: { type: Boolean, reflect: true },
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
constructor() {
|
|
238
|
-
super();
|
|
239
|
-
|
|
240
|
-
this.active = false;
|
|
241
|
-
this.disabled = false;
|
|
242
|
-
this.before = "";
|
|
243
|
-
this.after = "";
|
|
244
|
-
|
|
245
|
-
/**
|
|
246
|
-
* A programmatic way to highlight the menu item like it is hovered.
|
|
247
|
-
* This is just a visual effect and does not change the active state.
|
|
248
|
-
*/
|
|
249
|
-
this.highlighted = false;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
static getIconOrText(name) {
|
|
253
|
-
if (ICON_NAMES.includes(name)) {
|
|
254
|
-
return Icon(name)
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
if (name === "EMPTY") {
|
|
258
|
-
return html`<div class="icon-placeholder"></div>`
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
return name
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
renderBefore() {
|
|
265
|
-
if (this.before !== "") {
|
|
266
|
-
const content = LeuMenuItem.getIconOrText(this.before);
|
|
267
|
-
return html`<span class="before">${content}</span>`
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
return nothing
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
renderAfter() {
|
|
274
|
-
if (this.after !== "") {
|
|
275
|
-
const content = LeuMenuItem.getIconOrText(this.after);
|
|
276
|
-
return html`<span class="after">${content}</span>`
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
return nothing
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
render() {
|
|
283
|
-
return html`<button class="button" ?disabled=${this.disabled}>
|
|
284
|
-
${this.renderBefore()}<span class="label"><slot></slot></span
|
|
285
|
-
>${this.renderAfter()}
|
|
286
|
-
</button>`
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
function defineMenuItemElements() {
|
|
291
|
-
defineElement("menu-item", LeuMenuItem);
|
|
292
|
-
}
|
|
293
|
-
|
|
294
84
|
var css_248z = css`:host,
|
|
295
85
|
:host * {
|
|
296
86
|
box-sizing: border-box;
|
|
@@ -528,37 +318,76 @@ var css_248z = css`:host,
|
|
|
528
318
|
* @slot after - Optional content the appears after the option list
|
|
529
319
|
*/
|
|
530
320
|
class LeuSelect extends LitElement {
|
|
531
|
-
static styles = css_248z
|
|
532
|
-
|
|
533
321
|
static get properties() {
|
|
534
322
|
return {
|
|
535
|
-
open: {
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
323
|
+
open: {
|
|
324
|
+
type: Boolean,
|
|
325
|
+
attribute: "open"
|
|
326
|
+
},
|
|
327
|
+
label: {
|
|
328
|
+
type: String
|
|
329
|
+
},
|
|
330
|
+
options: {
|
|
331
|
+
type: Array
|
|
332
|
+
},
|
|
333
|
+
value: {
|
|
334
|
+
type: Array
|
|
335
|
+
},
|
|
336
|
+
clearable: {
|
|
337
|
+
type: Boolean,
|
|
338
|
+
reflect: true
|
|
339
|
+
},
|
|
340
|
+
disabled: {
|
|
341
|
+
type: Boolean,
|
|
342
|
+
reflect: true
|
|
343
|
+
},
|
|
344
|
+
filterable: {
|
|
345
|
+
type: Boolean,
|
|
346
|
+
reflect: true
|
|
347
|
+
},
|
|
348
|
+
multiple: {
|
|
349
|
+
type: Boolean,
|
|
350
|
+
reflect: true
|
|
351
|
+
},
|
|
352
|
+
optionFilter: {
|
|
353
|
+
type: String,
|
|
354
|
+
state: true
|
|
355
|
+
}
|
|
356
|
+
};
|
|
546
357
|
}
|
|
547
|
-
|
|
548
358
|
static getOptionLabel(option) {
|
|
549
359
|
if (typeof option === "object" && option !== null) {
|
|
550
|
-
return option.label
|
|
360
|
+
return option.label;
|
|
551
361
|
}
|
|
552
|
-
return option
|
|
362
|
+
return option;
|
|
553
363
|
}
|
|
554
364
|
|
|
555
365
|
/**
|
|
556
366
|
* @internal
|
|
557
367
|
*/
|
|
558
|
-
hasSlotController = new HasSlotController(this, ["before", "after"])
|
|
559
368
|
|
|
560
369
|
constructor() {
|
|
561
370
|
super();
|
|
371
|
+
_defineProperty(this, "hasSlotController", new HasSlotController(this, ["before", "after"]));
|
|
372
|
+
/**
|
|
373
|
+
* Handles clicks outside of the component to close the dropdown.
|
|
374
|
+
* @internal
|
|
375
|
+
* @param {MouseEvent} event
|
|
376
|
+
*/
|
|
377
|
+
_defineProperty(this, "handleDocumentClick", event => {
|
|
378
|
+
if (!this.contains(event.target) && this.open) {
|
|
379
|
+
this.closeDropdown();
|
|
380
|
+
}
|
|
381
|
+
});
|
|
382
|
+
/**
|
|
383
|
+
* @internal
|
|
384
|
+
* @param {KeyboardEvent} e
|
|
385
|
+
*/
|
|
386
|
+
_defineProperty(this, "handleKeyDown", event => {
|
|
387
|
+
if (event.key === "Escape") {
|
|
388
|
+
this.closeDropdown();
|
|
389
|
+
}
|
|
390
|
+
});
|
|
562
391
|
this.open = false;
|
|
563
392
|
this.clearable = false;
|
|
564
393
|
this.value = [];
|
|
@@ -575,15 +404,21 @@ class LeuSelect extends LitElement {
|
|
|
575
404
|
|
|
576
405
|
/** @internal */
|
|
577
406
|
this.deferedChangeEvent = false;
|
|
578
|
-
|
|
579
407
|
this.menuRef = createRef();
|
|
580
408
|
this.optionFilterRef = createRef();
|
|
581
409
|
this.toggleButtonRef = createRef();
|
|
582
410
|
}
|
|
583
|
-
|
|
411
|
+
connectedCallback() {
|
|
412
|
+
super.connectedCallback();
|
|
413
|
+
document.addEventListener("click", this.handleDocumentClick);
|
|
414
|
+
}
|
|
415
|
+
disconnectedCallback() {
|
|
416
|
+
super.disconnectedCallback();
|
|
417
|
+
document.removeEventListener("click", this.handleDocumentClick);
|
|
418
|
+
}
|
|
584
419
|
updated(changedProperties) {
|
|
585
420
|
if (changedProperties.has("open") && this.open) {
|
|
586
|
-
if (this.
|
|
421
|
+
if (this.filterable) {
|
|
587
422
|
this.optionFilterRef.value.focus();
|
|
588
423
|
} else {
|
|
589
424
|
this.menuRef.value.focus();
|
|
@@ -592,83 +427,53 @@ class LeuSelect extends LitElement {
|
|
|
592
427
|
this.toggleButtonRef.value.focus();
|
|
593
428
|
}
|
|
594
429
|
}
|
|
595
|
-
|
|
596
|
-
/**
|
|
597
|
-
* @internal
|
|
598
|
-
* @param {KeyboardEvent} e
|
|
599
|
-
*/
|
|
600
|
-
handleKeyDown = (event) => {
|
|
601
|
-
if (event.key === "Escape") {
|
|
602
|
-
this.closeDropdown();
|
|
603
|
-
}
|
|
604
|
-
}
|
|
605
|
-
|
|
606
430
|
getDisplayValue(value) {
|
|
607
431
|
if (this.multiple) {
|
|
608
|
-
return value.length === 0 ? `` : `${value.length} gewählt
|
|
432
|
+
return value.length === 0 ? `` : `${value.length} gewählt`;
|
|
609
433
|
}
|
|
610
|
-
|
|
611
|
-
return LeuSelect.getOptionLabel(value[0])
|
|
434
|
+
return LeuSelect.getOptionLabel(value[0]);
|
|
612
435
|
}
|
|
613
|
-
|
|
614
436
|
getFilteredOptions() {
|
|
615
|
-
return this.filterable && this.optionFilter.length > 0
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
})
|
|
620
|
-
: this.options
|
|
437
|
+
return this.filterable && this.optionFilter.length > 0 ? this.options.filter(option => {
|
|
438
|
+
const label = LeuSelect.getOptionLabel(option);
|
|
439
|
+
return label.toLowerCase().includes(this.optionFilter.toLowerCase());
|
|
440
|
+
}) : this.options;
|
|
621
441
|
}
|
|
622
|
-
|
|
623
442
|
emitUpdateEvents() {
|
|
624
443
|
this.emitInputEvent();
|
|
625
444
|
this.emitChangeEvent();
|
|
626
445
|
}
|
|
627
|
-
|
|
628
446
|
emitInputEvent() {
|
|
629
447
|
const inputevent = new CustomEvent("input", {
|
|
630
448
|
composed: true,
|
|
631
|
-
bubbles: true
|
|
449
|
+
bubbles: true
|
|
632
450
|
});
|
|
633
451
|
this.dispatchEvent(inputevent);
|
|
634
452
|
}
|
|
635
|
-
|
|
636
453
|
emitChangeEvent() {
|
|
637
454
|
const changeevent = new CustomEvent("change", {
|
|
638
455
|
composed: true,
|
|
639
|
-
bubbles: true
|
|
456
|
+
bubbles: true
|
|
640
457
|
});
|
|
641
458
|
this.dispatchEvent(changeevent);
|
|
642
459
|
}
|
|
643
|
-
|
|
644
460
|
clearValue(event) {
|
|
645
461
|
if (!this.disabled) {
|
|
646
462
|
event.stopPropagation();
|
|
647
463
|
this.value = [];
|
|
648
464
|
}
|
|
649
|
-
|
|
650
465
|
this.emitUpdateEvents();
|
|
651
466
|
}
|
|
652
|
-
|
|
653
|
-
clearOptionFilter() {
|
|
654
|
-
// refocus before removing the button, otherwise closeDropdown is triggered
|
|
655
|
-
this.optionFilterRef.value.focus();
|
|
656
|
-
this.optionFilter = "";
|
|
657
|
-
}
|
|
658
|
-
|
|
659
467
|
toggleDropdown() {
|
|
660
468
|
if (!this.disabled) {
|
|
661
469
|
this.open = !this.open;
|
|
662
470
|
}
|
|
663
471
|
}
|
|
664
|
-
|
|
665
472
|
openDropdown() {
|
|
666
473
|
this.open = true;
|
|
667
474
|
}
|
|
668
|
-
|
|
669
475
|
closeDropdown() {
|
|
670
476
|
this.open = false;
|
|
671
|
-
|
|
672
477
|
if (this.deferedChangeEvent) {
|
|
673
478
|
this.emitChangeEvent();
|
|
674
479
|
this.deferedChangeEvent = false;
|
|
@@ -682,44 +487,32 @@ class LeuSelect extends LitElement {
|
|
|
682
487
|
*/
|
|
683
488
|
selectOption(option) {
|
|
684
489
|
const isSelected = this.isSelected(option);
|
|
685
|
-
|
|
686
490
|
if (this.multiple) {
|
|
687
|
-
this.value = isSelected
|
|
688
|
-
? this.value.filter((v) => v !== option)
|
|
689
|
-
: this.value.concat(option);
|
|
690
|
-
|
|
491
|
+
this.value = isSelected ? this.value.filter(v => v !== option) : this.value.concat(option);
|
|
691
492
|
this.deferedChangeEvent = true;
|
|
692
493
|
} else {
|
|
693
494
|
this.value = isSelected ? [] : [option];
|
|
694
495
|
}
|
|
695
|
-
|
|
696
496
|
this.emitInputEvent();
|
|
697
|
-
|
|
698
497
|
if (!this.multiple) {
|
|
699
498
|
this.closeDropdown();
|
|
700
499
|
}
|
|
701
500
|
}
|
|
702
|
-
|
|
703
501
|
handleApplyClick() {
|
|
704
502
|
this.closeDropdown();
|
|
705
503
|
}
|
|
706
|
-
|
|
707
504
|
handleFilterInput(event) {
|
|
708
505
|
this.optionFilter = event.target.value;
|
|
709
506
|
}
|
|
710
|
-
|
|
711
507
|
isSelected(option) {
|
|
712
|
-
return this.value.includes(option)
|
|
508
|
+
return this.value.includes(option);
|
|
713
509
|
}
|
|
714
|
-
|
|
715
510
|
renderMenu() {
|
|
716
511
|
const menuClasses = {
|
|
717
512
|
"select-menu": true,
|
|
718
|
-
multiple: this.multiple
|
|
513
|
+
multiple: this.multiple
|
|
719
514
|
};
|
|
720
|
-
|
|
721
515
|
const filteredOptions = this.getFilteredOptions();
|
|
722
|
-
|
|
723
516
|
return html`
|
|
724
517
|
<leu-menu
|
|
725
518
|
role="listbox"
|
|
@@ -728,18 +521,15 @@ class LeuSelect extends LitElement {
|
|
|
728
521
|
aria-labelledby="select-label"
|
|
729
522
|
ref=${ref(this.menuRef)}
|
|
730
523
|
>
|
|
731
|
-
${filteredOptions.length > 0
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
}
|
|
741
|
-
|
|
742
|
-
return html`<leu-menu-item
|
|
524
|
+
${filteredOptions.length > 0 ? map(this.getFilteredOptions(), option => {
|
|
525
|
+
const isSelected = this.isSelected(option);
|
|
526
|
+
let beforeIcon;
|
|
527
|
+
if (this.multiple && isSelected) {
|
|
528
|
+
beforeIcon = "check";
|
|
529
|
+
} else if (this.multiple) {
|
|
530
|
+
beforeIcon = "EMPTY";
|
|
531
|
+
}
|
|
532
|
+
return html`<leu-menu-item
|
|
743
533
|
before=${ifDefined(beforeIcon)}
|
|
744
534
|
@click=${() => this.selectOption(option)}
|
|
745
535
|
role="option"
|
|
@@ -747,13 +537,13 @@ class LeuSelect extends LitElement {
|
|
|
747
537
|
aria-selected=${isSelected}
|
|
748
538
|
>
|
|
749
539
|
${LeuSelect.getOptionLabel(option)}
|
|
750
|
-
</leu-menu-item
|
|
751
|
-
|
|
752
|
-
|
|
540
|
+
</leu-menu-item>`;
|
|
541
|
+
}) : html`<leu-menu-item disabled
|
|
542
|
+
>${this.optionFilter === "" ? "Keine Optionen" : "Keine Resultate"}</leu-menu-item
|
|
543
|
+
>`}
|
|
753
544
|
</leu-menu>
|
|
754
|
-
|
|
545
|
+
`;
|
|
755
546
|
}
|
|
756
|
-
|
|
757
547
|
renderFilterInput() {
|
|
758
548
|
if (this.filterable) {
|
|
759
549
|
return html` <leu-input
|
|
@@ -761,13 +551,12 @@ class LeuSelect extends LitElement {
|
|
|
761
551
|
size="small"
|
|
762
552
|
@input=${this.handleFilterInput}
|
|
763
553
|
clearable
|
|
554
|
+
ref=${ref(this.optionFilterRef)}
|
|
764
555
|
>Nach Stichwort filtern</leu-input
|
|
765
|
-
|
|
556
|
+
>`;
|
|
766
557
|
}
|
|
767
|
-
|
|
768
|
-
return nothing
|
|
558
|
+
return nothing;
|
|
769
559
|
}
|
|
770
|
-
|
|
771
560
|
renderApplyButton() {
|
|
772
561
|
if (this.multiple) {
|
|
773
562
|
return html`
|
|
@@ -778,20 +567,17 @@ class LeuSelect extends LitElement {
|
|
|
778
567
|
label="Anwenden"
|
|
779
568
|
fluid
|
|
780
569
|
></leu-button>
|
|
781
|
-
|
|
570
|
+
`;
|
|
782
571
|
}
|
|
783
|
-
|
|
784
|
-
return nothing
|
|
572
|
+
return nothing;
|
|
785
573
|
}
|
|
786
|
-
|
|
787
574
|
renderToggleButton() {
|
|
788
575
|
const toggleClasses = {
|
|
789
576
|
"select-toggle": true,
|
|
790
577
|
open: this.open,
|
|
791
578
|
filled: this.value.length !== 0 && this.value !== null,
|
|
792
|
-
labeled: this.label !== ""
|
|
579
|
+
labeled: this.label !== ""
|
|
793
580
|
};
|
|
794
|
-
|
|
795
581
|
return html`<button
|
|
796
582
|
type="button"
|
|
797
583
|
class=${classMap(toggleClasses)}
|
|
@@ -805,8 +591,7 @@ class LeuSelect extends LitElement {
|
|
|
805
591
|
<span class="label" id="select-label">${this.label}</span>
|
|
806
592
|
<span class="value"> ${this.getDisplayValue(this.value)} </span>
|
|
807
593
|
<span class="arrow-icon"> ${this._arrowIcon} </span>
|
|
808
|
-
${this.clearable && this.value !== "" && this.value.length !== 0
|
|
809
|
-
? html`<button
|
|
594
|
+
${this.clearable && this.value !== "" && this.value.length !== 0 ? html`<button
|
|
810
595
|
type="button"
|
|
811
596
|
class="clear-button"
|
|
812
597
|
@click=${this.clearValue}
|
|
@@ -814,18 +599,15 @@ class LeuSelect extends LitElement {
|
|
|
814
599
|
?disabled=${this.disabled}
|
|
815
600
|
>
|
|
816
601
|
${this._clearIcon}
|
|
817
|
-
</button>`
|
|
818
|
-
|
|
819
|
-
</button>`
|
|
602
|
+
</button>` : nothing}
|
|
603
|
+
</button>`;
|
|
820
604
|
}
|
|
821
|
-
|
|
822
605
|
render() {
|
|
823
606
|
const selectClasses = {
|
|
824
607
|
select: true,
|
|
825
608
|
"select--has-before": this.hasSlotController.test("before"),
|
|
826
|
-
"select--has-after": this.hasSlotController.test("after")
|
|
609
|
+
"select--has-after": this.hasSlotController.test("after")
|
|
827
610
|
};
|
|
828
|
-
|
|
829
611
|
return html`<div
|
|
830
612
|
class=${classMap(selectClasses)}
|
|
831
613
|
?disabled=${this.disabled}
|
|
@@ -844,10 +626,10 @@ class LeuSelect extends LitElement {
|
|
|
844
626
|
${this.renderApplyButton()}
|
|
845
627
|
<slot name="after" class="after"></slot>
|
|
846
628
|
</dialog>
|
|
847
|
-
</div>
|
|
629
|
+
</div> `;
|
|
848
630
|
}
|
|
849
631
|
}
|
|
850
|
-
|
|
632
|
+
_defineProperty(LeuSelect, "styles", css_248z);
|
|
851
633
|
function defineSelectElements() {
|
|
852
634
|
defineButtonElements();
|
|
853
635
|
defineMenuElements();
|