mautourco-components 0.1.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/dist/components/atoms/Checkbox/Checkbox.js +7 -1
  2. package/dist/components/atoms/Icon/Icon.d.ts +1 -1
  3. package/dist/components/atoms/Icon/Icon.js +22 -1
  4. package/dist/components/atoms/Icon/icons/BuildingIcon.d.ts +8 -0
  5. package/dist/components/atoms/Icon/icons/BuildingIcon.js +36 -0
  6. package/dist/components/atoms/Icon/icons/CalendarOutlineIcon.d.ts +8 -0
  7. package/dist/components/atoms/Icon/icons/CalendarOutlineIcon.js +36 -0
  8. package/dist/components/atoms/Icon/icons/HomeIcon.d.ts +8 -0
  9. package/dist/components/atoms/Icon/icons/HomeIcon.js +25 -0
  10. package/dist/components/atoms/Icon/icons/MinusIcon.d.ts +8 -0
  11. package/dist/components/atoms/Icon/icons/MinusIcon.js +25 -0
  12. package/dist/components/atoms/Icon/icons/PlaneIcon.d.ts +8 -0
  13. package/dist/components/atoms/Icon/icons/PlaneIcon.js +36 -0
  14. package/dist/components/atoms/Icon/icons/PlusIcon.d.ts +8 -0
  15. package/dist/components/atoms/Icon/icons/PlusIcon.js +25 -0
  16. package/dist/components/atoms/Icon/icons/ShipIcon.d.ts +8 -0
  17. package/dist/components/atoms/Icon/icons/ShipIcon.js +36 -0
  18. package/dist/components/atoms/Illustration/Illustration.d.ts +14 -0
  19. package/dist/components/atoms/Illustration/Illustration.js +33 -0
  20. package/dist/components/atoms/Illustration/illustrations.d.ts +51 -0
  21. package/dist/components/atoms/Illustration/illustrations.js +97 -0
  22. package/dist/components/atoms/RatingStar/RatingStar.d.ts +40 -0
  23. package/dist/components/atoms/RatingStar/RatingStar.js +54 -0
  24. package/dist/components/atoms/SegmentedButton/SegmentedButton.d.ts +27 -0
  25. package/dist/components/atoms/SegmentedButton/SegmentedButton.js +49 -0
  26. package/dist/components/atoms/Slider/Slider.d.ts +52 -0
  27. package/dist/components/atoms/Slider/Slider.js +30 -0
  28. package/dist/components/molecules/Calendar/CalendarInput.d.ts +34 -0
  29. package/dist/components/molecules/Calendar/CalendarInput.js +49 -0
  30. package/dist/components/molecules/Calendar/DateTime.d.ts +25 -0
  31. package/dist/components/molecules/Calendar/DateTime.js +106 -0
  32. package/dist/components/molecules/Calendar/TimePicker.d.ts +16 -0
  33. package/dist/components/molecules/Calendar/TimePicker.js +91 -0
  34. package/dist/components/molecules/LocationDropdown/LocationDropdown.d.ts +34 -0
  35. package/dist/components/molecules/LocationDropdown/LocationDropdown.js +120 -0
  36. package/dist/components/molecules/LocationDropdown/index.d.ts +2 -0
  37. package/dist/components/molecules/LocationDropdown/index.js +1 -0
  38. package/dist/components/molecules/RatingTab/RatingTab.d.ts +39 -0
  39. package/dist/components/molecules/RatingTab/RatingTab.js +41 -0
  40. package/dist/components/molecules/TabGroup/TabGroup.d.ts +17 -0
  41. package/dist/components/molecules/TabGroup/TabGroup.js +30 -0
  42. package/dist/components/organisms/CardContainer/CardContainer.d.ts +37 -0
  43. package/dist/components/organisms/CardContainer/CardContainer.js +27 -0
  44. package/dist/components/organisms/DateTimePicker/DateTimePicker.d.ts +15 -0
  45. package/dist/components/organisms/DateTimePicker/DateTimePicker.js +66 -0
  46. package/dist/components/organisms/Dialog/Dialog.d.ts +103 -0
  47. package/dist/components/organisms/Dialog/Dialog.js +162 -0
  48. package/dist/components/organisms/PaxSelector/PaxSelector.d.ts +63 -0
  49. package/dist/components/organisms/PaxSelector/PaxSelector.js +402 -0
  50. package/dist/components/organisms/RoundTrip/RoundTrip.d.ts +54 -0
  51. package/dist/components/organisms/RoundTrip/RoundTrip.js +179 -0
  52. package/dist/components/organisms/RoundTrip/index.d.ts +2 -0
  53. package/dist/components/organisms/RoundTrip/index.js +1 -0
  54. package/dist/components/organisms/SearchBarTransfer/SearchBarTransfer.d.ts +35 -0
  55. package/dist/components/organisms/SearchBarTransfer/SearchBarTransfer.js +192 -0
  56. package/dist/components/organisms/SearchBarTransfer/index.d.ts +2 -0
  57. package/dist/components/organisms/SearchBarTransfer/index.js +1 -0
  58. package/dist/components/organisms/TransferLine/TransferLine.d.ts +53 -0
  59. package/dist/components/organisms/TransferLine/TransferLine.js +179 -0
  60. package/dist/components/ui/button.d.ts +10 -0
  61. package/dist/components/ui/button.js +56 -0
  62. package/dist/components/ui/calendar.d.ts +8 -0
  63. package/dist/components/ui/calendar.js +87 -0
  64. package/dist/components/ui/popover.d.ts +7 -0
  65. package/dist/components/ui/popover.js +42 -0
  66. package/dist/index.d.ts +26 -0
  67. package/dist/index.js +18 -0
  68. package/dist/lib/utils.d.ts +7 -0
  69. package/dist/lib/utils.js +13 -0
  70. package/package.json +21 -12
  71. package/src/components/atoms/Button/Button.css +34 -34
  72. package/src/components/atoms/Checkbox/Checkbox.tsx +83 -69
  73. package/src/components/atoms/Icon/Icon.tsx +30 -2
  74. package/src/components/atoms/Icon/icons/BuildingIcon.tsx +50 -0
  75. package/src/components/atoms/Icon/icons/CalendarOutlineIcon.tsx +50 -0
  76. package/src/components/atoms/Icon/icons/HomeIcon.tsx +52 -0
  77. package/src/components/atoms/Icon/icons/MinusIcon.tsx +45 -0
  78. package/src/components/atoms/Icon/icons/PlaneIcon.tsx +50 -0
  79. package/src/components/atoms/Icon/icons/PlusIcon.tsx +45 -0
  80. package/src/components/atoms/Icon/icons/ShipIcon.tsx +50 -0
  81. package/src/components/atoms/Illustration/Illustration.tsx +28 -0
  82. package/src/components/atoms/Illustration/illustrations.ts +116 -0
  83. package/src/components/atoms/RatingStar/RatingStar.tsx +114 -0
  84. package/src/components/atoms/SegmentedButton/SegmentedButton.tsx +94 -0
  85. package/src/components/atoms/Slider/Slider.tsx +95 -0
  86. package/src/components/molecules/Calendar/CalendarInput.tsx +135 -0
  87. package/src/components/molecules/Calendar/DateTime.tsx +172 -0
  88. package/src/components/molecules/Calendar/TimePicker.tsx +174 -0
  89. package/src/components/molecules/LocationDropdown/LocationDropdown.tsx +234 -0
  90. package/src/components/molecules/LocationDropdown/index.ts +2 -0
  91. package/src/components/molecules/RatingTab/RatingTab.tsx +96 -0
  92. package/src/components/molecules/TabGroup/TabGroup.tsx +60 -0
  93. package/src/components/molecules/UserCard/UserCard.stories.tsx +2 -2
  94. package/src/components/organisms/CardContainer/CardContainer.tsx +66 -0
  95. package/src/components/organisms/DateTimePicker/DateTimePicker.tsx +110 -0
  96. package/src/components/organisms/Dialog/Dialog.tsx +352 -0
  97. package/src/components/organisms/PaxSelector/PaxSelector.tsx +979 -0
  98. package/src/components/organisms/RoundTrip/RoundTrip.tsx +335 -0
  99. package/src/components/organisms/RoundTrip/index.ts +2 -0
  100. package/src/components/organisms/SearchBarTransfer/SearchBarTransfer.tsx +388 -0
  101. package/src/components/organisms/SearchBarTransfer/index.ts +2 -0
  102. package/src/components/organisms/TransferLine/TransferLine.tsx +369 -0
  103. package/src/components/ui/button.tsx +60 -0
  104. package/src/components/ui/calendar.tsx +246 -0
  105. package/src/components/ui/popover.tsx +46 -0
  106. package/src/styles/components/calendar.css +86 -0
  107. package/src/styles/components/checkbox.css +130 -132
  108. package/src/styles/components/dropdown.css +40 -40
  109. package/src/styles/components/forms.css +51 -51
  110. package/src/styles/components/illustration.css +7 -0
  111. package/src/styles/components/molecule/calendarInput.css +157 -0
  112. package/src/styles/components/molecule/dateTime.css +14 -0
  113. package/src/styles/components/molecule/location-dropdown.css +204 -0
  114. package/src/styles/components/molecule/timePicker.css +79 -0
  115. package/src/styles/components/multiselect-dropdown.css +230 -231
  116. package/src/styles/components/organism/card-container.css +49 -0
  117. package/src/styles/components/organism/dialog.css +241 -0
  118. package/src/styles/components/organism/pax-selector.css +702 -0
  119. package/src/styles/components/organism/round-trip.css +55 -0
  120. package/src/styles/components/organism/search-bar-transfer.css +128 -0
  121. package/src/styles/components/organism/transfer-line.css +86 -0
  122. package/src/styles/components/rating-star.css +39 -0
  123. package/src/styles/components/rating-tab.css +83 -0
  124. package/src/styles/components/segmented-button.css +134 -0
  125. package/src/styles/components/selected-value.css +16 -16
  126. package/src/styles/components/slider.css +86 -0
  127. package/src/styles/components/typography.css +36 -36
  128. package/src/styles/tokens/tokens.css +1093 -1093
  129. package/dist/components/atoms/Typography/Heading/Heading.d.ts +0 -9
  130. package/dist/components/atoms/Typography/Heading/Heading.js +0 -25
  131. package/dist/components/atoms/Typography/Text/Text.d.ts +0 -10
  132. package/dist/components/atoms/Typography/Text/Text.js +0 -77
