@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.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,522 @@ 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
|
+
};
|
|
3373
|
+
var useStyles10 = reactComponents.makeStyles({
|
|
3374
|
+
dialogSurface: {
|
|
3375
|
+
maxWidth: "600px",
|
|
3376
|
+
width: "100%"
|
|
3377
|
+
},
|
|
3378
|
+
content: {
|
|
3379
|
+
display: "flex",
|
|
3380
|
+
flexDirection: "column",
|
|
3381
|
+
gap: "0px",
|
|
3382
|
+
paddingTop: "10px",
|
|
3383
|
+
paddingLeft: "10px",
|
|
3384
|
+
paddingRight: "10px"
|
|
3385
|
+
},
|
|
3386
|
+
closeButton: {
|
|
3387
|
+
minWidth: "32px",
|
|
3388
|
+
minHeight: "32px"
|
|
3389
|
+
},
|
|
3390
|
+
headerRow: {
|
|
3391
|
+
display: "flex",
|
|
3392
|
+
justifyContent: "end",
|
|
3393
|
+
alignItems: "center",
|
|
3394
|
+
borderBottom: `1px solid ${reactComponents.tokens.colorNeutralStroke2}`
|
|
3395
|
+
},
|
|
3396
|
+
serviceList: {
|
|
3397
|
+
display: "flex",
|
|
3398
|
+
flexDirection: "column",
|
|
3399
|
+
gap: "0px",
|
|
3400
|
+
maxHeight: "400px",
|
|
3401
|
+
overflowY: "auto",
|
|
3402
|
+
paddingLeft: "20px"
|
|
3403
|
+
},
|
|
3404
|
+
serviceItem: {
|
|
3405
|
+
padding: "16px 0px",
|
|
3406
|
+
borderBottom: `1px solid ${reactComponents.tokens.colorNeutralStroke2}`,
|
|
3407
|
+
display: "flex",
|
|
3408
|
+
alignItems: "flex-start",
|
|
3409
|
+
gap: "12px",
|
|
3410
|
+
cursor: "pointer",
|
|
3411
|
+
transition: "background-color 0.2s ease",
|
|
3412
|
+
":hover": {
|
|
3413
|
+
backgroundColor: reactComponents.tokens.colorNeutralBackground1Hover
|
|
3414
|
+
}
|
|
3415
|
+
},
|
|
3416
|
+
serviceContent: {
|
|
3417
|
+
flex: 1,
|
|
3418
|
+
display: "flex",
|
|
3419
|
+
flexDirection: "column",
|
|
3420
|
+
gap: "4px"
|
|
3421
|
+
},
|
|
3422
|
+
serviceName: {
|
|
3423
|
+
fontSize: reactComponents.tokens.fontSizeBase300,
|
|
3424
|
+
fontWeight: reactComponents.tokens.fontWeightSemibold,
|
|
3425
|
+
color: reactComponents.tokens.colorNeutralForeground1
|
|
3426
|
+
},
|
|
3427
|
+
serviceType: {
|
|
3428
|
+
fontSize: reactComponents.tokens.fontSizeBase200,
|
|
3429
|
+
fontWeight: reactComponents.tokens.fontWeightRegular,
|
|
3430
|
+
color: reactComponents.tokens.colorNeutralForeground2
|
|
3431
|
+
},
|
|
3432
|
+
serviceDescription: {
|
|
3433
|
+
fontSize: reactComponents.tokens.fontSizeBase200,
|
|
3434
|
+
color: reactComponents.tokens.colorNeutralForeground3,
|
|
3435
|
+
lineHeight: "1.4"
|
|
3436
|
+
},
|
|
3437
|
+
footer: {
|
|
3438
|
+
padding: "16px 20px",
|
|
3439
|
+
borderTop: `1px solid ${reactComponents.tokens.colorNeutralStroke2}`
|
|
3440
|
+
},
|
|
3441
|
+
saveButton: {
|
|
3442
|
+
width: "100%",
|
|
3443
|
+
borderRadius: reactComponents.tokens.borderRadiusCircular
|
|
3444
|
+
}
|
|
3445
|
+
});
|
|
3446
|
+
var ModalService = ({
|
|
3447
|
+
open,
|
|
3448
|
+
onClose,
|
|
3449
|
+
title = "Pilih Kelas Layanan",
|
|
3450
|
+
services,
|
|
3451
|
+
selectedServiceIds,
|
|
3452
|
+
onSave,
|
|
3453
|
+
isLoading = false,
|
|
3454
|
+
isError = false
|
|
3455
|
+
}) => {
|
|
3456
|
+
const styles = useStyles10();
|
|
3457
|
+
const [selectedServices, setSelectedServices] = React2.useState(selectedServiceIds);
|
|
3458
|
+
React2.useEffect(() => {
|
|
3459
|
+
if (open) {
|
|
3460
|
+
if (selectedServiceIds && selectedServiceIds.length > 0) {
|
|
3461
|
+
const validIds = services.filter((s) => selectedServiceIds.includes(s.id)).map((s) => s.id);
|
|
3462
|
+
setSelectedServices(validIds);
|
|
3463
|
+
} else {
|
|
3464
|
+
setSelectedServices(services.map((s) => s.id));
|
|
3465
|
+
}
|
|
3466
|
+
}
|
|
3467
|
+
}, [open, services, selectedServiceIds]);
|
|
3468
|
+
const handleClose = () => {
|
|
3469
|
+
onClose();
|
|
3470
|
+
};
|
|
3471
|
+
const handleToggleService = (serviceId) => {
|
|
3472
|
+
setSelectedServices((prev) => {
|
|
3473
|
+
if (prev.includes(serviceId)) {
|
|
3474
|
+
return prev.filter((id) => id !== serviceId);
|
|
3475
|
+
} else {
|
|
3476
|
+
return [...prev, serviceId];
|
|
3477
|
+
}
|
|
3478
|
+
});
|
|
3479
|
+
};
|
|
3480
|
+
const handleToggleAll = () => {
|
|
3481
|
+
if (selectedServices.length === services.length) {
|
|
3482
|
+
setSelectedServices([]);
|
|
3483
|
+
} else {
|
|
3484
|
+
setSelectedServices(services.map((s) => s.id));
|
|
3485
|
+
}
|
|
3486
|
+
};
|
|
3487
|
+
const handleSave = () => {
|
|
3488
|
+
const selectedServiceItems = services.filter((s) => selectedServices.includes(s.id));
|
|
3489
|
+
onSave(selectedServiceItems);
|
|
3490
|
+
};
|
|
3491
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3492
|
+
reactComponents.Dialog,
|
|
3493
|
+
{
|
|
3494
|
+
open,
|
|
3495
|
+
onOpenChange: (_, data) => !data.open && onClose(),
|
|
3496
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactComponents.DialogSurface, { className: styles.dialogSurface, children: /* @__PURE__ */ jsxRuntime.jsxs(reactComponents.DialogBody, { children: [
|
|
3497
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3498
|
+
reactComponents.DialogTitle,
|
|
3499
|
+
{
|
|
3500
|
+
action: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3501
|
+
reactComponents.Button,
|
|
3502
|
+
{
|
|
3503
|
+
appearance: "subtle",
|
|
3504
|
+
"aria-label": "close",
|
|
3505
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(react.Icon, { icon: "fluent:dismiss-24-regular" }),
|
|
3506
|
+
onClick: handleClose,
|
|
3507
|
+
className: styles.closeButton
|
|
3508
|
+
}
|
|
3509
|
+
),
|
|
3510
|
+
children: title
|
|
3511
|
+
}
|
|
3512
|
+
),
|
|
3513
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactComponents.DialogContent, { className: styles.content, children: isLoading ? /* @__PURE__ */ jsxRuntime.jsx(reactComponents.Body1, { children: "Loading..." }) : isError ? /* @__PURE__ */ jsxRuntime.jsx(reactComponents.Body1, { children: "Error loading services" }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3514
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles.serviceList, children: [
|
|
3515
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles.headerRow, children: [
|
|
3516
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactComponents.Body1, { children: "Pilih Semua" }),
|
|
3517
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3518
|
+
reactComponents.Checkbox,
|
|
3519
|
+
{
|
|
3520
|
+
checked: selectedServices.length === services.length,
|
|
3521
|
+
onChange: handleToggleAll
|
|
3522
|
+
}
|
|
3523
|
+
)
|
|
3524
|
+
] }),
|
|
3525
|
+
services.map((service) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3526
|
+
"div",
|
|
3527
|
+
{
|
|
3528
|
+
className: styles.serviceItem,
|
|
3529
|
+
onClick: () => handleToggleService(service.id),
|
|
3530
|
+
children: [
|
|
3531
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles.serviceContent, children: [
|
|
3532
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactComponents.Body1, { className: styles.serviceName, children: service.serviceTypeName }),
|
|
3533
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactComponents.Caption1, { className: styles.serviceType, children: service.serviceTypeCode }),
|
|
3534
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactComponents.Caption1, { className: styles.serviceDescription, children: service.serviceDescription })
|
|
3535
|
+
] }),
|
|
3536
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3537
|
+
reactComponents.Checkbox,
|
|
3538
|
+
{
|
|
3539
|
+
checked: selectedServices.includes(service.id),
|
|
3540
|
+
onChange: () => handleToggleService(service.id)
|
|
3541
|
+
}
|
|
3542
|
+
)
|
|
3543
|
+
]
|
|
3544
|
+
},
|
|
3545
|
+
service.id
|
|
3546
|
+
))
|
|
3547
|
+
] }),
|
|
3548
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: styles.footer, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3549
|
+
reactComponents.Button,
|
|
3550
|
+
{
|
|
3551
|
+
appearance: "primary",
|
|
3552
|
+
size: "medium",
|
|
3553
|
+
className: styles.saveButton,
|
|
3554
|
+
onClick: handleSave,
|
|
3555
|
+
disabled: selectedServices.length === 0,
|
|
3556
|
+
children: "Simpan"
|
|
3557
|
+
}
|
|
3558
|
+
) })
|
|
3559
|
+
] }) })
|
|
3560
|
+
] }) })
|
|
3561
|
+
}
|
|
3562
|
+
);
|
|
3563
|
+
};
|
|
3046
3564
|
|
|
3047
3565
|
exports.BackgroundTicketCard = BackgroundTicketCard_default;
|
|
3048
3566
|
exports.BackgroundTicketCardVertical = BackgroundTicketCardVertical_default;
|
|
@@ -3056,6 +3574,8 @@ exports.InputDynamic = InputDynamic_default;
|
|
|
3056
3574
|
exports.MODAL_PRESETS = MODAL_PRESETS;
|
|
3057
3575
|
exports.ModalIllustration = ModalIllustration;
|
|
3058
3576
|
exports.ModalSearchHarbor = ModalSearchHarbor;
|
|
3577
|
+
exports.ModalSelectDate = ModalSelectDate;
|
|
3578
|
+
exports.ModalService = ModalService;
|
|
3059
3579
|
exports.getModalPreset = getModalPreset;
|
|
3060
3580
|
//# sourceMappingURL=index.js.map
|
|
3061
3581
|
//# sourceMappingURL=index.js.map
|