@asdp/ferryui 0.1.4 → 0.1.5
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/index.d.mts +94 -3
- package/dist/index.d.ts +94 -3
- package/dist/index.js +328 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +328 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React$1, { ReactNode } from 'react';
|
|
2
2
|
import { CarouselAnnouncerFunction } from '@fluentui/react-components';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
-
import { FieldValues, Path
|
|
4
|
+
import { FieldValues, Path } from 'react-hook-form';
|
|
5
5
|
|
|
6
6
|
interface ModalIllustrationButton {
|
|
7
7
|
/**
|
|
@@ -379,7 +379,7 @@ interface CountryCode {
|
|
|
379
379
|
}
|
|
380
380
|
interface InputDynamicProps<T extends FieldValues = FieldValues> {
|
|
381
381
|
name: Path<T>;
|
|
382
|
-
control:
|
|
382
|
+
control: any;
|
|
383
383
|
label?: string;
|
|
384
384
|
type: InputType;
|
|
385
385
|
placeholder?: string;
|
|
@@ -553,4 +553,95 @@ interface ModalSearchHarborProps {
|
|
|
553
553
|
*/
|
|
554
554
|
declare const ModalSearchHarbor: React.FC<ModalSearchHarborProps>;
|
|
555
555
|
|
|
556
|
-
|
|
556
|
+
/**
|
|
557
|
+
* Tab type for trip selection
|
|
558
|
+
*/
|
|
559
|
+
type TabType = 'one-way' | 'round-trip';
|
|
560
|
+
/**
|
|
561
|
+
* Props for ModalSelectDate component
|
|
562
|
+
*/
|
|
563
|
+
interface ModalSelectDateProps {
|
|
564
|
+
/**
|
|
565
|
+
* Whether the modal is open
|
|
566
|
+
*/
|
|
567
|
+
open: boolean;
|
|
568
|
+
/**
|
|
569
|
+
* Callback when modal should close
|
|
570
|
+
*/
|
|
571
|
+
onClose: () => void;
|
|
572
|
+
/**
|
|
573
|
+
* Modal title
|
|
574
|
+
* @default "Pilih Tanggal"
|
|
575
|
+
*/
|
|
576
|
+
title?: string;
|
|
577
|
+
/**
|
|
578
|
+
* Initial selected departure date
|
|
579
|
+
*/
|
|
580
|
+
selectedDepartureDate?: Date;
|
|
581
|
+
/**
|
|
582
|
+
* Initial selected return date (for round trip)
|
|
583
|
+
*/
|
|
584
|
+
selectedReturnDate?: Date;
|
|
585
|
+
/**
|
|
586
|
+
* Initial tab selection
|
|
587
|
+
* @default "one-way"
|
|
588
|
+
*/
|
|
589
|
+
initialTab?: TabType;
|
|
590
|
+
/**
|
|
591
|
+
* Whether to show tabs for one-way/round-trip selection
|
|
592
|
+
* @default true
|
|
593
|
+
*/
|
|
594
|
+
showTabs?: boolean;
|
|
595
|
+
/**
|
|
596
|
+
* Callback when departure date is selected
|
|
597
|
+
*/
|
|
598
|
+
onSelectDepartureDate: (date: Date) => void;
|
|
599
|
+
/**
|
|
600
|
+
* Callback when return date is selected (for round trip)
|
|
601
|
+
*/
|
|
602
|
+
onSelectReturnDate?: (date: Date) => void;
|
|
603
|
+
/**
|
|
604
|
+
* Callback when tab changes
|
|
605
|
+
*/
|
|
606
|
+
onTabChange?: (tab: TabType) => void;
|
|
607
|
+
/**
|
|
608
|
+
* Minimum selectable date
|
|
609
|
+
* @default new Date()
|
|
610
|
+
*/
|
|
611
|
+
minDate?: Date;
|
|
612
|
+
/**
|
|
613
|
+
* Maximum selectable date
|
|
614
|
+
*/
|
|
615
|
+
maxDate?: Date;
|
|
616
|
+
/**
|
|
617
|
+
* Date format for internal handling
|
|
618
|
+
* @default "DD MMMM YYYY"
|
|
619
|
+
*/
|
|
620
|
+
dateFormat?: string;
|
|
621
|
+
}
|
|
622
|
+
/**
|
|
623
|
+
* ModalSelectDate - A reusable modal component for selecting dates
|
|
624
|
+
*
|
|
625
|
+
* This component provides a date selection modal with features like:
|
|
626
|
+
* - Single date selection (one-way)
|
|
627
|
+
* - Date range selection (round-trip)
|
|
628
|
+
* - Visual range preview on hover
|
|
629
|
+
* - Customizable date constraints
|
|
630
|
+
*
|
|
631
|
+
* @example
|
|
632
|
+
* ```tsx
|
|
633
|
+
* <ModalSelectDate
|
|
634
|
+
* open={isOpen}
|
|
635
|
+
* onClose={() => setIsOpen(false)}
|
|
636
|
+
* title="Pilih Tanggal Keberangkatan"
|
|
637
|
+
* selectedDepartureDate={departureDate}
|
|
638
|
+
* selectedReturnDate={returnDate}
|
|
639
|
+
* onSelectDepartureDate={setDepartureDate}
|
|
640
|
+
* onSelectReturnDate={setReturnDate}
|
|
641
|
+
* onTabChange={handleTabChange}
|
|
642
|
+
* />
|
|
643
|
+
* ```
|
|
644
|
+
*/
|
|
645
|
+
declare const ModalSelectDate: React.FC<ModalSelectDateProps>;
|
|
646
|
+
|
|
647
|
+
export { BackgroundTicketCard, BackgroundTicketCardVertical, CardBanner, type CardBannerProps, CardPromo, type CardPromoProps, CardServiceMenu, type CardServiceMenuProps, CardTicket, type CardTicketButton, type CardTicketProps, CarouselWithCustomNav, type CarouselWithCustomNavProps, type CountryCode, DEFAULT_COUNTRY_CODES, type HarborItem, InputDynamic, type InputDynamicProps, type InputType, MODAL_PRESETS, ModalIllustration, type ModalIllustrationButton, type ModalIllustrationProps, type ModalPresetKey, ModalSearchHarbor, type ModalSearchHarborProps, ModalSelectDate, type ModalSelectDateProps, type RadioOption, type SelectOption, type ServiceMenuItem, type TabType, getModalPreset };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React$1, { ReactNode } from 'react';
|
|
2
2
|
import { CarouselAnnouncerFunction } from '@fluentui/react-components';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
-
import { FieldValues, Path
|
|
4
|
+
import { FieldValues, Path } from 'react-hook-form';
|
|
5
5
|
|
|
6
6
|
interface ModalIllustrationButton {
|
|
7
7
|
/**
|
|
@@ -379,7 +379,7 @@ interface CountryCode {
|
|
|
379
379
|
}
|
|
380
380
|
interface InputDynamicProps<T extends FieldValues = FieldValues> {
|
|
381
381
|
name: Path<T>;
|
|
382
|
-
control:
|
|
382
|
+
control: any;
|
|
383
383
|
label?: string;
|
|
384
384
|
type: InputType;
|
|
385
385
|
placeholder?: string;
|
|
@@ -553,4 +553,95 @@ interface ModalSearchHarborProps {
|
|
|
553
553
|
*/
|
|
554
554
|
declare const ModalSearchHarbor: React.FC<ModalSearchHarborProps>;
|
|
555
555
|
|
|
556
|
-
|
|
556
|
+
/**
|
|
557
|
+
* Tab type for trip selection
|
|
558
|
+
*/
|
|
559
|
+
type TabType = 'one-way' | 'round-trip';
|
|
560
|
+
/**
|
|
561
|
+
* Props for ModalSelectDate component
|
|
562
|
+
*/
|
|
563
|
+
interface ModalSelectDateProps {
|
|
564
|
+
/**
|
|
565
|
+
* Whether the modal is open
|
|
566
|
+
*/
|
|
567
|
+
open: boolean;
|
|
568
|
+
/**
|
|
569
|
+
* Callback when modal should close
|
|
570
|
+
*/
|
|
571
|
+
onClose: () => void;
|
|
572
|
+
/**
|
|
573
|
+
* Modal title
|
|
574
|
+
* @default "Pilih Tanggal"
|
|
575
|
+
*/
|
|
576
|
+
title?: string;
|
|
577
|
+
/**
|
|
578
|
+
* Initial selected departure date
|
|
579
|
+
*/
|
|
580
|
+
selectedDepartureDate?: Date;
|
|
581
|
+
/**
|
|
582
|
+
* Initial selected return date (for round trip)
|
|
583
|
+
*/
|
|
584
|
+
selectedReturnDate?: Date;
|
|
585
|
+
/**
|
|
586
|
+
* Initial tab selection
|
|
587
|
+
* @default "one-way"
|
|
588
|
+
*/
|
|
589
|
+
initialTab?: TabType;
|
|
590
|
+
/**
|
|
591
|
+
* Whether to show tabs for one-way/round-trip selection
|
|
592
|
+
* @default true
|
|
593
|
+
*/
|
|
594
|
+
showTabs?: boolean;
|
|
595
|
+
/**
|
|
596
|
+
* Callback when departure date is selected
|
|
597
|
+
*/
|
|
598
|
+
onSelectDepartureDate: (date: Date) => void;
|
|
599
|
+
/**
|
|
600
|
+
* Callback when return date is selected (for round trip)
|
|
601
|
+
*/
|
|
602
|
+
onSelectReturnDate?: (date: Date) => void;
|
|
603
|
+
/**
|
|
604
|
+
* Callback when tab changes
|
|
605
|
+
*/
|
|
606
|
+
onTabChange?: (tab: TabType) => void;
|
|
607
|
+
/**
|
|
608
|
+
* Minimum selectable date
|
|
609
|
+
* @default new Date()
|
|
610
|
+
*/
|
|
611
|
+
minDate?: Date;
|
|
612
|
+
/**
|
|
613
|
+
* Maximum selectable date
|
|
614
|
+
*/
|
|
615
|
+
maxDate?: Date;
|
|
616
|
+
/**
|
|
617
|
+
* Date format for internal handling
|
|
618
|
+
* @default "DD MMMM YYYY"
|
|
619
|
+
*/
|
|
620
|
+
dateFormat?: string;
|
|
621
|
+
}
|
|
622
|
+
/**
|
|
623
|
+
* ModalSelectDate - A reusable modal component for selecting dates
|
|
624
|
+
*
|
|
625
|
+
* This component provides a date selection modal with features like:
|
|
626
|
+
* - Single date selection (one-way)
|
|
627
|
+
* - Date range selection (round-trip)
|
|
628
|
+
* - Visual range preview on hover
|
|
629
|
+
* - Customizable date constraints
|
|
630
|
+
*
|
|
631
|
+
* @example
|
|
632
|
+
* ```tsx
|
|
633
|
+
* <ModalSelectDate
|
|
634
|
+
* open={isOpen}
|
|
635
|
+
* onClose={() => setIsOpen(false)}
|
|
636
|
+
* title="Pilih Tanggal Keberangkatan"
|
|
637
|
+
* selectedDepartureDate={departureDate}
|
|
638
|
+
* selectedReturnDate={returnDate}
|
|
639
|
+
* onSelectDepartureDate={setDepartureDate}
|
|
640
|
+
* onSelectReturnDate={setReturnDate}
|
|
641
|
+
* onTabChange={handleTabChange}
|
|
642
|
+
* />
|
|
643
|
+
* ```
|
|
644
|
+
*/
|
|
645
|
+
declare const ModalSelectDate: React.FC<ModalSelectDateProps>;
|
|
646
|
+
|
|
647
|
+
export { BackgroundTicketCard, BackgroundTicketCardVertical, CardBanner, type CardBannerProps, CardPromo, type CardPromoProps, CardServiceMenu, type CardServiceMenuProps, CardTicket, type CardTicketButton, type CardTicketProps, CarouselWithCustomNav, type CarouselWithCustomNavProps, type CountryCode, DEFAULT_COUNTRY_CODES, type HarborItem, InputDynamic, type InputDynamicProps, type InputType, MODAL_PRESETS, ModalIllustration, type ModalIllustrationButton, type ModalIllustrationProps, type ModalPresetKey, ModalSearchHarbor, type ModalSearchHarborProps, ModalSelectDate, type ModalSelectDateProps, type RadioOption, type SelectOption, type ServiceMenuItem, type TabType, getModalPreset };
|
package/dist/index.js
CHANGED
|
@@ -8,12 +8,14 @@ var reactHookForm = require('react-hook-form');
|
|
|
8
8
|
var PhoneInput = require('react-phone-input-2');
|
|
9
9
|
var Select = require('react-select');
|
|
10
10
|
var reactCalendarCompat = require('@fluentui/react-calendar-compat');
|
|
11
|
+
var moment = require('moment');
|
|
11
12
|
|
|
12
13
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
14
|
|
|
14
15
|
var React2__default = /*#__PURE__*/_interopDefault(React2);
|
|
15
16
|
var PhoneInput__default = /*#__PURE__*/_interopDefault(PhoneInput);
|
|
16
17
|
var Select__default = /*#__PURE__*/_interopDefault(Select);
|
|
18
|
+
var moment__default = /*#__PURE__*/_interopDefault(moment);
|
|
17
19
|
|
|
18
20
|
var useStyles = reactComponents.makeStyles({
|
|
19
21
|
dialogSurface: {
|
|
@@ -3043,6 +3045,331 @@ var ModalSearchHarbor = ({
|
|
|
3043
3045
|
}
|
|
3044
3046
|
);
|
|
3045
3047
|
};
|
|
3048
|
+
var useStyles9 = reactComponents.makeStyles({
|
|
3049
|
+
dialogSurface: {
|
|
3050
|
+
maxWidth: "600px",
|
|
3051
|
+
width: "100%"
|
|
3052
|
+
},
|
|
3053
|
+
content: {
|
|
3054
|
+
display: "flex",
|
|
3055
|
+
flexDirection: "column",
|
|
3056
|
+
gap: "0px",
|
|
3057
|
+
paddingTop: "10px",
|
|
3058
|
+
paddingLeft: "10px",
|
|
3059
|
+
paddingRight: "10px",
|
|
3060
|
+
paddingBottom: "20px",
|
|
3061
|
+
width: "100%",
|
|
3062
|
+
overflow: "hidden"
|
|
3063
|
+
},
|
|
3064
|
+
closeButton: {
|
|
3065
|
+
minWidth: "32px",
|
|
3066
|
+
minHeight: "32px"
|
|
3067
|
+
},
|
|
3068
|
+
tabContainer: {
|
|
3069
|
+
display: "flex",
|
|
3070
|
+
gap: "0px",
|
|
3071
|
+
marginBottom: "16px",
|
|
3072
|
+
borderBottom: `2px solid ${reactComponents.tokens.colorNeutralStroke2}`
|
|
3073
|
+
},
|
|
3074
|
+
tab: {
|
|
3075
|
+
flex: 1,
|
|
3076
|
+
padding: "12px 16px",
|
|
3077
|
+
cursor: "pointer",
|
|
3078
|
+
textAlign: "center",
|
|
3079
|
+
fontSize: reactComponents.tokens.fontSizeBase300,
|
|
3080
|
+
fontWeight: reactComponents.tokens.fontWeightRegular,
|
|
3081
|
+
color: reactComponents.tokens.colorNeutralForeground3,
|
|
3082
|
+
borderBottom: "2px solid transparent",
|
|
3083
|
+
marginBottom: "-2px",
|
|
3084
|
+
transition: "all 0.2s ease",
|
|
3085
|
+
backgroundColor: "transparent",
|
|
3086
|
+
border: "none",
|
|
3087
|
+
":hover": {
|
|
3088
|
+
color: reactComponents.tokens.colorNeutralForeground1,
|
|
3089
|
+
backgroundColor: reactComponents.tokens.colorNeutralBackground1Hover
|
|
3090
|
+
}
|
|
3091
|
+
},
|
|
3092
|
+
tabActive: {
|
|
3093
|
+
color: reactComponents.tokens.colorBrandForeground1,
|
|
3094
|
+
fontWeight: reactComponents.tokens.fontWeightSemibold,
|
|
3095
|
+
borderBottom: `2px solid ${reactComponents.tokens.colorBrandBackground}`
|
|
3096
|
+
},
|
|
3097
|
+
calendarContainer: {
|
|
3098
|
+
display: "flex",
|
|
3099
|
+
gap: "20px",
|
|
3100
|
+
justifyContent: "center",
|
|
3101
|
+
alignItems: "flex-start",
|
|
3102
|
+
width: "100%"
|
|
3103
|
+
},
|
|
3104
|
+
rangeCalendar: {
|
|
3105
|
+
"& .ms-CalendarDay": {
|
|
3106
|
+
position: "relative"
|
|
3107
|
+
},
|
|
3108
|
+
'& button[class*="ms-CalendarDay"]': {
|
|
3109
|
+
borderRadius: "999px",
|
|
3110
|
+
transition: "all 0.15s ease",
|
|
3111
|
+
border: "none",
|
|
3112
|
+
"&:hover": {
|
|
3113
|
+
backgroundColor: `${reactComponents.tokens.colorBrandBackground} !important`,
|
|
3114
|
+
color: reactComponents.tokens.colorNeutralForegroundStaticInverted
|
|
3115
|
+
}
|
|
3116
|
+
}
|
|
3117
|
+
},
|
|
3118
|
+
rangeStart: {
|
|
3119
|
+
backgroundColor: `${reactComponents.tokens.colorBrandBackground} !important`,
|
|
3120
|
+
color: `${reactComponents.tokens.colorNeutralForegroundStaticInverted} !important`,
|
|
3121
|
+
borderTopLeftRadius: "999px !important",
|
|
3122
|
+
borderBottomLeftRadius: "999px !important",
|
|
3123
|
+
fontWeight: reactComponents.tokens.fontWeightSemibold
|
|
3124
|
+
},
|
|
3125
|
+
rangeEnd: {
|
|
3126
|
+
backgroundColor: `${reactComponents.tokens.colorBrandBackground} !important`,
|
|
3127
|
+
color: `${reactComponents.tokens.colorNeutralForegroundOnBrand} !important`,
|
|
3128
|
+
borderTopRightRadius: "999px !important",
|
|
3129
|
+
borderBottomRightRadius: "999px !important",
|
|
3130
|
+
fontWeight: reactComponents.tokens.fontWeightSemibold
|
|
3131
|
+
},
|
|
3132
|
+
rangeMiddle: {
|
|
3133
|
+
backgroundColor: `${reactComponents.tokens.colorBrandBackground} !important`,
|
|
3134
|
+
color: `${reactComponents.tokens.colorNeutralForegroundStaticInverted} !important`,
|
|
3135
|
+
borderRadius: "0px !important"
|
|
3136
|
+
},
|
|
3137
|
+
rangePreview: {
|
|
3138
|
+
backgroundColor: `${reactComponents.tokens.colorBrandBackground} !important`,
|
|
3139
|
+
color: reactComponents.tokens.colorNeutralForegroundStaticInverted,
|
|
3140
|
+
borderRadius: "0px !important",
|
|
3141
|
+
boxShadow: `inset 0 0 0 1px ${reactComponents.tokens.colorBrandStroke1}`
|
|
3142
|
+
},
|
|
3143
|
+
rangeSingle: {
|
|
3144
|
+
backgroundColor: `${reactComponents.tokens.colorBrandBackground} !important`,
|
|
3145
|
+
color: `${reactComponents.tokens.colorNeutralForegroundOnBrand} !important`,
|
|
3146
|
+
borderRadius: "999px !important",
|
|
3147
|
+
fontWeight: reactComponents.tokens.fontWeightSemibold
|
|
3148
|
+
}
|
|
3149
|
+
});
|
|
3150
|
+
var ModalSelectDate = ({
|
|
3151
|
+
open,
|
|
3152
|
+
onClose,
|
|
3153
|
+
title = "Pilih Tanggal",
|
|
3154
|
+
selectedDepartureDate,
|
|
3155
|
+
selectedReturnDate,
|
|
3156
|
+
initialTab = "one-way",
|
|
3157
|
+
showTabs = true,
|
|
3158
|
+
onSelectDepartureDate,
|
|
3159
|
+
onSelectReturnDate,
|
|
3160
|
+
onTabChange,
|
|
3161
|
+
minDate = /* @__PURE__ */ new Date(),
|
|
3162
|
+
maxDate,
|
|
3163
|
+
dateFormat = "DD MMMM YYYY"
|
|
3164
|
+
}) => {
|
|
3165
|
+
const styles = useStyles9();
|
|
3166
|
+
const [selectedDate, setSelectedDate] = React2.useState(selectedDepartureDate);
|
|
3167
|
+
const [selectedEndDate, setSelectedEndDate] = React2.useState(selectedReturnDate);
|
|
3168
|
+
const [hoveredDate, setHoveredDate] = React2.useState();
|
|
3169
|
+
const [activeTab, setActiveTab] = React2.useState(initialTab);
|
|
3170
|
+
const previewEndDate = React2.useMemo(() => {
|
|
3171
|
+
if (selectedEndDate) return selectedEndDate;
|
|
3172
|
+
if (selectedDate && hoveredDate && hoveredDate > selectedDate) {
|
|
3173
|
+
return hoveredDate;
|
|
3174
|
+
}
|
|
3175
|
+
return void 0;
|
|
3176
|
+
}, [hoveredDate, selectedDate, selectedEndDate]);
|
|
3177
|
+
const isSameCalendarDay = (first, second) => {
|
|
3178
|
+
if (!first || !second) return false;
|
|
3179
|
+
return moment__default.default(first).isSame(second, "day");
|
|
3180
|
+
};
|
|
3181
|
+
React2.useEffect(() => {
|
|
3182
|
+
if (open) {
|
|
3183
|
+
setSelectedDate(selectedDepartureDate);
|
|
3184
|
+
setSelectedEndDate(selectedReturnDate);
|
|
3185
|
+
setActiveTab(initialTab);
|
|
3186
|
+
setHoveredDate(void 0);
|
|
3187
|
+
}
|
|
3188
|
+
}, [open, selectedDepartureDate, selectedReturnDate, initialTab]);
|
|
3189
|
+
const handleTabChange = (tab) => {
|
|
3190
|
+
setActiveTab(tab);
|
|
3191
|
+
setSelectedEndDate(void 0);
|
|
3192
|
+
setHoveredDate(void 0);
|
|
3193
|
+
if (onTabChange) {
|
|
3194
|
+
onTabChange(tab);
|
|
3195
|
+
}
|
|
3196
|
+
};
|
|
3197
|
+
const handleClose = () => {
|
|
3198
|
+
setHoveredDate(void 0);
|
|
3199
|
+
onClose();
|
|
3200
|
+
};
|
|
3201
|
+
const handleDateSelect = (date) => {
|
|
3202
|
+
if (!date) return;
|
|
3203
|
+
const currentStart = selectedDate;
|
|
3204
|
+
if (activeTab === "round-trip") {
|
|
3205
|
+
if (!currentStart || selectedEndDate) {
|
|
3206
|
+
setSelectedDate(date);
|
|
3207
|
+
setSelectedEndDate(void 0);
|
|
3208
|
+
setHoveredDate(void 0);
|
|
3209
|
+
onSelectDepartureDate(date);
|
|
3210
|
+
} else {
|
|
3211
|
+
if (date < currentStart) {
|
|
3212
|
+
setSelectedEndDate(currentStart);
|
|
3213
|
+
setSelectedDate(date);
|
|
3214
|
+
onSelectDepartureDate(date);
|
|
3215
|
+
if (onSelectReturnDate) {
|
|
3216
|
+
onSelectReturnDate(currentStart);
|
|
3217
|
+
}
|
|
3218
|
+
} else {
|
|
3219
|
+
setSelectedEndDate(date);
|
|
3220
|
+
if (onSelectReturnDate) {
|
|
3221
|
+
onSelectReturnDate(date);
|
|
3222
|
+
}
|
|
3223
|
+
}
|
|
3224
|
+
setHoveredDate(void 0);
|
|
3225
|
+
handleClose();
|
|
3226
|
+
}
|
|
3227
|
+
} else {
|
|
3228
|
+
setSelectedDate(date);
|
|
3229
|
+
onSelectDepartureDate(date);
|
|
3230
|
+
handleClose();
|
|
3231
|
+
}
|
|
3232
|
+
};
|
|
3233
|
+
const handleCustomDayCellRef = React2.useCallback(
|
|
3234
|
+
(element, date, _classNames) => {
|
|
3235
|
+
if (!element) return;
|
|
3236
|
+
const removeTokens = (className) => {
|
|
3237
|
+
className?.split(/\s+/).filter(Boolean).forEach((token) => element.classList.remove(token));
|
|
3238
|
+
};
|
|
3239
|
+
const addTokens = (className) => {
|
|
3240
|
+
className?.split(/\s+/).filter(Boolean).forEach((token) => element.classList.add(token));
|
|
3241
|
+
};
|
|
3242
|
+
const removableClasses = [
|
|
3243
|
+
styles.rangeStart,
|
|
3244
|
+
styles.rangeEnd,
|
|
3245
|
+
styles.rangeMiddle,
|
|
3246
|
+
styles.rangePreview,
|
|
3247
|
+
styles.rangeSingle
|
|
3248
|
+
];
|
|
3249
|
+
removableClasses.forEach(removeTokens);
|
|
3250
|
+
if (activeTab !== "round-trip" || !selectedDate) {
|
|
3251
|
+
element.onmouseenter = null;
|
|
3252
|
+
element.onmouseleave = null;
|
|
3253
|
+
return;
|
|
3254
|
+
}
|
|
3255
|
+
const endDateForVisual = previewEndDate;
|
|
3256
|
+
const startTime = selectedDate.getTime();
|
|
3257
|
+
const endTime = endDateForVisual?.getTime();
|
|
3258
|
+
const currentTime = date.getTime();
|
|
3259
|
+
const isSameStartEnd = isSameCalendarDay(endDateForVisual, selectedDate);
|
|
3260
|
+
const isStartDay = isSameCalendarDay(date, selectedDate);
|
|
3261
|
+
const isEndDay = isSameCalendarDay(date, endDateForVisual);
|
|
3262
|
+
if (isStartDay && (!endDateForVisual || isSameStartEnd)) {
|
|
3263
|
+
addTokens(styles.rangeSingle);
|
|
3264
|
+
} else {
|
|
3265
|
+
if (isStartDay) {
|
|
3266
|
+
addTokens(styles.rangeStart);
|
|
3267
|
+
}
|
|
3268
|
+
if (isEndDay && !isSameStartEnd) {
|
|
3269
|
+
addTokens(styles.rangeEnd);
|
|
3270
|
+
}
|
|
3271
|
+
}
|
|
3272
|
+
if (endTime && currentTime > startTime && currentTime < endTime) {
|
|
3273
|
+
addTokens(selectedEndDate ? styles.rangeMiddle : styles.rangePreview);
|
|
3274
|
+
}
|
|
3275
|
+
if (!selectedEndDate) {
|
|
3276
|
+
element.onmouseenter = () => {
|
|
3277
|
+
if (date < selectedDate) return;
|
|
3278
|
+
setHoveredDate((prev) => {
|
|
3279
|
+
if (isSameCalendarDay(prev, date)) {
|
|
3280
|
+
return prev;
|
|
3281
|
+
}
|
|
3282
|
+
return date;
|
|
3283
|
+
});
|
|
3284
|
+
};
|
|
3285
|
+
element.onmouseleave = () => {
|
|
3286
|
+
setHoveredDate(void 0);
|
|
3287
|
+
};
|
|
3288
|
+
} else {
|
|
3289
|
+
element.onmouseenter = null;
|
|
3290
|
+
element.onmouseleave = null;
|
|
3291
|
+
}
|
|
3292
|
+
},
|
|
3293
|
+
[
|
|
3294
|
+
activeTab,
|
|
3295
|
+
previewEndDate,
|
|
3296
|
+
selectedDate,
|
|
3297
|
+
selectedEndDate,
|
|
3298
|
+
styles.rangeEnd,
|
|
3299
|
+
styles.rangeMiddle,
|
|
3300
|
+
styles.rangePreview,
|
|
3301
|
+
styles.rangeSingle,
|
|
3302
|
+
styles.rangeStart
|
|
3303
|
+
]
|
|
3304
|
+
);
|
|
3305
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3306
|
+
reactComponents.Dialog,
|
|
3307
|
+
{
|
|
3308
|
+
open,
|
|
3309
|
+
onOpenChange: (_, data) => {
|
|
3310
|
+
if (!data.open) {
|
|
3311
|
+
onClose();
|
|
3312
|
+
}
|
|
3313
|
+
},
|
|
3314
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactComponents.DialogSurface, { className: styles.dialogSurface, children: /* @__PURE__ */ jsxRuntime.jsxs(reactComponents.DialogBody, { children: [
|
|
3315
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3316
|
+
reactComponents.DialogTitle,
|
|
3317
|
+
{
|
|
3318
|
+
action: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3319
|
+
reactComponents.Button,
|
|
3320
|
+
{
|
|
3321
|
+
appearance: "subtle",
|
|
3322
|
+
"aria-label": "close",
|
|
3323
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(react.Icon, { icon: "fluent:dismiss-24-regular" }),
|
|
3324
|
+
onClick: handleClose,
|
|
3325
|
+
className: styles.closeButton
|
|
3326
|
+
}
|
|
3327
|
+
),
|
|
3328
|
+
children: title
|
|
3329
|
+
}
|
|
3330
|
+
),
|
|
3331
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactComponents.DialogContent, { className: styles.content, children: [
|
|
3332
|
+
showTabs && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles.tabContainer, children: [
|
|
3333
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3334
|
+
"button",
|
|
3335
|
+
{
|
|
3336
|
+
disabled: activeTab === "round-trip",
|
|
3337
|
+
className: `${styles.tab} ${activeTab === "one-way" ? styles.tabActive : ""}`,
|
|
3338
|
+
onClick: () => handleTabChange("one-way"),
|
|
3339
|
+
children: "Sekali Jalan"
|
|
3340
|
+
}
|
|
3341
|
+
),
|
|
3342
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3343
|
+
"button",
|
|
3344
|
+
{
|
|
3345
|
+
className: `${styles.tab} ${activeTab === "round-trip" ? styles.tabActive : ""}`,
|
|
3346
|
+
onClick: () => handleTabChange("round-trip"),
|
|
3347
|
+
disabled: activeTab === "one-way",
|
|
3348
|
+
children: "Pulang Pergi"
|
|
3349
|
+
}
|
|
3350
|
+
)
|
|
3351
|
+
] }),
|
|
3352
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: styles.calendarContainer, children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: { width: "100%" }, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: activeTab === "round-trip" ? styles.rangeCalendar : "", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3353
|
+
reactCalendarCompat.Calendar,
|
|
3354
|
+
{
|
|
3355
|
+
minDate,
|
|
3356
|
+
maxDate,
|
|
3357
|
+
value: selectedDate,
|
|
3358
|
+
onSelectDate: handleDateSelect,
|
|
3359
|
+
showGoToToday: true,
|
|
3360
|
+
highlightSelectedMonth: true,
|
|
3361
|
+
showMonthPickerAsOverlay: false,
|
|
3362
|
+
allFocusable: true,
|
|
3363
|
+
calendarDayProps: {
|
|
3364
|
+
customDayCellRef: handleCustomDayCellRef
|
|
3365
|
+
}
|
|
3366
|
+
}
|
|
3367
|
+
) }) }) })
|
|
3368
|
+
] })
|
|
3369
|
+
] }) })
|
|
3370
|
+
}
|
|
3371
|
+
);
|
|
3372
|
+
};
|
|
3046
3373
|
|
|
3047
3374
|
exports.BackgroundTicketCard = BackgroundTicketCard_default;
|
|
3048
3375
|
exports.BackgroundTicketCardVertical = BackgroundTicketCardVertical_default;
|
|
@@ -3056,6 +3383,7 @@ exports.InputDynamic = InputDynamic_default;
|
|
|
3056
3383
|
exports.MODAL_PRESETS = MODAL_PRESETS;
|
|
3057
3384
|
exports.ModalIllustration = ModalIllustration;
|
|
3058
3385
|
exports.ModalSearchHarbor = ModalSearchHarbor;
|
|
3386
|
+
exports.ModalSelectDate = ModalSelectDate;
|
|
3059
3387
|
exports.getModalPreset = getModalPreset;
|
|
3060
3388
|
//# sourceMappingURL=index.js.map
|
|
3061
3389
|
//# sourceMappingURL=index.js.map
|