@acusti/date-picker 0.10.1 → 0.11.1

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.js CHANGED
@@ -1,4 +1,868 @@
1
- export { default as DatePicker } from './DatePicker.js';
2
- export { default as MonthCalendar } from './MonthCalendar.js';
3
- export * from './utils.js';
4
- //# sourceMappingURL=index.js.map
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { c } from "react/compiler-runtime";
3
+ import { Style } from "@acusti/styling";
4
+ import clsx from "clsx";
5
+ import * as React from "react";
6
+ const ROOT_CLASS_NAME$1 = "uktmonthcalendar";
7
+ const STYLES$1 = `
8
+ .${ROOT_CLASS_NAME$1} {
9
+ display: flex;
10
+ flex-direction: column;
11
+ flex: 1 1 auto;
12
+ box-sizing: border-box;
13
+ max-width: 325px;
14
+ }
15
+
16
+ .${ROOT_CLASS_NAME$1}-month-title {
17
+ display: flex;
18
+ align-items: center;
19
+ justify-content: center;
20
+ flex: 0 0 auto;
21
+ box-sizing: border-box;
22
+ padding-bottom: 25px;
23
+ }
24
+
25
+ h3.${ROOT_CLASS_NAME$1}-month-title-text {
26
+ font-size: 18px;
27
+ line-height: 23px;
28
+ font-weight: 600;
29
+ color: #000;
30
+ margin: 0px;
31
+ text-align: center;
32
+ }
33
+
34
+ .${ROOT_CLASS_NAME$1}-month-week {
35
+ flex: 0 0 auto;
36
+ display: grid;
37
+ grid-column-gap: 0px;
38
+ grid-template-columns: repeat(auto-fit, minmax(46px, 1fr));
39
+ grid-auto-flow: dense;
40
+ box-sizing: border-box;
41
+ padding-bottom: 12px;
42
+ }
43
+
44
+ .${ROOT_CLASS_NAME$1}-month-week .week-day-item {
45
+ flex: 1 1 auto;
46
+ display: flex;
47
+ justify-content: center;
48
+ align-items: center;
49
+ }
50
+
51
+ .${ROOT_CLASS_NAME$1}-month-week span.week-day-item-text {
52
+ text-align: center;
53
+ font-size: 13px;
54
+ line-height: 21px;
55
+ margin: 0px;
56
+ color: #9a9a9a;
57
+ }
58
+
59
+ .${ROOT_CLASS_NAME$1}-month-days {
60
+ flex: 1 1 auto;
61
+ display: flex;
62
+ flex-direction: column;
63
+ }
64
+
65
+ .${ROOT_CLASS_NAME$1}-month-row {
66
+ flex: 1 1 auto;
67
+ display: grid;
68
+ grid-column-gap: 0px;
69
+ grid-template-columns: repeat(auto-fit, minmax(46px, 1fr));
70
+ grid-auto-flow: dense;
71
+ margin-bottom: 1px;
72
+ }
73
+
74
+ .${ROOT_CLASS_NAME$1}-month-day-item {
75
+ display: flex;
76
+ justify-content: center;
77
+ align-items: center;
78
+ position: relative;
79
+ height: 46px;
80
+ width: 46px;
81
+ cursor: pointer;
82
+ border: none;
83
+ background-color: transparent;
84
+ }
85
+
86
+ .${ROOT_CLASS_NAME$1}-month-day-item:disabled {
87
+ cursor: auto;
88
+ }
89
+
90
+ .${ROOT_CLASS_NAME$1}-month-day-item.is-selected {
91
+ background-color: #f8f8f8;
92
+ }
93
+
94
+ .${ROOT_CLASS_NAME$1}-month-day-item.start-date {
95
+ background-color: #f8f8f8;
96
+ border-top-left-radius: 50%;
97
+ border-bottom-left-radius: 50%;
98
+ }
99
+
100
+ .${ROOT_CLASS_NAME$1}-month-day-item.start-date:after {
101
+ background-color: #000;
102
+ opacity: 1;
103
+ visibility: visible;
104
+ }
105
+ .${ROOT_CLASS_NAME$1}-month-day-item.start-date span.month-day-item-text {
106
+ color: #fff;
107
+ }
108
+
109
+ .${ROOT_CLASS_NAME$1}-month-day-item.end-date {
110
+ background-color: #f8f8f8;
111
+ border-top-right-radius: 50%;
112
+ border-bottom-right-radius: 50%;
113
+ }
114
+
115
+ .${ROOT_CLASS_NAME$1}-month-day-item.end-date:after {
116
+ background-color: #000;
117
+ opacity: 1;
118
+ visibility: visible;
119
+ }
120
+ .${ROOT_CLASS_NAME$1}-month-day-item.end-date span.month-day-item-text {
121
+ color: #fff;
122
+ }
123
+
124
+ .${ROOT_CLASS_NAME$1}-month-day-item:hover:after {
125
+ opacity: 1;
126
+ visibility: visible;
127
+ }
128
+
129
+ .${ROOT_CLASS_NAME$1}-month-day-item:after {
130
+ content: "";
131
+ position: absolute;
132
+ left: 50%;
133
+ top: 50%;
134
+ transform: translate(-50%, -50%);
135
+ pointer-events: none;
136
+ border-radius: 50%;
137
+ border: 1px solid #000;
138
+ width: 43px;
139
+ height: 43px;
140
+ transition: opacity 0.25s ease-in-out;
141
+ opacity: 0;
142
+ visibility: hidden;
143
+ }
144
+
145
+ .${ROOT_CLASS_NAME$1}-month-day-item.is-empty:after {
146
+ content: none;
147
+ }
148
+
149
+ .${ROOT_CLASS_NAME$1}-month-day-item span.month-day-item-text {
150
+ text-align: center;
151
+ font-size: 13px;
152
+ line-height: 21px;
153
+ margin: 0px;
154
+ color: #000;
155
+ position: relative;
156
+ z-index: 1;
157
+ }
158
+ `;
159
+ const START_YEAR = 1970;
160
+ const MONTH_NAMES = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
161
+ const getYearFromDate = (date, asUTC) => (asUTC ? date.getUTCFullYear() : date.getFullYear()) - START_YEAR;
162
+ const getMonthFromDate = (date, asUTC) => {
163
+ const yearAsMonths = getYearFromDate(date, asUTC) * 12;
164
+ return yearAsMonths + (asUTC ? date.getUTCMonth() : date.getMonth());
165
+ };
166
+ const getYearFromMonth = (month) => Math.floor(month / 12) + START_YEAR;
167
+ const getMonthNameFromMonth = (month) => {
168
+ let index = month % 12;
169
+ if (Number.isNaN(index)) return "";
170
+ if (index < 0) index = 12 + index;
171
+ return MONTH_NAMES[index];
172
+ };
173
+ const getMonthAbbreviationFromMonth = (month) => {
174
+ const monthName = getMonthNameFromMonth(month);
175
+ if (monthName === "September") return "Sept";
176
+ return monthName.substring(0, 3);
177
+ };
178
+ const getDateFromMonthAndDay = (month, day, asUTC) => {
179
+ const monthIn12 = month < 0 ? (12 - Math.abs(month % 12)) % 12 : month % 12;
180
+ const year = getYearFromMonth(month);
181
+ return asUTC ? new Date(Date.UTC(year, monthIn12, day)) : new Date(year, monthIn12, day);
182
+ };
183
+ const getLastDateFromMonth = (month, asUTC) => {
184
+ return getDateFromMonthAndDay(month + 1, 0, asUTC);
185
+ };
186
+ const {
187
+ Fragment: Fragment$1
188
+ } = React;
189
+ const DAYS = Array(7).fill(null);
190
+ function MonthCalendar(t0) {
191
+ const $ = c(56);
192
+ let {
193
+ className,
194
+ dateEnd,
195
+ dateEndPreview,
196
+ dateStart,
197
+ isRange,
198
+ month,
199
+ onChange,
200
+ onChangeEndPreview,
201
+ title
202
+ } = t0;
203
+ const year = getYearFromMonth(month);
204
+ title = title ?? `${getMonthNameFromMonth(month)} ${year}`;
205
+ let firstDay;
206
+ let t1;
207
+ let t2;
208
+ let totalDays;
209
+ if ($[0] !== month) {
210
+ const firstDate = getDateFromMonthAndDay(month, 1);
211
+ const lastDate = getLastDateFromMonth(month);
212
+ totalDays = lastDate.getDate();
213
+ firstDay = firstDate.getDay();
214
+ t2 = 7;
215
+ t1 = lastDate.getDay();
216
+ $[0] = month;
217
+ $[1] = firstDay;
218
+ $[2] = t1;
219
+ $[3] = t2;
220
+ $[4] = totalDays;
221
+ } else {
222
+ firstDay = $[1];
223
+ t1 = $[2];
224
+ t2 = $[3];
225
+ totalDays = $[4];
226
+ }
227
+ const spacesAfterLastDay = t2 - t1 % 7;
228
+ const daySpaces = totalDays + firstDay + spacesAfterLastDay;
229
+ let t3;
230
+ if ($[5] !== dateEnd || $[6] !== dateEndPreview || $[7] !== dateStart || $[8] !== month || $[9] !== totalDays) {
231
+ let t42;
232
+ if ($[11] !== month || $[12] !== totalDays) {
233
+ t42 = (acc, date, index) => {
234
+ if (date != null && !(date instanceof Date)) {
235
+ date = new Date(date);
236
+ }
237
+ if (date == null || Number.isNaN(date.getTime())) {
238
+ return acc;
239
+ }
240
+ const dateMonth = getMonthFromDate(date);
241
+ if (dateMonth < month) {
242
+ acc[index] = -1;
243
+ } else {
244
+ if (dateMonth > month) {
245
+ acc[index] = totalDays + 1;
246
+ } else {
247
+ acc[index] = date.getDate();
248
+ }
249
+ }
250
+ if (index === 1) {
251
+ const startDay = acc[index - 1];
252
+ const endDay = acc[index];
253
+ if (startDay != null && endDay != null && startDay > endDay) {
254
+ acc[index - 1] = endDay;
255
+ acc[index] = startDay;
256
+ }
257
+ }
258
+ return acc;
259
+ };
260
+ $[11] = month;
261
+ $[12] = totalDays;
262
+ $[13] = t42;
263
+ } else {
264
+ t42 = $[13];
265
+ }
266
+ t3 = [dateStart, dateEnd, dateEndPreview].reduce(t42, [null, null, null]);
267
+ $[5] = dateEnd;
268
+ $[6] = dateEndPreview;
269
+ $[7] = dateStart;
270
+ $[8] = month;
271
+ $[9] = totalDays;
272
+ $[10] = t3;
273
+ } else {
274
+ t3 = $[10];
275
+ }
276
+ const [dateRangeStartDay, dateRangeEndDay, dateRangeEndPreviewDay] = t3;
277
+ let t4;
278
+ if ($[14] !== onChange) {
279
+ t4 = (event) => {
280
+ const {
281
+ date: date_0
282
+ } = event.currentTarget.dataset;
283
+ if (date_0 && onChange) {
284
+ onChange(date_0);
285
+ }
286
+ };
287
+ $[14] = onChange;
288
+ $[15] = t4;
289
+ } else {
290
+ t4 = $[15];
291
+ }
292
+ const handleClickDay = t4;
293
+ let t5;
294
+ if ($[16] !== isRange || $[17] !== onChangeEndPreview) {
295
+ t5 = (event_0) => {
296
+ if (isRange && onChangeEndPreview) {
297
+ const {
298
+ date: date_1
299
+ } = event_0.currentTarget.dataset;
300
+ if (date_1) {
301
+ onChangeEndPreview(date_1);
302
+ }
303
+ }
304
+ };
305
+ $[16] = isRange;
306
+ $[17] = onChangeEndPreview;
307
+ $[18] = t5;
308
+ } else {
309
+ t5 = $[18];
310
+ }
311
+ const handleMouseEnterDay = t5;
312
+ let t6;
313
+ if ($[19] === Symbol.for("react.memo_cache_sentinel")) {
314
+ t6 = /* @__PURE__ */ jsx(Style, { href: "@acusti/date-picker/MonthCalendar", children: STYLES$1 });
315
+ $[19] = t6;
316
+ } else {
317
+ t6 = $[19];
318
+ }
319
+ let t7;
320
+ if ($[20] !== className) {
321
+ t7 = clsx(ROOT_CLASS_NAME$1, className);
322
+ $[20] = className;
323
+ $[21] = t7;
324
+ } else {
325
+ t7 = $[21];
326
+ }
327
+ let t8;
328
+ if ($[22] !== title) {
329
+ t8 = /* @__PURE__ */ jsx("div", { className: `${ROOT_CLASS_NAME$1}-month-title`, children: /* @__PURE__ */ jsx("h3", { className: `${ROOT_CLASS_NAME$1}-month-title-text`, children: title }) });
330
+ $[22] = title;
331
+ $[23] = t8;
332
+ } else {
333
+ t8 = $[23];
334
+ }
335
+ let t9;
336
+ if ($[24] === Symbol.for("react.memo_cache_sentinel")) {
337
+ t9 = /* @__PURE__ */ jsx("div", { className: "week-day-item", children: /* @__PURE__ */ jsx("span", { className: "week-day-item-text", children: "Su" }) });
338
+ $[24] = t9;
339
+ } else {
340
+ t9 = $[24];
341
+ }
342
+ let t10;
343
+ if ($[25] === Symbol.for("react.memo_cache_sentinel")) {
344
+ t10 = /* @__PURE__ */ jsx("div", { className: "week-day-item", children: /* @__PURE__ */ jsx("span", { className: "week-day-item-text", children: "Mo" }) });
345
+ $[25] = t10;
346
+ } else {
347
+ t10 = $[25];
348
+ }
349
+ let t11;
350
+ if ($[26] === Symbol.for("react.memo_cache_sentinel")) {
351
+ t11 = /* @__PURE__ */ jsx("div", { className: "week-day-item", children: /* @__PURE__ */ jsx("span", { className: "week-day-item-text", children: "Tu" }) });
352
+ $[26] = t11;
353
+ } else {
354
+ t11 = $[26];
355
+ }
356
+ let t12;
357
+ if ($[27] === Symbol.for("react.memo_cache_sentinel")) {
358
+ t12 = /* @__PURE__ */ jsx("div", { className: "week-day-item", children: /* @__PURE__ */ jsx("span", { className: "week-day-item-text", children: "We" }) });
359
+ $[27] = t12;
360
+ } else {
361
+ t12 = $[27];
362
+ }
363
+ let t13;
364
+ if ($[28] === Symbol.for("react.memo_cache_sentinel")) {
365
+ t13 = /* @__PURE__ */ jsx("div", { className: "week-day-item", children: /* @__PURE__ */ jsx("span", { className: "week-day-item-text", children: "Th" }) });
366
+ $[28] = t13;
367
+ } else {
368
+ t13 = $[28];
369
+ }
370
+ let t14;
371
+ if ($[29] === Symbol.for("react.memo_cache_sentinel")) {
372
+ t14 = /* @__PURE__ */ jsx("div", { className: "week-day-item", children: /* @__PURE__ */ jsx("span", { className: "week-day-item-text", children: "Fr" }) });
373
+ $[29] = t14;
374
+ } else {
375
+ t14 = $[29];
376
+ }
377
+ let t15;
378
+ if ($[30] === Symbol.for("react.memo_cache_sentinel")) {
379
+ t15 = /* @__PURE__ */ jsxs("div", { className: `${ROOT_CLASS_NAME$1}-month-week`, children: [
380
+ t9,
381
+ t10,
382
+ t11,
383
+ t12,
384
+ t13,
385
+ t14,
386
+ /* @__PURE__ */ jsx("div", { className: "week-day-item", children: /* @__PURE__ */ jsx("span", { className: "week-day-item-text", children: "Sa" }) })
387
+ ] });
388
+ $[30] = t15;
389
+ } else {
390
+ t15 = $[30];
391
+ }
392
+ const t16 = Math.floor(daySpaces / 7);
393
+ let t17;
394
+ if ($[31] !== dateRangeEndDay || $[32] !== dateRangeEndPreviewDay || $[33] !== dateRangeStartDay || $[34] !== firstDay || $[35] !== handleClickDay || $[36] !== handleMouseEnterDay || $[37] !== month || $[38] !== t16 || $[39] !== totalDays) {
395
+ let t182;
396
+ if ($[41] !== dateRangeEndDay || $[42] !== dateRangeEndPreviewDay || $[43] !== dateRangeStartDay || $[44] !== firstDay || $[45] !== handleClickDay || $[46] !== handleMouseEnterDay || $[47] !== month || $[48] !== totalDays) {
397
+ t182 = (_, weekIndex) => /* @__PURE__ */ jsx("div", { className: `${ROOT_CLASS_NAME$1}-month-row`, children: DAYS.map((__, dayIndex) => {
398
+ dayIndex = dayIndex + weekIndex * 7;
399
+ const dayNumber = dayIndex - firstDay + 1;
400
+ const isEmpty = dayNumber < 1 || dayNumber > totalDays;
401
+ const date_2 = isEmpty ? null : getDateFromMonthAndDay(month, dayNumber);
402
+ const isAfterDateRangeStart = dateRangeStartDay != null && dayNumber > dateRangeStartDay;
403
+ const isBeforeDateRangeEnd = dateRangeEndDay == null && dateRangeEndPreviewDay != null && dayNumber < dateRangeEndPreviewDay || dateRangeEndDay != null && dayNumber < dateRangeEndDay;
404
+ return /* @__PURE__ */ jsx("button", { className: clsx(`${ROOT_CLASS_NAME$1}-month-day-item`, {
405
+ "end-date": !isEmpty && dayNumber === dateRangeEndDay,
406
+ "is-empty": isEmpty,
407
+ "is-selected": !isEmpty && isAfterDateRangeStart && isBeforeDateRangeEnd,
408
+ "start-date": !isEmpty && dayNumber === dateRangeStartDay
409
+ }), "data-date": date_2 == null ? void 0 : date_2.toISOString(), disabled: isEmpty, onClick: handleClickDay, onMouseEnter: handleMouseEnterDay, type: "button", children: isEmpty ? null : /* @__PURE__ */ jsx("span", { className: "month-day-item-text", children: dayNumber }) }, `MonthDayItem-${dayNumber}`);
410
+ }) }, `MonthRow-${weekIndex}`);
411
+ $[41] = dateRangeEndDay;
412
+ $[42] = dateRangeEndPreviewDay;
413
+ $[43] = dateRangeStartDay;
414
+ $[44] = firstDay;
415
+ $[45] = handleClickDay;
416
+ $[46] = handleMouseEnterDay;
417
+ $[47] = month;
418
+ $[48] = totalDays;
419
+ $[49] = t182;
420
+ } else {
421
+ t182 = $[49];
422
+ }
423
+ t17 = Array(t16).fill(null).map(t182);
424
+ $[31] = dateRangeEndDay;
425
+ $[32] = dateRangeEndPreviewDay;
426
+ $[33] = dateRangeStartDay;
427
+ $[34] = firstDay;
428
+ $[35] = handleClickDay;
429
+ $[36] = handleMouseEnterDay;
430
+ $[37] = month;
431
+ $[38] = t16;
432
+ $[39] = totalDays;
433
+ $[40] = t17;
434
+ } else {
435
+ t17 = $[40];
436
+ }
437
+ let t18;
438
+ if ($[50] !== t17) {
439
+ t18 = /* @__PURE__ */ jsx("div", { className: `${ROOT_CLASS_NAME$1}-month-days`, children: t17 });
440
+ $[50] = t17;
441
+ $[51] = t18;
442
+ } else {
443
+ t18 = $[51];
444
+ }
445
+ let t19;
446
+ if ($[52] !== t18 || $[53] !== t7 || $[54] !== t8) {
447
+ t19 = /* @__PURE__ */ jsxs(Fragment$1, { children: [
448
+ t6,
449
+ /* @__PURE__ */ jsxs("div", { className: t7, children: [
450
+ t8,
451
+ t15,
452
+ t18
453
+ ] })
454
+ ] });
455
+ $[52] = t18;
456
+ $[53] = t7;
457
+ $[54] = t8;
458
+ $[55] = t19;
459
+ } else {
460
+ t19 = $[55];
461
+ }
462
+ return t19;
463
+ }
464
+ const ROOT_CLASS_NAME = "uktdatepicker";
465
+ const STYLES = `
466
+ .${ROOT_CLASS_NAME} {
467
+ display: flex;
468
+ box-sizing: border-box;
469
+ padding: 40px 60px 60px;
470
+ flex: 1 1 auto;
471
+ position: relative;
472
+ max-width: 450px;
473
+ }
474
+
475
+ .${ROOT_CLASS_NAME}.two-up {
476
+ max-width: 820px;
477
+ }
478
+
479
+ .${ROOT_CLASS_NAME}-range-arrow-wrap {
480
+ position: absolute;
481
+ top: 30px;
482
+ left: 0px;
483
+ display: flex;
484
+ justify-content: space-between;
485
+ height: 0px;
486
+ width: 100%;
487
+ padding: 0px 60px;
488
+ box-sizing: border-box;
489
+ }
490
+
491
+ .${ROOT_CLASS_NAME}-range-arrow {
492
+ width: 35px;
493
+ height: 35px;
494
+ text-align: center;
495
+ cursor: pointer;
496
+ }
497
+
498
+ .${ROOT_CLASS_NAME}-range-arrow.disabled {
499
+ color: #ccc;
500
+ cursor: default;
501
+ }
502
+
503
+ .${ROOT_CLASS_NAME}-range-arrow:active {
504
+ transform: translateY(1px);
505
+ }
506
+
507
+ .${ROOT_CLASS_NAME}-range-arrow.left-arrow:after,
508
+ .${ROOT_CLASS_NAME}-range-arrow.right-arrow:after {
509
+ content: "‹";
510
+ font-size: 24px;
511
+ line-height: 35px;
512
+ font-weight: bold;
513
+ }
514
+
515
+ .${ROOT_CLASS_NAME}-range-arrow.right-arrow:after {
516
+ content: "›";
517
+ }
518
+
519
+ .${ROOT_CLASS_NAME}-month-container {
520
+ display: flex;
521
+ flex: 1 1 auto;
522
+ justify-content: space-between;
523
+ }
524
+ `;
525
+ const {
526
+ Fragment,
527
+ useEffect,
528
+ useRef,
529
+ useState
530
+ } = React;
531
+ const getAbbreviatedMonthTitle = (month) => `${getMonthAbbreviationFromMonth(month)} ${getYearFromMonth(month)}`;
532
+ function DatePicker(t0) {
533
+ const $ = c(79);
534
+ let {
535
+ className,
536
+ dateEnd: _dateEnd,
537
+ dateStart: _dateStart,
538
+ initialMonth,
539
+ isRange: _isRange,
540
+ isTwoUp,
541
+ monthLimitFirst,
542
+ monthLimitLast: _monthLimitLast,
543
+ onChange,
544
+ showEndInitially,
545
+ useMonthAbbreviations
546
+ } = t0;
547
+ const isRange = _isRange ?? _dateEnd != null;
548
+ const monthLimitLast = isTwoUp && _monthLimitLast != null ? _monthLimitLast - 1 : _monthLimitLast;
549
+ let t1;
550
+ if ($[0] !== _dateEnd) {
551
+ t1 = _dateEnd != null && typeof _dateEnd !== "string" ? new Date(_dateEnd).toISOString() : _dateEnd;
552
+ $[0] = _dateEnd;
553
+ $[1] = t1;
554
+ } else {
555
+ t1 = $[1];
556
+ }
557
+ const dateEndFromProps = t1;
558
+ let t2;
559
+ if ($[2] !== _dateStart) {
560
+ t2 = _dateStart != null && typeof _dateStart !== "string" ? new Date(_dateStart).toISOString() : _dateStart;
561
+ $[2] = _dateStart;
562
+ $[3] = t2;
563
+ } else {
564
+ t2 = $[3];
565
+ }
566
+ const dateStartFromProps = t2;
567
+ const [dateEnd, setDateEnd] = useState(dateEndFromProps ?? null);
568
+ const [dateStart, setDateStart] = useState(dateStartFromProps ?? null);
569
+ const updatingDateEndRef = useRef(false);
570
+ let t3;
571
+ if ($[4] !== dateEndFromProps || $[5] !== setDateEnd) {
572
+ t3 = () => {
573
+ if (dateEndFromProps == null) {
574
+ return;
575
+ }
576
+ setDateEnd(dateEndFromProps);
577
+ };
578
+ $[4] = dateEndFromProps;
579
+ $[5] = setDateEnd;
580
+ $[6] = t3;
581
+ } else {
582
+ t3 = $[6];
583
+ }
584
+ let t4;
585
+ if ($[7] !== dateEndFromProps) {
586
+ t4 = [dateEndFromProps];
587
+ $[7] = dateEndFromProps;
588
+ $[8] = t4;
589
+ } else {
590
+ t4 = $[8];
591
+ }
592
+ useEffect(t3, t4);
593
+ let t5;
594
+ if ($[9] !== dateStartFromProps || $[10] !== setDateStart) {
595
+ t5 = () => {
596
+ if (dateStartFromProps == null) {
597
+ return;
598
+ }
599
+ setDateStart(dateStartFromProps);
600
+ };
601
+ $[9] = dateStartFromProps;
602
+ $[10] = setDateStart;
603
+ $[11] = t5;
604
+ } else {
605
+ t5 = $[11];
606
+ }
607
+ let t6;
608
+ if ($[12] !== dateStartFromProps) {
609
+ t6 = [dateStartFromProps];
610
+ $[12] = dateStartFromProps;
611
+ $[13] = t6;
612
+ } else {
613
+ t6 = $[13];
614
+ }
615
+ useEffect(t5, t6);
616
+ if (initialMonth == null) {
617
+ const useDateEnd = dateStart == null || Boolean(showEndInitially && dateEnd);
618
+ const initialDate = useDateEnd ? dateEnd : dateStart;
619
+ let t72;
620
+ if ($[14] !== initialDate) {
621
+ t72 = getMonthFromDate(initialDate == null ? /* @__PURE__ */ new Date() : new Date(initialDate));
622
+ $[14] = initialDate;
623
+ $[15] = t72;
624
+ } else {
625
+ t72 = $[15];
626
+ }
627
+ initialMonth = t72;
628
+ if (useDateEnd && isTwoUp) {
629
+ initialMonth = initialMonth - 1;
630
+ }
631
+ }
632
+ const [dateEndPreview, setDateEndPreview] = useState(null);
633
+ const [month, setMonth] = useState(initialMonth);
634
+ const delta = isTwoUp ? 2 : 1;
635
+ let t7;
636
+ if ($[16] !== delta || $[17] !== monthLimitFirst || $[18] !== setMonth) {
637
+ t7 = () => {
638
+ setMonth((existingMonth) => Math.max(existingMonth - delta, monthLimitFirst ?? -Infinity));
639
+ };
640
+ $[16] = delta;
641
+ $[17] = monthLimitFirst;
642
+ $[18] = setMonth;
643
+ $[19] = t7;
644
+ } else {
645
+ t7 = $[19];
646
+ }
647
+ const handleClickLeftArrow = t7;
648
+ let t8;
649
+ if ($[20] !== delta || $[21] !== monthLimitLast || $[22] !== setMonth) {
650
+ t8 = () => {
651
+ setMonth((existingMonth_0) => Math.min(existingMonth_0 + delta, monthLimitLast ?? Infinity));
652
+ };
653
+ $[20] = delta;
654
+ $[21] = monthLimitLast;
655
+ $[22] = setMonth;
656
+ $[23] = t8;
657
+ } else {
658
+ t8 = $[23];
659
+ }
660
+ const handleClickRightArrow = t8;
661
+ let t9;
662
+ if ($[24] !== dateEnd || $[25] !== dateStart || $[26] !== isRange || $[27] !== onChange || $[28] !== setDateEnd || $[29] !== setDateStart) {
663
+ t9 = (date) => {
664
+ if (isRange && dateStart != null && (updatingDateEndRef.current || dateEnd == null)) {
665
+ if (date < dateStart) {
666
+ setDateStart(date);
667
+ setDateEnd(dateStart);
668
+ onChange({
669
+ dateEnd: dateStart,
670
+ dateStart: date
671
+ });
672
+ } else {
673
+ setDateEnd(date);
674
+ onChange({
675
+ dateEnd: date,
676
+ dateStart
677
+ });
678
+ }
679
+ updatingDateEndRef.current = false;
680
+ } else {
681
+ setDateStart(date);
682
+ setDateEnd(null);
683
+ if (isRange) {
684
+ onChange({
685
+ dateEnd: null,
686
+ dateStart: date
687
+ });
688
+ updatingDateEndRef.current = true;
689
+ } else {
690
+ onChange({
691
+ dateStart: date
692
+ });
693
+ }
694
+ }
695
+ };
696
+ $[24] = dateEnd;
697
+ $[25] = dateStart;
698
+ $[26] = isRange;
699
+ $[27] = onChange;
700
+ $[28] = setDateEnd;
701
+ $[29] = setDateStart;
702
+ $[30] = t9;
703
+ } else {
704
+ t9 = $[30];
705
+ }
706
+ const handleChange = t9;
707
+ let t10;
708
+ if ($[31] !== setDateEndPreview) {
709
+ t10 = (date_0) => {
710
+ setDateEndPreview(date_0);
711
+ };
712
+ $[31] = setDateEndPreview;
713
+ $[32] = t10;
714
+ } else {
715
+ t10 = $[32];
716
+ }
717
+ const handleChangeEndPreview = t10;
718
+ let t11;
719
+ if ($[33] === Symbol.for("react.memo_cache_sentinel")) {
720
+ t11 = /* @__PURE__ */ jsx(Style, { href: "@acusti/date-picker/DatePicker", children: STYLES });
721
+ $[33] = t11;
722
+ } else {
723
+ t11 = $[33];
724
+ }
725
+ let t12;
726
+ if ($[34] !== className || $[35] !== isTwoUp) {
727
+ t12 = clsx(ROOT_CLASS_NAME, className, {
728
+ "two-up": isTwoUp
729
+ });
730
+ $[34] = className;
731
+ $[35] = isTwoUp;
732
+ $[36] = t12;
733
+ } else {
734
+ t12 = $[36];
735
+ }
736
+ const t13 = monthLimitFirst != null && month <= monthLimitFirst;
737
+ let t14;
738
+ if ($[37] !== t13) {
739
+ t14 = clsx(`${ROOT_CLASS_NAME}-range-arrow left-arrow`, {
740
+ disabled: t13
741
+ });
742
+ $[37] = t13;
743
+ $[38] = t14;
744
+ } else {
745
+ t14 = $[38];
746
+ }
747
+ let t15;
748
+ if ($[39] !== handleClickLeftArrow || $[40] !== t14) {
749
+ t15 = /* @__PURE__ */ jsx("div", { className: t14, onClick: handleClickLeftArrow });
750
+ $[39] = handleClickLeftArrow;
751
+ $[40] = t14;
752
+ $[41] = t15;
753
+ } else {
754
+ t15 = $[41];
755
+ }
756
+ const t16 = monthLimitLast != null && month >= monthLimitLast;
757
+ let t17;
758
+ if ($[42] !== t16) {
759
+ t17 = clsx(`${ROOT_CLASS_NAME}-range-arrow right-arrow`, {
760
+ disabled: t16
761
+ });
762
+ $[42] = t16;
763
+ $[43] = t17;
764
+ } else {
765
+ t17 = $[43];
766
+ }
767
+ let t18;
768
+ if ($[44] !== handleClickRightArrow || $[45] !== t17) {
769
+ t18 = /* @__PURE__ */ jsx("div", { className: t17, onClick: handleClickRightArrow });
770
+ $[44] = handleClickRightArrow;
771
+ $[45] = t17;
772
+ $[46] = t18;
773
+ } else {
774
+ t18 = $[46];
775
+ }
776
+ let t19;
777
+ if ($[47] !== t15 || $[48] !== t18) {
778
+ t19 = /* @__PURE__ */ jsxs("div", { className: `${ROOT_CLASS_NAME}-range-arrow-wrap`, children: [
779
+ t15,
780
+ t18
781
+ ] });
782
+ $[47] = t15;
783
+ $[48] = t18;
784
+ $[49] = t19;
785
+ } else {
786
+ t19 = $[49];
787
+ }
788
+ let t20;
789
+ if ($[50] !== month || $[51] !== useMonthAbbreviations) {
790
+ t20 = useMonthAbbreviations ? getAbbreviatedMonthTitle(month) : void 0;
791
+ $[50] = month;
792
+ $[51] = useMonthAbbreviations;
793
+ $[52] = t20;
794
+ } else {
795
+ t20 = $[52];
796
+ }
797
+ let t21;
798
+ if ($[53] !== dateEnd || $[54] !== dateEndPreview || $[55] !== dateStart || $[56] !== handleChange || $[57] !== handleChangeEndPreview || $[58] !== isRange || $[59] !== month || $[60] !== t20) {
799
+ t21 = /* @__PURE__ */ jsx(MonthCalendar, { dateEnd, dateEndPreview, dateStart, isRange, month, onChange: handleChange, onChangeEndPreview: handleChangeEndPreview, title: t20 });
800
+ $[53] = dateEnd;
801
+ $[54] = dateEndPreview;
802
+ $[55] = dateStart;
803
+ $[56] = handleChange;
804
+ $[57] = handleChangeEndPreview;
805
+ $[58] = isRange;
806
+ $[59] = month;
807
+ $[60] = t20;
808
+ $[61] = t21;
809
+ } else {
810
+ t21 = $[61];
811
+ }
812
+ let t22;
813
+ if ($[62] !== dateEnd || $[63] !== dateEndPreview || $[64] !== dateStart || $[65] !== handleChange || $[66] !== handleChangeEndPreview || $[67] !== isRange || $[68] !== isTwoUp || $[69] !== month || $[70] !== useMonthAbbreviations) {
814
+ t22 = isTwoUp ? /* @__PURE__ */ jsx(MonthCalendar, { dateEnd, dateEndPreview, dateStart, isRange, month: month + 1, onChange: handleChange, onChangeEndPreview: handleChangeEndPreview, title: useMonthAbbreviations ? getAbbreviatedMonthTitle(month + 1) : void 0 }) : null;
815
+ $[62] = dateEnd;
816
+ $[63] = dateEndPreview;
817
+ $[64] = dateStart;
818
+ $[65] = handleChange;
819
+ $[66] = handleChangeEndPreview;
820
+ $[67] = isRange;
821
+ $[68] = isTwoUp;
822
+ $[69] = month;
823
+ $[70] = useMonthAbbreviations;
824
+ $[71] = t22;
825
+ } else {
826
+ t22 = $[71];
827
+ }
828
+ let t23;
829
+ if ($[72] !== t21 || $[73] !== t22) {
830
+ t23 = /* @__PURE__ */ jsxs("div", { className: `${ROOT_CLASS_NAME}-month-container`, children: [
831
+ t21,
832
+ t22
833
+ ] });
834
+ $[72] = t21;
835
+ $[73] = t22;
836
+ $[74] = t23;
837
+ } else {
838
+ t23 = $[74];
839
+ }
840
+ let t24;
841
+ if ($[75] !== t12 || $[76] !== t19 || $[77] !== t23) {
842
+ t24 = /* @__PURE__ */ jsxs(Fragment, { children: [
843
+ t11,
844
+ /* @__PURE__ */ jsxs("div", { className: t12, children: [
845
+ t19,
846
+ t23
847
+ ] })
848
+ ] });
849
+ $[75] = t12;
850
+ $[76] = t19;
851
+ $[77] = t23;
852
+ $[78] = t24;
853
+ } else {
854
+ t24 = $[78];
855
+ }
856
+ return t24;
857
+ }
858
+ export {
859
+ DatePicker,
860
+ MonthCalendar,
861
+ getDateFromMonthAndDay,
862
+ getLastDateFromMonth,
863
+ getMonthAbbreviationFromMonth,
864
+ getMonthFromDate,
865
+ getMonthNameFromMonth,
866
+ getYearFromMonth
867
+ };
868
+ //# sourceMappingURL=index.js.map