mautourco-components 0.2.117 → 0.2.119

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 (27) hide show
  1. package/dist/components/molecules/AgeSelector/AgeSelector.d.ts +1 -1
  2. package/dist/components/molecules/AgeSelector/AgeSelector.js +1 -1
  3. package/dist/components/organisms/PaxSelector/ClientTypeSelector.d.ts +7 -0
  4. package/dist/components/organisms/PaxSelector/ClientTypeSelector.js +29 -0
  5. package/dist/components/organisms/PaxSelector/PaxSelector.d.ts +4 -1
  6. package/dist/components/organisms/PaxSelector/PaxSelector.js +23 -145
  7. package/dist/components/organisms/PaxSelector/RoomEditor.d.ts +17 -0
  8. package/dist/components/organisms/PaxSelector/RoomEditor.js +130 -0
  9. package/dist/components/organisms/PaxSelector/StepperRow.d.ts +9 -0
  10. package/dist/components/organisms/PaxSelector/StepperRow.js +18 -0
  11. package/dist/components/organisms/RoundTrip/RoundTrip.js +13 -8
  12. package/dist/components/organisms/SearchBarTransfer/SearchBarTransfer.js +3 -5
  13. package/dist/components/organisms/TopNavigation/DesktopNav.d.ts +1 -0
  14. package/dist/components/organisms/TransferLine/TransferLine.js +4 -1
  15. package/dist/hooks/useTransferAge.d.ts +5 -0
  16. package/dist/hooks/useTransferAge.js +26 -0
  17. package/dist/index.d.ts +2 -1
  18. package/package.json +1 -1
  19. package/src/components/molecules/AgeSelector/AgeSelector.tsx +2 -2
  20. package/src/components/organisms/PaxSelector/ClientTypeSelector.tsx +83 -0
  21. package/src/components/organisms/PaxSelector/PaxSelector.tsx +32 -422
  22. package/src/components/organisms/PaxSelector/RoomEditor.tsx +290 -0
  23. package/src/components/organisms/PaxSelector/StepperRow.tsx +63 -0
  24. package/src/components/organisms/RoundTrip/RoundTrip.tsx +16 -10
  25. package/src/components/organisms/SearchBarTransfer/SearchBarTransfer.tsx +4 -7
  26. package/src/components/organisms/TopNavigation/DesktopNav.tsx +1 -0
  27. package/src/components/organisms/TransferLine/TransferLine.tsx +5 -3
