@sia.soul/sia-react-ui 0.1.160 → 0.1.163
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/{Select-DIdEbGwf.d.cts → Select-Dxevc0f6.d.cts} +1 -1
- package/dist/{Select-BCVUoK0I.d.ts → Select-tsENCXQI.d.ts} +1 -1
- package/dist/chart.cjs +10 -10
- package/dist/chart.js +5 -5
- package/dist/{chunk-EMBCJFJM.js → chunk-23FQ5ARA.js} +4 -4
- package/dist/{chunk-H6UTSSZM.js → chunk-2EC653G5.js} +5 -5
- package/dist/{chunk-SRWUDTCS.js → chunk-CUAXJCSH.js} +10 -10
- package/dist/{chunk-KDIJYXKW.js → chunk-DKQ5UCN6.js} +618 -273
- package/dist/{chunk-ZIH5VLPT.js → chunk-G5EJJFUI.js} +2 -2
- package/dist/{chunk-NRLIOMXY.js → chunk-J6BPKBEL.js} +2 -2
- package/dist/{chunk-6SSZVJO4.js → chunk-NHGCGOF2.js} +3 -3
- package/dist/{chunk-YO5OJQEH.js → chunk-OHAESA5R.js} +1 -1
- package/dist/{chunk-PU2V3VB5.js → chunk-PAWEP65C.js} +1 -1
- package/dist/{chunk-REAWVQH2.js → chunk-SX4LLT3H.js} +5 -5
- package/dist/{chunk-XXFYFLZA.js → chunk-V4I32DPL.js} +2 -2
- package/dist/{chunk-P5ZCOIKQ.js → chunk-WR5YBY2A.js} +6 -6
- package/dist/{core--AEiGVOU.d.ts → core-XtqUDbbD.d.ts} +3 -3
- package/dist/{core-DolUEUCo.d.cts → core-r-smfiNN.d.cts} +3 -3
- package/dist/core.cjs +10 -10
- package/dist/core.css +245 -29
- package/dist/core.d.cts +2 -2
- package/dist/core.d.ts +2 -2
- package/dist/core.js +8 -8
- package/dist/game.cjs +10 -10
- package/dist/game.js +3 -3
- package/dist/index.cjs +666 -320
- package/dist/index.css +245 -29
- package/dist/index.d.cts +13 -8
- package/dist/index.d.ts +13 -8
- package/dist/index.js +60 -59
- package/dist/markdown-editor.cjs +10 -10
- package/dist/markdown-editor.js +3 -3
- package/dist/rich-text-editor.cjs +10 -10
- package/dist/rich-text-editor.js +7 -7
- package/dist/{select-date-range-CIwE5nFu.d.cts → select-date-range-C9lTBQFX.d.cts} +10 -11
- package/dist/{select-date-range-DYrA87Tl.d.ts → select-date-range-CQCGGkkt.d.ts} +10 -11
- package/dist/select-date-range.cjs +618 -273
- package/dist/select-date-range.d.cts +2 -2
- package/dist/select-date-range.d.ts +2 -2
- package/dist/select-date-range.js +8 -8
- package/package.json +1 -1
|
@@ -532,8 +532,8 @@ var import_react3 = require("react");
|
|
|
532
532
|
// src/components/popupFluidMotion.ts
|
|
533
533
|
var popupEnterDuration = 260;
|
|
534
534
|
var popupExitDuration = 140;
|
|
535
|
-
var popupInitialScale = 0.
|
|
536
|
-
var popupTravelOffset =
|
|
535
|
+
var popupInitialScale = 0.93;
|
|
536
|
+
var popupTravelOffset = 4;
|
|
537
537
|
function popupFluidFrames(placement, open = true) {
|
|
538
538
|
const side = placement.split("-")[0];
|
|
539
539
|
const axis = side === "left" || side === "right" ? "X" : "Y";
|
|
@@ -542,8 +542,8 @@ function popupFluidFrames(placement, open = true) {
|
|
|
542
542
|
const visible = { opacity: 1, transform: "none" };
|
|
543
543
|
return open ? [
|
|
544
544
|
{ ...hidden, offset: 0 },
|
|
545
|
-
{ opacity: 1, transform: "scale(1.
|
|
546
|
-
{ opacity: 1, transform: "scale(.
|
|
545
|
+
{ opacity: 1, transform: "scale(1.05, 1.04)", offset: 0.68 },
|
|
546
|
+
{ opacity: 1, transform: "scale(.977, .985)", offset: 0.86 },
|
|
547
547
|
{ ...visible, offset: 1 }
|
|
548
548
|
] : [{ ...visible, offset: 0 }, { ...hidden, offset: 1 }];
|
|
549
549
|
}
|
|
@@ -563,16 +563,16 @@ function motionFrames(kind, placement) {
|
|
|
563
563
|
const outside = `translate${axis}(${sign * 100}%)`;
|
|
564
564
|
return [
|
|
565
565
|
{ transform: outside, offset: 0 },
|
|
566
|
-
{ transform: `translate${axis}(0) scale${axis}(1.
|
|
567
|
-
{ transform: `translate${axis}(0) scale${axis}(.
|
|
566
|
+
{ transform: `translate${axis}(0) scale${axis}(1.03)`, offset: 0.68 },
|
|
567
|
+
{ transform: `translate${axis}(0) scale${axis}(.988)`, offset: 0.86 },
|
|
568
568
|
{ transform: "none", offset: 1 }
|
|
569
569
|
];
|
|
570
570
|
}
|
|
571
571
|
const modal = kind === "modal";
|
|
572
572
|
return [
|
|
573
|
-
{ opacity: 0, transform: `translateY(${modal ?
|
|
574
|
-
{ opacity: 1, transform: modal ? "scale(1.
|
|
575
|
-
{ opacity: 1, transform: modal ? "scale(.
|
|
573
|
+
{ opacity: 0, transform: `translateY(${modal ? 14 : -4}px) scale(${modal ? 0.95 : 0.93})`, offset: 0 },
|
|
574
|
+
{ opacity: 1, transform: modal ? "scale(1.035, 1.02)" : "scale(1.05, 1.04)", offset: 0.68 },
|
|
575
|
+
{ opacity: 1, transform: modal ? "scale(.984, .992)" : "scale(.977, .985)", offset: 0.86 },
|
|
576
576
|
{ opacity: 1, transform: "none", offset: 1 }
|
|
577
577
|
];
|
|
578
578
|
}
|
|
@@ -790,7 +790,7 @@ var PopupPortal = (0, import_react4.forwardRef)(function PopupPortal2({
|
|
|
790
790
|
cancelAnimationFrame(frame);
|
|
791
791
|
observer.disconnect();
|
|
792
792
|
};
|
|
793
|
-
}, [anchorRef, offset, motion.present, placement, viewportPadding]);
|
|
793
|
+
}, [anchorRef, offset, motion.present, placement, viewportPadding, position?.availableHeight, position?.placement]);
|
|
794
794
|
if (!motion.present || typeof document === "undefined") return null;
|
|
795
795
|
return (0, import_react_dom.createPortal)(
|
|
796
796
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
@@ -2287,8 +2287,51 @@ function CalendarMonth({
|
|
|
2287
2287
|
previewEnd,
|
|
2288
2288
|
disabledDate,
|
|
2289
2289
|
onSelect,
|
|
2290
|
-
onHover
|
|
2290
|
+
onHover,
|
|
2291
|
+
onSwipeMonth
|
|
2291
2292
|
}) {
|
|
2293
|
+
const monthRef = (0, import_react8.useRef)(null);
|
|
2294
|
+
const swipe = (0, import_react8.useRef)({ startX: 0, startY: 0, pointerId: -1, dragging: false, lastTime: 0, lastX: 0, velocity: 0 });
|
|
2295
|
+
function onMonthPointerDown(event) {
|
|
2296
|
+
if (!onSwipeMonth || event.button !== 0) return;
|
|
2297
|
+
swipe.current = { startX: event.clientX, startY: event.clientY, pointerId: event.pointerId, dragging: false, lastTime: event.timeStamp, lastX: event.clientX, velocity: 0 };
|
|
2298
|
+
}
|
|
2299
|
+
function onMonthPointerMove(event) {
|
|
2300
|
+
const state = swipe.current;
|
|
2301
|
+
if (!onSwipeMonth || state.pointerId !== event.pointerId || !monthRef.current) return;
|
|
2302
|
+
const dx = event.clientX - state.startX;
|
|
2303
|
+
const dy = event.clientY - state.startY;
|
|
2304
|
+
if (!state.dragging && Math.abs(dx) > 6 && Math.abs(dx) > Math.abs(dy)) {
|
|
2305
|
+
state.dragging = true;
|
|
2306
|
+
try {
|
|
2307
|
+
monthRef.current?.setPointerCapture(event.pointerId);
|
|
2308
|
+
} catch {
|
|
2309
|
+
}
|
|
2310
|
+
}
|
|
2311
|
+
if (!state.dragging) return;
|
|
2312
|
+
monthRef.current.style.transition = "none";
|
|
2313
|
+
monthRef.current.style.transform = `translateX(${dx}px)`;
|
|
2314
|
+
const dt = event.timeStamp - state.lastTime;
|
|
2315
|
+
if (dt > 0) state.velocity = (event.clientX - state.lastX) / dt;
|
|
2316
|
+
state.lastTime = event.timeStamp;
|
|
2317
|
+
state.lastX = event.clientX;
|
|
2318
|
+
}
|
|
2319
|
+
function onMonthPointerUp(event) {
|
|
2320
|
+
const state = swipe.current;
|
|
2321
|
+
const node = monthRef.current;
|
|
2322
|
+
if (state.pointerId !== event.pointerId || !node) return;
|
|
2323
|
+
state.pointerId = -1;
|
|
2324
|
+
try {
|
|
2325
|
+
node.releasePointerCapture?.(event.pointerId);
|
|
2326
|
+
} catch {
|
|
2327
|
+
}
|
|
2328
|
+
if (!state.dragging) return;
|
|
2329
|
+
const dx = event.clientX - state.startX;
|
|
2330
|
+
const shouldSwitch = Math.abs(dx) >= 56 || Math.abs(state.velocity) > 0.5;
|
|
2331
|
+
if (shouldSwitch && onSwipeMonth) onSwipeMonth(dx < 0 ? 1 : -1);
|
|
2332
|
+
node.style.transition = "transform 220ms cubic-bezier(.2, .7, .2, 1)";
|
|
2333
|
+
node.style.transform = "translateX(0)";
|
|
2334
|
+
}
|
|
2292
2335
|
const first = startOfMonth(month);
|
|
2293
2336
|
const mondayIndex = (first.getDay() + 6) % 7;
|
|
2294
2337
|
const gridStart = addDays(first, -mondayIndex);
|
|
@@ -2297,43 +2340,63 @@ function CalendarMonth({
|
|
|
2297
2340
|
const end = range[1] || previewEnd || "";
|
|
2298
2341
|
const low = start && end ? start <= end ? start : end : "";
|
|
2299
2342
|
const high = start && end ? start <= end ? end : start : "";
|
|
2300
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2343
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
2344
|
+
"div",
|
|
2345
|
+
{
|
|
2346
|
+
className: "sia-date-panel__month",
|
|
2347
|
+
ref: monthRef,
|
|
2348
|
+
onPointerDown: onMonthPointerDown,
|
|
2349
|
+
onPointerMove: onMonthPointerMove,
|
|
2350
|
+
onPointerUp: onMonthPointerUp,
|
|
2351
|
+
onPointerCancel: onMonthPointerUp,
|
|
2352
|
+
onClickCapture: (event) => {
|
|
2353
|
+
if (!swipe.current.dragging) return;
|
|
2354
|
+
event.preventDefault();
|
|
2355
|
+
event.stopPropagation();
|
|
2356
|
+
swipe.current.dragging = false;
|
|
2357
|
+
},
|
|
2358
|
+
children: [
|
|
2359
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "sia-date-panel__weekdays", "aria-hidden": "true", children: WEEKDAYS.map((day) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { children: day }, day)) }),
|
|
2360
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "sia-date-panel__days", children: Array.from({ length: 42 }, (_, index) => {
|
|
2361
|
+
const date = addDays(gridStart, index);
|
|
2362
|
+
const key = dateKey(date);
|
|
2363
|
+
const outside = date.getMonth() !== month.getMonth();
|
|
2364
|
+
const disabled = disabledDate?.(key) ?? false;
|
|
2365
|
+
const selected = selectedDates.includes(key);
|
|
2366
|
+
const rangeStart = Boolean(start && key === start);
|
|
2367
|
+
const rangeEnd = Boolean(range[1] && key === range[1]);
|
|
2368
|
+
const inRange = Boolean(low && high && key >= low && key <= high);
|
|
2369
|
+
const segmentStart = inRange && (index % 7 === 0 || key === low);
|
|
2370
|
+
const segmentEnd = inRange && (index % 7 === 6 || key === high);
|
|
2371
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2372
|
+
"span",
|
|
2317
2373
|
{
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2374
|
+
className: `sia-date-panel__cell${outside ? " is-outside" : ""}${selected ? " is-selected" : ""}${rangeStart ? " is-range-start" : ""}${rangeEnd ? " is-range-end" : ""}${inRange ? " is-in-range" : ""}${segmentStart ? " is-range-segment-start" : ""}${segmentEnd ? " is-range-segment-end" : ""}${key === today ? " is-today" : ""}`,
|
|
2375
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2376
|
+
"button",
|
|
2377
|
+
{
|
|
2378
|
+
type: "button",
|
|
2379
|
+
"aria-label": key,
|
|
2380
|
+
"aria-pressed": selected || rangeStart || rangeEnd || void 0,
|
|
2381
|
+
disabled,
|
|
2382
|
+
onClick: () => onSelect(key),
|
|
2383
|
+
onMouseEnter: () => onHover?.(key),
|
|
2384
|
+
children: date.getDate()
|
|
2385
|
+
}
|
|
2386
|
+
)
|
|
2387
|
+
},
|
|
2388
|
+
key
|
|
2389
|
+
);
|
|
2390
|
+
}) })
|
|
2391
|
+
]
|
|
2392
|
+
}
|
|
2393
|
+
);
|
|
2332
2394
|
}
|
|
2333
2395
|
function CalendarHeader({
|
|
2334
2396
|
month,
|
|
2335
2397
|
label,
|
|
2336
2398
|
range = false,
|
|
2399
|
+
onTitleClick,
|
|
2337
2400
|
onPreviousYear,
|
|
2338
2401
|
onPreviousMonth,
|
|
2339
2402
|
onNextMonth,
|
|
@@ -2347,7 +2410,15 @@ function CalendarHeader({
|
|
|
2347
2410
|
] }) : null,
|
|
2348
2411
|
onPreviousMonth ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { type: "button", "aria-label": "\u4E0A\u4E2A\u6708", onClick: onPreviousMonth, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { name: "chevron-left", size: 15 }) }) : null
|
|
2349
2412
|
] }),
|
|
2350
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("
|
|
2413
|
+
onTitleClick ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("button", { type: "button", className: "sia-date-panel__title", "aria-label": "\u9009\u62E9\u5E74\u4EFD", onClick: onTitleClick, children: [
|
|
2414
|
+
label ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("small", { children: label }) : null,
|
|
2415
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { children: [
|
|
2416
|
+
month.getFullYear(),
|
|
2417
|
+
"\u5E74\xA0 ",
|
|
2418
|
+
month.getMonth() + 1,
|
|
2419
|
+
"\u6708"
|
|
2420
|
+
] })
|
|
2421
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("strong", { children: [
|
|
2351
2422
|
label ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("small", { children: label }) : null,
|
|
2352
2423
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { children: [
|
|
2353
2424
|
month.getFullYear(),
|
|
@@ -2366,36 +2437,146 @@ function CalendarHeader({
|
|
|
2366
2437
|
range ? null : null
|
|
2367
2438
|
] });
|
|
2368
2439
|
}
|
|
2440
|
+
var TIME_OPTION_HEIGHT = 32;
|
|
2441
|
+
var TIME_COLUMN_PADDING = 4;
|
|
2442
|
+
function TimeColumn({
|
|
2443
|
+
ariaLabel,
|
|
2444
|
+
columnIndex,
|
|
2445
|
+
count,
|
|
2446
|
+
value,
|
|
2447
|
+
siblings,
|
|
2448
|
+
use12Hours = false,
|
|
2449
|
+
unit = "",
|
|
2450
|
+
unitLabels = false,
|
|
2451
|
+
disabledTime,
|
|
2452
|
+
onSelect
|
|
2453
|
+
}) {
|
|
2454
|
+
const listRef = (0, import_react8.useRef)(null);
|
|
2455
|
+
const drag = (0, import_react8.useRef)({ startY: 0, startScroll: 0, pointerId: -1, dragging: false, samples: [], velocity: 0, frame: 0 });
|
|
2456
|
+
(0, import_react8.useLayoutEffect)(() => {
|
|
2457
|
+
const column = listRef.current;
|
|
2458
|
+
const selected = column?.querySelector('[aria-selected="true"]');
|
|
2459
|
+
const first = column?.firstElementChild;
|
|
2460
|
+
if (!column || !selected || !first) return;
|
|
2461
|
+
const top = selected.offsetTop - first.offsetTop + parseFloat(getComputedStyle(column).paddingTop || "0");
|
|
2462
|
+
const bottom = top + selected.offsetHeight;
|
|
2463
|
+
if (top < column.scrollTop || bottom > column.scrollTop + column.clientHeight) {
|
|
2464
|
+
column.scrollTop = Math.max(0, top - (column.clientHeight - selected.offsetHeight) / 2);
|
|
2465
|
+
}
|
|
2466
|
+
}, [value, count]);
|
|
2467
|
+
(0, import_react8.useEffect)(() => () => cancelAnimationFrame(drag.current.frame), []);
|
|
2468
|
+
function stopWithSnap() {
|
|
2469
|
+
const column = listRef.current;
|
|
2470
|
+
if (!column) return;
|
|
2471
|
+
const snapped = Math.round((column.scrollTop - TIME_COLUMN_PADDING) / TIME_OPTION_HEIGHT) * TIME_OPTION_HEIGHT + TIME_COLUMN_PADDING;
|
|
2472
|
+
const max = column.scrollHeight - column.clientHeight;
|
|
2473
|
+
column.scrollTo({ top: Math.max(0, Math.min(max, snapped)), behavior: "smooth" });
|
|
2474
|
+
}
|
|
2475
|
+
function onPointerDown(event) {
|
|
2476
|
+
if (event.button !== 0) return;
|
|
2477
|
+
const column = listRef.current;
|
|
2478
|
+
if (!column) return;
|
|
2479
|
+
drag.current = { startY: event.clientY, startScroll: column.scrollTop, pointerId: event.pointerId, dragging: false, samples: [event.timeStamp, event.clientY], velocity: 0, frame: 0 };
|
|
2480
|
+
}
|
|
2481
|
+
function onPointerMove(event) {
|
|
2482
|
+
const state = drag.current;
|
|
2483
|
+
const column = listRef.current;
|
|
2484
|
+
if (state.pointerId !== event.pointerId || !column) return;
|
|
2485
|
+
const dy = event.clientY - state.startY;
|
|
2486
|
+
if (!state.dragging && Math.abs(dy) > 4) {
|
|
2487
|
+
state.dragging = true;
|
|
2488
|
+
try {
|
|
2489
|
+
column.setPointerCapture(event.pointerId);
|
|
2490
|
+
} catch {
|
|
2491
|
+
}
|
|
2492
|
+
}
|
|
2493
|
+
if (!state.dragging) return;
|
|
2494
|
+
column.scrollTop = state.startScroll - dy;
|
|
2495
|
+
state.samples.push(event.timeStamp, event.clientY);
|
|
2496
|
+
while (state.samples.length > 4 && event.timeStamp - state.samples[0] > 100) state.samples.splice(0, 2);
|
|
2497
|
+
}
|
|
2498
|
+
function onPointerUp(event) {
|
|
2499
|
+
const state = drag.current;
|
|
2500
|
+
const column = listRef.current;
|
|
2501
|
+
if (state.pointerId !== event.pointerId || !column) return;
|
|
2502
|
+
state.pointerId = -1;
|
|
2503
|
+
try {
|
|
2504
|
+
column.releasePointerCapture?.(event.pointerId);
|
|
2505
|
+
} catch {
|
|
2506
|
+
}
|
|
2507
|
+
if (!state.dragging) return;
|
|
2508
|
+
const samples = state.samples;
|
|
2509
|
+
const dt = samples[samples.length - 2] - samples[0];
|
|
2510
|
+
const dy = samples[samples.length - 1] - samples[1];
|
|
2511
|
+
let velocity = dt > 4 ? dy / dt : 0;
|
|
2512
|
+
velocity = Math.max(-2.5, Math.min(2.5, velocity));
|
|
2513
|
+
cancelAnimationFrame(state.frame);
|
|
2514
|
+
let last = performance.now();
|
|
2515
|
+
const step = (now) => {
|
|
2516
|
+
const elapsed = Math.min(32, now - last);
|
|
2517
|
+
last = now;
|
|
2518
|
+
column.scrollTop -= velocity * elapsed;
|
|
2519
|
+
velocity *= Math.pow(0.94, elapsed / 16.7);
|
|
2520
|
+
if (Math.abs(velocity) > 0.04) state.frame = requestAnimationFrame(step);
|
|
2521
|
+
else stopWithSnap();
|
|
2522
|
+
};
|
|
2523
|
+
state.frame = requestAnimationFrame(step);
|
|
2524
|
+
}
|
|
2525
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
|
|
2526
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2527
|
+
"div",
|
|
2528
|
+
{
|
|
2529
|
+
ref: listRef,
|
|
2530
|
+
role: "listbox",
|
|
2531
|
+
"aria-label": ariaLabel,
|
|
2532
|
+
onPointerDown,
|
|
2533
|
+
onPointerMove,
|
|
2534
|
+
onPointerUp,
|
|
2535
|
+
onPointerCancel: onPointerUp,
|
|
2536
|
+
onClickCapture: (event) => {
|
|
2537
|
+
if (!drag.current.dragging) return;
|
|
2538
|
+
event.preventDefault();
|
|
2539
|
+
event.stopPropagation();
|
|
2540
|
+
drag.current.dragging = false;
|
|
2541
|
+
},
|
|
2542
|
+
children: Array.from({ length: count }, (_, index) => {
|
|
2543
|
+
const next = pad(index);
|
|
2544
|
+
const candidate = [...siblings];
|
|
2545
|
+
candidate[columnIndex] = next;
|
|
2546
|
+
const selected = next === value;
|
|
2547
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("button", { type: "button", role: "option", disabled: disabledTime?.(candidate.join(":")), "aria-selected": selected, className: selected ? "is-selected" : "", onKeyDown: (event) => {
|
|
2548
|
+
if (!["ArrowDown", "ArrowUp", "Home", "End"].includes(event.key)) return;
|
|
2549
|
+
event.preventDefault();
|
|
2550
|
+
const buttons = Array.from(event.currentTarget.parentElement.querySelectorAll("button:not(:disabled)"));
|
|
2551
|
+
const position = buttons.indexOf(event.currentTarget);
|
|
2552
|
+
const target = event.key === "Home" ? 0 : event.key === "End" ? buttons.length - 1 : Math.max(0, Math.min(buttons.length - 1, position + (event.key === "ArrowDown" ? 1 : -1)));
|
|
2553
|
+
buttons[target]?.focus();
|
|
2554
|
+
}, onClick: () => onSelect(next), children: [
|
|
2555
|
+
use12Hours && columnIndex === 0 ? `${pad(index % 12 || 12)} ${index < 12 ? "AM" : "PM"}` : next,
|
|
2556
|
+
unitLabels && selected ? unit : ""
|
|
2557
|
+
] }, next);
|
|
2558
|
+
})
|
|
2559
|
+
}
|
|
2560
|
+
),
|
|
2561
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(FloatingScrollbarProvider, { targetRef: listRef })
|
|
2562
|
+
] });
|
|
2563
|
+
}
|
|
2369
2564
|
function TimePanel({
|
|
2370
2565
|
value,
|
|
2371
2566
|
showSecond = false,
|
|
2372
2567
|
ariaLabel = "\u65F6\u95F4",
|
|
2373
2568
|
disabledTime,
|
|
2374
2569
|
use12Hours = false,
|
|
2570
|
+
title,
|
|
2571
|
+
unitLabels = false,
|
|
2375
2572
|
onChange
|
|
2376
2573
|
}) {
|
|
2377
2574
|
const [hour = "00", minute = "00", second = "00"] = value.split(":");
|
|
2378
|
-
const
|
|
2379
|
-
const hourRef = (0, import_react8.useRef)(null);
|
|
2380
|
-
const minuteRef = (0, import_react8.useRef)(null);
|
|
2381
|
-
const secondRef = (0, import_react8.useRef)(null);
|
|
2382
|
-
const columnRefs = [hourRef, minuteRef, secondRef];
|
|
2383
|
-
(0, import_react8.useLayoutEffect)(() => {
|
|
2384
|
-
for (const column of columnsRef.current?.children ?? []) {
|
|
2385
|
-
const selected = column.querySelector('[aria-selected="true"]');
|
|
2386
|
-
const first = column.firstElementChild;
|
|
2387
|
-
if (!selected || !first) continue;
|
|
2388
|
-
const top = selected.offsetTop - first.offsetTop + parseFloat(getComputedStyle(column).paddingTop || "0");
|
|
2389
|
-
const bottom = top + selected.offsetHeight;
|
|
2390
|
-
if (top < column.scrollTop || bottom > column.scrollTop + column.clientHeight) {
|
|
2391
|
-
column.scrollTop = Math.max(0, top - (column.clientHeight - selected.offsetHeight) / 2);
|
|
2392
|
-
}
|
|
2393
|
-
}
|
|
2394
|
-
}, [hour, minute, second, showSecond, ariaLabel]);
|
|
2575
|
+
const siblings = [hour, minute, second];
|
|
2395
2576
|
const columns = [
|
|
2396
|
-
{ label: "\u5C0F\u65F6", value: hour, count: 24, index: 0 },
|
|
2397
|
-
{ label: "\u5206\u949F", value: minute, count: 60, index: 1 },
|
|
2398
|
-
...showSecond ? [{ label: "\u79D2", value: second, count: 60, index: 2 }] : []
|
|
2577
|
+
{ label: "\u5C0F\u65F6", unit: "\u65F6", value: hour, count: 24, index: 0 },
|
|
2578
|
+
{ label: "\u5206\u949F", unit: "\u5206", value: minute, count: 60, index: 1 },
|
|
2579
|
+
...showSecond ? [{ label: "\u79D2", unit: "\u79D2", value: second, count: 60, index: 2 }] : []
|
|
2399
2580
|
];
|
|
2400
2581
|
function update(index, next) {
|
|
2401
2582
|
const values = [hour, minute, second];
|
|
@@ -2403,27 +2584,29 @@ function TimePanel({
|
|
|
2403
2584
|
onChange(values.join(":"));
|
|
2404
2585
|
}
|
|
2405
2586
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("aside", { className: "sia-date-panel__time", "aria-label": ariaLabel, children: [
|
|
2406
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("strong", { children: [
|
|
2587
|
+
title != null ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("strong", { className: "sia-date-panel__time-title", children: title }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("strong", { children: [
|
|
2407
2588
|
use12Hours ? pad(Number(hour) % 12 || 12) : hour,
|
|
2408
2589
|
":",
|
|
2409
2590
|
minute,
|
|
2410
2591
|
showSecond ? `:${second}` : "",
|
|
2411
2592
|
use12Hours ? Number(hour) < 12 ? " AM" : " PM" : ""
|
|
2412
2593
|
] }),
|
|
2413
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", {
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2594
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "sia-date-panel__time-columns", children: columns.map((column) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2595
|
+
TimeColumn,
|
|
2596
|
+
{
|
|
2597
|
+
ariaLabel: `${ariaLabel}${column.label}`,
|
|
2598
|
+
columnIndex: column.index,
|
|
2599
|
+
count: column.count,
|
|
2600
|
+
value: column.value,
|
|
2601
|
+
siblings,
|
|
2602
|
+
use12Hours,
|
|
2603
|
+
unit: column.unit,
|
|
2604
|
+
unitLabels,
|
|
2605
|
+
disabledTime,
|
|
2606
|
+
onSelect: (next) => update(column.index, next)
|
|
2607
|
+
},
|
|
2608
|
+
column.label
|
|
2609
|
+
)) })
|
|
2427
2610
|
] });
|
|
2428
2611
|
}
|
|
2429
2612
|
function DatePanelFooter({
|
|
@@ -2443,6 +2626,50 @@ function DatePanelFooter({
|
|
|
2443
2626
|
needConfirm ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { type: "button", className: "sia-date-panel__confirm", disabled: disabledConfirm, onClick: onConfirm, children: confirmText }) : null
|
|
2444
2627
|
] });
|
|
2445
2628
|
}
|
|
2629
|
+
function DateTimePanelFooter({
|
|
2630
|
+
date,
|
|
2631
|
+
time,
|
|
2632
|
+
view,
|
|
2633
|
+
disabled = false,
|
|
2634
|
+
extra,
|
|
2635
|
+
onSwitchDate,
|
|
2636
|
+
onSwitchTime,
|
|
2637
|
+
onClearTime
|
|
2638
|
+
}) {
|
|
2639
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("footer", { className: "sia-date-panel__footer sia-date-panel__footer--datetime", children: [
|
|
2640
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { children: [
|
|
2641
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("button", { type: "button", className: "sia-date-panel__chip", "aria-pressed": view === "date" || void 0, disabled, onClick: onSwitchDate, children: [
|
|
2642
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { name: "calendar", size: 14, "aria-hidden": "true" }),
|
|
2643
|
+
date
|
|
2644
|
+
] }),
|
|
2645
|
+
extra
|
|
2646
|
+
] }),
|
|
2647
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("button", { type: "button", className: `sia-date-panel__chip sia-date-panel__chip--time${onClearTime ? " is-clearable" : ""}`, "aria-pressed": view === "time" || void 0, disabled, onClick: onSwitchTime, children: [
|
|
2648
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { name: "clock", size: 14, "aria-hidden": "true" }),
|
|
2649
|
+
time,
|
|
2650
|
+
onClearTime && !disabled ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2651
|
+
"span",
|
|
2652
|
+
{
|
|
2653
|
+
role: "button",
|
|
2654
|
+
tabIndex: 0,
|
|
2655
|
+
"aria-label": "\u6E05\u7A7A\u65F6\u95F4",
|
|
2656
|
+
className: "sia-date-panel__chip-clear",
|
|
2657
|
+
onClick: (event) => {
|
|
2658
|
+
event.stopPropagation();
|
|
2659
|
+
onClearTime();
|
|
2660
|
+
},
|
|
2661
|
+
onKeyDown: (event) => {
|
|
2662
|
+
if (event.key !== "Enter" && event.key !== " ") return;
|
|
2663
|
+
event.preventDefault();
|
|
2664
|
+
event.stopPropagation();
|
|
2665
|
+
onClearTime();
|
|
2666
|
+
},
|
|
2667
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { name: "circle-close", variant: "filled", size: 13, "aria-hidden": "true" })
|
|
2668
|
+
}
|
|
2669
|
+
) : null
|
|
2670
|
+
] })
|
|
2671
|
+
] });
|
|
2672
|
+
}
|
|
2446
2673
|
|
|
2447
2674
|
// src/components/DatePicker.tsx
|
|
2448
2675
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
@@ -2492,6 +2719,12 @@ function resolvePreset(value) {
|
|
|
2492
2719
|
function resolveRangePreset(value) {
|
|
2493
2720
|
return typeof value === "function" ? value() : value;
|
|
2494
2721
|
}
|
|
2722
|
+
function hasExplicitTime(value) {
|
|
2723
|
+
return /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}/.test(String(value ?? ""));
|
|
2724
|
+
}
|
|
2725
|
+
function isZeroTime(time, showSecond) {
|
|
2726
|
+
return showSecond ? time === "00:00:00" : time.slice(0, 5) === "00:00";
|
|
2727
|
+
}
|
|
2495
2728
|
function DatePicker({
|
|
2496
2729
|
value,
|
|
2497
2730
|
defaultValue,
|
|
@@ -2531,7 +2764,11 @@ function DatePicker({
|
|
|
2531
2764
|
const firstCurrent = Array.isArray(currentValue) ? currentValue[0] : currentValue;
|
|
2532
2765
|
const [viewMonth, setViewMonth] = (0, import_react9.useState)(() => startOfMonth(parseDate(dayFromValue(firstCurrent)) ?? /* @__PURE__ */ new Date()));
|
|
2533
2766
|
const [draftTime, setDraftTime] = (0, import_react9.useState)(() => timePart(firstCurrent, defaultTimeFrom(showTime)));
|
|
2534
|
-
const
|
|
2767
|
+
const showTimeDefaultProvided = typeof showTime === "object" && showTime.defaultValue !== void 0;
|
|
2768
|
+
const [timeExplicit, setTimeExplicit] = (0, import_react9.useState)(() => showTimeDefaultProvided || hasExplicitTime(typeof initialValue === "string" ? initialValue : void 0));
|
|
2769
|
+
const [dateTimeView, setDateTimeView] = (0, import_react9.useState)("date");
|
|
2770
|
+
const [yearDrill, setYearDrill] = (0, import_react9.useState)(false);
|
|
2771
|
+
const resolvedNeedConfirm = showTime ? false : Boolean(needConfirm);
|
|
2535
2772
|
const showSecond = showSecondFrom(showTime);
|
|
2536
2773
|
const selectedDates = (0, import_react9.useMemo)(() => {
|
|
2537
2774
|
const values = Array.isArray(draftValue) ? draftValue : draftValue ? [draftValue] : [];
|
|
@@ -2552,6 +2789,9 @@ function DatePicker({
|
|
|
2552
2789
|
const current = Array.isArray(currentValue) ? currentValue[0] : currentValue;
|
|
2553
2790
|
setViewMonth(startOfMonth(parseDate(dayFromValue(current)) ?? /* @__PURE__ */ new Date()));
|
|
2554
2791
|
setDraftTime(timePart(current, defaultTimeFrom(showTime)));
|
|
2792
|
+
setTimeExplicit(showTimeDefaultProvided || hasExplicitTime(typeof current === "string" ? current : void 0));
|
|
2793
|
+
setDateTimeView("date");
|
|
2794
|
+
setYearDrill(false);
|
|
2555
2795
|
}
|
|
2556
2796
|
setVisible(next);
|
|
2557
2797
|
}
|
|
@@ -2563,9 +2803,11 @@ function DatePicker({
|
|
|
2563
2803
|
if (maximum && day.slice(0, length) > String(maximum).slice(0, length)) return true;
|
|
2564
2804
|
return disabledDate?.(day, { type: "date" }) ?? false;
|
|
2565
2805
|
}
|
|
2566
|
-
function buildValue(day, time = draftTime) {
|
|
2806
|
+
function buildValue(day, time = draftTime, explicit = timeExplicit) {
|
|
2567
2807
|
const picked = formatPickerValue(day, picker);
|
|
2568
|
-
|
|
2808
|
+
if (!(showTime && picker === "date")) return picked;
|
|
2809
|
+
if (!explicit && isZeroTime(time, showSecond)) return picked;
|
|
2810
|
+
return withTime(picked, time, showSecond);
|
|
2569
2811
|
}
|
|
2570
2812
|
function selectDate(day, time = draftTime, ensureSelected = false) {
|
|
2571
2813
|
if (isDisabled(day)) return;
|
|
@@ -2581,7 +2823,7 @@ function DatePicker({
|
|
|
2581
2823
|
setDraftValue(nextValue);
|
|
2582
2824
|
if (!resolvedNeedConfirm) {
|
|
2583
2825
|
setCurrentValue(nextValue);
|
|
2584
|
-
changeOpen(false);
|
|
2826
|
+
if (!showTime) changeOpen(false);
|
|
2585
2827
|
}
|
|
2586
2828
|
}
|
|
2587
2829
|
function commitDraft() {
|
|
@@ -2590,6 +2832,72 @@ function DatePicker({
|
|
|
2590
2832
|
setCurrentValue(draftValue);
|
|
2591
2833
|
changeOpen(false);
|
|
2592
2834
|
}
|
|
2835
|
+
function applyDraftTime(next) {
|
|
2836
|
+
setDraftTime(next);
|
|
2837
|
+
setTimeExplicit(true);
|
|
2838
|
+
const day = typeof draftValue === "string" ? dayFromValue(draftValue) : "";
|
|
2839
|
+
if (!day) return;
|
|
2840
|
+
const nextValue = withTime(day, next, showSecond);
|
|
2841
|
+
setDraftValue(nextValue);
|
|
2842
|
+
setCurrentValue(nextValue);
|
|
2843
|
+
}
|
|
2844
|
+
function clearDraftTime() {
|
|
2845
|
+
setDraftTime("00:00:00");
|
|
2846
|
+
setTimeExplicit(false);
|
|
2847
|
+
const day = typeof draftValue === "string" ? dayFromValue(draftValue) : "";
|
|
2848
|
+
if (!day) return;
|
|
2849
|
+
setDraftValue(day);
|
|
2850
|
+
setCurrentValue(day);
|
|
2851
|
+
}
|
|
2852
|
+
function renderCalendarSection() {
|
|
2853
|
+
return picker === "year" || yearDrill ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
|
|
2854
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "sia-date-panel__header", children: [
|
|
2855
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "sia-date-panel__nav", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", "aria-label": "\u4E0A\u5341\u5E74", onClick: () => setViewMonth(addMonths(viewMonth, -120)), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { name: "chevron-left", size: 15 }) }) }),
|
|
2856
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("strong", { children: [
|
|
2857
|
+
Math.floor(viewMonth.getFullYear() / 10) * 10,
|
|
2858
|
+
"\u5E74 \u2014 ",
|
|
2859
|
+
Math.floor(viewMonth.getFullYear() / 10) * 10 + 9,
|
|
2860
|
+
"\u5E74"
|
|
2861
|
+
] }),
|
|
2862
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "sia-date-panel__nav", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", "aria-label": "\u4E0B\u5341\u5E74", onClick: () => setViewMonth(addMonths(viewMonth, 120)), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { name: "chevron-right", size: 15 }) }) })
|
|
2863
|
+
] }),
|
|
2864
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "sia-date-panel__years", children: Array.from({ length: 10 }, (_, index) => {
|
|
2865
|
+
const year = String(Math.floor(viewMonth.getFullYear() / 10) * 10 + index);
|
|
2866
|
+
const day = `${year}-01-01`;
|
|
2867
|
+
const selected = selectedDates.some((value2) => value2.slice(0, 4) === year);
|
|
2868
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: `sia-date-panel__cell${selected ? " is-selected" : ""}${year === String((/* @__PURE__ */ new Date()).getFullYear()) ? " is-today" : ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", "aria-label": `${year}\u5E74`, "aria-pressed": selected, disabled: isDisabled(day), onClick: () => {
|
|
2869
|
+
if (yearDrill) {
|
|
2870
|
+
setViewMonth(new Date(Number(year), viewMonth.getMonth(), 1));
|
|
2871
|
+
setYearDrill(false);
|
|
2872
|
+
} else {
|
|
2873
|
+
selectDate(day);
|
|
2874
|
+
}
|
|
2875
|
+
}, children: year }) }, year);
|
|
2876
|
+
}) })
|
|
2877
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
|
|
2878
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2879
|
+
CalendarHeader,
|
|
2880
|
+
{
|
|
2881
|
+
month: viewMonth,
|
|
2882
|
+
onTitleClick: picker === "date" ? () => setYearDrill(true) : void 0,
|
|
2883
|
+
onPreviousYear: () => setViewMonth(addMonths(viewMonth, -12)),
|
|
2884
|
+
onPreviousMonth: () => setViewMonth(addMonths(viewMonth, -1)),
|
|
2885
|
+
onNextMonth: () => setViewMonth(addMonths(viewMonth, 1)),
|
|
2886
|
+
onNextYear: () => setViewMonth(addMonths(viewMonth, 12))
|
|
2887
|
+
}
|
|
2888
|
+
),
|
|
2889
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2890
|
+
CalendarMonth,
|
|
2891
|
+
{
|
|
2892
|
+
month: viewMonth,
|
|
2893
|
+
selectedDates,
|
|
2894
|
+
disabledDate: isDisabled,
|
|
2895
|
+
onSelect: selectDate,
|
|
2896
|
+
onSwipeMonth: picker === "date" ? (direction) => setViewMonth(addMonths(viewMonth, direction)) : void 0
|
|
2897
|
+
}
|
|
2898
|
+
)
|
|
2899
|
+
] });
|
|
2900
|
+
}
|
|
2593
2901
|
function clearValue(event) {
|
|
2594
2902
|
event.stopPropagation();
|
|
2595
2903
|
const empty = multiple ? [] : "";
|
|
@@ -2629,72 +2937,82 @@ function DatePicker({
|
|
|
2629
2937
|
),
|
|
2630
2938
|
floating.label,
|
|
2631
2939
|
allowClear && display && !disabled ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", className: "sia-picker__clear", "aria-label": "\u6E05\u9664\u65E5\u671F", onClick: clearValue, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { name: "circle-close", variant: "filled", size: 15 }) }) : null,
|
|
2632
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2940
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
2941
|
+
PopupPortal,
|
|
2942
|
+
{
|
|
2943
|
+
ref: popupRef,
|
|
2944
|
+
anchorRef: rootRef,
|
|
2945
|
+
open: visible,
|
|
2946
|
+
className: `sia-date-panel${showTime ? " sia-date-panel--datetime" : ""}${presets?.length ? " sia-date-panel--with-presets" : ""}`,
|
|
2947
|
+
role: "dialog",
|
|
2948
|
+
"aria-label": "\u65E5\u671F\u9009\u62E9\u9762\u677F",
|
|
2949
|
+
onKeyDown: (event) => {
|
|
2950
|
+
if (event.key === "Escape") {
|
|
2951
|
+
event.stopPropagation();
|
|
2640
2952
|
changeOpen(false);
|
|
2641
2953
|
}
|
|
2642
|
-
},
|
|
2643
|
-
|
|
2644
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "sia-date-
|
|
2645
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2954
|
+
},
|
|
2955
|
+
children: [
|
|
2956
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "sia-date-panel__body", children: [
|
|
2957
|
+
presets?.length ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("aside", { className: "sia-date-panel__presets", children: presets.map((preset2, index) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", onClick: () => {
|
|
2958
|
+
const next = resolvePreset(preset2.value);
|
|
2959
|
+
if (!next || isDisabled(dayFromValue(next))) return;
|
|
2960
|
+
setDraftValue(next);
|
|
2961
|
+
setDraftTime(timePart(next, defaultTimeFrom(showTime)));
|
|
2962
|
+
setTimeExplicit(hasExplicitTime(next));
|
|
2963
|
+
if (!resolvedNeedConfirm) {
|
|
2964
|
+
setCurrentValue(next);
|
|
2965
|
+
changeOpen(false);
|
|
2966
|
+
}
|
|
2967
|
+
}, children: preset2.label }, index)) }) : null,
|
|
2968
|
+
showTime ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "sia-date-panel__views", children: [
|
|
2969
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("section", { className: `sia-date-panel__view sia-date-panel__view--date${dateTimeView === "date" ? " is-active" : ""}`, "aria-hidden": dateTimeView !== "date", children: renderCalendarSection() }),
|
|
2970
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: `sia-date-panel__view sia-date-panel__view--time${dateTimeView === "time" ? " is-active" : ""}`, "aria-hidden": dateTimeView !== "time", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2971
|
+
TimePanel,
|
|
2972
|
+
{
|
|
2973
|
+
value: draftTime,
|
|
2974
|
+
showSecond,
|
|
2975
|
+
title: "\u9009\u62E9\u65F6\u95F4",
|
|
2976
|
+
unitLabels: true,
|
|
2977
|
+
ariaLabel: "\u9009\u62E9\u65F6\u95F4",
|
|
2978
|
+
onChange: applyDraftTime
|
|
2979
|
+
}
|
|
2980
|
+
) })
|
|
2981
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("section", { className: "sia-date-panel__calendar", children: renderCalendarSection() })
|
|
2653
2982
|
] }),
|
|
2654
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2655
|
-
|
|
2656
|
-
const day = `${year}-01-01`;
|
|
2657
|
-
const selected = selectedDates.some((value2) => value2.slice(0, 4) === year);
|
|
2658
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: `sia-date-panel__cell${selected ? " is-selected" : ""}${year === String((/* @__PURE__ */ new Date()).getFullYear()) ? " is-today" : ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", "aria-label": `${year}\u5E74`, "aria-pressed": selected, disabled: isDisabled(day), onClick: () => selectDate(day), children: year }) }, year);
|
|
2659
|
-
}) })
|
|
2660
|
-
] }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
|
|
2661
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2662
|
-
CalendarHeader,
|
|
2983
|
+
showTime ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2984
|
+
DateTimePanelFooter,
|
|
2663
2985
|
{
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2986
|
+
date: (typeof draftValue === "string" ? dayFromValue(draftValue) : "") || dateKey(/* @__PURE__ */ new Date()),
|
|
2987
|
+
time: showSecond ? draftTime : draftTime.slice(0, 5),
|
|
2988
|
+
view: dateTimeView,
|
|
2989
|
+
extra: renderExtraFooter?.(),
|
|
2990
|
+
onSwitchDate: () => setDateTimeView("date"),
|
|
2991
|
+
onSwitchTime: () => setDateTimeView("time"),
|
|
2992
|
+
onClearTime: clearDraftTime
|
|
2669
2993
|
}
|
|
2670
|
-
),
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
selectDate(day, time, true);
|
|
2693
|
-
},
|
|
2694
|
-
onConfirm: commitDraft
|
|
2695
|
-
}
|
|
2696
|
-
)
|
|
2697
|
-
] })
|
|
2994
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2995
|
+
DatePanelFooter,
|
|
2996
|
+
{
|
|
2997
|
+
extra: renderExtraFooter?.(),
|
|
2998
|
+
showToday,
|
|
2999
|
+
needConfirm: resolvedNeedConfirm,
|
|
3000
|
+
disabledConfirm: Array.isArray(draftValue) ? draftValue.length === 0 : !draftValue,
|
|
3001
|
+
onToday: () => {
|
|
3002
|
+
const now = /* @__PURE__ */ new Date();
|
|
3003
|
+
const day = dateKey(now);
|
|
3004
|
+
if (isDisabled(day)) return;
|
|
3005
|
+
const time = [now.getHours(), now.getMinutes(), now.getSeconds()].map(pad).join(":");
|
|
3006
|
+
if (showTime) setDraftTime(time);
|
|
3007
|
+
setViewMonth(startOfMonth(now));
|
|
3008
|
+
selectDate(day, time, true);
|
|
3009
|
+
},
|
|
3010
|
+
onConfirm: commitDraft
|
|
3011
|
+
}
|
|
3012
|
+
)
|
|
3013
|
+
]
|
|
3014
|
+
}
|
|
3015
|
+
)
|
|
2698
3016
|
] });
|
|
2699
3017
|
}
|
|
2700
3018
|
function DateRangePicker({
|
|
@@ -2754,11 +3072,10 @@ function DateRangePicker({
|
|
|
2754
3072
|
}
|
|
2755
3073
|
return () => observer.disconnect();
|
|
2756
3074
|
});
|
|
2757
|
-
const [
|
|
2758
|
-
const [presetSelected, setPresetSelected] = (0, import_react9.useState)(false);
|
|
3075
|
+
const [dateTimeViews, setDateTimeViews] = (0, import_react9.useState)(["date", "date"]);
|
|
2759
3076
|
const [hoverDate, setHoverDate] = (0, import_react9.useState)("");
|
|
2760
3077
|
const [viewMonth, setViewMonth] = (0, import_react9.useState)(() => startOfMonth(parseDate(dayFromValue(currentValue[0] || currentValue[1])) ?? /* @__PURE__ */ new Date()));
|
|
2761
|
-
const [endViewMonth, setEndViewMonth] = (0, import_react9.useState)(() => startOfMonth(parseDate(dayFromValue(currentValue[1])) ?? addMonths(parseDate(dayFromValue(currentValue[0])) ?? /* @__PURE__ */ new Date(), 1)));
|
|
3078
|
+
const [endViewMonth, setEndViewMonth] = (0, import_react9.useState)(() => startOfMonth(parseDate(dayFromValue(currentValue[1])) ?? (showTime ? parseDate(dayFromValue(currentValue[0])) ?? /* @__PURE__ */ new Date() : addMonths(parseDate(dayFromValue(currentValue[0])) ?? /* @__PURE__ */ new Date(), 1))));
|
|
2762
3079
|
const showSecond = showSecondFrom(showTime);
|
|
2763
3080
|
const defaultTime = defaultTimeFrom(showTime);
|
|
2764
3081
|
const defaultEndTime = defaultTimeFrom(showTime, 1);
|
|
@@ -2766,7 +3083,7 @@ function DateRangePicker({
|
|
|
2766
3083
|
timePart(currentValue[0], defaultTime),
|
|
2767
3084
|
timePart(currentValue[1], defaultEndTime)
|
|
2768
3085
|
]);
|
|
2769
|
-
const resolvedNeedConfirm =
|
|
3086
|
+
const resolvedNeedConfirm = showTime ? false : Boolean(needConfirm);
|
|
2770
3087
|
const rangeDates = [dayFromValue(draftValue[0]), dayFromValue(draftValue[1])];
|
|
2771
3088
|
const invalidDateTimeRange = Boolean(showTime && draftValue[0] && draftValue[1] && draftValue[0] > draftValue[1]);
|
|
2772
3089
|
(0, import_react9.useEffect)(() => {
|
|
@@ -2783,14 +3100,13 @@ function DateRangePicker({
|
|
|
2783
3100
|
}
|
|
2784
3101
|
function changeOpen(next, endpoint) {
|
|
2785
3102
|
if (next && !visible) {
|
|
2786
|
-
setConfirmedIndex(null);
|
|
2787
|
-
setPresetSelected(false);
|
|
2788
3103
|
setDraftValue(currentValue);
|
|
2789
3104
|
setTimes([timePart(currentValue[0], defaultTime), timePart(currentValue[1], defaultEndTime)]);
|
|
2790
3105
|
setActiveIndex(endpointDisabled[0] ? 1 : endpointDisabled[1] ? 0 : endpoint ?? (currentValue[0] && !currentValue[1] ? 1 : 0));
|
|
3106
|
+
setDateTimeViews(["date", "date"]);
|
|
2791
3107
|
const nextStartMonth = startOfMonth(parseDate(dayFromValue(currentValue[0] || currentValue[1])) ?? /* @__PURE__ */ new Date());
|
|
2792
3108
|
setViewMonth(nextStartMonth);
|
|
2793
|
-
setEndViewMonth(startOfMonth(parseDate(dayFromValue(currentValue[1])) ?? addMonths(nextStartMonth, 1)));
|
|
3109
|
+
setEndViewMonth(startOfMonth(parseDate(dayFromValue(currentValue[1])) ?? (showTime ? nextStartMonth : addMonths(nextStartMonth, 1))));
|
|
2794
3110
|
}
|
|
2795
3111
|
if (next && endpoint !== void 0 && !endpointDisabled[endpoint]) setActiveIndex(endpoint);
|
|
2796
3112
|
setVisible(next);
|
|
@@ -2803,9 +3119,9 @@ function DateRangePicker({
|
|
|
2803
3119
|
if (maximum && day > String(maximum).slice(0, 10)) return true;
|
|
2804
3120
|
const from = index === 1 ? rangeDates[0] : void 0;
|
|
2805
3121
|
if (dateTimeStep) {
|
|
2806
|
-
const
|
|
2807
|
-
const otherEndpoint = rangeDates[
|
|
2808
|
-
if (otherEndpoint
|
|
3122
|
+
const otherIndex = index === 0 ? 1 : 0;
|
|
3123
|
+
const otherEndpoint = rangeDates[otherIndex];
|
|
3124
|
+
if (otherEndpoint) {
|
|
2809
3125
|
if (index === 0 && day > otherEndpoint || index === 1 && day < otherEndpoint) return true;
|
|
2810
3126
|
if (maxRangeDays && Math.abs(daysBetween(otherEndpoint, day)) >= maxRangeDays) return true;
|
|
2811
3127
|
}
|
|
@@ -2816,10 +3132,9 @@ function DateRangePicker({
|
|
|
2816
3132
|
return showTime ? withTime(day, times[index], showSecond) : day;
|
|
2817
3133
|
}
|
|
2818
3134
|
function updateDraft(next) {
|
|
2819
|
-
setPresetSelected(false);
|
|
2820
3135
|
setDraftValue(next);
|
|
2821
3136
|
onCalendarChange?.(next);
|
|
2822
|
-
if (
|
|
3137
|
+
if (isValidRange(next) && (next[0] !== currentValue[0] || next[1] !== currentValue[1])) {
|
|
2823
3138
|
setCurrentValue(next);
|
|
2824
3139
|
}
|
|
2825
3140
|
}
|
|
@@ -2896,19 +3211,7 @@ function DateRangePicker({
|
|
|
2896
3211
|
}
|
|
2897
3212
|
return true;
|
|
2898
3213
|
}
|
|
2899
|
-
const otherIndex = activeIndex === 0 ? 1 : 0;
|
|
2900
|
-
const needsOtherConfirmation = Boolean(showTime && !presetSelected && !endpointDisabled[otherIndex] && confirmedIndex !== otherIndex);
|
|
2901
3214
|
function confirm() {
|
|
2902
|
-
if (needsOtherConfirmation) {
|
|
2903
|
-
if (!draftValue[activeIndex] && !allowEmpty[activeIndex]) return;
|
|
2904
|
-
setConfirmedIndex(activeIndex);
|
|
2905
|
-
setActiveIndex(otherIndex);
|
|
2906
|
-
const month = startOfMonth(parseDate(dayFromValue(draftValue[activeIndex])) ?? /* @__PURE__ */ new Date());
|
|
2907
|
-
if (otherIndex === 0) setViewMonth(month);
|
|
2908
|
-
else setEndViewMonth(month);
|
|
2909
|
-
setHoverDate("");
|
|
2910
|
-
return;
|
|
2911
|
-
}
|
|
2912
3215
|
if (!isValidRange(draftValue)) return;
|
|
2913
3216
|
setCurrentValue(draftValue);
|
|
2914
3217
|
changeOpen(false);
|
|
@@ -2921,13 +3224,11 @@ function DateRangePicker({
|
|
|
2921
3224
|
];
|
|
2922
3225
|
if (!isValidRange(next)) return;
|
|
2923
3226
|
updateDraft(next);
|
|
2924
|
-
setConfirmedIndex(null);
|
|
2925
|
-
setPresetSelected(true);
|
|
2926
3227
|
setTimes([timePart(next[0], defaultTime), timePart(next[1], defaultEndTime)]);
|
|
2927
3228
|
const nextStartMonth = startOfMonth(parseDate(dayFromValue(next[0] || next[1])) ?? /* @__PURE__ */ new Date());
|
|
2928
3229
|
setViewMonth(nextStartMonth);
|
|
2929
|
-
setEndViewMonth(startOfMonth(parseDate(dayFromValue(next[1])) ?? addMonths(nextStartMonth, 1)));
|
|
2930
|
-
if (!
|
|
3230
|
+
setEndViewMonth(startOfMonth(parseDate(dayFromValue(next[1])) ?? (showTime ? nextStartMonth : addMonths(nextStartMonth, 1))));
|
|
3231
|
+
if (!resolvedNeedConfirm) {
|
|
2931
3232
|
changeOpen(false);
|
|
2932
3233
|
}
|
|
2933
3234
|
}
|
|
@@ -2942,49 +3243,66 @@ function DateRangePicker({
|
|
|
2942
3243
|
const month = index === 0 ? viewMonth : endViewMonth;
|
|
2943
3244
|
const setMonth = index === 0 ? setViewMonth : setEndViewMonth;
|
|
2944
3245
|
const endpointLabel = index === 0 ? "\u5F00\u59CB" : "\u7ED3\u675F";
|
|
2945
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
3246
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
|
|
3247
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3248
|
+
CalendarHeader,
|
|
3249
|
+
{
|
|
3250
|
+
month,
|
|
3251
|
+
label: endpointLabel,
|
|
3252
|
+
range: true,
|
|
3253
|
+
onPreviousYear: () => setMonth(addMonths(month, -12)),
|
|
3254
|
+
onPreviousMonth: () => setMonth(addMonths(month, -1)),
|
|
3255
|
+
onNextMonth: () => setMonth(addMonths(month, 1)),
|
|
3256
|
+
onNextYear: () => setMonth(addMonths(month, 12))
|
|
3257
|
+
}
|
|
3258
|
+
),
|
|
3259
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3260
|
+
CalendarMonth,
|
|
3261
|
+
{
|
|
3262
|
+
month,
|
|
3263
|
+
range: rangeDates,
|
|
3264
|
+
disabledDate: (day) => isDisabled(day, index, true),
|
|
3265
|
+
onSelect: (day) => selectDateTime(day, index)
|
|
3266
|
+
}
|
|
3267
|
+
)
|
|
3268
|
+
] });
|
|
3269
|
+
}
|
|
3270
|
+
function switchDateTimeView(index, view) {
|
|
3271
|
+
if (endpointDisabled[index]) return;
|
|
3272
|
+
setActiveIndex(index);
|
|
3273
|
+
setDateTimeViews((previous) => index === 0 ? [view, previous[1]] : [previous[0], view]);
|
|
3274
|
+
}
|
|
3275
|
+
function renderDateTimeEndpoint(index) {
|
|
3276
|
+
const label = index === 0 ? "\u5F00\u59CB" : "\u7ED3\u675F";
|
|
3277
|
+
const view = dateTimeViews[index];
|
|
3278
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("section", { className: "sia-date-panel__endpoint", "aria-label": `${label}\u65E5\u671F\u65F6\u95F4`, children: [
|
|
3279
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "sia-date-panel__views", children: [
|
|
3280
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("section", { className: `sia-date-panel__view sia-date-panel__view--date${view === "date" ? " is-active" : ""}`, "aria-hidden": view !== "date", ...view !== "date" ? { inert: "" } : {}, "aria-label": `${label}\u65E5\u671F`, children: renderDateTimeGroup(index) }),
|
|
3281
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: `sia-date-panel__view sia-date-panel__view--time${view === "time" ? " is-active" : ""}`, "aria-hidden": view !== "time", ...view !== "time" ? { inert: "" } : {}, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3282
|
+
TimePanel,
|
|
3283
|
+
{
|
|
3284
|
+
value: times[index],
|
|
3285
|
+
showSecond,
|
|
3286
|
+
title: `\u9009\u62E9${label}\u65F6\u95F4`,
|
|
3287
|
+
unitLabels: true,
|
|
3288
|
+
ariaLabel: `\u9009\u62E9${label}\u65F6\u95F4`,
|
|
3289
|
+
disabledTime: endpointDisabled[index] ? () => true : void 0,
|
|
3290
|
+
onChange: (nextTime) => changeTime(index, nextTime)
|
|
3291
|
+
}
|
|
3292
|
+
) })
|
|
3293
|
+
] }),
|
|
3294
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3295
|
+
DateTimePanelFooter,
|
|
3296
|
+
{
|
|
3297
|
+
date: rangeDates[index] || dateKey(/* @__PURE__ */ new Date()),
|
|
3298
|
+
time: showSecond ? times[index] : times[index].slice(0, 5),
|
|
3299
|
+
view,
|
|
3300
|
+
disabled: endpointDisabled[index],
|
|
3301
|
+
onSwitchDate: () => switchDateTimeView(index, "date"),
|
|
3302
|
+
onSwitchTime: () => switchDateTimeView(index, "time")
|
|
3303
|
+
}
|
|
3304
|
+
)
|
|
3305
|
+
] }, index);
|
|
2988
3306
|
}
|
|
2989
3307
|
const displayValue = visible && allowEmpty.some(Boolean) ? draftValue : currentValue;
|
|
2990
3308
|
const startFloating = useFloatingPlaceholder({ mode: placeholderMode, placeholder: placeholder[0], filled: Boolean(displayValue[0]), active: visible });
|
|
@@ -3029,67 +3347,94 @@ function DateRangePicker({
|
|
|
3029
3347
|
}
|
|
3030
3348
|
),
|
|
3031
3349
|
allowClear && (displayValue[0] || displayValue[1]) && !disabled ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", className: "sia-picker__clear", "aria-label": "\u6E05\u9664\u65E5\u671F\u8303\u56F4", onClick: clearValue, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { name: "circle-close", variant: "filled", size: 15 }) }) : null,
|
|
3032
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("
|
|
3049
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3350
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
3351
|
+
PopupPortal,
|
|
3352
|
+
{
|
|
3353
|
+
ref: popupRef,
|
|
3354
|
+
anchorRef: rootRef,
|
|
3355
|
+
open: visible,
|
|
3356
|
+
className: `sia-date-panel${showTime ? " sia-date-panel--datetime-range" : " sia-date-panel--range"}${presets?.length ? " sia-date-panel--with-presets" : ""}`,
|
|
3357
|
+
role: "dialog",
|
|
3358
|
+
"aria-label": "\u65E5\u671F\u8303\u56F4\u9009\u62E9\u9762\u677F",
|
|
3359
|
+
onKeyDown: (event) => {
|
|
3360
|
+
if (event.key === "Escape") {
|
|
3361
|
+
event.stopPropagation();
|
|
3362
|
+
dismissPanel();
|
|
3363
|
+
}
|
|
3364
|
+
},
|
|
3365
|
+
children: [
|
|
3366
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "sia-date-panel__body", children: [
|
|
3367
|
+
presets?.length ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("aside", { className: "sia-date-panel__presets", "aria-label": "\u5FEB\u6377\u65E5\u671F\u8303\u56F4", children: presets.map((preset2, index) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", onClick: () => applyPreset(preset2), children: preset2.label }, index)) }) : null,
|
|
3368
|
+
showTime ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "sia-date-panel__datetime-endpoints", children: [
|
|
3369
|
+
renderDateTimeEndpoint(0),
|
|
3370
|
+
renderDateTimeEndpoint(1)
|
|
3371
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "sia-date-panel__range-calendars", children: [
|
|
3372
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("section", { className: "sia-date-panel__calendar", children: [
|
|
3373
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3374
|
+
CalendarHeader,
|
|
3375
|
+
{
|
|
3376
|
+
month: viewMonth,
|
|
3377
|
+
range: true,
|
|
3378
|
+
onPreviousYear: () => setViewMonth(addMonths(viewMonth, -12)),
|
|
3379
|
+
onPreviousMonth: () => setViewMonth(addMonths(viewMonth, -1))
|
|
3380
|
+
}
|
|
3381
|
+
),
|
|
3382
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(CalendarMonth, { month: viewMonth, range: rangeDates, previewEnd: activeIndex === 1 ? hoverDate : "", disabledDate: isDisabled, onSelect: selectDate, onHover: activeIndex === 1 ? setHoverDate : void 0 })
|
|
3383
|
+
] }),
|
|
3384
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("section", { className: "sia-date-panel__calendar", children: [
|
|
3385
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3386
|
+
CalendarHeader,
|
|
3387
|
+
{
|
|
3388
|
+
month: addMonths(viewMonth, 1),
|
|
3389
|
+
range: true,
|
|
3390
|
+
onNextMonth: () => setViewMonth(addMonths(viewMonth, 1)),
|
|
3391
|
+
onNextYear: () => setViewMonth(addMonths(viewMonth, 12))
|
|
3392
|
+
}
|
|
3393
|
+
),
|
|
3394
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(CalendarMonth, { month: addMonths(viewMonth, 1), range: rangeDates, previewEnd: activeIndex === 1 ? hoverDate : "", disabledDate: isDisabled, onSelect: selectDate, onHover: activeIndex === 1 ? setHoverDate : void 0 })
|
|
3395
|
+
] })
|
|
3396
|
+
] })
|
|
3075
3397
|
] }),
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3398
|
+
showTime ? renderExtraFooter || invalidDateTimeRange || maxRangeDays ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3399
|
+
DatePanelFooter,
|
|
3400
|
+
{
|
|
3401
|
+
showToday: false,
|
|
3402
|
+
extra: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
|
|
3403
|
+
renderExtraFooter?.(),
|
|
3404
|
+
invalidDateTimeRange ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("small", { className: "sia-date-panel__range-error", children: "\u7ED3\u675F\u65F6\u95F4\u4E0D\u80FD\u65E9\u4E8E\u5F00\u59CB\u65F6\u95F4" }) : maxRangeDays ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("small", { children: [
|
|
3405
|
+
"\u6700\u591A\u9009\u62E9 ",
|
|
3406
|
+
maxRangeDays,
|
|
3407
|
+
" \u5929"
|
|
3408
|
+
] }) : null
|
|
3409
|
+
] })
|
|
3087
3410
|
}
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3411
|
+
) : null : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3412
|
+
DatePanelFooter,
|
|
3413
|
+
{
|
|
3414
|
+
showToday: showToday && !presets?.length,
|
|
3415
|
+
needConfirm: resolvedNeedConfirm || allowEmpty.some(Boolean),
|
|
3416
|
+
disabledConfirm: !isValidRange(draftValue),
|
|
3417
|
+
extra: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
|
|
3418
|
+
renderExtraFooter?.(),
|
|
3419
|
+
invalidDateTimeRange ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("small", { className: "sia-date-panel__range-error", children: "\u7ED3\u675F\u65F6\u95F4\u4E0D\u80FD\u65E9\u4E8E\u5F00\u59CB\u65F6\u95F4" }) : maxRangeDays ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("small", { children: [
|
|
3420
|
+
"\u6700\u591A\u9009\u62E9 ",
|
|
3421
|
+
maxRangeDays,
|
|
3422
|
+
" \u5929"
|
|
3423
|
+
] }) : null
|
|
3424
|
+
] }),
|
|
3425
|
+
onToday: () => {
|
|
3426
|
+
const now = /* @__PURE__ */ new Date();
|
|
3427
|
+
const day = dateKey(now);
|
|
3428
|
+
if (isDisabled(day, activeIndex, Boolean(showTime))) return;
|
|
3429
|
+
setViewMonth(startOfMonth(now));
|
|
3430
|
+
selectDate(day);
|
|
3431
|
+
},
|
|
3432
|
+
onConfirm: confirm
|
|
3433
|
+
}
|
|
3434
|
+
)
|
|
3435
|
+
]
|
|
3436
|
+
}
|
|
3437
|
+
)
|
|
3093
3438
|
] });
|
|
3094
3439
|
}
|
|
3095
3440
|
((DatePicker2) => {
|