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