@@ -6,7 +6,7 @@ export interface AgeSelectorProps {
6
6
  /** Current selected age value */
7
7
  value: number | undefined;
8
8
  /** Callback when age changes */
9
- onChange: (age: number) => void;
9
+ onChange: (age: number | undefined) => void;
10
10
  /** Available age range */
11
11
  ageRange: number[];
12
12
  /** Whether the field is required */
@@ -35,7 +35,7 @@ var AgeSelector = function (_a) {
35
35
  var numValue = parseInt(newValue, 10);
36
36
  if (newValue === '') {
37
37
  // Allow empty input - don't update onChange
38
- return;
38
+ return onChange(undefined);
39
39
  }
40
40
  else if (!isNaN(numValue) && ageRange.includes(numValue)) {
41
41
  onChange(numValue);
@@ -0,0 +1,7 @@
1
+ export type ClientType = 'Standard client' | 'VIP' | 'VVIP' | 'Honeymooners';
2
+ interface ClientTypeSelectorProps {
3
+ value: ClientType;
4
+ onChange: (value: ClientType) => void;
5
+ }
6
+ declare const ClientTypeSelector: React.FC<ClientTypeSelectorProps>;
7
+ export default ClientTypeSelector;
@@ -0,0 +1,29 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useRef, useState } from 'react';
3
+ import Icon from '../../atoms/Icon/Icon';
4
+ import { Text } from '../../atoms/Typography/Typography';
5
+ var CLIENT_TYPES = ['Standard client', 'VIP', 'VVIP', 'Honeymooners'];
6
+ var ClientTypeSelector = function (_a) {
7
+ var value = _a.value, onChange = _a.onChange;
8
+ var _b = useState(false), isOpen = _b[0], setIsOpen = _b[1];
9
+ var containerRef = useRef(null);
10
+ useEffect(function () {
11
+ var handleClickOutside = function (event) {
12
+ if (containerRef.current && !containerRef.current.contains(event.target)) {
13
+ setIsOpen(false);
14
+ }
15
+ };
16
+ if (isOpen) {
17
+ document.addEventListener('mousedown', handleClickOutside);
18
+ }
19
+ return function () {
20
+ document.removeEventListener('mousedown', handleClickOutside);
21
+ };
22
+ }, [isOpen]);
23
+ var handleSelect = function (type) {
24
+ onChange(type);
25
+ setIsOpen(false);
26
+ };
27
+ return (_jsxs("div", { className: "pax-selector__client-type", children: [_jsx(Text, { size: "sm", variant: "regular", className: "pax-selector__client-type-label", children: "Client type" }), _jsxs("div", { className: "pax-selector__client-type-select", ref: containerRef, children: [_jsxs("button", { type: "button", className: "pax-selector__client-type-trigger", onClick: function () { return setIsOpen(!isOpen); }, "aria-expanded": isOpen, "aria-haspopup": "listbox", children: [_jsxs("div", { className: "pax-selector__client-type-content", children: [_jsx(Icon, { name: "user-icon", size: "sm", className: "pax-selector__client-type-icon" }), _jsx("span", { className: "pax-selector__client-type-text", children: value })] }), _jsx(Icon, { name: "chevron-down", size: "sm", className: "pax-selector__client-type-chevron ".concat(isOpen ? 'pax-selector__client-type-chevron--open' : '') })] }), isOpen && (_jsx("div", { className: "pax-selector__client-type-dropdown", role: "listbox", children: CLIENT_TYPES.map(function (type) { return (_jsxs("button", { type: "button", className: "pax-selector__client-type-option ".concat(value === type ? 'pax-selector__client-type-option--selected' : ''), onClick: function () { return handleSelect(type); }, role: "option", "aria-selected": value === type, children: [_jsx(Icon, { name: "user-icon", size: "sm" }), type] }, type)); }) }))] })] }));
28
+ };
29
+ export default ClientTypeSelector;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- export type ClientType = 'Standard client' | 'VIP' | 'VVIP' | 'Honeymooners';
2
+ import { ClientType } from './ClientTypeSelector';
3
3
  /**
4
4
  * Individual passenger/pax data for a single room
5
5
  */
@@ -66,7 +66,10 @@ export interface PaxSelectorProps {
66
66
  ageRange?: number[];
67
67
  /** Whether to check if age inputs are empty and show error state */
68
68
  checkEmpty?: boolean;
69
+ /** Callback when pax selector opens */
69
70
  onPaxOpenChange?: () => void;
71
+ /** Callback when pax validation is checked */
72
+ onPaxInvalid?: (isValid: boolean) => void;
70
73
  }
71
74
  export declare const DEFAULT_PAX_DATA_WITH_ADULTS: PaxData;
72
75
  export declare const CHILD_CATEGORY_AGES: number[];
@@ -24,6 +24,9 @@ import { scrollIntoViewOnOpen } from '../../../lib/utils';
24
24
  import Icon from '../../atoms/Icon/Icon';
25
25
  import { Text } from '../../atoms/Typography/Typography';
26
26
  import AgeSelector from '../../molecules/AgeSelector/AgeSelector';
27
+ import ClientTypeSelector from './ClientTypeSelector';
28
+ import RoomEditor from './RoomEditor';
29
+ import StepperRow from './StepperRow';
27
30
  var DEFAULT_PAX_DATA = {
28
31
  adults: 0,
29
32
  teens: 0,
@@ -44,149 +47,14 @@ export var DEFAULT_PAX_DATA_WITH_ADULTS = {
44
47
  infantAges: [],
45
48
  clientType: 'Standard client',
46
49
  };
47
- var CLIENT_TYPES = ['Standard client', 'VIP', 'VVIP', 'Honeymooners'];
48
50
  // Age range for all child categories (teens, children, infants)
49
51
  export var CHILD_CATEGORY_AGES = Array.from({ length: 18 }, function (_, i) { return i + 1; }); // 1-18 years
50
- var StepperRow = function (_a) {
51
- var label = _a.label, value = _a.value, _b = _a.min, min = _b === void 0 ? 0 : _b, _c = _a.max, max = _c === void 0 ? 99 : _c, onChange = _a.onChange;
52
- var handleDecrement = function () {
53
- if (value > min) {
54
- onChange(value - 1);
55
- }
56
- };
57
- var handleIncrement = function () {
58
- if (value < max) {
59
- onChange(value + 1);
60
- }
61
- };
62
- return (_jsxs("div", { className: "pax-selector__stepper", children: [_jsx(Text, { size: "base", variant: "bold", color: "default", className: "pax-selector__stepper-label", children: label }), _jsxs("div", { className: "pax-selector__stepper-controls", children: [_jsx("button", { type: "button", className: "pax-selector__stepper-btn", onClick: handleDecrement, disabled: value <= min, "aria-label": "Decrease ".concat(label), children: _jsx(Icon, { name: "minus", size: "sm" }) }), _jsx("span", { className: "pax-selector__stepper-count", children: value }), _jsx("button", { type: "button", className: "pax-selector__stepper-btn", onClick: handleIncrement, disabled: value >= max, "aria-label": "Increase ".concat(label), children: _jsx(Icon, { name: "plus", size: "sm" }) })] })] }));
63
- };
64
- var ClientTypeSelector = function (_a) {
65
- var value = _a.value, onChange = _a.onChange;
66
- var _b = useState(false), isOpen = _b[0], setIsOpen = _b[1];
67
- var containerRef = useRef(null);
68
- useEffect(function () {
69
- var handleClickOutside = function (event) {
70
- if (containerRef.current && !containerRef.current.contains(event.target)) {
71
- setIsOpen(false);
72
- }
73
- };
74
- if (isOpen) {
75
- document.addEventListener('mousedown', handleClickOutside);
76
- }
77
- return function () {
78
- document.removeEventListener('mousedown', handleClickOutside);
79
- };
80
- }, [isOpen]);
81
- var handleSelect = function (type) {
82
- onChange(type);
83
- setIsOpen(false);
84
- };
85
- return (_jsxs("div", { className: "pax-selector__client-type", children: [_jsx(Text, { size: "sm", variant: "regular", className: "pax-selector__client-type-label", children: "Client type" }), _jsxs("div", { className: "pax-selector__client-type-select", ref: containerRef, children: [_jsxs("button", { type: "button", className: "pax-selector__client-type-trigger", onClick: function () { return setIsOpen(!isOpen); }, "aria-expanded": isOpen, "aria-haspopup": "listbox", children: [_jsxs("div", { className: "pax-selector__client-type-content", children: [_jsx(Icon, { name: "user-icon", size: "sm", className: "pax-selector__client-type-icon" }), _jsx("span", { className: "pax-selector__client-type-text", children: value })] }), _jsx(Icon, { name: "chevron-down", size: "sm", className: "pax-selector__client-type-chevron ".concat(isOpen ? 'pax-selector__client-type-chevron--open' : '') })] }), isOpen && (_jsx("div", { className: "pax-selector__client-type-dropdown", role: "listbox", children: CLIENT_TYPES.map(function (type) { return (_jsxs("button", { type: "button", className: "pax-selector__client-type-option ".concat(value === type ? 'pax-selector__client-type-option--selected' : ''), onClick: function () { return handleSelect(type); }, role: "option", "aria-selected": value === type, children: [_jsx(Icon, { name: "user-icon", size: "sm" }), type] }, type)); }) }))] })] }));
86
- };
87
- var RoomEditor = function (_a) {
88
- var room = _a.room, roomNumber = _a.roomNumber, showRemove = _a.showRemove, maxAdults = _a.maxAdults, maxTeens = _a.maxTeens, maxChildren = _a.maxChildren, maxInfants = _a.maxInfants, onChange = _a.onChange, onRemove = _a.onRemove, scrollToRef = _a.scrollToRef, ageRange = _a.ageRange, _b = _a.checkEmpty, checkEmpty = _b === void 0 ? false : _b;
89
- var roomAgesSectionRef = useRef(null);
90
- var previousRoomCounts = useRef({ teens: 0, children: 0, infants: 0 });
91
- var handleFieldChange = function (field, value) {
92
- var _a;
93
- onChange(__assign(__assign({}, room), (_a = {}, _a[field] = value, _a)));
94
- };
95
- var handleAgeChange = function (category, index, age) {
96
- var ages = __spreadArray([], (room[category] || []), true);
97
- ages[index] = age;
98
- handleFieldChange(category, ages);
99
- };
100
- // Scroll to age section when new age inputs are added in this room
101
- useEffect(function () {
102
- var prev = previousRoomCounts.current;
103
- var curr = {
104
- teens: room.teens,
105
- children: room.children,
106
- infants: room.infants,
107
- };
108
- // Check if any count increased
109
- var hasIncrease = curr.teens > prev.teens ||
110
- curr.children > prev.children ||
111
- curr.infants > prev.infants;
112
- if (hasIncrease && roomAgesSectionRef.current) {
113
- // Scroll to the age section after a short delay to ensure DOM is updated
114
- setTimeout(function () {
115
- if (roomAgesSectionRef.current) {
116
- roomAgesSectionRef.current.scrollIntoView({
117
- behavior: 'smooth',
118
- block: 'nearest',
119
- inline: 'nearest',
120
- });
121
- }
122
- }, 100);
123
- }
124
- // Update previous counts
125
- previousRoomCounts.current = curr;
126
- }, [room.teens, room.children, room.infants]);
127
- // Generate age arrays based on counts
128
- useEffect(function () {
129
- var teenAges = room.teenAges || [];
130
- var childAges = room.childAges || [];
131
- var infantAges = room.infantAges || [];
132
- // Adjust teen ages array
133
- if (teenAges.length < room.teens) {
134
- handleFieldChange('teenAges', __spreadArray(__spreadArray([], teenAges, true), Array(room.teens - teenAges.length).fill(undefined), true));
135
- }
136
- else if (teenAges.length > room.teens) {
137
- handleFieldChange('teenAges', teenAges.slice(0, room.teens));
138
- }
139
- // Adjust child ages array
140
- if (childAges.length < room.children) {
141
- handleFieldChange('childAges', __spreadArray(__spreadArray([], childAges, true), Array(room.children - childAges.length).fill(undefined), true));
142
- }
143
- else if (childAges.length > room.children) {
144
- handleFieldChange('childAges', childAges.slice(0, room.children));
145
- }
146
- // Adjust infant ages array
147
- if (infantAges.length < room.infants) {
148
- handleFieldChange('infantAges', __spreadArray(__spreadArray([], infantAges, true), Array(room.infants - infantAges.length).fill(undefined), true));
149
- }
150
- else if (infantAges.length > room.infants) {
151
- handleFieldChange('infantAges', infantAges.slice(0, room.infants));
152
- }
153
- }, [room.teens, room.children, room.infants]);
154
- // Chunk ages into groups of 2 for layout
155
- var chunkAges = function (ages, category) {
156
- var chunks = [];
157
- for (var i = 0; i < ages.length; i += 2) {
158
- chunks.push(ages.slice(i, i + 2));
159
- }
160
- return chunks;
161
- };
162
- var teenAgeChunks = chunkAges(room.teenAges || [], 'Teen');
163
- var childAgeChunks = chunkAges(room.childAges || [], 'Child');
164
- var infantAgeChunks = chunkAges(room.infantAges || [], 'Infant');
165
- return (_jsxs("div", { className: "pax-selector__room-container", ref: scrollToRef, children: [_jsxs("div", { className: "pax-selector__room-header", children: [_jsxs("div", { className: "pax-selector__room-title", children: [_jsxs(Text, { size: "lg", variant: "bold", color: "accent", className: "pax-selector__room-name", children: ["Room ", roomNumber] }), _jsx(Icon, { name: "home", size: "md", className: "pax-selector__room-icon" })] }), showRemove && (_jsxs("button", { type: "button", className: "pax-selector__room-remove", onClick: onRemove, "aria-label": "Remove room ".concat(roomNumber), children: [_jsx(Icon, { name: "close", size: "sm", className: "pax-selector__room-remove-icon" }), _jsx("span", { className: "pax-selector__room-remove-text", children: "Remove" })] }))] }), _jsxs("div", { className: "pax-selector__room-content", children: [_jsxs("div", { className: "pax-selector__steppers", children: [_jsx(StepperRow, { label: "Adult", value: room.adults, max: maxAdults, onChange: function (val) { return handleFieldChange('adults', val); } }), _jsx(StepperRow, { label: "Teen", value: room.teens, max: maxTeens, onChange: function (val) { return handleFieldChange('teens', val); } }), _jsx(StepperRow, { label: "Child", value: room.children, max: maxChildren, onChange: function (val) { return handleFieldChange('children', val); } }), _jsx(StepperRow, { label: "Infant", value: room.infants, max: maxInfants, onChange: function (val) { return handleFieldChange('infants', val); } })] }), (room.teens > 0 || room.children > 0 || room.infants > 0) && (_jsxs("div", { className: "pax-selector__age-section", ref: roomAgesSectionRef, children: [_jsx(Text, { size: "base", variant: "bold", color: "default", className: "pax-selector__age-section-title", children: "Please specify the age :" }), _jsxs("div", { className: "pax-selector__age-groups", children: [room.teens > 0 &&
166
- teenAgeChunks.map(function (chunk, chunkIndex) { return (_jsx(Fragment, { children: chunk.map(function (age, ageIndex) {
167
- var actualIndex = chunkIndex * 2 + ageIndex;
168
- return (_jsx(AgeSelector, { label: "Teen", value: age, onChange: function (selectedAge) {
169
- return handleAgeChange('teenAges', actualIndex, selectedAge);
170
- }, ageRange: ageRange, required: true, error: checkEmpty }, "teen-".concat(actualIndex)));
171
- }) }, "teen-chunk-".concat(chunkIndex))); }), room.children > 0 &&
172
- childAgeChunks.map(function (chunk, chunkIndex) { return (_jsx(Fragment, { children: chunk.map(function (age, ageIndex) {
173
- var actualIndex = chunkIndex * 2 + ageIndex;
174
- return (_jsx(AgeSelector, { label: "Child", value: age, onChange: function (selectedAge) {
175
- return handleAgeChange('childAges', actualIndex, selectedAge);
176
- }, ageRange: ageRange, required: true, error: checkEmpty }, "child-".concat(actualIndex)));
177
- }) }, "child-chunk-".concat(chunkIndex))); }), room.infants > 0 &&
178
- infantAgeChunks.map(function (chunk, chunkIndex) { return (_jsx(Fragment, { children: chunk.map(function (age, ageIndex) {
179
- var actualIndex = chunkIndex * 2 + ageIndex;
180
- return (_jsx(AgeSelector, { label: "Infant", value: age, onChange: function (selectedAge) {
181
- return handleAgeChange('infantAges', actualIndex, selectedAge);
182
- }, ageRange: ageRange, required: true, error: checkEmpty }, "infant-".concat(actualIndex)));
183
- }) }, "infant-chunk-".concat(chunkIndex))); })] })] })), _jsx(ClientTypeSelector, { value: room.clientType, onChange: function (val) { return handleFieldChange('clientType', val); } })] })] }));
184
- };
185
52
  var PaxSelector = function (_a) {
186
- var _b = _a.label, label = _b === void 0 ? 'Number of pax' : _b, value = _a.value, onChange = _a.onChange, onAddRoom = _a.onAddRoom, onDone = _a.onDone, _c = _a.placeholder, placeholder = _c === void 0 ? 'Select pax' : _c, _d = _a.className, className = _d === void 0 ? '' : _d, _e = _a.maxAdults, maxAdults = _e === void 0 ? 10 : _e, _f = _a.maxTeens, maxTeens = _f === void 0 ? 10 : _f, _g = _a.maxChildren, maxChildren = _g === void 0 ? 10 : _g, _h = _a.maxInfants, maxInfants = _h === void 0 ? 10 : _h, _j = _a.showAddRoom, showAddRoom = _j === void 0 ? true : _j, _k = _a.multipleRooms, multipleRooms = _k === void 0 ? false : _k, defaultRooms = _a.defaultRooms, onRoomsChange = _a.onRoomsChange, onRemoveRoom = _a.onRemoveRoom, _l = _a.defaultPaxData, defaultPaxData = _l === void 0 ? DEFAULT_PAX_DATA_WITH_ADULTS : _l, _m = _a.ageRange, ageRange = _m === void 0 ? CHILD_CATEGORY_AGES : _m, _o = _a.scrollOnOpen, scrollOnOpen = _o === void 0 ? false : _o, _p = _a.disabled, disabled = _p === void 0 ? false : _p, _q = _a.checkEmpty, checkEmpty = _q === void 0 ? false : _q, onPaxOpenChange = _a.onPaxOpenChange;
53
+ var _b = _a.label, label = _b === void 0 ? 'Number of pax' : _b, value = _a.value, onChange = _a.onChange, onAddRoom = _a.onAddRoom, onDone = _a.onDone, _c = _a.placeholder, placeholder = _c === void 0 ? 'Select pax' : _c, _d = _a.className, className = _d === void 0 ? '' : _d, _e = _a.maxAdults, maxAdults = _e === void 0 ? 10 : _e, _f = _a.maxTeens, maxTeens = _f === void 0 ? 10 : _f, _g = _a.maxChildren, maxChildren = _g === void 0 ? 10 : _g, _h = _a.maxInfants, maxInfants = _h === void 0 ? 10 : _h, _j = _a.showAddRoom, showAddRoom = _j === void 0 ? true : _j, _k = _a.multipleRooms, multipleRooms = _k === void 0 ? false : _k, defaultRooms = _a.defaultRooms, onRoomsChange = _a.onRoomsChange, onRemoveRoom = _a.onRemoveRoom, _l = _a.defaultPaxData, defaultPaxData = _l === void 0 ? DEFAULT_PAX_DATA_WITH_ADULTS : _l, _m = _a.ageRange, ageRange = _m === void 0 ? CHILD_CATEGORY_AGES : _m, _o = _a.scrollOnOpen, scrollOnOpen = _o === void 0 ? false : _o, _p = _a.disabled, disabled = _p === void 0 ? false : _p, _q = _a.checkEmpty, checkEmpty = _q === void 0 ? false : _q, onPaxOpenChange = _a.onPaxOpenChange, onPaxInvalid = _a.onPaxInvalid;
187
54
  var _r = useState(false), isOpen = _r[0], setIsOpen = _r[1];
188
- var _s = useState(value || defaultPaxData || DEFAULT_PAX_DATA), internalData = _s[0], setInternalData = _s[1];
189
- var _t = useState(defaultRooms || [__assign(__assign({}, DEFAULT_PAX_DATA), { roomId: '1' })]), rooms = _t[0], setRooms = _t[1];
55
+ var _s = useState(false), isDone = _s[0], setIsDone = _s[1];
56
+ var _t = useState(value || defaultPaxData || DEFAULT_PAX_DATA), internalData = _t[0], setInternalData = _t[1];
57
+ var _u = useState(defaultRooms || [__assign(__assign({}, DEFAULT_PAX_DATA), { roomId: '1' })]), rooms = _u[0], setRooms = _u[1];
190
58
  var containerRef = useRef(null);
191
59
  var triggerRef = useRef(null);
192
60
  var paxSelectorRef = useRef(null);
@@ -321,8 +189,13 @@ var PaxSelector = function (_a) {
321
189
  if (containerRef.current && !containerRef.current.contains(event.target)) {
322
190
  // Only close if all ages are filled (when there are minors)
323
191
  if (!hasMinorsWithoutAges() || areAllAgesFilled()) {
192
+ onPaxInvalid === null || onPaxInvalid === void 0 ? void 0 : onPaxInvalid(false);
324
193
  setIsOpen(false);
194
+ return;
325
195
  }
196
+ var isInvalid = hasMinorsWithoutAges() && !areAllAgesFilled();
197
+ onPaxInvalid === null || onPaxInvalid === void 0 ? void 0 : onPaxInvalid(isInvalid);
198
+ setIsDone(true);
326
199
  }
327
200
  };
328
201
  if (isOpen) {
@@ -331,7 +204,7 @@ var PaxSelector = function (_a) {
331
204
  return function () {
332
205
  document.removeEventListener('mousedown', handleClickOutside);
333
206
  };
334
- }, [isOpen, internalData, rooms, multipleRooms]);
207
+ }, [isOpen, internalData, rooms, multipleRooms, checkEmpty]);
335
208
  // Scroll to input when dropdown opens (if scrollOnOpen is true)
336
209
  useEffect(function () {
337
210
  setTimeout(function () {
@@ -393,6 +266,7 @@ var PaxSelector = function (_a) {
393
266
  }
394
267
  };
395
268
  var handleDone = function () {
269
+ setIsDone(true);
396
270
  // Only close if all ages are filled (when there are minors)
397
271
  if (!hasMinorsWithoutAges() || areAllAgesFilled()) {
398
272
  setIsOpen(false);
@@ -460,8 +334,12 @@ var PaxSelector = function (_a) {
460
334
  var childAgeChunks = chunkAges(internalData.childAges || [], 'Child');
461
335
  var infantAgeChunks = chunkAges(internalData.infantAges || [], 'Infant');
462
336
  var handleAgeChange = function (category, index, age) {
463
- var ages = __spreadArray([], (internalData[category] || []), true);
464
- ages[index] = age;
337
+ var ages = __spreadArray([], (internalData[category] || []), true).map(function (a, aIndex) {
338
+ if (aIndex === index) {
339
+ return age;
340
+ }
341
+ return a;
342
+ });
465
343
  handleDataChange(category, ages);
466
344
  };
467
345
  return (_jsxs(_Fragment, { children: [internalData.teens > 0 &&
@@ -469,19 +347,19 @@ var PaxSelector = function (_a) {
469
347
  var actualIndex = chunkIndex * 2 + ageIndex;
470
348
  return (_jsx(AgeSelector, { label: "Teen", value: age, onChange: function (selectedAge) {
471
349
  return handleAgeChange('teenAges', actualIndex, selectedAge);
472
- }, ageRange: ageRange, required: true, error: checkEmpty }, "teen-".concat(actualIndex)));
350
+ }, ageRange: ageRange, required: true, error: checkEmpty || (isDone && !age) }, "teen-".concat(actualIndex)));
473
351
  }) }, "teen-chunk-".concat(chunkIndex))); }), internalData.children > 0 &&
474
352
  childAgeChunks.map(function (chunk, chunkIndex) { return (_jsx(Fragment, { children: chunk.map(function (age, ageIndex) {
475
353
  var actualIndex = chunkIndex * 2 + ageIndex;
476
354
  return (_jsx(AgeSelector, { label: "Child", value: age, onChange: function (selectedAge) {
477
355
  return handleAgeChange('childAges', actualIndex, selectedAge);
478
- }, ageRange: ageRange, required: true, error: checkEmpty }, "child-".concat(actualIndex)));
356
+ }, ageRange: ageRange, required: true, error: checkEmpty || (isDone && !age) }, "child-".concat(actualIndex)));
479
357
  }) }, "child-chunk-".concat(chunkIndex))); }), internalData.infants > 0 &&
