@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/stepper/step.js CHANGED
@@ -1,35 +1,35 @@
1
1
  import { css as o, LitElement as l, html as p } from "lit";
2
2
  import { customElement as h } from "lit/decorators.js";
3
- import { ref as c } from "lit/directives/ref.js";
4
- import { SbbConnectedAbortController as d } from "../core/controllers.js";
3
+ import { ref as d } from "lit/directives/ref.js";
4
+ import { SbbConnectedAbortController as c } from "../core/controllers.js";
5
5
  import { hostAttributes as v } from "../core/decorators.js";
6
6
  import { EventEmitter as m } from "../core/eventing.js";
7
7
  import { AgnosticResizeObserver as u } from "../core/observers.js";
8
8
  const f = o`*,:before,:after{box-sizing:border-box}:host{--sbb-step-position: initial;--sbb-step-inset-block-start: unset;--sbb-step-opacity: 0;--sbb-step-visibility: hidden;--sbb-step-height: 0;--sbb-step-animation-duration: var( --sbb-disable-animation-zero-time, var(--sbb-animation-duration-2x) );--sbb-step-animation-delay: 0;--sbb-step-color: var(--sbb-color-iron);display:contents}:host([data-selected]){--sbb-step-opacity: 1;--sbb-step-visibility: visible;--sbb-step-height: fit-content;--sbb-step-animation-duration: var(--sbb-animation-duration-4x);--sbb-step-animation-delay: var(--sbb-step-animation-duration)}:host([data-orientation=horizontal]){--sbb-step-position: absolute;--sbb-step-inset-block-start: 0}:host([data-orientation=vertical]) .sbb-step--wrapper{margin-inline-start:var(--sbb-spacing-fixed-4x);opacity:0;height:0;transition:height var(--sbb-stepper-animation-duration) var(--sbb-animation-easing),opacity var(--sbb-step-animation-duration) var(--sbb-animation-easing)}:host([data-selected][data-orientation=vertical]) .sbb-step--wrapper{opacity:1;height:var(--sbb-stepper-content-height);transition:height var(--sbb-stepper-animation-duration) var(--sbb-animation-easing),opacity var(--sbb-step-animation-duration) var(--sbb-stepper-animation-duration) var(--sbb-animation-easing)}.sbb-step{--sbb-text-font-size: var(--sbb-font-size-text-m);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);position:var(--sbb-step-position);width:100%;inset-block-start:var(--sbb-step-inset-block-start);opacity:var(--sbb-step-opacity);visibility:var(--sbb-step-visibility);height:var(--sbb-step-height);color:var(--sbb-step-color);transition-property:opacity,visibility;transition-duration:var(--sbb-step-animation-duration);transition-delay:var(--sbb-step-animation-delay);transition-timing-function:var(--sbb-animation-easing)}`;
