@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
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { _ as _defineProperty, d as defineElement } from './defineElement-ba770aed.js';
|
|
2
|
+
import { css, LitElement, html } from 'lit';
|
|
3
|
+
import { defineButtonElements } from './Button.js';
|
|
4
|
+
import 'lit/directives/class-map.js';
|
|
5
|
+
import './icon-03e86700.js';
|
|
6
|
+
|
|
7
|
+
var css_248z = css`:host {
|
|
8
|
+
margin-top: 16px;
|
|
9
|
+
display: flex;
|
|
10
|
+
justify-content: end;
|
|
11
|
+
font-family: var(--leu-font-regular);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.input {
|
|
15
|
+
width: 50px;
|
|
16
|
+
padding: 0;
|
|
17
|
+
border: 2px solid var(--leu-color-black-40);
|
|
18
|
+
border-radius: 2px;
|
|
19
|
+
color: var(--leu-color-black-transp-60);
|
|
20
|
+
text-align: center;
|
|
21
|
+
font-size: 16px;
|
|
22
|
+
font-style: normal;
|
|
23
|
+
font-weight: 400;
|
|
24
|
+
line-height: 24px;
|
|
25
|
+
outline-offset: 2px;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/* no arrows: Chrome, Safari, Edge, Opera */
|
|
29
|
+
|
|
30
|
+
.input::-webkit-outer-spin-button,
|
|
31
|
+
.input::-webkit-inner-spin-button {
|
|
32
|
+
-webkit-appearance: none;
|
|
33
|
+
appearance: none;
|
|
34
|
+
margin: 0;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/* no arrows: Firefox */
|
|
38
|
+
|
|
39
|
+
.input[type="number"] {
|
|
40
|
+
-webkit-appearance: textfield;
|
|
41
|
+
-moz-appearance: textfield;
|
|
42
|
+
appearance: textfield;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.input:focus,
|
|
46
|
+
.input:hover {
|
|
47
|
+
border-color: var(--leu-color-func-cyan);
|
|
48
|
+
outline: none;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.input:focus-visible {
|
|
52
|
+
outline: 2px solid var(--leu-color-func-cyan);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.label {
|
|
56
|
+
margin: 0 16px;
|
|
57
|
+
line-height: 50px;
|
|
58
|
+
color: var(--leu-color-black-transp-60);
|
|
59
|
+
white-space: nowrap;
|
|
60
|
+
}
|
|
61
|
+
`;
|
|
62
|
+
|
|
63
|
+
const MIN_PAGE = 1;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* @tagname leu-pagination
|
|
67
|
+
*/
|
|
68
|
+
class LeuPagination extends LitElement {
|
|
69
|
+
constructor() {
|
|
70
|
+
super();
|
|
71
|
+
/** @type {number} */
|
|
72
|
+
this.page = 1;
|
|
73
|
+
/** @type {number} */
|
|
74
|
+
this.dataLength = 0;
|
|
75
|
+
/** @type {number} */
|
|
76
|
+
this.itemsOnAPage = 30;
|
|
77
|
+
}
|
|
78
|
+
get maxPage() {
|
|
79
|
+
return Math.ceil(this.dataLength / this.itemsOnAPage);
|
|
80
|
+
}
|
|
81
|
+
get firstPage() {
|
|
82
|
+
return this.page === MIN_PAGE;
|
|
83
|
+
}
|
|
84
|
+
get lastPage() {
|
|
85
|
+
return this.page === this.maxPage;
|
|
86
|
+
}
|
|
87
|
+
holdInRange(value) {
|
|
88
|
+
return Math.min(Math.max(value, MIN_PAGE), this.maxPage);
|
|
89
|
+
}
|
|
90
|
+
numberUpdate(number) {
|
|
91
|
+
this.page = this.holdInRange(number);
|
|
92
|
+
const min = (this.page - 1) * this.itemsOnAPage;
|
|
93
|
+
const max = Math.min(min + this.itemsOnAPage, this.dataLength);
|
|
94
|
+
this.dispatchEvent(new CustomEvent("range-updated", {
|
|
95
|
+
detail: {
|
|
96
|
+
min,
|
|
97
|
+
max
|
|
98
|
+
},
|
|
99
|
+
bubbles: false
|
|
100
|
+
}));
|
|
101
|
+
}
|
|
102
|
+
change(event) {
|
|
103
|
+
// target.value = this.page // eslint-disable-line
|
|
104
|
+
this.numberUpdate(parseInt(event.target.value, 10) || 0);
|
|
105
|
+
}
|
|
106
|
+
input(event) {
|
|
107
|
+
if (event.target.value !== "") {
|
|
108
|
+
event.preventDefault();
|
|
109
|
+
this.change(event);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
keydown(event) {
|
|
113
|
+
const specialKeys = ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", "Backspace", "Enter", "Tab"];
|
|
114
|
+
const numberKeys = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"];
|
|
115
|
+
if (!numberKeys.includes(event.key) && !specialKeys.includes(event.key)) {
|
|
116
|
+
event.preventDefault();
|
|
117
|
+
} else {
|
|
118
|
+
if (event.key === "ArrowUp") {
|
|
119
|
+
event.preventDefault();
|
|
120
|
+
this.numberUpdate(this.page + 1);
|
|
121
|
+
}
|
|
122
|
+
if (event.key === "ArrowDown") {
|
|
123
|
+
event.preventDefault();
|
|
124
|
+
this.numberUpdate(this.page - 1);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
firstUpdated() {
|
|
129
|
+
this.numberUpdate(this.page);
|
|
130
|
+
}
|
|
131
|
+
requestUpdate(name, oldValue, newValue) {
|
|
132
|
+
if (name === "itemsOnAPage") {
|
|
133
|
+
this.numberUpdate(this.page);
|
|
134
|
+
}
|
|
135
|
+
return super.requestUpdate(name, oldValue, newValue);
|
|
136
|
+
}
|
|
137
|
+
render() {
|
|
138
|
+
return html`
|
|
139
|
+
<input
|
|
140
|
+
class="input"
|
|
141
|
+
.value=${this.page}
|
|
142
|
+
@input=${this.input}
|
|
143
|
+
@change=${this.change}
|
|
144
|
+
@keydown=${this.keydown}
|
|
145
|
+
type="number"
|
|
146
|
+
/>
|
|
147
|
+
<div class="label">von ${this.maxPage}</div>
|
|
148
|
+
<leu-button
|
|
149
|
+
icon="angleLeft"
|
|
150
|
+
variant="secondary"
|
|
151
|
+
@click=${_ => {
|
|
152
|
+
this.numberUpdate(this.page - 1);
|
|
153
|
+
}}
|
|
154
|
+
?disabled=${this.firstPage}
|
|
155
|
+
></leu-button>
|
|
156
|
+
<leu-button
|
|
157
|
+
icon="angleRight"
|
|
158
|
+
variant="secondary"
|
|
159
|
+
@click=${_ => {
|
|
160
|
+
this.numberUpdate(this.page + 1);
|
|
161
|
+
}}
|
|
162
|
+
?disabled=${this.lastPage}
|
|
163
|
+
style="margin-left:4px;"
|
|
164
|
+
></leu-button>
|
|
165
|
+
`;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
_defineProperty(LeuPagination, "styles", css_248z);
|
|
169
|
+
_defineProperty(LeuPagination, "events", {
|
|
170
|
+
range: {}
|
|
171
|
+
});
|
|
172
|
+
_defineProperty(LeuPagination, "properties", {
|
|
173
|
+
page: {
|
|
174
|
+
type: Number,
|
|
175
|
+
reflect: true
|
|
176
|
+
},
|
|
177
|
+
itemsOnAPage: {
|
|
178
|
+
type: Number
|
|
179
|
+
},
|
|
180
|
+
dataLength: {
|
|
181
|
+
type: Number
|
|
182
|
+
},
|
|
183
|
+
_minPage: {
|
|
184
|
+
type: Number,
|
|
185
|
+
state: true
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
function definePaginationElements() {
|
|
189
|
+
defineButtonElements();
|
|
190
|
+
defineElement("pagination", LeuPagination);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export { LeuPagination, definePaginationElements };
|
package/dist/Radio.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { _ as _defineProperty, d as defineElement } from './defineElement-ba770aed.js';
|
|
1
2
|
import { css, LitElement, html } from 'lit';
|
|
2
|
-
import { d as defineElement } from './defineElement-47d4f665.js';
|
|
3
3
|
|
|
4
4
|
var css_248z = css`:host {
|
|
5
5
|
--radio-color: var(--leu-color-black-40);
|
|
@@ -98,39 +98,20 @@ var css_248z = css`:host {
|
|
|
98
98
|
* @tagname leu-radio
|
|
99
99
|
*/
|
|
100
100
|
class LeuRadio extends LitElement {
|
|
101
|
-
static styles = css_248z
|
|
102
|
-
|
|
103
|
-
static shadowRootOptions = {
|
|
104
|
-
...LitElement.shadowRootOptions,
|
|
105
|
-
delegatesFocus: true,
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
static properties = {
|
|
109
|
-
checked: { type: Boolean, reflect: true },
|
|
110
|
-
disabled: { type: Boolean, reflect: true },
|
|
111
|
-
identifier: { type: String },
|
|
112
|
-
value: { type: String },
|
|
113
|
-
name: { type: String },
|
|
114
|
-
}
|
|
115
|
-
|
|
116
101
|
constructor() {
|
|
117
102
|
super();
|
|
118
103
|
this.checked = false;
|
|
119
104
|
this.disabled = false;
|
|
120
105
|
this.tabIndex = 0;
|
|
121
106
|
}
|
|
122
|
-
|
|
123
107
|
handleChange(event) {
|
|
124
108
|
this.checked = event.target.checked;
|
|
125
|
-
|
|
126
109
|
const customEvent = new CustomEvent(event.type, event);
|
|
127
110
|
this.dispatchEvent(customEvent);
|
|
128
111
|
}
|
|
129
|
-
|
|
130
112
|
handleInput(event) {
|
|
131
113
|
this.checked = event.target.checked;
|
|
132
114
|
}
|
|
133
|
-
|
|
134
115
|
render() {
|
|
135
116
|
return html`
|
|
136
117
|
<input
|
|
@@ -145,10 +126,33 @@ class LeuRadio extends LitElement {
|
|
|
145
126
|
.value=${this.value}
|
|
146
127
|
/>
|
|
147
128
|
<label for=${this.identifier} class="label"><slot></slot></label>
|
|
148
|
-
|
|
129
|
+
`;
|
|
149
130
|
}
|
|
150
131
|
}
|
|
151
|
-
|
|
132
|
+
_defineProperty(LeuRadio, "styles", css_248z);
|
|
133
|
+
_defineProperty(LeuRadio, "shadowRootOptions", {
|
|
134
|
+
...LitElement.shadowRootOptions,
|
|
135
|
+
delegatesFocus: true
|
|
136
|
+
});
|
|
137
|
+
_defineProperty(LeuRadio, "properties", {
|
|
138
|
+
checked: {
|
|
139
|
+
type: Boolean,
|
|
140
|
+
reflect: true
|
|
141
|
+
},
|
|
142
|
+
disabled: {
|
|
143
|
+
type: Boolean,
|
|
144
|
+
reflect: true
|
|
145
|
+
},
|
|
146
|
+
identifier: {
|
|
147
|
+
type: String
|
|
148
|
+
},
|
|
149
|
+
value: {
|
|
150
|
+
type: String
|
|
151
|
+
},
|
|
152
|
+
name: {
|
|
153
|
+
type: String
|
|
154
|
+
}
|
|
155
|
+
});
|
|
152
156
|
function defineRadioElements() {
|
|
153
157
|
defineElement("radio", LeuRadio);
|
|
154
158
|
}
|
package/dist/RadioGroup.js
CHANGED
|
@@ -1,140 +1,84 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { _ as _defineProperty, d as defineElement } from './defineElement-ba770aed.js';
|
|
2
|
+
import { css, LitElement, html } from 'lit';
|
|
2
3
|
import { classMap } from 'lit/directives/class-map.js';
|
|
3
|
-
import { d as defineElement } from './defineElement-47d4f665.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @tagname leu-radio-group
|
|
7
7
|
*/
|
|
8
8
|
class LeuRadioGroup extends LitElement {
|
|
9
|
-
static styles = css`
|
|
10
|
-
:host {
|
|
11
|
-
--group-font-regular: var(--leu-font-regular);
|
|
12
|
-
--group-font-black: var(--leu-font-black);
|
|
13
|
-
|
|
14
|
-
font-family: var(--group-font-regular);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
.fieldset {
|
|
18
|
-
display: flex;
|
|
19
|
-
align-items: flex-start;
|
|
20
|
-
flex-wrap: wrap;
|
|
21
|
-
gap: 0.5rem 1rem;
|
|
22
|
-
|
|
23
|
-
border: none;
|
|
24
|
-
padding: 0;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.fieldset--vertical {
|
|
28
|
-
flex-direction: column;
|
|
29
|
-
gap: 1rem;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
.legend {
|
|
33
|
-
font-family: var(--group-font-black);
|
|
34
|
-
font-size: 1.125rem;
|
|
35
|
-
line-height: 1.5;
|
|
36
|
-
|
|
37
|
-
margin-bottom: 0.5rem;
|
|
38
|
-
}
|
|
39
|
-
`
|
|
40
|
-
|
|
41
|
-
static properties = {
|
|
42
|
-
orientation: { type: String },
|
|
43
|
-
}
|
|
44
|
-
|
|
45
9
|
constructor() {
|
|
46
10
|
super();
|
|
11
|
+
_defineProperty(this, "handleFocusIn", e => {
|
|
12
|
+
this._currentIndex = this.items.indexOf(e.target);
|
|
13
|
+
});
|
|
14
|
+
_defineProperty(this, "handleKeyDown", e => {
|
|
15
|
+
const currentIndex = this.items.indexOf(e.target);
|
|
16
|
+
switch (e.key) {
|
|
17
|
+
case "ArrowUp":
|
|
18
|
+
case "ArrowLeft":
|
|
19
|
+
this.selectNextItem(currentIndex, -1);
|
|
20
|
+
break;
|
|
21
|
+
case "ArrowDown":
|
|
22
|
+
case "ArrowRight":
|
|
23
|
+
this.selectNextItem(currentIndex, 1);
|
|
24
|
+
break;
|
|
25
|
+
case "Home":
|
|
26
|
+
this.selectItem(this.items.find(item => !item.disabled));
|
|
27
|
+
break;
|
|
28
|
+
case "End":
|
|
29
|
+
this.selectItem(this.items.findLast(item => !item.disabled));
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
this.setTabIndex();
|
|
33
|
+
});
|
|
34
|
+
_defineProperty(this, "handleInput", e => {
|
|
35
|
+
if (e.target.checked) {
|
|
36
|
+
this.items.filter(item => item !== e.target).forEach(item => {
|
|
37
|
+
item.checked = false; // eslint-disable-line no-param-reassign
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
});
|
|
47
41
|
this.orientation = "HORIZONTAL";
|
|
48
42
|
this._currentIndex = 0;
|
|
49
43
|
this.items = [];
|
|
50
44
|
}
|
|
51
|
-
|
|
52
45
|
get value() {
|
|
53
|
-
const checkedValues = this.items
|
|
54
|
-
|
|
55
|
-
.map((i) => i.value);
|
|
56
|
-
return checkedValues.length > 0 ? checkedValues[0] : ""
|
|
46
|
+
const checkedValues = this.items.filter(i => i.checked).map(i => i.value);
|
|
47
|
+
return checkedValues.length > 0 ? checkedValues[0] : "";
|
|
57
48
|
}
|
|
58
|
-
|
|
59
49
|
connectedCallback() {
|
|
60
50
|
super.connectedCallback();
|
|
61
51
|
this.handleItems();
|
|
62
52
|
this.addEventListeners();
|
|
63
53
|
}
|
|
64
|
-
|
|
65
54
|
disconnectedCallback() {
|
|
66
55
|
super.disconnectedCallback();
|
|
67
56
|
this.removeEventListeners();
|
|
68
57
|
}
|
|
69
|
-
|
|
70
58
|
addEventListeners() {
|
|
71
59
|
this.addEventListener("input", this.handleInput);
|
|
72
60
|
this.addEventListener("focusin", this.handleFocusIn);
|
|
73
61
|
this.addEventListener("keydown", this.handleKeyDown);
|
|
74
62
|
}
|
|
75
|
-
|
|
76
63
|
removeEventListeners() {
|
|
77
64
|
this.removeEventListener("input", this.handleInput);
|
|
78
65
|
this.removeEventListener("focusin", this.handleFocusIn);
|
|
79
66
|
this.removeEventListener("keydown", this.handleKeyDown);
|
|
80
67
|
}
|
|
81
|
-
|
|
82
68
|
handleSlotChange() {
|
|
83
69
|
this.handleItems();
|
|
84
70
|
}
|
|
85
|
-
|
|
86
|
-
handleFocusIn = (e) => {
|
|
87
|
-
this._currentIndex = this.items.indexOf(e.target);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
handleKeyDown = (e) => {
|
|
91
|
-
const currentIndex = this.items.indexOf(e.target);
|
|
92
|
-
|
|
93
|
-
switch (e.key) {
|
|
94
|
-
case "ArrowUp":
|
|
95
|
-
case "ArrowLeft":
|
|
96
|
-
this.selectNextItem(currentIndex, -1);
|
|
97
|
-
break
|
|
98
|
-
case "ArrowDown":
|
|
99
|
-
case "ArrowRight":
|
|
100
|
-
this.selectNextItem(currentIndex, 1);
|
|
101
|
-
break
|
|
102
|
-
case "Home":
|
|
103
|
-
this.selectItem(this.items.find((item) => !item.disabled));
|
|
104
|
-
break
|
|
105
|
-
case "End":
|
|
106
|
-
this.selectItem(this.items.findLast((item) => !item.disabled));
|
|
107
|
-
break
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
this.setTabIndex();
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
handleInput = (e) => {
|
|
114
|
-
if (e.target.checked) {
|
|
115
|
-
this.items
|
|
116
|
-
.filter((item) => item !== e.target)
|
|
117
|
-
.forEach((item) => {
|
|
118
|
-
item.checked = false; // eslint-disable-line no-param-reassign
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
71
|
selectItem(selectingItem) {
|
|
124
|
-
this.items.forEach(
|
|
72
|
+
this.items.forEach(item => {
|
|
125
73
|
item.checked = item === selectingItem; // eslint-disable-line no-param-reassign
|
|
126
74
|
});
|
|
127
75
|
}
|
|
128
76
|
|
|
129
77
|
selectNextItem(startingIndex, direction) {
|
|
130
78
|
let selected = false;
|
|
131
|
-
|
|
132
79
|
for (let index = 0; index < this.items.length; index += 1) {
|
|
133
|
-
const currentIndex =
|
|
134
|
-
(this.items.length + index * direction + startingIndex + direction) %
|
|
135
|
-
this.items.length;
|
|
80
|
+
const currentIndex = (this.items.length + index * direction + startingIndex + direction) % this.items.length;
|
|
136
81
|
const currentItem = this.items[currentIndex];
|
|
137
|
-
|
|
138
82
|
if (!selected && !currentItem.disabled) {
|
|
139
83
|
currentItem.checked = true;
|
|
140
84
|
currentItem.focus();
|
|
@@ -144,7 +88,6 @@ class LeuRadioGroup extends LitElement {
|
|
|
144
88
|
}
|
|
145
89
|
}
|
|
146
90
|
}
|
|
147
|
-
|
|
148
91
|
setTabIndex() {
|
|
149
92
|
this.items.forEach((item, index) => {
|
|
150
93
|
if (index === this._currentIndex) {
|
|
@@ -160,33 +103,60 @@ class LeuRadioGroup extends LitElement {
|
|
|
160
103
|
this.initializeIndex();
|
|
161
104
|
this.setTabIndex();
|
|
162
105
|
}
|
|
163
|
-
|
|
164
106
|
initializeIndex() {
|
|
165
|
-
const index = this.items.findIndex(
|
|
166
|
-
|
|
167
|
-
);
|
|
168
|
-
const nextEnabledIndex = this.items.findIndex(
|
|
169
|
-
(item) => !item.hasAttribute("disabled")
|
|
170
|
-
);
|
|
171
|
-
|
|
107
|
+
const index = this.items.findIndex(item => item.hasAttribute("checked") && !item.hasAttribute("disabled"));
|
|
108
|
+
const nextEnabledIndex = this.items.findIndex(item => !item.hasAttribute("disabled"));
|
|
172
109
|
this._currentIndex = index >= 0 ? index : nextEnabledIndex;
|
|
173
110
|
}
|
|
174
|
-
|
|
175
111
|
render() {
|
|
176
112
|
const fieldsetClasses = {
|
|
177
113
|
fieldset: "true",
|
|
178
|
-
"fieldset--vertical": this.orientation === "VERTICAL"
|
|
114
|
+
"fieldset--vertical": this.orientation === "VERTICAL"
|
|
179
115
|
};
|
|
180
|
-
|
|
181
116
|
return html`
|
|
182
117
|
<fieldset class=${classMap(fieldsetClasses)}>
|
|
183
118
|
<legend class="legend"><slot name="legend"></slot></legend>
|
|
184
119
|
<slot @slotchange=${this.handleSlotChange}></slot>
|
|
185
120
|
</fieldset>
|
|
186
|
-
|
|
121
|
+
`;
|
|
187
122
|
}
|
|
188
123
|
}
|
|
124
|
+
_defineProperty(LeuRadioGroup, "styles", css`
|
|
125
|
+
:host {
|
|
126
|
+
--group-font-regular: var(--leu-font-regular);
|
|
127
|
+
--group-font-black: var(--leu-font-black);
|
|
128
|
+
|
|
129
|
+
font-family: var(--group-font-regular);
|
|
130
|
+
}
|
|
189
131
|
|
|
132
|
+
.fieldset {
|
|
133
|
+
display: flex;
|
|
134
|
+
align-items: flex-start;
|
|
135
|
+
flex-wrap: wrap;
|
|
136
|
+
gap: 0.5rem 1rem;
|
|
137
|
+
|
|
138
|
+
border: none;
|
|
139
|
+
padding: 0;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.fieldset--vertical {
|
|
143
|
+
flex-direction: column;
|
|
144
|
+
gap: 1rem;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.legend {
|
|
148
|
+
font-family: var(--group-font-black);
|
|
149
|
+
font-size: 1.125rem;
|
|
150
|
+
line-height: 1.5;
|
|
151
|
+
|
|
152
|
+
margin-bottom: 0.5rem;
|
|
153
|
+
}
|
|
154
|
+
`);
|
|
155
|
+
_defineProperty(LeuRadioGroup, "properties", {
|
|
156
|
+
orientation: {
|
|
157
|
+
type: String
|
|
158
|
+
}
|
|
159
|
+
});
|
|
190
160
|
function defineRadioGroupElements() {
|
|
191
161
|
defineElement("radio-group", LeuRadioGroup);
|
|
192
162
|
}
|