480
358
  infantAgeChunks.map(function (chunk, chunkIndex) { return (_jsx(Fragment, { children: chunk.map(function (age, ageIndex) {
481
359
  var actualIndex = chunkIndex * 2 + ageIndex;
482
360
  return (_jsx(AgeSelector, { label: "Infant", value: age, onChange: function (selectedAge) {
483
361
  return handleAgeChange('infantAges', actualIndex, selectedAge);
484
- }, ageRange: ageRange, required: true, error: checkEmpty }, "infant-".concat(actualIndex)));
362
+ }, ageRange: ageRange, required: true, error: checkEmpty || (isDone && !age) }, "infant-".concat(actualIndex)));
485
363
  }) }, "infant-chunk-".concat(chunkIndex))); })] }));
486
364
  })() })] })), _jsx(ClientTypeSelector, { value: internalData.clientType, onChange: function (val) { return handleDataChange('clientType', val); } })] })), _jsxs("div", { className: "pax-selector__actions", children: [_jsx("button", { type: "button", className: "pax-selector__clear-btn", onClick: handleClear, children: "Clear Pax" }), _jsx("button", { type: "button", className: "pax-selector__done-btn", onClick: handleDone, children: "Done" })] })] }))] }));
487
365
  };
@@ -0,0 +1,17 @@
1
+ import { RoomData } from './PaxSelector';
2
+ interface RoomEditorProps {
3
+ room: RoomData;
4
+ roomNumber: number;
5
+ showRemove: boolean;
6
+ maxAdults: number;
7
+ maxTeens: number;
8
+ maxChildren: number;
9
+ maxInfants: number;
10
+ onChange: (room: RoomData) => void;
11
+ onRemove: () => void;
12
+ scrollToRef?: React.RefObject<HTMLDivElement | null>;
13
+ ageRange: number[];
14
+ checkEmpty?: boolean;
15
+ }
16
+ declare const RoomEditor: React.FC<RoomEditorProps>;
17
+ export default RoomEditor;
@@ -0,0 +1,130 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
13
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
14
+ if (ar || !(i in from)) {
15
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
16
+ ar[i] = from[i];
17
+ }
18
+ }
19
+ return to.concat(ar || Array.prototype.slice.call(from));
20
+ };
21
+ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
22
+ import { Fragment, useEffect, useRef } from 'react';
23
+ import Icon from '../../atoms/Icon/Icon';
24
+ import { Text } from '../../atoms/Typography/Typography';
25
+ import AgeSelector from '../../molecules/AgeSelector/AgeSelector';
26
+ import ClientTypeSelector from './ClientTypeSelector';
27
+ import StepperRow from './StepperRow';
28
+ var RoomEditor = function (_a) {
29
+ var room = _a.room, roomNumber = _a.roomNumber, showRemove = _a.showRemove, maxAdults = _a.maxAdults, maxTeens = _a.maxTeens, maxChildren = _a.maxChildren, maxInfants = _a.maxInfants, onChange = _a.onChange, onRemove = _a.onRemove, scrollToRef = _a.scrollToRef, ageRange = _a.ageRange, _b = _a.checkEmpty, checkEmpty = _b === void 0 ? false : _b;
30
+ var roomAgesSectionRef = useRef(null);
31
+ var previousRoomCounts = useRef({ teens: 0, children: 0, infants: 0 });
32
+ var handleFieldChange = function (field, value) {
33
+ var _a;
34
+ onChange(__assign(__assign({}, room), (_a = {}, _a[field] = value, _a)));
35
+ };
36
+ var handleAgeChange = function (category, index, age) {
37
+ var ages = __spreadArray([], (room[category] || []), true).map(function (a, aIndex) {
38
+ if (aIndex === index) {
39
+ return age;
40
+ }
41
+ return a;
42
+ });
43
+ handleFieldChange(category, ages);
44
+ };
45
+ // Scroll to age section when new age inputs are added in this room
46
+ useEffect(function () {
47
+ var prev = previousRoomCounts.current;
48
+ var curr = {
49
+ teens: room.teens,
50
+ children: room.children,
51
+ infants: room.infants,
52
+ };
53
+ // Check if any count increased
54
+ var hasIncrease = curr.teens > prev.teens ||
55
+ curr.children > prev.children ||
56
+ curr.infants > prev.infants;
57
+ if (hasIncrease && roomAgesSectionRef.current) {
58
+ // Scroll to the age section after a short delay to ensure DOM is updated
59
+ setTimeout(function () {
60
+ if (roomAgesSectionRef.current) {
61
+ roomAgesSectionRef.current.scrollIntoView({
62
+ behavior: 'smooth',
63
+ block: 'nearest',
64
+ inline: 'nearest',
65
+ });
66
+ }
67
+ }, 100);
68
+ }
69
+ // Update previous counts
70
+ previousRoomCounts.current = curr;
71
+ }, [room.teens, room.children, room.infants]);
72
+ // Generate age arrays based on counts
73
+ useEffect(function () {
74
+ var teenAges = room.teenAges || [];
75
+ var childAges = room.childAges || [];
76
+ var infantAges = room.infantAges || [];
77
+ // Adjust teen ages array
78
+ if (teenAges.length < room.teens) {
79
+ handleFieldChange('teenAges', __spreadArray(__spreadArray([], teenAges, true), Array(room.teens - teenAges.length).fill(undefined), true));
80
+ }
81
+ else if (teenAges.length > room.teens) {
82
+ handleFieldChange('teenAges', teenAges.slice(0, room.teens));
83
+ }
84
+ // Adjust child ages array
85
+ if (childAges.length < room.children) {
86
+ handleFieldChange('childAges', __spreadArray(__spreadArray([], childAges, true), Array(room.children - childAges.length).fill(undefined), true));
87
+ }
88
+ else if (childAges.length > room.children) {
89
+ handleFieldChange('childAges', childAges.slice(0, room.children));
90
+ }
91
+ // Adjust infant ages array
92
+ if (infantAges.length < room.infants) {
93
+ handleFieldChange('infantAges', __spreadArray(__spreadArray([], infantAges, true), Array(room.infants - infantAges.length).fill(undefined), true));
94
+ }
95
+ else if (infantAges.length > room.infants) {
96
+ handleFieldChange('infantAges', infantAges.slice(0, room.infants));
97
+ }
98
+ }, [room.teens, room.children, room.infants]);
99
+ // Chunk ages into groups of 2 for layout
100
+ var chunkAges = function (ages, category) {
101
+ var chunks = [];
102
+ for (var i = 0; i < ages.length; i += 2) {
103
+ chunks.push(ages.slice(i, i + 2));
104
+ }
105
+ return chunks;
106
+ };
107
+ var teenAgeChunks = chunkAges(room.teenAges || [], 'Teen');
108
+ var childAgeChunks = chunkAges(room.childAges || [], 'Child');
109
+ var infantAgeChunks = chunkAges(room.infantAges || [], 'Infant');
110
+ return (_jsxs("div", { className: "pax-selector__room-container", ref: scrollToRef, children: [_jsxs("div", { className: "pax-selector__room-header", children: [_jsxs("div", { className: "pax-selector__room-title", children: [_jsxs(Text, { size: "lg", variant: "bold", color: "accent", className: "pax-selector__room-name", children: ["Room ", roomNumber] }), _jsx(Icon, { name: "home", size: "md", className: "pax-selector__room-icon" })] }), showRemove && (_jsxs("button", { type: "button", className: "pax-selector__room-remove", onClick: onRemove, "aria-label": "Remove room ".concat(roomNumber), children: [_jsx(Icon, { name: "close", size: "sm", className: "pax-selector__room-remove-icon" }), _jsx("span", { className: "pax-selector__room-remove-text", children: "Remove" })] }))] }), _jsxs("div", { className: "pax-selector__room-content", children: [_jsxs("div", { className: "pax-selector__steppers", children: [_jsx(StepperRow, { label: "Adult", value: room.adults, max: maxAdults, onChange: function (val) { return handleFieldChange('adults', val); } }), _jsx(StepperRow, { label: "Teen", value: room.teens, max: maxTeens, onChange: function (val) { return handleFieldChange('teens', val); } }), _jsx(StepperRow, { label: "Child", value: room.children, max: maxChildren, onChange: function (val) { return handleFieldChange('children', val); } }), _jsx(StepperRow, { label: "Infant", value: room.infants, max: maxInfants, onChange: function (val) { return handleFieldChange('infants', val); } })] }), (room.teens > 0 || room.children > 0 || room.infants > 0) && (_jsxs("div", { className: "pax-selector__age-section", ref: roomAgesSectionRef, children: [_jsx(Text, { size: "base", variant: "bold", color: "default", className: "pax-selector__age-section-title", children: "Please specify the age :" }), _jsxs("div", { className: "pax-selector__age-groups", children: [room.teens > 0 &&
111
+ teenAgeChunks.map(function (chunk, chunkIndex) { return (_jsx(Fragment, { children: chunk.map(function (age, ageIndex) {
112
+ var actualIndex = chunkIndex * 2 + ageIndex;
113
+ return (_jsx(AgeSelector, { label: "Teen", value: age, onChange: function (selectedAge) {
114
+ return handleAgeChange('teenAges', actualIndex, selectedAge);
115
+ }, ageRange: ageRange, required: true, error: checkEmpty }, "teen-".concat(actualIndex)));
116
+ }) }, "teen-chunk-".concat(chunkIndex))); }), room.children > 0 &&
117
+ childAgeChunks.map(function (chunk, chunkIndex) { return (_jsx(Fragment, { children: chunk.map(function (age, ageIndex) {
118
+ var actualIndex = chunkIndex * 2 + ageIndex;
119
+ return (_jsx(AgeSelector, { label: "Child", value: age, onChange: function (selectedAge) {
120
+ return handleAgeChange('childAges', actualIndex, selectedAge);
121
+ }, ageRange: ageRange, required: true, error: checkEmpty }, "child-".concat(actualIndex)));
122
+ }) }, "child-chunk-".concat(chunkIndex))); }), room.infants > 0 &&
123
+ infantAgeChunks.map(function (chunk, chunkIndex) { return (_jsx(Fragment, { children: chunk.map(function (age, ageIndex) {
124
+ var actualIndex = chunkIndex * 2 + ageIndex;
125
+ return (_jsx(AgeSelector, { label: "Infant", value: age, onChange: function (selectedAge) {
126
+ return handleAgeChange('infantAges', actualIndex, selectedAge);
127
+ }, ageRange: ageRange, required: true, error: checkEmpty }, "infant-".concat(actualIndex)));
128
+ }) }, "infant-chunk-".concat(chunkIndex))); })] })] })), _jsx(ClientTypeSelector, { value: room.clientType, onChange: function (val) { return handleFieldChange('clientType', val); } })] })] }));
129
+ };
130
+ export default RoomEditor;
@@ -0,0 +1,9 @@
1
+ interface StepperRowProps {
2
+ label: string;
3
+ value: number;
4
+ min?: number;
5
+ max?: number;
6
+ onChange: (value: number) => void;
7
+ }
8
+ declare const StepperRow: React.FC<StepperRowProps>;
9
+ export default StepperRow;
@@ -0,0 +1,18 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import Icon from '../../atoms/Icon/Icon';
3
+ import { Text } from '../../atoms/Typography/Typography';
4
+ var StepperRow = function (_a) {
5
+ var label = _a.label, value = _a.value, _b = _a.min, min = _b === void 0 ? 0 : _b, _c = _a.max, max = _c === void 0 ? 99 : _c, onChange = _a.onChange;
6
+ var handleDecrement = function () {
7
+ if (value > min) {
8
+ onChange(value - 1);
9
+ }
10
+ };
11
+ var handleIncrement = function () {
12
+ if (value < max) {
13
+ onChange(value + 1);
14
+ }
15
+ };
16
+ return (_jsxs("div", { className: "pax-selector__stepper", children: [_jsx(Text, { size: "base", variant: "bold", color: "default", className: "pax-selector__stepper-label", children: label }), _jsxs("div", { className: "pax-selector__stepper-controls", children: [_jsx("button", { type: "button", className: "pax-selector__stepper-btn", onClick: handleDecrement, disabled: value <= min, "aria-label": "Decrease ".concat(label), children: _jsx(Icon, { name: "minus", size: "sm" }) }), _jsx("span", { className: "pax-selector__stepper-count", children: value }), _jsx("button", { type: "button", className: "pax-selector__stepper-btn", onClick: handleIncrement, disabled: value >= max, "aria-label": "Increase ".concat(label), children: _jsx(Icon, { name: "plus", size: "sm" }) })] })] }));
17
+ };
18
+ export default StepperRow;
@@ -19,7 +19,8 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
19
19
  return to.concat(ar || Array.prototype.slice.call(from));
