@mamrp/components 1.3.2 → 1.4.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.
@@ -0,0 +1,737 @@
1
+ // react-shim.js
2
+ import * as React from "react";
3
+
4
+ // src/date-pickers/date-range-picker/index.tsx
5
+ import React2, { useState, useEffect } from "react";
6
+ import {
7
+ Box,
8
+ Typography,
9
+ CircularProgress,
10
+ Popover,
11
+ TextField,
12
+ Button,
13
+ useMediaQuery,
14
+ IconButton
15
+ } from "@mui/material";
16
+ import {
17
+ MdClear,
18
+ MdDateRange,
19
+ MdEvent,
20
+ MdPerson,
21
+ MdGpsFixed,
22
+ MdCheckCircle,
23
+ MdTipsAndUpdates
24
+ } from "react-icons/md";
25
+ import { useController } from "react-hook-form";
26
+ import {
27
+ StaticDatePicker,
28
+ DatePicker,
29
+ PickersDay,
30
+ LocalizationProvider
31
+ } from "@mui/x-date-pickers";
32
+ import { AdapterMomentJalaali } from "@mui/x-date-pickers/AdapterMomentJalaali";
33
+ import moment from "moment-jalaali";
34
+ moment.locale("fa");
35
+ moment.loadPersian({ dialect: "persian-modern", usePersianDigits: true });
36
+ var DateRangePicker = ({
37
+ fromDate,
38
+ toDate,
39
+ fromViews = ["year", "month", "day"],
40
+ fromOpenTo = "day",
41
+ toViews = ["year", "month", "day"],
42
+ toOpenTo = "day",
43
+ control,
44
+ label = "\u0627\u0646\u062A\u062E\u0627\u0628 \u0628\u0627\u0632\u0647",
45
+ size = "medium",
46
+ disabled = false,
47
+ persian = true,
48
+ align = "left",
49
+ isLoading = false,
50
+ minDate,
51
+ maxDate,
52
+ clear = true,
53
+ singleCalendar = false,
54
+ // Default to dual calendars on desktop
55
+ useMobilePickers = false,
56
+ // Default to calendar popup style
57
+ dualCalendar = false
58
+ // Default to single calendar with smart tabs
59
+ }) => {
60
+ const [open, setOpen] = useState(false);
61
+ const [anchorEl, setAnchorEl] = useState(null);
62
+ const [tempStartDate, setTempStartDate] = useState(null);
63
+ const [tempEndDate, setTempEndDate] = useState(null);
64
+ const [secondCalendarMonth, setSecondCalendarMonth] = useState(moment());
65
+ const [activeTab, setActiveTab] = useState("from");
66
+ const [autoSelectMode, setAutoSelectMode] = useState(true);
67
+ const isMobile = useMediaQuery("(max-width:700px)");
68
+ const showSingleCalendar = isMobile || singleCalendar || !dualCalendar;
69
+ const {
70
+ field: fieldFrom,
71
+ fieldState: { error: errorFrom }
72
+ } = useController({ name: fromDate, control });
73
+ const {
74
+ field: fieldTo,
75
+ fieldState: { error: errorTo }
76
+ } = useController({ name: toDate, control });
77
+ const handleOpen = (event) => {
78
+ if (!disabled && !isLoading) {
79
+ setAnchorEl(event.currentTarget);
80
+ setOpen(true);
81
+ }
82
+ };
83
+ const handleClose = () => {
84
+ setOpen(false);
85
+ setTempStartDate(null);
86
+ setTempEndDate(null);
87
+ };
88
+ useEffect(() => {
89
+ if (open) {
90
+ if (fieldFrom.value) {
91
+ setTempStartDate(moment(fieldFrom.value));
92
+ setSecondCalendarMonth(moment(fieldFrom.value));
93
+ } else {
94
+ setSecondCalendarMonth(moment());
95
+ }
96
+ if (fieldTo.value) {
97
+ setTempEndDate(moment(fieldTo.value));
98
+ }
99
+ }
100
+ }, [open, fieldFrom.value, fieldTo.value]);
101
+ const handleDaySelect = (day, calendarSide) => {
102
+ if (!dualCalendar && showSingleCalendar) {
103
+ if (autoSelectMode) {
104
+ if (!tempStartDate && !tempEndDate) {
105
+ setTempStartDate(day);
106
+ setActiveTab("to");
107
+ } else if (tempStartDate && !tempEndDate) {
108
+ if (day.isBefore(tempStartDate)) {
109
+ setTempEndDate(tempStartDate);
110
+ setTempStartDate(day);
111
+ } else {
112
+ setTempEndDate(day);
113
+ }
114
+ } else if (!tempStartDate && tempEndDate) {
115
+ if (day.isAfter(tempEndDate)) {
116
+ setTempStartDate(tempEndDate);
117
+ setTempEndDate(day);
118
+ } else {
119
+ setTempStartDate(day);
120
+ }
121
+ } else {
122
+ setTempStartDate(day);
123
+ setTempEndDate(null);
124
+ setActiveTab("to");
125
+ }
126
+ } else {
127
+ if (activeTab === "from") {
128
+ setTempStartDate(day);
129
+ setActiveTab("to");
130
+ } else {
131
+ setTempEndDate(day);
132
+ setActiveTab("from");
133
+ }
134
+ }
135
+ } else {
136
+ if (!tempStartDate && !tempEndDate) {
137
+ if (calendarSide === "right") {
138
+ setTempStartDate(day);
139
+ } else {
140
+ setTempEndDate(day);
141
+ }
142
+ } else if (tempStartDate && tempEndDate) {
143
+ setTempStartDate(day);
144
+ setTempEndDate(null);
145
+ } else if (tempStartDate && !tempEndDate) {
146
+ if (day.isBefore(tempStartDate)) {
147
+ setTempEndDate(tempStartDate);
148
+ setTempStartDate(day);
149
+ } else {
150
+ setTempEndDate(day);
151
+ }
152
+ } else if (!tempStartDate && tempEndDate) {
153
+ if (day.isAfter(tempEndDate)) {
154
+ setTempStartDate(tempEndDate);
155
+ setTempEndDate(day);
156
+ } else {
157
+ setTempStartDate(day);
158
+ }
159
+ }
160
+ }
161
+ };
162
+ const handleConfirm = () => {
163
+ if (tempStartDate) {
164
+ fieldFrom.onChange(tempStartDate.locale("en").format("YYYY-MM-DD"));
165
+ }
166
+ if (tempEndDate) {
167
+ fieldTo.onChange(tempEndDate.locale("en").format("YYYY-MM-DD"));
168
+ }
169
+ setOpen(false);
170
+ setTempStartDate(null);
171
+ setTempEndDate(null);
172
+ };
173
+ const handleClear = () => {
174
+ fieldFrom.onChange(null);
175
+ fieldTo.onChange(null);
176
+ setTempStartDate(null);
177
+ setTempEndDate(null);
178
+ setActiveTab("from");
179
+ };
180
+ const handleInputClear = (event) => {
181
+ event.stopPropagation();
182
+ fieldFrom.onChange(null);
183
+ fieldTo.onChange(null);
184
+ setTempStartDate(null);
185
+ setTempEndDate(null);
186
+ setActiveTab("from");
187
+ };
188
+ const displayValue = () => {
189
+ const start = fieldFrom.value ? moment(fieldFrom.value) : null;
190
+ const end = fieldTo.value ? moment(fieldTo.value) : null;
191
+ if (start && end) {
192
+ return persian ? `${end.format("jYYYY/jMM/jDD")} - ${start.format("jYYYY/jMM/jDD")}` : `${end.format("YYYY/MM/DD")} - ${start.format("YYYY/MM/DD")}`;
193
+ } else if (start) {
194
+ return persian ? "\u0627\u0632 \u062A\u0627\u0631\u06CC\u062E " + start.format("jYYYY/jMM/jDD") : start.format("YYYY/MM/DD");
195
+ } else if (end) {
196
+ return persian ? "\u062A\u0627 \u062A\u0627\u0631\u06CC\u062E " + end.format("jYYYY/jMM/jDD") : end.format("YYYY/MM/DD");
197
+ }
198
+ return "";
199
+ };
200
+ const error = errorFrom || errorTo;
201
+ const customLocaleText = {
202
+ cancelButtonLabel: "\u0644\u063A\u0648",
203
+ okButtonLabel: "\u062A\u0623\u06CC\u06CC\u062F",
204
+ todayButtonLabel: "\u0627\u0645\u0631\u0648\u0632",
205
+ clearButtonLabel: "\u067E\u0627\u06A9 \u06A9\u0631\u062F\u0646"
206
+ };
207
+ return /* @__PURE__ */ React2.createElement(
208
+ LocalizationProvider,
209
+ {
210
+ dateAdapter: AdapterMomentJalaali,
211
+ localeText: customLocaleText
212
+ },
213
+ /* @__PURE__ */ React2.createElement(Box, { sx: { width: "100%" } }, /* @__PURE__ */ React2.createElement(
214
+ TextField,
215
+ {
216
+ label,
217
+ size,
218
+ fullWidth: true,
219
+ value: displayValue(),
220
+ onClick: handleOpen,
221
+ disabled: disabled || isLoading,
222
+ placeholder: "\u0627\u0646\u062A\u062E\u0627\u0628 \u0628\u0627\u0632\u0647 \u062A\u0627\u0631\u06CC\u062E",
223
+ error: !!error,
224
+ InputLabelProps: {
225
+ shrink: true
226
+ },
227
+ InputProps: {
228
+ readOnly: true,
229
+ sx: {
230
+ textAlign: align,
231
+ direction: "ltr",
232
+ cursor: disabled ? "default" : "pointer",
233
+ "& input": {
234
+ textAlign: align
235
+ }
236
+ },
237
+ endAdornment: /* @__PURE__ */ React2.createElement(Box, { sx: { display: "flex", alignItems: "center", gap: 0.5 } }, (fieldFrom.value || fieldTo.value) && !disabled && !isLoading && /* @__PURE__ */ React2.createElement(
238
+ IconButton,
239
+ {
240
+ size: "small",
241
+ onClick: handleInputClear,
242
+ sx: {
243
+ padding: "4px",
244
+ color: "text.secondary",
245
+ "&:hover": {
246
+ color: "error.main",
247
+ backgroundColor: "rgba(244, 67, 54, 0.08)"
248
+ }
249
+ }
250
+ },
251
+ /* @__PURE__ */ React2.createElement(MdClear, { size: 16 })
252
+ ), isLoading && /* @__PURE__ */ React2.createElement(CircularProgress, { size: 20, color: "secondary" }))
253
+ },
254
+ sx: {
255
+ "& .MuiOutlinedInput-root": {
256
+ height: size === "small" ? 40 : 56
257
+ }
258
+ }
259
+ }
260
+ ), error && /* @__PURE__ */ React2.createElement(Typography, { fontSize: 13, color: "error", sx: { mt: 0.6, ml: 1 } }, error.message), /* @__PURE__ */ React2.createElement(
261
+ Popover,
262
+ {
263
+ open,
264
+ anchorEl,
265
+ onClose: handleClose,
266
+ anchorOrigin: {
267
+ vertical: "bottom",
268
+ horizontal: "left"
269
+ },
270
+ transformOrigin: {
271
+ vertical: "top",
272
+ horizontal: "left"
273
+ },
274
+ slotProps: {
275
+ paper: {
276
+ sx: {
277
+ mt: 1,
278
+ maxWidth: isMobile ? "95vw" : "auto",
279
+ width: isMobile ? "auto" : "auto",
280
+ maxHeight: isMobile ? "90vh" : "auto",
281
+ overflow: isMobile ? "auto" : "visible"
282
+ }
283
+ }
284
+ }
285
+ },
286
+ /* @__PURE__ */ React2.createElement(Box, { sx: { p: isMobile ? 1 : 2 } }, /* @__PURE__ */ React2.createElement(Box, { sx: { mb: 2 } }, /* @__PURE__ */ React2.createElement(Typography, { variant: "overline", color: "primary" }, "\u0627\u0646\u062A\u062E\u0627\u0628 \u0628\u0627\u0632\u0647 \u062A\u0627\u0631\u06CC\u062E"), /* @__PURE__ */ React2.createElement(Typography, { variant: "body2", color: "text.secondary" }, tempStartDate && tempEndDate ? `${tempStartDate.format("jDD jMMMM")} \u062A\u0627 ${tempEndDate.format("jDD jMMMM")}` : tempStartDate ? `\u0627\u0632 ${tempStartDate.format("jDD jMMMM")}` : "\u062A\u0627\u0631\u06CC\u062E \u0634\u0631\u0648\u0639 \u0648 \u067E\u0627\u06CC\u0627\u0646 \u0631\u0627 \u0627\u0646\u062A\u062E\u0627\u0628 \u06A9\u0646\u06CC\u062F")), useMobilePickers ? (
287
+ // Mobile-style: Use DatePicker inputs
288
+ /* @__PURE__ */ React2.createElement(
289
+ Box,
290
+ {
291
+ sx: {
292
+ display: "flex",
293
+ flexDirection: "column",
294
+ gap: 2,
295
+ alignItems: "center",
296
+ width: "100%"
297
+ }
298
+ },
299
+ /* @__PURE__ */ React2.createElement(Box, { sx: { width: "100%" } }, /* @__PURE__ */ React2.createElement(Typography, { variant: "body2", sx: { mb: 1, fontWeight: 500 } }, "\u062A\u0627\u0631\u06CC\u062E \u0634\u0631\u0648\u0639 (\u0627\u0632):"), /* @__PURE__ */ React2.createElement(
300
+ DatePicker,
301
+ {
302
+ value: tempStartDate,
303
+ onChange: (day) => {
304
+ setTempStartDate(day);
305
+ },
306
+ openTo: fromOpenTo,
307
+ views: fromViews,
308
+ minDate,
309
+ maxDate: maxDate || moment(),
310
+ slotProps: {
311
+ textField: {
312
+ fullWidth: true,
313
+ size: "small",
314
+ placeholder: "\u0627\u0646\u062A\u062E\u0627\u0628 \u062A\u0627\u0631\u06CC\u062E \u0634\u0631\u0648\u0639"
315
+ }
316
+ }
317
+ }
318
+ )),
319
+ /* @__PURE__ */ React2.createElement(Box, { sx: { width: "100%" } }, /* @__PURE__ */ React2.createElement(Typography, { variant: "body2", sx: { mb: 1, fontWeight: 500 } }, "\u062A\u0627\u0631\u06CC\u062E \u067E\u0627\u06CC\u0627\u0646 (\u062A\u0627):"), /* @__PURE__ */ React2.createElement(
320
+ DatePicker,
321
+ {
322
+ value: tempEndDate,
323
+ onChange: (day) => {
324
+ setTempEndDate(day);
325
+ },
326
+ openTo: toOpenTo,
327
+ views: toViews,
328
+ minDate: tempStartDate || minDate,
329
+ maxDate: maxDate || moment(),
330
+ slotProps: {
331
+ textField: {
332
+ fullWidth: true,
333
+ size: "small",
334
+ placeholder: "\u0627\u0646\u062A\u062E\u0627\u0628 \u062A\u0627\u0631\u06CC\u062E \u067E\u0627\u06CC\u0627\u0646"
335
+ }
336
+ }
337
+ }
338
+ ))
339
+ )
340
+ ) : (
341
+ // Calendar popup style: Use StaticDatePicker(s)
342
+ /* @__PURE__ */ React2.createElement(
343
+ Box,
344
+ {
345
+ sx: {
346
+ display: "flex",
347
+ gap: showSingleCalendar ? 0 : 2,
348
+ flexDirection: showSingleCalendar ? "column" : "row",
349
+ alignItems: "center"
350
+ }
351
+ },
352
+ !dualCalendar && showSingleCalendar && /* @__PURE__ */ React2.createElement(Box, { sx: { width: "100%", mb: 2 } }, /* @__PURE__ */ React2.createElement(
353
+ Box,
354
+ {
355
+ sx: { display: "flex", justifyContent: "center", mb: 1 }
356
+ },
357
+ /* @__PURE__ */ React2.createElement(
358
+ Button,
359
+ {
360
+ size: "small",
361
+ variant: autoSelectMode ? "contained" : "outlined",
362
+ onClick: () => setAutoSelectMode(!autoSelectMode),
363
+ sx: { fontSize: "12px", minWidth: "120px" }
364
+ },
365
+ /* @__PURE__ */ React2.createElement(
366
+ Box,
367
+ {
368
+ sx: {
369
+ display: "flex",
370
+ alignItems: "center",
371
+ gap: 0.5
372
+ }
373
+ },
374
+ autoSelectMode ? /* @__PURE__ */ React2.createElement(MdTipsAndUpdates, { size: 16 }) : /* @__PURE__ */ React2.createElement(MdPerson, { size: 16 }),
375
+ autoSelectMode ? "\u0647\u0648\u0634\u0645\u0646\u062F" : "\u062F\u0633\u062A\u06CC"
376
+ )
377
+ )
378
+ ), !autoSelectMode && /* @__PURE__ */ React2.createElement(
379
+ Box,
380
+ {
381
+ sx: {
382
+ display: "flex",
383
+ justifyContent: "center",
384
+ gap: 1,
385
+ mb: 2,
386
+ borderBottom: 1,
387
+ borderColor: "divider",
388
+ pb: 1
389
+ }
390
+ },
391
+ /* @__PURE__ */ React2.createElement(
392
+ Button,
393
+ {
394
+ size: "small",
395
+ variant: activeTab === "from" ? "contained" : "outlined",
396
+ onClick: () => setActiveTab("from"),
397
+ sx: {
398
+ minWidth: "140px",
399
+ fontSize: "13px",
400
+ backgroundColor: activeTab === "from" ? "primary.main" : "transparent",
401
+ color: activeTab === "from" ? "white" : "primary.main"
402
+ }
403
+ },
404
+ /* @__PURE__ */ React2.createElement(
405
+ Box,
406
+ {
407
+ sx: {
408
+ display: "flex",
409
+ alignItems: "center",
410
+ gap: 0.5,
411
+ flexDirection: "column"
412
+ }
413
+ },
414
+ /* @__PURE__ */ React2.createElement(
415
+ Box,
416
+ {
417
+ sx: {
418
+ display: "flex",
419
+ alignItems: "center",
420
+ gap: 0.5
421
+ }
422
+ },
423
+ /* @__PURE__ */ React2.createElement(MdDateRange, { size: 16 }),
424
+ "\u0627\u0632 \u062A\u0627\u0631\u06CC\u062E"
425
+ ),
426
+ tempStartDate && /* @__PURE__ */ React2.createElement(
427
+ Typography,
428
+ {
429
+ variant: "caption",
430
+ sx: { fontSize: "10px" }
431
+ },
432
+ tempStartDate.format("jYYYY/jMM/jDD")
433
+ )
434
+ )
435
+ ),
436
+ /* @__PURE__ */ React2.createElement(
437
+ Button,
438
+ {
439
+ size: "small",
440
+ variant: activeTab === "to" ? "contained" : "outlined",
441
+ onClick: () => setActiveTab("to"),
442
+ sx: {
443
+ minWidth: "140px",
444
+ fontSize: "13px",
445
+ backgroundColor: activeTab === "to" ? "primary.main" : "transparent",
446
+ color: activeTab === "to" ? "white" : "primary.main"
447
+ }
448
+ },
449
+ /* @__PURE__ */ React2.createElement(
450
+ Box,
451
+ {
452
+ sx: {
453
+ display: "flex",
454
+ alignItems: "center",
455
+ gap: 0.5,
456
+ flexDirection: "column"
457
+ }
458
+ },
459
+ /* @__PURE__ */ React2.createElement(
460
+ Box,
461
+ {
462
+ sx: {
463
+ display: "flex",
464
+ alignItems: "center",
465
+ gap: 0.5
466
+ }
467
+ },
468
+ /* @__PURE__ */ React2.createElement(MdEvent, { size: 16 }),
469
+ "\u062A\u0627 \u062A\u0627\u0631\u06CC\u062E"
470
+ ),
471
+ tempEndDate && /* @__PURE__ */ React2.createElement(
472
+ Typography,
473
+ {
474
+ variant: "caption",
475
+ sx: { fontSize: "10px" }
476
+ },
477
+ tempEndDate.format("jYYYY/jMM/jDD")
478
+ )
479
+ )
480
+ )
481
+ ), autoSelectMode && /* @__PURE__ */ React2.createElement(Box, { sx: { textAlign: "center", mb: 2 } }, /* @__PURE__ */ React2.createElement(
482
+ Typography,
483
+ {
484
+ variant: "caption",
485
+ color: "text.secondary",
486
+ sx: {
487
+ display: "flex",
488
+ alignItems: "center",
489
+ justifyContent: "center",
490
+ gap: 0.5
491
+ }
492
+ },
493
+ !tempStartDate && !tempEndDate ? /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(MdGpsFixed, { size: 14 }), "\u0627\u0648\u0644\u06CC\u0646 \u062A\u0627\u0631\u06CC\u062E \u0631\u0627 \u0627\u0646\u062A\u062E\u0627\u0628 \u06A9\u0646\u06CC\u062F") : tempStartDate && !tempEndDate ? /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(MdGpsFixed, { size: 14 }), "\u062A\u0627\u0631\u06CC\u062E \u067E\u0627\u06CC\u0627\u0646 \u0631\u0627 \u0627\u0646\u062A\u062E\u0627\u0628 \u06A9\u0646\u06CC\u062F") : tempStartDate && tempEndDate ? /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(MdCheckCircle, { size: 14 }), "\u0628\u0627\u0632\u0647 \u0627\u0646\u062A\u062E\u0627\u0628 \u0634\u062F\u0647 - \u062A\u0627\u0631\u06CC\u062E \u062C\u062F\u06CC\u062F \u0628\u0631\u0627\u06CC \u0634\u0631\u0648\u0639 \u0645\u062C\u062F\u062F") : /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(MdGpsFixed, { size: 14 }), "\u062A\u0627\u0631\u06CC\u062E \u0634\u0631\u0648\u0639 \u0631\u0627 \u0627\u0646\u062A\u062E\u0627\u0628 \u06A9\u0646\u06CC\u062F")
494
+ ))),
495
+ /* @__PURE__ */ React2.createElement(
496
+ StaticDatePicker,
497
+ {
498
+ value: tempStartDate || (fieldFrom.value ? moment(fieldFrom.value) : null),
499
+ onChange: (day) => {
500
+ if (day) handleDaySelect(day, "right");
501
+ },
502
+ openTo: fromOpenTo,
503
+ views: fromViews,
504
+ slots: {
505
+ day: (props) => CustomDay({
506
+ ...props,
507
+ startDate: tempStartDate,
508
+ endDate: tempEndDate
509
+ }),
510
+ actionBar: () => null,
511
+ monthButton: (props) => {
512
+ return /* @__PURE__ */ React2.createElement(
513
+ "button",
514
+ {
515
+ className: `${props.className}`,
516
+ style: {
517
+ width: "100%",
518
+ padding: "15px 8px",
519
+ border: "1px solid #ccc",
520
+ borderRadius: "8px",
521
+ backgroundColor: props.disabled ? "#f0f0f0" : "#ffffff",
522
+ fontSize: "17px",
523
+ cursor: props.disabled ? "default" : "pointer",
524
+ textAlign: "center",
525
+ boxSizing: "border-box"
526
+ },
527
+ disabled: props.disabled,
528
+ onFocus: props.onFocus,
529
+ onBlur: props.onBlur,
530
+ onClick: props.onClick,
531
+ ref: props.ref
532
+ },
533
+ props["aria-label"]
534
+ );
535
+ }
536
+ },
537
+ minDate,
538
+ maxDate: maxDate || moment(),
539
+ slotProps: {
540
+ toolbar: { hidden: true },
541
+ layout: {
542
+ sx: {
543
+ "& .MuiPickersCalendarHeader-root": {
544
+ minHeight: "40px",
545
+ maxHeight: "40px"
546
+ },
547
+ "& .MuiDayCalendar-header": {
548
+ justifyContent: "space-around"
549
+ },
550
+ "& .MuiDayCalendar-weekContainer": {
551
+ justifyContent: "space-around"
552
+ },
553
+ "& .MuiPickersDay-root": {
554
+ fontSize: "0.875rem"
555
+ },
556
+ "& .MuiMonthCalendar-root": {
557
+ display: "grid",
558
+ gridTemplateColumns: "repeat(3, 1fr)",
559
+ gap: "8px",
560
+ width: "100%"
561
+ }
562
+ }
563
+ }
564
+ },
565
+ sx: {
566
+ "& .MuiPickersLayout-contentWrapper": {
567
+ minWidth: showSingleCalendar ? "300px" : "280px",
568
+ maxWidth: showSingleCalendar ? "350px" : "320px"
569
+ }
570
+ }
571
+ }
572
+ ),
573
+ dualCalendar && !showSingleCalendar && /* @__PURE__ */ React2.createElement(
574
+ StaticDatePicker,
575
+ {
576
+ value: secondCalendarMonth,
577
+ onChange: (day) => {
578
+ if (day) handleDaySelect(day, "left");
579
+ },
580
+ openTo: toOpenTo,
581
+ views: toViews,
582
+ slots: {
583
+ day: (props) => CustomDay({
584
+ ...props,
585
+ startDate: tempStartDate,
586
+ endDate: tempEndDate
587
+ }),
588
+ actionBar: () => null,
589
+ monthButton: (props) => {
590
+ return /* @__PURE__ */ React2.createElement(
591
+ "button",
592
+ {
593
+ className: `${props.className}`,
594
+ style: {
595
+ width: "100%",
596
+ padding: "15px 8px",
597
+ border: "1px solid #ccc",
598
+ borderRadius: "8px",
599
+ backgroundColor: props.disabled ? "#f0f0f0" : "#ffffff",
600
+ fontSize: "17px",
601
+ cursor: props.disabled ? "default" : "pointer",
602
+ textAlign: "center",
603
+ boxSizing: "border-box"
604
+ },
605
+ disabled: props.disabled,
606
+ onFocus: props.onFocus,
607
+ onBlur: props.onBlur,
608
+ onClick: props.onClick,
609
+ ref: props.ref
610
+ },
611
+ props["aria-label"]
612
+ );
613
+ }
614
+ },
615
+ minDate,
616
+ maxDate: maxDate || moment(),
617
+ slotProps: {
618
+ toolbar: { hidden: true },
619
+ layout: {
620
+ sx: {
621
+ "& .MuiPickersCalendarHeader-root": {
622
+ minHeight: "40px",
623
+ maxHeight: "40px"
624
+ },
625
+ "& .MuiDayCalendar-header": {
626
+ justifyContent: "space-around"
627
+ },
628
+ "& .MuiDayCalendar-weekContainer": {
629
+ justifyContent: "space-around"
630
+ },
631
+ "& .MuiPickersDay-root": {
632
+ fontSize: "0.875rem"
633
+ },
634
+ "& .MuiMonthCalendar-root": {
635
+ display: "grid",
636
+ gridTemplateColumns: "repeat(3, 1fr)",
637
+ gap: "8px",
638
+ width: "100%"
639
+ }
640
+ }
641
+ }
642
+ },
643
+ sx: {
644
+ "& .MuiPickersLayout-contentWrapper": {
645
+ minWidth: "280px",
646
+ maxWidth: "320px"
647
+ }
648
+ },
649
+ onMonthChange: (newMonth) => {
650
+ setSecondCalendarMonth(newMonth);
651
+ }
652
+ }
653
+ )
654
+ )
655
+ ), /* @__PURE__ */ React2.createElement(
656
+ Box,
657
+ {
658
+ sx: {
659
+ display: "flex",
660
+ justifyContent: "space-between",
661
+ gap: 1,
662
+ mt: 2,
663
+ pt: 2,
664
+ borderTop: 1,
665
+ borderColor: "divider"
666
+ }
667
+ },
668
+ /* @__PURE__ */ React2.createElement(Box, null, clear && /* @__PURE__ */ React2.createElement(
669
+ Button,
670
+ {
671
+ size: "small",
672
+ onClick: handleClear,
673
+ disabled: !fieldFrom.value && !fieldTo.value
674
+ },
675
+ "\u067E\u0627\u06A9 \u06A9\u0631\u062F\u0646"
676
+ )),
677
+ /* @__PURE__ */ React2.createElement(Box, { sx: { display: "flex", gap: 1 } }, /* @__PURE__ */ React2.createElement(Button, { size: "small", onClick: handleClose }, "\u0644\u063A\u0648"), /* @__PURE__ */ React2.createElement(
678
+ Button,
679
+ {
680
+ variant: "contained",
681
+ size: "small",
682
+ onClick: handleConfirm,
683
+ disabled: !tempStartDate && !tempEndDate
684
+ },
685
+ "\u062A\u0623\u06CC\u06CC\u062F"
686
+ ))
687
+ ))
688
+ ))
689
+ );
690
+ };
691
+ function CustomDay(props) {
692
+ const { day, outsideCurrentMonth, startDate, endDate, ...other } = props;
693
+ const isToday = moment(day).isSame(moment(), "day");
694
+ const isFriday = moment(day).day() === 5;
695
+ let inRange = false;
696
+ if (startDate && endDate) {
697
+ inRange = day.isAfter(startDate, "day") && day.isBefore(endDate, "day");
698
+ }
699
+ const isStart = startDate && day.isSame(startDate, "day");
700
+ const isEnd = endDate && day.isSame(endDate, "day");
701
+ const isSelected = isStart || isEnd;
702
+ return /* @__PURE__ */ React2.createElement(
703
+ PickersDay,
704
+ {
705
+ ...other,
706
+ day,
707
+ outsideCurrentMonth,
708
+ selected: false,
709
+ sx: {
710
+ borderRadius: isSelected ? "50%" : inRange ? "100%" : "50%",
711
+ fontSize: "0.9rem",
712
+ width: 34,
713
+ height: 34,
714
+ my: 0.2,
715
+ bgcolor: isSelected ? "primary.main" : inRange ? "rgba(25,118,210,0.12)" : isToday ? "rgba(25,118,210,0.08)" : "transparent",
716
+ color: isSelected ? "#fff" : isFriday ? "error.main" : isToday ? "primary.main" : outsideCurrentMonth ? "text.disabled" : "text.primary",
717
+ fontWeight: isSelected ? 600 : isToday ? 500 : 400,
718
+ "&:hover": {
719
+ bgcolor: isSelected ? "primary.dark" : inRange ? "rgba(25,118,210,0.2)" : "rgba(0,0,0,0.04)"
720
+ },
721
+ ...isStart && endDate && {
722
+ borderTopRightRadius: "50%",
723
+ borderBottomRightRadius: "50%"
724
+ },
725
+ ...isEnd && startDate && {
726
+ borderTopLeftRadius: "50%",
727
+ borderBottomLeftRadius: "50%"
728
+ }
729
+ }
730
+ }
731
+ );
732
+ }
733
+ var date_range_picker_default = DateRangePicker;
734
+ export {
735
+ date_range_picker_default as DateRangePicker
736
+ };
737
+ //# sourceMappingURL=index.mjs.map