9
- var g = Object.defineProperty, y = Object.getOwnPropertyDescriptor, x = (t, i, a, s) => {
10
- for (var e = s > 1 ? void 0 : s ? y(i, a) : i, b = t.length - 1, r; b >= 0; b--)
11
- (r = t[b]) && (e = (s ? r(i, a, e) : r(e)) || e);
12
- return s && e && g(i, a, e), e;
9
+ var g = Object.defineProperty, _ = Object.getOwnPropertyDescriptor, y = (t, s, a, i) => {
10
+ for (var e = i > 1 ? void 0 : i ? _(s, a) : s, r = t.length - 1, b; r >= 0; r--)
11
+ (b = t[r]) && (e = (i ? b(s, a, e) : b(e)) || e);
12
+ return i && e && g(s, a, e), e;
13
13
  };
14
- let w = 0, n = class extends l {
14
+ let x = 0, n = class extends l {
15
15
  constructor() {
16
- super(...arguments), this.f = new m(
16
+ super(...arguments), this._validate = new m(
17
17
  this,
18
18
  n.events.validate
19
- ), this.c = !1, this.g = new d(this), this.a = null, this.b = null, this.d = new u(
20
- (t) => this.h(t)
19
+ ), this._loaded = !1, this._abort = new c(this), this._stepper = null, this._label = null, this._stepResizeObserver = new u(
20
+ (t) => this._onStepElementResize(t)
21
21
  );
22
22
  }
23
23
  /** The label of the step. */
24
24
  get label() {
25
- return this.b;
25
+ return this._label;
26
26
  }
27
27
  /**
28
28
  * Selects and configures the step.
29
29
  * @internal
30
30
  */
31
31
  select() {
32
- !this.c || !this.label || (this.toggleAttribute("data-selected", !0), this.label.select());
32
+ !this._loaded || !this.label || (this.toggleAttribute("data-selected", !0), this.label.select());
33
33
  }
34
34
  /**
35
35
  * Deselects and configures the step.
@@ -43,35 +43,35 @@ let w = 0, n = class extends l {
43
43
  * @internal
44
44
  */
45
45
  validate(t) {
46
- return !!this.f.emit(t);
46
+ return !!this._validate.emit(t);
47
47
  }
48
48
  /**
49
49
  * Configures the step.
50
50
  * @internal
51
51
  */
52
52
  configure(t) {
53
- t && (this.b = this.e()), this.label && this.setAttribute("aria-labelledby", this.label.id);
53
+ t && (this._label = this._getStepLabel()), this.label && this.setAttribute("aria-labelledby", this.label.id);
54
54
  }
55
55
  /** Watches for clicked elements with `sbb-stepper-next` or `sbb-stepper-previous` attributes. */
56
- i(t) {
57
- var a, s;
58
- const i = t.composedPath().filter((e) => e instanceof window.HTMLElement);
59
- i.some((e) => this.j(e)) ? (a = this.a) == null || a.next() : i.some((e) => this.k(e)) && ((s = this.a) == null || s.previous());
56
+ _handleClick(t) {
57
+ var a, i;
58
+ const s = t.composedPath().filter((e) => e instanceof window.HTMLElement);
59
+ s.some((e) => this._isGoNextElement(e)) ? (a = this._stepper) == null || a.next() : s.some((e) => this._isGoPreviousElement(e)) && ((i = this._stepper) == null || i.previous());
60
60
  }
61
- j(t) {
61
+ _isGoNextElement(t) {
62
62
  return t.hasAttribute("sbb-stepper-next") && !t.hasAttribute("disabled");
63
63
  }
64
- k(t) {
64
+ _isGoPreviousElement(t) {
65
65
  return t.hasAttribute("sbb-stepper-previous") && !t.hasAttribute("disabled");
66
66
  }
67
- h(t) {
68
- var a, s;
67
+ _onStepElementResize(t) {
68
+ var a, i;
69
69
  if (!this.hasAttribute("data-selected"))
70
70
  return;
71
- const i = Math.floor(t[0].contentRect.height);
72
- (s = (a = this.a) == null ? void 0 : a.style) == null || s.setProperty("--sbb-stepper-content-height", `${i}px`);
71
+ const s = Math.floor(t[0].contentRect.height);
72
+ (i = (a = this._stepper) == null ? void 0 : a.style) == null || i.setProperty("--sbb-stepper-content-height", `${s}px`);
73
73
  }
74
- e() {
74
+ _getStepLabel() {
75
75
  let t = this.previousElementSibling;
76
76
  for (; t && t.localName !== "sbb-step-label"; )
77
77
  t = t.previousElementSibling;
@@ -79,21 +79,21 @@ let w = 0, n = class extends l {
79
79
  }
80
80
  connectedCallback() {
81
81
  super.connectedCallback();
82
- const t = this.g.signal;
83
- this.id = this.id || `sbb-step-${w++}`, this.addEventListener("click", (i) => this.i(i), { signal: t }), this.a = this.closest("sbb-stepper"), this.b = this.e();
82
+ const t = this._abort.signal;
83
+ this.id = this.id || `sbb-step-${x++}`, this.addEventListener("click", (s) => this._handleClick(s), { signal: t }), this._stepper = this.closest("sbb-stepper"), this._label = this._getStepLabel();
84
84
  }
85
85
  firstUpdated(t) {
86
- super.firstUpdated(t), this.c = !0;
86
+ super.firstUpdated(t), this._loaded = !0;
87
87
  }
88
88
  disconnectedCallback() {
89
- super.disconnectedCallback(), this.d.disconnect();
89
+ super.disconnectedCallback(), this._stepResizeObserver.disconnect();
90
90
  }
91
91
  render() {
92
92
  return p`
93
93
  <div class="sbb-step--wrapper">
94
94
  <div
95
95
  class="sbb-step"
96
- ${c((t) => t && this.d.observe(t))}
96
+ ${d((t) => t && this._stepResizeObserver.observe(t))}
97
97
  >
98
98
  <slot></slot>
99
99
  </div>
@@ -105,7 +105,7 @@ n.styles = f;
105
105
  n.events = {
106
106
  validate: "validate"
107
107
  };
108
- n = x([
108
+ n = y([
109
109
  h("sbb-step"),
110
110
  v({
111
111
  slot: "step",
@@ -1,34 +1,34 @@
1
1
  import { css as h, LitElement as p, html as c } from "lit";
2
2
  import { property as l, customElement as f } from "lit/decorators.js";
3
3
  import { isArrowKeyPressed as u, getNextElementIndex as m } from "../core/a11y.js";
4
- import { SbbConnectedAbortController as v } from "../core/controllers.js";
5
- import { breakpoints as x, isBreakpoint as g } from "../core/dom.js";
6
- const _ = h`*,:before,:after{box-sizing:border-box}:host{--sbb-stepper-orientation: row;--sbb-stepper-border-width: var(--sbb-border-width-1x);--sbb-stepper-marker-size: 0;--sbb-stepper-marker-width: var(--sbb-border-width-3x);--sbb-stepper-animation-duration: var( --sbb-disable-animation-zero-time, var(--sbb-animation-duration-6x) );--sbb-stepper-marker-color: var(--sbb-color-charcoal);display:block;position:relative;counter-reset:step-label}@media (forced-colors: active){:host{--sbb-stepper-marker-color: ButtonText}}:host([data-disable-animation]){--sbb-disable-animation-time: .1ms;--sbb-disable-animation-zero-time: 0s}:host([orientation=vertical]){--sbb-stepper-orientation: column}.sbb-stepper{width:100%}.sbb-stepper__labels{display:flex;flex-direction:var(--sbb-stepper-orientation);position:relative;justify-content:space-between;margin-block-end:var(--sbb-spacing-responsive-m)}.sbb-stepper__labels:before{content:"";position:absolute;inset-inline-start:calc(var(--sbb-stepper-border-width) * -1);background-color:var(--sbb-stepper-marker-color)}:host([orientation=horizontal]) .sbb-stepper__labels{gap:var(--sbb-spacing-fixed-4x);padding-block-end:var(--sbb-spacing-fixed-4x);border-block-end:var(--sbb-stepper-border-width) solid var(--sbb-color-cloud)}:host([orientation=horizontal]) .sbb-stepper__labels:before{inset-block-end:calc(var(--sbb-stepper-border-width) * -1);height:var(--sbb-stepper-marker-width);width:var(--sbb-stepper-marker-size);transition:width var(--sbb-stepper-animation-duration) var(--sbb-animation-easing)}:host([orientation=vertical]) .sbb-stepper__labels{padding-inline-start:var(--sbb-spacing-fixed-4x);border-inline-start:var(--sbb-stepper-border-width) solid var(--sbb-color-cloud)}:host([orientation=vertical]) .sbb-stepper__labels:before{inset-block-start:0;width:var(--sbb-stepper-marker-width);height:var(--sbb-stepper-marker-size);transition:height var(--sbb-stepper-animation-duration) var(--sbb-animation-easing)}.sbb-stepper__steps{position:relative}:host([orientation=horizontal]) .sbb-stepper__steps{height:var(--sbb-stepper-content-height);transition:height var(--sbb-stepper-animation-duration) var(--sbb-animation-easing)}::slotted(sbb-step-label):before{content:counter(step-label);counter-increment:step-label}`;
7
- var w = Object.defineProperty, I = Object.getOwnPropertyDescriptor, n = (e, t, s, i) => {
8
- for (var r = i > 1 ? void 0 : i ? I(t, s) : t, a = e.length - 1, b; a >= 0; a--)
9
- (b = e[a]) && (r = (i ? b(t, s, r) : b(r)) || r);
10
- return i && r && w(t, s, r), r;
4
+ import { SbbConnectedAbortController as _ } from "../core/controllers.js";
5
+ import { breakpoints as v, isBreakpoint as g } from "../core/dom.js";
6
+ const x = h`*,:before,:after{box-sizing:border-box}:host{--sbb-stepper-orientation: row;--sbb-stepper-border-width: var(--sbb-border-width-1x);--sbb-stepper-marker-size: 0;--sbb-stepper-marker-width: var(--sbb-border-width-3x);--sbb-stepper-animation-duration: var( --sbb-disable-animation-zero-time, var(--sbb-animation-duration-6x) );--sbb-stepper-marker-color: var(--sbb-color-charcoal);display:block;position:relative;counter-reset:step-label}@media (forced-colors: active){:host{--sbb-stepper-marker-color: ButtonText}}:host([data-disable-animation]){--sbb-disable-animation-time: .1ms;--sbb-disable-animation-zero-time: 0s}:host([orientation=vertical]){--sbb-stepper-orientation: column}.sbb-stepper{width:100%}.sbb-stepper__labels{display:flex;flex-direction:var(--sbb-stepper-orientation);position:relative;justify-content:space-between;margin-block-end:var(--sbb-spacing-responsive-m)}.sbb-stepper__labels:before{content:"";position:absolute;inset-inline-start:calc(var(--sbb-stepper-border-width) * -1);background-color:var(--sbb-stepper-marker-color)}:host([orientation=horizontal]) .sbb-stepper__labels{gap:var(--sbb-spacing-fixed-4x);padding-block-end:var(--sbb-spacing-fixed-4x);border-block-end:var(--sbb-stepper-border-width) solid var(--sbb-color-cloud)}:host([orientation=horizontal]) .sbb-stepper__labels:before{inset-block-end:calc(var(--sbb-stepper-border-width) * -1);height:var(--sbb-stepper-marker-width);width:var(--sbb-stepper-marker-size);transition:width var(--sbb-stepper-animation-duration) var(--sbb-animation-easing)}:host([orientation=vertical]) .sbb-stepper__labels{padding-inline-start:var(--sbb-spacing-fixed-4x);border-inline-start:var(--sbb-stepper-border-width) solid var(--sbb-color-cloud)}:host([orientation=vertical]) .sbb-stepper__labels:before{inset-block-start:0;width:var(--sbb-stepper-marker-width);height:var(--sbb-stepper-marker-size);transition:height var(--sbb-stepper-animation-duration) var(--sbb-animation-easing)}.sbb-stepper__steps{position:relative}:host([orientation=horizontal]) .sbb-stepper__steps{height:var(--sbb-stepper-content-height);transition:height var(--sbb-stepper-animation-duration) var(--sbb-animation-easing)}::slotted(sbb-step-label):before{content:counter(step-label);counter-increment:step-label}`;
7
+ var z = Object.defineProperty, w = Object.getOwnPropertyDescriptor, n = (e, t, s, i) => {
8
+ for (var r = i > 1 ? void 0 : i ? w(t, s) : t, a = e.length - 1, d; a >= 0; a--)
9
+ (d = e[a]) && (r = (i ? d(t, s, r) : d(r)) || r);
10
+ return i && r && z(t, s, r), r;
11
11
  };
12
- const d = 150;
12
+ const b = 150;
13
13
  let o = class extends p {
14
14
  constructor() {
15
- super(...arguments), this.linear = !1, this.orientation = "horizontal", this.a = !1, this.k = new v(this), this.g = null;
15
+ super(...arguments), this.linear = !1, this.orientation = "horizontal", this._loaded = !1, this._abort = new _(this), this._resizeObserverTimeout = null;
16
16
  }
17
17
  set horizontalFrom(e) {
18
- this.c = x.includes(e) ? e : void 0, this.c && this.a && this.d();
18
+ this._horizontalFrom = v.includes(e) ? e : void 0, this._horizontalFrom && this._loaded && this._checkOrientation();
19
19
  }
20
20
  get horizontalFrom() {
21
- return this.c;
21
+ return this._horizontalFrom;
22
22
  }
23
23
  set selected(e) {
24
- this.a && this.b(e);
24
+ this._loaded && this._select(e);
25
25
  }
26
26
  get selected() {
27
27
  var e;
28
28
  return ((e = this.querySelector) == null ? void 0 : e.call(this, "sbb-step[data-selected]")) ?? void 0;
29
29
  }
30
30
  set selectedIndex(e) {
31
- this.a && this.b(this.steps[e]);
31
+ this._loaded && this._select(this.steps[e]);
32
32
  }
33
33
  get selectedIndex() {
34
34
  return this.selected ? this.steps.indexOf(this.selected) : void 0;
@@ -38,7 +38,7 @@ let o = class extends p {
38
38
  var e;
39
39
  return Array.from(((e = this.querySelectorAll) == null ? void 0 : e.call(this, "sbb-step")) ?? []);
40
40
  }
41
- get f() {
41
+ get _enabledSteps() {
42
42
  return this.steps.filter((e) => {
43
43
  var t;
44
44
  return !((t = e.label) != null && t.hasAttribute("disabled"));
@@ -46,11 +46,11 @@ let o = class extends p {
46
46
  }
47
47
  /** Selects the next step. */
48
48
  next() {
49
- this.selectedIndex !== void 0 && this.b(this.steps[this.selectedIndex + 1]);
49
+ this.selectedIndex !== void 0 && this._select(this.steps[this.selectedIndex + 1]);
50
50
  }
51
51
  /** Selects the previous step. */
52
52
  previous() {
53
- this.selectedIndex !== void 0 && this.b(this.steps[this.selectedIndex - 1]);
53
+ this.selectedIndex !== void 0 && this._select(this.steps[this.selectedIndex - 1]);
54
54
  }
55
55
  /** Resets the form in which the stepper is nested or every form of each step, if any. */
56
56
  reset() {
@@ -58,7 +58,7 @@ let o = class extends p {
58
58
  const e = this.closest("form");
59
59
  e ? e.reset() : this.querySelectorAll("form").forEach((r) => r.reset()), this.selectedIndex = 0, ((t = document.activeElement) == null ? void 0 : t.closest("sbb-stepper")) === this && ((i = (s = this.selected) == null ? void 0 : s.label) == null || i.focus());
60
60
  }
61
- l(e) {
61
+ _isValidStep(e) {
62
62
  var t;
63
63
  if (!e || !this.linear && ((t = e.label) != null && t.hasAttribute("disabled")))
64
64
  return !1;
@@ -70,9 +70,9 @@ let o = class extends p {
70
70
  }
71
71
  return !0;
72
72
  }
73
- b(e) {
73
+ _select(e) {
74
74
  var i, r, a;
75
- if (!this.l(e))
75
+ if (!this._isValidStep(e))
76
76
  return;
77
77
  const t = {
78
78
  currentIndex: this.selectedIndex,
@@ -83,15 +83,15 @@ let o = class extends p {
83
83
  if (this.selected && !this.selected.validate(t))
84
84
  return;
85
85
  const s = this.selected;
86
- s == null || s.deselect(), e.select(), this.e(), this.h(), ((i = document.activeElement) == null ? void 0 : i.closest("sbb-stepper")) === this && ((a = (r = this.selected) == null ? void 0 : r.label) == null || a.focus());
86
+ s == null || s.deselect(), e.select(), this._setMarkerSize(), this._configureLinearMode(), ((i = document.activeElement) == null ? void 0 : i.closest("sbb-stepper")) === this && ((a = (r = this.selected) == null ? void 0 : r.label) == null || a.focus());
87
87
  }
88
- e() {
89
- if (!this.a || !this.selected || this.selectedIndex === void 0 || !this.selected.label)
88
+ _setMarkerSize() {
89
+ if (!this._loaded || !this.selected || this.selectedIndex === void 0 || !this.selected.label)
90
90
  return;
91
- const e = this.orientation === "horizontal" ? this.selected.label.offsetLeft + this.selected.label.offsetWidth : this.m();
91
+ const e = this.orientation === "horizontal" ? this.selected.label.offsetLeft + this.selected.label.offsetWidth : this._calculateLabelOffsetTop();
92
92
  this.style.setProperty("--sbb-stepper-marker-size", `${e}px`);
93
93
  }
94
- m() {
94
+ _calculateLabelOffsetTop() {
95
95
  if (this.selectedIndex === void 0)
96
96
  return;
97
97
  let e = 0;
@@ -102,28 +102,28 @@ let o = class extends p {
102
102
  }
103
103
  return e + this.selected.label.offsetHeight + parseFloat(getComputedStyle(this).getPropertyValue("--sbb-spacing-fixed-6x")) * 16 * this.selectedIndex;
104
104
  }
105
- i() {
105
+ _configure() {
106
106
  const e = this.steps;
107
- e.forEach((t) => t.configure(this.a)), e.filter((t) => t.label).map((t) => t.label).forEach((t, s, i) => {
108
- t.configure(s + 1, i.length, this.a);
109
- }), this.b(this.selected || this.f[0]);
107
+ e.forEach((t) => t.configure(this._loaded)), e.filter((t) => t.label).map((t) => t.label).forEach((t, s, i) => {
108
+ t.configure(s + 1, i.length, this._loaded);
109
+ }), this._select(this.selected || this._enabledSteps[0]);
110
110
  }
111
- j() {
111
+ _updateLabels() {
112
112
  this.steps.forEach((e) => {
113
113
  var t;
114
114
  e.slot = this.orientation === "horizontal" ? "step" : "step-label", e.setAttribute("data-orientation", this.orientation), (t = e.label) == null || t.setAttribute("data-orientation", this.orientation);
115
115
  });
116
116
  }
117
- d() {
118
- this.horizontalFrom && (this.orientation = g(this.horizontalFrom) ? "horizontal" : "vertical", this.j()), setTimeout(() => this.e(), 0);
117
+ _checkOrientation() {
118
+ this.horizontalFrom && (this.orientation = g(this.horizontalFrom) ? "horizontal" : "vertical", this._updateLabels()), setTimeout(() => this._setMarkerSize(), 0);
119
119
  }
120
- n() {
121
- this.d(), clearTimeout(this.g), this.toggleAttribute("data-disable-animation", !0), this.g = setTimeout(
120
+ _onStepperResize() {
121
+ this._checkOrientation(), clearTimeout(this._resizeObserverTimeout), this.toggleAttribute("data-disable-animation", !0), this._resizeObserverTimeout = setTimeout(
122
122
  () => this.toggleAttribute("data-disable-animation", !1),
123
- d
123
+ b
124
124
  );
125
125
  }
126
- h() {
126
+ _configureLinearMode() {
127
127
  this.steps.forEach((e, t) => {
128
128
  var s;
129
129
  (s = e.label) == null || s.toggleAttribute(
@@ -134,40 +134,40 @@ let o = class extends p {
134
134
  }
135
135
  connectedCallback() {
136
136
  super.connectedCallback();
137
- const e = this.k.signal;
138
- this.addEventListener("keydown", (t) => this.o(t), { signal: e }), window.addEventListener("resize", () => this.n(), {
137
+ const e = this._abort.signal;
138
+ this.addEventListener("keydown", (t) => this._handleKeyDown(t), { signal: e }), window.addEventListener("resize", () => this._onStepperResize(), {
139
139
  signal: e,
140
140
  passive: !0
141
- }), this.toggleAttribute("data-disable-animation", !this.a);
141
+ }), this.toggleAttribute("data-disable-animation", !this._loaded);
142
142
  }
143
143
  async firstUpdated(e) {
144
- super.firstUpdated(e), await this.updateComplete, this.a = !0, this.selectedIndex = this.linear ? 0 : Number(this.getAttribute("selected-index")) || 0, this.d(), setTimeout(() => this.toggleAttribute("data-disable-animation", !1), d);
144
+ super.firstUpdated(e), await this.updateComplete, this._loaded = !0, this.selectedIndex = this.linear ? 0 : Number(this.getAttribute("selected-index")) || 0, this._checkOrientation(), setTimeout(() => this.toggleAttribute("data-disable-animation", !1), b);
145
145
  }
146
146
  willUpdate(e) {
147
- super.willUpdate(e), e.has("orientation") && !this.horizontalFrom && (this.j(), this.e()), e.has("linear") && this.a && this.h();
147
+ super.willUpdate(e), e.has("orientation") && !this.horizontalFrom && (this._updateLabels(), this._setMarkerSize()), e.has("linear") && this._loaded && this._configureLinearMode();
148
148
  }
149
- o(e) {
150
- const t = this.f;
149
+ _handleKeyDown(e) {
150
+ const t = this._enabledSteps;
151
151
  if (!(!t || // don't trap nested handling
152
152
  e.target !== this && e.target.parentElement !== this) && u(e)) {
153
153
  const s = t.indexOf(this.selected), i = m(e, s, t.length);
154
- this.b(t[i]), e.preventDefault();
154
+ this._select(t[i]), e.preventDefault();
155
155
  }
156
156
  }
157
157
  render() {
158
158
  return c`
159
159
  <div class="sbb-stepper">
160
160
  <div class="sbb-stepper__labels" role="tablist">
161
- <slot name="step-label" @slotchange=${this.i}></slot>
161
+ <slot name="step-label" @slotchange=${this._configure}></slot>
162
162
  </div>
163
163
  <div class="sbb-stepper__steps">
164
- <slot name="step" @slotchange=${this.i}></slot>
164
+ <slot name="step" @slotchange=${this._configure}></slot>
165
165
  </div>
166
166
  </div>
167
167
  `;
168
168
  }
169
169
  };
170
- o.styles = _;
170
+ o.styles = x;
171
171
  n([
172
172
  l({ type: Boolean })
173
173
  ], o.prototype, "linear", 2);
package/tabs/tab-group.js CHANGED
@@ -1,50 +1,50 @@
1
1
  import { css as h, LitElement as u, html as f } from "lit";
2
- import { property as c, customElement as v } from "lit/decorators.js";
2
+ import { property as d, customElement as v } from "lit/decorators.js";
3
3
  import { ref as p } from "lit/directives/ref.js";
4
- import { isArrowKeyPressed as g, getNextElementIndex as m } from "../core/a11y.js";
5
- import { SbbConnectedAbortController as A } from "../core/controllers.js";
6
- import { EventEmitter as x, throttle as y } from "../core/eventing.js";
7
- import { AgnosticMutationObserver as C, AgnosticResizeObserver as d } from "../core/observers.js";
8
- const E = h`@charset "UTF-8";*,:before,:after{box-sizing:border-box}:host{--sbb-tab-group-animation-duration: var( --sbb-disable-animation-zero-time, var(--sbb-animation-duration-4x) );display:block}.tab-group{display:flex;flex-wrap:wrap}.tab-content{margin-block-start:var(--sbb-spacing-responsive-m);transition:height var(--sbb-tab-group-animation-duration) var(--sbb-animation-easing)}.tab-content:after,.tab-content:before{content:" ";display:block;visibility:hidden;height:0}.tab-content ::slotted(*){visibility:hidden;opacity:0;height:0;overflow:hidden;position:relative}.tab-content ::slotted(*[active]){visibility:visible;opacity:1;height:fit-content;overflow:unset;transition-duration:var(--sbb-tab-group-animation-duration);transition-delay:var(--sbb-tab-group-animation-duration);transition-timing-function:var(--sbb-animation-easing);transition-property:opacity,visibility}.tab-content ::slotted([role=tabpanel]:focus-visible){outline-offset:var(--sbb-focus-outline-offset);outline:var(--sbb-focus-outline-color) solid var(--sbb-focus-outline-width)}:host([data-nested]:not([active])) *,:host([data-nested]:not([active])) ::slotted(*){visibility:hidden;opacity:0;height:0}`;
9
- var w = Object.defineProperty, G = Object.getOwnPropertyDescriptor, l = (t, e, i, s) => {
10
- for (var a = s > 1 ? void 0 : s ? G(e, i) : e, n = t.length - 1, r; n >= 0; n--)
4
+ import { isArrowKeyPressed as g, getNextElementIndex as _ } from "../core/a11y.js";
5
+ import { SbbConnectedAbortController as m } from "../core/controllers.js";
6
+ import { EventEmitter as A, throttle as C } from "../core/eventing.js";
7
+ import { AgnosticMutationObserver as T, AgnosticResizeObserver as b } from "../core/observers.js";
8
+ const y = h`@charset "UTF-8";*,:before,:after{box-sizing:border-box}:host{--sbb-tab-group-animation-duration: var( --sbb-disable-animation-zero-time, var(--sbb-animation-duration-4x) );display:block}.tab-group{display:flex;flex-wrap:wrap}.tab-content{margin-block-start:var(--sbb-spacing-responsive-m);transition:height var(--sbb-tab-group-animation-duration) var(--sbb-animation-easing)}.tab-content:after,.tab-content:before{content:" ";display:block;visibility:hidden;height:0}.tab-content ::slotted(*){visibility:hidden;opacity:0;height:0;overflow:hidden;position:relative}.tab-content ::slotted(*[active]){visibility:visible;opacity:1;height:fit-content;overflow:unset;transition-duration:var(--sbb-tab-group-animation-duration);transition-delay:var(--sbb-tab-group-animation-duration);transition-timing-function:var(--sbb-animation-easing);transition-property:opacity,visibility}.tab-content ::slotted([role=tabpanel]:focus-visible){outline-offset:var(--sbb-focus-outline-offset);outline:var(--sbb-focus-outline-color) solid var(--sbb-focus-outline-width)}:host([data-nested]:not([active])) *,:host([data-nested]:not([active])) ::slotted(*){visibility:hidden;opacity:0;height:0}`;
9
+ var E = Object.defineProperty, x = Object.getOwnPropertyDescriptor, l = (t, e, i, s) => {
10
+ for (var a = s > 1 ? void 0 : s ? x(e, i) : e, n = t.length - 1, r; n >= 0; n--)
11
11
  (r = t[n]) && (a = (s ? r(e, i, a) : r(a)) || a);
12
- return s && a && w(e, i, a), a;
12
+ return s && a && E(e, i, a), a;
13
13
  };
14
- const S = {
14
+ const z = {
15
15
  attributeFilter: ["active", "disabled"]
16
- }, T = ["article", "div", "section", "sbb-tab-group"];
17
- let I = 0, o = class extends u {
16
+ }, G = ["article", "div", "section", "sbb-tab-group"];
17
+ let S = 0, o = class extends u {
18
18
  constructor() {
19
- super(...arguments), this.a = [], this.l = new A(this), this.h = new C(
20
- (t) => this.m(t)
21
- ), this.i = new d(
22
- (t) => this.n(t)
23
- ), this.d = new d(
24
- (t) => this.o(t)
25
- ), this.j = "l", this.initialSelectedIndex = 0, this.q = new x(
19
+ super(...arguments), this._tabs = [], this._abort = new m(this), this._tabAttributeObserver = new T(
20
+ (t) => this._onTabAttributesChange(t)
21
+ ), this._tabGroupResizeObserver = new b(
22
+ (t) => this._onTabGroupElementResize(t)
23
+ ), this._tabContentResizeObserver = new b(
24
+ (t) => this._onTabContentElementResize(t)
25
+ ), this._size = "l", this.initialSelectedIndex = 0, this._selectedTabChanged = new A(
26
26
  this,
27
27
  o.events.didChange
28
- ), this.t = () => {
29
- this.g = this.shadowRoot.querySelector("div.tab-content");
30
- const t = this.e().filter((e) => !this.a.includes(e));
31
- t.length && (t.forEach((e) => this.k(e)), this.a = this.a.concat(t));
32
- }, this.u = () => {
33
- const t = this.e();
34
- t.length < this.a.length && (this.a.filter((i) => !t.includes(i)).forEach((i) => {
28
+ ), this._onContentSlotChange = () => {
29
+ this._tabContentElement = this.shadowRoot.querySelector("div.tab-content");
30
+ const t = this._getTabs().filter((e) => !this._tabs.includes(e));
31
+ t.length && (t.forEach((e) => this._configure(e)), this._tabs = this._tabs.concat(t));
32
+ }, this._onTabsSlotChange = () => {
33
+ const t = this._getTabs();
34
+ t.length < this._tabs.length && (this._tabs.filter((i) => !t.includes(i)).forEach((i) => {
35
35
  var s;
36
36
  (s = i.relatedContent) == null || s.remove();
37
- }), this.a = t), this.a.forEach((e) => e.setAttribute("data-size", this.size));
37
+ }), this._tabs = t), this._tabs.forEach((e) => e.setAttribute("data-size", this.size));
38
38
  };
39
39
  }
40
40
  set size(t) {
41
- this.j = t, this.p();
41
+ this._size = t, this._updateSize();
42
42
  }
43
43
  get size() {
44
- return this.j;
44
+ return this._size;
45
45
  }
46
- p() {
47
- for (const t of this.a)
46
+ _updateSize() {
47
+ for (const t of this._tabs)
48
48
  t.setAttribute("data-size", this.size);
49
49
  }
50
50
  /**
@@ -53,7 +53,7 @@ let I = 0, o = class extends u {
53
53
  */
54
54
  disableTab(t) {
55
55
  var e, i;
56
- (i = (e = this.a[t]) == null ? void 0 : e.tabGroupActions) == null || i.disable();
56
+ (i = (e = this._tabs[t]) == null ? void 0 : e.tabGroupActions) == null || i.disable();
57
57
  }
58
58
  /**
59
59
  * Enables a tab by index.
@@ -61,7 +61,7 @@ let I = 0, o = class extends u {
61
61
  */
62
62
  enableTab(t) {
63
63
  var e, i;
64
- (i = (e = this.a[t]) == null ? void 0 : e.tabGroupActions) == null || i.enable();
64
+ (i = (e = this._tabs[t]) == null ? void 0 : e.tabGroupActions) == null || i.enable();
65
65
  }
66
66
  /**
67
67
  * Activates a tab by index.
@@ -69,61 +69,61 @@ let I = 0, o = class extends u {
69
69
  */
70
70
  activateTab(t) {
71
71
  var e, i;
72
- (i = (e = this.a[t]) == null ? void 0 : e.tabGroupActions) == null || i.select();
72
+ (i = (e = this._tabs[t]) == null ? void 0 : e.tabGroupActions) == null || i.select();
73
73
  }
74
- e() {
74
+ _getTabs() {
75
75
  return Array.from(this.children ?? []).filter(
76
76
  (t) => /^sbb-tab-title$/u.test(t.localName)
77
77
  );
78
78
  }
79
- get f() {
80
- return this.a.filter((t) => !t.hasAttribute("disabled"));
79
+ get _enabledTabs() {
80
+ return this._tabs.filter((t) => !t.hasAttribute("disabled"));
81
81
  }
82
82
  connectedCallback() {
83
83
  var e;
84
84
  super.connectedCallback();
85
- const t = this.l.signal;
86
- this.addEventListener("keydown", (i) => this.r(i), { signal: t }), this.toggleAttribute("data-nested", !!((e = this.parentElement) != null && e.closest("sbb-tab-group")));
85
+ const t = this._abort.signal;
86
+ this.addEventListener("keydown", (i) => this._handleKeyDown(i), { signal: t }), this.toggleAttribute("data-nested", !!((e = this.parentElement) != null && e.closest("sbb-tab-group")));
87
87
  }
88
88
  firstUpdated(t) {
89
- super.firstUpdated(t), this.a = this.e(), this.a.forEach((e) => this.k(e)), this.s(), this.i.observe(this.c);
89
+ super.firstUpdated(t), this._tabs = this._getTabs(), this._tabs.forEach((e) => this._configure(e)), this._initSelection(), this._tabGroupResizeObserver.observe(this._tabGroupElement);
90
90
  }
91
91
  disconnectedCallback() {
92
- super.disconnectedCallback(), this.h.disconnect(), this.d.disconnect(), this.i.disconnect();
92
+ super.disconnectedCallback(), this._tabAttributeObserver.disconnect(), this._tabContentResizeObserver.disconnect(), this._tabGroupResizeObserver.disconnect();
93
93
  }
94
- v() {
95
- return `sbb-tab-panel-${++I}`;
94
+ _assignId() {
95
+ return `sbb-tab-panel-${++S}`;
96
96
  }
97
- s() {
97
+ _initSelection() {
98
98
  var t, e, i;
99
- this.initialSelectedIndex >= 0 && this.initialSelectedIndex < this.a.length && !this.a[this.initialSelectedIndex].disabled ? (t = this.a[this.initialSelectedIndex].tabGroupActions) == null || t.select() : (i = (e = this.f[0]) == null ? void 0 : e.tabGroupActions) == null || i.select();
99
+ this.initialSelectedIndex >= 0 && this.initialSelectedIndex < this._tabs.length && !this._tabs[this.initialSelectedIndex].disabled ? (t = this._tabs[this.initialSelectedIndex].tabGroupActions) == null || t.select() : (i = (e = this._enabledTabs[0]) == null ? void 0 : e.tabGroupActions) == null || i.select();
100
100
  }
101
- m(t) {
101
+ _onTabAttributesChange(t) {
102
102
  var e, i, s;
103
103
  for (const a of t) {
104
104
  if (a.type !== "attributes")
105
105
  return;
106
106
  const n = a.target;
107
- a.attributeName === "disabled" && (n.hasAttribute("disabled") && n !== this.b ? (e = n.tabGroupActions) == null || e.disable() : n.disabled && ((i = n.tabGroupActions) == null || i.enable())), a.attributeName === "active" && (n.hasAttribute("active") && !n.disabled ? (s = n.tabGroupActions) == null || s.select() : n === this.b && n.toggleAttribute("active", !0));
107
+ a.attributeName === "disabled" && (n.hasAttribute("disabled") && n !== this._selectedTab ? (e = n.tabGroupActions) == null || e.disable() : n.disabled && ((i = n.tabGroupActions) == null || i.enable())), a.attributeName === "active" && (n.hasAttribute("active") && !n.disabled ? (s = n.tabGroupActions) == null || s.select() : n === this._selectedTab && n.toggleAttribute("active", !0));
108
108
  }
109
109
  }
110
- n(t) {
110
+ _onTabGroupElementResize(t) {
111
111
  for (const e of t) {
112
112
  const i = e.target.firstElementChild.assignedElements();
113
113
  for (const s of i)
114
114
  s.toggleAttribute(
115
115
  "data-has-divider",
116
116
  s === i[0] || s.offsetLeft === i[0].offsetLeft
117
- ), this.style.setProperty("--sbb-tab-group-width", `${this.c.clientWidth}px`);
117
+ ), this.style.setProperty("--sbb-tab-group-width", `${this._tabGroupElement.clientWidth}px`);
118
118
  }
119
119
  }
120
- o(t) {
120
+ _onTabContentElementResize(t) {
121
121
  for (const e of t) {
122
122
  const i = Math.floor(e.contentRect.height);
123
- this.g.style.height = `${i}px`;
123
+ this._tabContentElement.style.height = `${i}px`;
124
124
  }
125
125
  }
126
- k(t) {
126
+ _configure(t) {
127
127
  var e, i;
128
128
  t.tabGroupActions = {
129
129
  activate: () => {
@@ -136,29 +136,29 @@ let I = 0, o = class extends u {
136
136
  },
137
137
  disable: () => {
138
138
  var s, a, n;
139
- t.disabled || (t.hasAttribute("disabled") || t.toggleAttribute("disabled", !0), t.disabled = !0, t.tabIndex = -1, t.setAttribute("aria-selected", "false"), (s = t.relatedContent) == null || s.removeAttribute("active"), t.active && (t.removeAttribute("active"), t.active = !1, (n = (a = this.f[0]) == null ? void 0 : a.tabGroupActions) == null || n.select()));
139
+ t.disabled || (t.hasAttribute("disabled") || t.toggleAttribute("disabled", !0), t.disabled = !0, t.tabIndex = -1, t.setAttribute("aria-selected", "false"), (s = t.relatedContent) == null || s.removeAttribute("active"), t.active && (t.removeAttribute("active"), t.active = !1, (n = (a = this._enabledTabs[0]) == null ? void 0 : a.tabGroupActions) == null || n.select()));
140
140
  },
141
141
  enable: () => {
142
142
  t.disabled && (t.removeAttribute("disabled"), t.disabled = !1);
143
143
  },
144
144
  select: () => {
145
145
  var s, a;
146
- if (t !== this.b && !t.disabled) {
147
- const n = this.b;
148
- n && ((s = n.tabGroupActions) == null || s.deactivate(), this.d.unobserve(n.relatedContent)), (a = t.tabGroupActions) == null || a.activate(), this.b = t, this.d.observe(t.relatedContent), this.q.emit();
146
+ if (t !== this._selectedTab && !t.disabled) {
147
+ const n = this._selectedTab;
148
+ n && ((s = n.tabGroupActions) == null || s.deactivate(), this._tabContentResizeObserver.unobserve(n.relatedContent)), (a = t.tabGroupActions) == null || a.activate(), this._selectedTab = t, this._tabContentResizeObserver.observe(t.relatedContent), this._selectedTabChanged.emit();
149
149
  }
150
150
  }
151
- }, (e = t.nextElementSibling) != null && e.localName && T.includes((i = t.nextElementSibling) == null ? void 0 : i.localName) ? (t.relatedContent = t.nextElementSibling, t.relatedContent.id = this.v(), t.relatedContent.nodeName !== "SBB-TAB-GROUP" && (t.relatedContent.tabIndex = 0)) : (t.insertAdjacentHTML("afterend", "<div>No content.</div>"), t.relatedContent = t.nextElementSibling), t.tabIndex = -1, t.disabled = t.hasAttribute("disabled"), t.active = t.hasAttribute("active") && !t.disabled, t.setAttribute("role", "tab"), t.setAttribute("aria-controls", t.relatedContent.id), t.setAttribute("aria-selected", "false"), t.relatedContent.setAttribute("role", "tabpanel"), t.relatedContent.toggleAttribute("active", t.active), t.addEventListener("click", () => {
151
+ }, (e = t.nextElementSibling) != null && e.localName && G.includes((i = t.nextElementSibling) == null ? void 0 : i.localName) ? (t.relatedContent = t.nextElementSibling, t.relatedContent.id = this._assignId(), t.relatedContent.nodeName !== "SBB-TAB-GROUP" && (t.relatedContent.tabIndex = 0)) : (t.insertAdjacentHTML("afterend", "<div>No content.</div>"), t.relatedContent = t.nextElementSibling), t.tabIndex = -1, t.disabled = t.hasAttribute("disabled"), t.active = t.hasAttribute("active") && !t.disabled, t.setAttribute("role", "tab"), t.setAttribute("aria-controls", t.relatedContent.id), t.setAttribute("aria-selected", "false"), t.relatedContent.setAttribute("role", "tabpanel"), t.relatedContent.toggleAttribute("active", t.active), t.addEventListener("click", () => {
152
152
  var s;
153
153
  (s = t.tabGroupActions) == null || s.select();
154
- }), this.h.observe(t, S), t.slot = "tab-bar";
154
+ }), this._tabAttributeObserver.observe(t, z), t.slot = "tab-bar";
155
155
  }
156
- r(t) {
156
+ _handleKeyDown(t) {
157
157
  var i, s, a;
158
- const e = this.f;
158
+ const e = this._enabledTabs;
159
159
  if (!(!e || // don't trap nested handling
160
160
  t.target !== this && t.target.parentElement !== this) && g(t)) {
161
- const n = e.findIndex((b) => b.active), r = m(t, n, e.length);
161
+ const n = e.findIndex((c) => c.active), r = _(t, n, e.length);
162
162
  (s = (i = e[r]) == null ? void 0 : i.tabGroupActions) == null || s.select(), (a = e[r]) == null || a.focus(), t.preventDefault();
163
163
  }
164
164
  }
@@ -167,26 +167,26 @@ let I = 0, o = class extends u {
167
167
  <div
168
168
  class="tab-group"
169
169
  role="tablist"
170
- ${p((t) => this.c = t)}
170
+ ${p((t) => this._tabGroupElement = t)}
171
171
  >
172
- <slot name="tab-bar" @slotchange=${this.u}></slot>
172
+ <slot name="tab-bar" @slotchange=${this._onTabsSlotChange}></slot>
173
173
  </div>
174
174
 
175
175
  <div class="tab-content">
176
- <slot @slotchange=${y(this.t, 150)}></slot>
176
+ <slot @slotchange=${C(this._onContentSlotChange, 150)}></slot>
177
177
  </div>
178
178
  `;
179
179
  }
180
180
  };
181
- o.styles = E;
181
+ o.styles = y;
182
182
  o.events = {
183
183
  didChange: "didChange"
184
184
  };
185
185
  l([
186
- c()
186
+ d()
187
187
  ], o.prototype, "size", 1);
188
188
  l([
189
- c({ attribute: "initial-selected-index", type: Number })
189
+ d({ attribute: "initial-selected-index", type: Number })
190
190
  ], o.prototype, "initialSelectedIndex", 2);
191
191
  o = l([
192
192
  v("sbb-tab-group")