20
20
  };
21
21
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
22
- import { useEffect, useState } from 'react';
22
+ import useTransferAge from '../../../hooks/useTransferAge';
23
+ import { useEffect, useMemo, useState } from 'react';
23
24
  import '../../../styles/components/organism/round-trip.css';
24
25
  import { Text } from '../../atoms/Typography/Typography';
25
26
  import LocationDropdown from '../../molecules/LocationDropdown/LocationDropdown';
@@ -32,6 +33,7 @@ var RoundTrip = function (_a) {
32
33
  var _h = useState(departureDate), internalDepartureDate = _h[0], setInternalDepartureDate = _h[1];
33
34
  var _j = useState(null), internalPickupDropoffPoint = _j[0], setInternalPickupDropoffPoint = _j[1];
34
35
  var _k = useState(null), internalAccommodation = _k[0], setInternalAccommodation = _k[1];
36
+ var _l = useTransferAge(internalPaxData), setIsInvalidPax = _l.setIsInvalidPax, areAllAgesValid = _l.areAllAgesValid;
35
37
  // Helper function to get all locations (from options and groups)
36
38
  var getAllLocations = function (options, groups) {
37
39
  var groupOptions = groups.flatMap(function (group) { return group.options; });
@@ -222,12 +224,15 @@ var RoundTrip = function (_a) {
222
224
  onAccommodationChange === null || onAccommodationChange === void 0 ? void 0 : onAccommodationChange(locationOption);
223
225
  };
224
226
  // Check if inputs are empty (when checkEmpty is true)
225
- var isPaxEmpty = checkEmpty &&
226
- (!internalPaxData ||
227
- (internalPaxData.adults === 0 &&
228
- internalPaxData.teens === 0 &&
229
- internalPaxData.children === 0 &&
230
- (internalPaxData.infants === undefined || internalPaxData.infants === 0)));
227
+ var isPaxEmpty = useMemo(function () {
228
+ return (checkEmpty &&
229
+ (!internalPaxData ||
230
+ areAllAgesValid ||
231
+ (internalPaxData.adults === 0 &&
232
+ internalPaxData.teens === 0 &&
233
+ internalPaxData.children === 0 &&
234
+ (internalPaxData.infants === undefined || internalPaxData.infants === 0))));
235
+ }, [internalPaxData, checkEmpty, areAllAgesValid]);
231
236
  // Show error if checkEmpty is true and either date is missing
232
237
  var isDateEmpty = checkEmpty &&
233
238
  (!internalArrivalDate ||
@@ -266,7 +271,7 @@ var RoundTrip = function (_a) {
266
271
  };
267
272
  var defaultPickupDropoffOption = findLocationOption(pickupDropoffPoint, 'pickup-dropoff');
268
273
  var defaultAccommodationOption = findLocationOption(accommodation, 'accommodation');
269
- return (_jsx("div", { className: "round-trip ".concat(className), "data-round-trip-id": id, children: _jsxs("div", { className: "round-trip__content", children: [_jsx("div", { className: "round-trip__field round-trip__field--pax ".concat(isPaxEmpty ? 'round-trip__field--error' : ''), children: _jsx(PaxSelector, { label: "Number of pax", value: internalPaxData, onChange: handlePaxChange, placeholder: "2 pax", className: isPaxEmpty ? 'pax-selector--error' : '', scrollOnOpen: scrollOnOpen, checkEmpty: checkEmpty }) }), _jsxs("div", { className: "round-trip__field round-trip__field--dates", children: [_jsx(Text, { size: "sm", variant: "regular", className: "round-trip__field-label", children: "Arrival date - Departure date" }), _jsx(DateTimePicker, { placeholder: "DD/MM/YYYY - DD/MM/YYYY", mode: "calendar", iconPosition: "left", numberOfMonths: 2, iconBGFull: false, showChevron: true, onValueChange: handleDateRangeChange, selectionMode: "range", defaultValue: internalArrivalDate && internalDepartureDate
274
+ return (_jsx("div", { className: "round-trip ".concat(className), "data-round-trip-id": id, children: _jsxs("div", { className: "round-trip__content", children: [_jsx("div", { className: "round-trip__field round-trip__field--pax ".concat(isPaxEmpty ? 'round-trip__field--error' : ''), children: _jsx(PaxSelector, { label: "Number of pax", value: internalPaxData, onChange: handlePaxChange, placeholder: "2 pax", className: isPaxEmpty ? 'pax-selector--error' : '', scrollOnOpen: scrollOnOpen, checkEmpty: checkEmpty, onPaxInvalid: function (isInvalid) { return setIsInvalidPax(isInvalid); } }) }), _jsxs("div", { className: "round-trip__field round-trip__field--dates", children: [_jsx(Text, { size: "sm", variant: "regular", className: "round-trip__field-label", children: "Arrival date - Departure date" }), _jsx(DateTimePicker, { placeholder: "DD/MM/YYYY - DD/MM/YYYY", mode: "calendar", iconPosition: "left", numberOfMonths: 2, iconBGFull: false, showChevron: true, onValueChange: handleDateRangeChange, selectionMode: "range", defaultValue: internalArrivalDate && internalDepartureDate
270
275
  ? [internalArrivalDate, internalDepartureDate]
271
276
  : undefined, inputClassName: "round-trip__date-picker--input", state: isDateError() ? 'error' : undefined, scrollOnOpen: scrollOnOpen })] }), _jsx("div", { className: "round-trip__field round-trip__field--pickup-dropoff", children: _jsx(LocationDropdown, { label: "Pick up / Drop-off point", options: pickupDropoffOptions.options, groups: pickupDropoffOptions.groups, selectedValue: (internalPickupDropoffPoint === null || internalPickupDropoffPoint === void 0 ? void 0 : internalPickupDropoffPoint.id) || null, onSelectionChange: handlePickupDropoffChange, placeholder: "Select pick-up / drop-off point", direction: undefined, type: "airport-port", showGroupTitles: true, error: isPickupDropoffEmpty, scrollOnOpen: scrollOnOpen, defaultValue: defaultPickupDropoffOption }) }), _jsx("div", { className: "round-trip__field round-trip__field--accommodation", children: _jsx(LocationDropdown, { label: "Accommodation", options: accommodationOptions.options, groups: accommodationOptions.groups, selectedValue: (internalAccommodation === null || internalAccommodation === void 0 ? void 0 : internalAccommodation.id) || null, onSelectionChange: handleAccommodationChange, placeholder: "Select accommodation", direction: "dropoff", type: "accommodation", showGroupTitles: false, error: isAccommodationEmpty, scrollOnOpen: scrollOnOpen, defaultValue: defaultAccommodationOption }) })] }) }));
272
277
  };
@@ -49,7 +49,6 @@ function SearchBarTransfer(_a) {
49
49
  var _j = useState(defaultRoundTripData), roundTripData = _j[0], setRoundTripData = _j[1];
50
50
  var _k = useState(initializeTransferLines(defaultTransferLines)), transferLines = _k[0], setTransferLines = _k[1];
51
51
  var _l = useState(null), error = _l[0], setError = _l[1];
52
- var _m = useState(0), validationTrigger = _m[0], setValidationTrigger = _m[1];
53
52
  // Notify parent of changes
54
53
  useEffect(function () {
55
54
  var data = {
@@ -372,7 +371,6 @@ function SearchBarTransfer(_a) {
372
371
  };
373
372
  // Handle search
374
373
  var handleSearch = function () {
375
- setValidationTrigger(function (prev) { return prev + 1; });
376
374
  if (validateData()) {
377
375
  var data = {
378
376
  mode: mode,
@@ -383,7 +381,7 @@ function SearchBarTransfer(_a) {
383
381
  onSearch === null || onSearch === void 0 ? void 0 : onSearch(data);
384
382
  }
385
383
  };
386
- return (_jsxs("div", { className: "search-bar-transfer ".concat(className), children: [_jsxs("div", { className: "search-bar-transfer__header", children: [_jsx(Heading, { level: 5, variant: "bold", color: "accent", children: "Select your transfer details" }), _jsx("div", { className: "search-bar-transfer__mode-selector", children: _jsx(SegmentedButton, { options: modeOptions, value: mode, onChange: handleModeChange, name: "transfer-mode" }) })] }), mode === 'roundtrip' ? (_jsxs(_Fragment, { children: [_jsx(RoundTrip, { id: "roundtrip-main", locations: locations, paxData: roundTripData === null || roundTripData === void 0 ? void 0 : roundTripData.paxData, arrivalDate: roundTripData === null || roundTripData === void 0 ? void 0 : roundTripData.arrivalDate, departureDate: roundTripData === null || roundTripData === void 0 ? void 0 : roundTripData.departureDate, pickupDropoffPoint: roundTripData === null || roundTripData === void 0 ? void 0 : roundTripData.pickupDropoffPoint, accommodation: roundTripData === null || roundTripData === void 0 ? void 0 : roundTripData.accommodation, onChange: setRoundTripData, checkEmpty: error !== null, scrollOnOpen: scrollOnOpen }, "roundtrip-".concat(validationTrigger)), _jsx("div", { className: "search-bar-transfer__transfer-type", children: renderTransferTypeButtons(handleAddTransferFromRoundTrip) })] })) : (_jsxs(_Fragment, { children: [_jsxs("div", { className: "search-bar-transfer__transfer-type", children: [_jsx(Text, { size: "lg", variant: "bold", color: "subtle", as: "div", className: "search-bar-transfer__transfer-type-label", children: "Select a transfer type you want to add" }), renderTransferTypeButtons(handleAddTransfer)] }), transferLines.length === 0 && (_jsx(TransferLine, { id: "placeholder-transfer", type: "inter-hotel", locations: locations, onDataChange: function () { }, showDelete: false, disabled: true, scrollOnOpen: scrollOnOpen, onPaxOpenChange: onPaxOpenChange })), transferLines.length > 0 && (_jsx("div", { className: "search-bar-transfer__transfer-lines", children: (function () {
384
+ return (_jsxs("div", { className: "search-bar-transfer ".concat(className), children: [_jsxs("div", { className: "search-bar-transfer__header", children: [_jsx(Heading, { level: 5, variant: "bold", color: "accent", children: "Select your transfer details" }), _jsx("div", { className: "search-bar-transfer__mode-selector", children: _jsx(SegmentedButton, { options: modeOptions, value: mode, onChange: handleModeChange, name: "transfer-mode" }) })] }), mode === 'roundtrip' ? (_jsxs(_Fragment, { children: [_jsx(RoundTrip, { id: "roundtrip-main", locations: locations, paxData: roundTripData === null || roundTripData === void 0 ? void 0 : roundTripData.paxData, arrivalDate: roundTripData === null || roundTripData === void 0 ? void 0 : roundTripData.arrivalDate, departureDate: roundTripData === null || roundTripData === void 0 ? void 0 : roundTripData.departureDate, pickupDropoffPoint: roundTripData === null || roundTripData === void 0 ? void 0 : roundTripData.pickupDropoffPoint, accommodation: roundTripData === null || roundTripData === void 0 ? void 0 : roundTripData.accommodation, onChange: setRoundTripData, checkEmpty: error !== null, scrollOnOpen: scrollOnOpen }, "roundtrip"), _jsx("div", { className: "search-bar-transfer__transfer-type", children: renderTransferTypeButtons(handleAddTransferFromRoundTrip) })] })) : (_jsxs(_Fragment, { children: [_jsxs("div", { className: "search-bar-transfer__transfer-type", children: [_jsx(Text, { size: "lg", variant: "bold", color: "subtle", as: "div", className: "search-bar-transfer__transfer-type-label", children: "Select a transfer type you want to add" }), renderTransferTypeButtons(handleAddTransfer)] }), transferLines.length === 0 && (_jsx(TransferLine, { id: "placeholder-transfer", type: "inter-hotel", locations: locations, onDataChange: function () { }, showDelete: false, disabled: true, scrollOnOpen: scrollOnOpen, onPaxOpenChange: onPaxOpenChange })), transferLines.length > 0 && (_jsx("div", { className: "search-bar-transfer__transfer-lines", children: (function () {
387
385
  // Group transfers by type
388
386
  var groupedTransfers = {
389
387
  arrival: [],
@@ -402,7 +400,7 @@ function SearchBarTransfer(_a) {
402
400
  departure: { label: 'Departure', icon: 'departure' },
403
401
  'inter-hotel': { label: 'Inter-Hotel', icon: 'building' },
404
402
  };
405
- return nonEmptyGroups.map(function (type, groupIndex) { return (_jsxs(React.Fragment, { children: [_jsxs("div", { className: "search-bar-transfer__category-header", children: [_jsx(Icon, { name: categoryInfo[type].icon, size: "md" }), _jsx(Text, { size: "md", variant: "bold", color: "default", as: "span", children: categoryInfo[type].label })] }), groupedTransfers[type].map(function (line) { return (_jsx(TransferLine, { id: line.id, type: line.type, paxData: line.paxData, transferDate: line.transferDate, pickupPoint: line.pickupPoint, dropoffPoint: line.dropoffPoint, locations: locations, onDataChange: function (data) { return handleTransferLineChange(line.id, data); }, onDelete: function () { return handleDeleteTransferLine(line.id); }, showDelete: transferLines.length > 1, checkEmpty: error !== null, scrollOnOpen: scrollOnOpen, onPaxOpenChange: onPaxOpenChange }, "".concat(line.id, "-").concat(validationTrigger))); }), groupIndex < nonEmptyGroups.length - 1 && (_jsx("svg", { className: "search-bar-transfer__divider", xmlns: "http://www.w3.org/2000/svg", width: "100%", height: "1", viewBox: "0 0 1076 1", fill: "none", preserveAspectRatio: "none", children: _jsx("path", { d: "M0 0.5L1076 0.499906", stroke: "var(--color-border-medium, #A3A3A3)", strokeWidth: "1", strokeDasharray: "10 10" }) }))] }, type)); });
406
- })() }))] })), _jsxs("div", { className: "search-bar-transfer__actions", children: [_jsx(Checkbox, { checked: sameVehicle, onChange: setSameVehicle, label: "Use the same vehicle for all your transfers" }), _jsxs("div", { className: "search-bar-transfer__cta", children: [error && _jsx(Toast, { text: error, type: "danger" }), _jsxs(Button, { variant: "primary", size: "lg", onClick: handleSearch, children: [isUpdateLabel && 'Update', " Search"] })] })] })] }));
403
+ return nonEmptyGroups.map(function (type, groupIndex) { return (_jsxs(React.Fragment, { children: [_jsxs("div", { className: "search-bar-transfer__category-header", children: [_jsx(Icon, { name: categoryInfo[type].icon, size: "md" }), _jsx(Text, { size: "md", variant: "bold", color: "default", as: "span", children: categoryInfo[type].label })] }), groupedTransfers[type].map(function (line, index) { return (_jsx(TransferLine, { id: line.id, type: line.type, paxData: line.paxData, transferDate: line.transferDate, pickupPoint: line.pickupPoint, dropoffPoint: line.dropoffPoint, locations: locations, onDataChange: function (data) { return handleTransferLineChange(line.id, data); }, onDelete: function () { return handleDeleteTransferLine(line.id); }, showDelete: transferLines.length > 1, checkEmpty: error !== null, scrollOnOpen: scrollOnOpen, onPaxOpenChange: onPaxOpenChange }, "".concat(line.id, "-").concat(index))); }), groupIndex < nonEmptyGroups.length - 1 && (_jsx("svg", { className: "search-bar-transfer__divider", xmlns: "http://www.w3.org/2000/svg", width: "100%", height: "1", viewBox: "0 0 1076 1", fill: "none", preserveAspectRatio: "none", children: _jsx("path", { d: "M0 0.5L1076 0.499906", stroke: "var(--color-border-medium, #A3A3A3)", strokeWidth: "1", strokeDasharray: "10 10" }) }))] }, type)); });
404
+ })() }))] })), _jsxs("div", { className: "search-bar-transfer__actions", children: [_jsx(Checkbox, { checked: sameVehicle, onChange: setSameVehicle, label: "Use the same vehicle for all your transfers" }), _jsxs("div", { className: "search-bar-transfer__cta", children: [error && _jsx(Toast, { text: error, type: "danger" }), _jsxs(Button, { type: "button", variant: "primary", size: "lg", onClick: handleSearch, children: [isUpdateLabel && 'Update', " Search"] })] })] })] }));
407
405
  }
408
406
  export default SearchBarTransfer;
@@ -1,3 +1,4 @@
1
+ import React from 'react';
1
2
  type Link = {
2
3
  label: string;
3
4
  route: string;