mautourco-components 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/atoms/Checkbox/Checkbox.js +7 -1
- package/dist/components/atoms/Icon/Icon.d.ts +1 -1
- package/dist/components/atoms/Icon/Icon.js +22 -1
- package/dist/components/atoms/Icon/icons/BuildingIcon.d.ts +8 -0
- package/dist/components/atoms/Icon/icons/BuildingIcon.js +36 -0
- package/dist/components/atoms/Icon/icons/CalendarOutlineIcon.d.ts +8 -0
- package/dist/components/atoms/Icon/icons/CalendarOutlineIcon.js +36 -0
- package/dist/components/atoms/Icon/icons/HomeIcon.d.ts +8 -0
- package/dist/components/atoms/Icon/icons/HomeIcon.js +25 -0
- package/dist/components/atoms/Icon/icons/MinusIcon.d.ts +8 -0
- package/dist/components/atoms/Icon/icons/MinusIcon.js +25 -0
- package/dist/components/atoms/Icon/icons/PlaneIcon.d.ts +8 -0
- package/dist/components/atoms/Icon/icons/PlaneIcon.js +36 -0
- package/dist/components/atoms/Icon/icons/PlusIcon.d.ts +8 -0
- package/dist/components/atoms/Icon/icons/PlusIcon.js +25 -0
- package/dist/components/atoms/Icon/icons/ShipIcon.d.ts +8 -0
- package/dist/components/atoms/Icon/icons/ShipIcon.js +36 -0
- package/dist/components/atoms/Illustration/Illustration.d.ts +14 -0
- package/dist/components/atoms/Illustration/Illustration.js +33 -0
- package/dist/components/atoms/Illustration/illustrations.d.ts +51 -0
- package/dist/components/atoms/Illustration/illustrations.js +97 -0
- package/dist/components/atoms/RatingStar/RatingStar.d.ts +40 -0
- package/dist/components/atoms/RatingStar/RatingStar.js +54 -0
- package/dist/components/atoms/SegmentedButton/SegmentedButton.d.ts +27 -0
- package/dist/components/atoms/SegmentedButton/SegmentedButton.js +49 -0
- package/dist/components/atoms/Slider/Slider.d.ts +52 -0
- package/dist/components/atoms/Slider/Slider.js +30 -0
- package/dist/components/molecules/Calendar/CalendarInput.d.ts +34 -0
- package/dist/components/molecules/Calendar/CalendarInput.js +49 -0
- package/dist/components/molecules/Calendar/DateTime.d.ts +25 -0
- package/dist/components/molecules/Calendar/DateTime.js +106 -0
- package/dist/components/molecules/Calendar/TimePicker.d.ts +16 -0
- package/dist/components/molecules/Calendar/TimePicker.js +91 -0
- package/dist/components/molecules/LocationDropdown/LocationDropdown.d.ts +34 -0
- package/dist/components/molecules/LocationDropdown/LocationDropdown.js +120 -0
- package/dist/components/molecules/LocationDropdown/index.d.ts +2 -0
- package/dist/components/molecules/LocationDropdown/index.js +1 -0
- package/dist/components/molecules/RatingTab/RatingTab.d.ts +39 -0
- package/dist/components/molecules/RatingTab/RatingTab.js +41 -0
- package/dist/components/molecules/TabGroup/TabGroup.d.ts +17 -0
- package/dist/components/molecules/TabGroup/TabGroup.js +30 -0
- package/dist/components/organisms/CardContainer/CardContainer.d.ts +37 -0
- package/dist/components/organisms/CardContainer/CardContainer.js +27 -0
- package/dist/components/organisms/DateTimePicker/DateTimePicker.d.ts +15 -0
- package/dist/components/organisms/DateTimePicker/DateTimePicker.js +66 -0
- package/dist/components/organisms/Dialog/Dialog.d.ts +103 -0
- package/dist/components/organisms/Dialog/Dialog.js +162 -0
- package/dist/components/organisms/PaxSelector/PaxSelector.d.ts +63 -0
- package/dist/components/organisms/PaxSelector/PaxSelector.js +402 -0
- package/dist/components/organisms/RoundTrip/RoundTrip.d.ts +54 -0
- package/dist/components/organisms/RoundTrip/RoundTrip.js +179 -0
- package/dist/components/organisms/RoundTrip/index.d.ts +2 -0
- package/dist/components/organisms/RoundTrip/index.js +1 -0
- package/dist/components/organisms/SearchBarTransfer/SearchBarTransfer.d.ts +35 -0
- package/dist/components/organisms/SearchBarTransfer/SearchBarTransfer.js +192 -0
- package/dist/components/organisms/SearchBarTransfer/index.d.ts +2 -0
- package/dist/components/organisms/SearchBarTransfer/index.js +1 -0
- package/dist/components/organisms/TransferLine/TransferLine.d.ts +53 -0
- package/dist/components/organisms/TransferLine/TransferLine.js +179 -0
- package/dist/components/ui/button.d.ts +10 -0
- package/dist/components/ui/button.js +56 -0
- package/dist/components/ui/calendar.d.ts +8 -0
- package/dist/components/ui/calendar.js +87 -0
- package/dist/components/ui/popover.d.ts +7 -0
- package/dist/components/ui/popover.js +42 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +18 -0
- package/dist/lib/utils.d.ts +7 -0
- package/dist/lib/utils.js +13 -0
- package/package.json +21 -12
- package/src/components/atoms/Button/Button.css +34 -34
- package/src/components/atoms/Checkbox/Checkbox.tsx +83 -69
- package/src/components/atoms/Icon/Icon.tsx +30 -2
- package/src/components/atoms/Icon/icons/BuildingIcon.tsx +50 -0
- package/src/components/atoms/Icon/icons/CalendarOutlineIcon.tsx +50 -0
- package/src/components/atoms/Icon/icons/HomeIcon.tsx +52 -0
- package/src/components/atoms/Icon/icons/MinusIcon.tsx +45 -0
- package/src/components/atoms/Icon/icons/PlaneIcon.tsx +50 -0
- package/src/components/atoms/Icon/icons/PlusIcon.tsx +45 -0
- package/src/components/atoms/Icon/icons/ShipIcon.tsx +50 -0
- package/src/components/atoms/Illustration/Illustration.tsx +28 -0
- package/src/components/atoms/Illustration/illustrations.ts +116 -0
- package/src/components/atoms/RatingStar/RatingStar.tsx +114 -0
- package/src/components/atoms/SegmentedButton/SegmentedButton.tsx +94 -0
- package/src/components/atoms/Slider/Slider.tsx +95 -0
- package/src/components/molecules/Calendar/CalendarInput.tsx +135 -0
- package/src/components/molecules/Calendar/DateTime.tsx +172 -0
- package/src/components/molecules/Calendar/TimePicker.tsx +174 -0
- package/src/components/molecules/LocationDropdown/LocationDropdown.tsx +234 -0
- package/src/components/molecules/LocationDropdown/index.ts +2 -0
- package/src/components/molecules/RatingTab/RatingTab.tsx +96 -0
- package/src/components/molecules/TabGroup/TabGroup.tsx +60 -0
- package/src/components/molecules/UserCard/UserCard.stories.tsx +2 -2
- package/src/components/organisms/CardContainer/CardContainer.tsx +66 -0
- package/src/components/organisms/DateTimePicker/DateTimePicker.tsx +110 -0
- package/src/components/organisms/Dialog/Dialog.tsx +352 -0
- package/src/components/organisms/PaxSelector/PaxSelector.tsx +979 -0
- package/src/components/organisms/RoundTrip/RoundTrip.tsx +335 -0
- package/src/components/organisms/RoundTrip/index.ts +2 -0
- package/src/components/organisms/SearchBarTransfer/SearchBarTransfer.tsx +388 -0
- package/src/components/organisms/SearchBarTransfer/index.ts +2 -0
- package/src/components/organisms/TransferLine/TransferLine.tsx +369 -0
- package/src/components/ui/button.tsx +60 -0
- package/src/components/ui/calendar.tsx +246 -0
- package/src/components/ui/popover.tsx +46 -0
- package/src/styles/components/calendar.css +86 -0
- package/src/styles/components/checkbox.css +130 -132
- package/src/styles/components/dropdown.css +40 -40
- package/src/styles/components/forms.css +51 -51
- package/src/styles/components/illustration.css +7 -0
- package/src/styles/components/molecule/calendarInput.css +157 -0
- package/src/styles/components/molecule/dateTime.css +14 -0
- package/src/styles/components/molecule/location-dropdown.css +204 -0
- package/src/styles/components/molecule/timePicker.css +79 -0
- package/src/styles/components/multiselect-dropdown.css +230 -231
- package/src/styles/components/organism/card-container.css +49 -0
- package/src/styles/components/organism/dialog.css +241 -0
- package/src/styles/components/organism/pax-selector.css +702 -0
- package/src/styles/components/organism/round-trip.css +55 -0
- package/src/styles/components/organism/search-bar-transfer.css +128 -0
- package/src/styles/components/organism/transfer-line.css +86 -0
- package/src/styles/components/rating-star.css +39 -0
- package/src/styles/components/rating-tab.css +83 -0
- package/src/styles/components/segmented-button.css +134 -0
- package/src/styles/components/selected-value.css +16 -16
- package/src/styles/components/slider.css +86 -0
- package/src/styles/components/typography.css +36 -36
- package/src/styles/tokens/tokens.css +1093 -1093
- package/dist/components/atoms/Typography/Heading/Heading.d.ts +0 -9
- package/dist/components/atoms/Typography/Heading/Heading.js +0 -25
- package/dist/components/atoms/Typography/Text/Text.d.ts +0 -10
- package/dist/components/atoms/Typography/Text/Text.js +0 -77
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
/**
|
|
14
|
+
* Star Rating atom
|
|
15
|
+
*
|
|
16
|
+
* Displays a row of stars from 0 to `max` (default: 5),
|
|
17
|
+
* using tokens from Components/rating-star.
|
|
18
|
+
* Can be used in read-only mode or interactive mode.
|
|
19
|
+
*/
|
|
20
|
+
export var RatingStar = function (_a) {
|
|
21
|
+
var value = _a.value, _b = _a.max, max = _b === void 0 ? 5 : _b, _c = _a.interactive, interactive = _c === void 0 ? false : _c, onChange = _a.onChange, _d = _a.disabled, disabled = _d === void 0 ? false : _d, _e = _a.className, className = _e === void 0 ? '' : _e, ariaLabel = _a["aria-label"];
|
|
22
|
+
var handleClick = function (index) {
|
|
23
|
+
if (!interactive || disabled || !onChange)
|
|
24
|
+
return;
|
|
25
|
+
onChange(index + 1);
|
|
26
|
+
};
|
|
27
|
+
var handleKeyDown = function (event) {
|
|
28
|
+
if (!interactive || disabled || !onChange)
|
|
29
|
+
return;
|
|
30
|
+
if (event.key === 'ArrowRight' || event.key === 'ArrowUp') {
|
|
31
|
+
event.preventDefault();
|
|
32
|
+
onChange(Math.min(max, value + 1));
|
|
33
|
+
}
|
|
34
|
+
if (event.key === 'ArrowLeft' || event.key === 'ArrowDown') {
|
|
35
|
+
event.preventDefault();
|
|
36
|
+
onChange(Math.max(0, value - 1));
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
var stars = Array.from({ length: max }, function (_, index) {
|
|
40
|
+
var isSelected = index < value;
|
|
41
|
+
var starClass = [
|
|
42
|
+
'rating-star__icon',
|
|
43
|
+
isSelected ? 'rating-star__icon--selected' : 'rating-star__icon--default',
|
|
44
|
+
]
|
|
45
|
+
.filter(Boolean)
|
|
46
|
+
.join(' ');
|
|
47
|
+
return (_jsx("button", __assign({ type: "button", className: "rating-star__button", onClick: function () { return handleClick(index); }, disabled: disabled || !interactive, "aria-hidden": !interactive, tabIndex: interactive ? 0 : -1 }, { children: _jsx("span", __assign({ className: starClass }, { children: "\u2605" })) }), index));
|
|
48
|
+
});
|
|
49
|
+
var containerClasses = ['rating-star', interactive ? 'rating-star--interactive' : '', className]
|
|
50
|
+
.filter(Boolean)
|
|
51
|
+
.join(' ');
|
|
52
|
+
return (_jsx("div", __assign({ className: containerClasses, role: interactive ? 'slider' : 'img', "aria-valuemin": interactive ? 0 : undefined, "aria-valuemax": interactive ? max : undefined, "aria-valuenow": interactive ? value : undefined, "aria-label": ariaLabel, tabIndex: interactive && !disabled ? 0 : -1, onKeyDown: handleKeyDown }, { children: stars })));
|
|
53
|
+
};
|
|
54
|
+
export default RatingStar;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface SegmentedButtonOption {
|
|
3
|
+
/** Valeur de l'option */
|
|
4
|
+
value: string;
|
|
5
|
+
/** Libellé affiché */
|
|
6
|
+
label: string;
|
|
7
|
+
/** État désactivé */
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface SegmentedButtonProps {
|
|
11
|
+
/** Options du bouton segmenté */
|
|
12
|
+
options: SegmentedButtonOption[];
|
|
13
|
+
/** Valeur sélectionnée */
|
|
14
|
+
value: string;
|
|
15
|
+
/** Handler de changement */
|
|
16
|
+
onChange: (value: string) => void;
|
|
17
|
+
/** Orientation du bouton segmenté */
|
|
18
|
+
orientation?: 'horizontal' | 'vertical';
|
|
19
|
+
/** État désactivé pour tout le groupe */
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
/** Classes CSS supplémentaires */
|
|
22
|
+
className?: string;
|
|
23
|
+
/** Nom du groupe pour l'accessibilité */
|
|
24
|
+
name?: string;
|
|
25
|
+
}
|
|
26
|
+
declare const SegmentedButton: React.FC<SegmentedButtonProps>;
|
|
27
|
+
export default SegmentedButton;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
var SegmentedButton = function (_a) {
|
|
14
|
+
var options = _a.options, value = _a.value, onChange = _a.onChange, _b = _a.orientation, orientation = _b === void 0 ? 'horizontal' : _b, _c = _a.disabled, disabled = _c === void 0 ? false : _c, _d = _a.className, className = _d === void 0 ? '' : _d, name = _a.name;
|
|
15
|
+
var containerClasses = [
|
|
16
|
+
'segmented-button',
|
|
17
|
+
"segmented-button--".concat(orientation),
|
|
18
|
+
disabled && 'segmented-button--disabled',
|
|
19
|
+
className,
|
|
20
|
+
]
|
|
21
|
+
.filter(Boolean)
|
|
22
|
+
.join(' ');
|
|
23
|
+
var handleClick = function (optionValue, optionDisabled) {
|
|
24
|
+
if (!disabled && !optionDisabled && optionValue !== value) {
|
|
25
|
+
onChange(optionValue);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
var getButtonClasses = function (option, index) {
|
|
29
|
+
var isSelected = option.value === value;
|
|
30
|
+
var isFirst = index === 0;
|
|
31
|
+
var isLast = index === options.length - 1;
|
|
32
|
+
var isDisabled = disabled || option.disabled;
|
|
33
|
+
return [
|
|
34
|
+
'segmented-button__item',
|
|
35
|
+
isSelected && 'segmented-button__item--selected',
|
|
36
|
+
isFirst && 'segmented-button__item--first',
|
|
37
|
+
isLast && 'segmented-button__item--last',
|
|
38
|
+
isDisabled && 'segmented-button__item--disabled',
|
|
39
|
+
]
|
|
40
|
+
.filter(Boolean)
|
|
41
|
+
.join(' ');
|
|
42
|
+
};
|
|
43
|
+
return (_jsx("div", __assign({ className: containerClasses, role: "group", "aria-label": name }, { children: options.map(function (option, index) {
|
|
44
|
+
var isSelected = option.value === value;
|
|
45
|
+
var isDisabled = disabled || option.disabled;
|
|
46
|
+
return (_jsx("button", __assign({ type: "button", className: getButtonClasses(option, index), onClick: function () { return handleClick(option.value, option.disabled); }, disabled: isDisabled, "aria-pressed": isSelected, "aria-label": option.label }, { children: _jsx("span", __assign({ className: "segmented-button__label" }, { children: option.label })) }), option.value));
|
|
47
|
+
}) })));
|
|
48
|
+
};
|
|
49
|
+
export default SegmentedButton;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export type SliderVariant = 'full' | 'half';
|
|
3
|
+
export interface SliderProps {
|
|
4
|
+
/**
|
|
5
|
+
* Current value of the slider (controlled mode).
|
|
6
|
+
*/
|
|
7
|
+
value: number;
|
|
8
|
+
/**
|
|
9
|
+
* Minimum value.
|
|
10
|
+
*/
|
|
11
|
+
min?: number;
|
|
12
|
+
/**
|
|
13
|
+
* Maximum value.
|
|
14
|
+
*/
|
|
15
|
+
max?: number;
|
|
16
|
+
/**
|
|
17
|
+
* Step between values.
|
|
18
|
+
*/
|
|
19
|
+
step?: number;
|
|
20
|
+
/**
|
|
21
|
+
* Called when the value changes.
|
|
22
|
+
*/
|
|
23
|
+
onChange: (value: number) => void;
|
|
24
|
+
/**
|
|
25
|
+
* Visual variant (from Figma: Type=Full | Type=Half).
|
|
26
|
+
*/
|
|
27
|
+
variant?: SliderVariant;
|
|
28
|
+
/**
|
|
29
|
+
* Whether the slider is disabled.
|
|
30
|
+
*/
|
|
31
|
+
disabled?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Accessible label (aria-label) if no visible label is provided.
|
|
34
|
+
*/
|
|
35
|
+
'aria-label'?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Optional id to link with an external label.
|
|
38
|
+
*/
|
|
39
|
+
id?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Additional CSS classes.
|
|
42
|
+
*/
|
|
43
|
+
className?: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Slider atom.
|
|
47
|
+
*
|
|
48
|
+
* Represents a single horizontal slider control (rail + thumb),
|
|
49
|
+
* matching the Figma Slider component (Full / Half variants).
|
|
50
|
+
*/
|
|
51
|
+
export declare const Slider: React.FC<SliderProps>;
|
|
52
|
+
export default Slider;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
/**
|
|
14
|
+
* Slider atom.
|
|
15
|
+
*
|
|
16
|
+
* Represents a single horizontal slider control (rail + thumb),
|
|
17
|
+
* matching the Figma Slider component (Full / Half variants).
|
|
18
|
+
*/
|
|
19
|
+
export var Slider = function (_a) {
|
|
20
|
+
var value = _a.value, _b = _a.min, min = _b === void 0 ? 0 : _b, _c = _a.max, max = _c === void 0 ? 100 : _c, _d = _a.step, step = _d === void 0 ? 1 : _d, onChange = _a.onChange, _e = _a.variant, variant = _e === void 0 ? 'full' : _e, _f = _a.disabled, disabled = _f === void 0 ? false : _f, id = _a.id, _g = _a.className, className = _g === void 0 ? '' : _g, ariaLabel = _a["aria-label"];
|
|
21
|
+
var handleChange = function (event) {
|
|
22
|
+
var next = Number(event.target.value);
|
|
23
|
+
onChange(next);
|
|
24
|
+
};
|
|
25
|
+
var classes = ['slider', "slider--".concat(variant), disabled ? 'slider--disabled' : '', className]
|
|
26
|
+
.filter(Boolean)
|
|
27
|
+
.join(' ');
|
|
28
|
+
return (_jsx("div", __assign({ className: "slider-container" }, { children: _jsx("input", { id: id, type: "range", className: classes, min: min, max: max, step: step, value: value, onChange: handleChange, disabled: disabled, "aria-label": ariaLabel }) })));
|
|
29
|
+
};
|
|
30
|
+
export default Slider;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface CalendarInputProps {
|
|
3
|
+
/** Placeholder text */
|
|
4
|
+
placeholder?: string;
|
|
5
|
+
/** Selected date value (formatted as string) */
|
|
6
|
+
value?: string;
|
|
7
|
+
/** State of the input: default, active, typing, disabled, success, error */
|
|
8
|
+
state?: "default" | "active" | "typing" | "disabled" | "success" | "error";
|
|
9
|
+
/** Helper/support text below input */
|
|
10
|
+
/** Whether the input is disabled */
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
/** Callback when the input is clicked */
|
|
13
|
+
onClick?: () => void;
|
|
14
|
+
/** Callback when calendar icon is clicked */
|
|
15
|
+
onCalendarClick?: () => void;
|
|
16
|
+
/** Callback when input value changes */
|
|
17
|
+
onChange?: (value: string) => void;
|
|
18
|
+
/** Callback when input gains focus */
|
|
19
|
+
onFocus?: () => void;
|
|
20
|
+
/** Callback when input loses focus */
|
|
21
|
+
onBlur?: () => void;
|
|
22
|
+
/** Additional CSS classes */
|
|
23
|
+
className?: string;
|
|
24
|
+
/** Whether the calendar icon has full bg*/
|
|
25
|
+
iconBGFull?: boolean;
|
|
26
|
+
/** Position of the calendar icon: left or right */
|
|
27
|
+
iconPosition?: "left" | "right";
|
|
28
|
+
/** Show chevron on the right when icon is on the left */
|
|
29
|
+
showChevron?: boolean;
|
|
30
|
+
/** Whether the calendar popover is open */
|
|
31
|
+
isOpen?: boolean;
|
|
32
|
+
}
|
|
33
|
+
declare const CalendarInput: React.FC<CalendarInputProps>;
|
|
34
|
+
export default CalendarInput;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import React, { useState } from "react";
|
|
14
|
+
import Icon from "../../atoms/Icon/Icon";
|
|
15
|
+
var CalendarInput = function (_a) {
|
|
16
|
+
var _b = _a.placeholder, placeholder = _b === void 0 ? "Select date" : _b, _c = _a.value, value = _c === void 0 ? "" : _c, _d = _a.state, state = _d === void 0 ? "default" : _d, _e = _a.disabled, disabled = _e === void 0 ? false : _e, onClick = _a.onClick, onCalendarClick = _a.onCalendarClick, onChange = _a.onChange, onFocus = _a.onFocus, onBlur = _a.onBlur, _f = _a.className, className = _f === void 0 ? "" : _f, _g = _a.iconBGFull, iconBGFull = _g === void 0 ? true : _g, _h = _a.iconPosition, iconPosition = _h === void 0 ? "right" : _h, _j = _a.showChevron, showChevron = _j === void 0 ? false : _j, _k = _a.isOpen, isOpen = _k === void 0 ? false : _k;
|
|
17
|
+
var _l = useState(false), isFocused = _l[0], setIsFocused = _l[1];
|
|
18
|
+
var _m = useState(value), localValue = _m[0], setLocalValue = _m[1];
|
|
19
|
+
var _o = useState(false), isTyping = _o[0], setIsTyping = _o[1];
|
|
20
|
+
var finalState = disabled ? "disabled" : state;
|
|
21
|
+
var displayState = isFocused && isTyping ? "typing" : isFocused ? "active" : finalState;
|
|
22
|
+
var handleInputChange = function (e) {
|
|
23
|
+
var newValue = e.target.value;
|
|
24
|
+
setLocalValue(newValue);
|
|
25
|
+
setIsTyping(true);
|
|
26
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
|
|
27
|
+
};
|
|
28
|
+
var handleFocus = function () {
|
|
29
|
+
setIsFocused(true);
|
|
30
|
+
onFocus === null || onFocus === void 0 ? void 0 : onFocus();
|
|
31
|
+
};
|
|
32
|
+
var handleBlur = function () {
|
|
33
|
+
setIsFocused(false);
|
|
34
|
+
setIsTyping(false);
|
|
35
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur();
|
|
36
|
+
};
|
|
37
|
+
var handleCalendarClick = function () {
|
|
38
|
+
if (!disabled) {
|
|
39
|
+
onCalendarClick === null || onCalendarClick === void 0 ? void 0 : onCalendarClick();
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
// keep localValue in sync when parent changes `value` (controlled)
|
|
43
|
+
React.useEffect(function () {
|
|
44
|
+
setLocalValue(value);
|
|
45
|
+
}, [value]);
|
|
46
|
+
var iconButton = (_jsx("button", __assign({ type: "button", className: "calendar-input__icon-button ".concat(iconBGFull ? " calendar-input__icon-button--full-bg" : "", " calendar-input__icon-button--").concat(iconPosition), onClick: handleCalendarClick, disabled: disabled, "aria-label": "Open calendar picker", title: "Select date" }, { children: _jsx(Icon, { name: "calendar", size: "sm", className: "calendar-input__icon" }) })));
|
|
47
|
+
return (_jsxs("div", __assign({ className: "calendar-input calendar-input--".concat(displayState, " calendar-input--icon-").concat(iconPosition, " ").concat(className).trim(), "data-node-id": "3425:11289", onClick: onClick }, { children: [iconPosition === "left" && iconButton, _jsxs("div", __assign({ className: "calendar-input__input-wrapper" }, { children: [_jsx("input", { type: "text", className: "calendar-input__field", placeholder: placeholder, value: localValue || placeholder, disabled: disabled, onChange: handleInputChange, onFocus: handleFocus, onBlur: handleBlur, readOnly: true, "aria-label": "Select date" }), iconPosition === "left" && showChevron && (_jsx("div", __assign({ className: "calendar-input__chevron ".concat(isOpen ? 'calendar-input__chevron--open' : '') }, { children: _jsx(Icon, { name: "chevron-down", size: "sm" }) })))] })), iconPosition === "right" && iconButton] })));
|
|
48
|
+
};
|
|
49
|
+
export default CalendarInput;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { DateRange } from "react-day-picker";
|
|
3
|
+
export interface DateTimeProps {
|
|
4
|
+
mode?: "calendar" | "time" | "both";
|
|
5
|
+
selectionMode?: "single" | "range";
|
|
6
|
+
numberOfMonths?: 1 | 2;
|
|
7
|
+
disableBeforeToday?: boolean;
|
|
8
|
+
disableToday?: boolean;
|
|
9
|
+
defaultDateRange?: DateRange;
|
|
10
|
+
defaultTime?: {
|
|
11
|
+
hour: string;
|
|
12
|
+
minute: string;
|
|
13
|
+
meridiem: "AM" | "PM";
|
|
14
|
+
};
|
|
15
|
+
onChange?: (payload: {
|
|
16
|
+
dateRange?: DateRange;
|
|
17
|
+
time?: {
|
|
18
|
+
hour: string;
|
|
19
|
+
minute: string;
|
|
20
|
+
meridiem: "AM" | "PM";
|
|
21
|
+
};
|
|
22
|
+
}) => void;
|
|
23
|
+
}
|
|
24
|
+
declare const DateTime: React.FC<DateTimeProps>;
|
|
25
|
+
export default DateTime;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { useState, useEffect } from "react";
|
|
14
|
+
import { Calendar } from "../../ui/calendar";
|
|
15
|
+
import { Button } from "../../ui/button";
|
|
16
|
+
import TimePicker from "./TimePicker";
|
|
17
|
+
import Icon from "../../atoms/Icon/Icon";
|
|
18
|
+
var DateTime = function (_a) {
|
|
19
|
+
var _b, _c, _d;
|
|
20
|
+
var _e = _a.mode, mode = _e === void 0 ? "both" : _e, _f = _a.selectionMode, selectionMode = _f === void 0 ? "range" : _f, _g = _a.numberOfMonths, numberOfMonths = _g === void 0 ? 2 : _g, _h = _a.disableBeforeToday, disableBeforeToday = _h === void 0 ? true : _h, _j = _a.disableToday, disableToday = _j === void 0 ? false : _j, defaultDateRange = _a.defaultDateRange, defaultTime = _a.defaultTime, onChange = _a.onChange;
|
|
21
|
+
var _k = useState(defaultDateRange), dateRange = _k[0], setDateRange = _k[1];
|
|
22
|
+
var _l = useState((_b = defaultTime === null || defaultTime === void 0 ? void 0 : defaultTime.hour) !== null && _b !== void 0 ? _b : "12"), hours = _l[0], setHours = _l[1];
|
|
23
|
+
var _m = useState((_c = defaultTime === null || defaultTime === void 0 ? void 0 : defaultTime.minute) !== null && _c !== void 0 ? _c : "00"), minutes = _m[0], setMinutes = _m[1];
|
|
24
|
+
var _o = useState((_d = defaultTime === null || defaultTime === void 0 ? void 0 : defaultTime.meridiem) !== null && _d !== void 0 ? _d : "AM"), amPm = _o[0], setAmPm = _o[1];
|
|
25
|
+
// notify parent when date or time changes
|
|
26
|
+
useEffect(function () {
|
|
27
|
+
onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
28
|
+
dateRange: dateRange !== null && dateRange !== void 0 ? dateRange : undefined,
|
|
29
|
+
time: mode === "calendar" ? undefined : { hour: hours, minute: minutes, meridiem: amPm },
|
|
30
|
+
});
|
|
31
|
+
}, [dateRange, hours, minutes, amPm, onChange, mode]);
|
|
32
|
+
var handleSelect = function (val) {
|
|
33
|
+
if (!val) {
|
|
34
|
+
setDateRange(undefined);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (val instanceof Date) {
|
|
38
|
+
setDateRange({ from: val, to: val });
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (Array.isArray(val)) {
|
|
42
|
+
var sorted = val.slice().sort(function (a, b) { return +a - +b; });
|
|
43
|
+
setDateRange({ from: sorted[0], to: sorted[sorted.length - 1] });
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
setDateRange(val);
|
|
47
|
+
};
|
|
48
|
+
var resetTime = function () {
|
|
49
|
+
setHours("12");
|
|
50
|
+
setMinutes("00");
|
|
51
|
+
setAmPm("AM");
|
|
52
|
+
};
|
|
53
|
+
var clearSelection = function () {
|
|
54
|
+
setDateRange(undefined);
|
|
55
|
+
resetTime();
|
|
56
|
+
};
|
|
57
|
+
var selectToday = function () {
|
|
58
|
+
var today = new Date();
|
|
59
|
+
today.setHours(0, 0, 0, 0);
|
|
60
|
+
setDateRange({ from: today, to: today });
|
|
61
|
+
};
|
|
62
|
+
var calendarMode = selectionMode === "single" ? "single" : "range";
|
|
63
|
+
var buildDisabled = function () {
|
|
64
|
+
var disabled = [];
|
|
65
|
+
if (disableBeforeToday) {
|
|
66
|
+
var today = new Date();
|
|
67
|
+
today.setHours(0, 0, 0, 0);
|
|
68
|
+
disabled.push({ before: today });
|
|
69
|
+
}
|
|
70
|
+
if (disableToday) {
|
|
71
|
+
var today = new Date();
|
|
72
|
+
today.setHours(0, 0, 0, 0);
|
|
73
|
+
disabled.push(today);
|
|
74
|
+
}
|
|
75
|
+
return disabled.length ? disabled : undefined;
|
|
76
|
+
};
|
|
77
|
+
var disabledDays = buildDisabled();
|
|
78
|
+
return (_jsxs("div", __assign({ className: "calendar--dropdown" }, { children: [mode !== "time" && (function () {
|
|
79
|
+
var calendarProps = {
|
|
80
|
+
mode: calendarMode,
|
|
81
|
+
selected: dateRange,
|
|
82
|
+
onSelect: handleSelect,
|
|
83
|
+
weekStartsOn: 1,
|
|
84
|
+
showOutsideDays: false,
|
|
85
|
+
numberOfMonths: numberOfMonths,
|
|
86
|
+
disabled: disabledDays,
|
|
87
|
+
className: "p-0",
|
|
88
|
+
formatters: {
|
|
89
|
+
formatWeekdayName: function (weekday, options) {
|
|
90
|
+
var _a;
|
|
91
|
+
return weekday
|
|
92
|
+
.toLocaleDateString((_a = options === null || options === void 0 ? void 0 : options.locale) === null || _a === void 0 ? void 0 : _a.code, { weekday: "short" })
|
|
93
|
+
.toUpperCase();
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
return _jsx(Calendar, __assign({}, calendarProps));
|
|
98
|
+
})(), mode !== "calendar" && (_jsx("div", __assign({ className: "".concat(mode === "both" ? "calendar--time_container_separated" : "") }, { children: _jsx(TimePicker, { label: "Time", hour: hours, minute: minutes, meridiem: amPm, onChange: function (h, m, mm) {
|
|
99
|
+
var hh = String(Math.max(0, Math.min(12, Number(h || 0)))).padStart(2, "0");
|
|
100
|
+
var mmn = String(Math.max(0, Math.min(59, Number(m || 0)))).padStart(2, "0");
|
|
101
|
+
setHours(hh);
|
|
102
|
+
setMinutes(mmn);
|
|
103
|
+
setAmPm(mm);
|
|
104
|
+
} }) }))), mode !== "time" && (_jsxs("div", __assign({ className: "calendar--footer" }, { children: [_jsxs(Button, __assign({ variant: "ghost", size: "sm", onClick: selectToday, type: "button", className: "calendar--footer--button", disabled: disableToday }, { children: [_jsx(Icon, { name: "calendar-outline", size: "sm" }), "Today"] })), _jsx(Button, __assign({ variant: "ghost", size: "sm", onClick: clearSelection, type: "button", className: "calendar--footer--button" }, { children: "Clear" }))] })))] })));
|
|
105
|
+
};
|
|
106
|
+
export default DateTime;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface TimePickerProps {
|
|
3
|
+
label?: string;
|
|
4
|
+
hour?: string;
|
|
5
|
+
minute?: string;
|
|
6
|
+
meridiem?: "AM" | "PM";
|
|
7
|
+
state?: "default" | "active" | "typing" | "disabled" | "success" | "error";
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
errorMessage?: string;
|
|
10
|
+
successMessage?: string;
|
|
11
|
+
onChange?: (hour: string, minute: string, meridiem: "AM" | "PM") => void;
|
|
12
|
+
onFocus?: () => void;
|
|
13
|
+
onBlur?: () => void;
|
|
14
|
+
}
|
|
15
|
+
declare const TimePicker: React.FC<TimePickerProps>;
|
|
16
|
+
export default TimePicker;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { useState, useEffect } from "react";
|
|
14
|
+
var clampTwoDigits = function (val) {
|
|
15
|
+
return val.replace(/\D/g, "").slice(-2);
|
|
16
|
+
};
|
|
17
|
+
var TimePicker = function (_a) {
|
|
18
|
+
var _b = _a.label, label = _b === void 0 ? "Time" : _b, _c = _a.hour, hour = _c === void 0 ? "" : _c, _d = _a.minute, minute = _d === void 0 ? "" : _d, _e = _a.meridiem, meridiem = _e === void 0 ? "AM" : _e, _f = _a.state, state = _f === void 0 ? "default" : _f, _g = _a.disabled, disabled = _g === void 0 ? false : _g, onChange = _a.onChange, onFocus = _a.onFocus, onBlur = _a.onBlur;
|
|
19
|
+
var _h = useState(hour), localHour = _h[0], setLocalHour = _h[1];
|
|
20
|
+
var _j = useState(minute), localMinute = _j[0], setLocalMinute = _j[1];
|
|
21
|
+
var _k = useState(meridiem), localMeridiem = _k[0], setLocalMeridiem = _k[1];
|
|
22
|
+
var _l = useState(false), isFocused = _l[0], setIsFocused = _l[1];
|
|
23
|
+
var _m = useState(false), isTyping = _m[0], setIsTyping = _m[1];
|
|
24
|
+
// Keep local state in sync when parent props change (e.g. Clear button)
|
|
25
|
+
useEffect(function () {
|
|
26
|
+
if (hour !== localHour)
|
|
27
|
+
setLocalHour(hour);
|
|
28
|
+
}, [hour]);
|
|
29
|
+
useEffect(function () {
|
|
30
|
+
if (minute !== localMinute)
|
|
31
|
+
setLocalMinute(minute);
|
|
32
|
+
}, [minute]);
|
|
33
|
+
useEffect(function () {
|
|
34
|
+
if (meridiem !== localMeridiem)
|
|
35
|
+
setLocalMeridiem(meridiem);
|
|
36
|
+
}, [meridiem]);
|
|
37
|
+
var finalState = disabled ? "disabled" : state;
|
|
38
|
+
var displayState = isFocused && isTyping ? "typing" : isFocused ? "active" : finalState;
|
|
39
|
+
var emitChange = function (h, m, mm) {
|
|
40
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(h, m, mm);
|
|
41
|
+
};
|
|
42
|
+
var handleHourChange = function (e) {
|
|
43
|
+
var raw = clampTwoDigits(e.target.value);
|
|
44
|
+
if (raw === "") {
|
|
45
|
+
setLocalHour("");
|
|
46
|
+
setIsTyping(true);
|
|
47
|
+
emitChange("", localMinute, localMeridiem);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
var num = Number(raw || 0);
|
|
51
|
+
if (num > 12)
|
|
52
|
+
num = 12;
|
|
53
|
+
var val = String(num).padStart(2, "0");
|
|
54
|
+
setLocalHour(val);
|
|
55
|
+
setIsTyping(true);
|
|
56
|
+
emitChange(val, localMinute, localMeridiem);
|
|
57
|
+
};
|
|
58
|
+
var handleMinuteChange = function (e) {
|
|
59
|
+
var raw = clampTwoDigits(e.target.value);
|
|
60
|
+
if (raw === "") {
|
|
61
|
+
setLocalMinute("");
|
|
62
|
+
setIsTyping(true);
|
|
63
|
+
emitChange(localHour, "", localMeridiem);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
var num = Number(raw || 0);
|
|
67
|
+
if (num > 59)
|
|
68
|
+
num = 59;
|
|
69
|
+
var val = String(num).padStart(2, "0");
|
|
70
|
+
setLocalMinute(val);
|
|
71
|
+
setIsTyping(true);
|
|
72
|
+
emitChange(localHour, val, localMeridiem);
|
|
73
|
+
};
|
|
74
|
+
var handleMeridiemClick = function (value) {
|
|
75
|
+
if (disabled)
|
|
76
|
+
return;
|
|
77
|
+
setLocalMeridiem(value);
|
|
78
|
+
emitChange(localHour, localMinute, value);
|
|
79
|
+
};
|
|
80
|
+
var handleFocus = function () {
|
|
81
|
+
setIsFocused(true);
|
|
82
|
+
onFocus === null || onFocus === void 0 ? void 0 : onFocus();
|
|
83
|
+
};
|
|
84
|
+
var handleBlur = function () {
|
|
85
|
+
setIsFocused(false);
|
|
86
|
+
setIsTyping(false);
|
|
87
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur();
|
|
88
|
+
};
|
|
89
|
+
return (_jsxs("div", __assign({ className: "time-picker-wrapper", "data-state": displayState }, { children: [label && _jsx("div", __assign({ className: "time-picker__div" }, { children: label })), _jsxs("div", __assign({ className: "time-picker time-picker--".concat(displayState) }, { children: [_jsx("input", { className: "time-picker__input", type: "text", inputMode: "numeric", pattern: "[0-9]*", value: localHour, placeholder: "00", onChange: handleHourChange, onFocus: handleFocus, onBlur: handleBlur, disabled: disabled, "aria-label": "Hour", "data-unit": "hour" }), _jsx("div", __assign({ className: "time-picker__colon" }, { children: ":" })), _jsx("input", { className: "time-picker__input", type: "text", inputMode: "numeric", pattern: "[0-9]*", value: localMinute, placeholder: "00", onChange: handleMinuteChange, onFocus: handleFocus, onBlur: handleBlur, disabled: disabled, "aria-label": "Minute", "data-unit": "minute" }), _jsxs("div", __assign({ className: "time-picker__am-pm", role: "tablist", "aria-label": "AM/PM selector" }, { children: [_jsx("button", __assign({ type: "button", className: "time-picker__seg time-picker__seg--left ".concat(localMeridiem === "AM" ? "time-picker__seg--selected" : ""), onClick: function () { return handleMeridiemClick("AM"); }, disabled: disabled, "aria-pressed": localMeridiem === "AM" }, { children: "AM" })), _jsx("button", __assign({ type: "button", className: "time-picker__seg time-picker__seg--right ".concat(localMeridiem === "PM" ? "time-picker__seg--selected" : ""), onClick: function () { return handleMeridiemClick("PM"); }, disabled: disabled, "aria-pressed": localMeridiem === "PM" }, { children: "PM" }))] }))] }))] })));
|
|
90
|
+
};
|
|
91
|
+
export default TimePicker;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import '../../../styles/components/molecule/location-dropdown.css';
|
|
3
|
+
export interface LocationOption {
|
|
4
|
+
id: string | number;
|
|
5
|
+
label: string;
|
|
6
|
+
type: 'airport' | 'port' | 'accommodation';
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface LocationGroup {
|
|
10
|
+
id: string;
|
|
11
|
+
label: string;
|
|
12
|
+
options: LocationOption[];
|
|
13
|
+
}
|
|
14
|
+
export interface LocationData {
|
|
15
|
+
id: string | number;
|
|
16
|
+
locationName: string;
|
|
17
|
+
}
|
|
18
|
+
export interface LocationDropdownProps {
|
|
19
|
+
options?: LocationOption[];
|
|
20
|
+
groups?: LocationGroup[];
|
|
21
|
+
selectedValue?: string | number | null;
|
|
22
|
+
placeholder?: string;
|
|
23
|
+
label?: string;
|
|
24
|
+
onSelectionChange: (location: LocationData | null) => void;
|
|
25
|
+
disabled?: boolean;
|
|
26
|
+
error?: boolean;
|
|
27
|
+
className?: string;
|
|
28
|
+
type?: 'airport-port' | 'accommodation' | 'pickup-dropoff';
|
|
29
|
+
maxHeight?: number;
|
|
30
|
+
direction?: 'pickup' | 'dropoff';
|
|
31
|
+
showGroupTitles?: boolean;
|
|
32
|
+
}
|
|
33
|
+
declare const LocationDropdown: React.FC<LocationDropdownProps>;
|
|
34
|
+
export default LocationDropdown;
|