@sbb-esta/lyne-elements-experimental 2.10.1 → 2.11.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.
Files changed (166) hide show
  1. package/custom-elements.json +4357 -0
  2. package/development/seat-reservation/common/mapper/icon-mapper.d.ts +112 -0
  3. package/development/seat-reservation/common/mapper/icon-mapper.d.ts.map +1 -0
  4. package/development/seat-reservation/common/mapper/icon-mapper.js +72 -0
  5. package/development/seat-reservation/common/mapper/mapper.d.ts +29 -0
  6. package/development/seat-reservation/common/mapper/mapper.d.ts.map +1 -0
  7. package/development/seat-reservation/common/mapper/mapper.js +117 -0
  8. package/development/seat-reservation/common/mapper/seat-reservation-sample-data.d.ts +225 -0
  9. package/development/seat-reservation/common/mapper/seat-reservation-sample-data.d.ts.map +1 -0
  10. package/development/seat-reservation/common/mapper/seat-reservation-sample-data.js +6152 -0
  11. package/development/seat-reservation/common/mapper.d.ts +3 -0
  12. package/development/seat-reservation/common/mapper.d.ts.map +1 -0
  13. package/development/seat-reservation/common/mapper.js +10 -0
  14. package/development/seat-reservation/common/svgs.d.ts +25 -0
  15. package/development/seat-reservation/common/svgs.d.ts.map +1 -0
  16. package/development/seat-reservation/common/svgs.js +48 -0
  17. package/development/seat-reservation/common/translations/i18n.d.ts +19 -0
  18. package/development/seat-reservation/common/translations/i18n.d.ts.map +1 -0
  19. package/development/seat-reservation/common/translations/i18n.js +462 -0
  20. package/development/seat-reservation/common/translations.d.ts +2 -0
  21. package/development/seat-reservation/common/translations.d.ts.map +1 -0
  22. package/development/seat-reservation/common/translations.js +5 -0
  23. package/development/seat-reservation/common/types.d.ts +71 -0
  24. package/development/seat-reservation/common/types.d.ts.map +1 -0
  25. package/development/seat-reservation/common/types.js +2 -0
  26. package/development/seat-reservation/common.d.ts +8 -0
  27. package/development/seat-reservation/common.d.ts.map +1 -0
  28. package/development/seat-reservation/common.js +14 -0
  29. package/development/seat-reservation/seat-reservation/seat-reservation-base-element.d.ts +157 -0
  30. package/development/seat-reservation/seat-reservation/seat-reservation-base-element.d.ts.map +1 -0
  31. package/development/seat-reservation/seat-reservation/seat-reservation-base-element.js +706 -0
  32. package/development/seat-reservation/seat-reservation/seat-reservation-scoped/seat-reservation-scoped.component.d.ts +29 -0
  33. package/development/seat-reservation/seat-reservation/seat-reservation-scoped/seat-reservation-scoped.component.d.ts.map +1 -0
  34. package/development/seat-reservation/seat-reservation/seat-reservation-scoped/seat-reservation-scoped.component.js +196 -0
  35. package/development/seat-reservation/seat-reservation/seat-reservation-scoped.d.ts +5 -0
  36. package/development/seat-reservation/seat-reservation/seat-reservation-scoped.d.ts.map +1 -0
  37. package/development/seat-reservation/seat-reservation/seat-reservation-scoped.js +5 -0
  38. package/development/seat-reservation/seat-reservation/seat-reservation.component.d.ts +62 -0
  39. package/development/seat-reservation/seat-reservation/seat-reservation.component.d.ts.map +1 -0
  40. package/development/seat-reservation/seat-reservation/seat-reservation.component.js +615 -0
  41. package/development/seat-reservation/seat-reservation-area/seat-reservation-area.component.d.ts +18 -0
  42. package/development/seat-reservation/seat-reservation-area/seat-reservation-area.component.d.ts.map +1 -0
  43. package/development/seat-reservation/seat-reservation-area/seat-reservation-area.component.js +108 -0
  44. package/development/seat-reservation/seat-reservation-area.d.ts +5 -0
  45. package/development/seat-reservation/seat-reservation-area.d.ts.map +1 -0
  46. package/development/seat-reservation/seat-reservation-area.js +5 -0
  47. package/development/seat-reservation/seat-reservation-graphic/seat-reservation-assets.d.ts +9 -0
  48. package/development/seat-reservation/seat-reservation-graphic/seat-reservation-assets.d.ts.map +1 -0
  49. package/development/seat-reservation/seat-reservation-graphic/seat-reservation-assets.js +326 -0
  50. package/development/seat-reservation/seat-reservation-graphic/seat-reservation-graphic.component.d.ts +29 -0
  51. package/development/seat-reservation/seat-reservation-graphic/seat-reservation-graphic.component.d.ts.map +1 -0
  52. package/development/seat-reservation/seat-reservation-graphic/seat-reservation-graphic.component.js +224 -0
  53. package/development/seat-reservation/seat-reservation-graphic.d.ts +5 -0
  54. package/development/seat-reservation/seat-reservation-graphic.d.ts.map +1 -0
  55. package/development/seat-reservation/seat-reservation-graphic.js +5 -0
  56. package/development/seat-reservation/seat-reservation-navigation/seat-reservation-navigation-coach/seat-reservation-navigation-coach.component.d.ts +66 -0
  57. package/development/seat-reservation/seat-reservation-navigation/seat-reservation-navigation-coach/seat-reservation-navigation-coach.component.d.ts.map +1 -0
  58. package/development/seat-reservation/seat-reservation-navigation/seat-reservation-navigation-coach/seat-reservation-navigation-coach.component.js +576 -0
  59. package/development/seat-reservation/seat-reservation-navigation/seat-reservation-navigation-coach.d.ts +5 -0
  60. package/development/seat-reservation/seat-reservation-navigation/seat-reservation-navigation-coach.d.ts.map +1 -0
  61. package/development/seat-reservation/seat-reservation-navigation/seat-reservation-navigation-coach.js +5 -0
  62. package/development/seat-reservation/seat-reservation-navigation/seat-reservation-navigation-services/seat-reservation-navigation-services.component.d.ts +21 -0
  63. package/development/seat-reservation/seat-reservation-navigation/seat-reservation-navigation-services/seat-reservation-navigation-services.component.d.ts.map +1 -0
  64. package/development/seat-reservation/seat-reservation-navigation/seat-reservation-navigation-services/seat-reservation-navigation-services.component.js +123 -0
  65. package/development/seat-reservation/seat-reservation-navigation/seat-reservation-navigation-services.d.ts +5 -0
  66. package/development/seat-reservation/seat-reservation-navigation/seat-reservation-navigation-services.d.ts.map +1 -0
  67. package/development/seat-reservation/seat-reservation-navigation/seat-reservation-navigation-services.js +5 -0
  68. package/development/seat-reservation/seat-reservation-navigation.d.ts +6 -0
  69. package/development/seat-reservation/seat-reservation-navigation.d.ts.map +1 -0
  70. package/development/seat-reservation/seat-reservation-navigation.js +7 -0
  71. package/development/seat-reservation/seat-reservation-place-control/seat-reservation-place-control.component.d.ts +53 -0
  72. package/development/seat-reservation/seat-reservation-place-control/seat-reservation-place-control.component.d.ts.map +1 -0
  73. package/development/seat-reservation/seat-reservation-place-control/seat-reservation-place-control.component.js +446 -0
  74. package/development/seat-reservation/seat-reservation-place-control.d.ts +5 -0
  75. package/development/seat-reservation/seat-reservation-place-control.d.ts.map +1 -0
  76. package/development/seat-reservation/seat-reservation-place-control.js +5 -0
  77. package/development/seat-reservation/seat-reservation.d.ts +7 -0
  78. package/development/seat-reservation/seat-reservation.d.ts.map +1 -0
  79. package/development/seat-reservation/seat-reservation.js +9 -0
  80. package/development/seat-reservation.d.ts +10 -0
  81. package/development/seat-reservation.d.ts.map +1 -0
  82. package/development/seat-reservation.js +30 -0
  83. package/index.d.ts +14 -0
  84. package/index.js +14 -0
  85. package/package.json +52 -2
  86. package/seat-reservation/common/mapper/icon-mapper.d.ts +112 -0
  87. package/seat-reservation/common/mapper/icon-mapper.d.ts.map +1 -0
  88. package/seat-reservation/common/mapper/icon-mapper.js +71 -0
  89. package/seat-reservation/common/mapper/mapper.d.ts +29 -0
  90. package/seat-reservation/common/mapper/mapper.d.ts.map +1 -0
  91. package/seat-reservation/common/mapper/mapper.js +87 -0
  92. package/seat-reservation/common/mapper/seat-reservation-sample-data.d.ts +225 -0
  93. package/seat-reservation/common/mapper/seat-reservation-sample-data.d.ts.map +1 -0
  94. package/seat-reservation/common/mapper/seat-reservation-sample-data.js +6149 -0
  95. package/seat-reservation/common/mapper.d.ts +3 -0
  96. package/seat-reservation/common/mapper.d.ts.map +1 -0
  97. package/seat-reservation/common/mapper.js +9 -0
  98. package/seat-reservation/common/svgs.d.ts +25 -0
  99. package/seat-reservation/common/svgs.d.ts.map +1 -0
  100. package/seat-reservation/common/svgs.js +250 -0
  101. package/seat-reservation/common/translations/i18n.d.ts +19 -0
  102. package/seat-reservation/common/translations/i18n.d.ts.map +1 -0
  103. package/seat-reservation/common/translations/i18n.js +460 -0
  104. package/seat-reservation/common/translations.d.ts +2 -0
  105. package/seat-reservation/common/translations.d.ts.map +1 -0
  106. package/seat-reservation/common/translations.js +4 -0
  107. package/seat-reservation/common/types.d.ts +71 -0
  108. package/seat-reservation/common/types.d.ts.map +1 -0
  109. package/seat-reservation/common/types.js +1 -0
  110. package/seat-reservation/common.d.ts +8 -0
  111. package/seat-reservation/common.d.ts.map +1 -0
  112. package/seat-reservation/common.js +13 -0
  113. package/seat-reservation/seat-reservation/seat-reservation-base-element.d.ts +157 -0
  114. package/seat-reservation/seat-reservation/seat-reservation-base-element.d.ts.map +1 -0
  115. package/seat-reservation/seat-reservation/seat-reservation-base-element.js +435 -0
  116. package/seat-reservation/seat-reservation/seat-reservation-scoped/seat-reservation-scoped.component.d.ts +29 -0
  117. package/seat-reservation/seat-reservation/seat-reservation-scoped/seat-reservation-scoped.component.d.ts.map +1 -0
  118. package/seat-reservation/seat-reservation/seat-reservation-scoped/seat-reservation-scoped.component.js +107 -0
  119. package/seat-reservation/seat-reservation/seat-reservation-scoped.d.ts +5 -0
  120. package/seat-reservation/seat-reservation/seat-reservation-scoped.d.ts.map +1 -0
  121. package/seat-reservation/seat-reservation/seat-reservation-scoped.js +4 -0
  122. package/seat-reservation/seat-reservation/seat-reservation.component.d.ts +62 -0
  123. package/seat-reservation/seat-reservation/seat-reservation.component.d.ts.map +1 -0
  124. package/seat-reservation/seat-reservation/seat-reservation.component.js +404 -0
  125. package/seat-reservation/seat-reservation-area/seat-reservation-area.component.d.ts +18 -0
  126. package/seat-reservation/seat-reservation-area/seat-reservation-area.component.d.ts.map +1 -0
  127. package/seat-reservation/seat-reservation-area/seat-reservation-area.component.js +49 -0
  128. package/seat-reservation/seat-reservation-area.d.ts +5 -0
  129. package/seat-reservation/seat-reservation-area.d.ts.map +1 -0
  130. package/seat-reservation/seat-reservation-area.js +4 -0
  131. package/seat-reservation/seat-reservation-graphic/seat-reservation-assets.d.ts +9 -0
  132. package/seat-reservation/seat-reservation-graphic/seat-reservation-assets.d.ts.map +1 -0
  133. package/seat-reservation/seat-reservation-graphic/seat-reservation-assets.js +317 -0
  134. package/seat-reservation/seat-reservation-graphic/seat-reservation-graphic.component.d.ts +29 -0
  135. package/seat-reservation/seat-reservation-graphic/seat-reservation-graphic.component.d.ts.map +1 -0
  136. package/seat-reservation/seat-reservation-graphic/seat-reservation-graphic.component.js +113 -0
  137. package/seat-reservation/seat-reservation-graphic.d.ts +5 -0
  138. package/seat-reservation/seat-reservation-graphic.d.ts.map +1 -0
  139. package/seat-reservation/seat-reservation-graphic.js +4 -0
  140. package/seat-reservation/seat-reservation-navigation/seat-reservation-navigation-coach/seat-reservation-navigation-coach.component.d.ts +66 -0
  141. package/seat-reservation/seat-reservation-navigation/seat-reservation-navigation-coach/seat-reservation-navigation-coach.component.d.ts.map +1 -0
  142. package/seat-reservation/seat-reservation-navigation/seat-reservation-navigation-coach/seat-reservation-navigation-coach.component.js +248 -0
  143. package/seat-reservation/seat-reservation-navigation/seat-reservation-navigation-coach.d.ts +5 -0
  144. package/seat-reservation/seat-reservation-navigation/seat-reservation-navigation-coach.d.ts.map +1 -0
  145. package/seat-reservation/seat-reservation-navigation/seat-reservation-navigation-coach.js +4 -0
  146. package/seat-reservation/seat-reservation-navigation/seat-reservation-navigation-services/seat-reservation-navigation-services.component.d.ts +21 -0
  147. package/seat-reservation/seat-reservation-navigation/seat-reservation-navigation-services/seat-reservation-navigation-services.component.d.ts.map +1 -0
  148. package/seat-reservation/seat-reservation-navigation/seat-reservation-navigation-services/seat-reservation-navigation-services.component.js +80 -0
  149. package/seat-reservation/seat-reservation-navigation/seat-reservation-navigation-services.d.ts +5 -0
  150. package/seat-reservation/seat-reservation-navigation/seat-reservation-navigation-services.d.ts.map +1 -0
  151. package/seat-reservation/seat-reservation-navigation/seat-reservation-navigation-services.js +4 -0
  152. package/seat-reservation/seat-reservation-navigation.d.ts +6 -0
  153. package/seat-reservation/seat-reservation-navigation.d.ts.map +1 -0
  154. package/seat-reservation/seat-reservation-navigation.js +6 -0
  155. package/seat-reservation/seat-reservation-place-control/seat-reservation-place-control.component.d.ts +53 -0
  156. package/seat-reservation/seat-reservation-place-control/seat-reservation-place-control.component.d.ts.map +1 -0
  157. package/seat-reservation/seat-reservation-place-control/seat-reservation-place-control.component.js +190 -0
  158. package/seat-reservation/seat-reservation-place-control.d.ts +5 -0
  159. package/seat-reservation/seat-reservation-place-control.d.ts.map +1 -0
  160. package/seat-reservation/seat-reservation-place-control.js +4 -0
  161. package/seat-reservation/seat-reservation.d.ts +7 -0
  162. package/seat-reservation/seat-reservation.d.ts.map +1 -0
  163. package/seat-reservation/seat-reservation.js +8 -0
  164. package/seat-reservation.d.ts +10 -0
  165. package/seat-reservation.d.ts.map +1 -0
  166. package/seat-reservation.js +29 -0
