@sbb-esta/lyne-elements 0.52.1 → 0.52.2
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/accordion.js +54 -54
- package/action-group.js +3 -3
- package/alert/alert-group.js +22 -22
- package/alert/alert.js +22 -22
- package/autocomplete.js +126 -126
- package/breadcrumb/breadcrumb-group.js +60 -60
- package/breadcrumb/breadcrumb.js +17 -17
- package/calendar.js +423 -423
- package/card/card-badge.js +17 -17
- package/card/card.js +2 -2
- package/card/common.js +30 -30
- package/checkbox/checkbox-group.js +17 -17
- package/checkbox/checkbox.js +34 -34
- package/clock.js +83 -83
- package/container/sticky-bar.js +16 -16
- package/core/a11y.js +91 -91
- package/core/base-elements.js +86 -86
- package/core/controllers.js +40 -40
- package/core/datetime.js +32 -32
- package/core/dom.js +26 -26
- package/core/eventing.js +33 -33
- package/core/mixins.js +122 -122
- package/core/testing.js +29 -29
- package/datepicker/common.js +55 -55
- package/datepicker/datepicker-toggle.js +94 -94
- package/datepicker/datepicker.js +144 -144
- package/dialog/dialog-title.js +20 -20
- package/dialog/dialog.js +66 -66
- package/expansion-panel/expansion-panel-header.js +20 -20
- package/expansion-panel/expansion-panel.js +60 -60
- package/file-selector.js +91 -91
- package/form-field/form-field-clear.js +12 -12
- package/form-field/form-field.js +111 -111
- package/header/header.js +53 -53
- package/icon.js +107 -107
- package/image.js +87 -87
- package/journey-header.js +29 -29
- package/map-container.js +23 -23
- package/menu/menu.js +91 -91
- package/navigation/common.js +16 -16
- package/navigation/navigation-marker.js +34 -34
- package/navigation/navigation-section.js +83 -83
- package/navigation/navigation.js +87 -87
- package/notification.js +52 -52
- package/option/optgroup.js +45 -45
- package/option/option.js +108 -108
- package/overlay.js +5 -5
- package/package.json +1 -1
- package/popover/popover.js +110 -110
- package/radio-button/radio-button-group.js +93 -93
- package/radio-button/radio-button.js +84 -84
- package/select.js +178 -178
- package/selection-panel.js +44 -44
- package/slider.js +58 -58
- package/status.js +6 -6
- package/stepper/step-label.js +19 -19
- package/stepper/step.js +31 -31
- package/stepper/stepper.js +46 -46
- package/tabs/tab-group.js +67 -67
- package/tag/tag-group.js +8 -8
- package/tag/tag.js +27 -27
- package/teaser-paid.js +12 -12
- package/time-input.js +73 -73
- package/timetable-occupancy-icon.js +26 -26
- package/timetable-occupancy.js +9 -9
- package/toast.js +38 -38
- package/toggle/toggle-option.js +33 -33
- package/toggle/toggle.js +46 -46
- package/train/train-formation.js +36 -36
- package/train/train-wagon.js +30 -30
- package/train/train.js +13 -13
package/menu/menu.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { css as v, html as l } from "lit";
|
|
2
|
-
import { property as
|
|
3
|
-
import { ref as
|
|
4
|
-
import { SbbFocusHandler as
|
|
5
|
-
import { SbbOpenCloseBaseElement as
|
|
6
|
-
import { SbbConnectedAbortController as
|
|
7
|
-
import { SbbScrollHandler as
|
|
8
|
-
import { SbbNamedSlotListMixin as
|
|
9
|
-
import { isEventOnElement as
|
|
2
|
+
import { property as g, customElement as p } from "lit/decorators.js";
|
|
3
|
+
import { ref as _ } from "lit/directives/ref.js";
|
|
4
|
+
import { SbbFocusHandler as f, isArrowKeyPressed as w, interactivityChecker as E, getNextElementIndex as x, setModalityOnNextFocus as c, IS_FOCUSABLE_QUERY as y } from "../core/a11y.js";
|
|
5
|
+
import { SbbOpenCloseBaseElement as k } from "../core/base-elements.js";
|
|
6
|
+
import { SbbConnectedAbortController as C } from "../core/controllers.js";
|
|
7
|
+
import { SbbScrollHandler as L, isBreakpoint as d, findReferencedElement as O } from "../core/dom.js";
|
|
8
|
+
import { SbbNamedSlotListMixin as N } from "../core/mixins.js";
|
|
9
|
+
import { isEventOnElement as h, applyInertMechanism as m, removeInertMechanism as u, removeAriaOverlayTriggerAttributes as S, setAriaOverlayTriggerAttributes as B, getElementPosition as A } from "../core/overlay.js";
|
|
10
10
|
const T = v`*,:before,:after{box-sizing:border-box}:host{--sbb-menu-position-x: 0;--sbb-menu-position-y: 0;--sbb-menu-animation-duration: var( --sbb-disable-animation-zero-time, var(--sbb-animation-duration-6x) );--sbb-menu-animation-easing: ease;--sbb-menu-transform: translateY(100%);--sbb-menu-max-width: 100%;--sbb-menu-min-width: 100%;--sbb-menu-inset: 0 auto auto 0;--sbb-menu-container-height: 100vh;--sbb-menu-max-height: calc(85vh - var(--sbb-spacing-fixed-8x));--sbb-menu-min-height: 3.03125rem;--sbb-menu-border-radius: var(--sbb-border-radius-4x);--sbb-menu-visibility: hidden;--sbb-menu-backdrop-color: transparent;display:contents}@supports (height: 100dvh){:host{--sbb-menu-container-height: 100dvh}}@media (min-width: 52.5rem){:host{--sbb-menu-transform: translateY(var(--sbb-spacing-fixed-2x));--sbb-menu-max-width: 20rem;--sbb-menu-min-width: 11.25rem}}:host(:is([data-state=opened],[data-state=opening])){--sbb-menu-visibility: visible;--sbb-menu-backdrop-color: var(--sbb-color-black-alpha-20)}@media (min-width: 52.5rem){:host(:is([data-state=opened],[data-state=opening])){--sbb-menu-backdrop-color: transparent}}:host(:not([data-state=closed])){--sbb-menu-inset: 0}::slotted(:not(sbb-menu-button,sbb-menu-link,sbb-divider)){display:block;padding-inline:var(--sbb-spacing-fixed-5x)}::slotted(sbb-divider){--sbb-divider-color: var(--sbb-color-iron);margin-block:var(--sbb-spacing-fixed-2x)}.sbb-menu__container{position:fixed;pointer-events:none;inset:var(--sbb-menu-inset);height:var(--sbb-menu-container-height);z-index:var(--sbb-menu-z-index, var(--sbb-overlay-default-z-index))}.sbb-menu__container:before{content:"";visibility:var(--sbb-menu-visibility);pointer-events:all;position:fixed;inset:var(--sbb-menu-inset);height:var(--sbb-menu-container-height);background-color:var(--sbb-menu-backdrop-color);transition-duration:var(--sbb-menu-animation-duration);transition-timing-function:var(--sbb-menu-animation-easing);transition-property:background-color,visibility}.sbb-menu{display:none;opacity:0;pointer-events:none;max-width:var(--sbb-menu-max-width);min-width:var(--sbb-menu-min-width);text-align:start;position:absolute;inset-inline-start:0;inset-block-start:unset;inset-block-end:0;inset-inline-end:unset;color:var(--sbb-color-white);border:none;border-radius:var(--sbb-menu-border-radius) var(--sbb-menu-border-radius) 0 0;background-color:var(--sbb-color-black);padding:0;overflow:hidden}:host([data-state]:not([data-state=closed])) .sbb-menu{display:block;opacity:1;pointer-events:all;animation-name:open;animation-duration:var(--sbb-menu-animation-duration);animation-timing-function:var(--sbb-menu-animation-easing)}:host([data-state][data-state=closing]) .sbb-menu{pointer-events:none;animation-name:close}@media (forced-colors: active){.sbb-menu{outline:var(--sbb-border-width-1x) solid CanvasText}}@media (min-width: 52.5rem){.sbb-menu{top:0;bottom:unset;left:0;right:unset;max-height:fit-content;border-radius:var(--sbb-menu-border-radius)}:host(:not([data-state=closed])) .sbb-menu{top:var(--sbb-menu-position-y);left:var(--sbb-menu-position-x);max-height:var(--sbb-menu-max-height);min-height:var(--sbb-menu-min-height)}}.sbb-menu__content{--sbb-scrollbar-thumb-width: .125rem;--sbb-scrollbar-thumb-width-hover: .25rem;--sbb-scrollbar-width-firefox: thin;--sbb-scrollbar-color: var(--sbb-color-white-alpha-30);--sbb-scrollbar-color-hover: var(--sbb-color-white-alpha-60);--sbb-scrollbar-track-color: transparent;--sbb-scrollbar-width: var(--sbb-spacing-fixed-3x);max-height:var(--sbb-menu-max-height);padding-block:var(--sbb-spacing-fixed-1x);overflow:auto;outline:none}.sbb-menu__content::-webkit-scrollbar{width:var(--sbb-scrollbar-width);height:var(--sbb-scrollbar-width);background-color:var(--sbb-scrollbar-track-color, transparent)}.sbb-menu__content::-webkit-scrollbar-corner{background-color:var(--sbb-scrollbar-track-color, transparent)}.sbb-menu__content::-webkit-scrollbar-thumb{background-color:var(--sbb-scrollbar-color, currentcolor);border:calc(.5 * (var(--sbb-scrollbar-width) - var(--sbb-scrollbar-thumb-width))) solid transparent;border-radius:var(--sbb-border-radius-4x);background-clip:padding-box}.sbb-menu__content::-webkit-scrollbar-thumb:hover{background-color:var(--sbb-scrollbar-color-hover, currentcolor);border-width:calc(.5 * (var(--sbb-scrollbar-width) - var(--sbb-scrollbar-thumb-width-hover)))}.sbb-menu__content::-webkit-scrollbar-button,.sbb-menu__content::-webkit-scrollbar-corner{display:none}@supports not selector(::-webkit-scrollbar){.sbb-menu__content{scrollbar-width:var(--sbb-scrollbar-width-firefox);scrollbar-color:var(--sbb-scrollbar-color, currentcolor) var(--sbb-scrollbar-track-color, transparent)}}.sbb-menu__content:after{content:"";display:block;height:var(--sbb-spacing-fixed-8x)}@media (min-width: 52.5rem){.sbb-menu__content{max-height:fit-content}:host(:not([data-state=closed])) .sbb-menu__content{max-height:var(--sbb-menu-max-height);min-height:var(--sbb-menu-min-height)}.sbb-menu__content:after{display:none}}.sbb-menu-list{list-style:none;margin:0;padding:0;font-size:inherit}@keyframes open{0%{opacity:0;transform:var(--sbb-menu-transform)}to{opacity:1;transform:translateY(0)}}@keyframes close{0%{opacity:1;transform:translateY(0)}to{opacity:0;transform:var(--sbb-menu-transform)}}`;
|
|
11
|
-
var
|
|
12
|
-
for (var i =
|
|
13
|
-
(a =
|
|
14
|
-
return
|
|
11
|
+
var M = Object.defineProperty, P = Object.getOwnPropertyDescriptor, b = (e, t, n, s) => {
|
|
12
|
+
for (var i = s > 1 ? void 0 : s ? P(t, n) : t, o = e.length - 1, a; o >= 0; o--)
|
|
13
|
+
(a = e[o]) && (i = (s ? a(t, n, i) : a(i)) || i);
|
|
14
|
+
return s && i && M(t, n, i), i;
|
|
15
15
|
};
|
|
16
|
-
const
|
|
16
|
+
const I = 8, K = [
|
|
17
17
|
"A",
|
|
18
18
|
"BUTTON",
|
|
19
19
|
"SBB-BUTTON",
|
|
@@ -23,153 +23,153 @@ const K = 8, U = [
|
|
|
23
23
|
"SBB-LINK-BUTTON",
|
|
24
24
|
"SBB-BLOCK-LINK-BUTTON"
|
|
25
25
|
];
|
|
26
|
-
let
|
|
26
|
+
let D = 0, r = class extends N(k) {
|
|
27
27
|
constructor() {
|
|
28
|
-
super(...arguments), this.listChildLocalNames = ["sbb-menu-button", "sbb-menu-link"], this.
|
|
29
|
-
this.
|
|
30
|
-
}, this.
|
|
31
|
-
!this.
|
|
28
|
+
super(...arguments), this.listChildLocalNames = ["sbb-menu-button", "sbb-menu-link"], this._trigger = null, this._triggerElement = null, this._isPointerDownEventOnMenu = !1, this._abort = new C(this), this._focusHandler = new f(), this._scrollHandler = new L(), this._pointerDownListener = (e) => {
|
|
29
|
+
this._isPointerDownEventOnMenu = h(this._menu, e);
|
|
30
|
+
}, this._closeOnBackdropClick = (e) => {
|
|
31
|
+
!this._isPointerDownEventOnMenu && !h(this._menu, e) && this.close();
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
|
-
set trigger(
|
|
35
|
-
const
|
|
36
|
-
this.
|
|
34
|
+
set trigger(e) {
|
|
35
|
+
const t = this._trigger;
|
|
36
|
+
this._trigger = e, this._removeTriggerClickListener(this._trigger, t);
|
|
37
37
|
}
|
|
38
38
|
get trigger() {
|
|
39
|
-
return this.
|
|
39
|
+
return this._trigger;
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
42
|
* Opens the menu on trigger click.
|
|
43
43
|
*/
|
|
44
44
|
open() {
|
|
45
|
-
var
|
|
46
|
-
this.state === "closing" || !this.
|
|
45
|
+
var e;
|
|
46
|
+
this.state === "closing" || !this._menu || this.willOpen.emit() && (this.state = "opening", this._setMenuPosition(), (e = this._triggerElement) == null || e.setAttribute("aria-expanded", "true"), d("medium") || this._scrollHandler.disableScroll());
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
49
|
* Closes the menu.
|
|
50
50
|
*/
|
|
51
51
|
close() {
|
|
52
|
-
var
|
|
53
|
-
this.state !== "opening" && this.willClose.emit() && (this.state = "closing", (
|
|
52
|
+
var e;
|
|
53
|
+
this.state !== "opening" && this.willClose.emit() && (this.state = "closing", (e = this._triggerElement) == null || e.setAttribute("aria-expanded", "false"));
|
|
54
54
|
}
|
|
55
55
|
/**
|
|
56
56
|
* Handles click and checks if its target is a sbb-menu-button/sbb-menu-link.
|
|
57
57
|
*/
|
|
58
|
-
|
|
59
|
-
const
|
|
60
|
-
((
|
|
58
|
+
_onClick(e) {
|
|
59
|
+
const t = e.target;
|
|
60
|
+
((t == null ? void 0 : t.localName) === "sbb-menu-button" || (t == null ? void 0 : t.localName) === "sbb-menu-link") && this.close();
|
|
61
61
|
}
|
|
62
|
-
|
|
63
|
-
if (!
|
|
62
|
+
_handleKeyDown(e) {
|
|
63
|
+
if (!w(e))
|
|
64
64
|
return;
|
|
65
|
-
|
|
66
|
-
const
|
|
65
|
+
e.preventDefault();
|
|
66
|
+
const t = Array.from(
|
|
67
67
|
this.querySelectorAll(
|
|
68
68
|
"sbb-menu-button, sbb-menu-link"
|
|
69
69
|
)
|
|
70
70
|
).filter(
|
|
71
|
-
(i) => !i.disabled &&
|
|
72
|
-
),
|
|
73
|
-
|
|
71
|
+
(i) => !i.disabled && E.isVisible(i)
|
|
72
|
+
), n = t.findIndex((i) => i === e.target), s = x(e, n, t.length);
|
|
73
|
+
t[s].focus();
|
|
74
74
|
}
|
|
75
75
|
// Closes the menu on "Esc" key pressed and traps focus within the menu.
|
|
76
|
-
async
|
|
77
|
-
if (this.state === "opened" &&
|
|
76
|
+
async _onKeydownEvent(e) {
|
|
77
|
+
if (this.state === "opened" && e.key === "Escape") {
|
|
78
78
|
this.close();
|
|
79
79
|
return;
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
// Removes trigger click listener on trigger change.
|
|
83
|
-
|
|
84
|
-
var
|
|
85
|
-
|
|
83
|
+
_removeTriggerClickListener(e, t) {
|
|
84
|
+
var n, s;
|
|
85
|
+
e !== t && ((n = this._menuController) == null || n.abort(), (s = this._windowEventsController) == null || s.abort(), this._configure(this.trigger));
|
|
86
86
|
}
|
|
87
87
|
connectedCallback() {
|
|
88
|
-
var
|
|
88
|
+
var t;
|
|
89
89
|
super.connectedCallback();
|
|
90
|
-
const
|
|
91
|
-
this.addEventListener("click", (
|
|
92
|
-
signal:
|
|
90
|
+
const e = this._abort.signal;
|
|
91
|
+
this.addEventListener("click", (n) => this._onClick(n), { signal: e }), this.addEventListener("keydown", (n) => this._handleKeyDown(n), { signal: e }), (t = this.shadowRoot) == null || t.addEventListener("slotchange", (n) => this._checkListCase(n), {
|
|
92
|
+
signal: e,
|
|
93
93
|
capture: !0
|
|
94
|
-
}), this.
|
|
94
|
+
}), this._configure(this.trigger), this.state === "opened" && m(this);
|
|
95
95
|
}
|
|
96
96
|
disconnectedCallback() {
|
|
97
|
-
var
|
|
98
|
-
super.disconnectedCallback(), (
|
|
97
|
+
var e, t;
|
|
98
|
+
super.disconnectedCallback(), (e = this._menuController) == null || e.abort(), (t = this._windowEventsController) == null || t.abort(), this._focusHandler.disconnect(), u();
|
|
99
99
|
}
|
|
100
|
-
|
|
101
|
-
var
|
|
102
|
-
(
|
|
103
|
-
(
|
|
104
|
-
) || (
|
|
100
|
+
_checkListCase(e) {
|
|
101
|
+
var t;
|
|
102
|
+
(t = this.children) != null && t.length && Array.from(this.children ?? []).every(
|
|
103
|
+
(n) => n.localName === "sbb-menu-button" || n.localName === "sbb-menu-link"
|
|
104
|
+
) || (e.stopImmediatePropagation(), this.listChildren.length && (this.listChildren.forEach((n) => n.removeAttribute("slot")), this.listChildren = []));
|
|
105
105
|
}
|
|
106
106
|
// Check if the trigger is valid and attach click event listeners.
|
|
107
|
-
|
|
108
|
-
var
|
|
109
|
-
|
|
110
|
-
signal: this.
|
|
107
|
+
_configure(e) {
|
|
108
|
+
var t;
|
|
109
|
+
S(this._triggerElement), e && (this._triggerElement = O(e), this._triggerElement && (this.id = this.id || `sbb-menu-${D++}`, B(this._triggerElement, "menu", this.id, this.state), (t = this._menuController) == null || t.abort(), this._menuController = new AbortController(), this._triggerElement.addEventListener("click", () => this.open(), {
|
|
110
|
+
signal: this._menuController.signal
|
|
111
111
|
})));
|
|
112
112
|
}
|
|
113
|
-
|
|
114
|
-
this.
|
|
113
|
+
_attachWindowEvents() {
|
|
114
|
+
this._windowEventsController = new AbortController(), document.addEventListener("scroll", () => this._setMenuPosition(), {
|
|
115
115
|
passive: !0,
|
|
116
|
-
signal: this.
|
|
117
|
-
}), window.addEventListener("resize", () => this.
|
|
116
|
+
signal: this._windowEventsController.signal
|
|
117
|
+
}), window.addEventListener("resize", () => this._setMenuPosition(), {
|
|
118
118
|
passive: !0,
|
|
119
|
-
signal: this.
|
|
120
|
-
}), window.addEventListener("keydown", (
|
|
121
|
-
signal: this.
|
|
122
|
-
}), window.addEventListener("pointerdown", this.
|
|
123
|
-
signal: this.
|
|
124
|
-
}), window.addEventListener("pointerup", this.
|
|
125
|
-
signal: this.
|
|
119
|
+
signal: this._windowEventsController.signal
|
|
120
|
+
}), window.addEventListener("keydown", (e) => this._onKeydownEvent(e), {
|
|
121
|
+
signal: this._windowEventsController.signal
|
|
122
|
+
}), window.addEventListener("pointerdown", this._pointerDownListener, {
|
|
123
|
+
signal: this._windowEventsController.signal
|
|
124
|
+
}), window.addEventListener("pointerup", this._closeOnBackdropClick, {
|
|
125
|
+
signal: this._windowEventsController.signal
|
|
126
126
|
});
|
|
127
127
|
}
|
|
128
128
|
// Close menu at any click on an interactive element inside the <sbb-menu> that bubbles to the container.
|
|
129
|
-
|
|
130
|
-
const
|
|
131
|
-
|
|
129
|
+
_closeOnInteractiveElementClick(e) {
|
|
130
|
+
const t = e.target;
|
|
131
|
+
K.includes(t.nodeName) && !t.hasAttribute("disabled") && this.close();
|
|
132
132
|
}
|
|
133
133
|
// Set menu position (x, y) to '0' once the menu is closed and the transition ended to prevent the
|
|
134
134
|
// viewport from overflowing. And set the focus to the first focusable element once the menu is open.
|
|
135
135
|
// In rare cases it can be that the animationEnd event is triggered twice.
|
|
136
136
|
// To avoid entering a corrupt state, exit when state is not expected.
|
|
137
|
-
|
|
138
|
-
var
|
|
139
|
-
|
|
137
|
+
_onMenuAnimationEnd(e) {
|
|
138
|
+
var t, n, s, i;
|
|
139
|
+
e.animationName === "open" && this.state === "opening" ? (this.state = "opened", this.didOpen.emit(), m(this), this._setMenuFocus(), this._focusHandler.trap(this), this._attachWindowEvents()) : e.animationName === "close" && this.state === "closing" && (this.state = "closed", (n = (t = this._menu) == null ? void 0 : t.firstElementChild) == null || n.scrollTo(0, 0), u(), c(this._triggerElement), (s = this._triggerElement) == null || s.focus({
|
|
140
140
|
// When inside the sbb-header, we prevent the scroll to avoid the snapping to the top of the page
|
|
141
|
-
preventScroll: this.
|
|
142
|
-
}), this.didClose.emit(), (i = this.
|
|
141
|
+
preventScroll: this._triggerElement.localName === "sbb-header-button" || this._triggerElement.localName === "sbb-header-link"
|
|
142
|
+
}), this.didClose.emit(), (i = this._windowEventsController) == null || i.abort(), this._focusHandler.disconnect(), this._scrollHandler.enableScroll());
|
|
143
143
|
}
|
|
144
144
|
// Set focus on the first focusable element.
|
|
145
|
-
|
|
146
|
-
const
|
|
147
|
-
c(
|
|
145
|
+
_setMenuFocus() {
|
|
146
|
+
const e = this.querySelector(y);
|
|
147
|
+
c(e), e.focus();
|
|
148
148
|
}
|
|
149
149
|
// Set menu position and max height if the breakpoint is medium-ultra.
|
|
150
|
-
|
|
151
|
-
if (!
|
|
150
|
+
_setMenuPosition() {
|
|
151
|
+
if (!d("medium") || !this._menu || !this._triggerElement || this.state === "closing")
|
|
152
152
|
return;
|
|
153
|
-
const
|
|
153
|
+
const e = A(
|
|
154
154
|
this.shadowRoot.querySelector(".sbb-menu__content"),
|
|
155
|
-
this.
|
|
155
|
+
this._triggerElement,
|
|
156
156
|
this.shadowRoot.querySelector(".sbb-menu__container"),
|
|
157
157
|
{
|
|
158
|
-
verticalOffset:
|
|
158
|
+
verticalOffset: I
|
|
159
159
|
}
|
|
160
160
|
);
|
|
161
|
-
this.style.setProperty("--sbb-menu-position-x", `${
|
|
161
|
+
this.style.setProperty("--sbb-menu-position-x", `${e.left}px`), this.style.setProperty("--sbb-menu-position-y", `${e.top}px`), this.style.setProperty("--sbb-menu-max-height", e.maxHeight);
|
|
162
162
|
}
|
|
163
163
|
render() {
|
|
164
164
|
return l`
|
|
165
165
|
<div class="sbb-menu__container">
|
|
166
166
|
<div
|
|
167
|
-
@animationend=${(
|
|
167
|
+
@animationend=${(e) => this._onMenuAnimationEnd(e)}
|
|
168
168
|
class="sbb-menu"
|
|
169
|
-
${
|
|
169
|
+
${_((e) => this._menu = e)}
|
|
170
170
|
>
|
|
171
171
|
<div
|
|
172
|
-
@click=${(
|
|
172
|
+
@click=${(e) => this._closeOnInteractiveElementClick(e)}
|
|
173
173
|
class="sbb-menu__content"
|
|
174
174
|
>
|
|
175
175
|
${this.listChildren.length ? this.renderList({ class: "sbb-menu-list", ariaLabel: this.listAccessibilityLabel }) : l`<slot></slot>`}
|
|
@@ -181,13 +181,13 @@ let z = 0, r = class extends L(E) {
|
|
|
181
181
|
};
|
|
182
182
|
r.styles = T;
|
|
183
183
|
b([
|
|
184
|
-
|
|
184
|
+
g()
|
|
185
185
|
], r.prototype, "trigger", 1);
|
|
186
186
|
b([
|
|
187
|
-
|
|
187
|
+
g({ attribute: "list-accessibility-label" })
|
|
188
188
|
], r.prototype, "listAccessibilityLabel", 2);
|
|
189
189
|
r = b([
|
|
190
|
-
|
|
190
|
+
p("sbb-menu")
|
|
191
191
|
], r);
|
|
192
192
|
export {
|
|
193
193
|
r as SbbMenuElement
|
package/navigation/common.js
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import { property as
|
|
1
|
+
import { property as e } from "lit/decorators.js";
|
|
2
2
|
import { html as b } from "lit/static-html.js";
|
|
3
3
|
import { SbbConnectedAbortController as r } from "../core/controllers.js";
|
|
4
4
|
import { css as l } from "lit";
|
|
5
5
|
import "../icon.js";
|
|
6
6
|
const c = l`*,:before,:after{box-sizing:border-box}:host{--sbb-navigation-action-color: var(--sbb-color-cloud);--sbb-navigation-action-icon-display: none;display:block;outline:none!important}:host([data-section-action][data-action-active].sbb-active){--sbb-navigation-action-icon-display: block}:host([data-action-active]){--sbb-navigation-action-color: var(--sbb-color-storm)}@media (forced-colors: active){:host([data-action-active]){--sbb-navigation-action-color: Highlight}}sbb-icon{display:var(--sbb-navigation-action-icon-display);position:absolute;inset-inline-start:calc((var(--sbb-size-icon-ui-small) + var(--sbb-spacing-fixed-1x)) * -1);inset-block-start:calc(1em * var(--sbb-typo-line-height-body-text) / 2);transform:translateY(-50%)}@media (any-hover: hover){:host(:hover){--sbb-navigation-action-color: var(--sbb-color-storm)}}@media (forced-colors: active){:host([role=button]){--sbb-navigation-action-color: ButtonText}}:is(.sbb-navigation-button,.sbb-navigation-link){--sbb-title-line-height: var(--sbb-typo-line-height-titles);--sbb-title-margin-block-start: 0;--sbb-title-margin-block-end: 0;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;margin:0;margin-block:var(--sbb-title-margin-block-start) var(--sbb-title-margin-block-end);font-family:var(--sbb-typo-font-family);font-weight:700;line-height:var(--sbb-title-line-height);letter-spacing:var(--sbb-typo-letter-spacing-titles);font-size:var(--sbb-title-font-size);--sbb-title-font-size: var(--sbb-font-size-title-4);cursor:pointer;position:relative;text-decoration:none;display:flex;-webkit-user-select:none;user-select:none;-webkit-tap-highlight-color:transparent;transition:color var(--sbb-disable-animation-zero-time, var(--sbb-animation-duration-3x)) ease;-webkit-hyphens:auto;hyphens:auto;text-align:left;color:var(--sbb-navigation-action-color);outline:none}@media (forced-colors: active){:is(.sbb-navigation-button,.sbb-navigation-link){transition:none}}:host([size=m]) :is(.sbb-navigation-button,.sbb-navigation-link){--sbb-text-font-size: var(--sbb-font-size-text-s);font-family:var(--sbb-typo-font-family);font-weight:400;line-height:var(--sbb-typo-line-height-body-text);letter-spacing:var(--sbb-typo-letter-spacing-body-text);font-size:var(--sbb-text-font-size);font-weight:700}:host([size=s]) :is(.sbb-navigation-button,.sbb-navigation-link){--sbb-text-font-size: var(--sbb-font-size-text-xxs);font-family:var(--sbb-typo-font-family);font-weight:400;line-height:var(--sbb-typo-line-height-body-text);letter-spacing:var(--sbb-typo-letter-spacing-body-text);font-size:var(--sbb-text-font-size);font-weight:700}:host(:focus-visible:not([data-focus-origin=mouse],[data-focus-origin=touch])) :is(.sbb-navigation-button,.sbb-navigation-link),:host(:not([data-focus-origin=mouse],[data-focus-origin=touch])) :is(.sbb-navigation-button,.sbb-navigation-link):focus-visible{outline-offset:var(--sbb-focus-outline-offset);outline:var(--sbb-focus-outline-color) solid var(--sbb-focus-outline-width);border-radius:calc(var(--sbb-border-radius-4x) - var(--sbb-focus-outline-offset))}`;
|
|
7
|
-
var
|
|
8
|
-
for (var t = void 0,
|
|
9
|
-
(
|
|
10
|
-
return t &&
|
|
7
|
+
var v = Object.defineProperty, g = (a, i, o, h) => {
|
|
8
|
+
for (var t = void 0, n = a.length - 1, s; n >= 0; n--)
|
|
9
|
+
(s = a[n]) && (t = s(i, o, t) || t);
|
|
10
|
+
return t && v(i, o, t), t;
|
|
11
11
|
};
|
|
12
|
-
const y = (
|
|
13
|
-
const o = class o extends
|
|
12
|
+
const y = (a) => {
|
|
13
|
+
const o = class o extends a {
|
|
14
14
|
constructor() {
|
|
15
|
-
super(...arguments), this.size = "l", this.
|
|
15
|
+
super(...arguments), this.size = "l", this._abort = new r(this), this._navigationMarker = null, this._navigationSection = null;
|
|
16
16
|
}
|
|
17
17
|
/** The navigation marker in which the action is nested. */
|
|
18
18
|
get marker() {
|
|
19
|
-
return this.
|
|
19
|
+
return this._navigationMarker;
|
|
20
20
|
}
|
|
21
21
|
/** The section in which the action is nested. */
|
|
22
22
|
get section() {
|
|
23
|
-
return this.
|
|
23
|
+
return this._navigationSection;
|
|
24
24
|
}
|
|
25
25
|
connectedCallback() {
|
|
26
26
|
super.connectedCallback();
|
|
27
|
-
const t = this.
|
|
27
|
+
const t = this._abort.signal;
|
|
28
28
|
this.addEventListener(
|
|
29
29
|
"click",
|
|
30
30
|
() => {
|
|
31
|
-
var
|
|
32
|
-
!this.hasAttribute("data-action-active") && this.
|
|
31
|
+
var n;
|
|
32
|
+
!this.hasAttribute("data-action-active") && this._navigationMarker && !this.connectedSection && ((n = this.marker) == null || n.select(
|
|
33
33
|
this
|
|
34
34
|
));
|
|
35
35
|
},
|
|
36
36
|
{ signal: t }
|
|
37
|
-
), this.
|
|
37
|
+
), this._navigationMarker = this.closest("sbb-navigation-marker"), this._navigationSection = this.closest("sbb-navigation-section"), this.toggleAttribute("data-section-action", !!this._navigationSection);
|
|
38
38
|
}
|
|
39
39
|
renderTemplate() {
|
|
40
40
|
return b`<sbb-icon name="dash-small"></sbb-icon> <slot></slot>`;
|
|
@@ -42,8 +42,8 @@ const y = (n) => {
|
|
|
42
42
|
};
|
|
43
43
|
o.styles = c;
|
|
44
44
|
let i = o;
|
|
45
|
-
return
|
|
46
|
-
|
|
45
|
+
return g([
|
|
46
|
+
e({ reflect: !0 })
|
|
47
47
|
], i.prototype, "size"), i;
|
|
48
48
|
};
|
|
49
49
|
export {
|
|
@@ -1,77 +1,77 @@
|
|
|
1
|
-
import { css as
|
|
2
|
-
import { property as
|
|
1
|
+
import { css as c, LitElement as l } from "lit";
|
|
2
|
+
import { property as v, state as g, customElement as h } from "lit/decorators.js";
|
|
3
3
|
import { SbbNamedSlotListMixin as d } from "../core/mixins.js";
|
|
4
|
-
import { AgnosticResizeObserver as
|
|
5
|
-
const
|
|
6
|
-
var f = Object.defineProperty, k = Object.getOwnPropertyDescriptor, b = (t, i, n,
|
|
7
|
-
for (var
|
|
8
|
-
(o = t[
|
|
9
|
-
return
|
|
4
|
+
import { AgnosticResizeObserver as p } from "../core/observers.js";
|
|
5
|
+
const m = c`*,:before,:after{box-sizing:border-box}:host{--sbb-navigation-action-gap: var(--sbb-spacing-responsive-xs);--sbb-navigation-marker-position-x: var(--sbb-spacing-fixed-1x);--sbb-navigation-marker-position-y: unset;--sbb-navigation-marker-width: 1.0625rem;--sbb-navigation-marker-border: var(--sbb-border-width-1x);--sbb-navigation-marker-padding-inline-start: var(--sbb-spacing-fixed-6x);--sbb-navigation-marker-typo-line-height: var(--sbb-typo-line-height-titles);--sbb-navigation-margin-inline-start: var(--sbb-spacing-fixed-3x);--sbb-navigation-marker-margin-block: calc( 1em * var(--sbb-navigation-marker-typo-line-height) / 2 - var(--sbb-navigation-marker-border) / 2 );display:block}:host([size=s]){--sbb-navigation-action-gap: var(--sbb-spacing-fixed-2x);--sbb-navigation-marker-width: .5rem;--sbb-navigation-marker-typo-line-height: var(--sbb-typo-line-height-body-text);--sbb-navigation-margin-inline-start: var(--sbb-spacing-fixed-2x);--sbb-navigation-marker-position-x: calc( var(--sbb-navigation-marker-padding-inline-start) - var(--sbb-spacing-fixed-2x) );--sbb-navigation-marker-padding-inline-start: calc( var(--sbb-spacing-fixed-6x) + var(--sbb-spacing-fixed-1x) )}.sbb-navigation-marker{list-style:none;padding:0;font-size:inherit;--sbb-title-line-height: var(--sbb-typo-line-height-titles);--sbb-title-margin-block-start: 0;--sbb-title-margin-block-end: 0;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;margin:0;margin-block:var(--sbb-title-margin-block-start) var(--sbb-title-margin-block-end);font-family:var(--sbb-typo-font-family);font-weight:700;line-height:var(--sbb-title-line-height);letter-spacing:var(--sbb-typo-letter-spacing-titles);font-size:var(--sbb-title-font-size);--sbb-title-font-size: var(--sbb-font-size-title-4);position:relative;display:flex;flex-direction:column;align-items:flex-start;gap:var(--sbb-navigation-action-gap);padding-inline-start:var(--sbb-navigation-marker-padding-inline-start)}.sbb-navigation-marker:before{content:"";position:absolute;opacity:0;inset-inline-start:var(--sbb-navigation-marker-position-x);inset-block-start:var(--sbb-navigation-marker-position-y);width:var(--sbb-navigation-marker-width);border-block-start:var(--sbb-navigation-marker-border) solid var(--sbb-color-storm);margin-block:var(--sbb-navigation-marker-margin-block);transition-duration:var(--sbb-disable-animation-zero-time, var(--sbb-animation-duration-6x));transition-timing-function:ease;transition-property:opacity,inset-block-start}:host([data-has-active-action]) .sbb-navigation-marker:before{opacity:1}@media (forced-colors: active){.sbb-navigation-marker:before{border-color:CanvasText}}:host([size=s]) .sbb-navigation-marker{--sbb-text-font-size: var(--sbb-font-size-text-xxs);font-family:var(--sbb-typo-font-family);font-weight:400;line-height:var(--sbb-typo-line-height-body-text);letter-spacing:var(--sbb-typo-letter-spacing-body-text);font-size:var(--sbb-text-font-size);font-weight:700}::slotted(:is(sbb-navigation-button,sbb-navigation-link)){margin-inline-start:var(--sbb-navigation-margin-inline-start)}`;
|
|
6
|
+
var f = Object.defineProperty, k = Object.getOwnPropertyDescriptor, b = (t, i, n, e) => {
|
|
7
|
+
for (var a = e > 1 ? void 0 : e ? k(i, n) : i, s = t.length - 1, o; s >= 0; s--)
|
|
8
|
+
(o = t[s]) && (a = (e ? o(i, n, a) : o(a)) || a);
|
|
9
|
+
return e && a && f(i, n, a), a;
|
|
10
10
|
};
|
|
11
|
-
let
|
|
11
|
+
let r = class extends d(l) {
|
|
12
12
|
constructor() {
|
|
13
13
|
super(...arguments), this.listChildLocalNames = [
|
|
14
14
|
"sbb-navigation-button",
|
|
15
15
|
"sbb-navigation-link"
|
|
16
|
-
], this.size = "l", this.
|
|
17
|
-
() => this.
|
|
16
|
+
], this.size = "l", this._navigationMarkerResizeObserver = new p(
|
|
17
|
+
() => this._setMarkerPosition()
|
|
18
18
|
);
|
|
19
19
|
}
|
|
20
20
|
willUpdate(t) {
|
|
21
|
-
super.willUpdate(t), (t.has("size") || t.has("listChildren")) && this.
|
|
21
|
+
super.willUpdate(t), (t.has("size") || t.has("listChildren")) && this._updateMarkerActions(), this.toggleAttribute("data-has-active-action", !!this._currentActiveAction);
|
|
22
22
|
}
|
|
23
|
-
|
|
23
|
+
_updateMarkerActions() {
|
|
24
24
|
for (const t of this.listChildren)
|
|
25
25
|
t.size = this.size;
|
|
26
|
-
this.
|
|
26
|
+
this._currentActiveAction = this.listChildren.find(
|
|
27
27
|
(t) => t.hasAttribute("data-action-active")
|
|
28
|
-
), this.
|
|
28
|
+
), this._setMarkerPosition();
|
|
29
29
|
}
|
|
30
30
|
connectedCallback() {
|
|
31
|
-
super.connectedCallback(), this.
|
|
31
|
+
super.connectedCallback(), this._navigationMarkerResizeObserver.observe(this), this._checkActiveAction();
|
|
32
32
|
}
|
|
33
|
-
|
|
33
|
+
_checkActiveAction() {
|
|
34
34
|
const t = this.querySelector(
|
|
35
35
|
":is(sbb-navigation-button, sbb-navigation-link).sbb-active"
|
|
36
36
|
);
|
|
37
37
|
t && this.select(t);
|
|
38
38
|
}
|
|
39
39
|
disconnectedCallback() {
|
|
40
|
-
super.disconnectedCallback(), this.
|
|
40
|
+
super.disconnectedCallback(), this._navigationMarkerResizeObserver.disconnect();
|
|
41
41
|
}
|
|
42
42
|
select(t) {
|
|
43
|
-
t && (this.reset(), t.toggleAttribute("data-action-active", !0), this.
|
|
43
|
+
t && (this.reset(), t.toggleAttribute("data-action-active", !0), this._currentActiveAction = t, setTimeout(() => this._setMarkerPosition()));
|
|
44
44
|
}
|
|
45
45
|
firstUpdated(t) {
|
|
46
|
-
super.firstUpdated(t), setTimeout(() => this.
|
|
46
|
+
super.firstUpdated(t), setTimeout(() => this._setMarkerPosition());
|
|
47
47
|
}
|
|
48
48
|
reset() {
|
|
49
49
|
var t;
|
|
50
|
-
this.
|
|
50
|
+
this._currentActiveAction && (this._currentActiveAction.removeAttribute("data-action-active"), (t = this._currentActiveAction.connectedSection) == null || t.close(), this._currentActiveAction = void 0);
|
|
51
51
|
}
|
|
52
|
-
|
|
53
|
-
var n,
|
|
54
|
-
if (!this.
|
|
52
|
+
_setMarkerPosition() {
|
|
53
|
+
var n, e;
|
|
54
|
+
if (!this._currentActiveAction)
|
|
55
55
|
return;
|
|
56
|
-
const t = this.listChildren.indexOf(this.
|
|
56
|
+
const t = this.listChildren.indexOf(this._currentActiveAction), i = (n = this.shadowRoot.querySelector(
|
|
57
57
|
`li:nth-child(${t + 1})`
|
|
58
58
|
)) == null ? void 0 : n.offsetTop;
|
|
59
|
-
i != null && ((
|
|
59
|
+
i != null && ((e = this.style) == null || e.setProperty("--sbb-navigation-marker-position-y", `${i}px`));
|
|
60
60
|
}
|
|
61
61
|
render() {
|
|
62
62
|
return this.renderList();
|
|
63
63
|
}
|
|
64
64
|
};
|
|
65
|
-
|
|
65
|
+
r.styles = m;
|
|
66
66
|
b([
|
|
67
|
-
|
|
68
|
-
],
|
|
67
|
+
v({ reflect: !0 })
|
|
68
|
+
], r.prototype, "size", 2);
|
|
69
69
|
b([
|
|
70
|
-
|
|
71
|
-
],
|
|
72
|
-
|
|
70
|
+
g()
|
|
71
|
+
], r.prototype, "_currentActiveAction", 2);
|
|
72
|
+
r = b([
|
|
73
73
|
h("sbb-navigation-marker")
|
|
74
|
-
],
|
|
74
|
+
], r);
|
|
75
75
|
export {
|
|
76
|
-
|
|
76
|
+
r as SbbNavigationMarkerElement
|
|
77
77
|
};
|