@asdp/ferryui 0.1.4 → 0.1.6
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 +181 -3
- package/dist/index.d.ts +181 -3
- package/dist/index.js +520 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +520 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -1
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { makeStyles, tokens, shorthands, Popover, PopoverTrigger, Input, PopoverSurface, Dialog, DialogSurface, DialogBody, DialogTitle, DialogContent, Body1, Button, Carousel, mergeClasses, CarouselViewport, CarouselSlider, CarouselNav, CarouselNavButton, CarouselCard, Subtitle2, Card, Tooltip, Badge, Caption1, Title2, Caption2, Divider, Title3, Caption1Strong, Field, Label, Text, Body1Strong,
|
|
1
|
+
import { makeStyles, tokens, shorthands, Popover, PopoverTrigger, Input, PopoverSurface, Dialog, DialogSurface, DialogBody, DialogTitle, DialogContent, Body1, Button, Carousel, mergeClasses, CarouselViewport, CarouselSlider, CarouselNav, CarouselNavButton, CarouselCard, Subtitle2, Card, Tooltip, Badge, Caption1, Title2, Caption2, Divider, Title3, Caption1Strong, Field, Label, Text, Body1Strong, Checkbox, typographyStyles, RadioGroup, Radio, Switch, Textarea } from '@fluentui/react-components';
|
|
2
2
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
3
|
-
import React2, { forwardRef, useState, useCallback, useRef, useEffect } from 'react';
|
|
3
|
+
import React2, { forwardRef, useState, useCallback, useRef, useEffect, useMemo } from 'react';
|
|
4
4
|
import { Icon } from '@iconify/react';
|
|
5
5
|
import { Controller } from 'react-hook-form';
|
|
6
6
|
import PhoneInput from 'react-phone-input-2';
|
|
7
7
|
import Select from 'react-select';
|
|
8
8
|
import { Calendar } from '@fluentui/react-calendar-compat';
|
|
9
|
+
import moment from 'moment';
|
|
9
10
|
|
|
10
11
|
var useStyles = makeStyles({
|
|
11
12
|
dialogSurface: {
|
|
@@ -3035,7 +3036,523 @@ var ModalSearchHarbor = ({
|
|
|
3035
3036
|
}
|
|
3036
3037
|
);
|
|
3037
3038
|
};
|
|
3039
|
+
var useStyles9 = makeStyles({
|
|
3040
|
+
dialogSurface: {
|
|
3041
|
+
maxWidth: "600px",
|
|
3042
|
+
width: "100%"
|
|
3043
|
+
},
|
|
3044
|
+
content: {
|
|
3045
|
+
display: "flex",
|
|
3046
|
+
flexDirection: "column",
|
|
3047
|
+
gap: "0px",
|
|
3048
|
+
paddingTop: "10px",
|
|
3049
|
+
paddingLeft: "10px",
|
|
3050
|
+
paddingRight: "10px",
|
|
3051
|
+
paddingBottom: "20px",
|
|
3052
|
+
width: "100%",
|
|
3053
|
+
overflow: "hidden"
|
|
3054
|
+
},
|
|
3055
|
+
closeButton: {
|
|
3056
|
+
minWidth: "32px",
|
|
3057
|
+
minHeight: "32px"
|
|
3058
|
+
},
|
|
3059
|
+
tabContainer: {
|
|
3060
|
+
display: "flex",
|
|
3061
|
+
gap: "0px",
|
|
3062
|
+
marginBottom: "16px",
|
|
3063
|
+
borderBottom: `2px solid ${tokens.colorNeutralStroke2}`
|
|
3064
|
+
},
|
|
3065
|
+
tab: {
|
|
3066
|
+
flex: 1,
|
|
3067
|
+
padding: "12px 16px",
|
|
3068
|
+
cursor: "pointer",
|
|
3069
|
+
textAlign: "center",
|
|
3070
|
+
fontSize: tokens.fontSizeBase300,
|
|
3071
|
+
fontWeight: tokens.fontWeightRegular,
|
|
3072
|
+
color: tokens.colorNeutralForeground3,
|
|
3073
|
+
borderBottom: "2px solid transparent",
|
|
3074
|
+
marginBottom: "-2px",
|
|
3075
|
+
transition: "all 0.2s ease",
|
|
3076
|
+
backgroundColor: "transparent",
|
|
3077
|
+
border: "none",
|
|
3078
|
+
":hover": {
|
|
3079
|
+
color: tokens.colorNeutralForeground1,
|
|
3080
|
+
backgroundColor: tokens.colorNeutralBackground1Hover
|
|
3081
|
+
}
|
|
3082
|
+
},
|
|
3083
|
+
tabActive: {
|
|
3084
|
+
color: tokens.colorBrandForeground1,
|
|
3085
|
+
fontWeight: tokens.fontWeightSemibold,
|
|
3086
|
+
borderBottom: `2px solid ${tokens.colorBrandBackground}`
|
|
3087
|
+
},
|
|
3088
|
+
calendarContainer: {
|
|
3089
|
+
display: "flex",
|
|
3090
|
+
gap: "20px",
|
|
3091
|
+
justifyContent: "center",
|
|
3092
|
+
alignItems: "flex-start",
|
|
3093
|
+
width: "100%"
|
|
3094
|
+
},
|
|
3095
|
+
rangeCalendar: {
|
|
3096
|
+
"& .ms-CalendarDay": {
|
|
3097
|
+
position: "relative"
|
|
3098
|
+
},
|
|
3099
|
+
'& button[class*="ms-CalendarDay"]': {
|
|
3100
|
+
borderRadius: "999px",
|
|
3101
|
+
transition: "all 0.15s ease",
|
|
3102
|
+
border: "none",
|
|
3103
|
+
"&:hover": {
|
|
3104
|
+
backgroundColor: `${tokens.colorBrandBackground} !important`,
|
|
3105
|
+
color: tokens.colorNeutralForegroundStaticInverted
|
|
3106
|
+
}
|
|
3107
|
+
}
|
|
3108
|
+
},
|
|
3109
|
+
rangeStart: {
|
|
3110
|
+
backgroundColor: `${tokens.colorBrandBackground} !important`,
|
|
3111
|
+
color: `${tokens.colorNeutralForegroundStaticInverted} !important`,
|
|
3112
|
+
borderTopLeftRadius: "999px !important",
|
|
3113
|
+
borderBottomLeftRadius: "999px !important",
|
|
3114
|
+
fontWeight: tokens.fontWeightSemibold
|
|
3115
|
+
},
|
|
3116
|
+
rangeEnd: {
|
|
3117
|
+
backgroundColor: `${tokens.colorBrandBackground} !important`,
|
|
3118
|
+
color: `${tokens.colorNeutralForegroundOnBrand} !important`,
|
|
3119
|
+
borderTopRightRadius: "999px !important",
|
|
3120
|
+
borderBottomRightRadius: "999px !important",
|
|
3121
|
+
fontWeight: tokens.fontWeightSemibold
|
|
3122
|
+
},
|
|
3123
|
+
rangeMiddle: {
|
|
3124
|
+
backgroundColor: `${tokens.colorBrandBackground} !important`,
|
|
3125
|
+
color: `${tokens.colorNeutralForegroundStaticInverted} !important`,
|
|
3126
|
+
borderRadius: "0px !important"
|
|
3127
|
+
},
|
|
3128
|
+
rangePreview: {
|
|
3129
|
+
backgroundColor: `${tokens.colorBrandBackground} !important`,
|
|
3130
|
+
color: tokens.colorNeutralForegroundStaticInverted,
|
|
3131
|
+
borderRadius: "0px !important",
|
|
3132
|
+
boxShadow: `inset 0 0 0 1px ${tokens.colorBrandStroke1}`
|
|
3133
|
+
},
|
|
3134
|
+
rangeSingle: {
|
|
3135
|
+
backgroundColor: `${tokens.colorBrandBackground} !important`,
|
|
3136
|
+
color: `${tokens.colorNeutralForegroundOnBrand} !important`,
|
|
3137
|
+
borderRadius: "999px !important",
|
|
3138
|
+
fontWeight: tokens.fontWeightSemibold
|
|
3139
|
+
}
|
|
3140
|
+
});
|
|
3141
|
+
var ModalSelectDate = ({
|
|
3142
|
+
open,
|
|
3143
|
+
onClose,
|
|
3144
|
+
title = "Pilih Tanggal",
|
|
3145
|
+
selectedDepartureDate,
|
|
3146
|
+
selectedReturnDate,
|
|
3147
|
+
initialTab = "one-way",
|
|
3148
|
+
showTabs = true,
|
|
3149
|
+
onSelectDepartureDate,
|
|
3150
|
+
onSelectReturnDate,
|
|
3151
|
+
onTabChange,
|
|
3152
|
+
minDate = /* @__PURE__ */ new Date(),
|
|
3153
|
+
maxDate,
|
|
3154
|
+
dateFormat = "DD MMMM YYYY"
|
|
3155
|
+
}) => {
|
|
3156
|
+
const styles = useStyles9();
|
|
3157
|
+
const [selectedDate, setSelectedDate] = useState(selectedDepartureDate);
|
|
3158
|
+
const [selectedEndDate, setSelectedEndDate] = useState(selectedReturnDate);
|
|
3159
|
+
const [hoveredDate, setHoveredDate] = useState();
|
|
3160
|
+
const [activeTab, setActiveTab] = useState(initialTab);
|
|
3161
|
+
const previewEndDate = useMemo(() => {
|
|
3162
|
+
if (selectedEndDate) return selectedEndDate;
|
|
3163
|
+
if (selectedDate && hoveredDate && hoveredDate > selectedDate) {
|
|
3164
|
+
return hoveredDate;
|
|
3165
|
+
}
|
|
3166
|
+
return void 0;
|
|
3167
|
+
}, [hoveredDate, selectedDate, selectedEndDate]);
|
|
3168
|
+
const isSameCalendarDay = (first, second) => {
|
|
3169
|
+
if (!first || !second) return false;
|
|
3170
|
+
return moment(first).isSame(second, "day");
|
|
3171
|
+
};
|
|
3172
|
+
useEffect(() => {
|
|
3173
|
+
if (open) {
|
|
3174
|
+
setSelectedDate(selectedDepartureDate);
|
|
3175
|
+
setSelectedEndDate(selectedReturnDate);
|
|
3176
|
+
setActiveTab(initialTab);
|
|
3177
|
+
setHoveredDate(void 0);
|
|
3178
|
+
}
|
|
3179
|
+
}, [open, selectedDepartureDate, selectedReturnDate, initialTab]);
|
|
3180
|
+
const handleTabChange = (tab) => {
|
|
3181
|
+
setActiveTab(tab);
|
|
3182
|
+
setSelectedEndDate(void 0);
|
|
3183
|
+
setHoveredDate(void 0);
|
|
3184
|
+
if (onTabChange) {
|
|
3185
|
+
onTabChange(tab);
|
|
3186
|
+
}
|
|
3187
|
+
};
|
|
3188
|
+
const handleClose = () => {
|
|
3189
|
+
setHoveredDate(void 0);
|
|
3190
|
+
onClose();
|
|
3191
|
+
};
|
|
3192
|
+
const handleDateSelect = (date) => {
|
|
3193
|
+
if (!date) return;
|
|
3194
|
+
const currentStart = selectedDate;
|
|
3195
|
+
if (activeTab === "round-trip") {
|
|
3196
|
+
if (!currentStart || selectedEndDate) {
|
|
3197
|
+
setSelectedDate(date);
|
|
3198
|
+
setSelectedEndDate(void 0);
|
|
3199
|
+
setHoveredDate(void 0);
|
|
3200
|
+
onSelectDepartureDate(date);
|
|
3201
|
+
} else {
|
|
3202
|
+
if (date < currentStart) {
|
|
3203
|
+
setSelectedEndDate(currentStart);
|
|
3204
|
+
setSelectedDate(date);
|
|
3205
|
+
onSelectDepartureDate(date);
|
|
3206
|
+
if (onSelectReturnDate) {
|
|
3207
|
+
onSelectReturnDate(currentStart);
|
|
3208
|
+
}
|
|
3209
|
+
} else {
|
|
3210
|
+
setSelectedEndDate(date);
|
|
3211
|
+
if (onSelectReturnDate) {
|
|
3212
|
+
onSelectReturnDate(date);
|
|
3213
|
+
}
|
|
3214
|
+
}
|
|
3215
|
+
setHoveredDate(void 0);
|
|
3216
|
+
handleClose();
|
|
3217
|
+
}
|
|
3218
|
+
} else {
|
|
3219
|
+
setSelectedDate(date);
|
|
3220
|
+
onSelectDepartureDate(date);
|
|
3221
|
+
handleClose();
|
|
3222
|
+
}
|
|
3223
|
+
};
|
|
3224
|
+
const handleCustomDayCellRef = useCallback(
|
|
3225
|
+
(element, date, _classNames) => {
|
|
3226
|
+
if (!element) return;
|
|
3227
|
+
const removeTokens = (className) => {
|
|
3228
|
+
className?.split(/\s+/).filter(Boolean).forEach((token) => element.classList.remove(token));
|
|
3229
|
+
};
|
|
3230
|
+
const addTokens = (className) => {
|
|
3231
|
+
className?.split(/\s+/).filter(Boolean).forEach((token) => element.classList.add(token));
|
|
3232
|
+
};
|
|
3233
|
+
const removableClasses = [
|
|
3234
|
+
styles.rangeStart,
|
|
3235
|
+
styles.rangeEnd,
|
|
3236
|
+
styles.rangeMiddle,
|
|
3237
|
+
styles.rangePreview,
|
|
3238
|
+
styles.rangeSingle
|
|
3239
|
+
];
|
|
3240
|
+
removableClasses.forEach(removeTokens);
|
|
3241
|
+
if (activeTab !== "round-trip" || !selectedDate) {
|
|
3242
|
+
element.onmouseenter = null;
|
|
3243
|
+
element.onmouseleave = null;
|
|
3244
|
+
return;
|
|
3245
|
+
}
|
|
3246
|
+
const endDateForVisual = previewEndDate;
|
|
3247
|
+
const startTime = selectedDate.getTime();
|
|
3248
|
+
const endTime = endDateForVisual?.getTime();
|
|
3249
|
+
const currentTime = date.getTime();
|
|
3250
|
+
const isSameStartEnd = isSameCalendarDay(endDateForVisual, selectedDate);
|
|
3251
|
+
const isStartDay = isSameCalendarDay(date, selectedDate);
|
|
3252
|
+
const isEndDay = isSameCalendarDay(date, endDateForVisual);
|
|
3253
|
+
if (isStartDay && (!endDateForVisual || isSameStartEnd)) {
|
|
3254
|
+
addTokens(styles.rangeSingle);
|
|
3255
|
+
} else {
|
|
3256
|
+
if (isStartDay) {
|
|
3257
|
+
addTokens(styles.rangeStart);
|
|
3258
|
+
}
|
|
3259
|
+
if (isEndDay && !isSameStartEnd) {
|
|
3260
|
+
addTokens(styles.rangeEnd);
|
|
3261
|
+
}
|
|
3262
|
+
}
|
|
3263
|
+
if (endTime && currentTime > startTime && currentTime < endTime) {
|
|
3264
|
+
addTokens(selectedEndDate ? styles.rangeMiddle : styles.rangePreview);
|
|
3265
|
+
}
|
|
3266
|
+
if (!selectedEndDate) {
|
|
3267
|
+
element.onmouseenter = () => {
|
|
3268
|
+
if (date < selectedDate) return;
|
|
3269
|
+
setHoveredDate((prev) => {
|
|
3270
|
+
if (isSameCalendarDay(prev, date)) {
|
|
3271
|
+
return prev;
|
|
3272
|
+
}
|
|
3273
|
+
return date;
|
|
3274
|
+
});
|
|
3275
|
+
};
|
|
3276
|
+
element.onmouseleave = () => {
|
|
3277
|
+
setHoveredDate(void 0);
|
|
3278
|
+
};
|
|
3279
|
+
} else {
|
|
3280
|
+
element.onmouseenter = null;
|
|
3281
|
+
element.onmouseleave = null;
|
|
3282
|
+
}
|
|
3283
|
+
},
|
|
3284
|
+
[
|
|
3285
|
+
activeTab,
|
|
3286
|
+
previewEndDate,
|
|
3287
|
+
selectedDate,
|
|
3288
|
+
selectedEndDate,
|
|
3289
|
+
styles.rangeEnd,
|
|
3290
|
+
styles.rangeMiddle,
|
|
3291
|
+
styles.rangePreview,
|
|
3292
|
+
styles.rangeSingle,
|
|
3293
|
+
styles.rangeStart
|
|
3294
|
+
]
|
|
3295
|
+
);
|
|
3296
|
+
return /* @__PURE__ */ jsx(
|
|
3297
|
+
Dialog,
|
|
3298
|
+
{
|
|
3299
|
+
open,
|
|
3300
|
+
onOpenChange: (_, data) => {
|
|
3301
|
+
if (!data.open) {
|
|
3302
|
+
onClose();
|
|
3303
|
+
}
|
|
3304
|
+
},
|
|
3305
|
+
children: /* @__PURE__ */ jsx(DialogSurface, { className: styles.dialogSurface, children: /* @__PURE__ */ jsxs(DialogBody, { children: [
|
|
3306
|
+
/* @__PURE__ */ jsx(
|
|
3307
|
+
DialogTitle,
|
|
3308
|
+
{
|
|
3309
|
+
action: /* @__PURE__ */ jsx(
|
|
3310
|
+
Button,
|
|
3311
|
+
{
|
|
3312
|
+
appearance: "subtle",
|
|
3313
|
+
"aria-label": "close",
|
|
3314
|
+
icon: /* @__PURE__ */ jsx(Icon, { icon: "fluent:dismiss-24-regular" }),
|
|
3315
|
+
onClick: handleClose,
|
|
3316
|
+
className: styles.closeButton
|
|
3317
|
+
}
|
|
3318
|
+
),
|
|
3319
|
+
children: title
|
|
3320
|
+
}
|
|
3321
|
+
),
|
|
3322
|
+
/* @__PURE__ */ jsxs(DialogContent, { className: styles.content, children: [
|
|
3323
|
+
showTabs && /* @__PURE__ */ jsxs("div", { className: styles.tabContainer, children: [
|
|
3324
|
+
/* @__PURE__ */ jsx(
|
|
3325
|
+
"button",
|
|
3326
|
+
{
|
|
3327
|
+
disabled: activeTab === "round-trip",
|
|
3328
|
+
className: `${styles.tab} ${activeTab === "one-way" ? styles.tabActive : ""}`,
|
|
3329
|
+
onClick: () => handleTabChange("one-way"),
|
|
3330
|
+
children: "Sekali Jalan"
|
|
3331
|
+
}
|
|
3332
|
+
),
|
|
3333
|
+
/* @__PURE__ */ jsx(
|
|
3334
|
+
"button",
|
|
3335
|
+
{
|
|
3336
|
+
className: `${styles.tab} ${activeTab === "round-trip" ? styles.tabActive : ""}`,
|
|
3337
|
+
onClick: () => handleTabChange("round-trip"),
|
|
3338
|
+
disabled: activeTab === "one-way",
|
|
3339
|
+
children: "Pulang Pergi"
|
|
3340
|
+
}
|
|
3341
|
+
)
|
|
3342
|
+
] }),
|
|
3343
|
+
/* @__PURE__ */ jsx("div", { className: styles.calendarContainer, children: /* @__PURE__ */ jsx("div", { style: { width: "100%" }, children: /* @__PURE__ */ jsx("div", { className: activeTab === "round-trip" ? styles.rangeCalendar : "", children: /* @__PURE__ */ jsx(
|
|
3344
|
+
Calendar,
|
|
3345
|
+
{
|
|
3346
|
+
minDate,
|
|
3347
|
+
maxDate,
|
|
3348
|
+
value: selectedDate,
|
|
3349
|
+
onSelectDate: handleDateSelect,
|
|
3350
|
+
showGoToToday: true,
|
|
3351
|
+
highlightSelectedMonth: true,
|
|
3352
|
+
showMonthPickerAsOverlay: false,
|
|
3353
|
+
allFocusable: true,
|
|
3354
|
+
calendarDayProps: {
|
|
3355
|
+
customDayCellRef: handleCustomDayCellRef
|
|
3356
|
+
}
|
|
3357
|
+
}
|
|
3358
|
+
) }) }) })
|
|
3359
|
+
] })
|
|
3360
|
+
] }) })
|
|
3361
|
+
}
|
|
3362
|
+
);
|
|
3363
|
+
};
|
|
3364
|
+
var useStyles10 = makeStyles({
|
|
3365
|
+
dialogSurface: {
|
|
3366
|
+
maxWidth: "600px",
|
|
3367
|
+
width: "100%"
|
|
3368
|
+
},
|
|
3369
|
+
content: {
|
|
3370
|
+
display: "flex",
|
|
3371
|
+
flexDirection: "column",
|
|
3372
|
+
gap: "0px",
|
|
3373
|
+
paddingTop: "10px",
|
|
3374
|
+
paddingLeft: "10px",
|
|
3375
|
+
paddingRight: "10px"
|
|
3376
|
+
},
|
|
3377
|
+
closeButton: {
|
|
3378
|
+
minWidth: "32px",
|
|
3379
|
+
minHeight: "32px"
|
|
3380
|
+
},
|
|
3381
|
+
headerRow: {
|
|
3382
|
+
display: "flex",
|
|
3383
|
+
justifyContent: "end",
|
|
3384
|
+
alignItems: "center",
|
|
3385
|
+
borderBottom: `1px solid ${tokens.colorNeutralStroke2}`
|
|
3386
|
+
},
|
|
3387
|
+
serviceList: {
|
|
3388
|
+
display: "flex",
|
|
3389
|
+
flexDirection: "column",
|
|
3390
|
+
gap: "0px",
|
|
3391
|
+
maxHeight: "400px",
|
|
3392
|
+
overflowY: "auto",
|
|
3393
|
+
paddingLeft: "20px"
|
|
3394
|
+
},
|
|
3395
|
+
serviceItem: {
|
|
3396
|
+
padding: "16px 0px",
|
|
3397
|
+
borderBottom: `1px solid ${tokens.colorNeutralStroke2}`,
|
|
3398
|
+
display: "flex",
|
|
3399
|
+
alignItems: "flex-start",
|
|
3400
|
+
gap: "12px",
|
|
3401
|
+
cursor: "pointer",
|
|
3402
|
+
transition: "background-color 0.2s ease",
|
|
3403
|
+
":hover": {
|
|
3404
|
+
backgroundColor: tokens.colorNeutralBackground1Hover
|
|
3405
|
+
}
|
|
3406
|
+
},
|
|
3407
|
+
serviceContent: {
|
|
3408
|
+
flex: 1,
|
|
3409
|
+
display: "flex",
|
|
3410
|
+
flexDirection: "column",
|
|
3411
|
+
gap: "4px"
|
|
3412
|
+
},
|
|
3413
|
+
serviceName: {
|
|
3414
|
+
fontSize: tokens.fontSizeBase300,
|
|
3415
|
+
fontWeight: tokens.fontWeightSemibold,
|
|
3416
|
+
color: tokens.colorNeutralForeground1
|
|
3417
|
+
},
|
|
3418
|
+
serviceType: {
|
|
3419
|
+
fontSize: tokens.fontSizeBase200,
|
|
3420
|
+
fontWeight: tokens.fontWeightRegular,
|
|
3421
|
+
color: tokens.colorNeutralForeground2
|
|
3422
|
+
},
|
|
3423
|
+
serviceDescription: {
|
|
3424
|
+
fontSize: tokens.fontSizeBase200,
|
|
3425
|
+
color: tokens.colorNeutralForeground3,
|
|
3426
|
+
lineHeight: "1.4"
|
|
3427
|
+
},
|
|
3428
|
+
footer: {
|
|
3429
|
+
padding: "16px 20px",
|
|
3430
|
+
borderTop: `1px solid ${tokens.colorNeutralStroke2}`
|
|
3431
|
+
},
|
|
3432
|
+
saveButton: {
|
|
3433
|
+
width: "100%",
|
|
3434
|
+
borderRadius: tokens.borderRadiusCircular
|
|
3435
|
+
}
|
|
3436
|
+
});
|
|
3437
|
+
var ModalService = ({
|
|
3438
|
+
open,
|
|
3439
|
+
onClose,
|
|
3440
|
+
title = "Pilih Kelas Layanan",
|
|
3441
|
+
services,
|
|
3442
|
+
selectedServiceIds,
|
|
3443
|
+
onSave,
|
|
3444
|
+
isLoading = false,
|
|
3445
|
+
isError = false
|
|
3446
|
+
}) => {
|
|
3447
|
+
const styles = useStyles10();
|
|
3448
|
+
const [selectedServices, setSelectedServices] = useState(selectedServiceIds);
|
|
3449
|
+
useEffect(() => {
|
|
3450
|
+
if (open) {
|
|
3451
|
+
if (selectedServiceIds && selectedServiceIds.length > 0) {
|
|
3452
|
+
const validIds = services.filter((s) => selectedServiceIds.includes(s.id)).map((s) => s.id);
|
|
3453
|
+
setSelectedServices(validIds);
|
|
3454
|
+
} else {
|
|
3455
|
+
setSelectedServices(services.map((s) => s.id));
|
|
3456
|
+
}
|
|
3457
|
+
}
|
|
3458
|
+
}, [open, services, selectedServiceIds]);
|
|
3459
|
+
const handleClose = () => {
|
|
3460
|
+
onClose();
|
|
3461
|
+
};
|
|
3462
|
+
const handleToggleService = (serviceId) => {
|
|
3463
|
+
setSelectedServices((prev) => {
|
|
3464
|
+
if (prev.includes(serviceId)) {
|
|
3465
|
+
return prev.filter((id) => id !== serviceId);
|
|
3466
|
+
} else {
|
|
3467
|
+
return [...prev, serviceId];
|
|
3468
|
+
}
|
|
3469
|
+
});
|
|
3470
|
+
};
|
|
3471
|
+
const handleToggleAll = () => {
|
|
3472
|
+
if (selectedServices.length === services.length) {
|
|
3473
|
+
setSelectedServices([]);
|
|
3474
|
+
} else {
|
|
3475
|
+
setSelectedServices(services.map((s) => s.id));
|
|
3476
|
+
}
|
|
3477
|
+
};
|
|
3478
|
+
const handleSave = () => {
|
|
3479
|
+
const selectedServiceItems = services.filter((s) => selectedServices.includes(s.id));
|
|
3480
|
+
onSave(selectedServiceItems);
|
|
3481
|
+
};
|
|
3482
|
+
return /* @__PURE__ */ jsx(
|
|
3483
|
+
Dialog,
|
|
3484
|
+
{
|
|
3485
|
+
open,
|
|
3486
|
+
onOpenChange: (_, data) => !data.open && onClose(),
|
|
3487
|
+
children: /* @__PURE__ */ jsx(DialogSurface, { className: styles.dialogSurface, children: /* @__PURE__ */ jsxs(DialogBody, { children: [
|
|
3488
|
+
/* @__PURE__ */ jsx(
|
|
3489
|
+
DialogTitle,
|
|
3490
|
+
{
|
|
3491
|
+
action: /* @__PURE__ */ jsx(
|
|
3492
|
+
Button,
|
|
3493
|
+
{
|
|
3494
|
+
appearance: "subtle",
|
|
3495
|
+
"aria-label": "close",
|
|
3496
|
+
icon: /* @__PURE__ */ jsx(Icon, { icon: "fluent:dismiss-24-regular" }),
|
|
3497
|
+
onClick: handleClose,
|
|
3498
|
+
className: styles.closeButton
|
|
3499
|
+
}
|
|
3500
|
+
),
|
|
3501
|
+
children: title
|
|
3502
|
+
}
|
|
3503
|
+
),
|
|
3504
|
+
/* @__PURE__ */ jsx(DialogContent, { className: styles.content, children: isLoading ? /* @__PURE__ */ jsx(Body1, { children: "Loading..." }) : isError ? /* @__PURE__ */ jsx(Body1, { children: "Error loading services" }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3505
|
+
/* @__PURE__ */ jsxs("div", { className: styles.serviceList, children: [
|
|
3506
|
+
/* @__PURE__ */ jsxs("div", { className: styles.headerRow, children: [
|
|
3507
|
+
/* @__PURE__ */ jsx(Body1, { children: "Pilih Semua" }),
|
|
3508
|
+
/* @__PURE__ */ jsx(
|
|
3509
|
+
Checkbox,
|
|
3510
|
+
{
|
|
3511
|
+
checked: selectedServices.length === services.length,
|
|
3512
|
+
onChange: handleToggleAll
|
|
3513
|
+
}
|
|
3514
|
+
)
|
|
3515
|
+
] }),
|
|
3516
|
+
services.map((service) => /* @__PURE__ */ jsxs(
|
|
3517
|
+
"div",
|
|
3518
|
+
{
|
|
3519
|
+
className: styles.serviceItem,
|
|
3520
|
+
onClick: () => handleToggleService(service.id),
|
|
3521
|
+
children: [
|
|
3522
|
+
/* @__PURE__ */ jsxs("div", { className: styles.serviceContent, children: [
|
|
3523
|
+
/* @__PURE__ */ jsx(Body1, { className: styles.serviceName, children: service.serviceTypeName }),
|
|
3524
|
+
/* @__PURE__ */ jsx(Caption1, { className: styles.serviceType, children: service.serviceTypeCode }),
|
|
3525
|
+
/* @__PURE__ */ jsx(Caption1, { className: styles.serviceDescription, children: service.serviceDescription })
|
|
3526
|
+
] }),
|
|
3527
|
+
/* @__PURE__ */ jsx(
|
|
3528
|
+
Checkbox,
|
|
3529
|
+
{
|
|
3530
|
+
checked: selectedServices.includes(service.id),
|
|
3531
|
+
onChange: () => handleToggleService(service.id)
|
|
3532
|
+
}
|
|
3533
|
+
)
|
|
3534
|
+
]
|
|
3535
|
+
},
|
|
3536
|
+
service.id
|
|
3537
|
+
))
|
|
3538
|
+
] }),
|
|
3539
|
+
/* @__PURE__ */ jsx("div", { className: styles.footer, children: /* @__PURE__ */ jsx(
|
|
3540
|
+
Button,
|
|
3541
|
+
{
|
|
3542
|
+
appearance: "primary",
|
|
3543
|
+
size: "medium",
|
|
3544
|
+
className: styles.saveButton,
|
|
3545
|
+
onClick: handleSave,
|
|
3546
|
+
disabled: selectedServices.length === 0,
|
|
3547
|
+
children: "Simpan"
|
|
3548
|
+
}
|
|
3549
|
+
) })
|
|
3550
|
+
] }) })
|
|
3551
|
+
] }) })
|
|
3552
|
+
}
|
|
3553
|
+
);
|
|
3554
|
+
};
|
|
3038
3555
|
|
|
3039
|
-
export { BackgroundTicketCard_default as BackgroundTicketCard, BackgroundTicketCardVertical_default as BackgroundTicketCardVertical, CardBanner, CardPromo, CardServiceMenu, CardTicket, CarouselWithCustomNav, DEFAULT_COUNTRY_CODES2 as DEFAULT_COUNTRY_CODES, InputDynamic_default as InputDynamic, MODAL_PRESETS, ModalIllustration, ModalSearchHarbor, getModalPreset };
|
|
3556
|
+
export { BackgroundTicketCard_default as BackgroundTicketCard, BackgroundTicketCardVertical_default as BackgroundTicketCardVertical, CardBanner, CardPromo, CardServiceMenu, CardTicket, CarouselWithCustomNav, DEFAULT_COUNTRY_CODES2 as DEFAULT_COUNTRY_CODES, InputDynamic_default as InputDynamic, MODAL_PRESETS, ModalIllustration, ModalSearchHarbor, ModalSelectDate, ModalService, getModalPreset };
|
|
3040
3557
|
//# sourceMappingURL=index.mjs.map
|
|
3041
3558
|
//# sourceMappingURL=index.mjs.map
|