@acusti/date-picker 0.12.0 → 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/README.md +625 -27
- package/dist/DatePicker.d.ts +2 -2
- package/dist/MonthCalendar.d.ts +1 -1
- package/dist/index.js +241 -247
- package/dist/index.js.map +1 -1
- package/dist/styles/date-picker.d.ts +1 -1
- package/dist/styles/month-calendar.d.ts +1 -1
- package/package.json +11 -11
package/dist/MonthCalendar.d.ts
CHANGED
|
@@ -9,4 +9,4 @@ export type Props = {
|
|
|
9
9
|
onChangeEndPreview?: (date: string) => void;
|
|
10
10
|
title?: string;
|
|
11
11
|
};
|
|
12
|
-
export default function MonthCalendar({ className, dateEnd, dateEndPreview, dateStart, isRange, month, onChange, onChangeEndPreview, title, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export default function MonthCalendar({ className, dateEnd, dateEndPreview, dateStart, isRange, month: _month, onChange, onChangeEndPreview, title, }: Props): import("react/jsx-runtime").JSX.Element;
|
package/dist/index.js
CHANGED
|
@@ -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
|
}
|
|
@@ -185,278 +194,256 @@ const getLastDateFromMonth = (month, asUTC) => {
|
|
|
185
194
|
};
|
|
186
195
|
const DAYS = Array(7).fill(null);
|
|
187
196
|
function MonthCalendar(t0) {
|
|
188
|
-
const $ = c(
|
|
197
|
+
const $ = c(46);
|
|
189
198
|
let {
|
|
190
199
|
className,
|
|
191
200
|
dateEnd,
|
|
192
201
|
dateEndPreview,
|
|
193
202
|
dateStart,
|
|
194
203
|
isRange,
|
|
195
|
-
month,
|
|
204
|
+
month: _month,
|
|
196
205
|
onChange,
|
|
197
206
|
onChangeEndPreview,
|
|
198
207
|
title
|
|
199
208
|
} = t0;
|
|
200
|
-
|
|
201
|
-
title = title ?? `${getMonthNameFromMonth(month)} ${year}`;
|
|
202
|
-
let firstDay;
|
|
209
|
+
let T0;
|
|
203
210
|
let t1;
|
|
204
211
|
let t2;
|
|
205
|
-
let
|
|
206
|
-
|
|
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}`;
|
|
207
221
|
const firstDate = getDateFromMonthAndDay(month, 1);
|
|
208
222
|
const lastDate = getLastDateFromMonth(month);
|
|
209
|
-
totalDays = lastDate.getDate();
|
|
210
|
-
firstDay = firstDate.getDay();
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
let t42;
|
|
229
|
-
if ($[11] !== month || $[12] !== totalDays) {
|
|
230
|
-
t42 = (acc, date, index) => {
|
|
231
|
-
if (date != null && !(date instanceof Date)) {
|
|
232
|
-
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();
|
|
233
242
|
}
|
|
234
|
-
|
|
235
|
-
|
|
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;
|
|
236
250
|
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
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);
|
|
246
262
|
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
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);
|
|
253
279
|
}
|
|
254
280
|
}
|
|
255
|
-
return acc;
|
|
256
281
|
};
|
|
257
|
-
$[
|
|
258
|
-
$[
|
|
259
|
-
$[
|
|
282
|
+
$[19] = isRange;
|
|
283
|
+
$[20] = onChangeEndPreview;
|
|
284
|
+
$[21] = t82;
|
|
260
285
|
} else {
|
|
261
|
-
|
|
286
|
+
t82 = $[21];
|
|
262
287
|
}
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
$[
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
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];
|
|
315
408
|
}
|
|
316
409
|
let t7;
|
|
317
|
-
if ($[
|
|
318
|
-
t7 =
|
|
319
|
-
$[
|
|
320
|
-
$[
|
|
410
|
+
if ($[34] !== t1 || $[35] !== t2) {
|
|
411
|
+
t7 = /* @__PURE__ */ jsx("div", { className: t1, children: t2 });
|
|
412
|
+
$[34] = t1;
|
|
413
|
+
$[35] = t2;
|
|
414
|
+
$[36] = t7;
|
|
321
415
|
} else {
|
|
322
|
-
t7 = $[
|
|
416
|
+
t7 = $[36];
|
|
323
417
|
}
|
|
324
418
|
let t8;
|
|
325
|
-
if ($[
|
|
326
|
-
t8 = /* @__PURE__ */
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
t8 = $[23];
|
|
331
|
-
}
|
|
332
|
-
let t9;
|
|
333
|
-
if ($[24] === Symbol.for("react.memo_cache_sentinel")) {
|
|
334
|
-
t9 = /* @__PURE__ */ jsx("div", { className: "week-day-item", children: /* @__PURE__ */ jsx("span", { className: "week-day-item-text", children: "Su" }) });
|
|
335
|
-
$[24] = t9;
|
|
336
|
-
} else {
|
|
337
|
-
t9 = $[24];
|
|
338
|
-
}
|
|
339
|
-
let t10;
|
|
340
|
-
if ($[25] === Symbol.for("react.memo_cache_sentinel")) {
|
|
341
|
-
t10 = /* @__PURE__ */ jsx("div", { className: "week-day-item", children: /* @__PURE__ */ jsx("span", { className: "week-day-item-text", children: "Mo" }) });
|
|
342
|
-
$[25] = t10;
|
|
343
|
-
} else {
|
|
344
|
-
t10 = $[25];
|
|
345
|
-
}
|
|
346
|
-
let t11;
|
|
347
|
-
if ($[26] === Symbol.for("react.memo_cache_sentinel")) {
|
|
348
|
-
t11 = /* @__PURE__ */ jsx("div", { className: "week-day-item", children: /* @__PURE__ */ jsx("span", { className: "week-day-item-text", children: "Tu" }) });
|
|
349
|
-
$[26] = t11;
|
|
350
|
-
} else {
|
|
351
|
-
t11 = $[26];
|
|
352
|
-
}
|
|
353
|
-
let t12;
|
|
354
|
-
if ($[27] === Symbol.for("react.memo_cache_sentinel")) {
|
|
355
|
-
t12 = /* @__PURE__ */ jsx("div", { className: "week-day-item", children: /* @__PURE__ */ jsx("span", { className: "week-day-item-text", children: "We" }) });
|
|
356
|
-
$[27] = t12;
|
|
357
|
-
} else {
|
|
358
|
-
t12 = $[27];
|
|
359
|
-
}
|
|
360
|
-
let t13;
|
|
361
|
-
if ($[28] === Symbol.for("react.memo_cache_sentinel")) {
|
|
362
|
-
t13 = /* @__PURE__ */ jsx("div", { className: "week-day-item", children: /* @__PURE__ */ jsx("span", { className: "week-day-item-text", children: "Th" }) });
|
|
363
|
-
$[28] = t13;
|
|
364
|
-
} else {
|
|
365
|
-
t13 = $[28];
|
|
366
|
-
}
|
|
367
|
-
let t14;
|
|
368
|
-
if ($[29] === Symbol.for("react.memo_cache_sentinel")) {
|
|
369
|
-
t14 = /* @__PURE__ */ jsx("div", { className: "week-day-item", children: /* @__PURE__ */ jsx("span", { className: "week-day-item-text", children: "Fr" }) });
|
|
370
|
-
$[29] = t14;
|
|
371
|
-
} else {
|
|
372
|
-
t14 = $[29];
|
|
373
|
-
}
|
|
374
|
-
let t15;
|
|
375
|
-
if ($[30] === Symbol.for("react.memo_cache_sentinel")) {
|
|
376
|
-
t15 = /* @__PURE__ */ jsxs("div", { className: `${ROOT_CLASS_NAME$1}-month-week`, children: [
|
|
377
|
-
t9,
|
|
378
|
-
t10,
|
|
379
|
-
t11,
|
|
380
|
-
t12,
|
|
381
|
-
t13,
|
|
382
|
-
t14,
|
|
383
|
-
/* @__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
|
|
384
424
|
] });
|
|
385
|
-
$[
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
let t17;
|
|
391
|
-
if ($[31] !== dateRangeEndDay || $[32] !== dateRangeEndPreviewDay || $[33] !== dateRangeStartDay || $[34] !== firstDay || $[35] !== handleClickDay || $[36] !== handleMouseEnterDay || $[37] !== month || $[38] !== t16 || $[39] !== totalDays) {
|
|
392
|
-
let t182;
|
|
393
|
-
if ($[41] !== dateRangeEndDay || $[42] !== dateRangeEndPreviewDay || $[43] !== dateRangeStartDay || $[44] !== firstDay || $[45] !== handleClickDay || $[46] !== handleMouseEnterDay || $[47] !== month || $[48] !== totalDays) {
|
|
394
|
-
t182 = (_, weekIndex) => /* @__PURE__ */ jsx("div", { className: `${ROOT_CLASS_NAME$1}-month-row`, children: DAYS.map((__, dayIndex) => {
|
|
395
|
-
dayIndex = dayIndex + weekIndex * 7;
|
|
396
|
-
const dayNumber = dayIndex - firstDay + 1;
|
|
397
|
-
const isEmpty = dayNumber < 1 || dayNumber > totalDays;
|
|
398
|
-
const date_2 = isEmpty ? null : getDateFromMonthAndDay(month, dayNumber);
|
|
399
|
-
const isAfterDateRangeStart = dateRangeStartDay != null && dayNumber > dateRangeStartDay;
|
|
400
|
-
const isBeforeDateRangeEnd = dateRangeEndDay == null && dateRangeEndPreviewDay != null && dayNumber < dateRangeEndPreviewDay || dateRangeEndDay != null && dayNumber < dateRangeEndDay;
|
|
401
|
-
return /* @__PURE__ */ jsx("button", { className: clsx(`${ROOT_CLASS_NAME$1}-month-day-item`, {
|
|
402
|
-
"end-date": !isEmpty && dayNumber === dateRangeEndDay,
|
|
403
|
-
"is-empty": isEmpty,
|
|
404
|
-
"is-selected": !isEmpty && isAfterDateRangeStart && isBeforeDateRangeEnd,
|
|
405
|
-
"start-date": !isEmpty && dayNumber === dateRangeStartDay
|
|
406
|
-
}), "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}`);
|
|
407
|
-
}) }, `MonthRow-${weekIndex}`);
|
|
408
|
-
$[41] = dateRangeEndDay;
|
|
409
|
-
$[42] = dateRangeEndPreviewDay;
|
|
410
|
-
$[43] = dateRangeStartDay;
|
|
411
|
-
$[44] = firstDay;
|
|
412
|
-
$[45] = handleClickDay;
|
|
413
|
-
$[46] = handleMouseEnterDay;
|
|
414
|
-
$[47] = month;
|
|
415
|
-
$[48] = totalDays;
|
|
416
|
-
$[49] = t182;
|
|
417
|
-
} else {
|
|
418
|
-
t182 = $[49];
|
|
419
|
-
}
|
|
420
|
-
t17 = Array(t16).fill(null).map(t182);
|
|
421
|
-
$[31] = dateRangeEndDay;
|
|
422
|
-
$[32] = dateRangeEndPreviewDay;
|
|
423
|
-
$[33] = dateRangeStartDay;
|
|
424
|
-
$[34] = firstDay;
|
|
425
|
-
$[35] = handleClickDay;
|
|
426
|
-
$[36] = handleMouseEnterDay;
|
|
427
|
-
$[37] = month;
|
|
428
|
-
$[38] = t16;
|
|
429
|
-
$[39] = totalDays;
|
|
430
|
-
$[40] = t17;
|
|
425
|
+
$[37] = t3;
|
|
426
|
+
$[38] = t4;
|
|
427
|
+
$[39] = t5;
|
|
428
|
+
$[40] = t7;
|
|
429
|
+
$[41] = t8;
|
|
431
430
|
} else {
|
|
432
|
-
|
|
431
|
+
t8 = $[41];
|
|
433
432
|
}
|
|
434
|
-
let
|
|
435
|
-
if ($[
|
|
436
|
-
|
|
437
|
-
$[50] = t17;
|
|
438
|
-
$[51] = t18;
|
|
439
|
-
} else {
|
|
440
|
-
t18 = $[51];
|
|
441
|
-
}
|
|
442
|
-
let t19;
|
|
443
|
-
if ($[52] !== t18 || $[53] !== t7 || $[54] !== t8) {
|
|
444
|
-
t19 = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
433
|
+
let t9;
|
|
434
|
+
if ($[42] !== T0 || $[43] !== t6 || $[44] !== t8) {
|
|
435
|
+
t9 = /* @__PURE__ */ jsxs(T0, { children: [
|
|
445
436
|
t6,
|
|
446
|
-
|
|
447
|
-
t8,
|
|
448
|
-
t15,
|
|
449
|
-
t18
|
|
450
|
-
] })
|
|
437
|
+
t8
|
|
451
438
|
] });
|
|
452
|
-
$[
|
|
453
|
-
$[
|
|
454
|
-
$[
|
|
455
|
-
$[
|
|
439
|
+
$[42] = T0;
|
|
440
|
+
$[43] = t6;
|
|
441
|
+
$[44] = t8;
|
|
442
|
+
$[45] = t9;
|
|
456
443
|
} else {
|
|
457
|
-
|
|
444
|
+
t9 = $[45];
|
|
458
445
|
}
|
|
459
|
-
return
|
|
446
|
+
return t9;
|
|
460
447
|
}
|
|
461
448
|
const ROOT_CLASS_NAME = "uktdatepicker";
|
|
462
449
|
const STYLES = `
|
|
@@ -486,6 +473,8 @@ const STYLES = `
|
|
|
486
473
|
}
|
|
487
474
|
|
|
488
475
|
.${ROOT_CLASS_NAME}-range-arrow {
|
|
476
|
+
background-color: transparent;
|
|
477
|
+
border: 0;
|
|
489
478
|
width: 35px;
|
|
490
479
|
height: 35px;
|
|
491
480
|
text-align: center;
|
|
@@ -506,7 +495,6 @@ const STYLES = `
|
|
|
506
495
|
content: "‹";
|
|
507
496
|
font-size: 24px;
|
|
508
497
|
line-height: 35px;
|
|
509
|
-
font-weight: bold;
|
|
510
498
|
}
|
|
511
499
|
|
|
512
500
|
.${ROOT_CLASS_NAME}-range-arrow.right-arrow:after {
|
|
@@ -520,6 +508,10 @@ const STYLES = `
|
|
|
520
508
|
}
|
|
521
509
|
`;
|
|
522
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
|
+
};
|
|
523
515
|
function DatePicker(t0) {
|
|
524
516
|
const $ = c(68);
|
|
525
517
|
let {
|
|
@@ -539,7 +531,7 @@ function DatePicker(t0) {
|
|
|
539
531
|
const monthLimitLast = isTwoUp && _monthLimitLast != null ? _monthLimitLast - 1 : _monthLimitLast;
|
|
540
532
|
let t1;
|
|
541
533
|
if ($[0] !== _dateEnd) {
|
|
542
|
-
t1 =
|
|
534
|
+
t1 = normalizeDate(_dateEnd);
|
|
543
535
|
$[0] = _dateEnd;
|
|
544
536
|
$[1] = t1;
|
|
545
537
|
} else {
|
|
@@ -548,15 +540,15 @@ function DatePicker(t0) {
|
|
|
548
540
|
const dateEndFromProps = t1;
|
|
549
541
|
let t2;
|
|
550
542
|
if ($[2] !== _dateStart) {
|
|
551
|
-
t2 =
|
|
543
|
+
t2 = normalizeDate(_dateStart);
|
|
552
544
|
$[2] = _dateStart;
|
|
553
545
|
$[3] = t2;
|
|
554
546
|
} else {
|
|
555
547
|
t2 = $[3];
|
|
556
548
|
}
|
|
557
549
|
const dateStartFromProps = t2;
|
|
558
|
-
const [dateEnd, setDateEnd] = useState(dateEndFromProps
|
|
559
|
-
const [dateStart, setDateStart] = useState(dateStartFromProps
|
|
550
|
+
const [dateEnd, setDateEnd] = useState(dateEndFromProps);
|
|
551
|
+
const [dateStart, setDateStart] = useState(dateStartFromProps);
|
|
560
552
|
const updatingDateEndRef = useRef(false);
|
|
561
553
|
let t3;
|
|
562
554
|
let t4;
|
|
@@ -610,8 +602,10 @@ function DatePicker(t0) {
|
|
|
610
602
|
initialMonth = initialMonth - 1;
|
|
611
603
|
}
|
|
612
604
|
}
|
|
613
|
-
const
|
|
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);
|
|
614
607
|
const [month, setMonth] = useState(initialMonth);
|
|
608
|
+
const [dateEndPreview, setDateEndPreview] = useState(null);
|
|
615
609
|
const delta = isTwoUp ? 2 : 1;
|
|
616
610
|
let t7;
|
|
617
611
|
if ($[12] !== delta || $[13] !== monthLimitFirst) {
|
|
@@ -722,7 +716,7 @@ function DatePicker(t0) {
|
|
|
722
716
|
}
|
|
723
717
|
let t15;
|
|
724
718
|
if ($[30] !== handleClickLeftArrow || $[31] !== t14) {
|
|
725
|
-
t15 = /* @__PURE__ */ jsx("
|
|
719
|
+
t15 = /* @__PURE__ */ jsx("button", { "aria-label": "Previous Month", className: t14, onClick: handleClickLeftArrow, type: "button" });
|
|
726
720
|
$[30] = handleClickLeftArrow;
|
|
727
721
|
$[31] = t14;
|
|
728
722
|
$[32] = t15;
|
|
@@ -742,7 +736,7 @@ function DatePicker(t0) {
|
|
|
742
736
|
}
|
|
743
737
|
let t18;
|
|
744
738
|
if ($[35] !== handleClickRightArrow || $[36] !== t17) {
|
|
745
|
-
t18 = /* @__PURE__ */ jsx("
|
|
739
|
+
t18 = /* @__PURE__ */ jsx("button", { "aria-label": "Next Month", className: t17, onClick: handleClickRightArrow, type: "button" });
|
|
746
740
|
$[35] = handleClickRightArrow;
|
|
747
741
|
$[36] = t17;
|
|
748
742
|
$[37] = t18;
|