mautourco-components 0.2.118 → 0.2.120
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/dist/components/molecules/AgeSelector/AgeSelector.d.ts +1 -1
- package/dist/components/molecules/AgeSelector/AgeSelector.js +1 -1
- package/dist/components/organisms/PaxSelector/ClientTypeSelector.d.ts +7 -0
- package/dist/components/organisms/PaxSelector/ClientTypeSelector.js +29 -0
- package/dist/components/organisms/PaxSelector/PaxSelector.d.ts +4 -1
- package/dist/components/organisms/PaxSelector/PaxSelector.js +24 -145
- package/dist/components/organisms/PaxSelector/RoomEditor.d.ts +17 -0
- package/dist/components/organisms/PaxSelector/RoomEditor.js +130 -0
- package/dist/components/organisms/PaxSelector/StepperRow.d.ts +9 -0
- package/dist/components/organisms/PaxSelector/StepperRow.js +18 -0
- package/dist/components/organisms/RoundTrip/RoundTrip.js +13 -8
- package/dist/components/organisms/SearchBarTransfer/SearchBarTransfer.js +3 -5
- package/dist/components/organisms/TransferLine/TransferLine.js +4 -1
- package/dist/hooks/useTransferAge.d.ts +5 -0
- package/dist/hooks/useTransferAge.js +26 -0
- package/dist/index.d.ts +2 -1
- package/package.json +1 -1
- package/src/components/molecules/AgeSelector/AgeSelector.tsx +2 -2
- package/src/components/organisms/PaxSelector/ClientTypeSelector.tsx +83 -0
- package/src/components/organisms/PaxSelector/PaxSelector.tsx +33 -422
- package/src/components/organisms/PaxSelector/RoomEditor.tsx +290 -0
- package/src/components/organisms/PaxSelector/StepperRow.tsx +63 -0
- package/src/components/organisms/RoundTrip/RoundTrip.tsx +16 -10
- package/src/components/organisms/SearchBarTransfer/SearchBarTransfer.tsx +4 -7
- package/src/components/organisms/TransferLine/TransferLine.tsx +5 -3
|
@@ -19,6 +19,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
19
19
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
20
20
|
};
|
|
21
21
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
22
|
+
import useTransferAge from '../../../hooks/useTransferAge';
|
|
22
23
|
import React, { useState } from 'react';
|
|
23
24
|
import '../../../styles/components/organism/transfer-line.css';
|
|
24
25
|
import Icon from '../../atoms/Icon/Icon';
|
|
@@ -32,6 +33,7 @@ var TransferLine = function (_a) {
|
|
|
32
33
|
var _k = useState(transferDate), internalTransferDate = _k[0], setInternalTransferDate = _k[1];
|
|
33
34
|
var _l = useState(null), internalPickupPoint = _l[0], setInternalPickupPoint = _l[1];
|
|
34
35
|
var _m = useState(null), internalDropoffPoint = _m[0], setInternalDropoffPoint = _m[1];
|
|
36
|
+
var _o = useTransferAge(internalPaxData), setIsInvalidPax = _o.setIsInvalidPax, areAllAgesValid = _o.areAllAgesValid;
|
|
35
37
|
// Helper function to get all locations (from options and groups)
|
|
36
38
|
var getAllLocations = function (options, groups) {
|
|
37
39
|
var groupOptions = groups.flatMap(function (group) { return group.options; });
|
|
@@ -229,6 +231,7 @@ var TransferLine = function (_a) {
|
|
|
229
231
|
// Check if inputs are empty (when checkEmpty is true)
|
|
230
232
|
var isPaxEmpty = checkEmpty &&
|
|
231
233
|
(!internalPaxData ||
|
|
234
|
+
areAllAgesValid ||
|
|
232
235
|
(internalPaxData.adults === 0 &&
|
|
233
236
|
internalPaxData.teens === 0 &&
|
|
234
237
|
internalPaxData.children === 0 &&
|
|
@@ -251,7 +254,7 @@ var TransferLine = function (_a) {
|
|
|
251
254
|
};
|
|
252
255
|
var defaultPickupOption = findLocationOption(pickupPoint, 'pickup');
|
|
253
256
|
var defaultDropoffOption = findLocationOption(dropoffPoint, 'dropoff');
|
|
254
|
-
return (_jsxs("div", { className: "transfer-line transfer-line--".concat(type, " ").concat(disabled ? 'transfer-line--disabled' : '', " ").concat(className), "data-transfer-id": id, children: [showTitle && (_jsxs("div", { className: "transfer-line__header", children: [_jsx(Icon, { name: getTypeIcon(), size: "sm", className: "transfer-line__header-icon" }), _jsx(Text, { size: "sm", variant: "medium", className: "transfer-line__header-label", children: getTypeLabel() })] })), _jsxs("div", { className: "transfer-line__content-container", children: [_jsxs("div", { className: "transfer-line__content", children: [_jsx("div", { className: "transfer-line__field transfer-line__field--pax ".concat(isPaxEmpty ? 'transfer-line__field--error' : ''), children: _jsx(PaxSelector, { label: "Number of pax", value: internalPaxData, onChange: handlePaxChange, placeholder: "2 pax", className: isPaxEmpty ? 'pax-selector--error' : '', disabled: disabled, scrollOnOpen: scrollOnOpen, checkEmpty: checkEmpty, onPaxOpenChange: onPaxOpenChange }) }), _jsxs("div", { className: "transfer-line__field transfer-line__field--date", children: [_jsx(Text, { size: "sm", variant: "regular", className: "transfer-line__field-label", children: "Transfer date" }), _jsx(DateTimePicker, { placeholder: "DD/MM/YYYY", mode: "calendar", iconPosition: "left", numberOfMonths: 1, iconBGFull: false, showChevron: true, onValueChange: handleDateChange, selectionMode: "single", defaultValue: internalTransferDate, inputClassName: "transfer-line__date-picker", state: isDateEmpty ? 'error' : undefined, disabled: disabled, scrollOnOpen: scrollOnOpen })] }), _jsx("div", { className: "transfer-line__field transfer-line__field--pickup", children: _jsx(LocationDropdown, { label: "Pick-up point", options: filterLocations('pickup').options, groups: filterLocations('pickup').groups, selectedValue: (internalPickupPoint === null || internalPickupPoint === void 0 ? void 0 : internalPickupPoint.id) || null, onSelectionChange: handlePickupChange, placeholder: "Select a pick-up point", direction: "pickup", type: type === 'inter-hotel'
|
|
257
|
+
return (_jsxs("div", { className: "transfer-line transfer-line--".concat(type, " ").concat(disabled ? 'transfer-line--disabled' : '', " ").concat(className), "data-transfer-id": id, children: [showTitle && (_jsxs("div", { className: "transfer-line__header", children: [_jsx(Icon, { name: getTypeIcon(), size: "sm", className: "transfer-line__header-icon" }), _jsx(Text, { size: "sm", variant: "medium", className: "transfer-line__header-label", children: getTypeLabel() })] })), _jsxs("div", { className: "transfer-line__content-container", children: [_jsxs("div", { className: "transfer-line__content", children: [_jsx("div", { className: "transfer-line__field transfer-line__field--pax ".concat(isPaxEmpty ? 'transfer-line__field--error' : ''), children: _jsx(PaxSelector, { label: "Number of pax", value: internalPaxData, onChange: handlePaxChange, placeholder: "2 pax", className: isPaxEmpty ? 'pax-selector--error' : '', disabled: disabled, scrollOnOpen: scrollOnOpen, checkEmpty: checkEmpty, onPaxOpenChange: onPaxOpenChange, onPaxInvalid: function (isInvalid) { return setIsInvalidPax(isInvalid); } }) }), _jsxs("div", { className: "transfer-line__field transfer-line__field--date", children: [_jsx(Text, { size: "sm", variant: "regular", className: "transfer-line__field-label", children: "Transfer date" }), _jsx(DateTimePicker, { placeholder: "DD/MM/YYYY", mode: "calendar", iconPosition: "left", numberOfMonths: 1, iconBGFull: false, showChevron: true, onValueChange: handleDateChange, selectionMode: "single", defaultValue: internalTransferDate, inputClassName: "transfer-line__date-picker", state: isDateEmpty ? 'error' : undefined, disabled: disabled, scrollOnOpen: scrollOnOpen })] }), _jsx("div", { className: "transfer-line__field transfer-line__field--pickup", children: _jsx(LocationDropdown, { label: "Pick-up point", options: filterLocations('pickup').options, groups: filterLocations('pickup').groups, selectedValue: (internalPickupPoint === null || internalPickupPoint === void 0 ? void 0 : internalPickupPoint.id) || null, onSelectionChange: handlePickupChange, placeholder: "Select a pick-up point", direction: "pickup", type: type === 'inter-hotel'
|
|
255
258
|
? 'accommodation'
|
|
256
259
|
: type === 'arrival'
|
|
257
260
|
? 'airport-port'
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
export default function useTransferAge(internalPaxData) {
|
|
3
|
+
var _a = useState(false), isInvalidPax = _a[0], setIsInvalidPax = _a[1];
|
|
4
|
+
var checkAgeIsValid = function (key) {
|
|
5
|
+
if (internalPaxData && Array.isArray(internalPaxData[key])) {
|
|
6
|
+
var age = internalPaxData[key];
|
|
7
|
+
return age.some(function (age) { return !age; });
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
var checkAllAgesAreValid = function () {
|
|
11
|
+
var _a, _b, _c;
|
|
12
|
+
if ((_a = internalPaxData === null || internalPaxData === void 0 ? void 0 : internalPaxData.teenAges) === null || _a === void 0 ? void 0 : _a.length) {
|
|
13
|
+
return checkAgeIsValid('teenAges');
|
|
14
|
+
}
|
|
15
|
+
if ((_b = internalPaxData === null || internalPaxData === void 0 ? void 0 : internalPaxData.childAges) === null || _b === void 0 ? void 0 : _b.length) {
|
|
16
|
+
return checkAgeIsValid('childAges');
|
|
17
|
+
}
|
|
18
|
+
if ((_c = internalPaxData === null || internalPaxData === void 0 ? void 0 : internalPaxData.infantAges) === null || _c === void 0 ? void 0 : _c.length) {
|
|
19
|
+
return checkAgeIsValid('infantAges');
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
return {
|
|
23
|
+
setIsInvalidPax: setIsInvalidPax,
|
|
24
|
+
areAllAgesValid: checkAllAgesAreValid() || isInvalidPax,
|
|
25
|
+
};
|
|
26
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -98,8 +98,9 @@ export type { DateTimePickerProps } from './components/organisms/DateTimePicker/
|
|
|
98
98
|
export type { DialogProps, DialogSize } from './components/organisms/Dialog/Dialog';
|
|
99
99
|
export type { FooterProps } from './components/organisms/Footer/Footer';
|
|
100
100
|
export type { DocketDetailsData, DocketServiceType, MultipleQuotationDocketProps, } from './components/organisms/MultipleQuotationDocket';
|
|
101
|
+
export type { ClientType } from './components/organisms/PaxSelector/ClientTypeSelector';
|
|
101
102
|
export { CHILD_CATEGORY_AGES } from './components/organisms/PaxSelector/PaxSelector';
|
|
102
|
-
export type {
|
|
103
|
+
export type { PaxData, PaxSelectorProps, } from './components/organisms/PaxSelector/PaxSelector';
|
|
103
104
|
export type { RoundTripData, RoundTripProps, RoundTripTransfer, } from './components/organisms/RoundTrip/RoundTrip';
|
|
104
105
|
export type { SearchBarTransferData, SearchBarTransferProps, TransferMode, } from './components/organisms/SearchBarTransfer/SearchBarTransfer';
|
|
105
106
|
export type { TopNavigationProps } from './components/organisms/TopNavigation/TopNavigation';
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@ export interface AgeSelectorProps {
|
|
|
9
9
|
/** Current selected age value */
|
|
10
10
|
value: number | undefined;
|
|
11
11
|
/** Callback when age changes */
|
|
12
|
-
onChange: (age: number) => void;
|
|
12
|
+
onChange: (age: number | undefined) => void;
|
|
13
13
|
/** Available age range */
|
|
14
14
|
ageRange: number[];
|
|
15
15
|
/** Whether the field is required */
|
|
@@ -71,7 +71,7 @@ const AgeSelector: React.FC<AgeSelectorProps> = ({
|
|
|
71
71
|
const numValue = parseInt(newValue, 10);
|
|
72
72
|
if (newValue === '') {
|
|
73
73
|
// Allow empty input - don't update onChange
|
|
74
|
-
return;
|
|
74
|
+
return onChange(undefined);
|
|
75
75
|
} else if (!isNaN(numValue) && ageRange.includes(numValue)) {
|
|
76
76
|
onChange(numValue);
|
|
77
77
|
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import Icon from '../../atoms/Icon/Icon';
|
|
3
|
+
import { Text } from '../../atoms/Typography/Typography';
|
|
4
|
+
|
|
5
|
+
export type ClientType = 'Standard client' | 'VIP' | 'VVIP' | 'Honeymooners';
|
|
6
|
+
|
|
7
|
+
interface ClientTypeSelectorProps {
|
|
8
|
+
value: ClientType;
|
|
9
|
+
onChange: (value: ClientType) => void;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const CLIENT_TYPES: ClientType[] = ['Standard client', 'VIP', 'VVIP', 'Honeymooners'];
|
|
13
|
+
|
|
14
|
+
const ClientTypeSelector: React.FC<ClientTypeSelectorProps> = ({ value, onChange }) => {
|
|
15
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
16
|
+
const containerRef = useRef<HTMLDivElement>(null);
|
|
17
|
+
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
const handleClickOutside = (event: MouseEvent) => {
|
|
20
|
+
if (containerRef.current && !containerRef.current.contains(event.target as Node)) {
|
|
21
|
+
setIsOpen(false);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
if (isOpen) {
|
|
26
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return () => {
|
|
30
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
31
|
+
};
|
|
32
|
+
}, [isOpen]);
|
|
33
|
+
|
|
34
|
+
const handleSelect = (type: ClientType) => {
|
|
35
|
+
onChange(type);
|
|
36
|
+
setIsOpen(false);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<div className="pax-selector__client-type">
|
|
41
|
+
<Text size="sm" variant="regular" className="pax-selector__client-type-label">
|
|
42
|
+
Client type
|
|
43
|
+
</Text>
|
|
44
|
+
<div className="pax-selector__client-type-select" ref={containerRef}>
|
|
45
|
+
<button
|
|
46
|
+
type="button"
|
|
47
|
+
className="pax-selector__client-type-trigger"
|
|
48
|
+
onClick={() => setIsOpen(!isOpen)}
|
|
49
|
+
aria-expanded={isOpen}
|
|
50
|
+
aria-haspopup="listbox">
|
|
51
|
+
<div className="pax-selector__client-type-content">
|
|
52
|
+
<Icon name="user-icon" size="sm" className="pax-selector__client-type-icon" />
|
|
53
|
+
<span className="pax-selector__client-type-text">{value}</span>
|
|
54
|
+
</div>
|
|
55
|
+
<Icon
|
|
56
|
+
name="chevron-down"
|
|
57
|
+
size="sm"
|
|
58
|
+
className={`pax-selector__client-type-chevron ${isOpen ? 'pax-selector__client-type-chevron--open' : ''}`}
|
|
59
|
+
/>
|
|
60
|
+
</button>
|
|
61
|
+
|
|
62
|
+
{isOpen && (
|
|
63
|
+
<div className="pax-selector__client-type-dropdown" role="listbox">
|
|
64
|
+
{CLIENT_TYPES.map((type) => (
|
|
65
|
+
<button
|
|
66
|
+
key={type}
|
|
67
|
+
type="button"
|
|
68
|
+
className={`pax-selector__client-type-option ${value === type ? 'pax-selector__client-type-option--selected' : ''}`}
|
|
69
|
+
onClick={() => handleSelect(type)}
|
|
70
|
+
role="option"
|
|
71
|
+
aria-selected={value === type}>
|
|
72
|
+
<Icon name="user-icon" size="sm" />
|
|
73
|
+
{type}
|
|
74
|
+
</button>
|
|
75
|
+
))}
|
|
76
|
+
</div>
|
|
77
|
+
)}
|
|
78
|
+
</div>
|
|
79
|
+
</div>
|
|
80
|
+
);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export default ClientTypeSelector;
|