@@ -0,0 +1,157 @@
1
+ import { EventEmitter } from '@sbb-esta/lyne-elements/core/eventing.js';
2
+ import { LitElement, PropertyValues } from 'lit';
3
+ import { ElementDimension, ElementPosition, Place, PlaceSelection, SeatReservation, SeatReservationCoachSelection, SeatReservationPlaceSelection } from '../common.js';
4
+ declare enum ScrollDirection {
5
+ right = "right",
6
+ left = "left"
7
+ }
8
+ interface CoachScrollTriggerPoint {
9
+ start: number;
10
+ end: number;
11
+ width: number;
12
+ }
13
+ export type SeatReservationSelectedPlacesEventDetails = SeatReservationPlaceSelection[];
14
+ export declare class SeatReservationBaseElement extends LitElement {
15
+ static readonly events: {
16
+ readonly selectedPlaces: "selectedPlaces";
17
+ readonly selectedCoach: "selectedCoach";
18
+ };
19
+ /** The seat reservation object which contains all coaches and places */
20
+ accessor seatReservation: SeatReservation;
21
+ /** The seat resvervation navigation can be toggled by this property */
22
+ accessor hasNavigation: boolean;
23
+ /** The seat reservation area is aligned vertically */
24
+ accessor alignVertical: boolean;
25
+ /** The seat reservation area's base grid size */
26
+ accessor baseGridSize: number;
27
+ /** The seat reservation area's width */
28
+ accessor height: number;
29
+ /** Maximal number of possible clickable seats */
30
+ accessor maxReservations: number;
31
+ /** Any click functionality is prevented */
32
+ accessor preventPlaceClick: boolean;
33
+ protected accessor selectedCoachIndex: number;
34
+ protected accessor focusedCoachIndex: number;
35
+ /** Emits when a place was selected by user. */
36
+ protected selectedPlaces: EventEmitter<SeatReservationSelectedPlacesEventDetails>;
37
+ /** Emits when a coach was selected by user. */
38
+ protected selectedCoach: EventEmitter<SeatReservationCoachSelection>;
39
+ protected coachBorderPadding: number;
40
+ protected coachBorderOffset: number;
41
+ protected currScrollDirection: ScrollDirection;
42
+ protected maxCalcCoachsWidth: number;
43
+ protected scrollCoachsAreaWidth: number;
44
+ protected triggerCoachPositionsCollection: CoachScrollTriggerPoint[];
45
+ protected firstTabElement: HTMLElement;
46
+ protected lastTabElement: HTMLElement;
47
+ protected coachScrollArea: HTMLElement;
48
+ protected currSelectedPlace: Place | null;
49
+ protected currSelectedPlaceElementId: string | null;
50
+ protected currSelectedCoachIndex: number;
51
+ protected preventCoachScrollByPlaceClick: boolean;
52
+ protected selectedSeatReservationPlaces: SeatReservationPlaceSelection[];
53
+ protected seatReservationWithoutNavigationHasFocus: boolean;
54
+ protected isCoachGridFocusable: boolean;
55
+ protected isAutoScrolling: boolean;
56
+ protected isKeyboardNavigation: boolean;
57
+ protected keyboardNavigationEvents: {
58
+ readonly ArrowLeft: "ArrowLeft";
59
+ readonly ArrowRight: "ArrowRight";
60
+ readonly ArrowUp: "ArrowUp";
61
+ readonly ArrowDown: "ArrowDown";
62
+ readonly Tab: "Tab";
63
+ readonly Enter: "Enter";
64
+ };
65
+ protected willUpdate(changedProperties: PropertyValues<this>): void;
66
+ protected initNavigationSelectionByScrollEvent(): void;
67
+ /**
68
+ * If no navigation exists (property setting -> hasNavigation) and a table coach gets the focus,
69
+ * the first place in the coach must be automatically preselected to control the place navigation via keyboard
70
+ *
71
+ * @param focusCoachIndex
72
+ */
73
+ protected onFocusTableCoachAndPreselectPlace(focusCoachIndex: number): void;
74
+ /**
75
+ * Initialisation of Keyboard event handling to navigation between each places inside a selected coach by using [arrow] keys.
76
+ * With the [TAB] key the user navigation goes to the next coach navigation element and the currently selected place is automatically reset.
77
+ */
78
+ protected handleKeyboardEvent(event: KeyboardEvent): void;
79
+ /**
80
+ * Selects a place inside the coach if navigated via keyboard,
81
+ * otherwise the coach grid is selected (necessary for ScreenReader)
82
+ */
83
+ protected preselectPlaceInCoach(): void;
84
+ protected scrollToSelectedNavCoach(selectedNavCoachIndex: number): void;
85
+ /**
86
+ * Sets the new ScrollDirection by the new given target coach index.
87
+ */
88
+ private _setScrollDirectionByCoachIndex;
89
+ /**
90
+ * Returns the scroll start or end position X from the selected coach.
91
+ * In case the user is curretnly navigate throught places by keyboard and goes to previous coach,
92
+ * then we return the end position of the coach to get clostest next scroll position of the next focus place.
93
+ * @returns number
94
+ */
95
+ private _getCoachScrollPositionX;
96
+ /**
97
+ * Sets the focus on the HTML table (grid) caption element so that the heading is read out when using a ScreenReader.
98
+ */
99
+ private _setFocusToSelectedCoachGrid;
100
+ /**
101
+ * Returns whether the current scrolled position can be used to scroll to the selected wagon
102
+ * @returns boolean
103
+ */
104
+ private _isScrollableToSelectedCoach;
105
+ /**
106
+ * Returns the coach index which is currently visible in the scroll area
107
+ * @returns number
108
+ */
109
+ private _getCoachIndexByScrollTriggerPosition;
110
+ /**
111
+ * Get the first place of current selected coach by table cell coordinate 0-0 id.
112
+ * @returns Place or null
113
+ */
114
+ private _getFirstPlaceInSelecedCoach;
115
+ /**
116
+ * To get the correct closest place of current pressed key and the current selected place,
117
+ * we have to investigate the coordinates of each place to find the closest place of the currSelectedPlaceElementId.
118
+ * @param pressedKey
119
+ * @returns Place or null
120
+ */
121
+ private _getClosestPlaceByKeyDirection;
122
+ protected focusPlaceElement(place: Place | null, coachIndex?: number): void;
123
+ protected unfocusPlaceElement(): void;
124
+ protected getCalculatedDimension(elementDimension: ElementDimension, coachDimension?: ElementDimension, isOriginHeight?: boolean, isStretchHeight?: boolean): ElementDimension;
125
+ protected getCalculatedPosition(elementPosition: ElementPosition, elementDimension?: ElementDimension, coachDimension?: ElementDimension, isOriginHeight?: boolean): ElementPosition;
126
+ private _navigateCoachNavigationByKeyboard;
127
+ private _navigateToPlaceByKeyboard;
128
+ protected getNextAvailableCoachIndex(currentIndex?: number): number;
129
+ protected getPrevAvailableCoachIndex(currentIndex?: number): number;
130
+ protected updateSelectedSeatReservationPlaces(placeSelection: PlaceSelection): void;
131
+ protected updateCurrentSelectedPlaceInCoach(placeSelection: PlaceSelection): void;
132
+ protected updateCurrentSelectedCoach(): void;
133
+ /**
134
+ * Initialization of SeatReservationPlaceSelection Array based on the transferred places
135
+ * that have the state SELECTED within the seatReservation object
136
+ */
137
+ private _initSeatReservationPlaceSelection;
138
+ /**
139
+ * All selected places will be reset or the currentSelectedPlace was given, then we reset all except currentSelectedPlace
140
+ * @param currSelectedPlace
141
+ */
142
+ private _resetAllPlaceSelections;
143
+ private _getSeatReservationPlaceSelection;
144
+ private _getSeatReservationCoachSelection;
145
+ private _setCurrSelectedPlaceElementId;
146
+ /**
147
+ * Returns the current selected place HTML element by given placeNumber and coachIndex.
148
+ * If both doesnt exist, we try to return the place HTML element by the _currentSelectedPlaceElementId
149
+ * @param placeNumber optional as string
150
+ * @param coachIndex optional as string
151
+ * @returns HTMLElement or null
152
+ */
153
+ private _getPlaceHtmlElement;
154
+ private _setVerticalAlignmentOffset;
155
+ }
156
+ export {};
157
+ //# sourceMappingURL=seat-reservation-base-element.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seat-reservation-base-element.d.ts","sourceRoot":"","sources":["../../../../src/elements-experimental/seat-reservation/seat-reservation/seat-reservation-base-element.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,435 @@
1
+ var te = (o) => {
2
+ throw TypeError(o);
3
+ };
4
+ var ie = (o, n, d) => n.has(o) || te("Cannot " + d);
5
+ var f = (o, n, d) => (ie(o, n, "read from private field"), d ? d.call(o) : n.get(o)), g = (o, n, d) => n.has(o) ? te("Cannot add the same private member more than once") : n instanceof WeakSet ? n.add(o) : n.set(o, d), r = (o, n, d, w) => (ie(o, n, "write to private field"), w ? w.call(o, d) : n.set(o, d), d);
6
+ import { __runInitializers as h, __esDecorate as v } from "tslib";
7
+ import { isArrowKeyOrPageKeysPressed as oe } from "@sbb-esta/lyne-elements/core/a11y.js";
8
+ import { forceType as E } from "@sbb-esta/lyne-elements/core/decorators.js";
9
+ import { EventEmitter as se } from "@sbb-esta/lyne-elements/core/eventing.js";
10
+ import { LitElement as re } from "lit";
11
+ import { property as x, state as ae } from "lit/decorators.js";
12
+ import { mapPlaceInfosToPlaceSelection as le, mapPlaceAndCoachToSeatReservationPlaceSelection as he, mapCoachInfosToCoachSelection as ne } from "../common/mapper.js";
13
+ var S;
14
+ (function(o) {
15
+ o.right = "right", o.left = "left";
16
+ })(S || (S = {}));
17
+ let be = (() => {
18
+ var p, b, P, I, m, _, y, R, A, l;
19
+ let o = re, n, d = [], w = [], k, T = [], z = [], B, G = [], V = [], F, O = [], D = [], W, K = [], L = [], H, U = [], X = [], q, M = [], j = [], $, J = [], Q = [], Y, Z = [], ee = [];
20
+ return l = class extends o {
21
+ constructor() {
22
+ super(...arguments);
23
+ g(this, p);
24
+ g(this, b);
25
+ g(this, P);
26
+ g(this, I);
27
+ g(this, m);
28
+ g(this, _);
29
+ g(this, y);
30
+ g(this, R);
31
+ g(this, A);
32
+ r(this, p, h(this, d, null)), r(this, b, (h(this, w), h(this, T, !0))), r(this, P, (h(this, z), h(this, G, !1))), r(this, I, (h(this, V), h(this, O, 16))), r(this, m, (h(this, D), h(this, K, null))), r(this, _, (h(this, L), h(this, U, null))), r(this, y, (h(this, X), h(this, M, !1))), r(this, R, (h(this, j), h(this, J, -1))), r(this, A, (h(this, Q), h(this, Z, -1))), this.selectedPlaces = (h(this, ee), new se(this, l.events.selectedPlaces)), this.selectedCoach = new se(this, l.events.selectedCoach), this.coachBorderPadding = 6, this.coachBorderOffset = this.coachBorderPadding / this.baseGridSize, this.currScrollDirection = S.right, this.maxCalcCoachsWidth = 0, this.scrollCoachsAreaWidth = 0, this.triggerCoachPositionsCollection = [], this.firstTabElement = null, this.lastTabElement = null, this.coachScrollArea = null, this.currSelectedPlace = null, this.currSelectedPlaceElementId = null, this.currSelectedCoachIndex = -1, this.preventCoachScrollByPlaceClick = !1, this.selectedSeatReservationPlaces = [], this.seatReservationWithoutNavigationHasFocus = !1, this.isCoachGridFocusable = !1, this.isAutoScrolling = !1, this.isKeyboardNavigation = !1, this.keyboardNavigationEvents = {
33
+ ArrowLeft: "ArrowLeft",
34
+ ArrowRight: "ArrowRight",
35
+ ArrowUp: "ArrowUp",
36
+ ArrowDown: "ArrowDown",
37
+ Tab: "Tab",
38
+ Enter: "Enter"
39
+ };
40
+ }
41
+ /** The seat reservation object which contains all coaches and places */
42
+ get seatReservation() {
43
+ return f(this, p);
44
+ }
45
+ set seatReservation(e) {
46
+ r(this, p, e);
47
+ }
48
+ /** The seat resvervation navigation can be toggled by this property */
49
+ get hasNavigation() {
50
+ return f(this, b);
51
+ }
52
+ set hasNavigation(e) {
53
+ r(this, b, e);
54
+ }
55
+ /** The seat reservation area is aligned vertically */
56
+ get alignVertical() {
57
+ return f(this, P);
58
+ }
59
+ set alignVertical(e) {
60
+ r(this, P, e);
61
+ }
62
+ /** The seat reservation area's base grid size */
63
+ get baseGridSize() {
64
+ return f(this, I);
65
+ }
66
+ set baseGridSize(e) {
67
+ r(this, I, e);
68
+ }
69
+ /** The seat reservation area's width */
70
+ get height() {
71
+ return f(this, m);
72
+ }
73
+ set height(e) {
74
+ r(this, m, e);
75
+ }
76
+ /** Maximal number of possible clickable seats */
77
+ get maxReservations() {
78
+ return f(this, _);
79
+ }
80
+ set maxReservations(e) {
81
+ r(this, _, e);
82
+ }
83
+ /** Any click functionality is prevented */
84
+ get preventPlaceClick() {
85
+ return f(this, y);
86
+ }
87
+ set preventPlaceClick(e) {
88
+ r(this, y, e);
89
+ }
90
+ get selectedCoachIndex() {
91
+ return f(this, R);
92
+ }
93
+ set selectedCoachIndex(e) {
94
+ r(this, R, e);
95
+ }
96
+ get focusedCoachIndex() {
97
+ return f(this, A);
98
+ }
99
+ set focusedCoachIndex(e) {
100
+ r(this, A, e);
101
+ }
102
+ willUpdate(e) {
103
+ var t, i;
104
+ super.willUpdate(e), e.has("seatReservation") && this._initSeatReservationPlaceSelection(), e.has("baseGridSize") && (this.coachBorderOffset = this.coachBorderPadding / this.baseGridSize, (t = this.style) == null || t.setProperty("--sbb-seat-reservation-grid-size", `${this.baseGridSize}px`), this.alignVertical && this._setVerticalAlignmentOffset()), e.has("height") && this.height && this.seatReservation.coachItems.length && (this.baseGridSize = this.height / this.seatReservation.coachItems[0].dimension.h, this.coachBorderOffset = this.coachBorderPadding / this.baseGridSize, (i = this.style) == null || i.setProperty("--sbb-seat-reservation-grid-size", `${this.baseGridSize}px`), this.alignVertical && this._setVerticalAlignmentOffset()), e.has("alignVertical") && this.alignVertical && this._setVerticalAlignmentOffset();
105
+ }
106
+ /* Init scroll event handling for coach navigation */
107
+ initNavigationSelectionByScrollEvent() {
108
+ var e, t, i;
109
+ if (this.firstTabElement = (e = this.shadowRoot) == null ? void 0 : e.getElementById("first-tab-element"), this.lastTabElement = (t = this.shadowRoot) == null ? void 0 : t.getElementById("last-tab-element"), this.coachScrollArea = (i = this.shadowRoot) == null ? void 0 : i.getElementById("sbb-sr__parent-area"), this.coachScrollArea) {
110
+ let s = 0;
111
+ this.scrollCoachsAreaWidth = this.coachScrollArea.getBoundingClientRect().width, this.triggerCoachPositionsCollection = this.seatReservation.coachItems.map((c) => {
112
+ const C = s, u = this.getCalculatedDimension(c.dimension).w;
113
+ return s += u, {
114
+ start: C,
115
+ end: s,
116
+ width: u
117
+ };
118
+ }), this.maxCalcCoachsWidth = s, this.coachScrollArea.addEventListener("scrollend", () => {
119
+ const c = this.isAutoScrolling ? this.currSelectedCoachIndex : this._getCoachIndexByScrollTriggerPosition();
120
+ this._isScrollableToSelectedCoach() ? this.currSelectedCoachIndex = c : this.currSelectedCoachIndex = c < this.currSelectedCoachIndex ? this.currSelectedCoachIndex : c, this.preventCoachScrollByPlaceClick = !1, this.updateCurrentSelectedCoach(), this.hasNavigation || (this.preselectPlaceInCoach(), this.isAutoScrolling = !1);
121
+ }), this.alignVertical && this._setVerticalAlignmentOffset();
122
+ }
123
+ }
124
+ /**
125
+ * If no navigation exists (property setting -> hasNavigation) and a table coach gets the focus,
126
+ * the first place in the coach must be automatically preselected to control the place navigation via keyboard
127
+ *
128
+ * @param focusCoachIndex
129
+ */
130
+ onFocusTableCoachAndPreselectPlace(e) {
131
+ !this.seatReservationWithoutNavigationHasFocus && !this.hasNavigation && (this.seatReservationWithoutNavigationHasFocus = !0, this.currSelectedCoachIndex = e === 0 ? this.getNextAvailableCoachIndex(-1) : this.getPrevAvailableCoachIndex(e), this.preselectPlaceInCoach());
132
+ }
133
+ /**
134
+ * Initialisation of Keyboard event handling to navigation between each places inside a selected coach by using [arrow] keys.
135
+ * With the [TAB] key the user navigation goes to the next coach navigation element and the currently selected place is automatically reset.
136
+ */
137
+ handleKeyboardEvent(e) {
138
+ const t = e.key;
139
+ if (this.currSelectedPlace) {
140
+ if (e.shiftKey && e.keyCode === 9) {
141
+ this._navigateCoachNavigationByKeyboard("PREV_TAB"), e.preventDefault();
142
+ return;
143
+ }
144
+ if (t === this.keyboardNavigationEvents.Tab) {
145
+ this._navigateCoachNavigationByKeyboard("NEXT_TAB"), e.preventDefault();
146
+ return;
147
+ }
148
+ }
149
+ if (this.currSelectedCoachIndex !== -1 && oe(e))
150
+ switch (e.preventDefault(), t) {
151
+ case this.keyboardNavigationEvents.ArrowLeft:
152
+ {
153
+ const i = this.alignVertical ? this.keyboardNavigationEvents.ArrowDown : t;
154
+ this._navigateToPlaceByKeyboard(i);
155
+ }
156
+ break;
157
+ case this.keyboardNavigationEvents.ArrowRight:
158
+ {
159
+ const i = this.alignVertical ? this.keyboardNavigationEvents.ArrowUp : t;
160
+ this._navigateToPlaceByKeyboard(i);
161
+ }
162
+ break;
163
+ case this.keyboardNavigationEvents.ArrowUp:
164
+ {
165
+ const i = this.alignVertical ? this.keyboardNavigationEvents.ArrowLeft : t;
166
+ this._navigateToPlaceByKeyboard(i);
167
+ }
168
+ break;
169
+ case this.keyboardNavigationEvents.ArrowDown:
170
+ {
171
+ const i = this.alignVertical ? this.keyboardNavigationEvents.ArrowRight : t;
172
+ this._navigateToPlaceByKeyboard(i);
173
+ }
174
+ break;
175
+ }
176
+ }
177
+ /**
178
+ * Selects a place inside the coach if navigated via keyboard,
179
+ * otherwise the coach grid is selected (necessary for ScreenReader)
180
+ */
181
+ preselectPlaceInCoach() {
182
+ const e = this._getClosestPlaceByKeyDirection();
183
+ e && this.unfocusPlaceElement(), this.isKeyboardNavigation && this.isAutoScrolling ? e && this.focusPlaceElement(e) : (this.currSelectedPlace = e, this._setFocusToSelectedCoachGrid());
184
+ }
185
+ scrollToSelectedNavCoach(e) {
186
+ if (e !== this.currSelectedCoachIndex) {
187
+ this.isAutoScrolling = !0, this.isCoachGridFocusable = !0, this.currSelectedCoachIndex = e, this._setScrollDirectionByCoachIndex();
188
+ const t = this._getCoachScrollPositionX();
189
+ (this.selectedCoachIndex !== -1 || this.currSelectedCoachIndex > 0) && this._isScrollableToSelectedCoach() ? this.coachScrollArea.scrollTo({
190
+ top: 0,
191
+ left: t,
192
+ behavior: "smooth"
193
+ }) : this.updateCurrentSelectedCoach();
194
+ }
195
+ }
196
+ /**
197
+ * Sets the new ScrollDirection by the new given target coach index.
198
+ */
199
+ _setScrollDirectionByCoachIndex() {
200
+ this.currScrollDirection = this.currSelectedCoachIndex > this.selectedCoachIndex ? S.right : S.left;
201
+ }
202
+ /**
203
+ * Returns the scroll start or end position X from the selected coach.
204
+ * In case the user is curretnly navigate throught places by keyboard and goes to previous coach,
205
+ * then we return the end position of the coach to get clostest next scroll position of the next focus place.
206
+ * @returns number
207
+ */
208
+ _getCoachScrollPositionX() {
209
+ const e = this.triggerCoachPositionsCollection[this.currSelectedCoachIndex];
210
+ return this.isKeyboardNavigation && this.currScrollDirection === S.left && e.width > this.scrollCoachsAreaWidth ? e.end - this.scrollCoachsAreaWidth : e.start;
211
+ }
212
+ /**
213
+ * Sets the focus on the HTML table (grid) caption element so that the heading is read out when using a ScreenReader.
214
+ */
215
+ _setFocusToSelectedCoachGrid() {
216
+ var e;
217
+ if (this.isCoachGridFocusable) {
218
+ this.isCoachGridFocusable = !1;
219
+ const t = (e = this.shadowRoot) == null ? void 0 : e.querySelector("#sbb-sr-coach-caption-" + this.currSelectedCoachIndex);
220
+ t && t.focus();
221
+ }
222
+ }
223
+ /**
224
+ * Returns whether the current scrolled position can be used to scroll to the selected wagon
225
+ * @returns boolean
226
+ */
227
+ _isScrollableToSelectedCoach() {
228
+ const e = this.coachScrollArea.scrollLeft, t = this.coachScrollArea.getBoundingClientRect().width, i = this.maxCalcCoachsWidth - t, s = this.triggerCoachPositionsCollection[this.currSelectedCoachIndex], c = e === this.triggerCoachPositionsCollection[this.currSelectedCoachIndex].start;
229
+ return (e < i || e > s.start) && !c;
230
+ }
231
+ /**
232
+ * Returns the coach index which is currently visible in the scroll area
233
+ * @returns number
234
+ */
235
+ _getCoachIndexByScrollTriggerPosition() {
236
+ const e = this.coachScrollArea.scrollLeft + this.scrollCoachsAreaWidth / 2;
237
+ return this.triggerCoachPositionsCollection.findIndex((t) => e >= t.start && e <= t.end);
238
+ }
239
+ /**
240
+ * Get the first place of current selected coach by table cell coordinate 0-0 id.
241
+ * @returns Place or null
242
+ */
243
+ _getFirstPlaceInSelecedCoach() {
244
+ var c, C, u, N, a;
245
+ let e = null;
246
+ const t = (c = this.seatReservation) == null ? void 0 : c.coachItems[this.currSelectedCoachIndex], i = "cell-" + this.currSelectedCoachIndex + "-0-0", s = ((N = (u = (C = this.shadowRoot) == null ? void 0 : C.querySelector("[cell-id='" + i + "']")) == null ? void 0 : u.querySelector("sbb-seat-reservation-place-control")) == null ? void 0 : N.getAttribute("text")) || null;
247
+ return t && s && (e = ((a = t.places) == null ? void 0 : a.find((ce) => ce.number === s)) || null), e;
248
+ }
249
+ /**
250
+ * To get the correct closest place of current pressed key and the current selected place,
251
+ * we have to investigate the coordinates of each place to find the closest place of the currSelectedPlaceElementId.
252
+ * @param pressedKey
253
+ * @returns Place or null
254
+ */
255
+ _getClosestPlaceByKeyDirection(e) {
256
+ var s, c, C, u, N;
257
+ const t = (s = this.seatReservation) == null ? void 0 : s.coachItems[this.currSelectedCoachIndex];
258
+ let i = null;
259
+ if (t.places)
260
+ if (this.currSelectedPlaceElementId) {
261
+ if (this.currSelectedPlace)
262
+ for (const a of t.places)
263
+ e ? a.number !== ((u = this.currSelectedPlace) == null ? void 0 : u.number) && (e === this.keyboardNavigationEvents.ArrowRight && (a.position.y === this.currSelectedPlace.position.y || a.position.y === this.currSelectedPlace.position.y - 1) && a.position.x > this.currSelectedPlace.position.x && (!i || a.position.x < i.position.x) || e === this.keyboardNavigationEvents.ArrowDown && (a.position.x === this.currSelectedPlace.position.x || a.position.x === this.currSelectedPlace.position.x + 1) && a.position.y > this.currSelectedPlace.position.y && (!i || a.position.y < i.position.y) || e === this.keyboardNavigationEvents.ArrowLeft && (a.position.y === this.currSelectedPlace.position.y || a.position.y === this.currSelectedPlace.position.y + 1) && a.position.x < this.currSelectedPlace.position.x && (!i || a.position.x > i.position.x) || e === this.keyboardNavigationEvents.ArrowUp && (a.position.x === this.currSelectedPlace.position.x || a.position.x === this.currSelectedPlace.position.x - 1) && a.position.y < ((N = this.currSelectedPlace) == null ? void 0 : N.position.y) && (!i || a.position.y > i.position.y)) && (i = a) : (this.currScrollDirection === S.right && a.position.y === ((c = this.currSelectedPlace) == null ? void 0 : c.position.y) && (!i || a.position.x < i.position.x) || this.currScrollDirection === S.left && a.position.y === ((C = this.currSelectedPlace) == null ? void 0 : C.position.y) && (!i || a.position.x > i.position.x)) && (i = a);
264
+ } else
265
+ return this._getFirstPlaceInSelecedCoach();
266
+ return i;
267
+ }
268
+ focusPlaceElement(e, t) {
269
+ if (this.unfocusPlaceElement(), e) {
270
+ this.currSelectedPlace = e, t && (this.currSelectedCoachIndex = t), this._setCurrSelectedPlaceElementId(e);
271
+ const i = this._getPlaceHtmlElement();
272
+ i && i.setAttribute("keyfocus", "focus");
273
+ }
274
+ }
275
+ unfocusPlaceElement() {
276
+ const e = this._getPlaceHtmlElement();
277
+ e && (e.setAttribute("keyfocus", "unfocus"), this._setCurrSelectedPlaceElementId(null), this.currSelectedPlace = null);
278
+ }
279
+ getCalculatedDimension(e, t, i, s) {
280
+ return t && !i && (e.h += this.coachBorderOffset * 2), s && (e.h += this.coachBorderOffset), {
281
+ w: this.baseGridSize * e.w,
282
+ h: this.baseGridSize * e.h
283
+ };
284
+ }
285
+ getCalculatedPosition(e, t, i, s) {
286
+ if (i && t) {
287
+ const c = s ? i.h : i.h + this.coachBorderOffset;
288
+ e.y === 0 ? e.y -= this.coachBorderOffset : e.y + t.h === c && (e.y += this.coachBorderOffset);
289
+ }
290
+ return {
291
+ x: this.baseGridSize * e.x,
292
+ y: this.baseGridSize * e.y,
293
+ z: e.z
294
+ };
295
+ }
296
+ // Handling for Tab navigation if an place is selected inside the coach.
297
+ // This controls the focused coach from the current selected coach.
298
+ _navigateCoachNavigationByKeyboard(e) {
299
+ const t = this.focusedCoachIndex === -1 ? this.currSelectedCoachIndex === -1 ? 0 : this.currSelectedCoachIndex : this.focusedCoachIndex, i = e === "NEXT_TAB" ? this.getNextAvailableCoachIndex(t) : this.getPrevAvailableCoachIndex(t);
300
+ if (t === i) {
301
+ this.unfocusPlaceElement(), this.selectedCoachIndex = -1, this.currSelectedCoachIndex = -1, this.seatReservationWithoutNavigationHasFocus = !1, e === "NEXT_TAB" ? this.lastTabElement.focus() : this.firstTabElement.focus();
302
+ return;
303
+ }
304
+ if (this.hasNavigation) {
305
+ const s = this._getPlaceHtmlElement(), c = s ? s.getAttribute("keyfocus") === "focus" : !1;
306
+ e === "PREV_TAB" && this.selectedCoachIndex === t ? c ? (this.focusedCoachIndex = t, this.unfocusPlaceElement()) : this.focusedCoachIndex = i : i !== this.currSelectedCoachIndex ? this.focusedCoachIndex = i : (this.focusedCoachIndex = -1, this.selectedCoachIndex = i, c ? this.focusPlaceElement(this.currSelectedPlace) : (this.isCoachGridFocusable = !0, this._setFocusToSelectedCoachGrid()));
307
+ } else
308
+ this.scrollToSelectedNavCoach(i);
309
+ }
310
+ _navigateToPlaceByKeyboard(e) {
311
+ if (this.preventCoachScrollByPlaceClick = !1, this.isKeyboardNavigation = !0, this.focusedCoachIndex !== -1 && (this.focusedCoachIndex = -1), !this.preventPlaceClick) {
312
+ const t = this._getClosestPlaceByKeyDirection(e);
313
+ if (t)
314
+ this.focusPlaceElement(t);
315
+ else if (e === this.keyboardNavigationEvents.ArrowRight || e === this.keyboardNavigationEvents.ArrowLeft || this.alignVertical && (e === this.keyboardNavigationEvents.ArrowUp || e === this.keyboardNavigationEvents.ArrowDown)) {
316
+ const i = e === this.keyboardNavigationEvents.ArrowRight ? this.getNextAvailableCoachIndex() : this.getPrevAvailableCoachIndex();
317
+ this.scrollToSelectedNavCoach(i);
318
+ }
319
+ }
320
+ }
321
+ getNextAvailableCoachIndex(e) {
322
+ const t = e ?? this.currSelectedCoachIndex;
323
+ return t < this.seatReservation.coachItems.length - 1 ? t + 1 : t;
324
+ }
325
+ getPrevAvailableCoachIndex(e) {
326
+ const t = e ?? this.currSelectedCoachIndex;
327
+ return t > 0 ? t - 1 : t;
328
+ }
329
+ updateSelectedSeatReservationPlaces(e) {
330
+ if (e.state === "SELECTED") {
331
+ const t = this._getSeatReservationPlaceSelection(e);
332
+ t && this.selectedSeatReservationPlaces.push(t);
333
+ } else
334
+ this.selectedSeatReservationPlaces = this.selectedSeatReservationPlaces.filter((t) => t.id !== e.id);
335
+ this.maxReservations && this.selectedSeatReservationPlaces.length > this.maxReservations && this._resetAllPlaceSelections(e), this.selectedPlaces.emit(this.selectedSeatReservationPlaces);
336
+ }
337
+ updateCurrentSelectedPlaceInCoach(e) {
338
+ var s;
339
+ const t = e.coachIndex, i = (s = this.seatReservation.coachItems[t].places) == null ? void 0 : s.find((c) => c.number == e.number);
340
+ i && (this.currSelectedCoachIndex = t, this.currSelectedPlace = i, this.currSelectedCoachIndex !== this.selectedCoachIndex && this.updateCurrentSelectedCoach(), this._setCurrSelectedPlaceElementId(i));
341
+ }
342
+ updateCurrentSelectedCoach() {
343
+ this.selectedCoachIndex = this.currSelectedCoachIndex, this.focusedCoachIndex = -1;
344
+ const e = this._getSeatReservationCoachSelection(this.selectedCoachIndex);
345
+ e && this.selectedCoach.emit(e);
346
+ }
347
+ /**
348
+ * Initialization of SeatReservationPlaceSelection Array based on the transferred places
349
+ * that have the state SELECTED within the seatReservation object
350
+ */
351
+ _initSeatReservationPlaceSelection() {
352
+ this.seatReservation.coachItems.map((e, t) => {
353
+ var i, s;
354
+ (s = (i = e.places) == null ? void 0 : i.filter((c) => c.state === "SELECTED")) == null || s.forEach((c) => {
355
+ const C = le(c, t), u = this._getSeatReservationPlaceSelection(C);
356
+ u && this.selectedSeatReservationPlaces.push(u);
357
+ });
358
+ });
359
+ }
360
+ /**
361
+ * All selected places will be reset or the currentSelectedPlace was given, then we reset all except currentSelectedPlace
362
+ * @param currSelectedPlace
363
+ */
364
+ _resetAllPlaceSelections(e) {
365
+ var t;
366
+ for (const i of this.selectedSeatReservationPlaces)
367
+ (!e || e.id !== i.id) && ((t = this.shadowRoot) == null ? void 0 : t.getElementById(i.id)).setAttribute("state", "FREE");
368
+ e ? this.selectedSeatReservationPlaces = this.selectedSeatReservationPlaces.filter((i) => i.id === e.id) : this.selectedSeatReservationPlaces = [];
369
+ }
370
+ _getSeatReservationPlaceSelection(e) {
371
+ var s;
372
+ const t = this.seatReservation.coachItems[e.coachIndex], i = (s = t.places) == null ? void 0 : s.find((c) => c.number === e.number);
373
+ return i ? he(i, t, e.coachIndex) : null;
374
+ }
375
+ _getSeatReservationCoachSelection(e) {
376
+ if (!this.seatReservation.coachItems[e])
377
+ return null;
378
+ const t = this.seatReservation.coachItems[e];
379
+ return ne(e, t);
380
+ }
381
+ _setCurrSelectedPlaceElementId(e) {
382
+ e ? this.currSelectedPlaceElementId = "seat-reservation__place-button-" + this.currSelectedCoachIndex + "-" + e.number : this.currSelectedPlaceElementId = null;
383
+ }
384
+ /**
385
+ * Returns the current selected place HTML element by given placeNumber and coachIndex.
386
+ * If both doesnt exist, we try to return the place HTML element by the _currentSelectedPlaceElementId
387
+ * @param placeNumber optional as string
388
+ * @param coachIndex optional as string
389
+ * @returns HTMLElement or null
390
+ */
391
+ _getPlaceHtmlElement(e, t) {
392
+ var c;
393
+ const i = t || this.currSelectedCoachIndex, s = e ? "seat-reservation__place-button-" + i + "-" + e : this.currSelectedPlaceElementId;
394
+ return s && ((c = this.shadowRoot) == null ? void 0 : c.getElementById(s)) || null;
395
+ }
396
+ //Set the vertical offset
397
+ _setVerticalAlignmentOffset() {
398
+ setTimeout(() => {
399
+ var t, i;
400
+ const e = (t = this.shadowRoot) == null ? void 0 : t.querySelector(".sbb-sr__wrapper");
401
+ if (e) {
402
+ const s = e.getBoundingClientRect().width;
403
+ (i = this.style) == null || i.setProperty("--sbb-seat-reservation-vertical-offset", `${s}px`);
404
+ }
405
+ });
406
+ }
407
+ }, p = new WeakMap(), b = new WeakMap(), P = new WeakMap(), I = new WeakMap(), m = new WeakMap(), _ = new WeakMap(), y = new WeakMap(), R = new WeakMap(), A = new WeakMap(), (() => {
408
+ const e = typeof Symbol == "function" && Symbol.metadata ? Object.create(o[Symbol.metadata] ?? null) : void 0;
409
+ n = [x({ attribute: "seat-reservation", type: Object })], k = [E(), x({ attribute: "has-navigation", type: Boolean })], B = [E(), x({ attribute: "align-vertical", type: Boolean })], F = [E(), x({ attribute: "base-grid-size", type: Number })], W = [E(), x({ attribute: "height", type: Number })], H = [E(), x({ attribute: "max-reservations", type: Number })], q = [E(), x({ attribute: "prevent-place-click", type: Boolean })], $ = [ae()], Y = [ae()], v(l, null, n, { kind: "accessor", name: "seatReservation", static: !1, private: !1, access: { has: (t) => "seatReservation" in t, get: (t) => t.seatReservation, set: (t, i) => {
410
+ t.seatReservation = i;
411
+ } }, metadata: e }, d, w), v(l, null, k, { kind: "accessor", name: "hasNavigation", static: !1, private: !1, access: { has: (t) => "hasNavigation" in t, get: (t) => t.hasNavigation, set: (t, i) => {
412
+ t.hasNavigation = i;
413
+ } }, metadata: e }, T, z), v(l, null, B, { kind: "accessor", name: "alignVertical", static: !1, private: !1, access: { has: (t) => "alignVertical" in t, get: (t) => t.alignVertical, set: (t, i) => {
414
+ t.alignVertical = i;
415
+ } }, metadata: e }, G, V), v(l, null, F, { kind: "accessor", name: "baseGridSize", static: !1, private: !1, access: { has: (t) => "baseGridSize" in t, get: (t) => t.baseGridSize, set: (t, i) => {
416
+ t.baseGridSize = i;
417
+ } }, metadata: e }, O, D), v(l, null, W, { kind: "accessor", name: "height", static: !1, private: !1, access: { has: (t) => "height" in t, get: (t) => t.height, set: (t, i) => {
418
+ t.height = i;
419
+ } }, metadata: e }, K, L), v(l, null, H, { kind: "accessor", name: "maxReservations", static: !1, private: !1, access: { has: (t) => "maxReservations" in t, get: (t) => t.maxReservations, set: (t, i) => {
420
+ t.maxReservations = i;
421
+ } }, metadata: e }, U, X), v(l, null, q, { kind: "accessor", name: "preventPlaceClick", static: !1, private: !1, access: { has: (t) => "preventPlaceClick" in t, get: (t) => t.preventPlaceClick, set: (t, i) => {
422
+ t.preventPlaceClick = i;
423
+ } }, metadata: e }, M, j), v(l, null, $, { kind: "accessor", name: "selectedCoachIndex", static: !1, private: !1, access: { has: (t) => "selectedCoachIndex" in t, get: (t) => t.selectedCoachIndex, set: (t, i) => {
424
+ t.selectedCoachIndex = i;
425
+ } }, metadata: e }, J, Q), v(l, null, Y, { kind: "accessor", name: "focusedCoachIndex", static: !1, private: !1, access: { has: (t) => "focusedCoachIndex" in t, get: (t) => t.focusedCoachIndex, set: (t, i) => {
426
+ t.focusedCoachIndex = i;
427
+ } }, metadata: e }, Z, ee), e && Object.defineProperty(l, Symbol.metadata, { enumerable: !0, configurable: !0, writable: !0, value: e });
428
+ })(), l.events = {
429
+ selectedPlaces: "selectedPlaces",
430
+ selectedCoach: "selectedCoach"
431
+ }, l;
432
+ })();
433
+ export {
434
+ be as SeatReservationBaseElement
435
+ };
@@ -0,0 +1,29 @@
1
+ import { CSSResultGroup, PropertyValues, TemplateResult, LitElement } from 'lit';
2
+ /**
3
+ * Wrapper class for scoped elements with similar properties to set.
4
+ */
5
+ export declare class SbbSeatReservationScopedElement extends LitElement {
6
+ static styles: CSSResultGroup;
7
+ /** Inset block start in pixels (without unit) */
8
+ accessor insetBlockStart: string;
9
+ /** Inset inline start in pixels (without unit) */
10
+ accessor insetInlineStart: string;
11
+ /** Width of the scoped element in pixels (without unit) */
12
+ accessor width: string;
13
+ /** Height of the scoped element in pixels (without unit) */
14
+ accessor height: string;
15
+ /** Z-index of the scoped element */
16
+ accessor zIndex: string;
17
+ /** Cell id of the scoped element, if it is used in a table */
18
+ accessor cellId: string;
19
+ /** Scoped classes for the scoped element */
20
+ accessor scopedClasses: string;
21
+ protected willUpdate(_changedProperties: PropertyValues): void;
22
+ protected render(): TemplateResult;
23
+ }
24
+ declare global {
25
+ interface HTMLElementTagNameMap {
26
+ 'sbb-seat-reservation-scoped': SbbSeatReservationScopedElement;
27
+ }
28
+ }
29
+ //# sourceMappingURL=seat-reservation-scoped.component.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seat-reservation-scoped.component.d.ts","sourceRoot":"","sources":["../../../../../src/elements-experimental/seat-reservation/seat-reservation/seat-reservation-scoped/seat-reservation-scoped.component.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AACpF,OAAO,EAAQ,UAAU,EAAE,MAAM,KAAK,CAAC;AAKvC;;GAEG;AACH,qBAEM,+BAAgC,SAAQ,UAAU;IACtD,OAAuB,MAAM,EAAE,cAAc,CAAS;IAEtD,iDAAiD;IACjD,SAEgB,eAAe,EAAE,MAAM,CAAM;IAE7C,kDAAkD;IAClD,SAEgB,gBAAgB,EAAE,MAAM,CAAM;IAE9C,2DAA2D;IAC3D,SAEgB,KAAK,EAAE,MAAM,CAAM;IAEnC,4DAA4D;IAC5D,SAEgB,MAAM,EAAE,MAAM,CAAM;IAEpC,oCAAoC;IACpC,SAEgB,MAAM,EAAE,MAAM,CAAM;IAEpC,8DAA8D;IAC9D,SAEgB,MAAM,EAAE,MAAM,CAAM;IAEpC,4CAA4C;IAC5C,SAEgB,aAAa,EAAE,MAAM,CAAM;cAExB,UAAU,CAAC,kBAAkB,EAAE,cAAc,GAAG,IAAI;cA8BpD,MAAM,IAAI,cAAc;CAW5C;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAE7B,6BAA6B,EAAE,+BAA+B,CAAC;KAChE;CACF"}