@sbb-esta/lyne-elements-experimental 3.2.0 → 3.3.0
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/custom-elements.json +341 -125
- package/development/seat-reservation/common/mapper/icon-mapper.d.ts.map +1 -1
- package/development/seat-reservation/common/mapper/icon-mapper.js +4 -3
- package/development/seat-reservation/common/mapper/mapper.d.ts +4 -4
- package/development/seat-reservation/common/mapper/mapper.d.ts.map +1 -1
- package/development/seat-reservation/common/mapper/mapper.js +9 -8
- package/development/seat-reservation/common/mapper/seat-reservation-sample-data.d.ts +113 -0
- package/development/seat-reservation/common/mapper/seat-reservation-sample-data.d.ts.map +1 -1
- package/development/seat-reservation/common/mapper/seat-reservation-sample-data.js +20373 -8
- package/development/seat-reservation/common/translations/i18n.d.ts.map +1 -1
- package/development/seat-reservation/common/translations/i18n.js +35 -4
- package/development/seat-reservation/common/types.d.ts +10 -3
- package/development/seat-reservation/common/types.d.ts.map +1 -1
- package/development/seat-reservation/seat-reservation/seat-reservation-base-element.d.ts +20 -14
- package/development/seat-reservation/seat-reservation/seat-reservation-base-element.d.ts.map +1 -1
- package/development/seat-reservation/seat-reservation/seat-reservation-base-element.js +129 -79
- package/development/seat-reservation/seat-reservation/seat-reservation.component.d.ts +11 -10
- package/development/seat-reservation/seat-reservation/seat-reservation.component.d.ts.map +1 -1
- package/development/seat-reservation/seat-reservation/seat-reservation.component.js +208 -132
- package/development/seat-reservation/seat-reservation-area/seat-reservation-area.component.js +1 -1
- package/development/seat-reservation/seat-reservation-graphic/seat-reservation-graphic.component.js +4 -4
- package/development/seat-reservation/seat-reservation-navigation-coach/seat-reservation-navigation-coach.component.js +28 -28
- package/development/seat-reservation/seat-reservation-place-control/seat-reservation-place-control.component.d.ts +2 -0
- package/development/seat-reservation/seat-reservation-place-control/seat-reservation-place-control.component.d.ts.map +1 -1
- package/development/seat-reservation/seat-reservation-place-control/seat-reservation-place-control.component.js +22 -5
- package/package.json +2 -2
- package/seat-reservation/common/mapper/icon-mapper.d.ts.map +1 -1
- package/seat-reservation/common/mapper/icon-mapper.js +3 -2
- package/seat-reservation/common/mapper/mapper.d.ts +4 -4
- package/seat-reservation/common/mapper/mapper.d.ts.map +1 -1
- package/seat-reservation/common/mapper/mapper.js +29 -28
- package/seat-reservation/common/mapper/seat-reservation-sample-data.d.ts +113 -0
- package/seat-reservation/common/mapper/seat-reservation-sample-data.d.ts.map +1 -1
- package/seat-reservation/common/mapper/seat-reservation-sample-data.js +20375 -11
- package/seat-reservation/common/translations/i18n.d.ts.map +1 -1
- package/seat-reservation/common/translations/i18n.js +34 -3
- package/seat-reservation/common/types.d.ts +10 -3
- package/seat-reservation/common/types.d.ts.map +1 -1
- package/seat-reservation/seat-reservation/seat-reservation-base-element.d.ts +20 -14
- package/seat-reservation/seat-reservation/seat-reservation-base-element.d.ts.map +1 -1
- package/seat-reservation/seat-reservation/seat-reservation-base-element.js +191 -146
- package/seat-reservation/seat-reservation/seat-reservation.component.d.ts +11 -10
- package/seat-reservation/seat-reservation/seat-reservation.component.d.ts.map +1 -1
- package/seat-reservation/seat-reservation/seat-reservation.component.js +211 -188
- package/seat-reservation/seat-reservation-area/seat-reservation-area.component.js +1 -1
- package/seat-reservation/seat-reservation-graphic/seat-reservation-graphic.component.js +1 -1
- package/seat-reservation/seat-reservation-navigation-coach/seat-reservation-navigation-coach.component.js +74 -74
- package/seat-reservation/seat-reservation-place-control/seat-reservation-place-control.component.d.ts +2 -0
- package/seat-reservation/seat-reservation-place-control/seat-reservation-place-control.component.d.ts.map +1 -1
- package/seat-reservation/seat-reservation-place-control/seat-reservation-place-control.component.js +64 -53
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
var
|
|
2
|
-
throw TypeError(
|
|
1
|
+
var ue = (h) => {
|
|
2
|
+
throw TypeError(h);
|
|
3
3
|
};
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
import { __runInitializers as
|
|
7
|
-
import { isArrowKeyOrPageKeysPressed as
|
|
8
|
-
import { forceType as
|
|
9
|
-
import { LitElement as
|
|
10
|
-
import { property as C, state as
|
|
11
|
-
import { mapPlaceInfosToPlaceSelection as Ce, mapPlaceAndCoachToSeatReservationPlaceSelection as
|
|
12
|
-
var
|
|
13
|
-
(function(
|
|
14
|
-
|
|
15
|
-
})(
|
|
16
|
-
let
|
|
17
|
-
var
|
|
18
|
-
let
|
|
19
|
-
return
|
|
4
|
+
var ge = (h, d, u) => d.has(h) || ue("Cannot " + u);
|
|
5
|
+
var g = (h, d, u) => (ge(h, d, "read from private field"), u ? u.call(h) : d.get(h)), v = (h, d, u) => d.has(h) ? ue("Cannot add the same private member more than once") : d instanceof WeakSet ? d.add(h) : d.set(h, u), o = (h, d, u, w) => (ge(h, d, "write to private field"), w ? w.call(h, u) : d.set(h, u), u);
|
|
6
|
+
import { __runInitializers as r, __esDecorate as f } from "tslib";
|
|
7
|
+
import { isArrowKeyOrPageKeysPressed as ve } from "@sbb-esta/lyne-elements/core/a11y.js";
|
|
8
|
+
import { forceType as S } from "@sbb-esta/lyne-elements/core/decorators.js";
|
|
9
|
+
import { LitElement as fe } from "lit";
|
|
10
|
+
import { property as C, state as B } from "lit/decorators.js";
|
|
11
|
+
import { mapPlaceInfosToPlaceSelection as Ce, mapPlaceAndCoachToSeatReservationPlaceSelection as Se, mapCoachInfosToCoachSelection as xe } from "../common/mapper.js";
|
|
12
|
+
var x;
|
|
13
|
+
(function(h) {
|
|
14
|
+
h.right = "right", h.left = "left";
|
|
15
|
+
})(x || (x = {}));
|
|
16
|
+
let Re = (() => {
|
|
17
|
+
var I, p, b, m, y, _, P, A, R, k, E, N, n;
|
|
18
|
+
let h = fe, d, u = [], w = [], T, D = [], z = [], G, F = [], V = [], L, O = [], W = [], X, H = [], K = [], U, q = [], M = [], $, j = [], J = [], Q, Y = [], Z = [], ee, te = [], ie = [], se, ae = [], ce = [], oe, re = [], le = [], he, ne = [], de = [];
|
|
19
|
+
return n = class extends h {
|
|
20
20
|
constructor() {
|
|
21
21
|
super(...arguments);
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
22
|
+
v(this, I);
|
|
23
|
+
v(this, p);
|
|
24
|
+
v(this, b);
|
|
25
|
+
v(this, m);
|
|
26
|
+
v(this, y);
|
|
27
|
+
v(this, _);
|
|
28
|
+
v(this, P);
|
|
29
|
+
v(this, A);
|
|
30
|
+
v(this, R);
|
|
31
|
+
v(this, k);
|
|
32
|
+
v(this, E);
|
|
33
|
+
v(this, N);
|
|
34
|
+
o(this, I, r(this, u, null)), o(this, p, (r(this, w), r(this, D, !0))), o(this, b, (r(this, z), r(this, F, !1))), o(this, m, (r(this, V), r(this, O, 16))), o(this, y, (r(this, W), r(this, H, null))), o(this, _, (r(this, K), r(this, q, -1))), o(this, P, (r(this, M), r(this, j, -1))), o(this, A, (r(this, J), r(this, Y, !1))), o(this, R, (r(this, Z), r(this, te, -1))), o(this, k, (r(this, ie), r(this, ae, -1))), o(this, E, (r(this, ce), r(this, re, -1))), o(this, N, (r(this, le), r(this, ne, -1))), this.coachBorderPadding = (r(this, de), 6), this.gapBetweenCoaches = 4, this.coachBorderOffset = this.coachBorderPadding / this.baseGridSize, this.gapBetweenCoachDecks = 48, this.coachNavButtonDim = 0, this.currScrollDirection = x.right, this.maxCalcCoachsWidth = 0, this.scrollCoachsAreaWidth = 0, this.scrollNavigationAreaDim = 0, this.triggerCoachPositionsCollection = [], this.firstTabElement = null, this.lastTabElement = null, this.navigationScrollArea = null, this.coachScrollArea = null, this.currSelectedPlace = null, this.currSelectedPlaceElementId = null, this.currSelectedCoachIndex = -1, this.currSelectedDeckIndex = 0, this.preventCoachScrollByPlaceClick = !1, this.selectedSeatReservationPlaces = {
|
|
35
35
|
seats: [],
|
|
36
36
|
bicycles: []
|
|
37
|
-
}, this.seatReservationWithoutNavigationHasFocus = !1, this.isCoachGridFocusable = !1, this.isAutoScrolling = !1, this.isKeyboardNavigation = !1, this.keyboardNavigationEvents = {
|
|
37
|
+
}, this.seatReservationWithoutNavigationHasFocus = !1, this.isCoachGridFocusable = !1, this.isAutoScrolling = !1, this.isKeyboardNavigation = !1, this.hasMultipleDecks = !1, this.keyboardNavigationEvents = {
|
|
38
38
|
ArrowLeft: "ArrowLeft",
|
|
39
39
|
ArrowRight: "ArrowRight",
|
|
40
40
|
ArrowUp: "ArrowUp",
|
|
@@ -43,118 +43,134 @@ let Pe = (() => {
|
|
|
43
43
|
Enter: "Enter"
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
|
-
/** The seat
|
|
47
|
-
get
|
|
48
|
-
return
|
|
46
|
+
/** The seat reservations array contains all coaches and places */
|
|
47
|
+
get seatReservations() {
|
|
48
|
+
return g(this, I);
|
|
49
49
|
}
|
|
50
|
-
set
|
|
51
|
-
|
|
50
|
+
set seatReservations(e) {
|
|
51
|
+
o(this, I, e);
|
|
52
52
|
}
|
|
53
53
|
/** The seat reservation navigation can be toggled by this property */
|
|
54
54
|
get hasNavigation() {
|
|
55
|
-
return
|
|
55
|
+
return g(this, p);
|
|
56
56
|
}
|
|
57
57
|
set hasNavigation(e) {
|
|
58
|
-
|
|
58
|
+
o(this, p, e);
|
|
59
59
|
}
|
|
60
60
|
/** The seat reservation area is aligned vertically */
|
|
61
61
|
get alignVertical() {
|
|
62
|
-
return
|
|
62
|
+
return g(this, b);
|
|
63
63
|
}
|
|
64
64
|
set alignVertical(e) {
|
|
65
|
-
|
|
65
|
+
o(this, b, e);
|
|
66
66
|
}
|
|
67
67
|
/** The seat reservation area's base grid size */
|
|
68
68
|
get baseGridSize() {
|
|
69
|
-
return
|
|
69
|
+
return g(this, m);
|
|
70
70
|
}
|
|
71
71
|
set baseGridSize(e) {
|
|
72
|
-
|
|
72
|
+
o(this, m, e);
|
|
73
73
|
}
|
|
74
74
|
/** The seat reservation area's width */
|
|
75
75
|
get height() {
|
|
76
|
-
return
|
|
76
|
+
return g(this, y);
|
|
77
77
|
}
|
|
78
78
|
set height(e) {
|
|
79
|
-
|
|
79
|
+
o(this, y, e);
|
|
80
80
|
}
|
|
81
81
|
/** Maximal number of possible clickable seats */
|
|
82
82
|
get maxSeatReservations() {
|
|
83
|
-
return
|
|
83
|
+
return g(this, _);
|
|
84
84
|
}
|
|
85
85
|
set maxSeatReservations(e) {
|
|
86
|
-
|
|
86
|
+
o(this, _, e);
|
|
87
87
|
}
|
|
88
88
|
/** Maximal number of possible clickable bicycle places */
|
|
89
89
|
get maxBicycleReservations() {
|
|
90
|
-
return
|
|
90
|
+
return g(this, P);
|
|
91
91
|
}
|
|
92
92
|
set maxBicycleReservations(e) {
|
|
93
|
-
|
|
93
|
+
o(this, P, e);
|
|
94
94
|
}
|
|
95
95
|
/** Any click functionality is prevented */
|
|
96
96
|
get preventPlaceClick() {
|
|
97
|
-
return
|
|
97
|
+
return g(this, A);
|
|
98
98
|
}
|
|
99
99
|
set preventPlaceClick(e) {
|
|
100
|
-
|
|
100
|
+
o(this, A, e);
|
|
101
101
|
}
|
|
102
102
|
get preselectCoachIndex() {
|
|
103
|
-
return
|
|
103
|
+
return g(this, R);
|
|
104
104
|
}
|
|
105
105
|
set preselectCoachIndex(e) {
|
|
106
|
-
|
|
106
|
+
o(this, R, e);
|
|
107
107
|
}
|
|
108
108
|
get selectedCoachIndex() {
|
|
109
|
-
return
|
|
109
|
+
return g(this, k);
|
|
110
110
|
}
|
|
111
111
|
set selectedCoachIndex(e) {
|
|
112
|
-
|
|
112
|
+
o(this, k, e);
|
|
113
113
|
}
|
|
114
114
|
get focusedCoachIndex() {
|
|
115
|
-
return
|
|
115
|
+
return g(this, E);
|
|
116
116
|
}
|
|
117
117
|
set focusedCoachIndex(e) {
|
|
118
|
-
|
|
118
|
+
o(this, E, e);
|
|
119
119
|
}
|
|
120
120
|
//Sets the hover style when scrolling to a coach
|
|
121
121
|
get hoveredScrollCoachIndex() {
|
|
122
|
-
return
|
|
122
|
+
return g(this, N);
|
|
123
123
|
}
|
|
124
124
|
set hoveredScrollCoachIndex(e) {
|
|
125
|
-
|
|
125
|
+
o(this, N, e);
|
|
126
126
|
}
|
|
127
127
|
willUpdate(e) {
|
|
128
|
-
super.willUpdate(e), e.has("
|
|
128
|
+
if (super.willUpdate(e), e.has("seatReservations") && (this.hasMultipleDecks = this.seatReservations?.length > 1, this._initSeatReservationPlaceSelection()), e.has("baseGridSize") && (this.coachBorderOffset = this.coachBorderPadding / this.baseGridSize, this.style?.setProperty("--sbb-seat-reservation-grid-size", `${this.baseGridSize}px`), this.initNavigationSelectionByScrollEvent()), e.has("height") && this.height) {
|
|
129
|
+
const t = this.seatReservations[this.currSelectedDeckIndex] || null;
|
|
130
|
+
t?.coachItems.length && (this.baseGridSize = this.height / t.coachItems[0].dimension.h, this.coachBorderOffset = this.coachBorderPadding / this.baseGridSize, this.style?.setProperty("--sbb-seat-reservation-grid-size", `${this.baseGridSize}px`), this.initNavigationSelectionByScrollEvent());
|
|
131
|
+
}
|
|
132
|
+
e.has("alignVertical") && this.alignVertical && this.initNavigationSelectionByScrollEvent(), e.has("preselectCoachIndex") && this.preselectCoachIndex && setTimeout(() => this.scrollToSelectedNavCoach(this.preselectCoachIndex), 1);
|
|
129
133
|
}
|
|
130
134
|
navigateByDirectionBtn(e) {
|
|
131
135
|
this.unfocusPlaceElement();
|
|
132
136
|
let t = this.currSelectedCoachIndex;
|
|
133
|
-
e == "DIRECTION_LEFT" && t > 0 ? t = this.currSelectedCoachIndex != -1 ? this.currSelectedCoachIndex - 1 : 0 : e == "DIRECTION_RIGHT" && t < this.
|
|
137
|
+
e == "DIRECTION_LEFT" && t > 0 ? t = this.currSelectedCoachIndex != -1 ? this.currSelectedCoachIndex - 1 : 0 : e == "DIRECTION_RIGHT" && t < this.seatReservations[this.currSelectedDeckIndex].coachItems.length - 1 && (t = this.currSelectedCoachIndex != -1 ? this.currSelectedCoachIndex + 1 : 0), this.scrollToSelectedNavCoach(t);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Data can be prepared once for the entire component
|
|
141
|
+
* in order to avoid recurring iteration processes in rendering.
|
|
142
|
+
*/
|
|
143
|
+
initPrepairSeatReservationData() {
|
|
144
|
+
this._prepairCoachDriverArea();
|
|
134
145
|
}
|
|
135
146
|
/* Init scroll event handling for coach navigation */
|
|
136
147
|
initNavigationSelectionByScrollEvent() {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
148
|
+
this.firstTabElement = this.shadowRoot?.querySelector("#first-tab-element"), this.lastTabElement = this.shadowRoot?.querySelector("#last-tab-element"), this.coachScrollArea = this.shadowRoot?.querySelector("#sbb-sr__wrapper-scrollarea"), this.navigationScrollArea = this.shadowRoot?.querySelector("#sbb-sr-navigation");
|
|
149
|
+
const e = this.seatReservations ? this.seatReservations[this.currSelectedDeckIndex] : null;
|
|
150
|
+
if (e && e.coachItems.length > 0) {
|
|
151
|
+
const t = e.coachItems[0].dimension.h * this.baseGridSize + this.coachBorderPadding, i = (this.seatReservations.length - 1) * this.gapBetweenCoachDecks;
|
|
152
|
+
this.style?.setProperty("--sbb-seat-reservation-height", `${t * this.seatReservations.length + i}`), this.style?.setProperty("--sbb-seat-reservation-decks", `${this.seatReservations.length}`);
|
|
140
153
|
}
|
|
141
|
-
if (this.
|
|
154
|
+
if (this.navigationScrollArea) {
|
|
142
155
|
this.scrollNavigationAreaDim = this.alignVertical ? this.navigationScrollArea.getBoundingClientRect().height : this.navigationScrollArea.getBoundingClientRect().width;
|
|
143
|
-
const t = this.navigationScrollArea.querySelector("ul > li")
|
|
144
|
-
|
|
156
|
+
const t = this.navigationScrollArea.querySelector("ul > li");
|
|
157
|
+
if (t) {
|
|
158
|
+
const i = t?.getBoundingClientRect();
|
|
159
|
+
this.coachNavButtonDim = this.alignVertical ? i.height : i.width;
|
|
160
|
+
}
|
|
145
161
|
}
|
|
146
|
-
if (this.coachScrollArea) {
|
|
147
|
-
let
|
|
148
|
-
this.scrollCoachsAreaWidth = this.alignVertical ? this.coachScrollArea.getBoundingClientRect().height : this.coachScrollArea.getBoundingClientRect().width, this.triggerCoachPositionsCollection =
|
|
149
|
-
const
|
|
150
|
-
return
|
|
151
|
-
start:
|
|
152
|
-
end:
|
|
153
|
-
width:
|
|
162
|
+
if (this.coachScrollArea && e) {
|
|
163
|
+
let t = 0;
|
|
164
|
+
this.scrollCoachsAreaWidth = this.alignVertical ? this.coachScrollArea.getBoundingClientRect().height : this.coachScrollArea.getBoundingClientRect().width, this.triggerCoachPositionsCollection = e.coachItems.map((i) => {
|
|
165
|
+
const s = t, c = this.getCalculatedDimension(i.dimension).w;
|
|
166
|
+
return t += c + this.gapBetweenCoaches, {
|
|
167
|
+
start: s,
|
|
168
|
+
end: t,
|
|
169
|
+
width: c
|
|
154
170
|
};
|
|
155
|
-
}), this.maxCalcCoachsWidth =
|
|
156
|
-
const
|
|
157
|
-
this.currSelectedCoachIndex === -1 && (this.currSelectedCoachIndex =
|
|
171
|
+
}), this.maxCalcCoachsWidth = t, this.coachScrollArea.addEventListener("scrollend", () => {
|
|
172
|
+
const i = this.isAutoScrolling ? this.currSelectedCoachIndex : this._getCoachIndexByScrollTriggerPosition();
|
|
173
|
+
this.currSelectedCoachIndex === -1 && (this.currSelectedCoachIndex = i), this._isScrollableToSelectedCoach() ? this.currSelectedCoachIndex = i : this.currSelectedCoachIndex = i < this.currSelectedCoachIndex ? this.currSelectedCoachIndex : i, this.isAutoScrolling || this._scrollToSelectedNavigationButton(i), this.preventCoachScrollByPlaceClick = !1, this.updateCurrentSelectedCoach(), this.hasNavigation || (this.preselectPlaceInCoach(), this.isAutoScrolling = !1);
|
|
158
174
|
});
|
|
159
175
|
}
|
|
160
176
|
}
|
|
@@ -183,7 +199,7 @@ let Pe = (() => {
|
|
|
183
199
|
return;
|
|
184
200
|
}
|
|
185
201
|
}
|
|
186
|
-
if (this.currSelectedCoachIndex !== -1 &&
|
|
202
|
+
if (this.currSelectedCoachIndex !== -1 && ve(e))
|
|
187
203
|
switch (e.preventDefault(), t) {
|
|
188
204
|
case this.keyboardNavigationEvents.ArrowLeft:
|
|
189
205
|
{
|
|
@@ -230,11 +246,11 @@ let Pe = (() => {
|
|
|
230
246
|
}) : this.updateCurrentSelectedCoach(), this._scrollToSelectedNavigationButton(e);
|
|
231
247
|
}
|
|
232
248
|
}
|
|
233
|
-
focusPlaceElement(e
|
|
249
|
+
focusPlaceElement(e) {
|
|
234
250
|
if (this.unfocusPlaceElement(), e) {
|
|
235
|
-
this.currSelectedPlace = e,
|
|
236
|
-
const
|
|
237
|
-
|
|
251
|
+
this.currSelectedPlace = e, this._setCurrSelectedPlaceElementId(e);
|
|
252
|
+
const t = this._getPlaceHtmlElement();
|
|
253
|
+
t && t.setAttribute("keyfocus", "focus");
|
|
238
254
|
}
|
|
239
255
|
}
|
|
240
256
|
unfocusPlaceElement() {
|
|
@@ -249,8 +265,8 @@ let Pe = (() => {
|
|
|
249
265
|
}
|
|
250
266
|
getCalculatedPosition(e, t, i, s) {
|
|
251
267
|
if (i && t) {
|
|
252
|
-
const
|
|
253
|
-
e.y === 0 ? e.y -= this.coachBorderOffset : e.y + t.h ===
|
|
268
|
+
const c = s ? i.h : i.h + this.coachBorderOffset;
|
|
269
|
+
e.y === 0 ? e.y -= this.coachBorderOffset : e.y + t.h === c && (e.y += this.coachBorderOffset);
|
|
254
270
|
}
|
|
255
271
|
return {
|
|
256
272
|
x: this.baseGridSize * e.x,
|
|
@@ -265,7 +281,7 @@ let Pe = (() => {
|
|
|
265
281
|
* @returns An Object with count of free seats and free bicycle places
|
|
266
282
|
*/
|
|
267
283
|
getAvailableFreePlacesNumFromCoach(e) {
|
|
268
|
-
const t = { seats: 0, bicycles: 0 }, i = this.
|
|
284
|
+
const t = { seats: 0, bicycles: 0 }, i = this.seatReservations[this.currSelectedDeckIndex].coachItems[e].places?.reduce((s, c) => (c.state !== "FREE" || (c.type === "SEAT" ? s.seats++ : s.bicycles++), s), t);
|
|
269
285
|
return i || t;
|
|
270
286
|
}
|
|
271
287
|
/**
|
|
@@ -289,7 +305,7 @@ let Pe = (() => {
|
|
|
289
305
|
* Sets the new ScrollDirection by the new given target coach index.
|
|
290
306
|
*/
|
|
291
307
|
_setScrollDirectionByCoachIndex() {
|
|
292
|
-
this.currScrollDirection = this.currSelectedCoachIndex > this.selectedCoachIndex ?
|
|
308
|
+
this.currScrollDirection = this.currSelectedCoachIndex > this.selectedCoachIndex ? x.right : x.left;
|
|
293
309
|
}
|
|
294
310
|
/**
|
|
295
311
|
* Returns the scroll start or end position X from the selected coach.
|
|
@@ -299,7 +315,7 @@ let Pe = (() => {
|
|
|
299
315
|
*/
|
|
300
316
|
_getCoachScrollPositionX() {
|
|
301
317
|
const e = this.triggerCoachPositionsCollection[this.currSelectedCoachIndex];
|
|
302
|
-
return this.isKeyboardNavigation && this.currScrollDirection ===
|
|
318
|
+
return this.isKeyboardNavigation && this.currScrollDirection === x.left && e.width > this.scrollCoachsAreaWidth ? e.end - this.scrollCoachsAreaWidth : e.start;
|
|
303
319
|
}
|
|
304
320
|
/**
|
|
305
321
|
* Sets the focus on the HTML table (grid) caption element so that the heading is read out when using a ScreenReader.
|
|
@@ -316,8 +332,8 @@ let Pe = (() => {
|
|
|
316
332
|
* @returns boolean
|
|
317
333
|
*/
|
|
318
334
|
_isScrollableToSelectedCoach() {
|
|
319
|
-
const e = this.alignVertical ? this.coachScrollArea.scrollTop : this.coachScrollArea.scrollLeft, t = this.alignVertical ? this.coachScrollArea.getBoundingClientRect().height : this.coachScrollArea.getBoundingClientRect().width, i = this.maxCalcCoachsWidth - t, s = this.triggerCoachPositionsCollection[this.currSelectedCoachIndex],
|
|
320
|
-
return (e < i || e > s.start) && !
|
|
335
|
+
const e = this.alignVertical ? this.coachScrollArea.scrollTop : this.coachScrollArea.scrollLeft, t = this.alignVertical ? this.coachScrollArea.getBoundingClientRect().height : this.coachScrollArea.getBoundingClientRect().width, i = this.maxCalcCoachsWidth - t, s = this.triggerCoachPositionsCollection[this.currSelectedCoachIndex], c = e === this.triggerCoachPositionsCollection[this.currSelectedCoachIndex].start;
|
|
336
|
+
return (e < i || e > s.start) && !c;
|
|
321
337
|
}
|
|
322
338
|
/**
|
|
323
339
|
* Returns the coach index which is currently visible in the scroll area
|
|
@@ -333,8 +349,11 @@ let Pe = (() => {
|
|
|
333
349
|
*/
|
|
334
350
|
_getFirstPlaceInSelecedCoach() {
|
|
335
351
|
let e = null;
|
|
336
|
-
const t = this.
|
|
337
|
-
return t && s && (e = t.places?.find((
|
|
352
|
+
const t = this.seatReservations[this.currSelectedDeckIndex].coachItems[this.currSelectedCoachIndex], i = "cell-" + this.currSelectedDeckIndex + "-" + this.currSelectedCoachIndex + "-0-0", s = this.shadowRoot?.querySelector("#" + i)?.querySelector("sbb-seat-reservation-place-control")?.getAttribute("text") || null;
|
|
353
|
+
return t && s && (e = t.places?.find((c) => c.number === s) || null), e;
|
|
354
|
+
}
|
|
355
|
+
_getSwitchedCoachDeckIndexByKeyNavigation(e, t) {
|
|
356
|
+
return !this.currSelectedPlace || e === this.keyboardNavigationEvents.ArrowRight || e === this.keyboardNavigationEvents.ArrowLeft ? null : e === this.keyboardNavigationEvents.ArrowDown && this.currSelectedPlace.position.y + 2 === t.dimension.h && this.seatReservations[this.currSelectedDeckIndex + 1] ? this.currSelectedDeckIndex + 1 : e === this.keyboardNavigationEvents.ArrowUp && this.currSelectedPlace.position.y === 0 && this.seatReservations[this.currSelectedDeckIndex - 1] ? this.currSelectedDeckIndex - 1 : null;
|
|
338
357
|
}
|
|
339
358
|
/**
|
|
340
359
|
* To get the correct closest place of current pressed key and the current selected place,
|
|
@@ -343,18 +362,22 @@ let Pe = (() => {
|
|
|
343
362
|
* @returns Place or null
|
|
344
363
|
*/
|
|
345
364
|
_getClosestPlaceByKeyDirection(e) {
|
|
346
|
-
const t = this.
|
|
347
|
-
let i = null;
|
|
348
|
-
if (
|
|
365
|
+
const t = this.seatReservations[this.currSelectedDeckIndex].coachItems[this.currSelectedCoachIndex];
|
|
366
|
+
let i = null, s = t.places, c = null;
|
|
367
|
+
if (s)
|
|
349
368
|
if (this.currSelectedPlaceElementId) {
|
|
350
|
-
if (this.currSelectedPlace)
|
|
351
|
-
|
|
352
|
-
|
|
369
|
+
if (this.currSelectedPlace) {
|
|
370
|
+
const l = { ...this.currSelectedPlace.position };
|
|
371
|
+
e && (c = this._getSwitchedCoachDeckIndexByKeyNavigation(e, t), c !== null && (s = this.seatReservations[c].coachItems[this.currSelectedCoachIndex].places || [], l.y = c < this.currSelectedDeckIndex ? t.dimension.h : -1));
|
|
372
|
+
for (const a of s)
|
|
373
|
+
e ? a.number !== this.currSelectedPlace?.number && (e === this.keyboardNavigationEvents.ArrowRight && (a.position.y === l.y || a.position.y === l.y - 1) && a.position.x > l.x && (!i || a.position.x < i.position.x) || e === this.keyboardNavigationEvents.ArrowDown && (a.position.x === l.x || a.position.x === l.x + 1) && a.position.y > l.y && (!i || a.position.y < i.position.y) || e === this.keyboardNavigationEvents.ArrowLeft && (a.position.y === l.y || a.position.y === l.y + 1) && a.position.x < l.x && (!i || a.position.x > i.position.x) || e === this.keyboardNavigationEvents.ArrowUp && (a.position.x === l.x || a.position.x === l.x - 1) && a.position.y < l.y && (!i || a.position.y > i.position.y)) && (i = a) : (this.currScrollDirection === x.right && a.position.y === l.y && (!i || a.position.x < i.position.x) || this.currScrollDirection === x.left && a.position.y === l.y && (!i || a.position.x > i.position.x)) && (i = a);
|
|
374
|
+
c !== null && i && (this.currSelectedDeckIndex = c);
|
|
375
|
+
}
|
|
353
376
|
} else
|
|
354
377
|
return this._getFirstPlaceInSelecedCoach();
|
|
355
378
|
return i;
|
|
356
379
|
}
|
|
357
|
-
// Handling for Tab navigation if
|
|
380
|
+
// Handling for Tab navigation if an place is selected inside the coach.
|
|
358
381
|
// This controls the focused coach from the current selected coach.
|
|
359
382
|
_navigateCoachNavigationByKeyboard(e) {
|
|
360
383
|
const t = this.focusedCoachIndex === -1 ? this.currSelectedCoachIndex === -1 ? 0 : this.currSelectedCoachIndex : this.focusedCoachIndex, i = e === "NEXT_TAB" ? this.getNextAvailableCoachIndex(t) : this.getPrevAvailableCoachIndex(t);
|
|
@@ -363,14 +386,14 @@ let Pe = (() => {
|
|
|
363
386
|
return;
|
|
364
387
|
}
|
|
365
388
|
if (this.hasNavigation) {
|
|
366
|
-
const s = this._getPlaceHtmlElement(),
|
|
389
|
+
const s = this._getPlaceHtmlElement(), c = s ? s.getAttribute("keyfocus") === "focus" : !1;
|
|
367
390
|
if (e === "PREV_TAB" && this.selectedCoachIndex === t)
|
|
368
|
-
if (
|
|
391
|
+
if (c) {
|
|
369
392
|
this.focusedCoachIndex = t, this.unfocusPlaceElement();
|
|
370
393
|
return;
|
|
371
394
|
} else
|
|
372
395
|
this.focusedCoachIndex = i;
|
|
373
|
-
else i !== this.currSelectedCoachIndex ? this.focusedCoachIndex = i : (this.focusedCoachIndex = -1, this.selectedCoachIndex = i,
|
|
396
|
+
else i !== this.currSelectedCoachIndex ? this.focusedCoachIndex = i : (this.focusedCoachIndex = -1, this.selectedCoachIndex = i, c ? this.focusPlaceElement(this.currSelectedPlace) : (this.isCoachGridFocusable = !0, this._setFocusToSelectedCoachGrid()));
|
|
374
397
|
this._scrollToSelectedNavigationButton(i);
|
|
375
398
|
} else
|
|
376
399
|
this.scrollToSelectedNavCoach(i);
|
|
@@ -388,14 +411,15 @@ let Pe = (() => {
|
|
|
388
411
|
}
|
|
389
412
|
getNextAvailableCoachIndex(e) {
|
|
390
413
|
const t = e ?? this.currSelectedCoachIndex;
|
|
391
|
-
return t < this.
|
|
414
|
+
return t < this.seatReservations[this.currSelectedDeckIndex].coachItems.length - 1 ? t + 1 : t;
|
|
392
415
|
}
|
|
393
416
|
getPrevAvailableCoachIndex(e) {
|
|
394
417
|
const t = e ?? this.currSelectedCoachIndex;
|
|
395
418
|
return t > 0 ? t - 1 : t;
|
|
396
419
|
}
|
|
397
420
|
updateSelectedSeatReservationPlaces(e) {
|
|
398
|
-
e.placeType === "SEAT" ?
|
|
421
|
+
const t = e.placeType === "SEAT" ? "seats" : "bicycles", i = e.placeType === "SEAT" ? this.maxSeatReservations : this.maxBicycleReservations, s = this.selectedSeatReservationPlaces[t], c = this._updateSelectedSeatReservationPlaces(s, i, e);
|
|
422
|
+
this.selectedSeatReservationPlaces[t] = c, this.dispatchEvent(new CustomEvent("selectedplaces", {
|
|
399
423
|
bubbles: !0,
|
|
400
424
|
composed: !0,
|
|
401
425
|
detail: this.selectedSeatReservationPlaces
|
|
@@ -407,15 +431,19 @@ let Pe = (() => {
|
|
|
407
431
|
s && e.push(s);
|
|
408
432
|
} else
|
|
409
433
|
e = e.filter((s) => s.id !== i.id);
|
|
410
|
-
|
|
434
|
+
if (t > -1 && e.length > t) {
|
|
435
|
+
const s = t > 0 ? i : void 0;
|
|
436
|
+
e = this._resetAllPlaceSelections(e, s);
|
|
437
|
+
}
|
|
438
|
+
return e;
|
|
411
439
|
}
|
|
412
440
|
updateCurrentSelectedPlaceInCoach(e) {
|
|
413
|
-
const t = e.coachIndex, i = this.
|
|
441
|
+
const t = e.coachIndex, i = this.seatReservations[this.currSelectedDeckIndex].coachItems[t].places?.find((s) => s.number == e.number);
|
|
414
442
|
i && (this.currSelectedCoachIndex = t, this.currSelectedPlace = i, this.currSelectedCoachIndex !== this.selectedCoachIndex && this.updateCurrentSelectedCoach(), this._setCurrSelectedPlaceElementId(i));
|
|
415
443
|
}
|
|
416
444
|
updateCurrentSelectedCoach() {
|
|
417
445
|
this.selectedCoachIndex = this.currSelectedCoachIndex, this.focusedCoachIndex = -1;
|
|
418
|
-
const e = this.
|
|
446
|
+
const e = this._getSeatReservationSelectedCoach(this.selectedCoachIndex);
|
|
419
447
|
e && this.dispatchEvent(new CustomEvent("selectedcoach", {
|
|
420
448
|
bubbles: !0,
|
|
421
449
|
composed: !0,
|
|
@@ -427,12 +455,12 @@ let Pe = (() => {
|
|
|
427
455
|
* that have the state SELECTED within the seatReservation object
|
|
428
456
|
*/
|
|
429
457
|
_initSeatReservationPlaceSelection() {
|
|
430
|
-
this.
|
|
431
|
-
|
|
432
|
-
const
|
|
458
|
+
this.seatReservations?.forEach((e) => e.coachItems.map((t, i) => {
|
|
459
|
+
t.places?.filter((s) => s.state === "SELECTED")?.forEach((s) => {
|
|
460
|
+
const c = Ce(s, e.deckCoachIndex, i), l = this._getSeatReservationPlaceSelection(c);
|
|
433
461
|
l && (l.placeType === "SEAT" ? this.selectedSeatReservationPlaces.seats.push(l) : this.selectedSeatReservationPlaces.bicycles.push(l));
|
|
434
462
|
});
|
|
435
|
-
});
|
|
463
|
+
}));
|
|
436
464
|
}
|
|
437
465
|
/**
|
|
438
466
|
* All selected places will be reset or the currentSelectedPlace was given, then we reset all except currentSelectedPlace
|
|
@@ -441,65 +469,82 @@ let Pe = (() => {
|
|
|
441
469
|
*/
|
|
442
470
|
_resetAllPlaceSelections(e, t) {
|
|
443
471
|
for (const i of e)
|
|
444
|
-
(!t || t.id !== i.id)
|
|
472
|
+
if (!t || t.id !== i.id) {
|
|
473
|
+
const s = this.shadowRoot?.getElementById(i.id);
|
|
474
|
+
s && s.setAttribute("state", "FREE");
|
|
475
|
+
}
|
|
445
476
|
return t ? e = e.filter((i) => i.id === t.id) : e = [], e;
|
|
446
477
|
}
|
|
447
478
|
_getSeatReservationPlaceSelection(e) {
|
|
448
|
-
const t = this.
|
|
449
|
-
return i ?
|
|
479
|
+
const t = this.seatReservations[this.currSelectedDeckIndex].coachItems[e.coachIndex], i = t.places?.find((s) => s.number === e.number);
|
|
480
|
+
return i ? Se(i, t, e.deckIndex, e.coachIndex) : null;
|
|
450
481
|
}
|
|
451
|
-
|
|
452
|
-
if (!this.
|
|
482
|
+
_getSeatReservationSelectedCoach(e) {
|
|
483
|
+
if (!this.seatReservations[this.currSelectedDeckIndex].coachItems[e])
|
|
453
484
|
return null;
|
|
454
|
-
const t = this.
|
|
455
|
-
return
|
|
485
|
+
const t = this.seatReservations[this.currSelectedDeckIndex].coachItems[e], i = this.getAvailableFreePlacesNumFromCoach(e);
|
|
486
|
+
return xe(e, t, i);
|
|
456
487
|
}
|
|
457
488
|
_setCurrSelectedPlaceElementId(e) {
|
|
458
|
-
e ? this.currSelectedPlaceElementId = "seat-reservation__place-button-" + this.currSelectedCoachIndex + "-" + e.number : this.currSelectedPlaceElementId = null;
|
|
489
|
+
e ? this.currSelectedPlaceElementId = "seat-reservation__place-button-" + this.currSelectedDeckIndex + "-" + this.currSelectedCoachIndex + "-" + e.number : this.currSelectedPlaceElementId = null;
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* Prepares all coaches with the values for whether there is a driver area left or right
|
|
493
|
+
* */
|
|
494
|
+
_prepairCoachDriverArea() {
|
|
495
|
+
this.seatReservations.forEach((e, t) => {
|
|
496
|
+
this.seatReservations[t].coachItems = e.coachItems.map((i) => {
|
|
497
|
+
const s = i.graphicElements?.filter((c) => c.icon === "DRIVER_AREA");
|
|
498
|
+
if (s && s.length > 0) {
|
|
499
|
+
const c = s.find((a) => a.position.x === 0) || !1, l = s.find((a) => a.position.x > 0) || !1;
|
|
500
|
+
i.driverAreaSide = {
|
|
501
|
+
left: !!c,
|
|
502
|
+
right: !!l
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
return i;
|
|
506
|
+
});
|
|
507
|
+
});
|
|
459
508
|
}
|
|
460
509
|
/**
|
|
461
|
-
* Returns the current selected place HTML element by
|
|
462
|
-
* If both doesn't exist, we try to return the place HTML element by the _currentSelectedPlaceElementId
|
|
463
|
-
* @param placeNumber optional as string
|
|
464
|
-
* @param coachIndex optional as string
|
|
510
|
+
* Returns the current selected place HTML element by currSelectedPlaceElementId.
|
|
465
511
|
* @returns HTMLElement or null
|
|
466
512
|
*/
|
|
467
|
-
_getPlaceHtmlElement(
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
} }, metadata: e }, n, N), g(r, null, B, { kind: "accessor", name: "hasNavigation", static: !1, private: !1, access: { has: (t) => "hasNavigation" in t, get: (t) => t.hasNavigation, set: (t, i) => {
|
|
513
|
+
_getPlaceHtmlElement() {
|
|
514
|
+
return this.currSelectedPlaceElementId && this.shadowRoot?.getElementById(this.currSelectedPlaceElementId) || null;
|
|
515
|
+
}
|
|
516
|
+
}, I = new WeakMap(), p = new WeakMap(), b = new WeakMap(), m = new WeakMap(), y = new WeakMap(), _ = new WeakMap(), P = new WeakMap(), A = new WeakMap(), R = new WeakMap(), k = new WeakMap(), E = new WeakMap(), N = new WeakMap(), (() => {
|
|
517
|
+
const e = typeof Symbol == "function" && Symbol.metadata ? Object.create(h[Symbol.metadata] ?? null) : void 0;
|
|
518
|
+
d = [C({ attribute: "seat-reservations", type: Array })], T = [S(), C({ attribute: "has-navigation", type: Boolean })], G = [S(), C({ attribute: "align-vertical", type: Boolean })], L = [S(), C({ attribute: "base-grid-size", type: Number })], X = [S(), C({ attribute: "height", type: Number })], U = [S(), C({ attribute: "max-seat-reservations", type: Number })], $ = [S(), C({ attribute: "max-bicycle-reservations", type: Number })], Q = [S(), C({ attribute: "prevent-place-click", type: Boolean })], ee = [S(), C({ attribute: "preselect-coach-index", type: Number })], se = [B()], oe = [B()], he = [B()], f(n, null, d, { kind: "accessor", name: "seatReservations", static: !1, private: !1, access: { has: (t) => "seatReservations" in t, get: (t) => t.seatReservations, set: (t, i) => {
|
|
519
|
+
t.seatReservations = i;
|
|
520
|
+
} }, metadata: e }, u, w), f(n, null, T, { kind: "accessor", name: "hasNavigation", static: !1, private: !1, access: { has: (t) => "hasNavigation" in t, get: (t) => t.hasNavigation, set: (t, i) => {
|
|
476
521
|
t.hasNavigation = i;
|
|
477
|
-
} }, metadata: e },
|
|
522
|
+
} }, metadata: e }, D, z), f(n, null, G, { kind: "accessor", name: "alignVertical", static: !1, private: !1, access: { has: (t) => "alignVertical" in t, get: (t) => t.alignVertical, set: (t, i) => {
|
|
478
523
|
t.alignVertical = i;
|
|
479
|
-
} }, metadata: e },
|
|
524
|
+
} }, metadata: e }, F, V), f(n, null, L, { kind: "accessor", name: "baseGridSize", static: !1, private: !1, access: { has: (t) => "baseGridSize" in t, get: (t) => t.baseGridSize, set: (t, i) => {
|
|
480
525
|
t.baseGridSize = i;
|
|
481
|
-
} }, metadata: e },
|
|
526
|
+
} }, metadata: e }, O, W), f(n, null, X, { kind: "accessor", name: "height", static: !1, private: !1, access: { has: (t) => "height" in t, get: (t) => t.height, set: (t, i) => {
|
|
482
527
|
t.height = i;
|
|
483
|
-
} }, metadata: e },
|
|
528
|
+
} }, metadata: e }, H, K), f(n, null, U, { kind: "accessor", name: "maxSeatReservations", static: !1, private: !1, access: { has: (t) => "maxSeatReservations" in t, get: (t) => t.maxSeatReservations, set: (t, i) => {
|
|
484
529
|
t.maxSeatReservations = i;
|
|
485
|
-
} }, metadata: e },
|
|
530
|
+
} }, metadata: e }, q, M), f(n, null, $, { kind: "accessor", name: "maxBicycleReservations", static: !1, private: !1, access: { has: (t) => "maxBicycleReservations" in t, get: (t) => t.maxBicycleReservations, set: (t, i) => {
|
|
486
531
|
t.maxBicycleReservations = i;
|
|
487
|
-
} }, metadata: e },
|
|
532
|
+
} }, metadata: e }, j, J), f(n, null, Q, { kind: "accessor", name: "preventPlaceClick", static: !1, private: !1, access: { has: (t) => "preventPlaceClick" in t, get: (t) => t.preventPlaceClick, set: (t, i) => {
|
|
488
533
|
t.preventPlaceClick = i;
|
|
489
|
-
} }, metadata: e },
|
|
534
|
+
} }, metadata: e }, Y, Z), f(n, null, ee, { kind: "accessor", name: "preselectCoachIndex", static: !1, private: !1, access: { has: (t) => "preselectCoachIndex" in t, get: (t) => t.preselectCoachIndex, set: (t, i) => {
|
|
490
535
|
t.preselectCoachIndex = i;
|
|
491
|
-
} }, metadata: e },
|
|
536
|
+
} }, metadata: e }, te, ie), f(n, null, se, { kind: "accessor", name: "selectedCoachIndex", static: !1, private: !1, access: { has: (t) => "selectedCoachIndex" in t, get: (t) => t.selectedCoachIndex, set: (t, i) => {
|
|
492
537
|
t.selectedCoachIndex = i;
|
|
493
|
-
} }, metadata: e },
|
|
538
|
+
} }, metadata: e }, ae, ce), f(n, null, oe, { kind: "accessor", name: "focusedCoachIndex", static: !1, private: !1, access: { has: (t) => "focusedCoachIndex" in t, get: (t) => t.focusedCoachIndex, set: (t, i) => {
|
|
494
539
|
t.focusedCoachIndex = i;
|
|
495
|
-
} }, metadata: e },
|
|
540
|
+
} }, metadata: e }, re, le), f(n, null, he, { kind: "accessor", name: "hoveredScrollCoachIndex", static: !1, private: !1, access: { has: (t) => "hoveredScrollCoachIndex" in t, get: (t) => t.hoveredScrollCoachIndex, set: (t, i) => {
|
|
496
541
|
t.hoveredScrollCoachIndex = i;
|
|
497
|
-
} }, metadata: e },
|
|
498
|
-
})(),
|
|
542
|
+
} }, metadata: e }, ne, de), e && Object.defineProperty(n, Symbol.metadata, { enumerable: !0, configurable: !0, writable: !0, value: e });
|
|
543
|
+
})(), n.events = {
|
|
499
544
|
selectedplaces: "selectedplaces",
|
|
500
545
|
selectedcoach: "selectedcoach"
|
|
501
|
-
},
|
|
546
|
+
}, n;
|
|
502
547
|
})();
|
|
503
548
|
export {
|
|
504
|
-
|
|
549
|
+
Re as SeatReservationBaseElement
|
|
505
550
|
};
|