@cas-smartdesign/stage 3.0.2 → 3.1.1

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/dist/stage.mjs CHANGED
@@ -1,26 +1,26 @@
1
- import { LitElement as K, css as X, unsafeCSS as J, html as g } from "lit";
1
+ import { LitElement as q, unsafeCSS as G, css as X, html as g } from "lit";
2
2
  import { property as S } from "lit/decorators/property.js";
3
- import { repeat as Q } from "lit/directives/repeat.js";
3
+ import { repeat as J } from "lit/directives/repeat.js";
4
4
  import { ifDefined as I } from "lit/directives/if-defined.js";
5
- import { ValidationLevel as Y } from "@cas-smartdesign/field-validation-message";
6
- const Z = ':host{--component-stage-border-color: var(--color-base-grey-400, #cccccc);--component-stage-border-focus-color: var(--color-base-black, black);--component-stage-border-highlight-color: var(--color-base-white, white);--component-stage-inactive-color: var(--color-base-white, white);--component-stage-active-color: var(--color-base-green-200, #deedbc);--component-stage-selected-color: var(--color-base-green-400, #bedb79);--component-stage-hover-color: var(--color-base-green-300, #cee49c);--component-stage-focus-color: var(--color-base-green-300, #cee49c);--component-stage-font-color: var(--color-base-grey-900, #555555);--component-stage-font-inactive-color: var(--color-base-grey-900, #555555);--component-stage-font-selected-color: var(--color-base-grey-900, #555555);--component-stage-font-hover-color: var(--color-base-grey-900, #555555);--component-stage-font-focus-color: var(--color-base-grey-900, #555555);--component-stage-font-size: var(--size-font-medium, 13px);--component-stage-font-family: var(--font-family-base, "Segoe UI", Tahoma, Geneva, Verdana, sans-serif);--component-stage-transition-time: var(--time-transition-short, 275ms);display:flex;flex-direction:column;width:100%;margin:0;box-sizing:border-box;font-size:var(--component-stage-font-size);font-family:var(--component-stage-font-family);color:var(--component-stage-font-color)}@media (prefers-reduced-motion){:host{--component-stage-transition-time: 1ms}}:host *{box-sizing:border-box}:host *:before,:host *:after{box-sizing:border-box}:host .sections{width:100%;overflow:hidden;display:flex;-webkit-user-select:none;user-select:none}:host .sections .section:first-child{margin-left:0}:host .sections .section:first-child .content{padding-left:0}:host .section{display:flex;flex:1 1 80px;box-sizing:border-box;height:48px;cursor:pointer;overflow:visible;position:relative}:host .section.placeholder{flex:0 0 48px}:host .section.placeholder .index{display:none}:host .section.placeholder .content .label{top:18px;padding:0 16px}:host .section .content{height:100%;flex:1 1 0;overflow:hidden;transition:background-color var(--component-stage-transition-time) ease-in,color var(--component-stage-transition-time) ease-in}:host .section .content .label{position:absolute;top:25px;min-width:28px;width:100%;padding:0 8px 0 16px;text-align:center;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}:host .section .content .index{position:absolute;bottom:25px;width:100%;padding:0 8px 0 16px;text-align:center;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}:host .section .arrow{flex:0 0 auto;position:absolute;right:0;top:0;z-index:1;box-sizing:border-box;height:48px;width:48px;margin-right:-24px;transform-origin:center center;border:3px solid var(--component-stage-border-highlight-color);border-left:0px;border-bottom:0px;transform:scaleX(.5) scale(.707) rotate(45deg);transition:background-color var(--component-stage-transition-time) ease-in}:host .section:last-of-type .arrow{display:none}:host .section:last-of-type .content{margin-right:0}:host .section.inactive:last-of-type .content{border-right:1px solid var(--component-stage-border-color)}:host .section.inactive:first-child .content{border-left:1px solid var(--component-stage-border-color)}:host .section.inactive .arrow{border-color:var(--component-stage-border-color)}:host .section.inactive .content{color:var(--component-stage-font-inactive-color);background:var(--component-stage-inactive-color);border-top:1px solid var(--component-stage-border-color);border-bottom:1px solid var(--component-stage-border-color)}:host .section.inactive .content,:host .section.inactive .arrow{background:var(--component-stage-inactive-color)}:host .section.active .content,:host .section.active .arrow{color:var(--component-stage-font-color);background:var(--component-stage-active-color)}:host .section.selected .content,:host .section.selected .arrow{color:var(--component-stage-font-selected-color);background:var(--component-stage-selected-color)}:host .hidden{flex:0 1 0px;margin:0;overflow:hidden}:host ::slotted(*){display:none}:host(.readonly) .section{cursor:default}:host(:focus){outline:none}@media (hover: hover){:host(:not(.readonly)) .section:hover .content,:host(:not(.readonly)) .section:hover .arrow{color:var(--component-stage-font-hover-color);background:var(--component-stage-hover-color)}}:host(:not(.readonly)) .section.focused:focus-visible{outline:none}:host(:not(.readonly)) .section.focused:focus-visible .content{border-top:1px solid var(--component-stage-border-focus-color);border-bottom:1px solid var(--component-stage-border-focus-color)}:host(:not(.readonly)) .section.focused:focus-visible .content,:host(:not(.readonly)) .section.focused:focus-visible .arrow{color:var(--component-stage-font-focus-color);background:var(--component-stage-focus-color)}';
7
- var ee = Object.defineProperty, te = Object.getOwnPropertyDescriptor, O = (l, t, o, i) => {
8
- for (var r = i > 1 ? void 0 : i ? te(t, o) : t, s = l.length - 1, p; s >= 0; s--)
9
- (p = l[s]) && (r = (i ? p(t, o, r) : p(r)) || r);
10
- return i && r && ee(t, o, r), r;
5
+ import { ValidationLevel as Q } from "@cas-smartdesign/field-validation-message";
6
+ const Y = ':host{--component-stage-border-color: var(--color-base-grey-400, #cccccc);--component-stage-border-focus-color: var(--color-base-black, black);--component-stage-border-highlight-color: var(--color-base-white, white);--component-stage-inactive-color: var(--color-base-white, white);--component-stage-active-color: var(--color-base-green-200, #deedbc);--component-stage-selected-color: var(--color-base-green-400, #bedb79);--component-stage-hover-color: var(--color-base-green-300, #cee49c);--component-stage-focus-color: var(--color-base-green-300, #cee49c);--component-stage-font-color: var(--color-base-grey-900, #555555);--component-stage-font-inactive-color: var(--color-base-grey-900, #555555);--component-stage-font-selected-color: var(--color-base-grey-900, #555555);--component-stage-font-hover-color: var(--color-base-grey-900, #555555);--component-stage-font-focus-color: var(--color-base-grey-900, #555555);--component-stage-font-size: var(--size-font-medium, 13px);--component-stage-font-family: var(--font-family-base, "Segoe UI", Tahoma, Geneva, Verdana, sans-serif);--component-stage-transition-time: var(--time-transition-short, 275ms);display:flex;flex-direction:column;width:100%;margin:0;box-sizing:border-box;font-size:var(--component-stage-font-size);font-family:var(--component-stage-font-family);color:var(--component-stage-font-color)}@media (prefers-reduced-motion){:host{--component-stage-transition-time: 1ms}}:host *{box-sizing:border-box}:host *:before,:host *:after{box-sizing:border-box}:host .sections{width:100%;overflow:hidden;display:flex;-webkit-user-select:none;user-select:none}:host .sections .section:first-child{margin-left:0}:host .sections .section:first-child .content{padding-left:0}:host .section{display:flex;flex:1 1 80px;box-sizing:border-box;height:48px;cursor:pointer;overflow:visible;position:relative}:host .section.placeholder{flex:0 0 48px}:host .section.placeholder .index{display:none}:host .section.placeholder .content .label{top:18px;padding:0 16px}:host .section .content{height:100%;flex:1 1 0;overflow:hidden;transition:background-color var(--component-stage-transition-time) ease-in,color var(--component-stage-transition-time) ease-in}:host .section .content .label{position:absolute;top:25px;min-width:28px;width:100%;padding:0 8px 0 16px;text-align:center;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}:host .section .content .index{position:absolute;bottom:25px;width:100%;padding:0 8px 0 16px;text-align:center;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}:host .section .arrow{flex:0 0 auto;position:absolute;right:0;top:0;z-index:1;box-sizing:border-box;height:48px;width:48px;margin-right:-24px;transform-origin:center center;border:3px solid var(--component-stage-border-highlight-color);border-left:0px;border-bottom:0px;transform:scaleX(.5) scale(.707) rotate(45deg);transition:background-color var(--component-stage-transition-time) ease-in}:host .section:last-of-type .arrow{display:none}:host .section:last-of-type .content{margin-right:0}:host .section.inactive:last-of-type .content{border-right:1px solid var(--component-stage-border-color)}:host .section.inactive:first-child .content{border-left:1px solid var(--component-stage-border-color)}:host .section.inactive .arrow{border-color:var(--component-stage-border-color)}:host .section.inactive .content{color:var(--component-stage-font-inactive-color);background:var(--component-stage-inactive-color);border-top:1px solid var(--component-stage-border-color);border-bottom:1px solid var(--component-stage-border-color)}:host .section.inactive .content,:host .section.inactive .arrow{background:var(--component-stage-inactive-color)}:host .section.active .content,:host .section.active .arrow{color:var(--component-stage-font-color);background:var(--component-stage-active-color)}:host .section.selected .content,:host .section.selected .arrow{color:var(--component-stage-font-selected-color);background:var(--component-stage-selected-color)}:host .hidden{flex:0 1 0px;margin:0;overflow:hidden}:host ::slotted(*){display:none}:host(.readonly) .section{cursor:default}:host(:focus){outline:none}@media (hover: hover){:host(:not(.readonly)) .section:hover .content,:host(:not(.readonly)) .section:hover .arrow{color:var(--component-stage-font-hover-color);background:var(--component-stage-hover-color)}}:host(:not(.readonly)) .section.focused:focus-visible{outline:none}:host(:not(.readonly)) .section.focused:focus-visible .content{border-top:1px solid var(--component-stage-border-focus-color);border-bottom:1px solid var(--component-stage-border-focus-color)}:host(:not(.readonly)) .section.focused:focus-visible .content,:host(:not(.readonly)) .section.focused:focus-visible .arrow{color:var(--component-stage-font-focus-color);background:var(--component-stage-focus-color)}';
7
+ var Z = Object.defineProperty, ee = Object.getOwnPropertyDescriptor, O = (l, t, o, r) => {
8
+ for (var a = r > 1 ? void 0 : r ? ee(t, o) : t, s = l.length - 1, f; s >= 0; s--)
9
+ (f = l[s]) && (a = (r ? f(t, o, a) : f(a)) || a);
10
+ return r && a && Z(t, o, a), a;
11
11
  };
12
- function T(l) {
12
+ function H(l) {
13
13
  return l.label != null && l.id != null;
14
14
  }
15
- var a;
16
- const b = (a = class extends K {
15
+ var i;
16
+ const b = (i = class extends q {
17
17
  constructor() {
18
18
  super(...arguments), this._isSpaceOrEnterKeyDown = !1, this._focusIndex = -1, this._focusOutSuspended = !1;
19
19
  }
20
20
  static get styles() {
21
21
  return [
22
22
  X`
23
- ${J(Z)}
23
+ ${G(Y)}
24
24
  `
25
25
  ];
26
26
  }
@@ -50,12 +50,11 @@ const b = (a = class extends K {
50
50
  }
51
51
  updateFocusIndex(t) {
52
52
  (this.possibleValues || []).length != 0 && (this._focusIndex = Math.min(Math.max(0, t), this.possibleValues.length - 1), this._focusOutSuspended = !0, this.requestUpdate(), this.updateComplete.then(() => {
53
- var o;
54
- this._focusOutSuspended = !1, (o = this.shadowRoot.querySelector(".focused")) == null || o.focus();
53
+ this._focusOutSuspended = !1, this.shadowRoot.querySelector(".focused")?.focus();
55
54
  }));
56
55
  }
57
56
  getIndexOfSelection(t) {
58
- return (this.possibleValues || []).length == 0 ? -1 : this.possibleValues.map((i) => T(i) ? i.id : i).indexOf(t);
57
+ return (this.possibleValues || []).length == 0 ? -1 : this.possibleValues.map((r) => H(r) ? r.id : r).indexOf(t);
59
58
  }
60
59
  disconnectedCallback() {
61
60
  super.disconnectedCallback(), this._resizeObserver && (this._resizeObserver.disconnect(), this._resizeObserver = null);
@@ -68,65 +67,64 @@ const b = (a = class extends K {
68
67
  }), this._focusIndex = this.getIndexOfSelection(this.value);
69
68
  }
70
69
  render() {
71
- var P;
72
70
  let t = this.offsetWidth;
73
- const o = g`<slot @slotchange=${this.updatePossibleValuesFromOptionElements}></slot>`, i = g`<sd-field-validation-message
71
+ const o = g`<slot @slotchange=${this.updatePossibleValuesFromOptionElements}></slot>`, r = g`<sd-field-validation-message
74
72
  class="validation-message"
75
73
  .message=${this.validationMessage}
76
74
  .icon=${this.validationIconSrc}
77
75
  .level=${this.validationLevel}
78
76
  >
79
- </sd-field-validation-message>`, r = g`${o}${i}`;
77
+ </sd-field-validation-message>`, a = g`${o}${r}`;
80
78
  if ((this._possibleValues || []).length === 0)
81
- return r;
82
- const s = this._possibleValues.map((e, d) => T(e) ? {
79
+ return a;
80
+ const s = this._possibleValues.map((e, d) => H(e) ? {
83
81
  ...e,
84
82
  index: d
85
83
  } : {
86
84
  id: e,
87
85
  label: String(e),
88
86
  index: d
89
- }), p = {
87
+ }), f = {
90
88
  label: "...",
91
89
  id: "placeholder1",
92
90
  index: -2,
93
91
  firstHiddenIndex: 0
94
- }, D = {
92
+ }, V = {
95
93
  label: "...",
96
94
  id: "placeholder2",
97
95
  index: s.length,
98
96
  firstHiddenIndex: s.length
99
- }, E = 80, C = 48;
97
+ }, D = 80, z = 48;
100
98
  let u = [], m = [];
101
- if (t / E >= s.length || s.length <= 2)
99
+ if (t / D >= s.length || s.length <= 2)
102
100
  m = [...s], u = [...s];
103
101
  else {
104
- const e = () => Math.max(1, Math.floor(t / E)), d = () => {
102
+ const e = () => Math.max(1, Math.floor(t / D)), d = () => {
105
103
  t = this.offsetWidth;
106
- }, n = (k) => {
107
- const G = Math.max(0, k);
108
- let V = 0, L, R, v, w, q, H, _;
104
+ }, n = ($) => {
105
+ const B = Math.max(0, $);
106
+ let k = 0, A, F, v, w, L, R, _;
109
107
  do
110
- q = v, H = w, V = e(), v = Math.max(0, Math.min(Math.ceil(G - V / 2), s.length - V)), w = v + V, _ = !1, v > 0 && !L && (t -= C, L = !0, _ = !0), !_ && w < s.length && !R && (t -= C, R = !0, _ = !0);
111
- while (_ || q != v || H != w);
108
+ L = v, R = w, k = e(), v = Math.max(0, Math.min(Math.ceil(B - k / 2), s.length - k)), w = v + k, _ = !1, v > 0 && !A && (t -= z, A = !0, _ = !0), !_ && w < s.length && !F && (t -= z, F = !0, _ = !0);
109
+ while (_ || L != v || R != w);
112
110
  return { start: v, end: w };
113
111
  };
114
112
  let { start: x, end: h } = n(this._focusIndex);
115
113
  if (this._focusIndex > -1 && h - x >= 2 && h <= this._focusIndex + 1 && h < s.length) {
116
114
  d();
117
- const k = n(this._focusIndex + 1);
118
- x = k.start, h = k.end;
115
+ const $ = n(this._focusIndex + 1);
116
+ x = $.start, h = $.end;
119
117
  }
120
- const y = s.slice(x, h), A = x > 0 ? [p] : [], F = h < s.length ? [D] : [];
121
- D.firstHiddenIndex = h, m = [...A, ...y, ...F], u = [...A, ...s, ...F];
118
+ const y = s.slice(x, h), M = x > 0 ? [f] : [], P = h < s.length ? [V] : [];
119
+ V.firstHiddenIndex = h, m = [...M, ...y, ...P], u = [...M, ...s, ...P];
122
120
  }
123
- const f = this._value ? (P = u.find((e) => e.id === this._value)) == null ? void 0 : P.index : -1, c = (e) => e == p || e == D, U = (e) => e.index == this._focusIndex, M = (e) => !c(e) && f != null && e.index === f, W = (e) => c(e) ? e.firstHiddenIndex <= f : e.index < f, j = (e) => {
121
+ const p = this._value ? u.find((e) => e.id === this._value)?.index : -1, c = (e) => e == f || e == V, E = (e) => e.index == this._focusIndex, C = (e) => !c(e) && p != null && e.index === p, K = (e) => c(e) ? e.firstHiddenIndex <= p : e.index < p, T = (e) => {
124
122
  const d = m.indexOf(e) == -1;
125
123
  let n = "section";
126
- return f != null ? M(e) ? n += " selected" : W(e) ? n += " active" : n += " inactive" : n += " inactive", c(e) && (n += " placeholder"), U(e) && (n += " focused"), d && (n += " hidden"), n;
124
+ return p != null ? C(e) ? n += " selected" : K(e) ? n += " active" : n += " inactive" : n += " inactive", c(e) && (n += " placeholder"), E(e) && (n += " focused"), d && (n += " hidden"), n;
127
125
  };
128
126
  this._renderedItems = m.filter((e) => !c(e));
129
- const N = (e) => {
127
+ const W = (e) => {
130
128
  const d = () => {
131
129
  if (c(e)) {
132
130
  e.index < 0 ? this.focusSibling(-this._renderedItems.length) : this.focusSibling(this._renderedItems.length);
@@ -141,13 +139,13 @@ const b = (a = class extends K {
141
139
  id="${I(!c(e) && e.index ? "stage-option-" + e.index : void 0)}"
142
140
  aria-hidden="${I(c(e) ? !0 : void 0)}"
143
141
  aria-selected=${I(
144
- this._readonly || c(e) ? void 0 : M(e) ? "true" : "false"
142
+ this._readonly || c(e) ? void 0 : C(e) ? "true" : "false"
145
143
  )}
146
- tabindex="${U(e) ? 0 : -1}"
144
+ tabindex="${E(e) ? 0 : -1}"
147
145
  @keydown="${(y) => this.onKeyDown(y)}"
148
146
  @keyup="${(y) => this.onKeyUp(y, () => d())}"
149
147
  @click="${() => d()}"
150
- class="${j(e)}"
148
+ class="${T(e)}"
151
149
  >
152
150
  <div class="content" title="${e.label}">
153
151
  <div class="index" aria-hidden="true">${c(e) ? "" : e.index + 1}</div>
@@ -156,21 +154,21 @@ const b = (a = class extends K {
156
154
  <div class="arrow"></div>
157
155
  </div>
158
156
  `;
159
- }, z = u.find((e) => e.index == f), $ = u.find((e) => e.index == this._focusIndex), B = g`<div
157
+ }, j = u.find((e) => e.index == p), U = u.find((e) => e.index == this._focusIndex), N = g`<div
160
158
  class="sections"
161
159
  role="listbox"
162
- aria-activedescendant="${I($ != null && $.index ? "stage-option-" + $.index : void 0)}"
160
+ aria-activedescendant="${I(U?.index ? "stage-option-" + U.index : void 0)}"
163
161
  aria-orientation="horizontal"
164
- aria-valuenow=${I(z == null ? void 0 : z.label)}
162
+ aria-valuenow=${I(j?.label)}
165
163
  ?aria-readonly="${this._readonly}"
166
164
  >
167
- ${Q(
165
+ ${J(
168
166
  u,
169
167
  (e) => e.id,
170
- (e) => N(e)
168
+ (e) => W(e)
171
169
  )}
172
170
  </div>`;
173
- return g`${B}${r}`;
171
+ return g`${N}${a}`;
174
172
  }
175
173
  onKeyDown(t) {
176
174
  this.isSpaceOrEnter(t) && (this._isSpaceOrEnterKeyDown = !0, t.preventDefault());
@@ -198,12 +196,12 @@ const b = (a = class extends K {
198
196
  fireValueChange() {
199
197
  this.dispatchEvent(new CustomEvent("value-change", { detail: { value: this.value } }));
200
198
  }
201
- }, a.ID = "sd-stage", a.ensureDefined = () => {
202
- customElements.get(a.ID) || customElements.define(a.ID, a);
203
- }, a.shadowRootOptions = {
204
- ...K.shadowRootOptions,
199
+ }, i.ID = "sd-stage", i.ensureDefined = () => {
200
+ customElements.get(i.ID) || customElements.define(i.ID, i);
201
+ }, i.shadowRootOptions = {
202
+ ...q.shadowRootOptions,
205
203
  delegatesFocus: !0
206
- }, a);
204
+ }, i);
207
205
  O([
208
206
  S({ type: String })
209
207
  ], b.prototype, "validationMessage", 2);
@@ -211,7 +209,7 @@ O([
211
209
  S({ type: String })
212
210
  ], b.prototype, "validationIconSrc", 2);
213
211
  O([
214
- S({ type: Y, reflect: !0 })
212
+ S({ type: Q, reflect: !0 })
215
213
  ], b.prototype, "validationLevel", 2);
216
214
  O([
217
215
  S({
@@ -226,9 +224,9 @@ O([
226
224
  O([
227
225
  S({ type: Boolean, attribute: !0, reflect: !0 })
228
226
  ], b.prototype, "readonly", 1);
229
- let oe = b;
230
- oe.ensureDefined();
227
+ let te = b;
228
+ te.ensureDefined();
231
229
  export {
232
- oe as Stage
230
+ te as Stage
233
231
  };
234
232
  //# sourceMappingURL=stage.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"stage.mjs","sources":["../stage.ts"],"sourcesContent":["import { LitElement, html, unsafeCSS, TemplateResult, PropertyValues, css } from \"lit\";\nimport { property } from \"lit/decorators/property.js\";\nimport { repeat } from \"lit/directives/repeat.js\";\nimport { ifDefined } from \"lit/directives/if-defined.js\";\n\nimport { ValidationLevel } from \"@cas-smartdesign/field-validation-message\";\n\ndeclare global {\n interface HTMLElementTagNameMap {\n [Stage.ID]: Stage;\n }\n}\n\nimport style from \"./stage.scss?inline\";\n\nexport type ISelectionModelId = string | number;\n\nexport interface ISelectionModel {\n id: ISelectionModelId;\n label: string;\n}\n\nexport type SelectionModel = ISelectionModel | ISelectionModelId;\n\ninterface InternalSelectionModel extends ISelectionModel {\n index?: number;\n}\n\ninterface PlaceholderModel extends InternalSelectionModel {\n firstHiddenIndex: number;\n}\n\nfunction isSelectionModel(value: SelectionModel): value is ISelectionModel {\n return (value as ISelectionModel).label != null && (value as ISelectionModel).id != null;\n}\n\nexport interface IValueChangeEvent {\n value: ISelectionModelId;\n}\n\nexport interface CustomEventMap extends HTMLElementEventMap {\n \"value-change\": CustomEvent<IValueChangeEvent>;\n}\n\nexport interface Stage {\n addEventListener<K extends keyof CustomEventMap>(\n event: K,\n listener: ((this: this, ev: CustomEventMap[K]) => unknown) | null,\n options?: AddEventListenerOptions | boolean,\n ): void;\n addEventListener(\n type: string,\n callback: EventListenerOrEventListenerObject | null,\n options?: AddEventListenerOptions | boolean,\n ): void;\n removeEventListener<K extends keyof CustomEventMap>(\n type: K,\n listener: (this: this, ev: CustomEventMap[K]) => unknown,\n options?: boolean | EventListenerOptions,\n ): void;\n removeEventListener(\n type: string,\n listener: EventListenerOrEventListenerObject,\n options?: boolean | EventListenerOptions,\n ): void;\n dispatchEvent<EventType extends CustomEventMap[keyof CustomEventMap]>(event: EventType): boolean;\n}\nexport class Stage extends LitElement {\n public static readonly ID = \"sd-stage\";\n\n public static ensureDefined = (): void => {\n if (!customElements.get(Stage.ID)) {\n customElements.define(Stage.ID, Stage);\n }\n };\n\n private _value: ISelectionModelId;\n private _possibleValues: SelectionModel[];\n private _renderedItems: SelectionModel[];\n private _readonly: boolean;\n private _resizeObserver: ResizeObserver;\n private _isSpaceOrEnterKeyDown = false;\n private _focusIndex = -1;\n private _focusOutSuspended = false;\n\n static get styles() {\n return [\n css`\n ${unsafeCSS(style)}\n `,\n ];\n }\n\n @property({ type: String })\n public validationMessage: string;\n @property({ type: String })\n public validationIconSrc: string;\n @property({ type: ValidationLevel, reflect: true })\n public validationLevel: ValidationLevel;\n\n @property({\n reflect: true,\n attribute: true,\n converter: {\n fromAttribute: (value: string | number) => value,\n toAttribute: (value: ISelectionModelId): string | number => value,\n },\n })\n get value(): ISelectionModelId {\n return this._value;\n }\n\n set value(value: ISelectionModelId) {\n if (this._value !== value) {\n this._value = value;\n this._focusIndex = this.getIndexOfSelection(this.value);\n this.requestUpdate();\n }\n }\n\n @property({ type: Boolean, attribute: true, reflect: true })\n get readonly(): boolean {\n return this._readonly;\n }\n\n set readonly(readonly: boolean) {\n this._readonly = readonly;\n this.classList.remove(\"readonly\");\n if (this._readonly) {\n this.classList.add(\"readonly\");\n }\n this.requestUpdate(\"readonly\");\n }\n\n get possibleValues(): SelectionModel[] {\n return this._possibleValues;\n }\n\n set possibleValues(possibleValues: SelectionModel[]) {\n this._possibleValues = possibleValues;\n this.requestUpdate();\n }\n\n static shadowRootOptions: ShadowRootInit = {\n ...LitElement.shadowRootOptions,\n delegatesFocus: true,\n };\n\n connectedCallback(): void {\n super.connectedCallback();\n this._resizeObserver = new ResizeObserver(this.requestUpdate.bind(this));\n this._resizeObserver.observe(this);\n }\n\n private focusSibling(offset: number): void {\n this.updateFocusIndex(this._focusIndex + offset);\n }\n\n private updateFocusIndex(index: number) {\n if ((this.possibleValues || []).length == 0) {\n return;\n }\n this._focusIndex = Math.min(Math.max(0, index), this.possibleValues.length - 1);\n this._focusOutSuspended = true;\n this.requestUpdate();\n this.updateComplete.then(() => {\n this._focusOutSuspended = false;\n (this.shadowRoot.querySelector(\".focused\") as HTMLElement)?.focus();\n });\n }\n\n private getIndexOfSelection(item: ISelectionModelId) {\n if ((this.possibleValues || []).length == 0) {\n return -1;\n }\n const index = this.possibleValues.map((p) => (isSelectionModel(p) ? p.id : p)).indexOf(item);\n return index;\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback();\n if (this._resizeObserver) {\n this._resizeObserver.disconnect();\n this._resizeObserver = null;\n }\n }\n\n firstUpdated(_changedProperties: PropertyValues): void {\n super.firstUpdated(_changedProperties);\n this.updatePossibleValuesFromOptionElements();\n this.addEventListener(\"keydown\", (e) => {\n if (e.key == \"ArrowLeft\" || e.key == \"ArrowUp\") {\n this.focusSibling(-1);\n e.preventDefault();\n } else if (e.key == \"ArrowRight\" || e.key == \"ArrowDown\") {\n this.focusSibling(1);\n e.preventDefault();\n } else if (e.key == \"PageUp\") {\n this.focusSibling(-this._renderedItems.length);\n e.preventDefault();\n } else if (e.key == \"PageDown\") {\n this.focusSibling(this._renderedItems.length);\n e.preventDefault();\n }\n });\n this.addEventListener(\"focusout\", () => {\n if (this._focusOutSuspended) {\n return;\n }\n this._focusIndex = this.getIndexOfSelection(this.value);\n this.requestUpdate();\n });\n this._focusIndex = this.getIndexOfSelection(this.value);\n }\n\n render(): TemplateResult {\n let availableWidth = this.offsetWidth;\n\n const optionsSlot = html`<slot @slotchange=${this.updatePossibleValuesFromOptionElements}></slot>`;\n const validation = html`<sd-field-validation-message\n class=\"validation-message\"\n .message=${this.validationMessage}\n .icon=${this.validationIconSrc}\n .level=${this.validationLevel}\n >\n </sd-field-validation-message>`;\n\n const baseTemplate = html`${optionsSlot}${validation}`;\n\n if ((this._possibleValues || []).length === 0) {\n return baseTemplate;\n }\n\n const values: InternalSelectionModel[] = this._possibleValues.map((p, i) => {\n if (isSelectionModel(p)) {\n return {\n ...p,\n index: i,\n };\n } else {\n return {\n id: p,\n label: String(p),\n index: i,\n };\n }\n });\n\n const placeholder1: PlaceholderModel = {\n label: \"...\",\n id: \"placeholder1\",\n index: -2,\n firstHiddenIndex: 0,\n };\n const placeholder2: PlaceholderModel = {\n label: \"...\",\n id: \"placeholder2\",\n index: values.length,\n firstHiddenIndex: values.length,\n };\n\n const minItemWidth = 80;\n const placeholderWidth = 48;\n\n let allItems: InternalSelectionModel[] = [];\n let valuesToRender: InternalSelectionModel[] = [];\n const allItemsFit = availableWidth / minItemWidth >= values.length;\n\n if (allItemsFit || values.length <= 2) {\n valuesToRender = [...values];\n allItems = [...values];\n } else {\n const computeMaxVisibleItems = () => Math.max(1, Math.floor(availableWidth / minItemWidth));\n\n const resetComputationVariables = () => {\n availableWidth = this.offsetWidth;\n };\n\n const computeVisibleRange = (focusIndex: number) => {\n const center = Math.max(0, focusIndex);\n let visibleItems = 0;\n let needsHead;\n let needsTail;\n\n let start;\n let end;\n let oldStart;\n let oldEnd;\n let headOrTailChangedInThisRound;\n\n do {\n oldStart = start;\n oldEnd = end;\n\n visibleItems = computeMaxVisibleItems();\n\n // determine indexes for the visible item slice\n start = Math.max(0, Math.min(Math.ceil(center - visibleItems / 2), values.length - visibleItems));\n end = start + visibleItems;\n\n headOrTailChangedInThisRound = false;\n if (start > 0 && !needsHead) {\n availableWidth -= placeholderWidth;\n needsHead = true;\n headOrTailChangedInThisRound = true;\n }\n if (!headOrTailChangedInThisRound && end < values.length && !needsTail) {\n availableWidth -= placeholderWidth;\n needsTail = true;\n headOrTailChangedInThisRound = true;\n }\n } while (headOrTailChangedInThisRound || oldStart != start || oldEnd != end);\n return { start, end };\n };\n\n let { start, end } = computeVisibleRange(this._focusIndex);\n\n // show next item if possible\n if (this._focusIndex > -1 && end - start >= 2 && end <= this._focusIndex + 1 && end < values.length) {\n resetComputationVariables();\n const updatedRange = computeVisibleRange(this._focusIndex + 1);\n start = updatedRange.start;\n end = updatedRange.end;\n }\n\n const centerItems = values.slice(start, end);\n\n const placeholderHead = start > 0 ? [placeholder1] : [];\n const placeholderTail = end < values.length ? [placeholder2] : [];\n placeholder2.firstHiddenIndex = end;\n valuesToRender = [...placeholderHead, ...centerItems, ...placeholderTail];\n allItems = [...placeholderHead, ...values, ...placeholderTail];\n }\n\n const selectedIndex: number = this._value ? allItems.find((p) => p.id === this._value)?.index : -1;\n const isPlaceholder = (item: InternalSelectionModel): item is PlaceholderModel =>\n item == placeholder1 || item == placeholder2;\n const isFocused = (item: InternalSelectionModel) => item.index == this._focusIndex;\n const isSelected = (item: InternalSelectionModel) => {\n return !isPlaceholder(item) && selectedIndex != null && item.index === selectedIndex;\n };\n const isActive = (item: InternalSelectionModel) =>\n isPlaceholder(item) ? item.firstHiddenIndex <= selectedIndex : item.index < selectedIndex;\n const getClassName = (item: InternalSelectionModel) => {\n const hidden = valuesToRender.indexOf(item) == -1;\n let styleName = \"section\";\n\n if (selectedIndex != null) {\n if (isSelected(item)) {\n styleName += \" selected\";\n } else if (isActive(item)) {\n styleName += \" active\";\n } else {\n styleName += \" inactive\";\n }\n } else {\n styleName += \" inactive\";\n }\n\n if (isPlaceholder(item)) {\n styleName += \" placeholder\";\n }\n\n if (isFocused(item)) {\n styleName += \" focused\";\n }\n if (hidden) {\n styleName += \" hidden\";\n }\n return styleName;\n };\n this._renderedItems = valuesToRender.filter((p) => !isPlaceholder(p));\n const section = (p: InternalSelectionModel) => {\n const onClick = () => {\n if (isPlaceholder(p)) {\n if (p.index < 0) {\n this.focusSibling(-this._renderedItems.length);\n } else {\n this.focusSibling(this._renderedItems.length);\n }\n return;\n }\n if (this._readonly) {\n return;\n }\n\n this.value = p.id;\n this.fireValueChange();\n };\n const index = allItems.indexOf(p);\n const visuallyHidden = valuesToRender.indexOf(p) == -1;\n const zIndex = visuallyHidden ? -1 : allItems.length - index;\n\n return html`\n <div\n role=\"option\"\n style=\"z-index: ${zIndex}\"\n id=\"${ifDefined(!isPlaceholder(p) && p.index ? \"stage-option-\" + p.index : undefined)}\"\n aria-hidden=\"${ifDefined(isPlaceholder(p) ? true : undefined)}\"\n aria-selected=${ifDefined(\n this._readonly || isPlaceholder(p) ? undefined : isSelected(p) ? \"true\" : \"false\",\n )}\n tabindex=\"${isFocused(p) ? 0 : -1}\"\n @keydown=\"${(e) => this.onKeyDown(e)}\"\n @keyup=\"${(e) => this.onKeyUp(e, () => onClick())}\"\n @click=\"${() => onClick()}\"\n class=\"${getClassName(p)}\"\n >\n <div class=\"content\" title=\"${p.label}\">\n <div class=\"index\" aria-hidden=\"true\">${isPlaceholder(p) ? \"\" : p.index + 1}</div>\n <div class=\"label\">${p.label}</div>\n </div>\n <div class=\"arrow\"></div>\n </div>\n `;\n };\n const selected = allItems.find((p) => p.index == selectedIndex);\n const focused = allItems.find((p) => p.index == this._focusIndex);\n const sections = html`<div\n class=\"sections\"\n role=\"listbox\"\n aria-activedescendant=\"${ifDefined(focused?.index ? \"stage-option-\" + focused.index : undefined)}\"\n aria-orientation=\"horizontal\"\n aria-valuenow=${ifDefined(selected?.label)}\n ?aria-readonly=\"${this._readonly}\"\n >\n ${repeat(\n allItems,\n (p) => p.id,\n (p) => section(p),\n )}\n </div>`;\n\n return html`${sections}${baseTemplate}`;\n }\n\n private onKeyDown(e: KeyboardEvent): void {\n if (this.isSpaceOrEnter(e)) {\n this._isSpaceOrEnterKeyDown = true;\n e.preventDefault(); // prevent potential scroll-down triggered by space\n }\n }\n\n private onKeyUp(e: KeyboardEvent, onClick: VoidFunction): void {\n if (this.isSpaceOrEnter(e) && this._isSpaceOrEnterKeyDown == true) {\n this._isSpaceOrEnterKeyDown = false;\n onClick();\n }\n }\n\n private updatePossibleValuesFromOptionElements(): void {\n const options: HTMLOptionElement[] = Array.prototype.map.call(\n this.querySelectorAll(\"option\"),\n (p) => p as HTMLOptionElement,\n );\n this.possibleValues =\n options.length > 0 ? options.map((p) => ({ id: p.value, label: p.innerText })) : this.possibleValues;\n }\n\n private isSpaceOrEnter(event: KeyboardEvent): boolean {\n switch (event.key) {\n case \" \":\n case \"Space\":\n case \"Enter\":\n return true;\n default:\n return false;\n }\n }\n\n private fireValueChange(): void {\n this.dispatchEvent(new CustomEvent<IValueChangeEvent>(`value-change`, { detail: { value: this.value } }));\n }\n}\n\nStage.ensureDefined();\n"],"names":["isSelectionModel","value","_Stage","_a","LitElement","css","unsafeCSS","style","readonly","possibleValues","offset","index","item","p","_changedProperties","e","availableWidth","optionsSlot","html","validation","baseTemplate","values","i","placeholder1","placeholder2","minItemWidth","placeholderWidth","allItems","valuesToRender","computeMaxVisibleItems","resetComputationVariables","computeVisibleRange","focusIndex","center","visibleItems","needsHead","needsTail","start","end","oldStart","oldEnd","headOrTailChangedInThisRound","updatedRange","centerItems","placeholderHead","placeholderTail","selectedIndex","isPlaceholder","isFocused","isSelected","isActive","getClassName","hidden","styleName","section","onClick","zIndex","ifDefined","selected","focused","sections","repeat","options","event","__decorateClass","property","ValidationLevel","Stage"],"mappings":";;;;;;;;;;;AAgCA,SAASA,EAAiBC,GAAiD;AACvE,SAAQA,EAA0B,SAAS,QAASA,EAA0B,MAAM;AACxF;;AAiCO,MAAMC,KAANC,IAAA,cAAoBC,EAAW;AAAA,EAA/B,cAAA;AAAA,UAAA,GAAA,SAAA,GAcH,KAAQ,yBAAyB,IACjC,KAAQ,cAAc,IACtB,KAAQ,qBAAqB;AAAA,EAAA;AAAA,EAE7B,WAAW,SAAS;AACT,WAAA;AAAA,MACHC;AAAA,kBACMC,EAAUC,CAAK,CAAC;AAAA;AAAA,IAAA;AAAA,EAG9B;AAAA,EAiBA,IAAI,QAA2B;AAC3B,WAAO,KAAK;AAAA,EAChB;AAAA,EAEA,IAAI,MAAMN,GAA0B;AAC5B,IAAA,KAAK,WAAWA,MAChB,KAAK,SAASA,GACd,KAAK,cAAc,KAAK,oBAAoB,KAAK,KAAK,GACtD,KAAK,cAAc;AAAA,EAE3B;AAAA,EAGA,IAAI,WAAoB;AACpB,WAAO,KAAK;AAAA,EAChB;AAAA,EAEA,IAAI,SAASO,GAAmB;AAC5B,SAAK,YAAYA,GACZ,KA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b,eAAA,OAAOA,EAAM,IAAIA,CAAK;AACzC,GAsEJA,EAAO,oBAAoC;AAAA,EACvC,GAAGC,EAAW;AAAA,EACd,gBAAgB;AAAA,GA9EjBD;AA2BI6D,EAAA;AAAA,EADNC,EAAS,EAAE,MAAM,QAAQ;AAAA,GA1BjB/D,EA2BF,WAAA,qBAAA,CAAA;AAEA8D,EAAA;AAAA,EADNC,EAAS,EAAE,MAAM,QAAQ;AAAA,GA5BjB/D,EA6BF,WAAA,qBAAA,CAAA;AAEA8D,EAAA;AAAA,EADNC,EAAS,EAAE,MAAMC,GAAiB,SAAS,IAAM;AAAA,GA9BzChE,EA+BF,WAAA,mBAAA,CAAA;AAUH8D,EAAA;AAAA,EARHC,EAAS;AAAA,IACN,SAAS;AAAA,IACT,WAAW;AAAA,IACX,WAAW;AAAA,MACP,eAAe,CAAChE,MAA2BA;AAAA,MAC3C,aAAa,CAACA,MAA8CA;AAAA,IAChE;AAAA,EAAA,CACH;AAAA,GAxCQC,EAyCL,WAAA,SAAA,CAAA;AAaA8D,EAAA;AAAA,EADHC,EAAS,EAAE,MAAM,SAAS,WAAW,IAAM,SAAS,IAAM;AAAA,GArDlD/D,EAsDL,WAAA,YAAA,CAAA;AAtDD,IAAMiE,KAANjE;AAwZPiE,GAAM,cAAc;"}
1
+ {"version":3,"file":"stage.mjs","sources":["../stage.ts"],"sourcesContent":["import { LitElement, html, unsafeCSS, TemplateResult, PropertyValues, css } from \"lit\";\nimport { property } from \"lit/decorators/property.js\";\nimport { repeat } from \"lit/directives/repeat.js\";\nimport { ifDefined } from \"lit/directives/if-defined.js\";\n\nimport { ValidationLevel } from \"@cas-smartdesign/field-validation-message\";\n\ndeclare global {\n interface HTMLElementTagNameMap {\n [Stage.ID]: Stage;\n }\n}\n\nimport style from \"./stage.scss?inline\";\n\nexport type ISelectionModelId = string | number;\n\nexport interface ISelectionModel {\n id: ISelectionModelId;\n label: string;\n}\n\nexport type SelectionModel = ISelectionModel | ISelectionModelId;\n\ninterface InternalSelectionModel extends ISelectionModel {\n index?: number;\n}\n\ninterface PlaceholderModel extends InternalSelectionModel {\n firstHiddenIndex: number;\n}\n\nfunction isSelectionModel(value: SelectionModel): value is ISelectionModel {\n return (value as ISelectionModel).label != null && (value as ISelectionModel).id != null;\n}\n\nexport interface IValueChangeEvent {\n value: ISelectionModelId;\n}\n\nexport interface CustomEventMap extends HTMLElementEventMap {\n \"value-change\": CustomEvent<IValueChangeEvent>;\n}\n\nexport interface Stage {\n addEventListener<K extends keyof CustomEventMap>(\n event: K,\n listener: ((this: this, ev: CustomEventMap[K]) => unknown) | null,\n options?: AddEventListenerOptions | boolean,\n ): void;\n addEventListener(\n type: string,\n callback: EventListenerOrEventListenerObject | null,\n options?: AddEventListenerOptions | boolean,\n ): void;\n removeEventListener<K extends keyof CustomEventMap>(\n type: K,\n listener: (this: this, ev: CustomEventMap[K]) => unknown,\n options?: boolean | EventListenerOptions,\n ): void;\n removeEventListener(\n type: string,\n listener: EventListenerOrEventListenerObject,\n options?: boolean | EventListenerOptions,\n ): void;\n dispatchEvent<EventType extends CustomEventMap[keyof CustomEventMap]>(event: EventType): boolean;\n}\nexport class Stage extends LitElement {\n public static readonly ID = \"sd-stage\";\n\n public static ensureDefined = (): void => {\n if (!customElements.get(Stage.ID)) {\n customElements.define(Stage.ID, Stage);\n }\n };\n\n private _value: ISelectionModelId;\n private _possibleValues: SelectionModel[];\n private _renderedItems: SelectionModel[];\n private _readonly: boolean;\n private _resizeObserver: ResizeObserver;\n private _isSpaceOrEnterKeyDown = false;\n private _focusIndex = -1;\n private _focusOutSuspended = false;\n\n static get styles() {\n return [\n css`\n ${unsafeCSS(style)}\n `,\n ];\n }\n\n @property({ type: String })\n public validationMessage: string;\n @property({ type: String })\n public validationIconSrc: string;\n @property({ type: ValidationLevel, reflect: true })\n public validationLevel: ValidationLevel;\n\n @property({\n reflect: true,\n attribute: true,\n converter: {\n fromAttribute: (value: string | number) => value,\n toAttribute: (value: ISelectionModelId): string | number => value,\n },\n })\n get value(): ISelectionModelId {\n return this._value;\n }\n\n set value(value: ISelectionModelId) {\n if (this._value !== value) {\n this._value = value;\n this._focusIndex = this.getIndexOfSelection(this.value);\n this.requestUpdate();\n }\n }\n\n @property({ type: Boolean, attribute: true, reflect: true })\n get readonly(): boolean {\n return this._readonly;\n }\n\n set readonly(readonly: boolean) {\n this._readonly = readonly;\n this.classList.remove(\"readonly\");\n if (this._readonly) {\n this.classList.add(\"readonly\");\n }\n this.requestUpdate(\"readonly\");\n }\n\n get possibleValues(): SelectionModel[] {\n return this._possibleValues;\n }\n\n set possibleValues(possibleValues: SelectionModel[]) {\n this._possibleValues = possibleValues;\n this.requestUpdate();\n }\n\n static shadowRootOptions: ShadowRootInit = {\n ...LitElement.shadowRootOptions,\n delegatesFocus: true,\n };\n\n connectedCallback(): void {\n super.connectedCallback();\n this._resizeObserver = new ResizeObserver(this.requestUpdate.bind(this));\n this._resizeObserver.observe(this);\n }\n\n private focusSibling(offset: number): void {\n this.updateFocusIndex(this._focusIndex + offset);\n }\n\n private updateFocusIndex(index: number) {\n if ((this.possibleValues || []).length == 0) {\n return;\n }\n this._focusIndex = Math.min(Math.max(0, index), this.possibleValues.length - 1);\n this._focusOutSuspended = true;\n this.requestUpdate();\n this.updateComplete.then(() => {\n this._focusOutSuspended = false;\n (this.shadowRoot.querySelector(\".focused\") as HTMLElement)?.focus();\n });\n }\n\n private getIndexOfSelection(item: ISelectionModelId) {\n if ((this.possibleValues || []).length == 0) {\n return -1;\n }\n const index = this.possibleValues.map((p) => (isSelectionModel(p) ? p.id : p)).indexOf(item);\n return index;\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback();\n if (this._resizeObserver) {\n this._resizeObserver.disconnect();\n this._resizeObserver = null;\n }\n }\n\n firstUpdated(_changedProperties: PropertyValues): void {\n super.firstUpdated(_changedProperties);\n this.updatePossibleValuesFromOptionElements();\n this.addEventListener(\"keydown\", (e) => {\n if (e.key == \"ArrowLeft\" || e.key == \"ArrowUp\") {\n this.focusSibling(-1);\n e.preventDefault();\n } else if (e.key == \"ArrowRight\" || e.key == \"ArrowDown\") {\n this.focusSibling(1);\n e.preventDefault();\n } else if (e.key == \"PageUp\") {\n this.focusSibling(-this._renderedItems.length);\n e.preventDefault();\n } else if (e.key == \"PageDown\") {\n this.focusSibling(this._renderedItems.length);\n e.preventDefault();\n }\n });\n this.addEventListener(\"focusout\", () => {\n if (this._focusOutSuspended) {\n return;\n }\n this._focusIndex = this.getIndexOfSelection(this.value);\n this.requestUpdate();\n });\n this._focusIndex = this.getIndexOfSelection(this.value);\n }\n\n render(): TemplateResult {\n let availableWidth = this.offsetWidth;\n\n const optionsSlot = html`<slot @slotchange=${this.updatePossibleValuesFromOptionElements}></slot>`;\n const validation = html`<sd-field-validation-message\n class=\"validation-message\"\n .message=${this.validationMessage}\n .icon=${this.validationIconSrc}\n .level=${this.validationLevel}\n >\n </sd-field-validation-message>`;\n\n const baseTemplate = html`${optionsSlot}${validation}`;\n\n if ((this._possibleValues || []).length === 0) {\n return baseTemplate;\n }\n\n const values: InternalSelectionModel[] = this._possibleValues.map((p, i) => {\n if (isSelectionModel(p)) {\n return {\n ...p,\n index: i,\n };\n } else {\n return {\n id: p,\n label: String(p),\n index: i,\n };\n }\n });\n\n const placeholder1: PlaceholderModel = {\n label: \"...\",\n id: \"placeholder1\",\n index: -2,\n firstHiddenIndex: 0,\n };\n const placeholder2: PlaceholderModel = {\n label: \"...\",\n id: \"placeholder2\",\n index: values.length,\n firstHiddenIndex: values.length,\n };\n\n const minItemWidth = 80;\n const placeholderWidth = 48;\n\n let allItems: InternalSelectionModel[] = [];\n let valuesToRender: InternalSelectionModel[] = [];\n const allItemsFit = availableWidth / minItemWidth >= values.length;\n\n if (allItemsFit || values.length <= 2) {\n valuesToRender = [...values];\n allItems = [...values];\n } else {\n const computeMaxVisibleItems = () => Math.max(1, Math.floor(availableWidth / minItemWidth));\n\n const resetComputationVariables = () => {\n availableWidth = this.offsetWidth;\n };\n\n const computeVisibleRange = (focusIndex: number) => {\n const center = Math.max(0, focusIndex);\n let visibleItems = 0;\n let needsHead;\n let needsTail;\n\n let start;\n let end;\n let oldStart;\n let oldEnd;\n let headOrTailChangedInThisRound;\n\n do {\n oldStart = start;\n oldEnd = end;\n\n visibleItems = computeMaxVisibleItems();\n\n // determine indexes for the visible item slice\n start = Math.max(0, Math.min(Math.ceil(center - visibleItems / 2), values.length - visibleItems));\n end = start + visibleItems;\n\n headOrTailChangedInThisRound = false;\n if (start > 0 && !needsHead) {\n availableWidth -= placeholderWidth;\n needsHead = true;\n headOrTailChangedInThisRound = true;\n }\n if (!headOrTailChangedInThisRound && end < values.length && !needsTail) {\n availableWidth -= placeholderWidth;\n needsTail = true;\n headOrTailChangedInThisRound = true;\n }\n } while (headOrTailChangedInThisRound || oldStart != start || oldEnd != end);\n return { start, end };\n };\n\n let { start, end } = computeVisibleRange(this._focusIndex);\n\n // show next item if possible\n if (this._focusIndex > -1 && end - start >= 2 && end <= this._focusIndex + 1 && end < values.length) {\n resetComputationVariables();\n const updatedRange = computeVisibleRange(this._focusIndex + 1);\n start = updatedRange.start;\n end = updatedRange.end;\n }\n\n const centerItems = values.slice(start, end);\n\n const placeholderHead = start > 0 ? [placeholder1] : [];\n const placeholderTail = end < values.length ? [placeholder2] : [];\n placeholder2.firstHiddenIndex = end;\n valuesToRender = [...placeholderHead, ...centerItems, ...placeholderTail];\n allItems = [...placeholderHead, ...values, ...placeholderTail];\n }\n\n const selectedIndex: number = this._value ? allItems.find((p) => p.id === this._value)?.index : -1;\n const isPlaceholder = (item: InternalSelectionModel): item is PlaceholderModel =>\n item == placeholder1 || item == placeholder2;\n const isFocused = (item: InternalSelectionModel) => item.index == this._focusIndex;\n const isSelected = (item: InternalSelectionModel) => {\n return !isPlaceholder(item) && selectedIndex != null && item.index === selectedIndex;\n };\n const isActive = (item: InternalSelectionModel) =>\n isPlaceholder(item) ? item.firstHiddenIndex <= selectedIndex : item.index < selectedIndex;\n const getClassName = (item: InternalSelectionModel) => {\n const hidden = valuesToRender.indexOf(item) == -1;\n let styleName = \"section\";\n\n if (selectedIndex != null) {\n if (isSelected(item)) {\n styleName += \" selected\";\n } else if (isActive(item)) {\n styleName += \" active\";\n } else {\n styleName += \" inactive\";\n }\n } else {\n styleName += \" inactive\";\n }\n\n if (isPlaceholder(item)) {\n styleName += \" placeholder\";\n }\n\n if (isFocused(item)) {\n styleName += \" focused\";\n }\n if (hidden) {\n styleName += \" hidden\";\n }\n return styleName;\n };\n this._renderedItems = valuesToRender.filter((p) => !isPlaceholder(p));\n const section = (p: InternalSelectionModel) => {\n const onClick = () => {\n if (isPlaceholder(p)) {\n if (p.index < 0) {\n this.focusSibling(-this._renderedItems.length);\n } else {\n this.focusSibling(this._renderedItems.length);\n }\n return;\n }\n if (this._readonly) {\n return;\n }\n\n this.value = p.id;\n this.fireValueChange();\n };\n const index = allItems.indexOf(p);\n const visuallyHidden = valuesToRender.indexOf(p) == -1;\n const zIndex = visuallyHidden ? -1 : allItems.length - index;\n\n return html`\n <div\n role=\"option\"\n style=\"z-index: ${zIndex}\"\n id=\"${ifDefined(!isPlaceholder(p) && p.index ? \"stage-option-\" + p.index : undefined)}\"\n aria-hidden=\"${ifDefined(isPlaceholder(p) ? true : undefined)}\"\n aria-selected=${ifDefined(\n this._readonly || isPlaceholder(p) ? undefined : isSelected(p) ? \"true\" : \"false\",\n )}\n tabindex=\"${isFocused(p) ? 0 : -1}\"\n @keydown=\"${(e) => this.onKeyDown(e)}\"\n @keyup=\"${(e) => this.onKeyUp(e, () => onClick())}\"\n @click=\"${() => onClick()}\"\n class=\"${getClassName(p)}\"\n >\n <div class=\"content\" title=\"${p.label}\">\n <div class=\"index\" aria-hidden=\"true\">${isPlaceholder(p) ? \"\" : p.index + 1}</div>\n <div class=\"label\">${p.label}</div>\n </div>\n <div class=\"arrow\"></div>\n </div>\n `;\n };\n const selected = allItems.find((p) => p.index == selectedIndex);\n const focused = allItems.find((p) => p.index == this._focusIndex);\n const sections = html`<div\n class=\"sections\"\n role=\"listbox\"\n aria-activedescendant=\"${ifDefined(focused?.index ? \"stage-option-\" + focused.index : undefined)}\"\n aria-orientation=\"horizontal\"\n aria-valuenow=${ifDefined(selected?.label)}\n ?aria-readonly=\"${this._readonly}\"\n >\n ${repeat(\n allItems,\n (p) => p.id,\n (p) => section(p),\n )}\n </div>`;\n\n return html`${sections}${baseTemplate}`;\n }\n\n private onKeyDown(e: KeyboardEvent): void {\n if (this.isSpaceOrEnter(e)) {\n this._isSpaceOrEnterKeyDown = true;\n e.preventDefault(); // prevent potential scroll-down triggered by space\n }\n }\n\n private onKeyUp(e: KeyboardEvent, onClick: VoidFunction): void {\n if (this.isSpaceOrEnter(e) && this._isSpaceOrEnterKeyDown == true) {\n this._isSpaceOrEnterKeyDown = false;\n onClick();\n }\n }\n\n private updatePossibleValuesFromOptionElements(): void {\n const options: HTMLOptionElement[] = Array.prototype.map.call(\n this.querySelectorAll(\"option\"),\n (p) => p as HTMLOptionElement,\n );\n this.possibleValues =\n options.length > 0 ? options.map((p) => ({ id: p.value, label: p.innerText })) : this.possibleValues;\n }\n\n private isSpaceOrEnter(event: KeyboardEvent): boolean {\n switch (event.key) {\n case \" \":\n case \"Space\":\n case \"Enter\":\n return true;\n default:\n return false;\n }\n }\n\n private fireValueChange(): void {\n this.dispatchEvent(new CustomEvent<IValueChangeEvent>(`value-change`, { detail: { value: this.value } }));\n }\n}\n\nStage.ensureDefined();\n"],"names":["isSelectionModel","value","_Stage","_a","LitElement","css","unsafeCSS","style","readonly","possibleValues","offset","index","item","p","_changedProperties","e","availableWidth","optionsSlot","html","validation","baseTemplate","values","i","placeholder1","placeholder2","minItemWidth","placeholderWidth","allItems","valuesToRender","computeMaxVisibleItems","resetComputationVariables","computeVisibleRange","focusIndex","center","visibleItems","needsHead","needsTail","start","end","oldStart","oldEnd","headOrTailChangedInThisRound","updatedRange","centerItems","placeholderHead","placeholderTail","selectedIndex","isPlaceholder","isFocused","isSelected","isActive","getClassName","hidden","styleName","section","onClick","zIndex","ifDefined","selected","focused","sections","repeat","options","event","__decorateClass","property","ValidationLevel","Stage"],"mappings":";;;;;;;;;;;AAgCA,SAASA,EAAiBC,GAAiD;AACvE,SAAQA,EAA0B,SAAS,QAASA,EAA0B,MAAM;AACxF;;AAiCO,MAAMC,KAANC,IAAA,cAAoBC,EAAW;AAAA,EAA/B,cAAA;AAAA,UAAA,GAAA,SAAA,GAcH,KAAQ,yBAAyB,IACjC,KAAQ,cAAc,IACtB,KAAQ,qBAAqB;AAAA,EAAA;AAAA,EAE7B,WAAW,SAAS;AAChB,WAAO;AAAA,MACHC;AAAA,kBACMC,EAAUC,CAAK,CAAC;AAAA;AAAA,IAAA;AAAA,EAG9B;AAAA,EAiBA,IAAI,QAA2B;AAC3B,WAAO,KAAK;AAAA,EAChB;AAAA,EAEA,IAAI,MAAMN,GAA0B;AAChC,IAAI,KAAK,WAAWA,MAChB,KAAK,SAASA,GACd,KAAK,cAAc,KAAK,oBAAoB,KAAK,KAAK,GACtD,KAAK,cAAA;AAAA,EAEb;AAAA,EAGA,IAAI,WAAoB;AACpB,WAAO,KAAK;AAAA,EAChB;AAAA,EAEA,IAAI,SAASO,GAAmB;AAC5B,SAAK,YAAYA,GACjB,KAAK,UAAU,OAAO,UAAU,GAC5B,KAAK,aACL,KAAK,UAAU,IAAI,UAAU,GAEjC,KAAK,cAAc,UAAU;AAAA,EACjC;AAAA,EAEA,IAAI,iBAAmC;AACnC,WAAO,KAAK;AAAA,EAChB;AAAA,EAEA,IAAI,eAAeC,GAAkC;AACjD,SAAK,kBAAkBA,GACvB,KAAK,cAAA;AAAA,EACT;AAAA,EAOA,oBAA0B;AACtB,UAAM,kBAAA,GACN,KAAK,kBAAkB,IAAI,eAAe,KAAK,cAAc,KAAK,IAAI,CAAC,GACvE,KAAK,gBAAgB,QAAQ,IAAI;AAAA,EACrC;AAAA,EAEQ,aAAaC,GAAsB;AACvC,SAAK,iBAAiB,KAAK,cAAcA,CAAM;AAAA,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