@sia.soul/sia-react-ui 0.1.166 → 0.1.168
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-Dxevc0f6.d.cts → Select-BXL6JVj0.d.cts} +3 -1
- package/dist/{Select-tsENCXQI.d.ts → Select-xBynHOUn.d.ts} +3 -1
- package/dist/chart.cjs +4553 -4513
- package/dist/chart.d.cts +1850 -1843
- package/dist/chart.d.ts +1850 -1843
- package/dist/chart.js +1 -1
- package/dist/chunk-2FZI7TP6.js +0 -0
- package/dist/{chunk-T2F6X3LA.js → chunk-55MXRT55.js} +26 -22
- package/dist/{chunk-2EC653G5.js → chunk-5KTQXNGL.js} +2 -2
- package/dist/{chunk-NHGCGOF2.js → chunk-A7TLMWMM.js} +4754 -4714
- package/dist/{chunk-DKQ5UCN6.js → chunk-DQR7EPRA.js} +519 -220
- package/dist/{chunk-G5EJJFUI.js → chunk-FSO46WEJ.js} +14 -6
- package/dist/{chunk-SX4LLT3H.js → chunk-V4YT4LT5.js} +36 -29
- package/dist/{chunk-23FQ5ARA.js → chunk-XS7AVCHO.js} +27 -17
- package/dist/{core-Dy8NWJ1b.d.ts → core-BlCSI1Tm.d.ts} +7 -10
- package/dist/{core-Cnt8r6pj.d.cts → core-D_D7pOTq.d.cts} +7 -10
- package/dist/core.cjs +117 -88
- package/dist/core.css +3145 -5342
- package/dist/core.d.cts +2 -2
- package/dist/core.d.ts +2 -2
- package/dist/core.js +4 -4
- package/dist/game.cjs +14 -6
- package/dist/game.css +1658 -3131
- package/dist/game.js +1 -1
- package/dist/index.cjs +6684 -6237
- package/dist/index.css +8717 -8536
- package/dist/index.d.cts +137 -116
- package/dist/index.d.ts +137 -116
- package/dist/index.js +908 -828
- package/dist/markdown-editor.css +461 -0
- package/dist/markdown-editor.js +2 -1
- package/dist/rich-text-editor.cjs +38 -20
- package/dist/rich-text-editor.css +461 -0
- package/dist/rich-text-editor.js +4 -3
- package/dist/{select-date-range-E1N5-oXv.d.ts → select-date-range-C-29x2BA.d.ts} +7 -10
- package/dist/{select-date-range-BnlISSPV.d.cts → select-date-range-CewOaLtk.d.cts} +7 -10
- package/dist/select-date-range.cjs +563 -249
- package/dist/select-date-range.d.cts +2 -2
- package/dist/select-date-range.d.ts +2 -2
- package/dist/select-date-range.js +4 -4
- package/package.json +5 -1
- /package/dist/{chunk-V4I32DPL.js → chunk-GKWSCL5Q.js} +0 -0
|
@@ -2254,12 +2254,6 @@ function addMonths(value, amount) {
|
|
|
2254
2254
|
function addDays(value, amount) {
|
|
2255
2255
|
return new Date(value.getFullYear(), value.getMonth(), value.getDate() + amount);
|
|
2256
2256
|
}
|
|
2257
|
-
function daysBetween(left, right) {
|
|
2258
|
-
const leftDate = parseDate(left);
|
|
2259
|
-
const rightDate = parseDate(right);
|
|
2260
|
-
if (!leftDate || !rightDate) return 0;
|
|
2261
|
-
return Math.round((rightDate.getTime() - leftDate.getTime()) / 864e5);
|
|
2262
|
-
}
|
|
2263
2257
|
function timePart(value, fallback = "00:00:00") {
|
|
2264
2258
|
const match = value?.match(/[T ](\d{2}):(\d{2})(?::(\d{2}))?/);
|
|
2265
2259
|
return match ? `${match[1]}:${match[2]}:${match[3] ?? "00"}` : fallback;
|
|
@@ -2336,10 +2330,11 @@ function CalendarMonth({
|
|
|
2336
2330
|
const mondayIndex = (first.getDay() + 6) % 7;
|
|
2337
2331
|
const gridStart = addDays(first, -mondayIndex);
|
|
2338
2332
|
const today = dateKey(/* @__PURE__ */ new Date());
|
|
2339
|
-
const start = range[0];
|
|
2340
|
-
const end = range[1] || previewEnd || "";
|
|
2333
|
+
const start = range[0] || (range[1] ? previewEnd || "" : "");
|
|
2334
|
+
const end = range[1] || (range[0] ? previewEnd || "" : "");
|
|
2341
2335
|
const low = start && end ? start <= end ? start : end : "";
|
|
2342
2336
|
const high = start && end ? start <= end ? end : start : "";
|
|
2337
|
+
const selectedSet = new Set(selectedDates);
|
|
2343
2338
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
2344
2339
|
"div",
|
|
2345
2340
|
{
|
|
@@ -2362,12 +2357,16 @@ function CalendarMonth({
|
|
|
2362
2357
|
const key = dateKey(date);
|
|
2363
2358
|
const outside = date.getMonth() !== month.getMonth();
|
|
2364
2359
|
const disabled = disabledDate?.(key) ?? false;
|
|
2365
|
-
const selected =
|
|
2360
|
+
const selected = selectedSet.has(key);
|
|
2366
2361
|
const rangeStart = Boolean(start && key === start);
|
|
2367
2362
|
const rangeEnd = Boolean(range[1] && key === range[1]);
|
|
2368
|
-
const
|
|
2369
|
-
const
|
|
2370
|
-
const
|
|
2363
|
+
const inDateRange = Boolean(low && high && key >= low && key <= high);
|
|
2364
|
+
const prevSelected = selected && selectedSet.has(dateKey(addDays(date, -1)));
|
|
2365
|
+
const nextSelected = selected && selectedSet.has(dateKey(addDays(date, 1)));
|
|
2366
|
+
const inMultiRun = selected && (prevSelected || nextSelected);
|
|
2367
|
+
const inRange = inDateRange || inMultiRun;
|
|
2368
|
+
const segmentStart = inDateRange ? index % 7 === 0 || key === low : inMultiRun && (index % 7 === 0 || !prevSelected);
|
|
2369
|
+
const segmentEnd = inDateRange ? index % 7 === 6 || key === high : inMultiRun && (index % 7 === 6 || !nextSelected);
|
|
2371
2370
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2372
2371
|
"span",
|
|
2373
2372
|
{
|
|
@@ -2397,11 +2396,15 @@ function CalendarHeader({
|
|
|
2397
2396
|
label,
|
|
2398
2397
|
range = false,
|
|
2399
2398
|
onTitleClick,
|
|
2399
|
+
onYearClick,
|
|
2400
|
+
onMonthClick,
|
|
2400
2401
|
onPreviousYear,
|
|
2401
2402
|
onPreviousMonth,
|
|
2402
2403
|
onNextMonth,
|
|
2403
2404
|
onNextYear
|
|
2404
2405
|
}) {
|
|
2406
|
+
const yearText = `${month.getFullYear()}\u5E74`;
|
|
2407
|
+
const monthText = `${month.getMonth() + 1}\u6708`;
|
|
2405
2408
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "sia-date-panel__header", children: [
|
|
2406
2409
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { className: "sia-date-panel__nav", children: [
|
|
2407
2410
|
onPreviousYear ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("button", { type: "button", "aria-label": "\u4E0A\u4E00\u5E74", onClick: onPreviousYear, children: [
|
|
@@ -2410,21 +2413,23 @@ function CalendarHeader({
|
|
|
2410
2413
|
] }) : null,
|
|
2411
2414
|
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
|
|
2412
2415
|
] }),
|
|
2413
|
-
|
|
2416
|
+
onYearClick || onMonthClick ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "sia-date-panel__title-group", children: [
|
|
2417
|
+
label ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("small", { children: label }) : null,
|
|
2418
|
+
onYearClick ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { type: "button", className: "sia-date-panel__title-part", "aria-label": "\u9009\u62E9\u5E74\u4EFD", onClick: onYearClick, children: yearText }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { children: yearText }),
|
|
2419
|
+
onMonthClick ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("button", { type: "button", className: "sia-date-panel__title-part", "aria-label": "\u9009\u62E9\u6708\u4EFD", onClick: onMonthClick, children: monthText }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { children: monthText })
|
|
2420
|
+
] }) : 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
2421
|
label ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("small", { children: label }) : null,
|
|
2415
2422
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { children: [
|
|
2416
|
-
|
|
2417
|
-
"\
|
|
2418
|
-
|
|
2419
|
-
"\u6708"
|
|
2423
|
+
yearText,
|
|
2424
|
+
"\xA0 ",
|
|
2425
|
+
monthText
|
|
2420
2426
|
] })
|
|
2421
2427
|
] }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("strong", { children: [
|
|
2422
2428
|
label ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("small", { children: label }) : null,
|
|
2423
2429
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { children: [
|
|
2424
|
-
|
|
2425
|
-
"\
|
|
2426
|
-
|
|
2427
|
-
"\u6708"
|
|
2430
|
+
yearText,
|
|
2431
|
+
"\xA0 ",
|
|
2432
|
+
monthText
|
|
2428
2433
|
] })
|
|
2429
2434
|
] }),
|
|
2430
2435
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { className: "sia-date-panel__nav", children: [
|
|
@@ -2671,8 +2676,229 @@ function DateTimePanelFooter({
|
|
|
2671
2676
|
] });
|
|
2672
2677
|
}
|
|
2673
2678
|
|
|
2679
|
+
// src/components/dateRangeLogic.ts
|
|
2680
|
+
function parseDateOnly(value) {
|
|
2681
|
+
const match = value.match(/^(\d{4})-(\d{2})-(\d{2})/);
|
|
2682
|
+
if (!match) return null;
|
|
2683
|
+
const date = new Date(Number(match[1]), Number(match[2]) - 1, Number(match[3]));
|
|
2684
|
+
return Number.isNaN(date.getTime()) ? null : date;
|
|
2685
|
+
}
|
|
2686
|
+
function diffDays(left, right) {
|
|
2687
|
+
const leftDate = parseDateOnly(left);
|
|
2688
|
+
const rightDate = parseDateOnly(right);
|
|
2689
|
+
if (!leftDate || !rightDate) return 0;
|
|
2690
|
+
return Math.round((rightDate.getTime() - leftDate.getTime()) / 864e5);
|
|
2691
|
+
}
|
|
2692
|
+
function formatWithTime(date, time, showSecond) {
|
|
2693
|
+
if (!date) return "";
|
|
2694
|
+
const [hour = "00", minute = "00", second = "00"] = time.split(":");
|
|
2695
|
+
return `${date} ${hour}:${minute}${showSecond ? `:${second}` : ""}`;
|
|
2696
|
+
}
|
|
2697
|
+
function dayOnly(value) {
|
|
2698
|
+
const match = value.match(/^(\d{4}-\d{2}-\d{2})/);
|
|
2699
|
+
return match ? match[1] : "";
|
|
2700
|
+
}
|
|
2701
|
+
function normalizeTimeForCompare(time, showSecond) {
|
|
2702
|
+
const [h = "00", m = "00", s = "00"] = time.split(":");
|
|
2703
|
+
return showSecond ? `${h}:${m}:${s}` : `${h}:${m}:00`;
|
|
2704
|
+
}
|
|
2705
|
+
function validateDateRange(next, options) {
|
|
2706
|
+
const { currentValue, allowEmpty, endpointDisabled, minDate, maxDate, maxRangeDays, disabledDate } = options;
|
|
2707
|
+
if (!next[0] && !next[1]) return { valid: false, reason: "empty" };
|
|
2708
|
+
for (const index of [0, 1]) {
|
|
2709
|
+
if (!next[index]) {
|
|
2710
|
+
if (!allowEmpty[index]) return { valid: false, reason: "incomplete" };
|
|
2711
|
+
continue;
|
|
2712
|
+
}
|
|
2713
|
+
if (endpointDisabled[index]) {
|
|
2714
|
+
if (next[index] !== currentValue[index]) return { valid: false, reason: "locked" };
|
|
2715
|
+
continue;
|
|
2716
|
+
}
|
|
2717
|
+
const day = dayOnly(next[index]);
|
|
2718
|
+
if (!day) return { valid: false, reason: "invalid" };
|
|
2719
|
+
if (minDate && day < minDate.slice(0, 10) || maxDate && day > maxDate.slice(0, 10)) {
|
|
2720
|
+
return { valid: false, reason: "bounds", message: "\u6240\u9009\u65E5\u671F\u8D85\u51FA\u53EF\u9009\u8303\u56F4" };
|
|
2721
|
+
}
|
|
2722
|
+
const from = index === 1 ? dayOnly(next[0]) || void 0 : void 0;
|
|
2723
|
+
if (disabledDate?.(day, { from, type: "date" })) {
|
|
2724
|
+
return { valid: false, reason: "disabled", message: "\u5305\u542B\u4E0D\u53EF\u9009\u65E5\u671F" };
|
|
2725
|
+
}
|
|
2726
|
+
}
|
|
2727
|
+
if (next[0] && next[1]) {
|
|
2728
|
+
if (next[0] > next[1]) {
|
|
2729
|
+
return { valid: false, reason: "order", message: "\u7ED3\u675F\u65F6\u95F4\u4E0D\u80FD\u65E9\u4E8E\u5F00\u59CB\u65F6\u95F4" };
|
|
2730
|
+
}
|
|
2731
|
+
if (maxRangeDays && Math.abs(diffDays(dayOnly(next[0]), dayOnly(next[1]))) >= maxRangeDays) {
|
|
2732
|
+
return { valid: false, reason: "maxRange", message: `\u6700\u591A\u9009\u62E9 ${maxRangeDays} \u5929` };
|
|
2733
|
+
}
|
|
2734
|
+
}
|
|
2735
|
+
return { valid: true };
|
|
2736
|
+
}
|
|
2737
|
+
function isRangeDayDisabled(day, options) {
|
|
2738
|
+
const { activeIndex, rangeDates, endpointDisabled, minDate, maxDate, maxRangeDays, disabledDate } = options;
|
|
2739
|
+
if (endpointDisabled[activeIndex]) return true;
|
|
2740
|
+
if (minDate && day < minDate.slice(0, 10)) return true;
|
|
2741
|
+
if (maxDate && day > maxDate.slice(0, 10)) return true;
|
|
2742
|
+
const otherIndex = activeIndex === 0 ? 1 : 0;
|
|
2743
|
+
const otherDay = rangeDates[otherIndex];
|
|
2744
|
+
if (endpointDisabled[otherIndex] && otherDay) {
|
|
2745
|
+
if (activeIndex === 0 && day > otherDay) return true;
|
|
2746
|
+
if (activeIndex === 1 && day < otherDay) return true;
|
|
2747
|
+
if (maxRangeDays && Math.abs(diffDays(otherDay, day)) >= maxRangeDays) return true;
|
|
2748
|
+
} else if (activeIndex === 1 && rangeDates[0]) {
|
|
2749
|
+
if (maxRangeDays && Math.abs(diffDays(rangeDates[0], day)) >= maxRangeDays) return true;
|
|
2750
|
+
} else if (activeIndex === 0 && !rangeDates[0] && rangeDates[1]) {
|
|
2751
|
+
if (maxRangeDays && Math.abs(diffDays(rangeDates[1], day)) >= maxRangeDays) return true;
|
|
2752
|
+
}
|
|
2753
|
+
const from = activeIndex === 1 ? rangeDates[0] || void 0 : !rangeDates[0] && rangeDates[1] ? rangeDates[1] : void 0;
|
|
2754
|
+
return disabledDate?.(day, { from, type: "date" }) ?? false;
|
|
2755
|
+
}
|
|
2756
|
+
function isRangeTimeDisabled(candidateTime, activeIndex, rangeDates, times, endpointDisabled, showSecond) {
|
|
2757
|
+
if (endpointDisabled[activeIndex]) return true;
|
|
2758
|
+
if (!rangeDates[0] || !rangeDates[1] || rangeDates[0] !== rangeDates[1]) return false;
|
|
2759
|
+
const candidate = normalizeTimeForCompare(candidateTime, showSecond);
|
|
2760
|
+
const other = normalizeTimeForCompare(times[activeIndex === 0 ? 1 : 0], showSecond);
|
|
2761
|
+
return activeIndex === 0 ? candidate > other : candidate < other;
|
|
2762
|
+
}
|
|
2763
|
+
function pickRangeDate(input) {
|
|
2764
|
+
const { day, activeIndex, draftValue, times, defaultTimes, showTime, showSecond, endpointDisabled, maxRangeDays } = input;
|
|
2765
|
+
const startDay = dayOnly(draftValue[0]);
|
|
2766
|
+
const endDay = dayOnly(draftValue[1]);
|
|
2767
|
+
const nextTimes = [times[0], times[1]];
|
|
2768
|
+
const format = (targetDay, idx) => showTime ? formatWithTime(targetDay, nextTimes[idx], showSecond) : targetDay;
|
|
2769
|
+
if (endpointDisabled[0] || endpointDisabled[1]) {
|
|
2770
|
+
const editableIndex = endpointDisabled[0] ? 1 : 0;
|
|
2771
|
+
if (showTime && !draftValue[editableIndex]) {
|
|
2772
|
+
nextTimes[editableIndex] = defaultTimes[editableIndex];
|
|
2773
|
+
}
|
|
2774
|
+
const nextDraft = [draftValue[0], draftValue[1]];
|
|
2775
|
+
nextDraft[editableIndex] = format(day, editableIndex);
|
|
2776
|
+
return {
|
|
2777
|
+
nextDraft,
|
|
2778
|
+
nextTimes,
|
|
2779
|
+
nextActiveIndex: editableIndex,
|
|
2780
|
+
completedPair: Boolean(nextDraft[0] && nextDraft[1])
|
|
2781
|
+
};
|
|
2782
|
+
}
|
|
2783
|
+
if (activeIndex === 0) {
|
|
2784
|
+
if (showTime && !draftValue[0]) {
|
|
2785
|
+
nextTimes[0] = defaultTimes[0];
|
|
2786
|
+
}
|
|
2787
|
+
if (!startDay && endDay) {
|
|
2788
|
+
if (day > endDay) {
|
|
2789
|
+
return {
|
|
2790
|
+
nextDraft: [format(endDay, 0), format(day, 1)],
|
|
2791
|
+
nextTimes,
|
|
2792
|
+
nextActiveIndex: 0,
|
|
2793
|
+
completedPair: true
|
|
2794
|
+
};
|
|
2795
|
+
}
|
|
2796
|
+
return {
|
|
2797
|
+
nextDraft: [format(day, 0), draftValue[1]],
|
|
2798
|
+
nextTimes,
|
|
2799
|
+
nextActiveIndex: 0,
|
|
2800
|
+
completedPair: true
|
|
2801
|
+
};
|
|
2802
|
+
}
|
|
2803
|
+
const withinMaxSpan = !maxRangeDays || endDay && Math.abs(diffDays(day, endDay)) < maxRangeDays;
|
|
2804
|
+
if (endDay && day <= endDay && withinMaxSpan) {
|
|
2805
|
+
return {
|
|
2806
|
+
nextDraft: [format(day, 0), draftValue[1]],
|
|
2807
|
+
nextTimes,
|
|
2808
|
+
nextActiveIndex: 0,
|
|
2809
|
+
completedPair: false
|
|
2810
|
+
};
|
|
2811
|
+
}
|
|
2812
|
+
return {
|
|
2813
|
+
nextDraft: [format(day, 0), ""],
|
|
2814
|
+
nextTimes,
|
|
2815
|
+
nextActiveIndex: 1,
|
|
2816
|
+
completedPair: false
|
|
2817
|
+
};
|
|
2818
|
+
}
|
|
2819
|
+
if (!startDay) {
|
|
2820
|
+
if (showTime && !draftValue[1]) {
|
|
2821
|
+
nextTimes[1] = defaultTimes[1];
|
|
2822
|
+
}
|
|
2823
|
+
return {
|
|
2824
|
+
nextDraft: ["", format(day, 1)],
|
|
2825
|
+
nextTimes,
|
|
2826
|
+
nextActiveIndex: 0,
|
|
2827
|
+
completedPair: false
|
|
2828
|
+
};
|
|
2829
|
+
}
|
|
2830
|
+
if (day < startDay) {
|
|
2831
|
+
if (showTime && !draftValue[1]) {
|
|
2832
|
+
nextTimes[1] = defaultTimes[1];
|
|
2833
|
+
}
|
|
2834
|
+
return {
|
|
2835
|
+
nextDraft: [format(day, 0), format(startDay, 1)],
|
|
2836
|
+
nextTimes,
|
|
2837
|
+
nextActiveIndex: 1,
|
|
2838
|
+
completedPair: true
|
|
2839
|
+
};
|
|
2840
|
+
}
|
|
2841
|
+
if (showTime && !draftValue[1]) {
|
|
2842
|
+
nextTimes[1] = defaultTimes[1];
|
|
2843
|
+
}
|
|
2844
|
+
return {
|
|
2845
|
+
nextDraft: [draftValue[0], format(day, 1)],
|
|
2846
|
+
nextTimes,
|
|
2847
|
+
nextActiveIndex: 1,
|
|
2848
|
+
completedPair: true
|
|
2849
|
+
};
|
|
2850
|
+
}
|
|
2851
|
+
|
|
2674
2852
|
// src/components/DatePicker.tsx
|
|
2675
2853
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
2854
|
+
function weekStart(now) {
|
|
2855
|
+
const day = now.getDay();
|
|
2856
|
+
const offset = day === 0 ? -6 : 1 - day;
|
|
2857
|
+
return addDays(now, offset);
|
|
2858
|
+
}
|
|
2859
|
+
var DEFAULT_DATE_PRESETS = [
|
|
2860
|
+
{ label: "\u4ECA\u5929", value: () => dateKey(/* @__PURE__ */ new Date()) },
|
|
2861
|
+
{ label: "\u6628\u5929", value: () => dateKey(addDays(/* @__PURE__ */ new Date(), -1)) },
|
|
2862
|
+
{ label: "\u524D\u5929", value: () => dateKey(addDays(/* @__PURE__ */ new Date(), -2)) },
|
|
2863
|
+
{ label: "\u4E00\u5468\u524D", value: () => dateKey(addDays(/* @__PURE__ */ new Date(), -7)) },
|
|
2864
|
+
{ label: "\u534A\u6708\u524D", value: () => dateKey(addDays(/* @__PURE__ */ new Date(), -15)) },
|
|
2865
|
+
{ label: "\u4E00\u6708\u524D", value: () => dateKey(addDays(/* @__PURE__ */ new Date(), -30)) },
|
|
2866
|
+
{ label: "\u672C\u67081\u65E5", value: () => dateKey(startOfMonth(/* @__PURE__ */ new Date())) }
|
|
2867
|
+
];
|
|
2868
|
+
var DEFAULT_RANGE_PRESETS = [
|
|
2869
|
+
{ label: "\u4ECA\u5929", value: () => {
|
|
2870
|
+
const today = dateKey(/* @__PURE__ */ new Date());
|
|
2871
|
+
return [today, today];
|
|
2872
|
+
} },
|
|
2873
|
+
{ label: "\u6628\u5929", value: () => {
|
|
2874
|
+
const yesterday = dateKey(addDays(/* @__PURE__ */ new Date(), -1));
|
|
2875
|
+
return [yesterday, yesterday];
|
|
2876
|
+
} },
|
|
2877
|
+
{ label: "\u672C\u5468", value: () => {
|
|
2878
|
+
const now = /* @__PURE__ */ new Date();
|
|
2879
|
+
return [dateKey(weekStart(now)), dateKey(now)];
|
|
2880
|
+
} },
|
|
2881
|
+
{ label: "\u672C\u6708", value: () => {
|
|
2882
|
+
const now = /* @__PURE__ */ new Date();
|
|
2883
|
+
return [dateKey(startOfMonth(now)), dateKey(now)];
|
|
2884
|
+
} },
|
|
2885
|
+
{ label: "\u8FD17\u5929", value: () => {
|
|
2886
|
+
const now = /* @__PURE__ */ new Date();
|
|
2887
|
+
return [dateKey(addDays(now, -6)), dateKey(now)];
|
|
2888
|
+
} },
|
|
2889
|
+
{ label: "\u8FD115\u5929", value: () => {
|
|
2890
|
+
const now = /* @__PURE__ */ new Date();
|
|
2891
|
+
return [dateKey(addDays(now, -14)), dateKey(now)];
|
|
2892
|
+
} },
|
|
2893
|
+
{ label: "\u8FD130\u5929", value: () => {
|
|
2894
|
+
const now = /* @__PURE__ */ new Date();
|
|
2895
|
+
return [dateKey(addDays(now, -29)), dateKey(now)];
|
|
2896
|
+
} },
|
|
2897
|
+
{ label: "\u8FD160\u5929", value: () => {
|
|
2898
|
+
const now = /* @__PURE__ */ new Date();
|
|
2899
|
+
return [dateKey(addDays(now, -59)), dateKey(now)];
|
|
2900
|
+
} }
|
|
2901
|
+
];
|
|
2676
2902
|
function formatWeek(date) {
|
|
2677
2903
|
const target = new Date(date);
|
|
2678
2904
|
target.setHours(0, 0, 0, 0);
|
|
@@ -2725,7 +2951,7 @@ function hasExplicitTime(value) {
|
|
|
2725
2951
|
function isZeroTime(time, showSecond) {
|
|
2726
2952
|
return showSecond ? time === "00:00:00" : time.slice(0, 5) === "00:00";
|
|
2727
2953
|
}
|
|
2728
|
-
function DatePicker({
|
|
2954
|
+
var DatePickerRoot = (0, import_react9.forwardRef)(function DatePicker({
|
|
2729
2955
|
value,
|
|
2730
2956
|
defaultValue,
|
|
2731
2957
|
picker = "date",
|
|
@@ -2752,10 +2978,15 @@ function DatePicker({
|
|
|
2752
2978
|
formatValue = (value2) => value2,
|
|
2753
2979
|
renderExtraFooter,
|
|
2754
2980
|
...props
|
|
2755
|
-
}) {
|
|
2981
|
+
}, forwardedRef) {
|
|
2756
2982
|
const size = useControlSize(sizeProp);
|
|
2757
2983
|
const id = (0, import_react9.useId)();
|
|
2758
2984
|
const rootRef = (0, import_react9.useRef)(null);
|
|
2985
|
+
function setRootRef(node) {
|
|
2986
|
+
rootRef.current = node;
|
|
2987
|
+
if (typeof forwardedRef === "function") forwardedRef(node);
|
|
2988
|
+
else if (forwardedRef) forwardedRef.current = node;
|
|
2989
|
+
}
|
|
2759
2990
|
const popupRef = (0, import_react9.useRef)(null);
|
|
2760
2991
|
const initialValue = defaultValue ?? (multiple ? [] : "");
|
|
2761
2992
|
const [currentValue, setCurrentValue] = useControllableState({ value, defaultValue: initialValue, onChange });
|
|
@@ -2907,7 +3138,8 @@ function DatePicker({
|
|
|
2907
3138
|
const display = Array.isArray(currentValue) ? currentValue.map(formatValue).join("\u3001") : currentValue ? formatValue(currentValue) : "";
|
|
2908
3139
|
const floating = useFloatingPlaceholder({ mode: placeholderMode, placeholder: placeholder ?? placeholderFor(picker, showTime, multiple), filled: Boolean(display), active: visible });
|
|
2909
3140
|
const triggerLabel = props["aria-label"] ?? (typeof placeholder === "string" ? placeholder : "\u65E5\u671F\u9009\u62E9\u5668");
|
|
2910
|
-
|
|
3141
|
+
const resolvedPresets = presets !== void 0 ? presets : picker === "date" && !multiple ? DEFAULT_DATE_PRESETS : void 0;
|
|
3142
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { ref: setRootRef, className: `sia-picker${floating.className} sia-picker--${size} sia-picker--${status}${visible ? " is-open" : ""}${disabled ? " is-disabled" : ""} ${className}`.trim(), children: [
|
|
2911
3143
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
2912
3144
|
"button",
|
|
2913
3145
|
{
|
|
@@ -2943,7 +3175,7 @@ function DatePicker({
|
|
|
2943
3175
|
ref: popupRef,
|
|
2944
3176
|
anchorRef: rootRef,
|
|
2945
3177
|
open: visible,
|
|
2946
|
-
className: `sia-date-panel${showTime ? " sia-date-panel--datetime" : ""}${
|
|
3178
|
+
className: `sia-date-panel${showTime ? " sia-date-panel--datetime" : ""}${resolvedPresets?.length ? " sia-date-panel--with-presets" : ""}`,
|
|
2947
3179
|
role: "dialog",
|
|
2948
3180
|
"aria-label": "\u65E5\u671F\u9009\u62E9\u9762\u677F",
|
|
2949
3181
|
onKeyDown: (event) => {
|
|
@@ -2954,12 +3186,16 @@ function DatePicker({
|
|
|
2954
3186
|
},
|
|
2955
3187
|
children: [
|
|
2956
3188
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "sia-date-panel__body", children: [
|
|
2957
|
-
|
|
2958
|
-
const
|
|
2959
|
-
|
|
3189
|
+
resolvedPresets?.length ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("aside", { className: "sia-date-panel__presets", "aria-label": "\u5FEB\u6377\u65E5\u671F", children: resolvedPresets.map((preset2, index) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", onClick: () => {
|
|
3190
|
+
const raw = resolvePreset(preset2.value);
|
|
3191
|
+
const next = normalizeDateValue(raw, showTime);
|
|
3192
|
+
const day = dayFromValue(next);
|
|
3193
|
+
if (!next || !day || isDisabled(day)) return;
|
|
2960
3194
|
setDraftValue(next);
|
|
2961
3195
|
setDraftTime(timePart(next, defaultTimeFrom(showTime)));
|
|
2962
3196
|
setTimeExplicit(hasExplicitTime(next));
|
|
3197
|
+
const parsed = parseDate(day);
|
|
3198
|
+
if (parsed) setViewMonth(startOfMonth(parsed));
|
|
2963
3199
|
if (!resolvedNeedConfirm) {
|
|
2964
3200
|
setCurrentValue(next);
|
|
2965
3201
|
changeOpen(false);
|
|
@@ -3014,8 +3250,8 @@ function DatePicker({
|
|
|
3014
3250
|
}
|
|
3015
3251
|
)
|
|
3016
3252
|
] });
|
|
3017
|
-
}
|
|
3018
|
-
|
|
3253
|
+
});
|
|
3254
|
+
var DateRangePicker = (0, import_react9.forwardRef)(function DateRangePicker2({
|
|
3019
3255
|
value,
|
|
3020
3256
|
defaultValue = ["", ""],
|
|
3021
3257
|
placeholder = ["\u5F00\u59CB\u65E5\u671F", "\u7ED3\u675F\u65E5\u671F"],
|
|
@@ -3045,10 +3281,15 @@ function DateRangePicker({
|
|
|
3045
3281
|
formatValue = (value2) => value2,
|
|
3046
3282
|
renderExtraFooter,
|
|
3047
3283
|
...props
|
|
3048
|
-
}) {
|
|
3284
|
+
}, forwardedRef) {
|
|
3049
3285
|
const size = useControlSize(sizeProp);
|
|
3050
3286
|
const id = (0, import_react9.useId)();
|
|
3051
3287
|
const rootRef = (0, import_react9.useRef)(null);
|
|
3288
|
+
function setRootRef(node) {
|
|
3289
|
+
rootRef.current = node;
|
|
3290
|
+
if (typeof forwardedRef === "function") forwardedRef(node);
|
|
3291
|
+
else if (forwardedRef) forwardedRef.current = node;
|
|
3292
|
+
}
|
|
3052
3293
|
const popupRef = (0, import_react9.useRef)(null);
|
|
3053
3294
|
const [currentValue, setCurrentValue] = useControllableState({ value: value === void 0 ? void 0 : Array.isArray(value) ? value : ["", ""], defaultValue, onChange });
|
|
3054
3295
|
const [visible, setVisible] = useControllableState({ value: open, defaultValue: defaultOpen, onChange: onOpenChange });
|
|
@@ -3072,10 +3313,10 @@ function DateRangePicker({
|
|
|
3072
3313
|
}
|
|
3073
3314
|
return () => observer.disconnect();
|
|
3074
3315
|
});
|
|
3075
|
-
const [
|
|
3316
|
+
const [dateTimeView, setDateTimeView] = (0, import_react9.useState)("date");
|
|
3317
|
+
const [panelMode, setPanelMode] = (0, import_react9.useState)("date");
|
|
3076
3318
|
const [hoverDate, setHoverDate] = (0, import_react9.useState)("");
|
|
3077
3319
|
const [viewMonth, setViewMonth] = (0, import_react9.useState)(() => startOfMonth(parseDate(dayFromValue(currentValue[0] || currentValue[1])) ?? /* @__PURE__ */ new Date()));
|
|
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))));
|
|
3079
3320
|
const showSecond = showSecondFrom(showTime);
|
|
3080
3321
|
const defaultTime = defaultTimeFrom(showTime);
|
|
3081
3322
|
const defaultEndTime = defaultTimeFrom(showTime, 1);
|
|
@@ -3085,7 +3326,18 @@ function DateRangePicker({
|
|
|
3085
3326
|
]);
|
|
3086
3327
|
const resolvedNeedConfirm = showTime ? false : Boolean(needConfirm);
|
|
3087
3328
|
const rangeDates = [dayFromValue(draftValue[0]), dayFromValue(draftValue[1])];
|
|
3088
|
-
const
|
|
3329
|
+
const minBound = minDate ?? (props.min !== void 0 ? String(props.min) : void 0);
|
|
3330
|
+
const maxBound = maxDate ?? (props.max !== void 0 ? String(props.max) : void 0);
|
|
3331
|
+
const validation = validateDateRange(draftValue, {
|
|
3332
|
+
currentValue,
|
|
3333
|
+
allowEmpty,
|
|
3334
|
+
endpointDisabled,
|
|
3335
|
+
minDate: minBound,
|
|
3336
|
+
maxDate: maxBound,
|
|
3337
|
+
maxRangeDays,
|
|
3338
|
+
disabledDate
|
|
3339
|
+
});
|
|
3340
|
+
const invalidRangeMessage = !validation.valid && (validation.reason === "order" || validation.reason === "maxRange" || validation.reason === "bounds" || validation.reason === "disabled") ? validation.message : void 0;
|
|
3089
3341
|
(0, import_react9.useEffect)(() => {
|
|
3090
3342
|
if (!visible) return void 0;
|
|
3091
3343
|
const close = (event) => {
|
|
@@ -3098,38 +3350,53 @@ function DateRangePicker({
|
|
|
3098
3350
|
function dismissPanel() {
|
|
3099
3351
|
setVisible(false);
|
|
3100
3352
|
}
|
|
3353
|
+
function focusEndpoint(endpoint, sourceValue = draftValue) {
|
|
3354
|
+
if (endpointDisabled[endpoint]) return;
|
|
3355
|
+
setActiveIndex(endpoint);
|
|
3356
|
+
setHoverDate("");
|
|
3357
|
+
const targetDay = dayFromValue(sourceValue[endpoint]);
|
|
3358
|
+
if (targetDay) {
|
|
3359
|
+
const parsed = parseDate(targetDay);
|
|
3360
|
+
if (parsed) setViewMonth(startOfMonth(parsed));
|
|
3361
|
+
}
|
|
3362
|
+
}
|
|
3101
3363
|
function changeOpen(next, endpoint) {
|
|
3102
3364
|
if (next && !visible) {
|
|
3103
3365
|
setDraftValue(currentValue);
|
|
3104
3366
|
setTimes([timePart(currentValue[0], defaultTime), timePart(currentValue[1], defaultEndTime)]);
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3367
|
+
const initialEndpoint = endpointDisabled[0] ? 1 : endpointDisabled[1] ? 0 : endpoint ?? (currentValue[0] && !currentValue[1] ? 1 : 0);
|
|
3368
|
+
setActiveIndex(initialEndpoint);
|
|
3369
|
+
setDateTimeView("date");
|
|
3370
|
+
setPanelMode("date");
|
|
3371
|
+
setHoverDate("");
|
|
3372
|
+
const focusDay = dayFromValue(currentValue[initialEndpoint] || currentValue[0] || currentValue[1]);
|
|
3373
|
+
setViewMonth(startOfMonth(parseDate(focusDay) ?? /* @__PURE__ */ new Date()));
|
|
3374
|
+
} else if (next && endpoint !== void 0 && !endpointDisabled[endpoint]) {
|
|
3375
|
+
focusEndpoint(endpoint);
|
|
3110
3376
|
}
|
|
3111
|
-
if (next && endpoint !== void 0 && !endpointDisabled[endpoint]) setActiveIndex(endpoint);
|
|
3112
3377
|
setVisible(next);
|
|
3113
3378
|
}
|
|
3114
|
-
function isDisabled(day, index = activeIndex
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
if (otherEndpoint) {
|
|
3125
|
-
if (index === 0 && day > otherEndpoint || index === 1 && day < otherEndpoint) return true;
|
|
3126
|
-
if (maxRangeDays && Math.abs(daysBetween(otherEndpoint, day)) >= maxRangeDays) return true;
|
|
3127
|
-
}
|
|
3128
|
-
} else if (from && maxRangeDays && Math.abs(daysBetween(from, day)) >= maxRangeDays) return true;
|
|
3129
|
-
return disabledDate?.(day, { from, type: "date" }) ?? false;
|
|
3379
|
+
function isDisabled(day, index = activeIndex) {
|
|
3380
|
+
return isRangeDayDisabled(day, {
|
|
3381
|
+
activeIndex: index,
|
|
3382
|
+
rangeDates,
|
|
3383
|
+
endpointDisabled,
|
|
3384
|
+
minDate: minBound,
|
|
3385
|
+
maxDate: maxBound,
|
|
3386
|
+
maxRangeDays,
|
|
3387
|
+
disabledDate
|
|
3388
|
+
});
|
|
3130
3389
|
}
|
|
3131
|
-
function
|
|
3132
|
-
return
|
|
3390
|
+
function isValidRange(next) {
|
|
3391
|
+
return validateDateRange(next, {
|
|
3392
|
+
currentValue,
|
|
3393
|
+
allowEmpty,
|
|
3394
|
+
endpointDisabled,
|
|
3395
|
+
minDate: minBound,
|
|
3396
|
+
maxDate: maxBound,
|
|
3397
|
+
maxRangeDays,
|
|
3398
|
+
disabledDate
|
|
3399
|
+
}).valid;
|
|
3133
3400
|
}
|
|
3134
3401
|
function updateDraft(next) {
|
|
3135
3402
|
setDraftValue(next);
|
|
@@ -3139,44 +3406,26 @@ function DateRangePicker({
|
|
|
3139
3406
|
}
|
|
3140
3407
|
}
|
|
3141
3408
|
function selectDate(day) {
|
|
3142
|
-
if (isDisabled(day)) return;
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
setHoverDate("");
|
|
3158
|
-
return;
|
|
3159
|
-
}
|
|
3160
|
-
const startDay = rangeDates[0];
|
|
3161
|
-
const ordered = day < startDay ? [buildRangeValue(day, 0), buildRangeValue(startDay, 1)] : [draftValue[0], buildRangeValue(day, 1)];
|
|
3162
|
-
updateDraft(ordered);
|
|
3163
|
-
setActiveIndex(0);
|
|
3409
|
+
if (isDisabled(day, activeIndex)) return;
|
|
3410
|
+
const picked = pickRangeDate({
|
|
3411
|
+
day,
|
|
3412
|
+
activeIndex,
|
|
3413
|
+
draftValue,
|
|
3414
|
+
times,
|
|
3415
|
+
defaultTimes: [defaultTime, defaultEndTime],
|
|
3416
|
+
showTime: Boolean(showTime),
|
|
3417
|
+
showSecond,
|
|
3418
|
+
endpointDisabled,
|
|
3419
|
+
maxRangeDays
|
|
3420
|
+
});
|
|
3421
|
+
setTimes(picked.nextTimes);
|
|
3422
|
+
updateDraft(picked.nextDraft);
|
|
3423
|
+
setActiveIndex(picked.nextActiveIndex);
|
|
3164
3424
|
setHoverDate("");
|
|
3165
|
-
if (!resolvedNeedConfirm) {
|
|
3425
|
+
if (picked.completedPair && !showTime && !resolvedNeedConfirm && isValidRange(picked.nextDraft)) {
|
|
3166
3426
|
changeOpen(false);
|
|
3167
3427
|
}
|
|
3168
3428
|
}
|
|
3169
|
-
function selectDateTime(day, index, time = index === 1 ? "23:59:59" : times[index]) {
|
|
3170
|
-
if (isDisabled(day, index, true)) return;
|
|
3171
|
-
const nextTimes = [...times];
|
|
3172
|
-
nextTimes[index] = time;
|
|
3173
|
-
setTimes(nextTimes);
|
|
3174
|
-
const nextValue = [...draftValue];
|
|
3175
|
-
nextValue[index] = withTime(day, time, showSecond);
|
|
3176
|
-
updateDraft(nextValue);
|
|
3177
|
-
setHoverDate("");
|
|
3178
|
-
setActiveIndex(index);
|
|
3179
|
-
}
|
|
3180
3429
|
function changeTime(index, nextTime) {
|
|
3181
3430
|
if (endpointDisabled[index]) return;
|
|
3182
3431
|
const nextTimes = [...times];
|
|
@@ -3189,28 +3438,6 @@ function DateRangePicker({
|
|
|
3189
3438
|
updateDraft(nextValue);
|
|
3190
3439
|
}
|
|
3191
3440
|
}
|
|
3192
|
-
function isValidRange(next) {
|
|
3193
|
-
if (!next.some(Boolean)) return false;
|
|
3194
|
-
for (const index of [0, 1]) {
|
|
3195
|
-
if (!next[index]) {
|
|
3196
|
-
if (!allowEmpty[index]) return false;
|
|
3197
|
-
else continue;
|
|
3198
|
-
}
|
|
3199
|
-
if (endpointDisabled[index]) {
|
|
3200
|
-
if (next[index] !== currentValue[index]) return false;
|
|
3201
|
-
else continue;
|
|
3202
|
-
}
|
|
3203
|
-
const day = dayFromValue(next[index]);
|
|
3204
|
-
if (!day) return false;
|
|
3205
|
-
if (minDate && day < minDate.slice(0, 10) || maxDate && day > maxDate.slice(0, 10)) return false;
|
|
3206
|
-
if (disabledDate?.(day, { from: index === 1 ? dayFromValue(next[0]) || void 0 : void 0, type: "date" })) return false;
|
|
3207
|
-
}
|
|
3208
|
-
if (next[0] && next[1]) {
|
|
3209
|
-
if (next[0] > next[1]) return false;
|
|
3210
|
-
if (maxRangeDays && Math.abs(daysBetween(dayFromValue(next[0]), dayFromValue(next[1]))) >= maxRangeDays) return false;
|
|
3211
|
-
}
|
|
3212
|
-
return true;
|
|
3213
|
-
}
|
|
3214
3441
|
function confirm() {
|
|
3215
3442
|
if (!isValidRange(draftValue)) return;
|
|
3216
3443
|
setCurrentValue(draftValue);
|
|
@@ -3225,9 +3452,9 @@ function DateRangePicker({
|
|
|
3225
3452
|
if (!isValidRange(next)) return;
|
|
3226
3453
|
updateDraft(next);
|
|
3227
3454
|
setTimes([timePart(next[0], defaultTime), timePart(next[1], defaultEndTime)]);
|
|
3228
|
-
const
|
|
3229
|
-
setViewMonth(
|
|
3230
|
-
|
|
3455
|
+
const focusDay = dayFromValue(next[0] || next[1]);
|
|
3456
|
+
setViewMonth(startOfMonth(parseDate(focusDay) ?? /* @__PURE__ */ new Date()));
|
|
3457
|
+
setHoverDate("");
|
|
3231
3458
|
if (!resolvedNeedConfirm) {
|
|
3232
3459
|
changeOpen(false);
|
|
3233
3460
|
}
|
|
@@ -3237,77 +3464,114 @@ function DateRangePicker({
|
|
|
3237
3464
|
const empty = [endpointDisabled[0] ? currentValue[0] : "", endpointDisabled[1] ? currentValue[1] : ""];
|
|
3238
3465
|
updateDraft(empty);
|
|
3239
3466
|
setCurrentValue(empty);
|
|
3240
|
-
setActiveIndex(0);
|
|
3467
|
+
setActiveIndex(endpointDisabled[0] ? 1 : 0);
|
|
3468
|
+
setHoverDate("");
|
|
3241
3469
|
}
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3470
|
+
const activeLabel = activeIndex === 0 ? "\u5F00\u59CB" : "\u7ED3\u675F";
|
|
3471
|
+
const showPreview = !endpointDisabled[0] && !endpointDisabled[1] && (activeIndex === 1 && Boolean(rangeDates[0]) && !rangeDates[1] || activeIndex === 0 && !rangeDates[0] && Boolean(rangeDates[1]));
|
|
3472
|
+
function renderSingleMonthCalendar() {
|
|
3473
|
+
if (panelMode === "year") {
|
|
3474
|
+
const startYear = Math.floor(viewMonth.getFullYear() / 10) * 10;
|
|
3475
|
+
const currentYear = (/* @__PURE__ */ new Date()).getFullYear();
|
|
3476
|
+
const activeYear = viewMonth.getFullYear();
|
|
3477
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
|
|
3478
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "sia-date-panel__header", children: [
|
|
3479
|
+
/* @__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 }) }) }),
|
|
3480
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("strong", { children: [
|
|
3481
|
+
startYear,
|
|
3482
|
+
"\u5E74 \u2014 ",
|
|
3483
|
+
startYear + 9,
|
|
3484
|
+
"\u5E74"
|
|
3485
|
+
] }),
|
|
3486
|
+
/* @__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 }) }) })
|
|
3487
|
+
] }),
|
|
3488
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "sia-date-panel__years", role: "grid", "aria-label": "\u9009\u62E9\u5E74\u4EFD", children: Array.from({ length: 10 }, (_, index) => {
|
|
3489
|
+
const year = startYear + index;
|
|
3490
|
+
const selected = year === activeYear;
|
|
3491
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: `sia-date-panel__cell${selected ? " is-selected" : ""}${year === currentYear ? " is-today" : ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3492
|
+
"button",
|
|
3493
|
+
{
|
|
3494
|
+
type: "button",
|
|
3495
|
+
"aria-label": `${year}\u5E74`,
|
|
3496
|
+
"aria-pressed": selected,
|
|
3497
|
+
onClick: () => {
|
|
3498
|
+
setViewMonth(new Date(year, viewMonth.getMonth(), 1));
|
|
3499
|
+
setPanelMode("date");
|
|
3500
|
+
},
|
|
3501
|
+
children: year
|
|
3502
|
+
}
|
|
3503
|
+
) }, year);
|
|
3504
|
+
}) })
|
|
3505
|
+
] });
|
|
3506
|
+
}
|
|
3507
|
+
if (panelMode === "month") {
|
|
3508
|
+
const now = /* @__PURE__ */ new Date();
|
|
3509
|
+
const viewYear = viewMonth.getFullYear();
|
|
3510
|
+
const activeMonth = viewMonth.getMonth();
|
|
3511
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
|
|
3512
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "sia-date-panel__header", children: [
|
|
3513
|
+
/* @__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\u4E00\u5E74", onClick: () => setViewMonth(addMonths(viewMonth, -12)), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { name: "chevron-left", size: 15 }) }) }),
|
|
3514
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", className: "sia-date-panel__title", "aria-label": "\u9009\u62E9\u5E74\u4EFD", onClick: () => setPanelMode("year"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { children: [
|
|
3515
|
+
viewYear,
|
|
3516
|
+
"\u5E74"
|
|
3517
|
+
] }) }),
|
|
3518
|
+
/* @__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\u4E00\u5E74", onClick: () => setViewMonth(addMonths(viewMonth, 12)), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { name: "chevron-right", size: 15 }) }) })
|
|
3519
|
+
] }),
|
|
3520
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "sia-date-panel__years", role: "grid", "aria-label": "\u9009\u62E9\u6708\u4EFD", children: Array.from({ length: 12 }, (_, monthIndex) => {
|
|
3521
|
+
const selected = monthIndex === activeMonth;
|
|
3522
|
+
const isCurrentMonth = viewYear === now.getFullYear() && monthIndex === now.getMonth();
|
|
3523
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: `sia-date-panel__cell${selected ? " is-selected" : ""}${isCurrentMonth ? " is-today" : ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
3524
|
+
"button",
|
|
3525
|
+
{
|
|
3526
|
+
type: "button",
|
|
3527
|
+
"aria-label": `${viewYear}\u5E74${monthIndex + 1}\u6708`,
|
|
3528
|
+
"aria-pressed": selected,
|
|
3529
|
+
onClick: () => {
|
|
3530
|
+
setViewMonth(new Date(viewYear, monthIndex, 1));
|
|
3531
|
+
setPanelMode("date");
|
|
3532
|
+
},
|
|
3533
|
+
children: [
|
|
3534
|
+
monthIndex + 1,
|
|
3535
|
+
"\u6708"
|
|
3536
|
+
]
|
|
3537
|
+
}
|
|
3538
|
+
) }, monthIndex);
|
|
3539
|
+
}) })
|
|
3540
|
+
] });
|
|
3541
|
+
}
|
|
3246
3542
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
|
|
3247
3543
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3248
3544
|
CalendarHeader,
|
|
3249
3545
|
{
|
|
3250
|
-
month,
|
|
3251
|
-
label: endpointLabel,
|
|
3546
|
+
month: viewMonth,
|
|
3252
3547
|
range: true,
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3548
|
+
onYearClick: () => setPanelMode("year"),
|
|
3549
|
+
onMonthClick: () => setPanelMode("month"),
|
|
3550
|
+
onPreviousYear: () => setViewMonth(addMonths(viewMonth, -12)),
|
|
3551
|
+
onPreviousMonth: () => setViewMonth(addMonths(viewMonth, -1)),
|
|
3552
|
+
onNextMonth: () => setViewMonth(addMonths(viewMonth, 1)),
|
|
3553
|
+
onNextYear: () => setViewMonth(addMonths(viewMonth, 12))
|
|
3257
3554
|
}
|
|
3258
3555
|
),
|
|
3259
3556
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3260
3557
|
CalendarMonth,
|
|
3261
3558
|
{
|
|
3262
|
-
month,
|
|
3559
|
+
month: viewMonth,
|
|
3263
3560
|
range: rangeDates,
|
|
3264
|
-
|
|
3265
|
-
|
|
3561
|
+
previewEnd: showPreview ? hoverDate : "",
|
|
3562
|
+
disabledDate: (day) => isDisabled(day, activeIndex),
|
|
3563
|
+
onSelect: selectDate,
|
|
3564
|
+
onHover: showPreview ? setHoverDate : void 0,
|
|
3565
|
+
onSwipeMonth: (direction) => setViewMonth((current) => addMonths(current, direction))
|
|
3266
3566
|
}
|
|
3267
3567
|
)
|
|
3268
3568
|
] });
|
|
3269
3569
|
}
|
|
3270
|
-
|
|
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);
|
|
3306
|
-
}
|
|
3570
|
+
const resolvedRangePresets = presets !== void 0 ? presets : DEFAULT_RANGE_PRESETS;
|
|
3307
3571
|
const displayValue = visible && allowEmpty.some(Boolean) ? draftValue : currentValue;
|
|
3308
3572
|
const startFloating = useFloatingPlaceholder({ mode: placeholderMode, placeholder: placeholder[0], filled: Boolean(displayValue[0]), active: visible });
|
|
3309
3573
|
const endFloating = useFloatingPlaceholder({ mode: placeholderMode, placeholder: placeholder[1], filled: Boolean(displayValue[1]), active: visible });
|
|
3310
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { ref:
|
|
3574
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { ref: setRootRef, className: `sia-picker sia-picker-range-control sia-picker--${size} sia-picker--${status}${visible ? " is-open" : ""}${disabled ? " is-disabled" : ""} ${className}`.trim(), children: [
|
|
3311
3575
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
3312
3576
|
"button",
|
|
3313
3577
|
{
|
|
@@ -3325,7 +3589,7 @@ function DateRangePicker({
|
|
|
3325
3589
|
onClick: (event) => {
|
|
3326
3590
|
const field = event.target.closest("[data-range-endpoint]");
|
|
3327
3591
|
const endpoint = field?.dataset.rangeEndpoint;
|
|
3328
|
-
if (
|
|
3592
|
+
if (endpoint === "0" || endpoint === "1") {
|
|
3329
3593
|
const index = Number(endpoint);
|
|
3330
3594
|
if (!endpointDisabled[index]) changeOpen(true, index);
|
|
3331
3595
|
} else if (visible) dismissPanel();
|
|
@@ -3353,7 +3617,7 @@ function DateRangePicker({
|
|
|
3353
3617
|
ref: popupRef,
|
|
3354
3618
|
anchorRef: rootRef,
|
|
3355
3619
|
open: visible,
|
|
3356
|
-
className: `sia-date-panel${showTime ? " sia-date-panel--datetime
|
|
3620
|
+
className: `sia-date-panel sia-date-panel--single-range${showTime ? " sia-date-panel--datetime" : ""}${resolvedRangePresets.length ? " sia-date-panel--with-presets" : ""}`,
|
|
3357
3621
|
role: "dialog",
|
|
3358
3622
|
"aria-label": "\u65E5\u671F\u8303\u56F4\u9009\u62E9\u9762\u677F",
|
|
3359
3623
|
onKeyDown: (event) => {
|
|
@@ -3364,59 +3628,93 @@ function DateRangePicker({
|
|
|
3364
3628
|
},
|
|
3365
3629
|
children: [
|
|
3366
3630
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "sia-date-panel__body", children: [
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("section", { className: "sia-date-panel__calendar", children: [
|
|
3373
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3374
|
-
CalendarHeader,
|
|
3631
|
+
resolvedRangePresets.length ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("aside", { className: "sia-date-panel__presets", "aria-label": "\u5FEB\u6377\u65E5\u671F\u8303\u56F4", children: resolvedRangePresets.map((preset2, index) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", onClick: () => applyPreset(preset2), children: preset2.label }, index)) }) : null,
|
|
3632
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("section", { className: "sia-date-panel__single-range-main", "aria-label": "\u5355\u6708\u65E5\u671F\u8303\u56F4\u9762\u677F", children: [
|
|
3633
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "sia-date-panel__range-tabs", role: "tablist", "aria-label": "\u5207\u6362\u8D77\u6B62\u65E5\u671F", children: [
|
|
3634
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
3635
|
+
"button",
|
|
3375
3636
|
{
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3637
|
+
type: "button",
|
|
3638
|
+
role: "tab",
|
|
3639
|
+
"aria-selected": activeIndex === 0,
|
|
3640
|
+
disabled: endpointDisabled[0],
|
|
3641
|
+
title: rangeDates[0] ? `\u5F00\u59CB\uFF1A${rangeDates[0]}` : "\u9009\u62E9\u5F00\u59CB\u65E5\u671F",
|
|
3642
|
+
className: `sia-date-panel__range-tab${activeIndex === 0 ? " is-active" : ""}`,
|
|
3643
|
+
onClick: () => {
|
|
3644
|
+
setPanelMode("date");
|
|
3645
|
+
focusEndpoint(0);
|
|
3646
|
+
},
|
|
3647
|
+
children: [
|
|
3648
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "sia-date-panel__range-tab-label", children: "\u5F00\u59CB" }),
|
|
3649
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: `sia-date-panel__range-tab-value${rangeDates[0] ? "" : " is-placeholder"}`, children: rangeDates[0] || "\u672A\u9009" })
|
|
3650
|
+
]
|
|
3380
3651
|
}
|
|
3381
3652
|
),
|
|
3382
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3653
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "sia-date-panel__range-tabs-sep", "aria-hidden": "true", children: separator }),
|
|
3654
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
3655
|
+
"button",
|
|
3656
|
+
{
|
|
3657
|
+
type: "button",
|
|
3658
|
+
role: "tab",
|
|
3659
|
+
"aria-selected": activeIndex === 1,
|
|
3660
|
+
disabled: endpointDisabled[1],
|
|
3661
|
+
title: rangeDates[1] ? `\u7ED3\u675F\uFF1A${rangeDates[1]}` : "\u9009\u62E9\u7ED3\u675F\u65E5\u671F",
|
|
3662
|
+
className: `sia-date-panel__range-tab${activeIndex === 1 ? " is-active" : ""}`,
|
|
3663
|
+
onClick: () => {
|
|
3664
|
+
setPanelMode("date");
|
|
3665
|
+
focusEndpoint(1);
|
|
3666
|
+
},
|
|
3667
|
+
children: [
|
|
3668
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "sia-date-panel__range-tab-label", children: "\u7ED3\u675F" }),
|
|
3669
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: `sia-date-panel__range-tab-value${rangeDates[1] ? "" : " is-placeholder"}`, children: rangeDates[1] || "\u672A\u9009" })
|
|
3670
|
+
]
|
|
3671
|
+
}
|
|
3672
|
+
)
|
|
3383
3673
|
] }),
|
|
3384
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("
|
|
3385
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3386
|
-
|
|
3674
|
+
showTime ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "sia-date-panel__views", children: [
|
|
3675
|
+
/* @__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", ...dateTimeView !== "date" ? { inert: "" } : {}, "aria-label": `${activeLabel}\u65E5\u671F`, children: renderSingleMonthCalendar() }),
|
|
3676
|
+
/* @__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", ...dateTimeView !== "time" ? { inert: "" } : {}, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3677
|
+
TimePanel,
|
|
3387
3678
|
{
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3679
|
+
value: times[activeIndex],
|
|
3680
|
+
showSecond,
|
|
3681
|
+
title: `\u9009\u62E9${activeLabel}\u65F6\u95F4`,
|
|
3682
|
+
unitLabels: true,
|
|
3683
|
+
ariaLabel: `\u9009\u62E9${activeLabel}\u65F6\u95F4`,
|
|
3684
|
+
disabledTime: (candidate) => isRangeTimeDisabled(candidate, activeIndex, rangeDates, times, endpointDisabled, showSecond),
|
|
3685
|
+
onChange: (nextTime) => changeTime(activeIndex, nextTime)
|
|
3392
3686
|
}
|
|
3393
|
-
)
|
|
3394
|
-
|
|
3395
|
-
] })
|
|
3687
|
+
) })
|
|
3688
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("section", { className: "sia-date-panel__calendar", children: renderSingleMonthCalendar() })
|
|
3396
3689
|
] })
|
|
3397
3690
|
] }),
|
|
3398
|
-
showTime ?
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3691
|
+
showTime ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
|
|
3692
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3693
|
+
DateTimePanelFooter,
|
|
3694
|
+
{
|
|
3695
|
+
date: rangeDates[activeIndex] || dateKey(/* @__PURE__ */ new Date()),
|
|
3696
|
+
time: showSecond ? times[activeIndex] : times[activeIndex].slice(0, 5),
|
|
3697
|
+
view: dateTimeView,
|
|
3698
|
+
disabled: endpointDisabled[activeIndex],
|
|
3699
|
+
extra: renderExtraFooter?.(),
|
|
3700
|
+
onSwitchDate: () => setDateTimeView("date"),
|
|
3701
|
+
onSwitchTime: () => setDateTimeView("time")
|
|
3702
|
+
}
|
|
3703
|
+
),
|
|
3704
|
+
invalidRangeMessage || maxRangeDays ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "sia-date-panel__range-status", role: "status", children: invalidRangeMessage ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("small", { className: "sia-date-panel__range-error", children: invalidRangeMessage }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("small", { children: [
|
|
3705
|
+
"\u6700\u591A\u9009\u62E9 ",
|
|
3706
|
+
maxRangeDays,
|
|
3707
|
+
" \u5929"
|
|
3708
|
+
] }) }) : null
|
|
3709
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3412
3710
|
DatePanelFooter,
|
|
3413
3711
|
{
|
|
3414
|
-
showToday: showToday && !
|
|
3712
|
+
showToday: showToday && !resolvedRangePresets.length,
|
|
3415
3713
|
needConfirm: resolvedNeedConfirm || allowEmpty.some(Boolean),
|
|
3416
3714
|
disabledConfirm: !isValidRange(draftValue),
|
|
3417
3715
|
extra: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
|
|
3418
3716
|
renderExtraFooter?.(),
|
|
3419
|
-
|
|
3717
|
+
invalidRangeMessage ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("small", { className: "sia-date-panel__range-error", children: invalidRangeMessage }) : maxRangeDays ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("small", { children: [
|
|
3420
3718
|
"\u6700\u591A\u9009\u62E9 ",
|
|
3421
3719
|
maxRangeDays,
|
|
3422
3720
|
" \u5929"
|
|
@@ -3425,7 +3723,7 @@ function DateRangePicker({
|
|
|
3425
3723
|
onToday: () => {
|
|
3426
3724
|
const now = /* @__PURE__ */ new Date();
|
|
3427
3725
|
const day = dateKey(now);
|
|
3428
|
-
if (isDisabled(day, activeIndex
|
|
3726
|
+
if (isDisabled(day, activeIndex)) return;
|
|
3429
3727
|
setViewMonth(startOfMonth(now));
|
|
3430
3728
|
selectDate(day);
|
|
3431
3729
|
},
|
|
@@ -3436,10 +3734,11 @@ function DateRangePicker({
|
|
|
3436
3734
|
}
|
|
3437
3735
|
)
|
|
3438
3736
|
] });
|
|
3439
|
-
}
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3737
|
+
});
|
|
3738
|
+
var DatePicker2 = Object.assign(DatePickerRoot, {
|
|
3739
|
+
/** 日期区间选择器;采用单月面板与顶部起止端点切换栏(显示完整年月日),支持点击日历头部年份/月份分别进入年份和月份选择面板;修改起点且不晚于已有终点时保留原终点,晚于已有终点时清空终点并切到结束端(悬停实时预览范围,点早于起点自动交换);带时间时底部页脚在单月日历与当前端点时间视图间切换,同日起止自动校验时间先后并禁用非法时刻。 */
|
|
3740
|
+
RangePicker: DateRangePicker
|
|
3741
|
+
});
|
|
3443
3742
|
|
|
3444
3743
|
// src/components/Select.tsx
|
|
3445
3744
|
var import_react21 = require("react");
|
|
@@ -3688,19 +3987,27 @@ function useOverlayLifecycle(open, panelRef, onRequestClose, keyboard = true, au
|
|
|
3688
3987
|
closeRef.current();
|
|
3689
3988
|
return;
|
|
3690
3989
|
}
|
|
3691
|
-
|
|
3692
|
-
|
|
3990
|
+
const panel = panelRef.current;
|
|
3991
|
+
if (event.key !== "Tab" || !panel) return;
|
|
3992
|
+
const focusable = focusableElements(panel);
|
|
3693
3993
|
if (focusable.length === 0) {
|
|
3694
3994
|
event.preventDefault();
|
|
3695
|
-
|
|
3995
|
+
panel.focus();
|
|
3696
3996
|
return;
|
|
3697
3997
|
}
|
|
3698
3998
|
const first = focusable[0];
|
|
3699
3999
|
const last = focusable.at(-1);
|
|
3700
|
-
|
|
4000
|
+
const active = document.activeElement;
|
|
4001
|
+
const insidePanel = active instanceof Node && panel.contains(active);
|
|
4002
|
+
if (!insidePanel || active === panel) {
|
|
4003
|
+
event.preventDefault();
|
|
4004
|
+
(event.shiftKey ? last : first).focus();
|
|
4005
|
+
return;
|
|
4006
|
+
}
|
|
4007
|
+
if (event.shiftKey && active === first) {
|
|
3701
4008
|
event.preventDefault();
|
|
3702
4009
|
last.focus();
|
|
3703
|
-
} else if (!event.shiftKey &&
|
|
4010
|
+
} else if (!event.shiftKey && active === last) {
|
|
3704
4011
|
event.preventDefault();
|
|
3705
4012
|
first.focus();
|
|
3706
4013
|
}
|
|
@@ -3715,7 +4022,7 @@ function useOverlayLifecycle(open, panelRef, onRequestClose, keyboard = true, au
|
|
|
3715
4022
|
unlockBody();
|
|
3716
4023
|
previouslyFocused?.focus({ preventScroll: true });
|
|
3717
4024
|
};
|
|
3718
|
-
}, [keyboard, open, panelRef
|
|
4025
|
+
}, [keyboard, open, panelRef]);
|
|
3719
4026
|
(0, import_react12.useEffect)(() => {
|
|
3720
4027
|
if (!open) return;
|
|
3721
4028
|
const timer = window.setTimeout(() => {
|
|
@@ -5289,6 +5596,27 @@ var Select = (0, import_react21.forwardRef)(function Select2({
|
|
|
5289
5596
|
open,
|
|
5290
5597
|
title: modalConfig?.title ?? placeholder,
|
|
5291
5598
|
width: modalConfig?.width ?? 900,
|
|
5599
|
+
titleExtra: /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [
|
|
5600
|
+
modalConfig?.titleExtra != null && modalConfig.titleExtra !== false ? modalConfig.titleExtra : null,
|
|
5601
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
5602
|
+
Input,
|
|
5603
|
+
{
|
|
5604
|
+
className: "sia-select-modal__search",
|
|
5605
|
+
"aria-label": searchPlaceholder,
|
|
5606
|
+
placeholder: searchPlaceholder,
|
|
5607
|
+
placeholderMode: "default",
|
|
5608
|
+
prefix: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Icon, { name: "search", size: 14 }),
|
|
5609
|
+
value: query,
|
|
5610
|
+
allowClear: true,
|
|
5611
|
+
disabled: modalSubmitting || disabled,
|
|
5612
|
+
onChange: (event) => {
|
|
5613
|
+
setQuery(event.target.value);
|
|
5614
|
+
onSearch?.(event.target.value);
|
|
5615
|
+
}
|
|
5616
|
+
},
|
|
5617
|
+
"sia-select-modal-search"
|
|
5618
|
+
)
|
|
5619
|
+
] }),
|
|
5292
5620
|
confirmLoading: modalSubmitting,
|
|
5293
5621
|
onOpenChange: (next) => {
|
|
5294
5622
|
if (!next) closeDropdown();
|
|
@@ -5303,43 +5631,27 @@ var Select = (0, import_react21.forwardRef)(function Select2({
|
|
|
5303
5631
|
] }),
|
|
5304
5632
|
children: open ? /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [
|
|
5305
5633
|
modalConfig?.headerExtra != null && modalConfig.headerExtra !== false ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "sia-select-modal__header-extra", children: modalConfig.headerExtra }) : null,
|
|
5306
|
-
/* @__PURE__ */ (0, import_jsx_runtime19.
|
|
5307
|
-
/* @__PURE__ */ (0, import_jsx_runtime19.
|
|
5308
|
-
|
|
5309
|
-
|
|
5310
|
-
|
|
5311
|
-
|
|
5312
|
-
|
|
5313
|
-
|
|
5314
|
-
] }),
|
|
5315
|
-
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
5316
|
-
Input,
|
|
5317
|
-
{
|
|
5318
|
-
"aria-label": searchPlaceholder,
|
|
5319
|
-
placeholder: searchPlaceholder,
|
|
5320
|
-
prefix: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Icon, { name: "search", size: 14 }),
|
|
5321
|
-
value: query,
|
|
5322
|
-
allowClear: true,
|
|
5323
|
-
onChange: (event) => {
|
|
5324
|
-
setQuery(event.target.value);
|
|
5325
|
-
onSearch?.(event.target.value);
|
|
5326
|
-
}
|
|
5327
|
-
}
|
|
5328
|
-
)
|
|
5329
|
-
] }),
|
|
5634
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "sia-select-modal__heading", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { role: "tablist", "aria-label": "\u9009\u9879\u8303\u56F4", children: [
|
|
5635
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Button, { role: "tab", "aria-selected": !selectedOnly, variant: "link", onClick: () => setSelectedOnly(false), children: "\u5168\u90E8" }),
|
|
5636
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(Button, { role: "tab", "aria-selected": selectedOnly, variant: "link", onClick: () => setSelectedOnly(true), children: [
|
|
5637
|
+
"\u5DF2\u9009\u9879(",
|
|
5638
|
+
modalValues.length,
|
|
5639
|
+
")"
|
|
5640
|
+
] })
|
|
5641
|
+
] }) }),
|
|
5330
5642
|
multiple && showSelectAll ? /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "sia-select-modal__actions", children: [
|
|
5331
5643
|
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
5332
5644
|
Checkbox2,
|
|
5333
5645
|
{
|
|
5334
5646
|
checked: modalEnabled.length > 0 && modalEnabled.every((option) => modalValues.includes(option.value)),
|
|
5335
5647
|
indeterminate: modalEnabled.some((option) => modalValues.includes(option.value)) && !modalEnabled.every((option) => modalValues.includes(option.value)),
|
|
5336
|
-
disabled: !modalEnabled.length,
|
|
5648
|
+
disabled: modalSubmitting || disabled || loading || !modalEnabled.length,
|
|
5337
5649
|
onChange: (checked) => modalBatch(checked ? "all" : "remove"),
|
|
5338
5650
|
children: "\u5168\u9009"
|
|
5339
5651
|
}
|
|
5340
5652
|
),
|
|
5341
|
-
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Button, { variant: "link", size: "small", disabled: !modalEnabled.length, onClick: () => modalBatch("invert"), children: "\u53CD\u9009" }),
|
|
5342
|
-
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Button, { variant: "link", size: "small", danger: true, disabled: !modalValues.length, onClick: () => setModalValues([]), children: "\u6E05\u7A7A" })
|
|
5653
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Button, { variant: "link", size: "small", disabled: modalSubmitting || disabled || loading || !modalEnabled.length, onClick: () => modalBatch("invert"), children: "\u53CD\u9009" }),
|
|
5654
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Button, { variant: "link", size: "small", danger: true, disabled: modalSubmitting || disabled || loading || !modalValues.length, onClick: () => setModalValues([]), children: "\u6E05\u7A7A" })
|
|
5343
5655
|
] }) : null,
|
|
5344
5656
|
allowInput && canSubmitInput ? /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(Button, { variant: "link", onClick: () => {
|
|
5345
5657
|
setModalValues(multiple ? [.../* @__PURE__ */ new Set([...modalValues, inputValue])] : [inputValue]);
|
|
@@ -5358,6 +5670,8 @@ var Select = (0, import_react21.forwardRef)(function Select2({
|
|
|
5358
5670
|
multiple,
|
|
5359
5671
|
groupCheckable: modalConfig?.groupCheckable,
|
|
5360
5672
|
allowDeselect: allowClear,
|
|
5673
|
+
disabled: modalSubmitting || disabled,
|
|
5674
|
+
loading,
|
|
5361
5675
|
selectedOnly,
|
|
5362
5676
|
showValue,
|
|
5363
5677
|
showSearch: false,
|
|
@@ -5417,7 +5731,7 @@ function SelectDateRange({
|
|
|
5417
5731
|
}
|
|
5418
5732
|
),
|
|
5419
5733
|
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
5420
|
-
|
|
5734
|
+
DatePicker2.RangePicker,
|
|
5421
5735
|
{
|
|
5422
5736
|
className: "sia-select-date-range__picker",
|
|
5423
5737
|
"aria-label": rangeAriaLabel,
|