@statistikzh/leu 0.0.2 → 0.1.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 +12 -0
- 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 +112 -122
- package/dist/Menu.js +33 -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 +103 -337
- 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/index.js +7 -3
- package/package.json +3 -1
- package/rollup.config.js +26 -9
- 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/ChipLink.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { _ as _defineProperty, d as defineElement } from './defineElement-ba770aed.js';
|
|
1
2
|
import { html } from 'lit';
|
|
2
|
-
import {
|
|
3
|
-
import { L as LeuChipBase } from './Chip-60af1402.js';
|
|
3
|
+
import { L as LeuChipBase } from './Chip-389013ff.js';
|
|
4
4
|
|
|
5
5
|
const SIZES = {
|
|
6
6
|
regular: "regular",
|
|
7
|
-
large: "large"
|
|
7
|
+
large: "large"
|
|
8
8
|
};
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -12,33 +12,32 @@ const SIZES = {
|
|
|
12
12
|
* @tagname leu-chip-link
|
|
13
13
|
*/
|
|
14
14
|
class LeuChipLink extends LeuChipBase {
|
|
15
|
-
static properties = {
|
|
16
|
-
...LeuChipBase.properties,
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* The size of the chip
|
|
20
|
-
* @type {keyof typeof SIZES}
|
|
21
|
-
*/
|
|
22
|
-
size: { type: String },
|
|
23
|
-
|
|
24
|
-
href: { type: String, reflect: true },
|
|
25
|
-
}
|
|
26
|
-
|
|
27
15
|
constructor() {
|
|
28
16
|
super();
|
|
29
|
-
|
|
30
17
|
this.inverted = false;
|
|
31
18
|
this.size = SIZES.regular;
|
|
32
19
|
this.href = "";
|
|
33
20
|
}
|
|
34
|
-
|
|
35
21
|
render() {
|
|
36
22
|
return html`<a href=${this.href} class="button">
|
|
37
23
|
<span class="label"><slot></slot></span>
|
|
38
|
-
</a
|
|
24
|
+
</a>`;
|
|
39
25
|
}
|
|
40
26
|
}
|
|
41
|
-
|
|
27
|
+
_defineProperty(LeuChipLink, "properties", {
|
|
28
|
+
...LeuChipBase.properties,
|
|
29
|
+
/**
|
|
30
|
+
* The size of the chip
|
|
31
|
+
* @type {keyof typeof SIZES}
|
|
32
|
+
*/
|
|
33
|
+
size: {
|
|
34
|
+
type: String
|
|
35
|
+
},
|
|
36
|
+
href: {
|
|
37
|
+
type: String,
|
|
38
|
+
reflect: true
|
|
39
|
+
}
|
|
40
|
+
});
|
|
42
41
|
function defineChipLinkElements() {
|
|
43
42
|
defineElement("chip-link", LeuChipLink);
|
|
44
43
|
}
|
package/dist/ChipRemovable.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { _ as _defineProperty, d as defineElement } from './defineElement-ba770aed.js';
|
|
1
2
|
import { html } from 'lit';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { I as Icon } from './icon-b68c7e1e.js';
|
|
3
|
+
import { L as LeuChipBase } from './Chip-389013ff.js';
|
|
4
|
+
import { I as Icon } from './icon-03e86700.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* @slot - The content of the chip
|
|
@@ -9,33 +9,29 @@ import { I as Icon } from './icon-b68c7e1e.js';
|
|
|
9
9
|
* @fires remove - Dispatched when the user clicks on the chip
|
|
10
10
|
*/
|
|
11
11
|
class LeuChipRemovable extends LeuChipBase {
|
|
12
|
-
static properties = {
|
|
13
|
-
...LeuChipBase.properties,
|
|
14
|
-
}
|
|
15
|
-
|
|
16
12
|
constructor() {
|
|
17
13
|
super();
|
|
18
14
|
|
|
19
15
|
/** @internal */
|
|
20
16
|
this._removeIcon = Icon("close", 16);
|
|
21
17
|
}
|
|
22
|
-
|
|
23
18
|
handleClick() {
|
|
24
19
|
const customEvent = new CustomEvent("remove", {
|
|
25
20
|
bubble: true,
|
|
26
|
-
composed: true
|
|
21
|
+
composed: true
|
|
27
22
|
});
|
|
28
23
|
this.dispatchEvent(customEvent);
|
|
29
24
|
}
|
|
30
|
-
|
|
31
25
|
render() {
|
|
32
|
-
return html`<button @click=${
|
|
26
|
+
return html`<button @click=${e => this.handleClick(e)} class="button">
|
|
33
27
|
<span class="label"><slot></slot></span>
|
|
34
28
|
<div class="icon">${this._removeIcon}</div>
|
|
35
|
-
</button
|
|
29
|
+
</button>`;
|
|
36
30
|
}
|
|
37
31
|
}
|
|
38
|
-
|
|
32
|
+
_defineProperty(LeuChipRemovable, "properties", {
|
|
33
|
+
...LeuChipBase.properties
|
|
34
|
+
});
|
|
39
35
|
function defineChipRemovableElements() {
|
|
40
36
|
defineElement("chip-removable", LeuChipRemovable);
|
|
41
37
|
}
|
package/dist/ChipSelectable.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
+
import { _ as _defineProperty, d as defineElement } from './defineElement-ba770aed.js';
|
|
1
2
|
import { html } from 'lit';
|
|
2
|
-
import {
|
|
3
|
-
import { L as LeuChipBase } from './Chip-60af1402.js';
|
|
3
|
+
import { L as LeuChipBase } from './Chip-389013ff.js';
|
|
4
4
|
|
|
5
5
|
const SIZES = {
|
|
6
6
|
small: "small",
|
|
7
|
-
regular: "regular"
|
|
7
|
+
regular: "regular"
|
|
8
8
|
};
|
|
9
|
-
|
|
10
9
|
const VARIANTS = {
|
|
11
10
|
default: "default",
|
|
12
|
-
radio: "radio"
|
|
11
|
+
radio: "radio"
|
|
13
12
|
};
|
|
14
13
|
|
|
15
14
|
/**
|
|
@@ -18,73 +17,72 @@ const VARIANTS = {
|
|
|
18
17
|
* @tagname leu-chip-selectable
|
|
19
18
|
*/
|
|
20
19
|
class LeuChipSelectable extends LeuChipBase {
|
|
21
|
-
static properties = {
|
|
22
|
-
...LeuChipBase.properties,
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* The size of the chip. Not supported for radio variant.
|
|
26
|
-
* @type {keyof typeof SIZES}
|
|
27
|
-
* @default "regular"
|
|
28
|
-
*/
|
|
29
|
-
size: { type: String },
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* The variant of the chip. Has an effect not only on the visual appearance but also on the behavior.
|
|
33
|
-
* - `default`: The chip behaves like a toggle button.
|
|
34
|
-
* - `radio`: The chip behaves like a radio button.
|
|
35
|
-
*
|
|
36
|
-
* @type {keyof typeof VARIANTS}
|
|
37
|
-
* @default "default"
|
|
38
|
-
*/
|
|
39
|
-
variant: { type: String },
|
|
40
|
-
|
|
41
|
-
selected: { type: Boolean, reflect: true },
|
|
42
|
-
value: { type: String },
|
|
43
|
-
}
|
|
44
|
-
|
|
45
20
|
constructor() {
|
|
46
21
|
super();
|
|
47
22
|
this.size = SIZES.regular;
|
|
48
23
|
this.variant = VARIANTS.toggle;
|
|
49
24
|
this.selected = false;
|
|
50
|
-
|
|
51
25
|
if (this.variant === VARIANTS.radio && this.size === SIZES.small) {
|
|
52
26
|
console.warn("Small size has no effect on radio variant");
|
|
53
27
|
}
|
|
54
28
|
}
|
|
55
|
-
|
|
56
29
|
handleClick() {
|
|
57
30
|
let nextSelectedState = this.selected;
|
|
58
|
-
|
|
59
31
|
if (this.variant === VARIANTS.radio) {
|
|
60
32
|
nextSelectedState = true;
|
|
61
33
|
} else {
|
|
62
34
|
nextSelectedState = !this.selected;
|
|
63
35
|
}
|
|
64
|
-
|
|
65
36
|
if (nextSelectedState !== this.selected) {
|
|
66
37
|
this.selected = nextSelectedState;
|
|
67
|
-
this.dispatchEvent(
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
);
|
|
38
|
+
this.dispatchEvent(new CustomEvent("input", {
|
|
39
|
+
detail: {
|
|
40
|
+
selected: this.selected
|
|
41
|
+
},
|
|
42
|
+
bubbles: true,
|
|
43
|
+
composed: true
|
|
44
|
+
}));
|
|
74
45
|
}
|
|
75
46
|
}
|
|
76
|
-
|
|
77
47
|
render() {
|
|
78
48
|
return html`<button
|
|
79
|
-
@click=${
|
|
49
|
+
@click=${e => this.handleClick(e)}
|
|
80
50
|
class="button"
|
|
81
51
|
aria-selected=${this.selected ? "true" : "false"}
|
|
82
52
|
>
|
|
83
53
|
<span class="label"><slot></slot></span>
|
|
84
|
-
</button
|
|
54
|
+
</button>`;
|
|
85
55
|
}
|
|
86
56
|
}
|
|
87
|
-
|
|
57
|
+
_defineProperty(LeuChipSelectable, "properties", {
|
|
58
|
+
...LeuChipBase.properties,
|
|
59
|
+
/**
|
|
60
|
+
* The size of the chip. Not supported for radio variant.
|
|
61
|
+
* @type {keyof typeof SIZES}
|
|
62
|
+
* @default "regular"
|
|
63
|
+
*/
|
|
64
|
+
size: {
|
|
65
|
+
type: String
|
|
66
|
+
},
|
|
67
|
+
/**
|
|
68
|
+
* The variant of the chip. Has an effect not only on the visual appearance but also on the behavior.
|
|
69
|
+
* - `default`: The chip behaves like a toggle button.
|
|
70
|
+
* - `radio`: The chip behaves like a radio button.
|
|
71
|
+
*
|
|
72
|
+
* @type {keyof typeof VARIANTS}
|
|
73
|
+
* @default "default"
|
|
74
|
+
*/
|
|
75
|
+
variant: {
|
|
76
|
+
type: String
|
|
77
|
+
},
|
|
78
|
+
selected: {
|
|
79
|
+
type: Boolean,
|
|
80
|
+
reflect: true
|
|
81
|
+
},
|
|
82
|
+
value: {
|
|
83
|
+
type: String
|
|
84
|
+
}
|
|
85
|
+
});
|
|
88
86
|
function defineChipSelectableElements() {
|
|
89
87
|
defineElement("chip-selectable", LeuChipSelectable);
|
|
90
88
|
}
|
package/dist/Dropdown.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
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 { defineMenuElements } from './Menu.js';
|
|
5
|
+
import { defineMenuItemElements } from './MenuItem.js';
|
|
6
|
+
import 'lit/directives/class-map.js';
|
|
7
|
+
import './icon-03e86700.js';
|
|
8
|
+
|
|
9
|
+
var css_248z = css`:host,
|
|
10
|
+
:host * {
|
|
11
|
+
box-sizing: border-box;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
:host {
|
|
15
|
+
position: relative;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.content {
|
|
19
|
+
overflow: hidden;
|
|
20
|
+
box-shadow: var(--leu-box-shadow-short);
|
|
21
|
+
border-radius: 2px;
|
|
22
|
+
|
|
23
|
+
position: absolute;
|
|
24
|
+
top: calc(100% + 0.5rem);
|
|
25
|
+
}
|
|
26
|
+
`;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @tagname leu-dropdown
|
|
30
|
+
*/
|
|
31
|
+
class LeuDropdown extends LitElement {
|
|
32
|
+
constructor() {
|
|
33
|
+
super();
|
|
34
|
+
this.label = "";
|
|
35
|
+
this.expanded = false;
|
|
36
|
+
}
|
|
37
|
+
handleClick() {
|
|
38
|
+
this.expanded = !this.expanded;
|
|
39
|
+
}
|
|
40
|
+
render() {
|
|
41
|
+
return html`
|
|
42
|
+
<leu-button
|
|
43
|
+
icon="download"
|
|
44
|
+
variant="ghost"
|
|
45
|
+
label=${this.label}
|
|
46
|
+
expanded=${this.expanded ? "open" : "closed"}
|
|
47
|
+
aria-expanded=${this.expanded ? "true" : "false"}
|
|
48
|
+
aria-controls="content"
|
|
49
|
+
?active=${this.expanded}
|
|
50
|
+
@click=${this.handleClick}
|
|
51
|
+
></leu-button>
|
|
52
|
+
<div id="content" class="content" ?hidden=${!this.expanded}>
|
|
53
|
+
<slot></slot>
|
|
54
|
+
</div>
|
|
55
|
+
`;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
_defineProperty(LeuDropdown, "styles", css_248z);
|
|
59
|
+
_defineProperty(LeuDropdown, "properties", {
|
|
60
|
+
label: {
|
|
61
|
+
type: String
|
|
62
|
+
},
|
|
63
|
+
expanded: {
|
|
64
|
+
type: Boolean,
|
|
65
|
+
reflect: true
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
function defineDropdownElements() {
|
|
69
|
+
defineElement("dropdown", LeuDropdown);
|
|
70
|
+
defineButtonElements();
|
|
71
|
+
defineMenuElements();
|
|
72
|
+
defineMenuItemElements();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export { LeuDropdown, defineDropdownElements };
|
package/dist/Input.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { _ as _defineProperty, d as defineElement } from './defineElement-ba770aed.js';
|
|
1
2
|
import { css, LitElement, nothing, html } from 'lit';
|
|
2
3
|
import { classMap } from 'lit/directives/class-map.js';
|
|
3
4
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
4
5
|
import { createRef, ref } from 'lit/directives/ref.js';
|
|
5
|
-
import { I as Icon } from './icon-
|
|
6
|
-
import { d as defineElement } from './defineElement-47d4f665.js';
|
|
6
|
+
import { I as Icon } from './icon-03e86700.js';
|
|
7
7
|
|
|
8
8
|
var css_248z = css`:host,
|
|
9
9
|
:host * {
|
|
@@ -273,7 +273,7 @@ var css_248z = css`:host,
|
|
|
273
273
|
|
|
274
274
|
const SIZE_TYPES = {
|
|
275
275
|
SMALL: "small",
|
|
276
|
-
REGULAR: "regular"
|
|
276
|
+
REGULAR: "regular"
|
|
277
277
|
};
|
|
278
278
|
|
|
279
279
|
/**
|
|
@@ -286,15 +286,13 @@ const SIZE_TYPES = {
|
|
|
286
286
|
const VALIDATION_MESSAGES = {
|
|
287
287
|
badInput: "Bitte überprüfen Sie das Format.",
|
|
288
288
|
patternMismatch: "Bitte überprüfen Sie das Format.",
|
|
289
|
-
rangeOverflow:
|
|
290
|
-
rangeUnderflow:
|
|
289
|
+
rangeOverflow: max => `Der Wert darf nicht grösser als ${max} sein.`,
|
|
290
|
+
rangeUnderflow: min => `Der Wert darf nicht kleiner als ${min} sein.`,
|
|
291
291
|
stepMismatch: "Bitte überprüfen Sie das Format.",
|
|
292
|
-
tooLong:
|
|
293
|
-
|
|
294
|
-
tooShort: (minlength) =>
|
|
295
|
-
`Die Eingabe muss länger als ${minlength} Zeichen sein.`,
|
|
292
|
+
tooLong: maxlength => `Die Eingabe muss kürzer als ${maxlength} Zeichen sein.`,
|
|
293
|
+
tooShort: minlength => `Die Eingabe muss länger als ${minlength} Zeichen sein.`,
|
|
296
294
|
typeMismatch: "Bitte überprüfen Sie das Format.",
|
|
297
|
-
valueMissing: "Bitte füllen Sie das Feld aus."
|
|
295
|
+
valueMissing: "Bitte füllen Sie das Feld aus."
|
|
298
296
|
};
|
|
299
297
|
|
|
300
298
|
/**
|
|
@@ -326,65 +324,27 @@ const VALIDATION_MESSAGES = {
|
|
|
326
324
|
* @tagname leu-input
|
|
327
325
|
*/
|
|
328
326
|
class LeuInput extends LitElement {
|
|
329
|
-
static styles = css_248z
|
|
330
|
-
|
|
331
|
-
static properties = {
|
|
332
|
-
disabled: { type: Boolean, reflect: true },
|
|
333
|
-
required: { type: Boolean, reflect: true },
|
|
334
|
-
clearable: { type: Boolean, reflect: true },
|
|
335
|
-
|
|
336
|
-
value: { type: String },
|
|
337
|
-
name: { type: String },
|
|
338
|
-
error: { type: String },
|
|
339
|
-
|
|
340
|
-
label: { type: String },
|
|
341
|
-
prefix: { type: String },
|
|
342
|
-
suffix: { type: String },
|
|
343
|
-
size: { type: String },
|
|
344
|
-
icon: { type: String },
|
|
345
|
-
|
|
346
|
-
/* Validation attributes */
|
|
347
|
-
pattern: { type: String },
|
|
348
|
-
type: { type: String },
|
|
349
|
-
min: { type: Number },
|
|
350
|
-
max: { type: Number },
|
|
351
|
-
maxlength: { type: Number },
|
|
352
|
-
minlength: { type: Number },
|
|
353
|
-
validationMessages: { type: Object },
|
|
354
|
-
novalidate: { type: Boolean },
|
|
355
|
-
|
|
356
|
-
/** @type {ValidityState} */
|
|
357
|
-
_validity: { state: true },
|
|
358
|
-
}
|
|
359
|
-
|
|
360
327
|
static resolveErrorMessage(message, refernceValue) {
|
|
361
328
|
if (typeof message === "function") {
|
|
362
|
-
return message(refernceValue)
|
|
329
|
+
return message(refernceValue);
|
|
363
330
|
}
|
|
364
|
-
|
|
365
|
-
return message
|
|
331
|
+
return message;
|
|
366
332
|
}
|
|
367
|
-
|
|
368
333
|
constructor() {
|
|
369
334
|
super();
|
|
370
|
-
|
|
371
335
|
this.disabled = false;
|
|
372
336
|
this.required = false;
|
|
373
337
|
this.clearable = false;
|
|
374
|
-
|
|
375
338
|
this.value = "";
|
|
376
339
|
this.name = "";
|
|
377
340
|
this.error = "";
|
|
378
|
-
|
|
379
341
|
this.label = "";
|
|
380
342
|
this.prefix = "";
|
|
381
343
|
this.suffix = "";
|
|
382
344
|
|
|
383
345
|
/** @type {keyof typeof SIZE_TYPES} */
|
|
384
346
|
this.size = SIZE_TYPES.REGULAR;
|
|
385
|
-
|
|
386
347
|
this.icon = "";
|
|
387
|
-
|
|
388
348
|
this.type = "text";
|
|
389
349
|
this._validity = null;
|
|
390
350
|
this.validationMessages = {};
|
|
@@ -429,7 +389,6 @@ class LeuInput extends LitElement {
|
|
|
429
389
|
*/
|
|
430
390
|
handleBlur(event) {
|
|
431
391
|
this._validity = null;
|
|
432
|
-
|
|
433
392
|
if (!this.novalidate) {
|
|
434
393
|
event.target.checkValidity();
|
|
435
394
|
}
|
|
@@ -457,7 +416,6 @@ class LeuInput extends LitElement {
|
|
|
457
416
|
*/
|
|
458
417
|
handleChange(event) {
|
|
459
418
|
this.value = event.target.value;
|
|
460
|
-
|
|
461
419
|
const customEvent = new CustomEvent(event.type, event);
|
|
462
420
|
this.dispatchEvent(customEvent);
|
|
463
421
|
}
|
|
@@ -485,13 +443,14 @@ class LeuInput extends LitElement {
|
|
|
485
443
|
*/
|
|
486
444
|
clear() {
|
|
487
445
|
this.value = "";
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
);
|
|
492
|
-
this.dispatchEvent(
|
|
493
|
-
|
|
494
|
-
|
|
446
|
+
this.dispatchEvent(new CustomEvent("input", {
|
|
447
|
+
bubbles: true,
|
|
448
|
+
composed: true
|
|
449
|
+
}));
|
|
450
|
+
this.dispatchEvent(new CustomEvent("change", {
|
|
451
|
+
bubbles: true,
|
|
452
|
+
composed: true
|
|
453
|
+
}));
|
|
495
454
|
}
|
|
496
455
|
|
|
497
456
|
/**
|
|
@@ -504,17 +463,14 @@ class LeuInput extends LitElement {
|
|
|
504
463
|
*/
|
|
505
464
|
getId() {
|
|
506
465
|
const id = this.getAttribute("id");
|
|
507
|
-
|
|
508
466
|
if (id !== null && id !== "") {
|
|
509
|
-
return id
|
|
467
|
+
return id;
|
|
510
468
|
}
|
|
511
|
-
|
|
512
469
|
if (this._identifier !== "") {
|
|
513
|
-
return this._identifier
|
|
470
|
+
return this._identifier;
|
|
514
471
|
}
|
|
515
|
-
|
|
516
472
|
this._identifier = crypto.randomUUID();
|
|
517
|
-
return this._identifier
|
|
473
|
+
return this._identifier;
|
|
518
474
|
}
|
|
519
475
|
|
|
520
476
|
/**
|
|
@@ -531,30 +487,19 @@ class LeuInput extends LitElement {
|
|
|
531
487
|
getValidationMessages() {
|
|
532
488
|
const validationMessages = {
|
|
533
489
|
...VALIDATION_MESSAGES,
|
|
534
|
-
...this.validationMessages
|
|
490
|
+
...this.validationMessages
|
|
535
491
|
};
|
|
536
|
-
|
|
537
|
-
const { tooLong, tooShort, rangeOverflow, rangeUnderflow } =
|
|
538
|
-
validationMessages;
|
|
539
|
-
|
|
540
|
-
validationMessages.tooLong = LeuInput.resolveErrorMessage(
|
|
492
|
+
const {
|
|
541
493
|
tooLong,
|
|
542
|
-
this.maxlength
|
|
543
|
-
);
|
|
544
|
-
validationMessages.tooShort = LeuInput.resolveErrorMessage(
|
|
545
494
|
tooShort,
|
|
546
|
-
this.minlength
|
|
547
|
-
);
|
|
548
|
-
validationMessages.rangeOverflow = LeuInput.resolveErrorMessage(
|
|
549
495
|
rangeOverflow,
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
validationMessages.
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
);
|
|
556
|
-
|
|
557
|
-
return validationMessages
|
|
496
|
+
rangeUnderflow
|
|
497
|
+
} = validationMessages;
|
|
498
|
+
validationMessages.tooLong = LeuInput.resolveErrorMessage(tooLong, this.maxlength);
|
|
499
|
+
validationMessages.tooShort = LeuInput.resolveErrorMessage(tooShort, this.minlength);
|
|
500
|
+
validationMessages.rangeOverflow = LeuInput.resolveErrorMessage(rangeOverflow, this.max);
|
|
501
|
+
validationMessages.rangeUnderflow = LeuInput.resolveErrorMessage(rangeUnderflow, this.min);
|
|
502
|
+
return validationMessages;
|
|
558
503
|
}
|
|
559
504
|
|
|
560
505
|
/**
|
|
@@ -566,27 +511,18 @@ class LeuInput extends LitElement {
|
|
|
566
511
|
*/
|
|
567
512
|
renderErrorMessages() {
|
|
568
513
|
if (!this.isInvalid()) {
|
|
569
|
-
return nothing
|
|
514
|
+
return nothing;
|
|
570
515
|
}
|
|
571
|
-
|
|
572
516
|
const validationMessages = this.getValidationMessages();
|
|
573
|
-
let errorMessages = this._validity
|
|
574
|
-
? Object.entries(validationMessages)
|
|
575
|
-
.filter(([property]) => this._validity[property])
|
|
576
|
-
.map(([_, message]) => message)
|
|
577
|
-
: [];
|
|
578
|
-
|
|
517
|
+
let errorMessages = this._validity ? Object.entries(validationMessages).filter(([property]) => this._validity[property]).map(([_, message]) => message) : [];
|
|
579
518
|
if (this.error !== "") {
|
|
580
519
|
errorMessages = [this.error, errorMessages];
|
|
581
520
|
}
|
|
582
|
-
|
|
583
521
|
return html`
|
|
584
522
|
<ul class="error" aria-errormessage=${`input-${this.getId()}`}>
|
|
585
|
-
${errorMessages.map(
|
|
586
|
-
(message) => html`<li class="error-message">${message}</li>`
|
|
587
|
-
)}
|
|
523
|
+
${errorMessages.map(message => html`<li class="error-message">${message}</li>`)}
|
|
588
524
|
</ul>
|
|
589
|
-
|
|
525
|
+
`;
|
|
590
526
|
}
|
|
591
527
|
|
|
592
528
|
/**
|
|
@@ -598,9 +534,8 @@ class LeuInput extends LitElement {
|
|
|
598
534
|
*/
|
|
599
535
|
renderAfterContent() {
|
|
600
536
|
if (this.isInvalid()) {
|
|
601
|
-
return html`<div class="error-icon">${Icon("caution")}</div
|
|
537
|
+
return html`<div class="error-icon">${Icon("caution")}</div>`;
|
|
602
538
|
}
|
|
603
|
-
|
|
604
539
|
if (this.clearable && this.value !== "") {
|
|
605
540
|
return html`<button
|
|
606
541
|
class="clear-button"
|
|
@@ -609,33 +544,25 @@ class LeuInput extends LitElement {
|
|
|
609
544
|
?disabled=${this.disabled}
|
|
610
545
|
>
|
|
611
546
|
${this._clearIcon}
|
|
612
|
-
</button
|
|
547
|
+
</button>`;
|
|
613
548
|
}
|
|
614
|
-
|
|
615
549
|
if (this.icon !== "") {
|
|
616
|
-
return html`<div class="icon">${Icon(this.icon)}</div
|
|
550
|
+
return html`<div class="icon">${Icon(this.icon)}</div>`;
|
|
617
551
|
}
|
|
618
|
-
|
|
619
|
-
return nothing
|
|
552
|
+
return nothing;
|
|
620
553
|
}
|
|
621
|
-
|
|
622
554
|
isInvalid() {
|
|
623
555
|
if (this.error !== "") {
|
|
624
|
-
return true
|
|
556
|
+
return true;
|
|
625
557
|
}
|
|
626
|
-
|
|
627
|
-
return this._validity === null || this.novalidate
|
|
628
|
-
? false
|
|
629
|
-
: !this._validity.valid
|
|
558
|
+
return this._validity === null || this.novalidate ? false : !this._validity.valid;
|
|
630
559
|
}
|
|
631
|
-
|
|
632
560
|
render() {
|
|
633
561
|
const isInvalid = this.isInvalid();
|
|
634
|
-
|
|
635
562
|
const inputWrapperClasses = {
|
|
636
563
|
"input-wrapper": true,
|
|
637
564
|
"input-wrapper--empty": this.value === "",
|
|
638
|
-
"input-wrapper--invalid": isInvalid
|
|
565
|
+
"input-wrapper--invalid": isInvalid
|
|
639
566
|
};
|
|
640
567
|
|
|
641
568
|
/* See the description of the handleWrapperClick method on why this rule is disabled */
|
|
@@ -666,19 +593,82 @@ class LeuInput extends LitElement {
|
|
|
666
593
|
aria-invalid=${isInvalid}
|
|
667
594
|
/>
|
|
668
595
|
<label for="input-${this.getId()}" class="label"><slot></slot></label>
|
|
669
|
-
${this.prefix !== ""
|
|
670
|
-
|
|
671
|
-
: nothing}
|
|
672
|
-
${this.suffix !== ""
|
|
673
|
-
? html`<div class="suffix" .aria-hidden=${true}>${this.suffix}</div>`
|
|
674
|
-
: nothing}
|
|
596
|
+
${this.prefix !== "" ? html`<div class="prefix" .aria-hidden=${true}>${this.prefix}</div>` : nothing}
|
|
597
|
+
${this.suffix !== "" ? html`<div class="suffix" .aria-hidden=${true}>${this.suffix}</div>` : nothing}
|
|
675
598
|
${this.renderAfterContent()}
|
|
676
599
|
</div>
|
|
677
600
|
${this.renderErrorMessages()}
|
|
678
|
-
|
|
601
|
+
`;
|
|
679
602
|
}
|
|
680
603
|
}
|
|
681
|
-
|
|
604
|
+
_defineProperty(LeuInput, "styles", css_248z);
|
|
605
|
+
_defineProperty(LeuInput, "properties", {
|
|
606
|
+
disabled: {
|
|
607
|
+
type: Boolean,
|
|
608
|
+
reflect: true
|
|
609
|
+
},
|
|
610
|
+
required: {
|
|
611
|
+
type: Boolean,
|
|
612
|
+
reflect: true
|
|
613
|
+
},
|
|
614
|
+
clearable: {
|
|
615
|
+
type: Boolean,
|
|
616
|
+
reflect: true
|
|
617
|
+
},
|
|
618
|
+
value: {
|
|
619
|
+
type: String
|
|
620
|
+
},
|
|
621
|
+
name: {
|
|
622
|
+
type: String
|
|
623
|
+
},
|
|
624
|
+
error: {
|
|
625
|
+
type: String
|
|
626
|
+
},
|
|
627
|
+
label: {
|
|
628
|
+
type: String
|
|
629
|
+
},
|
|
630
|
+
prefix: {
|
|
631
|
+
type: String
|
|
632
|
+
},
|
|
633
|
+
suffix: {
|
|
634
|
+
type: String
|
|
635
|
+
},
|
|
636
|
+
size: {
|
|
637
|
+
type: String
|
|
638
|
+
},
|
|
639
|
+
icon: {
|
|
640
|
+
type: String
|
|
641
|
+
},
|
|
642
|
+
/* Validation attributes */
|
|
643
|
+
pattern: {
|
|
644
|
+
type: String
|
|
645
|
+
},
|
|
646
|
+
type: {
|
|
647
|
+
type: String
|
|
648
|
+
},
|
|
649
|
+
min: {
|
|
650
|
+
type: Number
|
|
651
|
+
},
|
|
652
|
+
max: {
|
|
653
|
+
type: Number
|
|
654
|
+
},
|
|
655
|
+
maxlength: {
|
|
656
|
+
type: Number
|
|
657
|
+
},
|
|
658
|
+
minlength: {
|
|
659
|
+
type: Number
|
|
660
|
+
},
|
|
661
|
+
validationMessages: {
|
|
662
|
+
type: Object
|
|
663
|
+
},
|
|
664
|
+
novalidate: {
|
|
665
|
+
type: Boolean
|
|
666
|
+
},
|
|
667
|
+
/** @type {ValidityState} */
|
|
668
|
+
_validity: {
|
|
669
|
+
state: true
|
|
670
|
+
}
|
|
671
|
+
});
|
|
682
672
|
function defineInputElements() {
|
|
683
673
|
defineElement("input", LeuInput);
|
|
684
674
|
}
|