@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/header/header.js
CHANGED
|
@@ -1,59 +1,59 @@
|
|
|
1
1
|
import { css as h, LitElement as c, isServer as b, html as f } from "lit";
|
|
2
|
-
import { property as
|
|
2
|
+
import { property as d, state as u, customElement as v } from "lit/decorators.js";
|
|
3
3
|
import { SbbFocusVisibleWithinController as m } from "../core/a11y.js";
|
|
4
4
|
import { findReferencedElement as p } from "../core/dom.js";
|
|
5
5
|
import { SbbHydrationMixin as g } from "../core/mixins.js";
|
|
6
6
|
import "../logo.js";
|
|
7
|
-
const
|
|
8
|
-
var
|
|
9
|
-
for (var
|
|
10
|
-
(
|
|
11
|
-
return
|
|
7
|
+
const _ = h`*,:before,:after{box-sizing:border-box}:host{--sbb-logo-height: 1rem;--sbb-header-position: fixed;--sbb-header-transition-duration: var( --sbb-disable-animation-zero-time, var(--sbb-animation-duration-6x) );--sbb-header-inset-inline-end: 0;display:block;height:var(--sbb-header-height)}@media (min-width: 52.5rem){:host{--sbb-logo-height: 1.25rem}}:host([hide-on-scroll]){--sbb-header-position: absolute}:host([hide-on-scroll][data-fixed]){--sbb-header-position: fixed;--sbb-header-animation-name: hide;--sbb-header-transform: translate3d(0, -100%, 0);--sbb-header-inset-inline-end: var(--sbb-scrollbar-width, 0)}:host([hide-on-scroll][data-fixed][data-animated]){--sbb-header-transition-timing: cubic-bezier(.4, 0, 1, 1)}:host([hide-on-scroll][data-fixed][data-visible]){--sbb-header-animation-name: show;--sbb-header-transform: translate3d(0, 0, 0);--sbb-header-transition-timing: cubic-bezier(0, 0, .2, 1)}:host([hide-on-scroll][data-fixed][data-has-visible-focus-within]){--sbb-header-transition-duration: 0;--sbb-header-transform: translate3d(0, 0, 0)}.sbb-header{position:var(--sbb-header-position);inset:0 var(--sbb-header-inset-inline-end) auto 0;background:var(--sbb-color-white);z-index:var(--sbb-header-z-index, 10);transform:var(--sbb-header-transform);transition-property:box-shadow;transition-duration:var(--sbb-header-transition-duration);transition-timing-function:var(--sbb-header-transition-timing);animation-name:var(--sbb-header-animation-name);animation-duration:var(--sbb-header-transition-duration);animation-timing-function:var(--sbb-header-transition-timing)}:host(:is([data-shadow],[data-has-visible-focus-within][data-fixed])) .sbb-header{box-shadow:var(--sbb-shadow-elevation-level-9-shadow-2-offset-x) var(--sbb-shadow-elevation-level-9-shadow-2-offset-y) var(--sbb-shadow-elevation-level-9-shadow-2-blur) var(--sbb-shadow-elevation-level-9-shadow-2-spread) var(--sbb-shadow-elevation-level-9-soft-2-color),var(--sbb-shadow-elevation-level-9-shadow-1-offset-x) var(--sbb-shadow-elevation-level-9-shadow-1-offset-y) var(--sbb-shadow-elevation-level-9-shadow-1-blur) var(--sbb-shadow-elevation-level-9-shadow-1-spread) var(--sbb-shadow-elevation-level-9-soft-1-color)}@media (forced-colors: active){.sbb-header{border-block-end:var(--sbb-border-width-1x) solid CanvasText}}.sbb-header__wrapper{display:flex;align-items:center;justify-content:flex-start;height:var(--sbb-header-height)}:host(:not([expanded])) .sbb-header__wrapper{padding-inline:var(--sbb-layout-base-offset-responsive);margin-inline:auto;width:100%}@media (min-width: 90rem){:host(:not([expanded])) .sbb-header__wrapper{max-width:calc(var(--sbb-layout-base-page-max-width) + 2 * var(--sbb-layout-base-offset-responsive))}}:host([expanded]) .sbb-header__wrapper{padding-inline:var(--sbb-spacing-responsive-xxs)}.sbb-header__logo{flex:0 0 auto;margin-inline-start:auto;padding-inline-start:var(--sbb-spacing-responsive-s)}::slotted(:is(sbb-header-button,sbb-header-link):first-child){margin-inline-start:var(--sbb-header-first-item-margin-inline-start)}::slotted(*){flex:0 0 auto}::slotted(.sbb-header-shrinkable){flex-shrink:1;min-width:0}::slotted(.sbb-header-spacer){flex-grow:1}::slotted(a[slot=logo]){display:block;padding-block:var(--sbb-spacing-fixed-3x);position:relative;outline:none!important}::slotted(a[slot=logo]):before{content:"";display:block;position:absolute;inset:var(--sbb-spacing-fixed-3x) 0}::slotted(a[slot=logo]:focus-visible:not([data-focus-origin=mouse],[data-focus-origin=touch])):before{outline-offset:var(--sbb-focus-outline-offset);outline:var(--sbb-focus-outline-color) solid var(--sbb-focus-outline-width);outline-offset:var(--sbb-spacing-fixed-3x);border-radius:1px}@keyframes show{0%{transform:translate3d(0,-100%,0)}to{transform:translateZ(0)}}@keyframes hide{0%{transform:translateZ(0)}to{transform:translate3d(0,-100%,0)}}`;
|
|
8
|
+
var w = Object.defineProperty, x = Object.getOwnPropertyDescriptor, a = (e, t, s, r) => {
|
|
9
|
+
for (var o = r > 1 ? void 0 : r ? x(t, s) : t, l = e.length - 1, n; l >= 0; l--)
|
|
10
|
+
(n = e[l]) && (o = (r ? n(t, s, o) : n(o)) || o);
|
|
11
|
+
return r && o && w(t, s, o), o;
|
|
12
12
|
};
|
|
13
|
-
const
|
|
14
|
-
let
|
|
13
|
+
const y = "[aria-controls][aria-expanded='true']";
|
|
14
|
+
let i = class extends g(c) {
|
|
15
15
|
constructor() {
|
|
16
|
-
super(...arguments), this.expanded = !1, this.
|
|
16
|
+
super(...arguments), this.expanded = !1, this._scrollOrigin = b ? null : document, this.hideOnScroll = !1, this._headerOnTop = !0, this._lastScroll = 0;
|
|
17
17
|
}
|
|
18
18
|
set scrollOrigin(e) {
|
|
19
|
-
const t = this.
|
|
20
|
-
this.
|
|
19
|
+
const t = this._scrollOrigin;
|
|
20
|
+
this._scrollOrigin = e, this._updateScrollOrigin(this._scrollOrigin, t);
|
|
21
21
|
}
|
|
22
22
|
get scrollOrigin() {
|
|
23
|
-
return this.
|
|
23
|
+
return this._scrollOrigin;
|
|
24
24
|
}
|
|
25
|
-
|
|
25
|
+
_updateScrollOrigin(e, t) {
|
|
26
26
|
if (e !== t) {
|
|
27
|
-
this.
|
|
28
|
-
const s = this.
|
|
29
|
-
this.
|
|
27
|
+
this._setListenerOnScrollElement(e);
|
|
28
|
+
const s = this._getCurrentScrollProperty("scrollTop");
|
|
29
|
+
this._lastScroll = s <= 0 ? 0 : s;
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
/** If `hideOnScroll` is set, checks the element to hook the listener on, and possibly add it.*/
|
|
33
33
|
connectedCallback() {
|
|
34
|
-
super.connectedCallback(), this.
|
|
34
|
+
super.connectedCallback(), this._setListenerOnScrollElement(this.scrollOrigin), new m(this);
|
|
35
35
|
}
|
|
36
36
|
/** Removes the scroll listener, if previously attached. */
|
|
37
37
|
disconnectedCallback() {
|
|
38
38
|
var e;
|
|
39
|
-
super.disconnectedCallback(), (e = this.
|
|
39
|
+
super.disconnectedCallback(), (e = this._scrollEventsController) == null || e.abort();
|
|
40
40
|
}
|
|
41
41
|
/** Sets the value of `_scrollElement` and `_scrollFunction` and possibly adds the function on the correct element. */
|
|
42
|
-
|
|
42
|
+
_setListenerOnScrollElement(e) {
|
|
43
43
|
var t, s;
|
|
44
|
-
(t = this.
|
|
44
|
+
(t = this._scrollEventsController) == null || t.abort(), this._scrollEventsController = new AbortController(), this._scrollElement = p(e) || (b ? null : document), this._scrollFunction = this._getScrollFunction.bind(this), (s = this._scrollElement) == null || s.addEventListener("scroll", this._scrollFunction, {
|
|
45
45
|
passive: !0,
|
|
46
|
-
signal: this.
|
|
46
|
+
signal: this._scrollEventsController.signal
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
49
|
/** Returns the correct function to attach on scroll. */
|
|
50
|
-
|
|
51
|
-
return this.hideOnScroll ? this.
|
|
50
|
+
_getScrollFunction() {
|
|
51
|
+
return this.hideOnScroll ? this._scrollListener() : this._scrollShadowListener();
|
|
52
52
|
}
|
|
53
53
|
/** Returns the requested property of the scrollContext. */
|
|
54
|
-
|
|
54
|
+
_getCurrentScrollProperty(e) {
|
|
55
55
|
var t;
|
|
56
|
-
return this.
|
|
56
|
+
return this._scrollElement instanceof Document ? this._scrollElement.documentElement[e] || this._scrollElement.body[e] : ((t = this._scrollElement) == null ? void 0 : t[e]) || 0;
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
59
59
|
* Sets the correct value for `scrollTop`, then:
|
|
@@ -61,27 +61,27 @@ let o = class extends g(c) {
|
|
|
61
61
|
* - hides the header, remove the shadow and possibly close any open menu on the header if it is not visible anymore;
|
|
62
62
|
* - shows the header and re-apply the shadow if the element/document has been scrolled up.
|
|
63
63
|
*/
|
|
64
|
-
|
|
65
|
-
const e = this.
|
|
66
|
-
this.
|
|
64
|
+
_scrollListener() {
|
|
65
|
+
const e = this._getCurrentScrollProperty("scrollTop");
|
|
66
|
+
this._getCurrentScrollProperty("scrollHeight") - window.innerHeight - e <= 0 || (this.toggleAttribute("data-shadow", e !== 0), e > this.offsetHeight && e > 0 && this._lastScroll < e && this._closeOpenOverlays(), e > this.offsetHeight * 2 ? (this._headerOnTop = !1, e > 0 && this._lastScroll < e ? ["data-shadow", "data-visible"].forEach((t) => this.removeAttribute(t)) : ["data-fixed", "data-shadow", "data-animated", "data-visible"].forEach(
|
|
67
67
|
(t) => this.toggleAttribute(t, !0)
|
|
68
|
-
)) : (e === 0 && (this.
|
|
68
|
+
)) : (e === 0 && (this._headerOnTop = !0), this._headerOnTop && ["data-shadow", "data-animated", "data-fixed", "data-visible"].forEach(
|
|
69
69
|
(t) => this.removeAttribute(t)
|
|
70
|
-
)), this.
|
|
70
|
+
)), this._lastScroll = e <= 0 ? 0 : e);
|
|
71
71
|
}
|
|
72
72
|
/** Apply the shadow if the element/document has been scrolled down. */
|
|
73
|
-
|
|
74
|
-
this.toggleAttribute("data-shadow", this.
|
|
73
|
+
_scrollShadowListener() {
|
|
74
|
+
this.toggleAttribute("data-shadow", this._getCurrentScrollProperty("scrollTop") !== 0);
|
|
75
75
|
}
|
|
76
|
-
|
|
76
|
+
_closeOpenOverlays() {
|
|
77
77
|
if (this.hasAttribute("data-has-visible-focus-within"))
|
|
78
78
|
return;
|
|
79
79
|
const e = Array.from(
|
|
80
|
-
this.querySelectorAll(
|
|
80
|
+
this.querySelectorAll(y)
|
|
81
81
|
);
|
|
82
82
|
for (const t of e) {
|
|
83
|
-
const s = t.getAttribute("aria-controls"),
|
|
84
|
-
typeof (
|
|
83
|
+
const s = t.getAttribute("aria-controls"), r = document.getElementById(s);
|
|
84
|
+
typeof (r == null ? void 0 : r.close) == "function" && r.close();
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
render() {
|
|
@@ -99,22 +99,22 @@ let o = class extends g(c) {
|
|
|
99
99
|
`;
|
|
100
100
|
}
|
|
101
101
|
};
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
],
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
],
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
],
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
],
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
],
|
|
102
|
+
i.styles = _;
|
|
103
|
+
a([
|
|
104
|
+
d({ reflect: !0, type: Boolean })
|
|
105
|
+
], i.prototype, "expanded", 2);
|
|
106
|
+
a([
|
|
107
|
+
d({ attribute: "scroll-origin" })
|
|
108
|
+
], i.prototype, "scrollOrigin", 1);
|
|
109
|
+
a([
|
|
110
|
+
d({ attribute: "hide-on-scroll", reflect: !0, type: Boolean })
|
|
111
|
+
], i.prototype, "hideOnScroll", 2);
|
|
112
|
+
a([
|
|
113
|
+
u()
|
|
114
|
+
], i.prototype, "_headerOnTop", 2);
|
|
115
|
+
i = a([
|
|
116
|
+
v("sbb-header")
|
|
117
|
+
], i);
|
|
118
118
|
export {
|
|
119
|
-
|
|
119
|
+
i as SbbHeaderElement
|
|
120
120
|
};
|
package/icon.js
CHANGED
|
@@ -1,174 +1,174 @@
|
|
|
1
|
-
import { state as g, property as
|
|
2
|
-
import { css as
|
|
3
|
-
import { unsafeHTML as
|
|
1
|
+
import { state as g, property as h, customElement as y } from "lit/decorators.js";
|
|
2
|
+
import { css as N, LitElement as I, html as u, nothing as b } from "lit";
|
|
3
|
+
import { unsafeHTML as $ } from "lit/directives/unsafe-html.js";
|
|
4
4
|
import { until as A } from "lit/directives/until.js";
|
|
5
|
-
import { hostAttributes as
|
|
6
|
-
import { readConfig as
|
|
7
|
-
const
|
|
8
|
-
if (
|
|
9
|
-
if (
|
|
5
|
+
import { hostAttributes as S } from "./core/decorators.js";
|
|
6
|
+
import { readConfig as L } from "./core/config.js";
|
|
7
|
+
const E = (e) => typeof e == "string", _ = (e) => {
|
|
8
|
+
if (e.nodeType === 1) {
|
|
9
|
+
if (e.nodeName.toLowerCase() === "script")
|
|
10
10
|
return !1;
|
|
11
|
-
for (let
|
|
12
|
-
const o =
|
|
13
|
-
if (
|
|
11
|
+
for (let t = 0; t < e.attributes.length; t++) {
|
|
12
|
+
const o = e.attributes[t].name;
|
|
13
|
+
if (E(o) && o.toLowerCase().indexOf("on") === 0)
|
|
14
14
|
return !1;
|
|
15
15
|
}
|
|
16
|
-
for (let
|
|
17
|
-
if (!
|
|
16
|
+
for (let t = 0; t < e.childNodes.length; t++)
|
|
17
|
+
if (!_(e.childNodes[t]))
|
|
18
18
|
return !1;
|
|
19
19
|
}
|
|
20
20
|
return !0;
|
|
21
|
-
}, P = (
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
for (let i =
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
return
|
|
28
|
-
}, m = "https://icons.app.sbb.ch/", C = (/* @__PURE__ */ new Map()).set("default", `${m}icons/`).set("picto", `${m}picto/`), v = /* @__PURE__ */ new Map(), O = (
|
|
29
|
-
var
|
|
30
|
-
const
|
|
31
|
-
if (
|
|
21
|
+
}, P = (e, t = !0, o = !1) => {
|
|
22
|
+
const r = document.createElement("div");
|
|
23
|
+
r.innerHTML = e;
|
|
24
|
+
for (let i = r.childNodes.length - 1; i >= 0; i--)
|
|
25
|
+
r.childNodes[i].nodeName.toLowerCase() !== "svg" && r.removeChild(r.childNodes[i]);
|
|
26
|
+
const s = r.firstElementChild;
|
|
27
|
+
return s && s.nodeName.toLowerCase() === "svg" && (o && !s.classList.contains("color-immutable") && s.classList.add("color-immutable"), t === !1 || _(s)) ? r.innerHTML : "";
|
|
28
|
+
}, m = "https://icons.app.sbb.ch/", C = (/* @__PURE__ */ new Map()).set("default", `${m}icons/`).set("picto", `${m}picto/`), v = /* @__PURE__ */ new Map(), O = (e, t, o) => {
|
|
29
|
+
var p;
|
|
30
|
+
const r = L().icon ?? {}, s = ((p = r.namespaces) == null ? void 0 : p.get(e)) ?? C.get(e);
|
|
31
|
+
if (s === void 0)
|
|
32
32
|
throw Error(
|
|
33
|
-
`Unable to find the namespace "${
|
|
33
|
+
`Unable to find the namespace "${e}". Please register your custom namespace.`
|
|
34
34
|
);
|
|
35
|
-
const i = `${
|
|
36
|
-
let
|
|
37
|
-
if (!
|
|
35
|
+
const i = `${s}${t}.svg`;
|
|
36
|
+
let a = v.get(i);
|
|
37
|
+
if (!a)
|
|
38
38
|
if (typeof fetch < "u" && typeof document < "u")
|
|
39
|
-
|
|
40
|
-
namespace:
|
|
41
|
-
name:
|
|
39
|
+
a = (r.interceptor ?? ((l) => l.request()))({
|
|
40
|
+
namespace: e,
|
|
41
|
+
name: t,
|
|
42
42
|
url: i,
|
|
43
43
|
request: () => fetch(i).then((l) => {
|
|
44
44
|
if (l.ok)
|
|
45
45
|
return l.text().then((c) => (c && (c = P(c, o)), c));
|
|
46
|
-
throw new Error("Failed to load icon " +
|
|
46
|
+
throw new Error("Failed to load icon " + e + ":" + t);
|
|
47
47
|
}).catch((l) => {
|
|
48
48
|
throw Error(l);
|
|
49
49
|
})
|
|
50
|
-
}), v.set(i,
|
|
50
|
+
}), v.set(i, a);
|
|
51
51
|
else
|
|
52
52
|
return Promise.resolve("");
|
|
53
|
-
return
|
|
54
|
-
}, x =
|
|
55
|
-
var z = Object.defineProperty, M = Object.getOwnPropertyDescriptor,
|
|
56
|
-
for (var
|
|
57
|
-
(
|
|
58
|
-
return
|
|
53
|
+
return a;
|
|
54
|
+
}, x = N`*,:before,:after{box-sizing:border-box}:host{display:inline-block;line-height:0;-webkit-tap-highlight-color:transparent}:host([data-empty]){--sbb-icon-default-dimension: 0}:host([data-empty][data-namespace=default][name$=-small]){--sbb-icon-default-dimension: var(--sbb-size-icon-ui-small)}:host([data-empty][data-namespace=default][name$=-medium]){--sbb-icon-default-dimension: var(--sbb-size-icon-ui-medium)}:host([data-empty][data-namespace=default][name$=-large]){--sbb-icon-default-dimension: var(--sbb-size-icon-ui-large)}svg{width:var(--sbb-icon-svg-width, var(--sbb-icon-default-dimension));height:var(--sbb-icon-svg-height, var(--sbb-icon-default-dimension));stroke:var(--sbb-icon-svg-stroke-color);stroke-width:var(--sbb-icon-svg-stroke-width)}svg:not(.color-immutable) [fill]:not([fill=none]){fill:currentcolor}svg:not(.color-immutable) [stroke]:not([stroke=none]){stroke:currentcolor}svg:not(.color-immutable)>:where(path,polygon,polyline):where(:not([stroke]):not([fill])),svg:not(.color-immutable) :where(:not([stroke]):not([fill])) :where(path,polygon,polyline):where(:not([stroke]):not([fill])){fill:currentcolor}`;
|
|
55
|
+
var z = Object.defineProperty, M = Object.getOwnPropertyDescriptor, d = (e, t, o, r) => {
|
|
56
|
+
for (var s = r > 1 ? void 0 : r ? M(t, o) : t, i = e.length - 1, a; i >= 0; i--)
|
|
57
|
+
(a = e[i]) && (s = (r ? a(t, o, s) : a(s)) || s);
|
|
58
|
+
return r && s && z(t, o, s), s;
|
|
59
59
|
};
|
|
60
|
-
let
|
|
60
|
+
let n = class extends I {
|
|
61
61
|
constructor() {
|
|
62
|
-
super(...arguments), this.
|
|
62
|
+
super(...arguments), this._svgNamespace = n._defaultNamespace, this.noSanitize = !1;
|
|
63
63
|
}
|
|
64
|
-
async loadSvgIcon(
|
|
65
|
-
if (!
|
|
64
|
+
async loadSvgIcon(e) {
|
|
65
|
+
if (!e)
|
|
66
66
|
return;
|
|
67
|
-
const [
|
|
68
|
-
this.
|
|
69
|
-
const
|
|
70
|
-
this.
|
|
67
|
+
const [t, o] = this._splitIconName(e);
|
|
68
|
+
this._svgNamespace = t, this.setAttribute("data-namespace", this._svgNamespace);
|
|
69
|
+
const r = this.fetchSvgIcon(this._svgNamespace, o);
|
|
70
|
+
this._svgIcon = r.then((s) => $(s));
|
|
71
71
|
try {
|
|
72
|
-
this.toggleAttribute("data-empty", !await
|
|
72
|
+
this.toggleAttribute("data-empty", !await r);
|
|
73
73
|
} catch {
|
|
74
74
|
this.toggleAttribute("data-empty", !0);
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
|
-
async fetchSvgIcon(
|
|
78
|
-
return await O(
|
|
77
|
+
async fetchSvgIcon(e, t) {
|
|
78
|
+
return await O(e, t, !this.noSanitize);
|
|
79
79
|
}
|
|
80
|
-
|
|
81
|
-
if (!
|
|
80
|
+
_splitIconName(e) {
|
|
81
|
+
if (!e)
|
|
82
82
|
return ["", ""];
|
|
83
|
-
const
|
|
84
|
-
switch (
|
|
83
|
+
const t = e.split(":");
|
|
84
|
+
switch (t.length) {
|
|
85
85
|
case 1:
|
|
86
|
-
return [
|
|
86
|
+
return [n._defaultNamespace, t[0]];
|
|
87
87
|
case 2:
|
|
88
|
-
return
|
|
88
|
+
return t;
|
|
89
89
|
default:
|
|
90
|
-
throw Error(`Invalid icon name: "${
|
|
90
|
+
throw Error(`Invalid icon name: "${e}"`);
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
|
-
firstUpdated(
|
|
94
|
-
super.firstUpdated(
|
|
93
|
+
firstUpdated(e) {
|
|
94
|
+
super.firstUpdated(e), this.setAttribute("role", this.getAttribute("role") ?? "img");
|
|
95
95
|
}
|
|
96
96
|
render() {
|
|
97
|
-
return
|
|
97
|
+
return u`<span class="sbb-icon-inner"
|
|
98
98
|
>${A(
|
|
99
|
-
this.
|
|
99
|
+
this._svgIcon,
|
|
100
100
|
// To reserve space, we need an empty svg to apply dimension to.
|
|
101
|
-
|
|
101
|
+
u`<svg width="0" height="0"></svg>`
|
|
102
102
|
)}</span
|
|
103
103
|
>`;
|
|
104
104
|
}
|
|
105
105
|
};
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
106
|
+
n.styles = x;
|
|
107
|
+
n._defaultNamespace = "default";
|
|
108
|
+
d([
|
|
109
109
|
g()
|
|
110
|
-
],
|
|
111
|
-
|
|
110
|
+
], n.prototype, "_svgNamespace", 2);
|
|
111
|
+
d([
|
|
112
112
|
g()
|
|
113
|
-
],
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
],
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
"data-namespace":
|
|
113
|
+
], n.prototype, "_svgIcon", 2);
|
|
114
|
+
d([
|
|
115
|
+
h({ attribute: "no-sanitize", type: Boolean })
|
|
116
|
+
], n.prototype, "noSanitize", 2);
|
|
117
|
+
n = d([
|
|
118
|
+
S({
|
|
119
|
+
"data-namespace": n._defaultNamespace,
|
|
120
120
|
"data-empty": ""
|
|
121
121
|
})
|
|
122
|
-
],
|
|
123
|
-
var U = Object.defineProperty, j = Object.getOwnPropertyDescriptor,
|
|
124
|
-
for (var
|
|
125
|
-
(
|
|
126
|
-
return
|
|
122
|
+
], n);
|
|
123
|
+
var U = Object.defineProperty, j = Object.getOwnPropertyDescriptor, w = (e, t, o, r) => {
|
|
124
|
+
for (var s = r > 1 ? void 0 : r ? j(t, o) : t, i = e.length - 1, a; i >= 0; i--)
|
|
125
|
+
(a = e[i]) && (s = (r ? a(t, o, s) : a(s)) || s);
|
|
126
|
+
return r && s && U(t, o, s), s;
|
|
127
127
|
};
|
|
128
|
-
let
|
|
128
|
+
let f = class extends n {
|
|
129
129
|
constructor() {
|
|
130
|
-
super(...arguments), this.
|
|
130
|
+
super(...arguments), this._defaultAriaLabel = "";
|
|
131
131
|
}
|
|
132
|
-
async fetchSvgIcon(
|
|
133
|
-
return this.getAttribute("aria-label") === this.
|
|
132
|
+
async fetchSvgIcon(e, t) {
|
|
133
|
+
return this.getAttribute("aria-label") === this._defaultAriaLabel && this.removeAttribute("aria-label"), this._defaultAriaLabel = `Icon ${t.replace(/-/g, " ")}`, this.getAttribute("aria-hidden") === "false" && !this.hasAttribute("aria-label") && t && this.setAttribute("aria-label", this._defaultAriaLabel), super.fetchSvgIcon(e, t);
|
|
134
134
|
}
|
|
135
|
-
willUpdate(
|
|
136
|
-
super.willUpdate(
|
|
135
|
+
willUpdate(e) {
|
|
136
|
+
super.willUpdate(e), e.has("name") && this.loadSvgIcon(this.name);
|
|
137
137
|
}
|
|
138
|
-
firstUpdated(
|
|
139
|
-
super.firstUpdated(
|
|
138
|
+
firstUpdated(e) {
|
|
139
|
+
super.firstUpdated(e), this.hasAttribute("aria-hidden") || this.setAttribute("aria-hidden", "true");
|
|
140
140
|
}
|
|
141
141
|
};
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
],
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
],
|
|
148
|
-
var T = Object.defineProperty, q = (
|
|
149
|
-
for (var
|
|
150
|
-
(
|
|
151
|
-
return
|
|
142
|
+
w([
|
|
143
|
+
h({ reflect: !0 })
|
|
144
|
+
], f.prototype, "name", 2);
|
|
145
|
+
f = w([
|
|
146
|
+
y("sbb-icon")
|
|
147
|
+
], f);
|
|
148
|
+
var T = Object.defineProperty, q = (e, t, o, r) => {
|
|
149
|
+
for (var s = void 0, i = e.length - 1, a; i >= 0; i--)
|
|
150
|
+
(a = e[i]) && (s = a(t, o, s) || s);
|
|
151
|
+
return s && T(t, o, s), s;
|
|
152
152
|
};
|
|
153
|
-
const J = (
|
|
154
|
-
class
|
|
155
|
-
renderIconSlot(
|
|
156
|
-
return
|
|
153
|
+
const J = (e) => {
|
|
154
|
+
class t extends e {
|
|
155
|
+
renderIconSlot(r) {
|
|
156
|
+
return u`
|
|
157
157
|
<slot name="icon">
|
|
158
|
-
${this.iconName ?
|
|
158
|
+
${this.iconName ? u`<sbb-icon name=${this.iconName} class=${r || b}></sbb-icon>` : b}
|
|
159
159
|
</slot>
|
|
160
160
|
`;
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
163
|
return q([
|
|
164
|
-
|
|
165
|
-
],
|
|
164
|
+
h({ attribute: "icon-name", reflect: !0 })
|
|
165
|
+
], t.prototype, "iconName"), t;
|
|
166
166
|
};
|
|
167
167
|
export {
|
|
168
|
-
|
|
169
|
-
|
|
168
|
+
n as SbbIconBase,
|
|
169
|
+
f as SbbIconElement,
|
|
170
170
|
J as SbbIconNameMixin,
|
|
171
171
|
O as getSvgContent,
|
|
172
|
-
|
|
172
|
+
_ as isValid,
|
|
173
173
|
P as validateContent
|
|
174
174
|
};
|