@@ -0,0 +1,162 @@
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
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
13
+ import { useEffect, useCallback, useRef } from 'react';
14
+ import { createPortal } from 'react-dom';
15
+ import { useMobile } from '../../../hooks/useMobile';
16
+ import Button from '../../atoms/Button/Button';
17
+ import Icon from '../../atoms/Icon/Icon';
18
+ import '../../../styles/components/organism/dialog.css';
19
+ /**
20
+ * Dialog component - A modal dialog that adapts to different screen sizes
21
+ *
22
+ * @example
23
+ * ```tsx
24
+ * <Dialog
25
+ * isOpen={isOpen}
26
+ * onClose={() => setIsOpen(false)}
27
+ * title="Edit Information"
28
+ * onPrimaryClick={handleSave}
29
+ * >
30
+ * <p>Your content here</p>
31
+ * </Dialog>
32
+ * ```
33
+ */
34
+ export var Dialog = function (_a) {
35
+ var isOpen = _a.isOpen, onClose = _a.onClose, title = _a.title, children = _a.children, footer = _a.footer, _b = _a.size, size = _b === void 0 ? 'responsive' : _b, _c = _a.primaryButtonText, primaryButtonText = _c === void 0 ? 'Save and update' : _c, _d = _a.secondaryButtonText, secondaryButtonText = _d === void 0 ? 'Cancel' : _d, onPrimaryClick = _a.onPrimaryClick, onSecondaryClick = _a.onSecondaryClick, _e = _a.showFooter, showFooter = _e === void 0 ? true : _e, _f = _a.showCloseButton, showCloseButton = _f === void 0 ? true : _f, _g = _a.closeOnOverlayClick, closeOnOverlayClick = _g === void 0 ? true : _g, _h = _a.closeOnEscape, closeOnEscape = _h === void 0 ? true : _h, _j = _a.className, className = _j === void 0 ? '' : _j, ariaLabelledBy = _a.ariaLabelledBy, ariaDescribedBy = _a.ariaDescribedBy;
36
+ var _k = useMobile(), isMobile = _k.isMobile, isTablet = _k.isTablet, isDesktop = _k.isDesktop;
37
+ var dialogRef = useRef(null);
38
+ var previousFocusRef = useRef(null);
39
+ // Determine the actual size based on responsive setting
40
+ var getActualSize = function () {
41
+ if (size !== 'responsive')
42
+ return size;
43
+ if (isMobile)
44
+ return 'mobile';
45
+ if (isTablet)
46
+ return 'tablet';
47
+ return 'desktop';
48
+ };
49
+ var actualSize = getActualSize();
50
+ var isMobileSize = actualSize === 'mobile';
51
+ var isTabletSize = actualSize === 'tablet';
52
+ // Handle escape key
53
+ var handleKeyDown = useCallback(function (event) {
54
+ if (closeOnEscape && event.key === 'Escape') {
55
+ onClose();
56
+ }
57
+ }, [closeOnEscape, onClose]);
58
+ // Handle overlay click
59
+ var handleOverlayClick = useCallback(function (event) {
60
+ if (closeOnOverlayClick && event.target === event.currentTarget) {
61
+ onClose();
62
+ }
63
+ }, [closeOnOverlayClick, onClose]);
64
+ // Focus management and scroll lock
65
+ useEffect(function () {
66
+ if (isOpen) {
67
+ // Store current focus
68
+ previousFocusRef.current = document.activeElement;
69
+ // Focus the dialog
70
+ if (dialogRef.current) {
71
+ dialogRef.current.focus();
72
+ }
73
+ // Lock body scroll
74
+ document.body.style.overflow = 'hidden';
75
+ // Add escape listener
76
+ document.addEventListener('keydown', handleKeyDown);
77
+ }
78
+ else {
79
+ // Unlock body scroll
80
+ document.body.style.overflow = '';
81
+ // Restore focus
82
+ if (previousFocusRef.current) {
83
+ previousFocusRef.current.focus();
84
+ }
85
+ }
86
+ return function () {
87
+ document.body.style.overflow = '';
88
+ document.removeEventListener('keydown', handleKeyDown);
89
+ };
90
+ }, [isOpen, handleKeyDown]);
91
+ // Handle secondary button click
92
+ var handleSecondaryClick = function () {
93
+ if (onSecondaryClick) {
94
+ onSecondaryClick();
95
+ }
96
+ else {
97
+ onClose();
98
+ }
99
+ };
100
+ // Handle primary button click
101
+ var handlePrimaryClick = function () {
102
+ if (onPrimaryClick) {
103
+ onPrimaryClick();
104
+ }
105
+ };
106
+ // Generate unique IDs for accessibility
107
+ var titleId = ariaLabelledBy || "dialog-title-".concat(title.replace(/\s+/g, '-').toLowerCase());
108
+ var bodyId = ariaDescribedBy || "dialog-body-".concat(title.replace(/\s+/g, '-').toLowerCase());
109
+ // Build class names
110
+ var contentClasses = [
111
+ 'dialog__content',
112
+ "dialog__content--".concat(actualSize),
113
+ size === 'responsive' ? 'dialog__content--responsive' : '',
114
+ className,
115
+ ]
116
+ .filter(Boolean)
117
+ .join(' ');
118
+ var headerClasses = [
119
+ 'dialog__header',
120
+ isMobileSize ? 'dialog__header--mobile' : '',
121
+ size === 'responsive' ? 'dialog__header--responsive' : '',
122
+ ]
123
+ .filter(Boolean)
124
+ .join(' ');
125
+ var titleClasses = [
126
+ 'dialog__title',
127
+ isMobileSize ? 'dialog__title--mobile' : '',
128
+ isTabletSize ? 'dialog__title--tablet' : '',
129
+ size === 'responsive' ? 'dialog__title--responsive' : '',
130
+ ]
131
+ .filter(Boolean)
132
+ .join(' ');
133
+ var closeButtonClasses = 'dialog__close-button';
134
+ var bodyClasses = [
135
+ 'dialog__body',
136
+ isMobileSize ? 'dialog__body--mobile' : '',
137
+ size === 'responsive' ? 'dialog__body--responsive' : '',
138
+ ]
139
+ .filter(Boolean)
140
+ .join(' ');
141
+ var footerClasses = [
142
+ 'dialog__footer',
143
+ isMobileSize ? 'dialog__footer--mobile' : '',
144
+ size === 'responsive' ? 'dialog__footer--responsive' : '',
145
+ ]
146
+ .filter(Boolean)
147
+ .join(' ');
148
+ var footerButtonsClasses = [
149
+ 'dialog__footer-buttons',
150
+ isMobileSize ? 'dialog__footer-buttons--mobile' : '',
151
+ size === 'responsive' ? 'dialog__footer-buttons--responsive' : '',
152
+ ]
153
+ .filter(Boolean)
154
+ .join(' ');
155
+ if (!isOpen) {
156
+ return null;
157
+ }
158
+ var dialogContent = (_jsxs(_Fragment, { children: [_jsx("div", { className: "dialog-overlay", onClick: handleOverlayClick, "aria-hidden": "true" }), _jsx("div", __assign({ className: "dialog", role: "dialog", "aria-modal": "true", "aria-labelledby": titleId, "aria-describedby": bodyId, ref: dialogRef, tabIndex: -1, onClick: handleOverlayClick }, { children: _jsxs("div", __assign({ className: contentClasses }, { children: [_jsxs("div", __assign({ className: headerClasses }, { children: [_jsx("h2", __assign({ id: titleId, className: titleClasses }, { children: title })), showCloseButton && (_jsx("button", __assign({ type: "button", className: closeButtonClasses, onClick: onClose, "aria-label": "Close dialog" }, { children: _jsx(Icon, { name: "close", size: "md" }) })))] })), _jsx("div", __assign({ id: bodyId, className: bodyClasses }, { children: _jsx("div", __assign({ className: "dialog__body-content" }, { children: children })) })), showFooter && (_jsx("div", __assign({ className: footerClasses }, { children: footer ? (footer) : (_jsxs("div", __assign({ className: footerButtonsClasses }, { children: [_jsx(Button, __assign({ variant: "outline-secondary", size: isMobileSize ? 'sm' : 'md', onClick: handleSecondaryClick }, { children: secondaryButtonText })), _jsx(Button, __assign({ variant: "secondary", size: isMobileSize ? 'sm' : 'md', onClick: handlePrimaryClick }, { children: primaryButtonText }))] }))) })))] })) }))] }));
159
+ // Use portal to render at the document body level
160
+ return createPortal(dialogContent, document.body);
161
+ };
162
+ export default Dialog;
@@ -0,0 +1,63 @@
1
+ import React from 'react';
2
+ export type ClientType = 'Standard client' | 'VIP' | 'VVIP' | 'Honeymooners';
3
+ /**
4
+ * Individual passenger/pax data for a single room
5
+ */
6
+ export interface PaxData {
7
+ adults: number;
8
+ teens: number;
9
+ children: number;
10
+ infants: number;
11
+ /** Ages for teens (1-18 years) */
12
+ teenAges?: number[];
13
+ /** Ages for children (1-18 years) */
14
+ childAges?: number[];
15
+ /** Ages for infants (1-18 years) */
16
+ infantAges?: number[];
17
+ clientType: ClientType;
18
+ }
19
+ /**
20
+ * Room data for multiple room mode
21
+ */
22
+ export interface RoomData extends PaxData {
23
+ roomId: string;
24
+ }
25
+ export interface PaxSelectorProps {
26
+ /** Label for the selector */
27
+ label?: string;
28
+ /** Current pax data (single room mode) */
29
+ value?: PaxData;
30
+ /** Callback when pax data changes (single room mode) */
31
+ onChange?: (data: PaxData) => void;
32
+ /** Callback when "Add a room" is clicked */
33
+ onAddRoom?: () => void;
34
+ /** Callback when Done button is clicked */
35
+ onDone?: (data: PaxData | RoomData[]) => void;
36
+ /** Placeholder text */
37
+ placeholder?: string;
38
+ /** Additional CSS classes */
39
+ className?: string;
40
+ /** Maximum number of adults */
41
+ maxAdults?: number;
42
+ /** Maximum number of teens */
43
+ maxTeens?: number;
44
+ /** Maximum number of children */
45
+ maxChildren?: number;
46
+ /** Maximum number of infants */
47
+ maxInfants?: number;
48
+ /** Show add room link */
49
+ showAddRoom?: boolean;
50
+ /** Enable multiple room mode */
51
+ multipleRooms?: boolean;
52
+ /** Default rooms for multiple room mode */
53
+ defaultRooms?: RoomData[];
54
+ /** Callback when rooms change in multiple room mode */
55
+ onRoomsChange?: (rooms: RoomData[]) => void;
56
+ /** Callback when a room is removed */
57
+ onRemoveRoom?: (roomId: string) => void;
58
+ /** Default pax data for single room mode (will trigger onChange on mount) */
59
+ defaultPaxData?: PaxData;
60
+ }
61
+ export declare const DEFAULT_PAX_DATA_WITH_ADULTS: PaxData;
62
+ declare const PaxSelector: React.FC<PaxSelectorProps>;
63
+ export default PaxSelector;
@@ -0,0 +1,402 @@
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 { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
22
+ import { useState, useRef, useEffect } from 'react';
23
+ import Icon from '../../atoms/Icon/Icon';
24
+ import { Text } from '../../atoms/Typography/Typography';
25
+ var DEFAULT_PAX_DATA = {
26
+ adults: 0,
27
+ teens: 0,
28
+ children: 0,
29
+ infants: 0,
30
+ teenAges: [],
31
+ childAges: [],
32
+ infantAges: [],
33
+ clientType: 'Standard client',
34
+ };
35
+ export var DEFAULT_PAX_DATA_WITH_ADULTS = {
36
+ adults: 2,
37
+ teens: 0,
38
+ children: 0,
39
+ infants: 0,
40
+ teenAges: [],
41
+ childAges: [],
42
+ infantAges: [],
43
+ clientType: 'Standard client',
44
+ };
45
+ var CLIENT_TYPES = ['Standard client', 'VIP', 'VVIP', 'Honeymooners'];
46
+ // Age range for all child categories (teens, children, infants)
47
+ var CHILD_CATEGORY_AGES = Array.from({ length: 18 }, function (_, i) { return i + 1; }); // 1-18 years
48
+ var AgeSelector = function (_a) {
49
+ var label = _a.label, value = _a.value, onChange = _a.onChange, ageRange = _a.ageRange, required = _a.required;
50
+ var _b = useState(false), isOpen = _b[0], setIsOpen = _b[1];
51
+ var _c = useState(value !== undefined ? value.toString() : ''), inputValue = _c[0], setInputValue = _c[1];
52
+ var containerRef = useRef(null);
53
+ var inputRef = useRef(null);
54
+ // Sync input value when prop value changes
55
+ useEffect(function () {
56
+ setInputValue(value !== undefined ? value.toString() : '');
57
+ }, [value]);
58
+ useEffect(function () {
59
+ var handleClickOutside = function (event) {
60
+ if (containerRef.current && !containerRef.current.contains(event.target)) {
61
+ setIsOpen(false);
62
+ }
63
+ };
64
+ if (isOpen) {
65
+ document.addEventListener('mousedown', handleClickOutside);
66
+ }
67
+ return function () {
68
+ document.removeEventListener('mousedown', handleClickOutside);
69
+ };
70
+ }, [isOpen]);
71
+ var handleInputChange = function (e) {
72
+ var newValue = e.target.value;
73
+ // Only allow numeric input or empty string
74
+ if (newValue === '' || /^\d+$/.test(newValue)) {
75
+ setInputValue(newValue);
76
+ // Only update if it's a valid number within range
77
+ var numValue = parseInt(newValue, 10);
78
+ if (newValue === '') {
79
+ // Allow empty input - don't update onChange
80
+ return;
81
+ }
82
+ else if (!isNaN(numValue) && ageRange.includes(numValue)) {
83
+ onChange(numValue);
84
+ }
85
+ }
86
+ };
87
+ var handleInputBlur = function () {
88
+ // Validate and set to valid value or clear if invalid
89
+ var numValue = parseInt(inputValue, 10);
90
+ if (inputValue === '') {
91
+ // Keep empty if user cleared it
92
+ return;
93
+ }
94
+ else if (isNaN(numValue) || !ageRange.includes(numValue)) {
95
+ // Reset to current value if invalid
96
+ setInputValue(value !== undefined ? value.toString() : '');
97
+ }
98
+ else {
99
+ // Ensure the input value matches the validated value
100
+ setInputValue(numValue.toString());
101
+ }
102
+ };
103
+ var handleInputKeyDown = function (e) {
104
+ var _a;
105
+ if (e.key === 'Enter') {
106
+ e.preventDefault();
107
+ (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.blur();
108
+ }
109
+ };
110
+ var handleSelect = function (age) {
111
+ var numAge = parseInt(age, 10);
112
+ onChange(numAge);
113
+ setIsOpen(false);
114
+ setInputValue(age);
115
+ };
116
+ var handleDropdownToggle = function () {
117
+ setIsOpen(!isOpen);
118
+ };
119
+ var ageOptions = ageRange.map(function (age) { return age.toString(); });
120
+ var displayValue = inputValue || undefined;
121
+ return (_jsxs("div", __assign({ className: "pax-selector__age-selector", ref: containerRef }, { children: [_jsxs(Text, __assign({ size: "sm", variant: "regular", className: "pax-selector__age-label" }, { children: [label, required && _jsx("span", __assign({ className: "pax-selector__age-required" }, { children: " *" }))] })), _jsxs("div", __assign({ className: "dropdown-container pax-selector__age-dropdown-container" }, { children: [_jsxs("div", __assign({ className: "dropdown-input ".concat(isOpen ? 'dropdown-input--open pax-selector__age-dropdown-input--open' : '', " ").concat(value !== undefined ? 'dropdown-input--selected' : 'dropdown-input--default', " pax-selector__age-dropdown-input") }, { children: [_jsx("input", { ref: inputRef, type: "text", inputMode: "numeric", className: "dropdown-input__text pax-selector__age-input-text", value: inputValue, onChange: handleInputChange, onBlur: handleInputBlur, onKeyDown: handleInputKeyDown, onFocus: function () { return setIsOpen(false); }, placeholder: "--", "aria-label": "".concat(label, " age"), style: {
122
+ background: 'transparent',
123
+ border: 'none',
124
+ outline: 'none',
125
+ width: '100%',
126
+ cursor: 'text'
127
+ } }), _jsx("button", __assign({ type: "button", className: "pax-selector__age-dropdown-btn", onClick: function (e) {
128
+ e.preventDefault();
129
+ e.stopPropagation();
130
+ handleDropdownToggle();
131
+ }, "aria-expanded": isOpen, "aria-haspopup": "listbox", "aria-label": "Open age dropdown", style: {
132
+ background: 'transparent',
133
+ border: 'none',
134
+ cursor: 'pointer',
135
+ padding: 0,
136
+ display: 'flex',
137
+ alignItems: 'center'
138
+ } }, { children: _jsx(Icon, { name: "chevron-down", size: "sm", className: "dropdown-input__icon dropdown-input__icon--chevron" }) }))] })), isOpen && (_jsx("div", __assign({ className: "dropdown-menu", role: "listbox" }, { children: ageOptions.map(function (age) { return (_jsx("div", __assign({ className: "dropdown-option ".concat((value === null || value === void 0 ? void 0 : value.toString()) === age ? 'dropdown-option--selected' : ''), onClick: function () { return handleSelect(age); }, role: "option", "aria-selected": (value === null || value === void 0 ? void 0 : value.toString()) === age }, { children: age }), age)); }) })))] }))] })));
139
+ };
140
+ var StepperRow = function (_a) {
141
+ 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;
142
+ var handleDecrement = function () {
143
+ if (value > min) {
144
+ onChange(value - 1);
145
+ }
146
+ };
147
+ var handleIncrement = function () {
148
+ if (value < max) {
149
+ onChange(value + 1);
150
+ }
151
+ };
152
+ return (_jsxs("div", __assign({ className: "pax-selector__stepper" }, { children: [_jsx(Text, __assign({ size: "base", variant: "bold", className: "pax-selector__stepper-label" }, { children: label })), _jsxs("div", __assign({ className: "pax-selector__stepper-controls" }, { children: [_jsx("button", __assign({ 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", __assign({ className: "pax-selector__stepper-count" }, { children: value })), _jsx("button", __assign({ type: "button", className: "pax-selector__stepper-btn", onClick: handleIncrement, disabled: value >= max, "aria-label": "Increase ".concat(label) }, { children: _jsx(Icon, { name: "plus", size: "sm" }) }))] }))] })));
153
+ };
154
+ var ClientTypeSelector = function (_a) {
155
+ var value = _a.value, onChange = _a.onChange;
156
+ var _b = useState(false), isOpen = _b[0], setIsOpen = _b[1];
157
+ var containerRef = useRef(null);
158
+ useEffect(function () {
159
+ var handleClickOutside = function (event) {
160
+ if (containerRef.current && !containerRef.current.contains(event.target)) {
161
+ setIsOpen(false);
162
+ }
163
+ };
164
+ if (isOpen) {
165
+ document.addEventListener('mousedown', handleClickOutside);
166
+ }
167
+ return function () {
168
+ document.removeEventListener('mousedown', handleClickOutside);
169
+ };
170
+ }, [isOpen]);
171
+ var handleSelect = function (type) {
172
+ onChange(type);
173
+ setIsOpen(false);
174
+ };
175
+ return (_jsxs("div", __assign({ className: "pax-selector__client-type" }, { children: [_jsx(Text, __assign({ size: "sm", variant: "regular", className: "pax-selector__client-type-label" }, { children: "Client type" })), _jsxs("div", __assign({ className: "pax-selector__client-type-select", ref: containerRef }, { children: [_jsxs("button", __assign({ type: "button", className: "pax-selector__client-type-trigger", onClick: function () { return setIsOpen(!isOpen); }, "aria-expanded": isOpen, "aria-haspopup": "listbox" }, { children: [_jsxs("div", __assign({ className: "pax-selector__client-type-content" }, { children: [_jsx(Icon, { name: "user-icon", size: "sm", className: "pax-selector__client-type-icon" }), _jsx("span", __assign({ 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", __assign({ className: "pax-selector__client-type-dropdown", role: "listbox" }, { children: CLIENT_TYPES.map(function (type) { return (_jsxs("button", __assign({ 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)); }) })))] }))] })));
176
+ };
177
+ var RoomEditor = function (_a) {
178
+ 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;
179
+ var handleFieldChange = function (field, value) {
180
+ var _a;
181
+ onChange(__assign(__assign({}, room), (_a = {}, _a[field] = value, _a)));
182
+ };
183
+ var handleAgeChange = function (category, index, age) {
184
+ var ages = __spreadArray([], (room[category] || []), true);
185
+ ages[index] = age;
186
+ handleFieldChange(category, ages);
187
+ };
188
+ // Generate age arrays based on counts
189
+ useEffect(function () {
190
+ var teenAges = room.teenAges || [];
191
+ var childAges = room.childAges || [];
192
+ var infantAges = room.infantAges || [];
193
+ // Adjust teen ages array
194
+ if (teenAges.length < room.teens) {
195
+ handleFieldChange('teenAges', __spreadArray(__spreadArray([], teenAges, true), Array(room.teens - teenAges.length).fill(undefined), true));
196
+ }
197
+ else if (teenAges.length > room.teens) {
198
+ handleFieldChange('teenAges', teenAges.slice(0, room.teens));
199
+ }
200
+ // Adjust child ages array
201
+ if (childAges.length < room.children) {
202
+ handleFieldChange('childAges', __spreadArray(__spreadArray([], childAges, true), Array(room.children - childAges.length).fill(undefined), true));
203
+ }
204
+ else if (childAges.length > room.children) {
205
+ handleFieldChange('childAges', childAges.slice(0, room.children));
206
+ }
207
+ // Adjust infant ages array
208
+ if (infantAges.length < room.infants) {
209
+ handleFieldChange('infantAges', __spreadArray(__spreadArray([], infantAges, true), Array(room.infants - infantAges.length).fill(undefined), true));
210
+ }
211
+ else if (infantAges.length > room.infants) {
212
+ handleFieldChange('infantAges', infantAges.slice(0, room.infants));
213
+ }
214
+ }, [room.teens, room.children, room.infants]);
215
+ // Chunk ages into groups of 2 for layout
216
+ var chunkAges = function (ages, category) {
217
+ var chunks = [];
218
+ for (var i = 0; i < ages.length; i += 2) {
219
+ chunks.push(ages.slice(i, i + 2));
220
+ }
221
+ return chunks;
222
+ };
223
+ var teenAgeChunks = chunkAges(room.teenAges || [], 'Teen');
224
+ var childAgeChunks = chunkAges(room.childAges || [], 'Child');
225
+ var infantAgeChunks = chunkAges(room.infantAges || [], 'Infant');
226
+ return (_jsxs("div", __assign({ className: "pax-selector__room-container" }, { children: [_jsxs("div", __assign({ className: "pax-selector__room-header" }, { children: [_jsxs("div", __assign({ className: "pax-selector__room-title" }, { children: [_jsxs(Text, __assign({ size: "lg", variant: "bold", className: "pax-selector__room-name" }, { children: ["Room ", roomNumber] })), _jsx(Icon, { name: "home", size: "md", className: "pax-selector__room-icon" })] })), showRemove && (_jsxs("button", __assign({ 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", __assign({ className: "pax-selector__room-remove-text" }, { children: "Remove" }))] })))] })), _jsxs("div", __assign({ className: "pax-selector__room-content" }, { children: [_jsxs("div", __assign({ 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", __assign({ className: "pax-selector__age-section" }, { children: [_jsx(Text, __assign({ size: "base", variant: "bold", className: "pax-selector__age-section-title" }, { children: "Please specify the age :" })), _jsxs("div", __assign({ className: "pax-selector__age-groups" }, { children: [room.teens > 0 && teenAgeChunks.map(function (chunk, chunkIndex) { return (_jsx("div", __assign({ className: "pax-selector__age-row" }, { children: chunk.map(function (age, ageIndex) {
227
+ var actualIndex = chunkIndex * 2 + ageIndex;
228
+ return (_jsx(AgeSelector, { label: "Teen", value: age, onChange: function (selectedAge) { return handleAgeChange('teenAges', actualIndex, selectedAge); }, ageRange: CHILD_CATEGORY_AGES, required: true }, "teen-".concat(actualIndex)));
229
+ }) }), "teen-chunk-".concat(chunkIndex))); }), room.children > 0 && childAgeChunks.map(function (chunk, chunkIndex) { return (_jsx("div", __assign({ className: "pax-selector__age-row" }, { children: chunk.map(function (age, ageIndex) {
230
+ var actualIndex = chunkIndex * 2 + ageIndex;
231
+ return (_jsx(AgeSelector, { label: "Child", value: age, onChange: function (selectedAge) { return handleAgeChange('childAges', actualIndex, selectedAge); }, ageRange: CHILD_CATEGORY_AGES, required: true }, "child-".concat(actualIndex)));
232
+ }) }), "child-chunk-".concat(chunkIndex))); }), room.infants > 0 && infantAgeChunks.map(function (chunk, chunkIndex) { return (_jsx("div", __assign({ className: "pax-selector__age-row" }, { children: chunk.map(function (age, ageIndex) {
233
+ var actualIndex = chunkIndex * 2 + ageIndex;
234
+ return (_jsx(AgeSelector, { label: "Infant", value: age, onChange: function (selectedAge) { return handleAgeChange('infantAges', actualIndex, selectedAge); }, ageRange: CHILD_CATEGORY_AGES, required: true }, "infant-".concat(actualIndex)));
235
+ }) }), "infant-chunk-".concat(chunkIndex))); })] }))] }))), _jsx(ClientTypeSelector, { value: room.clientType, onChange: function (val) { return handleFieldChange('clientType', val); } })] }))] })));
236
+ };
237
+ var PaxSelector = function (_a) {
238
+ 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;
239
+ var _m = useState(false), isOpen = _m[0], setIsOpen = _m[1];
240
+ var _o = useState(value || defaultPaxData || DEFAULT_PAX_DATA), internalData = _o[0], setInternalData = _o[1];
241
+ var _p = useState(defaultRooms || [__assign(__assign({}, DEFAULT_PAX_DATA), { roomId: '1' })]), rooms = _p[0], setRooms = _p[1];
242
+ var containerRef = useRef(null);
243
+ var hasInitialized = useRef(false);
244
+ // Sync internal data with external value prop
245
+ useEffect(function () {
246
+ if (value && !multipleRooms) {
247
+ setInternalData(value);
248
+ }
249
+ }, [value, multipleRooms]);
250
+ // Initialize with default pax data and trigger onChange on mount
251
+ useEffect(function () {
252
+ if (!hasInitialized.current && !value && defaultPaxData && !multipleRooms && onChange) {
253
+ hasInitialized.current = true;
254
+ onChange(defaultPaxData);
255
+ }
256
+ }, [defaultPaxData, value, multipleRooms, onChange]);
257
+ // Manage age arrays in single mode when counts change
258
+ useEffect(function () {
259
+ if (!multipleRooms) {
260
+ var teenAges = internalData.teenAges || [];
261
+ var childAges = internalData.childAges || [];
262
+ var infantAges = internalData.infantAges || [];
263
+ var needsUpdate = false;
264
+ var updatedData = __assign({}, internalData);
265
+ // Adjust teen ages array
266
+ if (teenAges.length < internalData.teens) {
267
+ updatedData.teenAges = __spreadArray(__spreadArray([], teenAges, true), Array(internalData.teens - teenAges.length).fill(undefined), true);
268
+ needsUpdate = true;
269
+ }
270
+ else if (teenAges.length > internalData.teens) {
271
+ updatedData.teenAges = teenAges.slice(0, internalData.teens);
272
+ needsUpdate = true;
273
+ }
274
+ // Adjust child ages array
275
+ if (childAges.length < internalData.children) {
276
+ updatedData.childAges = __spreadArray(__spreadArray([], childAges, true), Array(internalData.children - childAges.length).fill(undefined), true);
277
+ needsUpdate = true;
278
+ }
279
+ else if (childAges.length > internalData.children) {
280
+ updatedData.childAges = childAges.slice(0, internalData.children);
281
+ needsUpdate = true;
282
+ }
283
+ // Adjust infant ages array
284
+ if (infantAges.length < internalData.infants) {
285
+ updatedData.infantAges = __spreadArray(__spreadArray([], infantAges, true), Array(internalData.infants - infantAges.length).fill(undefined), true);
286
+ needsUpdate = true;
287
+ }
288
+ else if (infantAges.length > internalData.infants) {
289
+ updatedData.infantAges = infantAges.slice(0, internalData.infants);
290
+ needsUpdate = true;
291
+ }
292
+ if (needsUpdate) {
293
+ setInternalData(updatedData);
294
+ onChange === null || onChange === void 0 ? void 0 : onChange(updatedData);
295
+ }
296
+ }
297
+ // eslint-disable-next-line react-hooks/exhaustive-deps
298
+ }, [internalData.teens, internalData.children, internalData.infants, multipleRooms]);
299
+ // Handle clicks outside the dropdown
300
+ useEffect(function () {
301
+ var handleClickOutside = function (event) {
302
+ if (containerRef.current && !containerRef.current.contains(event.target)) {
303
+ setIsOpen(false);
304
+ }
305
+ };
306
+ if (isOpen) {
307
+ document.addEventListener('mousedown', handleClickOutside);
308
+ }
309
+ return function () {
310
+ document.removeEventListener('mousedown', handleClickOutside);
311
+ };
312
+ }, [isOpen]);
313
+ var handleDataChange = function (field, newValue) {
314
+ var _a;
315
+ var newData = __assign(__assign({}, internalData), (_a = {}, _a[field] = newValue, _a));
316
+ setInternalData(newData);
317
+ onChange === null || onChange === void 0 ? void 0 : onChange(newData);
318
+ };
319
+ var handleClear = function () {
320
+ if (multipleRooms) {
321
+ var clearedRooms = rooms.map(function (room) { return (__assign(__assign({}, DEFAULT_PAX_DATA), { roomId: room.roomId })); });
322
+ setRooms(clearedRooms);
323
+ onRoomsChange === null || onRoomsChange === void 0 ? void 0 : onRoomsChange(clearedRooms);
324
+ }
325
+ else {
326
+ var clearedData = __assign({}, DEFAULT_PAX_DATA);
327
+ setInternalData(clearedData);
328
+ onChange === null || onChange === void 0 ? void 0 : onChange(clearedData);
329
+ }
330
+ };
331
+ var handleDone = function () {
332
+ setIsOpen(false);
333
+ onDone === null || onDone === void 0 ? void 0 : onDone(multipleRooms ? rooms : internalData);
334
+ };
335
+ var handleAddRoom = function () {
336
+ var newRoom = __assign(__assign({}, DEFAULT_PAX_DATA), { roomId: "".concat(rooms.length + 1) });
337
+ var updatedRooms = __spreadArray(__spreadArray([], rooms, true), [newRoom], false);
338
+ setRooms(updatedRooms);
339
+ onRoomsChange === null || onRoomsChange === void 0 ? void 0 : onRoomsChange(updatedRooms);
340
+ onAddRoom === null || onAddRoom === void 0 ? void 0 : onAddRoom();
341
+ };
342
+ var handleRemoveRoom = function (roomId) {
343
+ var updatedRooms = rooms.filter(function (room) { return room.roomId !== roomId; });
344
+ setRooms(updatedRooms);
345
+ onRoomsChange === null || onRoomsChange === void 0 ? void 0 : onRoomsChange(updatedRooms);
346
+ onRemoveRoom === null || onRemoveRoom === void 0 ? void 0 : onRemoveRoom(roomId);
347
+ };
348
+ var handleRoomChange = function (roomId, updatedRoom) {
349
+ var updatedRooms = rooms.map(function (room) {
350
+ return room.roomId === roomId ? updatedRoom : room;
351
+ });
352
+ setRooms(updatedRooms);
353
+ onRoomsChange === null || onRoomsChange === void 0 ? void 0 : onRoomsChange(updatedRooms);
354
+ };
355
+ var getTotalPax = function () {
356
+ if (multipleRooms) {
357
+ return rooms.reduce(function (total, room) {
358
+ return total + room.adults + room.teens + room.children + room.infants;
359
+ }, 0);
360
+ }
361
+ var adults = internalData.adults, teens = internalData.teens, children = internalData.children, infants = internalData.infants;
362
+ return adults + teens + children + infants;
363
+ };
364
+ var getDisplayText = function () {
365
+ var total = getTotalPax();
366
+ if (total === 0) {
367
+ return placeholder;
368
+ }
369
+ return "".concat(total, " pax");
370
+ };
371
+ var hasPax = getTotalPax() > 0;
372
+ return (_jsxs("div", __assign({ className: "pax-selector ".concat(className), ref: containerRef }, { children: [_jsxs("button", __assign({ type: "button", className: "pax-selector__trigger", onClick: function () { return setIsOpen(!isOpen); }, "aria-expanded": isOpen, "aria-haspopup": "true" }, { children: [_jsx(Text, __assign({ size: "sm", variant: "regular", className: "pax-selector__label" }, { children: label })), _jsxs("div", __assign({ className: "pax-selector__input ".concat(isOpen ? 'pax-selector__input--active' : '') }, { children: [_jsxs("div", __assign({ className: "pax-selector__input-content" }, { children: [_jsx(Icon, { name: "user-icon", size: "sm", className: "pax-selector__input-icon" }), _jsx("span", __assign({ className: "pax-selector__input-text ".concat(!hasPax ? 'pax-selector__input-placeholder' : '') }, { children: getDisplayText() }))] })), _jsx(Icon, { name: "chevron-down", size: "sm", className: "pax-selector__chevron ".concat(isOpen ? 'pax-selector__chevron--open' : '') })] }))] })), isOpen && (_jsxs("div", __assign({ className: "pax-selector__dropdown" }, { children: [multipleRooms ? (_jsxs(_Fragment, { children: [showAddRoom && (_jsxs("button", __assign({ type: "button", className: "pax-selector__add-room", onClick: handleAddRoom }, { children: [_jsx(Icon, { name: "home", size: "sm", className: "pax-selector__add-room-icon" }), "Add a room", _jsx(Icon, { name: "plus", size: "sm", className: "pax-selector__add-room-icon" })] }))), _jsx("div", __assign({ className: "pax-selector__rooms" }, { children: rooms.map(function (room, index) { return (_jsx(RoomEditor, { room: room, roomNumber: index + 1, showRemove: rooms.length > 1, maxAdults: maxAdults, maxTeens: maxTeens, maxChildren: maxChildren, maxInfants: maxInfants, onChange: function (updatedRoom) { return handleRoomChange(room.roomId, updatedRoom); }, onRemove: function () { return handleRemoveRoom(room.roomId); } }, room.roomId)); }) }))] })) : (
373
+ /* Single Room Mode */
374
+ _jsxs(_Fragment, { children: [_jsxs("div", __assign({ className: "pax-selector__steppers" }, { children: [_jsx(StepperRow, { label: "Adult", value: internalData.adults, max: maxAdults, onChange: function (val) { return handleDataChange('adults', val); } }), _jsx(StepperRow, { label: "Teen", value: internalData.teens, max: maxTeens, onChange: function (val) { return handleDataChange('teens', val); } }), _jsx(StepperRow, { label: "Child", value: internalData.children, max: maxChildren, onChange: function (val) { return handleDataChange('children', val); } }), _jsx(StepperRow, { label: "Infant", value: internalData.infants, max: maxInfants, onChange: function (val) { return handleDataChange('infants', val); } })] })), ((internalData.teens > 0) || (internalData.children > 0) || (internalData.infants > 0)) && (_jsxs("div", __assign({ className: "pax-selector__age-section" }, { children: [_jsx(Text, __assign({ size: "base", variant: "bold", className: "pax-selector__age-section-title" }, { children: "Please specify the age :" })), _jsx("div", __assign({ className: "pax-selector__age-groups" }, { children: (function () {
375
+ var chunkAges = function (ages, category) {
376
+ var chunks = [];
377
+ for (var i = 0; i < ages.length; i += 2) {
378
+ chunks.push(ages.slice(i, i + 2));
379
+ }
380
+ return chunks;
381
+ };
382
+ var teenAgeChunks = chunkAges(internalData.teenAges || [], 'Teen');
383
+ var childAgeChunks = chunkAges(internalData.childAges || [], 'Child');
384
+ var infantAgeChunks = chunkAges(internalData.infantAges || [], 'Infant');
385
+ var handleAgeChange = function (category, index, age) {
386
+ var ages = __spreadArray([], (internalData[category] || []), true);
387
+ ages[index] = age;
388
+ handleDataChange(category, ages);
389
+ };
390
+ return (_jsxs(_Fragment, { children: [internalData.teens > 0 && teenAgeChunks.map(function (chunk, chunkIndex) { return (_jsx("div", __assign({ className: "pax-selector__age-row" }, { children: chunk.map(function (age, ageIndex) {
391
+ var actualIndex = chunkIndex * 2 + ageIndex;
392
+ return (_jsx(AgeSelector, { label: "Teen", value: age, onChange: function (selectedAge) { return handleAgeChange('teenAges', actualIndex, selectedAge); }, ageRange: CHILD_CATEGORY_AGES, required: true }, "teen-".concat(actualIndex)));
393
+ }) }), "teen-chunk-".concat(chunkIndex))); }), internalData.children > 0 && childAgeChunks.map(function (chunk, chunkIndex) { return (_jsx("div", __assign({ className: "pax-selector__age-row" }, { children: chunk.map(function (age, ageIndex) {
394
+ var actualIndex = chunkIndex * 2 + ageIndex;
395
+ return (_jsx(AgeSelector, { label: "Child", value: age, onChange: function (selectedAge) { return handleAgeChange('childAges', actualIndex, selectedAge); }, ageRange: CHILD_CATEGORY_AGES, required: true }, "child-".concat(actualIndex)));
396
+ }) }), "child-chunk-".concat(chunkIndex))); }), internalData.infants > 0 && infantAgeChunks.map(function (chunk, chunkIndex) { return (_jsx("div", __assign({ className: "pax-selector__age-row" }, { children: chunk.map(function (age, ageIndex) {
397
+ var actualIndex = chunkIndex * 2 + ageIndex;
398
+ return (_jsx(AgeSelector, { label: "Infant", value: age, onChange: function (selectedAge) { return handleAgeChange('infantAges', actualIndex, selectedAge); }, ageRange: CHILD_CATEGORY_AGES, required: true }, "infant-".concat(actualIndex)));
399
+ }) }), "infant-chunk-".concat(chunkIndex))); })] }));
400
+ })() }))] }))), _jsx(ClientTypeSelector, { value: internalData.clientType, onChange: function (val) { return handleDataChange('clientType', val); } })] })), _jsxs("div", __assign({ className: "pax-selector__actions" }, { children: [_jsx("button", __assign({ type: "button", className: "pax-selector__clear-btn", onClick: handleClear }, { children: "Clear Pax" })), _jsx("button", __assign({ type: "button", className: "pax-selector__done-btn", onClick: handleDone }, { children: "Done" }))] }))] })))] })));
401
+ };
402
+ export default PaxSelector;