@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.
Files changed (71) hide show
  1. package/accordion.js +54 -54
  2. package/action-group.js +3 -3
  3. package/alert/alert-group.js +22 -22
  4. package/alert/alert.js +22 -22
  5. package/autocomplete.js +126 -126
  6. package/breadcrumb/breadcrumb-group.js +60 -60
  7. package/breadcrumb/breadcrumb.js +17 -17
  8. package/calendar.js +423 -423
  9. package/card/card-badge.js +17 -17
  10. package/card/card.js +2 -2
  11. package/card/common.js +30 -30
  12. package/checkbox/checkbox-group.js +17 -17
  13. package/checkbox/checkbox.js +34 -34
  14. package/clock.js +83 -83
  15. package/container/sticky-bar.js +16 -16
  16. package/core/a11y.js +91 -91
  17. package/core/base-elements.js +86 -86
  18. package/core/controllers.js +40 -40
  19. package/core/datetime.js +32 -32
  20. package/core/dom.js +26 -26
  21. package/core/eventing.js +33 -33
  22. package/core/mixins.js +122 -122
  23. package/core/testing.js +29 -29
  24. package/datepicker/common.js +55 -55
  25. package/datepicker/datepicker-toggle.js +94 -94
  26. package/datepicker/datepicker.js +144 -144
  27. package/dialog/dialog-title.js +20 -20
  28. package/dialog/dialog.js +66 -66
  29. package/expansion-panel/expansion-panel-header.js +20 -20
  30. package/expansion-panel/expansion-panel.js +60 -60
  31. package/file-selector.js +91 -91
  32. package/form-field/form-field-clear.js +12 -12
  33. package/form-field/form-field.js +111 -111
  34. package/header/header.js +53 -53
  35. package/icon.js +107 -107
  36. package/image.js +87 -87
  37. package/journey-header.js +29 -29
  38. package/map-container.js +23 -23
  39. package/menu/menu.js +91 -91
  40. package/navigation/common.js +16 -16
  41. package/navigation/navigation-marker.js +34 -34
  42. package/navigation/navigation-section.js +83 -83
  43. package/navigation/navigation.js +87 -87
  44. package/notification.js +52 -52
  45. package/option/optgroup.js +45 -45
  46. package/option/option.js +108 -108
  47. package/overlay.js +5 -5
  48. package/package.json +1 -1
  49. package/popover/popover.js +110 -110
  50. package/radio-button/radio-button-group.js +93 -93
  51. package/radio-button/radio-button.js +84 -84
  52. package/select.js +178 -178
  53. package/selection-panel.js +44 -44
  54. package/slider.js +58 -58
  55. package/status.js +6 -6
  56. package/stepper/step-label.js +19 -19
  57. package/stepper/step.js +31 -31
  58. package/stepper/stepper.js +46 -46
  59. package/tabs/tab-group.js +67 -67
  60. package/tag/tag-group.js +8 -8
  61. package/tag/tag.js +27 -27
  62. package/teaser-paid.js +12 -12
  63. package/time-input.js +73 -73
  64. package/timetable-occupancy-icon.js +26 -26
  65. package/timetable-occupancy.js +9 -9
  66. package/toast.js +38 -38
  67. package/toggle/toggle-option.js +33 -33
  68. package/toggle/toggle.js +46 -46
  69. package/train/train-formation.js +36 -36
  70. package/train/train-wagon.js +30 -30
  71. 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 l, state as v, customElement as u } from "lit/decorators.js";
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 w = 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 x = Object.defineProperty, y = Object.getOwnPropertyDescriptor, r = (e, t, s, a) => {
9
- for (var i = a > 1 ? void 0 : a ? y(t, s) : t, n = e.length - 1, d; n >= 0; n--)
10
- (d = e[n]) && (i = (a ? d(t, s, i) : d(i)) || i);
11
- return a && i && x(t, s, i), i;
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 _ = "[aria-controls][aria-expanded='true']";
14
- let o = class extends g(c) {
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.b = b ? null : document, this.hideOnScroll = !1, this.f = !0, this.d = 0;
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.b;
20
- this.b = e, this.i(this.b, t);
19
+ const t = this._scrollOrigin;
20
+ this._scrollOrigin = e, this._updateScrollOrigin(this._scrollOrigin, t);
21
21
  }
22
22
  get scrollOrigin() {
23
- return this.b;
23
+ return this._scrollOrigin;
24
24
  }
25
- i(e, t) {
25
+ _updateScrollOrigin(e, t) {
26
26
  if (e !== t) {
27
- this.h(e);
28
- const s = this.e("scrollTop");
29
- this.d = s <= 0 ? 0 : s;
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.h(this.scrollOrigin), new m(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.c) == null || e.abort();
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
- h(e) {
42
+ _setListenerOnScrollElement(e) {
43
43
  var t, s;
44
- (t = this.c) == null || t.abort(), this.c = new AbortController(), this.a = p(e) || (b ? null : document), this.g = this.j.bind(this), (s = this.a) == null || s.addEventListener("scroll", this.g, {
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.c.signal
46
+ signal: this._scrollEventsController.signal
47
47
  });
48
48
  }
49
49
  /** Returns the correct function to attach on scroll. */
50
- j() {
51
- return this.hideOnScroll ? this.k() : this.l();
50
+ _getScrollFunction() {
51
+ return this.hideOnScroll ? this._scrollListener() : this._scrollShadowListener();
52
52
  }
53
53
  /** Returns the requested property of the scrollContext. */
54
- e(e) {
54
+ _getCurrentScrollProperty(e) {
55
55
  var t;
56
- return this.a instanceof Document ? this.a.documentElement[e] || this.a.body[e] : ((t = this.a) == null ? void 0 : t[e]) || 0;
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
- k() {
65
- const e = this.e("scrollTop");
66
- this.e("scrollHeight") - window.innerHeight - e <= 0 || (this.toggleAttribute("data-shadow", e !== 0), e > this.offsetHeight && e > 0 && this.d < e && this.m(), e > this.offsetHeight * 2 ? (this.f = !1, e > 0 && this.d < e ? ["data-shadow", "data-visible"].forEach((t) => this.removeAttribute(t)) : ["data-fixed", "data-shadow", "data-animated", "data-visible"].forEach(
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.f = !0), this.f && ["data-shadow", "data-animated", "data-fixed", "data-visible"].forEach(
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.d = e <= 0 ? 0 : e);
70
+ )), this._lastScroll = e <= 0 ? 0 : e);
71
71
  }
72
72
  /** Apply the shadow if the element/document has been scrolled down. */
73
- l() {
74
- this.toggleAttribute("data-shadow", this.e("scrollTop") !== 0);
73
+ _scrollShadowListener() {
74
+ this.toggleAttribute("data-shadow", this._getCurrentScrollProperty("scrollTop") !== 0);
75
75
  }
76
- m() {
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"), a = document.getElementById(s);
84
- typeof (a == null ? void 0 : a.close) == "function" && a.close();
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
- o.styles = w;
103
- r([
104
- l({ reflect: !0, type: Boolean })
105
- ], o.prototype, "expanded", 2);
106
- r([
107
- l({ attribute: "scroll-origin" })
108
- ], o.prototype, "scrollOrigin", 1);
109
- r([
110
- l({ attribute: "hide-on-scroll", reflect: !0, type: Boolean })
111
- ], o.prototype, "hideOnScroll", 2);
112
- r([
113
- v()
114
- ], o.prototype, "f", 2);
115
- o = r([
116
- u("sbb-header")
117
- ], o);
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
- o as SbbHeaderElement
119
+ i as SbbHeaderElement
120
120
  };
package/icon.js CHANGED
@@ -1,174 +1,174 @@
1
- import { state as g, property as f, customElement as $ } from "lit/decorators.js";
2
- import { css as S, LitElement as _, html as d, nothing as p } from "lit";
3
- import { unsafeHTML as I } from "lit/directives/unsafe-html.js";
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 N } from "./core/decorators.js";
6
- import { readConfig as E } from "./core/config.js";
7
- const L = (t) => typeof t == "string", w = (t) => {
8
- if (t.nodeType === 1) {
9
- if (t.nodeName.toLowerCase() === "script")
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 e = 0; e < t.attributes.length; e++) {
12
- const o = t.attributes[e].name;
13
- if (L(o) && o.toLowerCase().indexOf("on") === 0)
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 e = 0; e < t.childNodes.length; e++)
17
- if (!w(t.childNodes[e]))
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 = (t, e = !0, o = !1) => {
22
- const s = document.createElement("div");
23
- s.innerHTML = t;
24
- for (let i = s.childNodes.length - 1; i >= 0; i--)
25
- s.childNodes[i].nodeName.toLowerCase() !== "svg" && s.removeChild(s.childNodes[i]);
26
- const r = s.firstElementChild;
27
- return r && r.nodeName.toLowerCase() === "svg" && (o && !r.classList.contains("color-immutable") && r.classList.add("color-immutable"), e === !1 || w(r)) ? s.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 = (t, e, o) => {
29
- var b;
30
- const s = E().icon ?? {}, r = ((b = s.namespaces) == null ? void 0 : b.get(t)) ?? C.get(t);
31
- if (r === void 0)
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 "${t}". Please register your custom namespace.`
33
+ `Unable to find the namespace "${e}". Please register your custom namespace.`
34
34
  );
35
- const i = `${r}${e}.svg`;
36
- let n = v.get(i);
37
- if (!n)
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
- n = (s.interceptor ?? ((l) => l.request()))({
40
- namespace: t,
41
- name: e,
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 " + t + ":" + e);
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, n);
50
+ }), v.set(i, a);
51
51
  else
52
52
  return Promise.resolve("");
53
- return n;
54
- }, x = S`*,: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, h = (t, e, o, s) => {
56
- for (var r = s > 1 ? void 0 : s ? M(e, o) : e, i = t.length - 1, n; i >= 0; i--)
57
- (n = t[i]) && (r = (s ? n(e, o, r) : n(r)) || r);
58
- return s && r && z(e, o, r), r;
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 a = class extends _ {
60
+ let n = class extends I {
61
61
  constructor() {
62
- super(...arguments), this.b = a.a, this.noSanitize = !1;
62
+ super(...arguments), this._svgNamespace = n._defaultNamespace, this.noSanitize = !1;
63
63
  }
64
- async loadSvgIcon(t) {
65
- if (!t)
64
+ async loadSvgIcon(e) {
65
+ if (!e)
66
66
  return;
67
- const [e, o] = this.d(t);
68
- this.b = e, this.setAttribute("data-namespace", this.b);
69
- const s = this.fetchSvgIcon(this.b, o);
70
- this.c = s.then((r) => I(r));
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 s);
72
+ this.toggleAttribute("data-empty", !await r);
73
73
  } catch {
74
74
  this.toggleAttribute("data-empty", !0);
75
75
  }
76
76
  }
77
- async fetchSvgIcon(t, e) {
78
- return await O(t, e, !this.noSanitize);
77
+ async fetchSvgIcon(e, t) {
78
+ return await O(e, t, !this.noSanitize);
79
79
  }
80
- d(t) {
81
- if (!t)
80
+ _splitIconName(e) {
81
+ if (!e)
82
82
  return ["", ""];
83
- const e = t.split(":");
84
- switch (e.length) {
83
+ const t = e.split(":");
84
+ switch (t.length) {
85
85
  case 1:
86
- return [a.a, e[0]];
86
+ return [n._defaultNamespace, t[0]];
87
87
  case 2:
88
- return e;
88
+ return t;
89
89
  default:
90
- throw Error(`Invalid icon name: "${t}"`);
90
+ throw Error(`Invalid icon name: "${e}"`);
91
91
  }
92
92
  }
93
- firstUpdated(t) {
94
- super.firstUpdated(t), this.setAttribute("role", this.getAttribute("role") ?? "img");
93
+ firstUpdated(e) {
94
+ super.firstUpdated(e), this.setAttribute("role", this.getAttribute("role") ?? "img");
95
95
  }
96
96
  render() {
97
- return d`<span class="sbb-icon-inner"
97
+ return u`<span class="sbb-icon-inner"
98
98
  >${A(
99
- this.c,
99
+ this._svgIcon,
100
100
  // To reserve space, we need an empty svg to apply dimension to.
101
- d`<svg width="0" height="0"></svg>`
101
+ u`<svg width="0" height="0"></svg>`
102
102
  )}</span
103
103
  >`;
104
104
  }
105
105
  };
106
- a.styles = x;
107
- a.a = "default";
108
- h([
106
+ n.styles = x;
107
+ n._defaultNamespace = "default";
108
+ d([
109
109
  g()
110
- ], a.prototype, "b", 2);
111
- h([
110
+ ], n.prototype, "_svgNamespace", 2);
111
+ d([
112
112
  g()
113
- ], a.prototype, "c", 2);
114
- h([
115
- f({ attribute: "no-sanitize", type: Boolean })
116
- ], a.prototype, "noSanitize", 2);
117
- a = h([
118
- N({
119
- "data-namespace": a.a,
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
- ], a);
123
- var U = Object.defineProperty, j = Object.getOwnPropertyDescriptor, y = (t, e, o, s) => {
124
- for (var r = s > 1 ? void 0 : s ? j(e, o) : e, i = t.length - 1, n; i >= 0; i--)
125
- (n = t[i]) && (r = (s ? n(e, o, r) : n(r)) || r);
126
- return s && r && U(e, o, r), r;
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 u = class extends a {
128
+ let f = class extends n {
129
129
  constructor() {
130
- super(...arguments), this.a = "";
130
+ super(...arguments), this._defaultAriaLabel = "";
131
131
  }
132
- async fetchSvgIcon(t, e) {
133
- return this.getAttribute("aria-label") === this.a && this.removeAttribute("aria-label"), this.a = `Icon ${e.replace(/-/g, " ")}`, this.getAttribute("aria-hidden") === "false" && !this.hasAttribute("aria-label") && e && this.setAttribute("aria-label", this.a), super.fetchSvgIcon(t, e);
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(t) {
136
- super.willUpdate(t), t.has("name") && this.loadSvgIcon(this.name);
135
+ willUpdate(e) {
136
+ super.willUpdate(e), e.has("name") && this.loadSvgIcon(this.name);
137
137
  }
138
- firstUpdated(t) {
139
- super.firstUpdated(t), this.hasAttribute("aria-hidden") || this.setAttribute("aria-hidden", "true");
138
+ firstUpdated(e) {
139
+ super.firstUpdated(e), this.hasAttribute("aria-hidden") || this.setAttribute("aria-hidden", "true");
140
140
  }
141
141
  };
142
- y([
143
- f({ reflect: !0 })
144
- ], u.prototype, "name", 2);
145
- u = y([
146
- $("sbb-icon")
147
- ], u);
148
- var T = Object.defineProperty, q = (t, e, o, s) => {
149
- for (var r = void 0, i = t.length - 1, n; i >= 0; i--)
150
- (n = t[i]) && (r = n(e, o, r) || r);
151
- return r && T(e, o, r), r;
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 = (t) => {
154
- class e extends t {
155
- renderIconSlot(s) {
156
- return d`
153
+ const J = (e) => {
154
+ class t extends e {
155
+ renderIconSlot(r) {
156
+ return u`
157
157
  <slot name="icon">
158
- ${this.iconName ? d`<sbb-icon name=${this.iconName} class=${s || p}></sbb-icon>` : p}
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
- f({ attribute: "icon-name", reflect: !0 })
165
- ], e.prototype, "iconName"), e;
164
+ h({ attribute: "icon-name", reflect: !0 })
165
+ ], t.prototype, "iconName"), t;
166
166
  };
167
167
  export {
168
- a as SbbIconBase,
169
- u as SbbIconElement,
168
+ n as SbbIconBase,
169
+ f as SbbIconElement,
170
170
  J as SbbIconNameMixin,
171
171
  O as getSvgContent,
172
- w as isValid,
172
+ _ as isValid,
173
173
  P as validateContent
174
174
  };