@statistikzh/leu 0.5.1 → 0.7.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/.husky/commit-msg +0 -3
- package/.husky/pre-commit +0 -3
- package/CHANGELOG.md +54 -0
- package/dist/Accordion.d.ts +10 -9
- package/dist/Accordion.d.ts.map +1 -1
- package/dist/Accordion.js +12 -11
- package/dist/Breadcrumb.d.ts +4 -4
- package/dist/Breadcrumb.d.ts.map +1 -1
- package/dist/Breadcrumb.js +28 -24
- package/dist/{Button-5326c982.d.ts → Button-7370f901.d.ts} +10 -11
- package/dist/Button-7370f901.d.ts.map +1 -0
- package/dist/{Button-5326c982.js → Button-7370f901.js} +57 -67
- package/dist/Button.d.ts +1 -1
- package/dist/Button.js +3 -3
- package/dist/ButtonGroup.d.ts +2 -2
- package/dist/ButtonGroup.d.ts.map +1 -1
- package/dist/ButtonGroup.js +3 -3
- package/dist/Checkbox.d.ts +4 -3
- package/dist/Checkbox.d.ts.map +1 -1
- package/dist/Checkbox.js +14 -17
- package/dist/CheckboxGroup.d.ts +2 -2
- package/dist/CheckboxGroup.d.ts.map +1 -1
- package/dist/CheckboxGroup.js +4 -4
- package/dist/Chip.d.ts +2 -2
- package/dist/Chip.d.ts.map +1 -1
- package/dist/Chip.js +23 -28
- package/dist/ChipGroup.d.ts +16 -8
- package/dist/ChipGroup.d.ts.map +1 -1
- package/dist/ChipGroup.js +39 -9
- package/dist/ChipLink.d.ts +2 -1
- package/dist/ChipLink.d.ts.map +1 -1
- package/dist/ChipLink.js +4 -7
- package/dist/ChipRemovable.d.ts +0 -2
- package/dist/ChipRemovable.d.ts.map +1 -1
- package/dist/ChipRemovable.js +8 -11
- package/dist/ChipSelectable.d.ts +12 -2
- package/dist/ChipSelectable.d.ts.map +1 -1
- package/dist/ChipSelectable.js +24 -26
- package/dist/Dropdown.d.ts +9 -5
- package/dist/Dropdown.d.ts.map +1 -1
- package/dist/Dropdown.js +68 -32
- package/dist/Icon.d.ts +116 -0
- package/dist/Icon.d.ts.map +1 -0
- package/dist/{icon-03e86700.js → Icon.js} +61 -32
- package/dist/Input.d.ts +13 -17
- package/dist/Input.d.ts.map +1 -1
- package/dist/Input.js +33 -24
- package/dist/LeuElement-ba5ea33d.d.ts +7 -0
- package/dist/LeuElement-ba5ea33d.d.ts.map +1 -0
- package/dist/{_rollupPluginBabelHelpers-20f659f4.js → LeuElement-ba5ea33d.js} +20 -1
- package/dist/Menu.d.ts +24 -2
- package/dist/Menu.d.ts.map +1 -1
- package/dist/Menu.js +120 -3
- package/dist/MenuItem.d.ts +28 -11
- package/dist/MenuItem.d.ts.map +1 -1
- package/dist/MenuItem.js +110 -63
- package/dist/Pagination.d.ts +10 -3
- package/dist/Pagination.d.ts.map +1 -1
- package/dist/Pagination.js +24 -21
- package/dist/Popup.d.ts +21 -3
- package/dist/Popup.d.ts.map +1 -1
- package/dist/Popup.js +44 -17
- package/dist/Radio.d.ts +4 -2
- package/dist/Radio.d.ts.map +1 -1
- package/dist/Radio.js +9 -14
- package/dist/RadioGroup.d.ts +2 -2
- package/dist/RadioGroup.d.ts.map +1 -1
- package/dist/RadioGroup.js +20 -11
- package/dist/ScrollTop.d.ts +2 -2
- package/dist/ScrollTop.d.ts.map +1 -1
- package/dist/ScrollTop.js +10 -8
- package/dist/Select.d.ts +75 -37
- package/dist/Select.d.ts.map +1 -1
- package/dist/Select.js +279 -181
- package/dist/Table.d.ts +2 -6
- package/dist/Table.d.ts.map +1 -1
- package/dist/Table.js +16 -16
- package/dist/VisuallyHidden.d.ts +2 -2
- package/dist/VisuallyHidden.d.ts.map +1 -1
- package/dist/VisuallyHidden.js +3 -3
- package/dist/index.d.ts +2 -2
- package/dist/index.js +5 -14
- package/dist/leu-accordion.d.ts.map +1 -1
- package/dist/leu-accordion.js +2 -3
- package/dist/leu-breadcrumb.d.ts.map +1 -1
- package/dist/leu-breadcrumb.js +4 -10
- package/dist/leu-button-group.d.ts.map +1 -1
- package/dist/leu-button-group.js +2 -3
- package/dist/leu-button.d.ts +1 -1
- package/dist/leu-button.d.ts.map +1 -1
- package/dist/leu-button.js +4 -5
- package/dist/leu-checkbox-group.d.ts.map +1 -1
- package/dist/leu-checkbox-group.js +2 -3
- package/dist/leu-checkbox.d.ts.map +1 -1
- package/dist/leu-checkbox.js +3 -4
- package/dist/leu-chip-group.d.ts.map +1 -1
- package/dist/leu-chip-group.js +2 -3
- package/dist/leu-chip-link.d.ts.map +1 -1
- package/dist/leu-chip-link.js +2 -3
- package/dist/leu-chip-removable.d.ts.map +1 -1
- package/dist/leu-chip-removable.js +3 -4
- package/dist/leu-chip-selectable.d.ts.map +1 -1
- package/dist/leu-chip-selectable.js +2 -3
- package/dist/leu-dropdown.d.ts.map +1 -1
- package/dist/leu-dropdown.js +5 -10
- package/dist/leu-icon.d.ts +3 -0
- package/dist/leu-icon.d.ts.map +1 -0
- package/dist/leu-icon.js +7 -0
- package/dist/leu-input.d.ts.map +1 -1
- package/dist/leu-input.js +3 -4
- package/dist/leu-menu-item.d.ts.map +1 -1
- package/dist/leu-menu-item.js +3 -5
- package/dist/leu-menu.d.ts.map +1 -1
- package/dist/leu-menu.js +5 -3
- package/dist/leu-pagination.d.ts.map +1 -1
- package/dist/leu-pagination.js +4 -7
- package/dist/leu-popup.d.ts.map +1 -1
- package/dist/leu-popup.js +2 -3
- package/dist/leu-radio-group.d.ts.map +1 -1
- package/dist/leu-radio-group.js +2 -3
- package/dist/leu-radio.d.ts.map +1 -1
- package/dist/leu-radio.js +2 -3
- package/dist/leu-scroll-top.d.ts.map +1 -1
- package/dist/leu-scroll-top.js +4 -6
- package/dist/leu-select.d.ts.map +1 -1
- package/dist/leu-select.js +5 -13
- package/dist/leu-table.d.ts.map +1 -1
- package/dist/leu-table.js +4 -8
- package/dist/leu-visually-hidden.d.ts.map +1 -1
- package/dist/leu-visually-hidden.js +2 -3
- package/dist/theme.css +2 -0
- package/dist/vscode.html-custom-data.json +124 -74
- package/dist/vue/index.d.ts +83 -67
- package/dist/web-types.json +256 -142
- package/package.json +9 -12
- package/scripts/generate-component/templates/[Name].js +6 -3
- package/scripts/generate-component/templates/test/[name].test.js +1 -1
- package/src/components/accordion/Accordion.js +13 -10
- package/src/components/accordion/leu-accordion.js +1 -2
- package/src/components/breadcrumb/Breadcrumb.js +31 -18
- package/src/components/breadcrumb/leu-breadcrumb.js +1 -2
- package/src/components/button/Button.js +45 -71
- package/src/components/button/button.css +11 -9
- package/src/components/button/leu-button.js +1 -2
- package/src/components/button/stories/button.stories.js +60 -19
- package/src/components/button/test/button.test.js +26 -63
- package/src/components/button-group/ButtonGroup.js +4 -2
- package/src/components/button-group/leu-button-group.js +1 -2
- package/src/components/checkbox/Checkbox.js +17 -11
- package/src/components/checkbox/CheckboxGroup.js +6 -3
- package/src/components/checkbox/leu-checkbox-group.js +1 -2
- package/src/components/checkbox/leu-checkbox.js +1 -2
- package/src/components/checkbox/stories/checkbox-group.stories.js +10 -26
- package/src/components/checkbox/stories/checkbox.stories.js +2 -7
- package/src/components/checkbox/test/checkbox-group.test.js +6 -21
- package/src/components/checkbox/test/checkbox.test.js +1 -12
- package/src/components/chip/Chip.js +5 -4
- package/src/components/chip/ChipGroup.js +38 -8
- package/src/components/chip/ChipLink.js +3 -7
- package/src/components/chip/ChipRemovable.js +8 -11
- package/src/components/chip/ChipSelectable.js +23 -27
- package/src/components/chip/chip.css +19 -20
- package/src/components/chip/leu-chip-group.js +1 -2
- package/src/components/chip/leu-chip-link.js +1 -2
- package/src/components/chip/leu-chip-removable.js +1 -2
- package/src/components/chip/leu-chip-selectable.js +1 -2
- package/src/components/chip/stories/chip-group.stories.js +6 -9
- package/src/components/chip/stories/chip-link.stories.js +3 -5
- package/src/components/chip/stories/chip-removable.stories.js +3 -4
- package/src/components/chip/stories/chip-selectable.stories.js +3 -3
- package/src/components/chip/test/chip-group.test.js +82 -30
- package/src/components/chip/test/chip-link.test.js +2 -6
- package/src/components/chip/test/chip-removable.test.js +4 -10
- package/src/components/chip/test/chip-selectable.test.js +10 -12
- package/src/components/dropdown/Dropdown.js +79 -26
- package/src/components/dropdown/leu-dropdown.js +1 -2
- package/src/components/dropdown/stories/dropdown.stories.js +30 -7
- package/src/components/dropdown/test/dropdown.test.js +5 -5
- package/src/components/icon/Icon.js +55 -0
- package/src/components/icon/icon.css +6 -0
- package/src/components/icon/leu-icon.js +5 -0
- package/src/components/icon/{icon.js → paths.js} +4 -37
- package/src/components/icon/stories/icon.stories.js +47 -0
- package/src/components/icon/test/icon.test.js +23 -40
- package/src/components/input/Input.js +31 -20
- package/src/components/input/input.css +4 -2
- package/src/components/input/leu-input.js +1 -2
- package/src/components/input/stories/input.stories.js +5 -5
- package/src/components/input/test/input.test.js +22 -0
- package/src/components/menu/Menu.js +143 -2
- package/src/components/menu/MenuItem.js +104 -52
- package/src/components/menu/leu-menu-item.js +1 -2
- package/src/components/menu/leu-menu.js +1 -2
- package/src/components/menu/menu-item.css +11 -4
- package/src/components/menu/stories/menu-item.stories.js +15 -4
- package/src/components/menu/stories/menu.stories.js +34 -7
- package/src/components/menu/test/menu-item.test.js +88 -82
- package/src/components/menu/test/menu.test.js +101 -8
- package/src/components/pagination/Pagination.js +27 -18
- package/src/components/pagination/leu-pagination.js +1 -2
- package/src/components/popup/Popup.js +39 -16
- package/src/components/popup/leu-popup.js +1 -2
- package/src/components/popup/popup.css +1 -0
- package/src/components/radio/Radio.js +12 -7
- package/src/components/radio/RadioGroup.js +18 -12
- package/src/components/radio/leu-radio-group.js +1 -2
- package/src/components/radio/leu-radio.js +1 -2
- package/src/components/radio/stories/radio-group.stories.js +5 -19
- package/src/components/radio/stories/radio.stories.js +2 -7
- package/src/components/radio/test/radio-group.test.js +6 -9
- package/src/components/radio/test/radio.test.js +3 -13
- package/src/components/scroll-top/ScrollTop.js +15 -5
- package/src/components/scroll-top/leu-scroll-top.js +1 -2
- package/src/components/select/Select.js +279 -175
- package/src/components/select/leu-select.js +1 -2
- package/src/components/select/select.css +20 -12
- package/src/components/select/stories/select.stories.js +16 -2
- package/src/components/select/test/select.test.js +191 -37
- package/src/components/table/Table.js +15 -9
- package/src/components/table/leu-table.js +1 -2
- package/src/components/table/table.css +3 -1
- package/src/components/visually-hidden/VisuallyHidden.js +6 -2
- package/src/components/visually-hidden/leu-visually-hidden.js +1 -2
- package/src/lib/LeuElement.js +23 -0
- package/src/lib/a11y.js +26 -0
- package/src/styles/custom-properties.css +2 -0
- package/web-test-runner.config.mjs +2 -0
- package/dist/Button-5326c982.d.ts.map +0 -1
- package/dist/_rollupPluginBabelHelpers-20f659f4.d.ts +0 -3
- package/dist/_rollupPluginBabelHelpers-20f659f4.d.ts.map +0 -1
- package/dist/defineElement-40372b4b.d.ts +0 -9
- package/dist/defineElement-40372b4b.d.ts.map +0 -1
- package/dist/defineElement-40372b4b.js +0 -15
- package/dist/icon-03e86700.d.ts +0 -11
- package/dist/icon-03e86700.d.ts.map +0 -1
- package/src/lib/defineElement.js +0 -13
package/dist/Input.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { _ as _defineProperty } from './
|
|
2
|
-
import { css,
|
|
1
|
+
import { _ as _defineProperty, L as LeuElement } from './LeuElement-ba5ea33d.js';
|
|
2
|
+
import { css, nothing, html } from 'lit';
|
|
3
3
|
import { classMap } from 'lit/directives/class-map.js';
|
|
4
4
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
5
5
|
import { live } from 'lit/directives/live.js';
|
|
6
6
|
import { createRef, ref } from 'lit/directives/ref.js';
|
|
7
|
-
import {
|
|
7
|
+
import { LeuIcon } from './Icon.js';
|
|
8
8
|
|
|
9
9
|
var css_248z = css`:host,
|
|
10
10
|
:host * {
|
|
@@ -181,7 +181,9 @@ var css_248z = css`:host,
|
|
|
181
181
|
|
|
182
182
|
/* is size small AND has no focus AND is empty */
|
|
183
183
|
|
|
184
|
-
:host(:not(:focus-within)[size="small"])
|
|
184
|
+
:host(:not(:focus-within)[size="small"])
|
|
185
|
+
.input-wrapper--empty:not(.input-wrapper--invalid)
|
|
186
|
+
.label {
|
|
185
187
|
top: calc(0.75rem - var(--input-border-width));
|
|
186
188
|
opacity: 1;
|
|
187
189
|
visibility: visible;
|
|
@@ -270,15 +272,15 @@ var css_248z = css`:host,
|
|
|
270
272
|
color: var(--input-color-invalid);
|
|
271
273
|
}
|
|
272
274
|
|
|
273
|
-
.icon
|
|
275
|
+
.icon leu-icon, .error-icon leu-icon {
|
|
274
276
|
display: block;
|
|
275
277
|
}
|
|
276
278
|
`;
|
|
277
279
|
|
|
278
|
-
const
|
|
280
|
+
const SIZES = Object.freeze({
|
|
279
281
|
SMALL: "small",
|
|
280
282
|
REGULAR: "regular"
|
|
281
|
-
};
|
|
283
|
+
});
|
|
282
284
|
|
|
283
285
|
/**
|
|
284
286
|
* TODO:
|
|
@@ -328,7 +330,7 @@ const VALIDATION_MESSAGES = {
|
|
|
328
330
|
*
|
|
329
331
|
* @tagname leu-input
|
|
330
332
|
*/
|
|
331
|
-
class LeuInput extends
|
|
333
|
+
class LeuInput extends LeuElement {
|
|
332
334
|
static resolveErrorMessage(message, refernceValue) {
|
|
333
335
|
if (typeof message === "function") {
|
|
334
336
|
return message(refernceValue);
|
|
@@ -341,25 +343,29 @@ class LeuInput extends LitElement {
|
|
|
341
343
|
this.required = false;
|
|
342
344
|
this.clearable = false;
|
|
343
345
|
|
|
344
|
-
/** @type {
|
|
345
|
-
this.size =
|
|
346
|
+
/** @type {"small" | "regular"} */
|
|
347
|
+
this.size = SIZES.REGULAR;
|
|
346
348
|
this.type = "text";
|
|
347
349
|
this._validity = null;
|
|
348
350
|
this.validationMessages = {};
|
|
349
351
|
this.novalidate = false;
|
|
352
|
+
this.value = "";
|
|
350
353
|
|
|
351
354
|
/** @internal */
|
|
352
355
|
this._identifier = "";
|
|
353
356
|
|
|
354
|
-
/** @internal */
|
|
355
|
-
this._clearIcon = Icon("clear");
|
|
356
|
-
|
|
357
357
|
/**
|
|
358
358
|
* @internal
|
|
359
359
|
* @type {import("lit/directives/ref.js").Ref<HTMLInputElement>}
|
|
360
360
|
*/
|
|
361
361
|
this._inputRef = createRef();
|
|
362
362
|
}
|
|
363
|
+
get valueAsNumber() {
|
|
364
|
+
if (this.value === "") {
|
|
365
|
+
return NaN;
|
|
366
|
+
}
|
|
367
|
+
return Number(this.value);
|
|
368
|
+
}
|
|
363
369
|
|
|
364
370
|
/**
|
|
365
371
|
* Method for handling the click event of the wrapper element.
|
|
@@ -510,10 +516,7 @@ class LeuInput extends LitElement {
|
|
|
510
516
|
|
|
511
517
|
/**
|
|
512
518
|
* Creates an error list with an item for the given validity state.
|
|
513
|
-
* @
|
|
514
|
-
* @param {Object} validationMessages
|
|
515
|
-
* @param {String} idRef
|
|
516
|
-
* @returns
|
|
519
|
+
* @returns {import("lit").TemplateResult | nothing}
|
|
517
520
|
*/
|
|
518
521
|
renderErrorMessages() {
|
|
519
522
|
if (!this.isInvalid()) {
|
|
@@ -536,11 +539,13 @@ class LeuInput extends LitElement {
|
|
|
536
539
|
* This can be either an icon, a clear button or an error indicator icon.
|
|
537
540
|
*
|
|
538
541
|
* @private
|
|
539
|
-
* @returns {TemplateResult}
|
|
542
|
+
* @returns {import("lit").TemplateResult | nothing}
|
|
540
543
|
*/
|
|
541
544
|
renderAfterContent() {
|
|
542
545
|
if (this.isInvalid()) {
|
|
543
|
-
return html`<div class="error-icon"
|
|
546
|
+
return html`<div class="error-icon">
|
|
547
|
+
<leu-icon name="caution"></leu-icon>
|
|
548
|
+
</div>`;
|
|
544
549
|
}
|
|
545
550
|
if (this.clearable && this.value) {
|
|
546
551
|
return html`<button
|
|
@@ -549,11 +554,13 @@ class LeuInput extends LitElement {
|
|
|
549
554
|
aria-label="Eingabefeld zurücksetzen"
|
|
550
555
|
?disabled=${this.disabled}
|
|
551
556
|
>
|
|
552
|
-
|
|
557
|
+
<leu-icon name="clear"></leu-icon>
|
|
553
558
|
</button>`;
|
|
554
559
|
}
|
|
555
560
|
if (this.icon) {
|
|
556
|
-
return html`<div class="icon"
|
|
561
|
+
return html`<div class="icon">
|
|
562
|
+
<leu-icon name=${this.icon}></leu-icon>
|
|
563
|
+
</div>`;
|
|
557
564
|
}
|
|
558
565
|
return nothing;
|
|
559
566
|
}
|
|
@@ -608,12 +615,15 @@ class LeuInput extends LitElement {
|
|
|
608
615
|
`;
|
|
609
616
|
}
|
|
610
617
|
}
|
|
618
|
+
_defineProperty(LeuInput, "dependencies", {
|
|
619
|
+
"leu-icon": LeuIcon
|
|
620
|
+
});
|
|
611
621
|
_defineProperty(LeuInput, "styles", css_248z);
|
|
612
622
|
/**
|
|
613
623
|
* @internal
|
|
614
624
|
*/
|
|
615
625
|
_defineProperty(LeuInput, "shadowRootOptions", {
|
|
616
|
-
...
|
|
626
|
+
...LeuElement.shadowRootOptions,
|
|
617
627
|
delegatesFocus: true
|
|
618
628
|
});
|
|
619
629
|
_defineProperty(LeuInput, "properties", {
|
|
@@ -697,10 +707,9 @@ _defineProperty(LeuInput, "properties", {
|
|
|
697
707
|
type: String,
|
|
698
708
|
reflect: true
|
|
699
709
|
},
|
|
700
|
-
/** @type {ValidityState} */
|
|
701
710
|
_validity: {
|
|
702
711
|
state: true
|
|
703
712
|
}
|
|
704
713
|
});
|
|
705
714
|
|
|
706
|
-
export { LeuInput,
|
|
715
|
+
export { LeuInput, SIZES };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
declare class LeuElement extends LitElement {
|
|
2
|
+
static define(name: any, constructor?: typeof LeuElement, options?: {}): void;
|
|
3
|
+
}
|
|
4
|
+
declare function _defineProperty(obj: any, key: any, value: any): any;
|
|
5
|
+
import { LitElement } from 'lit';
|
|
6
|
+
export { LeuElement as L, _defineProperty as _ };
|
|
7
|
+
//# sourceMappingURL=LeuElement-ba5ea33d.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LeuElement-ba5ea33d.d.ts","sourceRoot":"","sources":["LeuElement-ba5ea33d.js"],"names":[],"mappings":"AA+BA;IACE,8EAMC;CAOF;AA3CD,sEAaC;2BAf0B,KAAK"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
|
|
1
3
|
function _defineProperty(obj, key, value) {
|
|
2
4
|
key = _toPropertyKey(key);
|
|
3
5
|
if (key in obj) {
|
|
@@ -27,4 +29,21 @@ function _toPropertyKey(arg) {
|
|
|
27
29
|
return typeof key === "symbol" ? key : String(key);
|
|
28
30
|
}
|
|
29
31
|
|
|
30
|
-
|
|
32
|
+
class LeuElement extends LitElement {
|
|
33
|
+
static define(name, constructor = this, options = {}) {
|
|
34
|
+
if (!customElements.get(name)) {
|
|
35
|
+
customElements.define(name, constructor, options);
|
|
36
|
+
} else {
|
|
37
|
+
console.info(`${name} is already defined`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
constructor() {
|
|
41
|
+
super();
|
|
42
|
+
Object.entries(this.constructor.dependencies).forEach(([name, component]) => {
|
|
43
|
+
this.constructor.define(name, component);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
_defineProperty(LeuElement, "dependencies", {});
|
|
48
|
+
|
|
49
|
+
export { LeuElement as L, _defineProperty as _ };
|
package/dist/Menu.d.ts
CHANGED
|
@@ -1,8 +1,30 @@
|
|
|
1
|
+
export type SelectsType = 'single' | 'multiple' | 'none';
|
|
2
|
+
/**
|
|
3
|
+
* @typedef {'single' | 'multiple' | 'none'} SelectsType
|
|
4
|
+
*/
|
|
1
5
|
/**
|
|
2
6
|
* @tagname leu-menu
|
|
7
|
+
* @property {SelectsType} selects - This has only an effect when the role is 'menu'. It defines which role the menu items will get. Default is 'none'.
|
|
3
8
|
*/
|
|
4
|
-
export class LeuMenu extends
|
|
9
|
+
export class LeuMenu extends LeuElement {
|
|
10
|
+
/** @type {SelectsType} */
|
|
11
|
+
selects: SelectsType;
|
|
12
|
+
value: any;
|
|
13
|
+
_handleSlotChange(): void;
|
|
14
|
+
_setMenuItemRoles(): void;
|
|
15
|
+
/**
|
|
16
|
+
*
|
|
17
|
+
* @returns {import("./MenuItem").LeuMenuItem[]}
|
|
18
|
+
*/
|
|
19
|
+
getMenuItems(): import("./MenuItem").LeuMenuItem[];
|
|
20
|
+
getVisibleMenuItems(): LeuMenuItem[];
|
|
21
|
+
_handleKeyDown(event: any): void;
|
|
22
|
+
setCurrentItem(index: any): any;
|
|
23
|
+
focusItem(index: any): void;
|
|
24
|
+
firstUpdated(): void;
|
|
25
|
+
updated(changedProperties: any): void;
|
|
5
26
|
render(): import("lit-html").TemplateResult<1>;
|
|
6
27
|
}
|
|
7
|
-
import {
|
|
28
|
+
import { L as LeuElement } from './LeuElement-ba5ea33d.js';
|
|
29
|
+
import { LeuMenuItem } from './MenuItem.js';
|
|
8
30
|
//# sourceMappingURL=Menu.d.ts.map
|
package/dist/Menu.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Menu.d.ts","sourceRoot":"","sources":["Menu.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Menu.d.ts","sourceRoot":"","sources":["Menu.js"],"names":[],"mappings":"0BA8Ba,QAAQ,GAAG,UAAU,GAAG,MAAM;AAD3C;;GAEG;AAEH;;;GAGG;AACH;IAII,0BAA0B;IAC1B,SADW,WAAW,CACD;IACrB,WAAsB;IAaxB,0BAGC;IACD,0BAmBC;IAED;;;OAGG;IACH,gBAFa,OAAO,YAAY,EAAE,WAAW,EAAE,CAO9C;IACD,qCAEC;IACD,iCAgBC;IACD,gCAaC;IACD,4BAGC;IACD,qBAEC;IACD,sCAIC;IACD,+CAEC;CACF;gCA5IqD,0BAA0B;4BAEpD,eAAe"}
|
package/dist/Menu.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import { _ as _defineProperty } from './
|
|
2
|
-
import { css,
|
|
1
|
+
import { _ as _defineProperty, L as LeuElement } from './LeuElement-ba5ea33d.js';
|
|
2
|
+
import { css, html } from 'lit';
|
|
3
|
+
import { LeuMenuItem } from './MenuItem.js';
|
|
4
|
+
import 'lit/directives/if-defined.js';
|
|
5
|
+
import './Icon.js';
|
|
3
6
|
|
|
4
7
|
var css_248z = css`:host,
|
|
5
8
|
:host * {
|
|
@@ -24,14 +27,128 @@ var css_248z = css`:host,
|
|
|
24
27
|
}
|
|
25
28
|
`;
|
|
26
29
|
|
|
30
|
+
/**
|
|
31
|
+
* @typedef {'single' | 'multiple' | 'none'} SelectsType
|
|
32
|
+
*/
|
|
33
|
+
|
|
27
34
|
/**
|
|
28
35
|
* @tagname leu-menu
|
|
36
|
+
* @property {SelectsType} selects - This has only an effect when the role is 'menu'. It defines which role the menu items will get. Default is 'none'.
|
|
29
37
|
*/
|
|
30
|
-
class LeuMenu extends
|
|
38
|
+
class LeuMenu extends LeuElement {
|
|
39
|
+
constructor() {
|
|
40
|
+
super();
|
|
41
|
+
|
|
42
|
+
/** @type {SelectsType} */
|
|
43
|
+
this.selects = "none";
|
|
44
|
+
this.value = undefined;
|
|
45
|
+
}
|
|
46
|
+
connectedCallback() {
|
|
47
|
+
super.connectedCallback();
|
|
48
|
+
if (!this.getAttribute("role")) {
|
|
49
|
+
this.setAttribute("role", "menu");
|
|
50
|
+
}
|
|
51
|
+
this.addEventListener("keydown", this._handleKeyDown);
|
|
52
|
+
}
|
|
53
|
+
disconnectedCallback() {
|
|
54
|
+
super.disconnectedCallback();
|
|
55
|
+
this.removeEventListener("keydown", this._handleKeyDown);
|
|
56
|
+
}
|
|
57
|
+
_handleSlotChange() {
|
|
58
|
+
this.setCurrentItem(0);
|
|
59
|
+
this._setMenuItemRoles();
|
|
60
|
+
}
|
|
61
|
+
_setMenuItemRoles() {
|
|
62
|
+
const menuRole = this.getAttribute("role");
|
|
63
|
+
let menuItemRole;
|
|
64
|
+
if (menuRole === "menu") {
|
|
65
|
+
if (this.selects === "multiple") {
|
|
66
|
+
menuItemRole = "menuitemcheckbox";
|
|
67
|
+
} else if (this.selects === "single") {
|
|
68
|
+
menuItemRole = "menuitemradio";
|
|
69
|
+
} else {
|
|
70
|
+
menuItemRole = "menuitem";
|
|
71
|
+
}
|
|
72
|
+
} else if (menuRole === "listbox") {
|
|
73
|
+
menuItemRole = "option";
|
|
74
|
+
}
|
|
75
|
+
if (menuItemRole) {
|
|
76
|
+
this.getMenuItems().forEach(menuItem => {
|
|
77
|
+
menuItem.componentRole = menuItemRole; // eslint-disable-line no-param-reassign
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
*
|
|
84
|
+
* @returns {import("./MenuItem").LeuMenuItem[]}
|
|
85
|
+
*/
|
|
86
|
+
getMenuItems() {
|
|
87
|
+
const slot = this.shadowRoot.querySelector("slot");
|
|
88
|
+
return slot.assignedElements({
|
|
89
|
+
flatten: true
|
|
90
|
+
}).filter(el => el instanceof LeuMenuItem);
|
|
91
|
+
}
|
|
92
|
+
getVisibleMenuItems() {
|
|
93
|
+
return this.getMenuItems().filter(menuItem => !menuItem.hidden);
|
|
94
|
+
}
|
|
95
|
+
_handleKeyDown(event) {
|
|
96
|
+
if (["ArrowDown", "ArrowUp", "Home", "End"].includes(event.key)) {
|
|
97
|
+
event.preventDefault();
|
|
98
|
+
const menuItems = this.getVisibleMenuItems();
|
|
99
|
+
let index = menuItems.findIndex(menuItem => menuItem.tabbable);
|
|
100
|
+
if (event.key === "ArrowDown") {
|
|
101
|
+
index += 1;
|
|
102
|
+
} else if (event.key === "ArrowUp") {
|
|
103
|
+
index -= 1;
|
|
104
|
+
} else if (event.key === "Home") {
|
|
105
|
+
index = 0;
|
|
106
|
+
} else if (event.key === "End") {
|
|
107
|
+
index = menuItems.length - 1;
|
|
108
|
+
}
|
|
109
|
+
this.focusItem(index);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
setCurrentItem(index) {
|
|
113
|
+
const menuItems = this.getVisibleMenuItems();
|
|
114
|
+
let currentItem = null;
|
|
115
|
+
const currentItemIndex = (index + menuItems.length) % menuItems.length;
|
|
116
|
+
menuItems.forEach((menuItem, i) => {
|
|
117
|
+
if (i === currentItemIndex) {
|
|
118
|
+
currentItem = menuItem;
|
|
119
|
+
menuItem.tabbable = true; // eslint-disable-line no-param-reassign
|
|
120
|
+
} else {
|
|
121
|
+
menuItem.tabbable = false; // eslint-disable-line no-param-reassign
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
return currentItem;
|
|
125
|
+
}
|
|
126
|
+
focusItem(index) {
|
|
127
|
+
const currentItem = this.setCurrentItem(index);
|
|
128
|
+
currentItem.focus();
|
|
129
|
+
}
|
|
130
|
+
firstUpdated() {
|
|
131
|
+
this.setCurrentItem(0);
|
|
132
|
+
}
|
|
133
|
+
updated(changedProperties) {
|
|
134
|
+
if (changedProperties.has("selects")) {
|
|
135
|
+
this._setMenuItemRoles();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
31
138
|
render() {
|
|
32
139
|
return html`<slot></slot>`;
|
|
33
140
|
}
|
|
34
141
|
}
|
|
35
142
|
_defineProperty(LeuMenu, "styles", css_248z);
|
|
143
|
+
_defineProperty(LeuMenu, "shadowRootOptions", {
|
|
144
|
+
...LeuElement.shadowRootOptions,
|
|
145
|
+
delegatesFocus: true
|
|
146
|
+
});
|
|
147
|
+
_defineProperty(LeuMenu, "properties", {
|
|
148
|
+
selects: {
|
|
149
|
+
type: String,
|
|
150
|
+
reflect: true
|
|
151
|
+
}
|
|
152
|
+
});
|
|
36
153
|
|
|
37
154
|
export { LeuMenu };
|
package/dist/MenuItem.d.ts
CHANGED
|
@@ -1,21 +1,38 @@
|
|
|
1
|
+
export type MenuItemRole = 'menuitem' | 'menuitemcheckbox' | 'menuitemradio' | 'option' | 'none';
|
|
2
|
+
/**
|
|
3
|
+
* @typedef {'menuitem' | 'menuitemcheckbox' | 'menuitemradio' | 'option' | 'none'} MenuItemRole
|
|
4
|
+
*/
|
|
1
5
|
/**
|
|
2
6
|
* @tagname leu-menu-item
|
|
3
7
|
* @slot - The label of the menu item
|
|
8
|
+
* @property {boolean} active - Defines if the item is selected or checked
|
|
9
|
+
* @property {boolean} disabled - Disables the underlying button or link
|
|
10
|
+
* @property {string} value - The value of the item. It must not contain commas. See `getValue()`
|
|
11
|
+
* @property {string} href - The href of the underlying link
|
|
12
|
+
* @property {boolean} tabbable - If the item should be focusable. Will be reflected as `tabindex` to the underlying button or link
|
|
13
|
+
* @property {MenuItemRole} componentRole - The role of the item. This will be reflected as `role` to the underlying button or link. Default is `'menuitem'.`
|
|
4
14
|
*/
|
|
5
|
-
export class LeuMenuItem extends
|
|
6
|
-
static getIconOrText(name: any): any;
|
|
15
|
+
export class LeuMenuItem extends LeuElement {
|
|
7
16
|
active: boolean;
|
|
8
17
|
disabled: boolean;
|
|
18
|
+
value: any;
|
|
19
|
+
href: any;
|
|
20
|
+
tabbable: any;
|
|
21
|
+
/** @type {MenuItemRole} */
|
|
22
|
+
componentRole: MenuItemRole;
|
|
23
|
+
_handleClick(event: any): void;
|
|
9
24
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
25
|
+
* Returns the value of the item. If `value` is not set, it will return the inner text
|
|
26
|
+
* @returns {string}
|
|
12
27
|
*/
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
28
|
+
getValue(): string;
|
|
29
|
+
_getAria(): {
|
|
30
|
+
disabled: boolean;
|
|
31
|
+
};
|
|
32
|
+
_getTabIndex(): 0 | -1;
|
|
33
|
+
_renderLink(content: any): import("lit-html").TemplateResult<1>;
|
|
34
|
+
_renderButton(content: any): import("lit-html").TemplateResult<1>;
|
|
35
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
18
36
|
}
|
|
19
|
-
import {
|
|
20
|
-
import { nothing } from 'lit';
|
|
37
|
+
import { L as LeuElement } from './LeuElement-ba5ea33d.js';
|
|
21
38
|
//# sourceMappingURL=MenuItem.d.ts.map
|
package/dist/MenuItem.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MenuItem.d.ts","sourceRoot":"","sources":["MenuItem.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MenuItem.d.ts","sourceRoot":"","sources":["MenuItem.js"],"names":[],"mappings":"2BA8Fa,UAAU,GAAG,kBAAkB,GAAG,eAAe,GAAG,QAAQ,GAAG,MAAM;AADlF;;GAEG;AAEH;;;;;;;;;GASG;AACH;IAGI,gBAAmB;IACnB,kBAAqB;IACrB,WAAsB;IACtB,UAAqB;IACrB,cAAyB;IAEzB,2BAA2B;IAC3B,eADW,YAAY,CACQ;IAUjC,+BAKC;IAED;;;OAGG;IACH,YAFa,MAAM,CAIlB;IACD;;MAaC;IACD,uBAKC;IACD,gEAYC;IACD,kEAYC;IACD,+CAOC;CACF;gCAnMqD,0BAA0B"}
|