mautourco-components 0.2.4 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +190 -190
- package/dist/components/atoms/Avatar/Avatar.d.ts +14 -14
- package/dist/components/atoms/Avatar/Avatar.js +31 -31
- package/dist/components/atoms/Button/Button.css +320 -320
- package/dist/components/atoms/Button/Button.d.ts +27 -27
- package/dist/components/atoms/Button/Button.js +35 -35
- package/dist/components/atoms/Checkbox/Checkbox.d.ts +13 -13
- package/dist/components/atoms/Checkbox/Checkbox.js +39 -39
- package/dist/components/atoms/Icon/Icon.d.ts +10 -10
- package/dist/components/atoms/Icon/Icon.js +123 -123
- package/dist/components/atoms/Icon/icons/ArrivalIcon.d.ts +8 -8
- package/dist/components/atoms/Icon/icons/ArrivalIcon.js +31 -31
- package/dist/components/atoms/Icon/icons/BuildingIcon.d.ts +8 -8
- package/dist/components/atoms/Icon/icons/BuildingIcon.js +36 -36
- package/dist/components/atoms/Icon/icons/CalendarIcon.d.ts +12 -12
- package/dist/components/atoms/Icon/icons/CalendarIcon.js +41 -41
- package/dist/components/atoms/Icon/icons/CalendarOutlineIcon.d.ts +8 -8
- package/dist/components/atoms/Icon/icons/CalendarOutlineIcon.js +36 -36
- package/dist/components/atoms/Icon/icons/CarIcon.d.ts +8 -8
- package/dist/components/atoms/Icon/icons/CarIcon.js +30 -30
- package/dist/components/atoms/Icon/icons/Check.d.ts +8 -8
- package/dist/components/atoms/Icon/icons/Check.js +30 -30
- package/dist/components/atoms/Icon/icons/CheckCircleIcon.d.ts +8 -8
- package/dist/components/atoms/Icon/icons/CheckCircleIcon.js +30 -30
- package/dist/components/atoms/Icon/icons/Chevron.d.ts +9 -9
- package/dist/components/atoms/Icon/icons/Chevron.js +54 -54
- package/dist/components/atoms/Icon/icons/ChevronDownIcon.d.ts +8 -8
- package/dist/components/atoms/Icon/icons/ChevronDownIcon.js +30 -30
- package/dist/components/atoms/Icon/icons/Close.d.ts +8 -8
- package/dist/components/atoms/Icon/icons/Close.js +30 -30
- package/dist/components/atoms/Icon/icons/DeleteIcon.d.ts +8 -8
- package/dist/components/atoms/Icon/icons/DeleteIcon.js +30 -30
- package/dist/components/atoms/Icon/icons/DepartureIcon.d.ts +8 -8
- package/dist/components/atoms/Icon/icons/DepartureIcon.js +30 -30
- package/dist/components/atoms/Icon/icons/EyeIcon.d.ts +8 -8
- package/dist/components/atoms/Icon/icons/EyeIcon.js +30 -30
- package/dist/components/atoms/Icon/icons/FacebookIcon.d.ts +8 -8
- package/dist/components/atoms/Icon/icons/FacebookIcon.js +36 -36
- package/dist/components/atoms/Icon/icons/HomeIcon.d.ts +8 -8
- package/dist/components/atoms/Icon/icons/HomeIcon.js +25 -25
- package/dist/components/atoms/Icon/icons/InfoIcon.d.ts +8 -8
- package/dist/components/atoms/Icon/icons/InfoIcon.js +30 -30
- package/dist/components/atoms/Icon/icons/LinkedInIcon.d.ts +8 -8
- package/dist/components/atoms/Icon/icons/LinkedInIcon.js +36 -36
- package/dist/components/atoms/Icon/icons/MapPinIcon.d.ts +8 -8
- package/dist/components/atoms/Icon/icons/MapPinIcon.js +30 -30
- package/dist/components/atoms/Icon/icons/MautoucoLogo.d.ts +8 -8
- package/dist/components/atoms/Icon/icons/MautoucoLogo.js +37 -37
- package/dist/components/atoms/Icon/icons/MenuIcon.d.ts +8 -8
- package/dist/components/atoms/Icon/icons/MenuIcon.js +37 -37
- package/dist/components/atoms/Icon/icons/MinusIcon.d.ts +8 -8
- package/dist/components/atoms/Icon/icons/MinusIcon.js +25 -25
- package/dist/components/atoms/Icon/icons/MoreIcon.d.ts +8 -8
- package/dist/components/atoms/Icon/icons/MoreIcon.js +30 -30
- package/dist/components/atoms/Icon/icons/PlaneIcon.d.ts +8 -8
- package/dist/components/atoms/Icon/icons/PlaneIcon.js +36 -36
- package/dist/components/atoms/Icon/icons/PlusIcon.d.ts +8 -8
- package/dist/components/atoms/Icon/icons/PlusIcon.js +25 -25
- package/dist/components/atoms/Icon/icons/Search.d.ts +8 -8
- package/dist/components/atoms/Icon/icons/Search.js +30 -30
- package/dist/components/atoms/Icon/icons/Settings.d.ts +8 -8
- package/dist/components/atoms/Icon/icons/Settings.js +30 -30
- package/dist/components/atoms/Icon/icons/ShipIcon.d.ts +8 -8
- package/dist/components/atoms/Icon/icons/ShipIcon.js +36 -36
- package/dist/components/atoms/Icon/icons/StrollerIcon.d.ts +8 -8
- package/dist/components/atoms/Icon/icons/StrollerIcon.js +30 -30
- package/dist/components/atoms/Icon/icons/TwitterIcon.d.ts +8 -8
- package/dist/components/atoms/Icon/icons/TwitterIcon.js +36 -36
- package/dist/components/atoms/Icon/icons/User.d.ts +8 -8
- package/dist/components/atoms/Icon/icons/User.js +30 -30
- package/dist/components/atoms/Icon/icons/UserIcon.d.ts +12 -12
- package/dist/components/atoms/Icon/icons/UserIcon.js +41 -41
- package/dist/components/atoms/Icon/icons/Youtube.d.ts +8 -8
- package/dist/components/atoms/Icon/icons/Youtube.js +36 -36
- package/dist/components/atoms/Illustration/Illustration.d.ts +14 -14
- package/dist/components/atoms/Illustration/Illustration.js +33 -33
- package/dist/components/atoms/Illustration/illustrations.d.ts +51 -51
- package/dist/components/atoms/Illustration/illustrations.js +97 -97
- package/dist/components/atoms/Inputs/DropdownInput/DropdownInput.d.ts +12 -12
- package/dist/components/atoms/Inputs/DropdownInput/DropdownInput.js +53 -53
- package/dist/components/atoms/Inputs/Input/Input.d.ts +15 -15
- package/dist/components/atoms/Inputs/Input/Input.js +27 -27
- package/dist/components/atoms/Inputs/Textarea/Textarea.d.ts +14 -14
- package/dist/components/atoms/Inputs/Textarea/Textarea.js +15 -15
- package/dist/components/atoms/Link/Link.d.ts +44 -44
- package/dist/components/atoms/Link/Link.js +76 -76
- package/dist/components/atoms/RatingStar/RatingStar.d.ts +40 -40
- package/dist/components/atoms/RatingStar/RatingStar.js +54 -54
- package/dist/components/atoms/SegmentedButton/SegmentedButton.d.ts +27 -27
- package/dist/components/atoms/SegmentedButton/SegmentedButton.js +49 -49
- package/dist/components/atoms/SelectedValue/SelectedValue.d.ts +11 -11
- package/dist/components/atoms/SelectedValue/SelectedValue.js +29 -29
- package/dist/components/atoms/Slider/Slider.d.ts +52 -52
- package/dist/components/atoms/Slider/Slider.js +30 -30
- package/dist/components/atoms/Spinner/Spinner.d.ts +9 -9
- package/dist/components/atoms/Spinner/Spinner.js +38 -38
- package/dist/components/atoms/Spinner/variants/ButtonSpinner.d.ts +8 -8
- package/dist/components/atoms/Spinner/variants/ButtonSpinner.js +19 -19
- package/dist/components/atoms/Spinner/variants/LoadingSpinner.d.ts +7 -7
- package/dist/components/atoms/Spinner/variants/LoadingSpinner.js +7 -7
- package/dist/components/atoms/Tab/Tab.css +266 -266
- package/dist/components/atoms/Tab/Tab.d.ts +22 -22
- package/dist/components/atoms/Tab/Tab.js +54 -54
- package/dist/components/atoms/Typography/Typography.d.ts +24 -24
- package/dist/components/atoms/Typography/Typography.js +100 -100
- package/dist/components/molecules/Calendar/CalendarInput.d.ts +34 -34
- package/dist/components/molecules/Calendar/CalendarInput.js +49 -49
- package/dist/components/molecules/Calendar/DateTime.d.ts +25 -25
- package/dist/components/molecules/Calendar/DateTime.js +106 -106
- package/dist/components/molecules/Calendar/TimePicker.d.ts +16 -16
- package/dist/components/molecules/Calendar/TimePicker.js +91 -91
- package/dist/components/molecules/LocationDropdown/LocationDropdown.d.ts +34 -34
- package/dist/components/molecules/LocationDropdown/LocationDropdown.js +120 -120
- package/dist/components/molecules/LocationDropdown/index.d.ts +2 -2
- package/dist/components/molecules/LocationDropdown/index.js +1 -1
- package/dist/components/molecules/MultiSelectDropdown/MultiSelectDropdown.d.ts +29 -29
- package/dist/components/molecules/MultiSelectDropdown/MultiSelectDropdown.js +106 -106
- package/dist/components/molecules/RatingTab/RatingTab.d.ts +39 -39
- package/dist/components/molecules/RatingTab/RatingTab.js +41 -41
- package/dist/components/molecules/TabGroup/TabGroup.d.ts +17 -17
- package/dist/components/molecules/TabGroup/TabGroup.js +30 -30
- package/dist/components/molecules/UserCard/UserCard.d.ts +20 -20
- package/dist/components/molecules/UserCard/UserCard.js +57 -57
- package/dist/components/organisms/CardContainer/CardContainer.d.ts +37 -37
- package/dist/components/organisms/CardContainer/CardContainer.js +27 -27
- package/dist/components/organisms/DateTimePicker/DateTimePicker.d.ts +15 -15
- package/dist/components/organisms/DateTimePicker/DateTimePicker.js +66 -66
- package/dist/components/organisms/Dialog/Dialog.d.ts +103 -103
- package/dist/components/organisms/Dialog/Dialog.js +162 -162
- package/dist/components/organisms/Footer/Footer.d.ts +38 -38
- package/dist/components/organisms/Footer/Footer.js +74 -74
- package/dist/components/organisms/PaxSelector/PaxSelector.d.ts +63 -63
- package/dist/components/organisms/PaxSelector/PaxSelector.js +402 -402
- package/dist/components/organisms/RoundTrip/RoundTrip.d.ts +54 -54
- package/dist/components/organisms/RoundTrip/RoundTrip.js +179 -179
- package/dist/components/organisms/RoundTrip/index.d.ts +2 -2
- package/dist/components/organisms/RoundTrip/index.js +1 -1
- package/dist/components/organisms/SearchBarTransfer/SearchBarTransfer.d.ts +35 -35
- package/dist/components/organisms/SearchBarTransfer/SearchBarTransfer.js +192 -192
- package/dist/components/organisms/SearchBarTransfer/index.d.ts +2 -2
- package/dist/components/organisms/SearchBarTransfer/index.js +1 -1
- package/dist/components/organisms/TopNavigation/DesktopNav.d.ts +33 -33
- package/dist/components/organisms/TopNavigation/DesktopNav.js +32 -26
- package/dist/components/organisms/TopNavigation/MobileNav.d.ts +32 -32
- package/dist/components/organisms/TopNavigation/MobileNav.js +45 -45
- package/dist/components/organisms/TopNavigation/TopNavigation.d.ts +33 -33
- package/dist/components/organisms/TopNavigation/TopNavigation.js +20 -20
- package/dist/components/organisms/TransferLine/TransferLine.d.ts +53 -53
- package/dist/components/organisms/TransferLine/TransferLine.js +179 -179
- package/dist/components/ui/button.d.ts +10 -10
- package/dist/components/ui/button.js +56 -56
- package/dist/components/ui/calendar.d.ts +8 -8
- package/dist/components/ui/calendar.js +87 -87
- package/dist/components/ui/popover.d.ts +7 -7
- package/dist/components/ui/popover.js +42 -42
- package/dist/hooks/useMobile.d.ts +5 -5
- package/dist/hooks/useMobile.js +26 -26
- package/dist/index.d.ts +49 -49
- package/dist/index.js +46 -46
- package/dist/lib/utils.d.ts +7 -7
- package/dist/lib/utils.js +13 -13
- package/dist/styles/components/avatar.css +122 -122
- package/dist/styles/components/calendar.css +140 -140
- package/dist/styles/components/checkbox.css +206 -206
- package/dist/styles/components/dropdown.css +269 -269
- package/dist/styles/components/forms.css +209 -209
- package/dist/styles/components/illustration.css +123 -123
- package/dist/styles/components/molecule/calendarInput.css +133 -133
- package/dist/styles/components/molecule/dateTime.css +126 -126
- package/dist/styles/components/molecule/location-dropdown.css +132 -132
- package/dist/styles/components/molecule/timePicker.css +122 -122
- package/dist/styles/components/multiselect-dropdown.css +286 -286
- package/dist/styles/components/organism/card-container.css +148 -148
- package/dist/styles/components/organism/dialog.css +168 -168
- package/dist/styles/components/organism/footer.css +119 -119
- package/dist/styles/components/organism/pax-selector.css +617 -617
- package/dist/styles/components/organism/round-trip.css +139 -139
- package/dist/styles/components/organism/search-bar-transfer.css +158 -161
- package/dist/styles/components/organism/topnavigation.css +143 -143
- package/dist/styles/components/organism/transfer-line.css +138 -138
- package/dist/styles/components/rating-star.css +145 -145
- package/dist/styles/components/rating-tab.css +179 -179
- package/dist/styles/components/scrollbar.css +155 -155
- package/dist/styles/components/segmented-button.css +214 -214
- package/dist/styles/components/selected-value.css +175 -175
- package/dist/styles/components/slider.css +182 -182
- package/dist/styles/components/typography.css +245 -245
- package/dist/styles/tokens/tokens.css +119 -119
- package/dist/styles/tokens/tokens.d.ts +3108 -3108
- package/dist/styles/tokens/tokens.js +2652 -2652
- package/package.json +103 -103
- package/src/components/atoms/Avatar/Avatar.tsx +60 -60
- package/src/components/atoms/Button/Button.css +200 -200
- package/src/components/atoms/Button/Button.tsx +82 -82
- package/src/components/atoms/Checkbox/Checkbox.tsx +83 -83
- package/src/components/atoms/Icon/Icon.tsx +163 -163
- package/src/components/atoms/Icon/icons/ArrivalIcon.tsx +52 -52
- package/src/components/atoms/Icon/icons/BuildingIcon.tsx +50 -50
- package/src/components/atoms/Icon/icons/CalendarIcon.tsx +63 -63
- package/src/components/atoms/Icon/icons/CalendarOutlineIcon.tsx +50 -50
- package/src/components/atoms/Icon/icons/CarIcon.tsx +44 -44
- package/src/components/atoms/Icon/icons/Check.tsx +36 -36
- package/src/components/atoms/Icon/icons/CheckCircleIcon.tsx +48 -48
- package/src/components/atoms/Icon/icons/Chevron.tsx +73 -73
- package/src/components/atoms/Icon/icons/ChevronDownIcon.tsx +46 -46
- package/src/components/atoms/Icon/icons/Close.tsx +39 -39
- package/src/components/atoms/Icon/icons/DeleteIcon.tsx +44 -44
- package/src/components/atoms/Icon/icons/DepartureIcon.tsx +50 -50
- package/src/components/atoms/Icon/icons/EyeIcon.tsx +44 -44
- package/src/components/atoms/Icon/icons/FacebookIcon.tsx +50 -50
- package/src/components/atoms/Icon/icons/HomeIcon.tsx +52 -52
- package/src/components/atoms/Icon/icons/InfoIcon.tsx +44 -44
- package/src/components/atoms/Icon/icons/LinkedInIcon.tsx +50 -50
- package/src/components/atoms/Icon/icons/MapPinIcon.tsx +44 -44
- package/src/components/atoms/Icon/icons/MautoucoLogo.tsx +93 -93
- package/src/components/atoms/Icon/icons/MenuIcon.tsx +49 -49
- package/src/components/atoms/Icon/icons/MinusIcon.tsx +45 -45
- package/src/components/atoms/Icon/icons/MoreIcon.tsx +44 -44
- package/src/components/atoms/Icon/icons/PlaneIcon.tsx +50 -50
- package/src/components/atoms/Icon/icons/PlusIcon.tsx +45 -45
- package/src/components/atoms/Icon/icons/Search.tsx +37 -37
- package/src/components/atoms/Icon/icons/Settings.tsx +38 -38
- package/src/components/atoms/Icon/icons/ShipIcon.tsx +50 -50
- package/src/components/atoms/Icon/icons/StrollerIcon.tsx +44 -44
- package/src/components/atoms/Icon/icons/TwitterIcon.tsx +50 -50
- package/src/components/atoms/Icon/icons/User.tsx +37 -37
- package/src/components/atoms/Icon/icons/UserIcon.tsx +63 -63
- package/src/components/atoms/Icon/icons/Youtube.tsx +50 -50
- package/src/components/atoms/Illustration/Illustration.tsx +28 -28
- package/src/components/atoms/Illustration/illustrations.ts +116 -116
- package/src/components/atoms/Inputs/DropdownInput/DropdownInput.tsx +96 -96
- package/src/components/atoms/Inputs/Textarea/Textarea.tsx +51 -51
- package/src/components/atoms/Link/Link.tsx +168 -168
- package/src/components/atoms/RatingStar/RatingStar.tsx +114 -114
- package/src/components/atoms/SegmentedButton/SegmentedButton.tsx +94 -94
- package/src/components/atoms/SelectedValue/SelectedValue.tsx +59 -59
- package/src/components/atoms/Slider/Slider.tsx +95 -95
- package/src/components/atoms/Spinner/Spinner.tsx +56 -56
- package/src/components/atoms/Spinner/variants/ButtonSpinner.tsx +37 -37
- package/src/components/atoms/Spinner/variants/LoadingSpinner.tsx +22 -22
- package/src/components/atoms/Tab/Tab.css +147 -147
- package/src/components/atoms/Tab/Tab.tsx +96 -96
- package/src/components/atoms/Typography/Typography.tsx +153 -153
- package/src/components/molecules/Calendar/CalendarInput.tsx +135 -135
- package/src/components/molecules/Calendar/DateTime.tsx +172 -172
- package/src/components/molecules/Calendar/TimePicker.tsx +174 -174
- package/src/components/molecules/LocationDropdown/LocationDropdown.tsx +234 -234
- package/src/components/molecules/LocationDropdown/index.ts +2 -2
- package/src/components/molecules/RatingTab/RatingTab.tsx +96 -96
- package/src/components/molecules/TabGroup/TabGroup.tsx +60 -60
- package/src/components/molecules/UserCard/UserCard.stories.tsx +36 -36
- package/src/components/molecules/UserCard/UserCard.tsx +173 -173
- package/src/components/organisms/CardContainer/CardContainer.tsx +66 -66
- package/src/components/organisms/DateTimePicker/DateTimePicker.tsx +110 -110
- package/src/components/organisms/Dialog/Dialog.tsx +352 -352
- package/src/components/organisms/Footer/Footer.tsx +290 -290
- package/src/components/organisms/PaxSelector/PaxSelector.tsx +979 -979
- package/src/components/organisms/RoundTrip/RoundTrip.tsx +335 -335
- package/src/components/organisms/RoundTrip/index.ts +2 -2
- package/src/components/organisms/SearchBarTransfer/SearchBarTransfer.tsx +388 -388
- package/src/components/organisms/SearchBarTransfer/index.ts +2 -2
- package/src/components/organisms/TopNavigation/DesktopNav.tsx +133 -122
- package/src/components/organisms/TopNavigation/MobileNav.tsx +212 -212
- package/src/components/organisms/TopNavigation/TopNavigation.tsx +45 -45
- package/src/components/organisms/TransferLine/TransferLine.tsx +369 -369
- package/src/components/ui/button.tsx +60 -60
- package/src/components/ui/calendar.tsx +246 -246
- package/src/components/ui/popover.tsx +46 -46
- package/src/styles/components/avatar.css +58 -58
- package/src/styles/components/calendar.css +85 -85
- package/src/styles/components/checkbox.css +130 -130
- package/src/styles/components/dropdown.css +214 -214
- package/src/styles/components/forms.css +147 -147
- package/src/styles/components/illustration.css +7 -7
- package/src/styles/components/molecule/calendarInput.css +156 -156
- package/src/styles/components/molecule/dateTime.css +14 -14
- package/src/styles/components/molecule/location-dropdown.css +204 -204
- package/src/styles/components/molecule/timePicker.css +78 -78
- package/src/styles/components/multiselect-dropdown.css +230 -230
- package/src/styles/components/organism/card-container.css +49 -49
- package/src/styles/components/organism/dialog.css +241 -241
- package/src/styles/components/organism/footer.css +113 -113
- package/src/styles/components/organism/pax-selector.css +702 -702
- package/src/styles/components/organism/round-trip.css +55 -55
- package/src/styles/components/organism/search-bar-transfer.css +128 -127
- package/src/styles/components/organism/topnavigation.css +161 -161
- package/src/styles/components/organism/transfer-line.css +86 -86
- package/src/styles/components/rating-star.css +39 -39
- package/src/styles/components/rating-tab.css +83 -83
- package/src/styles/components/scrollbar.css +63 -63
- package/src/styles/components/segmented-button.css +134 -134
- package/src/styles/components/selected-value.css +80 -80
- package/src/styles/components/slider.css +86 -86
- package/src/styles/components/typography.css +251 -251
- package/src/styles/fonts.css +50 -0
- package/src/styles/tokens/tokens.css +119 -119
- package/src/styles/tokens/tokens.js +12 -6
|
@@ -1,402 +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;
|
|
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;
|