@statistikzh/leu 0.9.0 → 0.10.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/CHANGELOG.md +15 -0
- package/dist/Accordion.d.ts +1 -1
- package/dist/Accordion.js +1 -1
- package/dist/Breadcrumb.d.ts +1 -1
- package/dist/Breadcrumb.js +1 -1
- package/dist/Button.d.ts +45 -1
- package/dist/Button.d.ts.map +1 -1
- package/dist/Button.js +473 -6
- package/dist/ButtonGroup.d.ts +1 -1
- package/dist/ButtonGroup.js +1 -1
- package/dist/Checkbox.d.ts +1 -1
- package/dist/Checkbox.js +1 -1
- package/dist/CheckboxGroup.d.ts +1 -1
- package/dist/CheckboxGroup.js +1 -1
- package/dist/Chip.d.ts +1 -1
- package/dist/Chip.js +1 -1
- package/dist/ChipGroup.d.ts +1 -1
- package/dist/ChipGroup.js +2 -2
- package/dist/ChipLink.js +1 -1
- package/dist/ChipRemovable.js +1 -1
- package/dist/ChipSelectable.js +1 -1
- package/dist/Dialog.d.ts +17 -0
- package/dist/Dialog.d.ts.map +1 -0
- package/dist/Dialog.js +255 -0
- package/dist/Dropdown.d.ts +1 -1
- package/dist/Dropdown.d.ts.map +1 -1
- package/dist/Dropdown.js +3 -2
- package/dist/Icon.d.ts +1 -1
- package/dist/Icon.js +1 -1
- package/dist/Input.d.ts +1 -1
- package/dist/Input.d.ts.map +1 -1
- package/dist/Input.js +3 -1
- package/dist/{LeuElement-7ab5ef5e.d.ts → LeuElement-6fbc0dee.d.ts} +1 -1
- package/dist/LeuElement-6fbc0dee.d.ts.map +1 -0
- package/dist/{LeuElement-7ab5ef5e.js → LeuElement-6fbc0dee.js} +1 -1
- package/dist/Menu.d.ts +1 -1
- package/dist/Menu.js +1 -1
- package/dist/MenuItem.d.ts +1 -1
- package/dist/MenuItem.js +1 -1
- package/dist/Pagination.d.ts +1 -1
- package/dist/Pagination.d.ts.map +1 -1
- package/dist/Pagination.js +3 -2
- package/dist/Popup.d.ts +1 -1
- package/dist/Popup.js +1 -1
- package/dist/Radio.d.ts +1 -1
- package/dist/Radio.js +1 -1
- package/dist/RadioGroup.d.ts +1 -1
- package/dist/RadioGroup.js +1 -1
- package/dist/ScrollTop.d.ts +1 -1
- package/dist/ScrollTop.d.ts.map +1 -1
- package/dist/ScrollTop.js +3 -2
- package/dist/Select.d.ts +1 -1
- package/dist/Select.d.ts.map +1 -1
- package/dist/Select.js +3 -2
- package/dist/Spinner.d.ts +1 -1
- package/dist/Spinner.js +1 -1
- package/dist/Table.d.ts +1 -1
- package/dist/Table.d.ts.map +1 -1
- package/dist/Table.js +3 -2
- package/dist/VisuallyHidden.d.ts +1 -1
- package/dist/VisuallyHidden.js +1 -1
- package/dist/hasSlotController-04d0dfa2.d.ts +38 -0
- package/dist/hasSlotController-04d0dfa2.d.ts.map +1 -0
- package/dist/hasSlotController-04d0dfa2.js +75 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -2
- package/dist/leu-accordion.js +1 -1
- package/dist/leu-breadcrumb.js +1 -1
- package/dist/leu-button-group.js +1 -1
- package/dist/leu-button.d.ts +1 -1
- package/dist/leu-button.d.ts.map +1 -1
- package/dist/leu-button.js +3 -2
- package/dist/leu-checkbox-group.js +1 -1
- package/dist/leu-checkbox.js +1 -1
- package/dist/leu-chip-group.js +1 -1
- package/dist/leu-chip-link.js +1 -1
- package/dist/leu-chip-removable.js +1 -1
- package/dist/leu-chip-selectable.js +1 -1
- package/dist/leu-dialog.d.ts +3 -0
- package/dist/leu-dialog.d.ts.map +1 -0
- package/dist/leu-dialog.js +11 -0
- package/dist/leu-dropdown.js +3 -2
- package/dist/leu-icon.js +1 -1
- package/dist/leu-input.js +1 -1
- package/dist/leu-menu-item.js +1 -1
- package/dist/leu-menu.js +1 -1
- package/dist/leu-pagination.js +3 -2
- package/dist/leu-popup.js +1 -1
- package/dist/leu-radio-group.js +1 -1
- package/dist/leu-radio.js +1 -1
- package/dist/leu-scroll-top.js +3 -2
- package/dist/leu-select.js +3 -2
- package/dist/leu-spinner.js +1 -1
- package/dist/leu-table.js +3 -2
- package/dist/leu-visually-hidden.js +1 -1
- package/dist/theme.css +318 -192
- package/dist/vscode.html-custom-data.json +15 -0
- package/dist/vue/index.d.ts +19 -0
- package/dist/web-types.json +29 -1
- package/package.json +1 -1
- package/rollup.config.js +4 -1
- package/scripts/postcss-leu-font-styles.cjs +29 -35
- package/src/components/chip/chip-group.css +1 -1
- package/src/components/dialog/Dialog.js +100 -0
- package/src/components/dialog/dialog.css +162 -0
- package/src/components/dialog/leu-dialog.js +5 -0
- package/src/components/dialog/stories/dialog.stories.js +144 -0
- package/src/components/dialog/test/dialog.test.js +85 -0
- package/src/components/input/input.css +2 -0
- package/src/styles/custom-properties.css +27 -0
- package/src/styles/font-definitions.json +27 -19
- package/src/styles/style.stories.js +61 -0
- package/dist/Button-5a8009c5.d.ts +0 -83
- package/dist/Button-5a8009c5.d.ts.map +0 -1
- package/dist/Button-5a8009c5.js +0 -544
- package/dist/LeuElement-7ab5ef5e.d.ts.map +0 -1
package/dist/Button-5a8009c5.js
DELETED
|
@@ -1,544 +0,0 @@
|
|
|
1
|
-
import { _ as _defineProperty, L as LeuElement } from './LeuElement-7ab5ef5e.js';
|
|
2
|
-
import { css, html, nothing } from 'lit';
|
|
3
|
-
import { classMap } from 'lit/directives/class-map.js';
|
|
4
|
-
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
5
|
-
import { LeuIcon } from './Icon.js';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Thanks Shoelace!
|
|
9
|
-
* Source: https://github.com/shoelace-style/shoelace/blob/next/src/internal/slot.ts
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* A reactive controller that determines when slots exist.
|
|
14
|
-
* @typedef {import("lit").ReactiveController} ReactiveController
|
|
15
|
-
* @implements {ReactiveController}
|
|
16
|
-
*/
|
|
17
|
-
class HasSlotController {
|
|
18
|
-
constructor(host, slotNames) {
|
|
19
|
-
/**
|
|
20
|
-
* @private
|
|
21
|
-
* @param {Event} event
|
|
22
|
-
*/
|
|
23
|
-
_defineProperty(this, "handleSlotChange", event => {
|
|
24
|
-
const slot = event.target;
|
|
25
|
-
if (slot instanceof HTMLSlotElement && (this.slotNames.includes("[default]") && !slot.name || slot.name && this.slotNames.includes(slot.name))) {
|
|
26
|
-
this.host.requestUpdate();
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
this.host = host;
|
|
30
|
-
host.addController(this);
|
|
31
|
-
this.slotNames = slotNames;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* @private
|
|
36
|
-
* @returns {Boolean}
|
|
37
|
-
*/
|
|
38
|
-
hasDefaultSlot() {
|
|
39
|
-
return [...this.host.childNodes].some(node => {
|
|
40
|
-
if (node.nodeType === node.TEXT_NODE && node.textContent.trim() !== "") {
|
|
41
|
-
return true;
|
|
42
|
-
}
|
|
43
|
-
if (node.nodeType === node.ELEMENT_NODE) {
|
|
44
|
-
const el = node;
|
|
45
|
-
|
|
46
|
-
// If it doesn't have a slot attribute, it's part of the default slot
|
|
47
|
-
if (!el.hasAttribute("slot")) {
|
|
48
|
-
return true;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return false;
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* @private
|
|
57
|
-
* @param {String} name
|
|
58
|
-
* @returns {Boolean}
|
|
59
|
-
*/
|
|
60
|
-
hasNamedSlot(name) {
|
|
61
|
-
return this.host.querySelector(`:scope > [slot="${name}"]`) !== null;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* @param {String} slotName
|
|
66
|
-
* @returns {Boolean}
|
|
67
|
-
*/
|
|
68
|
-
test(slotName) {
|
|
69
|
-
return slotName === "[default]" ? this.hasDefaultSlot() : this.hasNamedSlot(slotName);
|
|
70
|
-
}
|
|
71
|
-
hostConnected() {
|
|
72
|
-
this.host.shadowRoot.addEventListener("slotchange", this.handleSlotChange);
|
|
73
|
-
}
|
|
74
|
-
hostDisconnected() {
|
|
75
|
-
this.host.shadowRoot.removeEventListener("slotchange", this.handleSlotChange);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* All roles that are associated with a aria-checked attribute
|
|
81
|
-
* @link https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-checked
|
|
82
|
-
*/
|
|
83
|
-
const ARIA_CHECKED_ROLES = ["checkbox", "menuitemcheckbox", "menuitemradio", "option", "radio", "switch"];
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* All roles that are associated with a aria-selected attribute
|
|
87
|
-
* @link https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-selected
|
|
88
|
-
*/
|
|
89
|
-
const ARIA_SELECTED_ROLES = ["gridcell", "option", "row", "tab", "columnheader", "rowheader", "treeitem"];
|
|
90
|
-
|
|
91
|
-
var css_248z = css`:host {
|
|
92
|
-
display: inline-block;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
button {
|
|
96
|
-
font-family: var(--leu-font-family-black);
|
|
97
|
-
text-align: center;
|
|
98
|
-
-webkit-appearance: none;
|
|
99
|
-
-moz-appearance: none;
|
|
100
|
-
appearance: none;
|
|
101
|
-
transition: background 0.1s ease;
|
|
102
|
-
cursor: pointer;
|
|
103
|
-
border: none;
|
|
104
|
-
border-radius: 2px;
|
|
105
|
-
|
|
106
|
-
max-width: 100%;
|
|
107
|
-
display: flex;
|
|
108
|
-
align-items: center;
|
|
109
|
-
-moz-column-gap: 8px;
|
|
110
|
-
column-gap: 8px;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
.content {
|
|
114
|
-
flex: 1 1 0;
|
|
115
|
-
overflow: hidden;
|
|
116
|
-
text-overflow: ellipsis;
|
|
117
|
-
white-space: nowrap;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
button.round {
|
|
121
|
-
border-radius: 50%;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
button:disabled {
|
|
125
|
-
cursor: not-allowed;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
button:focus-visible {
|
|
129
|
-
outline: 2px solid var(--leu-color-func-cyan);
|
|
130
|
-
outline-offset: 2px;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
button.inverted:focus-visible {
|
|
134
|
-
outline: 2px solid var(--leu-color-black-0);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
:host([fluid]) button {
|
|
138
|
-
width: 100%;
|
|
139
|
-
justify-content: center;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/* size - regular */
|
|
143
|
-
|
|
144
|
-
button.regular {
|
|
145
|
-
padding: 12px 24px;
|
|
146
|
-
font-size: 16px;
|
|
147
|
-
line-height: 24px;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
button.regular.icon-only {
|
|
151
|
-
padding: 12px;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
/* size - small */
|
|
155
|
-
|
|
156
|
-
button.small {
|
|
157
|
-
padding: 6px 24px;
|
|
158
|
-
font-size: 14px;
|
|
159
|
-
line-height: 20px;
|
|
160
|
-
|
|
161
|
-
--leu-icon-size: 1rem;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
button.small.icon-only {
|
|
165
|
-
padding: 8px;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
/* primary */
|
|
169
|
-
|
|
170
|
-
button.primary {
|
|
171
|
-
color: var(--leu-color-black-0);
|
|
172
|
-
background: var(--leu-color-black-100);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
button.primary:hover {
|
|
176
|
-
color: var(--leu-color-black-0);
|
|
177
|
-
background: var(--leu-color-black-transp-80);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
button.primary.active {
|
|
181
|
-
color: var(--leu-color-black-0);
|
|
182
|
-
background: var(--leu-color-black-100);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
button.primary.active:hover {
|
|
186
|
-
background: var(--leu-color-black-transp-80);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
button.primary:disabled {
|
|
190
|
-
color: var(--leu-color-black-0);
|
|
191
|
-
background: var(--leu-color-black-transp-20);
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
/* secondary */
|
|
195
|
-
|
|
196
|
-
button.secondary {
|
|
197
|
-
color: var(--leu-color-black-transp-60);
|
|
198
|
-
background: var(--leu-color-black-transp-10);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
button.secondary:hover {
|
|
202
|
-
color: var(--leu-color-black-100);
|
|
203
|
-
background: var(--leu-color-black-transp-20);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
button.secondary.active {
|
|
207
|
-
color: var(--leu-color-black-0);
|
|
208
|
-
background: var(--leu-color-black-100);
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
button.secondary.active:hover {
|
|
212
|
-
background: var(--leu-color-black-transp-80);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
button.secondary:disabled {
|
|
216
|
-
color: var(--leu-color-black-transp-20);
|
|
217
|
-
background: var(--leu-color-black-transp-5);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
/* ghost */
|
|
221
|
-
|
|
222
|
-
button.ghost {
|
|
223
|
-
--leu-icon-size: 1rem;
|
|
224
|
-
|
|
225
|
-
background: transparent;
|
|
226
|
-
padding: 0 0.5rem;
|
|
227
|
-
color: var(--leu-color-black-60);
|
|
228
|
-
font-family: var(--leu-font-family-regular);
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
button.ghost:hover {
|
|
232
|
-
color: var(--leu-color-black-100);
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
button.ghost.active {
|
|
236
|
-
color: var(--leu-color-black-100);
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
button.ghost:disabled {
|
|
240
|
-
color: var(--leu-color-black-20);
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
/* primary + inverted */
|
|
244
|
-
|
|
245
|
-
button.primary.inverted {
|
|
246
|
-
color: var(--leu-color-black-100);
|
|
247
|
-
background: var(--leu-color-black-0);
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
button.primary.inverted:hover {
|
|
251
|
-
color: var(--leu-color-black-100);
|
|
252
|
-
background: var(--leu-color-white-transp-70);
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
button.primary.inverted.active {
|
|
256
|
-
color: var(--leu-color-black-0);
|
|
257
|
-
background: var(--leu-color-black-100);
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
button.primary.inverted:disabled {
|
|
261
|
-
color: var(--leu-color-black-40);
|
|
262
|
-
background: var(--leu-color-white-transp-70);
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
/* secondary + inverted */
|
|
266
|
-
|
|
267
|
-
button.secondary.inverted {
|
|
268
|
-
color: var(--leu-color-black-0);
|
|
269
|
-
background: var(--leu-color-black-transp-20);
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
button.secondary.inverted:hover {
|
|
273
|
-
color: var(--leu-color-black-0);
|
|
274
|
-
background: var(--leu-color-black-transp-40);
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
button.secondary.inverted.active {
|
|
278
|
-
color: var(--leu-color-black-100);
|
|
279
|
-
background: var(--leu-color-black-0);
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
button.secondary.inverted:disabled {
|
|
283
|
-
color: var(--leu-color-white-transp-70);
|
|
284
|
-
background: var(--leu-color-black-transp-10);
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
/* ghost + inverted */
|
|
288
|
-
|
|
289
|
-
button.ghost.inverted {
|
|
290
|
-
color: var(--leu-color-black-0);
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
button.ghost.inverted:hover {
|
|
294
|
-
color: var(--leu-color-white-transp-70);
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
button.ghost.inverted.active {
|
|
298
|
-
color: var(--leu-color-black-0);
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
button.ghost.inverted:disabled {
|
|
302
|
-
color: var(--leu-color-black-20);
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
/* icon-wrapper */
|
|
306
|
-
|
|
307
|
-
.icon-wrapper leu-icon {
|
|
308
|
-
display: block;
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
.ghost.icon-before .icon-wrapper--before,
|
|
312
|
-
.ghost.icon-after .icon-wrapper--after {
|
|
313
|
-
display: block;
|
|
314
|
-
padding: 0.5rem;
|
|
315
|
-
border-radius: 50%;
|
|
316
|
-
background: var(--leu-color-black-transp-10);
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
.ghost.active .icon-wrapper--before, .ghost.active .icon-wrapper--after {
|
|
320
|
-
background: var(--leu-color-black-100);
|
|
321
|
-
color: var(--leu-color-black-0);
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
.ghost:disabled .icon-wrapper--before {
|
|
325
|
-
background: var(--leu-color-black-transp-5);
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
.ghost:disabled .icon-wrapper--after {
|
|
329
|
-
background: var(--leu-color-black-transp-5);
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
/* inverted */
|
|
333
|
-
|
|
334
|
-
.ghost.inverted .icon-wrapper--before, .ghost.inverted .icon-wrapper--after {
|
|
335
|
-
background: var(--leu-color-black-transp-20);
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
.ghost.inverted:hover .icon-wrapper--before, .ghost.inverted:hover .icon-wrapper--after {
|
|
339
|
-
background: var(--leu-color-black-transp-40);
|
|
340
|
-
color: var(--leu-color-black-0);
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
.ghost.inverted:disabled .icon-wrapper--before {
|
|
344
|
-
background: var(--leu-color-black-transp-20);
|
|
345
|
-
color: var(--leu-color-white-transp-70);
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
.ghost.inverted:disabled .icon-wrapper--after {
|
|
349
|
-
background: var(--leu-color-black-transp-20);
|
|
350
|
-
color: var(--leu-color-white-transp-70);
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
.ghost.active.inverted .icon-wrapper--before, .ghost.active.inverted .icon-wrapper--after {
|
|
354
|
-
background: var(--leu-color-black-0);
|
|
355
|
-
color: var(--leu-color-black-100);
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
/* Expanded icon */
|
|
359
|
-
|
|
360
|
-
.icon-wrapper--expanded {
|
|
361
|
-
transition: transform 0.1s ease;
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
:host([expanded="open"]) .icon-wrapper--expanded {
|
|
365
|
-
transform: rotate(180deg);
|
|
366
|
-
}
|
|
367
|
-
`;
|
|
368
|
-
|
|
369
|
-
/*
|
|
370
|
-
Design: https://www.figma.com/file/d6Pv21UVUbnBs3AdcZijHmbN/KTZH-Design-System?type=design&node-id=4-1444&mode=design&t=xu5Vii8jXKKCKDez-0
|
|
371
|
-
Live Demo: zh.ch
|
|
372
|
-
*/
|
|
373
|
-
|
|
374
|
-
const BUTTON_VARIANTS = ["primary", "secondary", "ghost"];
|
|
375
|
-
Object.freeze(BUTTON_VARIANTS);
|
|
376
|
-
const BUTTON_SIZES = ["regular", "small"];
|
|
377
|
-
Object.freeze(BUTTON_SIZES);
|
|
378
|
-
const BUTTON_TYPES = ["button", "submit", "reset"];
|
|
379
|
-
Object.freeze(BUTTON_TYPES);
|
|
380
|
-
const BUTTON_EXPANDED_OPTIONS = ["true", "false"];
|
|
381
|
-
Object.freeze(BUTTON_EXPANDED_OPTIONS);
|
|
382
|
-
|
|
383
|
-
/**
|
|
384
|
-
* @tagname leu-button
|
|
385
|
-
* @slot before - The icon to display before the label
|
|
386
|
-
* @slot after - The icon to display after the label
|
|
387
|
-
* @slot - The label of the button or the icon if no label is set
|
|
388
|
-
*/
|
|
389
|
-
class LeuButton extends LeuElement {
|
|
390
|
-
constructor() {
|
|
391
|
-
super();
|
|
392
|
-
/** @type {string} */
|
|
393
|
-
/**
|
|
394
|
-
* @internal
|
|
395
|
-
*/
|
|
396
|
-
_defineProperty(this, "hasSlotController", new HasSlotController(this, ["before", "after", "[default]"]));
|
|
397
|
-
this.label = null;
|
|
398
|
-
/** @type {string} */
|
|
399
|
-
this.size = "regular";
|
|
400
|
-
/** @type {string} */
|
|
401
|
-
this.variant = "primary";
|
|
402
|
-
/** @type {"button" | "submit" | "reset"} */
|
|
403
|
-
this.type = "button";
|
|
404
|
-
|
|
405
|
-
/** @type {string} */
|
|
406
|
-
this.componentRole = undefined;
|
|
407
|
-
|
|
408
|
-
/** @type {boolean} */
|
|
409
|
-
this.disabled = false;
|
|
410
|
-
/** @type {boolean} - Only taken into account if no Label and an Icon is set */
|
|
411
|
-
this.round = false;
|
|
412
|
-
/** @type {boolean} */
|
|
413
|
-
this.active = false;
|
|
414
|
-
/** @type {boolean} - will be used on dark Background */
|
|
415
|
-
this.inverted = false;
|
|
416
|
-
|
|
417
|
-
/** @type {boolean} - Alters the shape of the button to be full width of its parent container */
|
|
418
|
-
this.fluid = false;
|
|
419
|
-
|
|
420
|
-
/**
|
|
421
|
-
* Only taken into account if variant is "ghost"
|
|
422
|
-
* @type {("true" | "false" | undefined)}
|
|
423
|
-
*/
|
|
424
|
-
this.expanded = undefined;
|
|
425
|
-
}
|
|
426
|
-
renderExpandingIcon() {
|
|
427
|
-
if (typeof this.expanded !== "undefined" && this.variant === "ghost") {
|
|
428
|
-
return html`<div class="icon-wrapper icon-wrapper--expanded">
|
|
429
|
-
<leu-icon name="angleDropDown" size="24"></leu-icon>
|
|
430
|
-
</div>`;
|
|
431
|
-
}
|
|
432
|
-
return nothing;
|
|
433
|
-
}
|
|
434
|
-
getAriaAttributes() {
|
|
435
|
-
const attributes = {
|
|
436
|
-
role: this.componentRole,
|
|
437
|
-
label: this.label
|
|
438
|
-
};
|
|
439
|
-
if (this.componentRole) {
|
|
440
|
-
if (ARIA_CHECKED_ROLES.includes(this.componentRole)) {
|
|
441
|
-
attributes.checked = this.active ? "true" : "false";
|
|
442
|
-
} else if (ARIA_SELECTED_ROLES.includes(this.componentRole)) {
|
|
443
|
-
attributes.selected = this.active ? "true" : "false";
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
return attributes;
|
|
447
|
-
}
|
|
448
|
-
hasTextContent() {
|
|
449
|
-
return Array.from(this.childNodes).some(node => node.nodeType === node.TEXT_NODE && node.textContent.trim() !== "");
|
|
450
|
-
}
|
|
451
|
-
render() {
|
|
452
|
-
const hasTextContent = this.hasTextContent();
|
|
453
|
-
const hasIconDefault = Boolean(this.querySelector("leu-icon"));
|
|
454
|
-
const hasIconBefore = this.hasSlotController.test("before");
|
|
455
|
-
const hasIconAfter = this.hasSlotController.test("after");
|
|
456
|
-
const aria = this.getAriaAttributes();
|
|
457
|
-
const cssClasses = {
|
|
458
|
-
"icon-only": hasIconDefault && !hasTextContent,
|
|
459
|
-
"icon-before": hasIconBefore,
|
|
460
|
-
"icon-after": hasIconAfter,
|
|
461
|
-
round: this.round,
|
|
462
|
-
active: this.active,
|
|
463
|
-
inverted: this.inverted,
|
|
464
|
-
[this.variant]: true,
|
|
465
|
-
[this.size]: true
|
|
466
|
-
};
|
|
467
|
-
return html`
|
|
468
|
-
<button
|
|
469
|
-
aria-label=${ifDefined(aria.label)}
|
|
470
|
-
aria-selected=${ifDefined(aria.selected)}
|
|
471
|
-
aria-checked=${ifDefined(aria.checked)}
|
|
472
|
-
aria-expanded=${ifDefined(this.expanded)}
|
|
473
|
-
role=${ifDefined(aria.role)}
|
|
474
|
-
class=${classMap(cssClasses)}
|
|
475
|
-
?disabled=${this.disabled}
|
|
476
|
-
type=${this.type}
|
|
477
|
-
>
|
|
478
|
-
<slot name="before" class="icon-wrapper icon-wrapper--before"></slot>
|
|
479
|
-
<span class="content"><slot></slot></span>
|
|
480
|
-
<slot name="after" class="icon-wrapper icon-wrapper--after"></slot>
|
|
481
|
-
${this.renderExpandingIcon()}
|
|
482
|
-
</button>
|
|
483
|
-
`;
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
_defineProperty(LeuButton, "dependencies", {
|
|
487
|
-
"leu-icon": LeuIcon
|
|
488
|
-
});
|
|
489
|
-
_defineProperty(LeuButton, "styles", css_248z);
|
|
490
|
-
/**
|
|
491
|
-
* @internal
|
|
492
|
-
*/
|
|
493
|
-
_defineProperty(LeuButton, "shadowRootOptions", {
|
|
494
|
-
...LeuElement.shadowRootOptions,
|
|
495
|
-
delegatesFocus: true
|
|
496
|
-
});
|
|
497
|
-
_defineProperty(LeuButton, "properties", {
|
|
498
|
-
label: {
|
|
499
|
-
type: String,
|
|
500
|
-
reflect: true
|
|
501
|
-
},
|
|
502
|
-
size: {
|
|
503
|
-
type: String,
|
|
504
|
-
reflect: true
|
|
505
|
-
},
|
|
506
|
-
variant: {
|
|
507
|
-
type: String,
|
|
508
|
-
reflect: true
|
|
509
|
-
},
|
|
510
|
-
type: {
|
|
511
|
-
type: String,
|
|
512
|
-
reflect: true
|
|
513
|
-
},
|
|
514
|
-
componentRole: {
|
|
515
|
-
type: String,
|
|
516
|
-
reflect: true
|
|
517
|
-
},
|
|
518
|
-
disabled: {
|
|
519
|
-
type: Boolean,
|
|
520
|
-
reflect: true
|
|
521
|
-
},
|
|
522
|
-
round: {
|
|
523
|
-
type: Boolean,
|
|
524
|
-
reflect: true
|
|
525
|
-
},
|
|
526
|
-
active: {
|
|
527
|
-
type: Boolean,
|
|
528
|
-
reflect: true
|
|
529
|
-
},
|
|
530
|
-
inverted: {
|
|
531
|
-
type: Boolean,
|
|
532
|
-
reflect: true
|
|
533
|
-
},
|
|
534
|
-
expanded: {
|
|
535
|
-
type: String,
|
|
536
|
-
reflect: true
|
|
537
|
-
},
|
|
538
|
-
fluid: {
|
|
539
|
-
type: Boolean,
|
|
540
|
-
reflect: true
|
|
541
|
-
}
|
|
542
|
-
});
|
|
543
|
-
|
|
544
|
-
export { BUTTON_VARIANTS as B, HasSlotController as H, LeuButton as L, BUTTON_SIZES as a, BUTTON_TYPES as b, BUTTON_EXPANDED_OPTIONS as c };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LeuElement-7ab5ef5e.d.ts","sourceRoot":"","sources":["LeuElement-7ab5ef5e.js"],"names":[],"mappings":"AA+BA;IACE,8EAcC;CACF;AA7CD,sEAaC;2BAf0B,KAAK"}
|