@sia.soul/sia-react-ui 0.1.160 → 0.1.162
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 +9 -9
- package/dist/chart.js +5 -5
- package/dist/{chunk-H6UTSSZM.js → chunk-33WX54AU.js} +5 -5
- package/dist/{chunk-PU2V3VB5.js → chunk-4B7ATL6J.js} +1 -1
- package/dist/{chunk-XXFYFLZA.js → chunk-5WZR2RHA.js} +2 -2
- package/dist/{chunk-YO5OJQEH.js → chunk-CRA7VNOA.js} +1 -1
- package/dist/{chunk-ZIH5VLPT.js → chunk-KA3M4TE4.js} +2 -2
- package/dist/{chunk-6SSZVJO4.js → chunk-M4IASLGB.js} +3 -3
- package/dist/{chunk-REAWVQH2.js → chunk-MXK6TKMO.js} +5 -5
- package/dist/{chunk-KDIJYXKW.js → chunk-Q3LEK2TL.js} +599 -270
- package/dist/{chunk-NRLIOMXY.js → chunk-UL54A2YN.js} +2 -2
- package/dist/{chunk-P5ZCOIKQ.js → chunk-UPXL2QLJ.js} +6 -6
- package/dist/{chunk-SRWUDTCS.js → chunk-WMZYYPIW.js} +9 -9
- package/dist/{chunk-EMBCJFJM.js → chunk-ZNPNZD6O.js} +4 -4
- 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 +9 -9
- package/dist/core.css +164 -22
- package/dist/core.d.cts +2 -2
- package/dist/core.d.ts +2 -2
- package/dist/core.js +8 -8
- package/dist/game.cjs +9 -9
- package/dist/game.js +3 -3
- package/dist/index.cjs +646 -316
- package/dist/index.css +164 -22
- 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 +9 -9
- package/dist/markdown-editor.js +3 -3
- package/dist/rich-text-editor.cjs +9 -9
- package/dist/rich-text-editor.js +7 -7
- package/dist/{select-date-range-DYrA87Tl.d.ts → select-date-range-CIXBuoef.d.ts} +8 -9
- package/dist/{select-date-range-CIwE5nFu.d.cts → select-date-range-Cbh37zmU.d.cts} +8 -9
- package/dist/select-date-range.cjs +598 -269
- 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
package/dist/index.cjs
CHANGED
|
@@ -724,8 +724,8 @@ var import_react3 = require("react");
|
|
|
724
724
|
// src/components/popupFluidMotion.ts
|
|
725
725
|
var popupEnterDuration = 260;
|
|
726
726
|
var popupExitDuration = 140;
|
|
727
|
-
var popupInitialScale = 0.
|
|
728
|
-
var popupTravelOffset =
|
|
727
|
+
var popupInitialScale = 0.93;
|
|
728
|
+
var popupTravelOffset = 4;
|
|
729
729
|
function popupFluidFrames(placement, open = true) {
|
|
730
730
|
const side = placement.split("-")[0];
|
|
731
731
|
const axis = side === "left" || side === "right" ? "X" : "Y";
|
|
@@ -734,8 +734,8 @@ function popupFluidFrames(placement, open = true) {
|
|
|
734
734
|
const visible = { opacity: 1, transform: "none" };
|
|
735
735
|
return open ? [
|
|
736
736
|
{ ...hidden, offset: 0 },
|
|
737
|
-
{ opacity: 1, transform: "scale(1.
|
|
738
|
-
{ opacity: 1, transform: "scale(.
|
|
737
|
+
{ opacity: 1, transform: "scale(1.05, 1.04)", offset: 0.68 },
|
|
738
|
+
{ opacity: 1, transform: "scale(.977, .985)", offset: 0.86 },
|
|
739
739
|
{ ...visible, offset: 1 }
|
|
740
740
|
] : [{ ...visible, offset: 0 }, { ...hidden, offset: 1 }];
|
|
741
741
|
}
|
|
@@ -755,16 +755,16 @@ function motionFrames(kind, placement) {
|
|
|
755
755
|
const outside = `translate${axis}(${sign * 100}%)`;
|
|
756
756
|
return [
|
|
757
757
|
{ transform: outside, offset: 0 },
|
|
758
|
-
{ transform: `translate${axis}(0) scale${axis}(1.
|
|
759
|
-
{ transform: `translate${axis}(0) scale${axis}(.
|
|
758
|
+
{ transform: `translate${axis}(0) scale${axis}(1.03)`, offset: 0.68 },
|
|
759
|
+
{ transform: `translate${axis}(0) scale${axis}(.988)`, offset: 0.86 },
|
|
760
760
|
{ transform: "none", offset: 1 }
|
|
761
761
|
];
|
|
762
762
|
}
|
|
763
763
|
const modal = kind === "modal";
|
|
764
764
|
return [
|
|
765
|
-
{ opacity: 0, transform: `translateY(${modal ?
|
|
766
|
-
{ opacity: 1, transform: modal ? "scale(1.
|
|
767
|
-
{ opacity: 1, transform: modal ? "scale(.
|
|
765
|
+
{ opacity: 0, transform: `translateY(${modal ? 14 : -4}px) scale(${modal ? 0.95 : 0.93})`, offset: 0 },
|
|
766
|
+
{ opacity: 1, transform: modal ? "scale(1.035, 1.02)" : "scale(1.05, 1.04)", offset: 0.68 },
|
|
767
|
+
{ opacity: 1, transform: modal ? "scale(.984, .992)" : "scale(.977, .985)", offset: 0.86 },
|
|
768
768
|
{ opacity: 1, transform: "none", offset: 1 }
|
|
769
769
|
];
|
|
770
770
|
}
|
|
@@ -9756,8 +9756,51 @@ function CalendarMonth({
|
|
|
9756
9756
|
previewEnd,
|
|
9757
9757
|
disabledDate,
|
|
9758
9758
|
onSelect,
|
|
9759
|
-
onHover
|
|
9759
|
+
onHover,
|
|
9760
|
+
onSwipeMonth
|
|
9760
9761
|
}) {
|
|
9762
|
+
const monthRef = (0, import_react45.useRef)(null);
|
|
9763
|
+
const swipe = (0, import_react45.useRef)({ startX: 0, startY: 0, pointerId: -1, dragging: false, lastTime: 0, lastX: 0, velocity: 0 });
|
|
9764
|
+
function onMonthPointerDown(event) {
|
|
9765
|
+
if (!onSwipeMonth || event.button !== 0) return;
|
|
9766
|
+
swipe.current = { startX: event.clientX, startY: event.clientY, pointerId: event.pointerId, dragging: false, lastTime: event.timeStamp, lastX: event.clientX, velocity: 0 };
|
|
9767
|
+
}
|
|
9768
|
+
function onMonthPointerMove(event) {
|
|
9769
|
+
const state = swipe.current;
|
|
9770
|
+
if (!onSwipeMonth || state.pointerId !== event.pointerId || !monthRef.current) return;
|
|
9771
|
+
const dx = event.clientX - state.startX;
|
|
9772
|
+
const dy = event.clientY - state.startY;
|
|
9773
|
+
if (!state.dragging && Math.abs(dx) > 6 && Math.abs(dx) > Math.abs(dy)) {
|
|
9774
|
+
state.dragging = true;
|
|
9775
|
+
try {
|
|
9776
|
+
monthRef.current?.setPointerCapture(event.pointerId);
|
|
9777
|
+
} catch {
|
|
9778
|
+
}
|
|
9779
|
+
}
|
|
9780
|
+
if (!state.dragging) return;
|
|
9781
|
+
monthRef.current.style.transition = "none";
|
|
9782
|
+
monthRef.current.style.transform = `translateX(${dx}px)`;
|
|
9783
|
+
const dt = event.timeStamp - state.lastTime;
|
|
9784
|
+
if (dt > 0) state.velocity = (event.clientX - state.lastX) / dt;
|
|
9785
|
+
state.lastTime = event.timeStamp;
|
|
9786
|
+
state.lastX = event.clientX;
|
|
9787
|
+
}
|
|
9788
|
+
function onMonthPointerUp(event) {
|
|
9789
|
+
const state = swipe.current;
|
|
9790
|
+
const node = monthRef.current;
|
|
9791
|
+
if (state.pointerId !== event.pointerId || !node) return;
|
|
9792
|
+
state.pointerId = -1;
|
|
9793
|
+
try {
|
|
9794
|
+
node.releasePointerCapture?.(event.pointerId);
|
|
9795
|
+
} catch {
|
|
9796
|
+
}
|
|
9797
|
+
if (!state.dragging) return;
|
|
9798
|
+
const dx = event.clientX - state.startX;
|
|
9799
|
+
const shouldSwitch = Math.abs(dx) >= 56 || Math.abs(state.velocity) > 0.5;
|
|
9800
|
+
if (shouldSwitch && onSwipeMonth) onSwipeMonth(dx < 0 ? 1 : -1);
|
|
9801
|
+
node.style.transition = "transform 220ms cubic-bezier(.2, .7, .2, 1)";
|
|
9802
|
+
node.style.transform = "translateX(0)";
|
|
9803
|
+
}
|
|
9761
9804
|
const first = startOfMonth(month);
|
|
9762
9805
|
const mondayIndex = (first.getDay() + 6) % 7;
|
|
9763
9806
|
const gridStart = addDays(first, -mondayIndex);
|
|
@@ -9766,43 +9809,61 @@ function CalendarMonth({
|
|
|
9766
9809
|
const end = range[1] || previewEnd || "";
|
|
9767
9810
|
const low = start && end ? start <= end ? start : end : "";
|
|
9768
9811
|
const high = start && end ? start <= end ? end : start : "";
|
|
9769
|
-
return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
|
|
9770
|
-
|
|
9771
|
-
|
|
9772
|
-
|
|
9773
|
-
|
|
9774
|
-
|
|
9775
|
-
|
|
9776
|
-
|
|
9777
|
-
|
|
9778
|
-
|
|
9779
|
-
|
|
9780
|
-
|
|
9781
|
-
|
|
9782
|
-
|
|
9783
|
-
|
|
9784
|
-
|
|
9785
|
-
|
|
9812
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
|
|
9813
|
+
"div",
|
|
9814
|
+
{
|
|
9815
|
+
className: "sia-date-panel__month",
|
|
9816
|
+
ref: monthRef,
|
|
9817
|
+
onPointerDown: onMonthPointerDown,
|
|
9818
|
+
onPointerMove: onMonthPointerMove,
|
|
9819
|
+
onPointerUp: onMonthPointerUp,
|
|
9820
|
+
onPointerCancel: onMonthPointerUp,
|
|
9821
|
+
onClickCapture: (event) => {
|
|
9822
|
+
if (!swipe.current.dragging) return;
|
|
9823
|
+
event.preventDefault();
|
|
9824
|
+
event.stopPropagation();
|
|
9825
|
+
swipe.current.dragging = false;
|
|
9826
|
+
},
|
|
9827
|
+
children: [
|
|
9828
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: "sia-date-panel__weekdays", "aria-hidden": "true", children: WEEKDAYS.map((day) => /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("span", { children: day }, day)) }),
|
|
9829
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: "sia-date-panel__days", children: Array.from({ length: 42 }, (_, index) => {
|
|
9830
|
+
const date = addDays(gridStart, index);
|
|
9831
|
+
const key = dateKey(date);
|
|
9832
|
+
const outside = date.getMonth() !== month.getMonth();
|
|
9833
|
+
const disabled = disabledDate?.(key) ?? false;
|
|
9834
|
+
const selected = selectedDates.includes(key);
|
|
9835
|
+
const rangeStart = Boolean(start && key === start);
|
|
9836
|
+
const rangeEnd = Boolean(range[1] && key === range[1]);
|
|
9837
|
+
const inRange = Boolean(low && high && key >= low && key <= high);
|
|
9838
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
9839
|
+
"span",
|
|
9786
9840
|
{
|
|
9787
|
-
|
|
9788
|
-
|
|
9789
|
-
|
|
9790
|
-
|
|
9791
|
-
|
|
9792
|
-
|
|
9793
|
-
|
|
9794
|
-
|
|
9795
|
-
|
|
9796
|
-
|
|
9797
|
-
|
|
9798
|
-
|
|
9799
|
-
|
|
9800
|
-
|
|
9841
|
+
className: `sia-date-panel__cell${outside ? " is-outside" : ""}${selected ? " is-selected" : ""}${rangeStart ? " is-range-start" : ""}${rangeEnd ? " is-range-end" : ""}${inRange ? " is-in-range" : ""}${key === today ? " is-today" : ""}`,
|
|
9842
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
9843
|
+
"button",
|
|
9844
|
+
{
|
|
9845
|
+
type: "button",
|
|
9846
|
+
"aria-label": key,
|
|
9847
|
+
"aria-pressed": selected || rangeStart || rangeEnd || void 0,
|
|
9848
|
+
disabled,
|
|
9849
|
+
onClick: () => onSelect(key),
|
|
9850
|
+
onMouseEnter: () => onHover?.(key),
|
|
9851
|
+
children: date.getDate()
|
|
9852
|
+
}
|
|
9853
|
+
)
|
|
9854
|
+
},
|
|
9855
|
+
key
|
|
9856
|
+
);
|
|
9857
|
+
}) })
|
|
9858
|
+
]
|
|
9859
|
+
}
|
|
9860
|
+
);
|
|
9801
9861
|
}
|
|
9802
9862
|
function CalendarHeader({
|
|
9803
9863
|
month,
|
|
9804
9864
|
label,
|
|
9805
9865
|
range = false,
|
|
9866
|
+
onTitleClick,
|
|
9806
9867
|
onPreviousYear,
|
|
9807
9868
|
onPreviousMonth,
|
|
9808
9869
|
onNextMonth,
|
|
@@ -9816,7 +9877,15 @@ function CalendarHeader({
|
|
|
9816
9877
|
] }) : null,
|
|
9817
9878
|
onPreviousMonth ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("button", { type: "button", "aria-label": "\u4E0A\u4E2A\u6708", onClick: onPreviousMonth, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Icon, { name: "chevron-left", size: 15 }) }) : null
|
|
9818
9879
|
] }),
|
|
9819
|
-
/* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("
|
|
9880
|
+
onTitleClick ? /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("button", { type: "button", className: "sia-date-panel__title", "aria-label": "\u9009\u62E9\u5E74\u4EFD", onClick: onTitleClick, children: [
|
|
9881
|
+
label ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("small", { children: label }) : null,
|
|
9882
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("span", { children: [
|
|
9883
|
+
month.getFullYear(),
|
|
9884
|
+
"\u5E74\xA0 ",
|
|
9885
|
+
month.getMonth() + 1,
|
|
9886
|
+
"\u6708"
|
|
9887
|
+
] })
|
|
9888
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("strong", { children: [
|
|
9820
9889
|
label ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("small", { children: label }) : null,
|
|
9821
9890
|
/* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("span", { children: [
|
|
9822
9891
|
month.getFullYear(),
|
|
@@ -9835,36 +9904,146 @@ function CalendarHeader({
|
|
|
9835
9904
|
range ? null : null
|
|
9836
9905
|
] });
|
|
9837
9906
|
}
|
|
9907
|
+
var TIME_OPTION_HEIGHT = 32;
|
|
9908
|
+
var TIME_COLUMN_PADDING = 4;
|
|
9909
|
+
function TimeColumn({
|
|
9910
|
+
ariaLabel,
|
|
9911
|
+
columnIndex,
|
|
9912
|
+
count,
|
|
9913
|
+
value,
|
|
9914
|
+
siblings,
|
|
9915
|
+
use12Hours = false,
|
|
9916
|
+
unit = "",
|
|
9917
|
+
unitLabels = false,
|
|
9918
|
+
disabledTime,
|
|
9919
|
+
onSelect
|
|
9920
|
+
}) {
|
|
9921
|
+
const listRef = (0, import_react45.useRef)(null);
|
|
9922
|
+
const drag = (0, import_react45.useRef)({ startY: 0, startScroll: 0, pointerId: -1, dragging: false, samples: [], velocity: 0, frame: 0 });
|
|
9923
|
+
(0, import_react45.useLayoutEffect)(() => {
|
|
9924
|
+
const column = listRef.current;
|
|
9925
|
+
const selected = column?.querySelector('[aria-selected="true"]');
|
|
9926
|
+
const first = column?.firstElementChild;
|
|
9927
|
+
if (!column || !selected || !first) return;
|
|
9928
|
+
const top = selected.offsetTop - first.offsetTop + parseFloat(getComputedStyle(column).paddingTop || "0");
|
|
9929
|
+
const bottom = top + selected.offsetHeight;
|
|
9930
|
+
if (top < column.scrollTop || bottom > column.scrollTop + column.clientHeight) {
|
|
9931
|
+
column.scrollTop = Math.max(0, top - (column.clientHeight - selected.offsetHeight) / 2);
|
|
9932
|
+
}
|
|
9933
|
+
}, [value, count]);
|
|
9934
|
+
(0, import_react45.useEffect)(() => () => cancelAnimationFrame(drag.current.frame), []);
|
|
9935
|
+
function stopWithSnap() {
|
|
9936
|
+
const column = listRef.current;
|
|
9937
|
+
if (!column) return;
|
|
9938
|
+
const snapped = Math.round((column.scrollTop - TIME_COLUMN_PADDING) / TIME_OPTION_HEIGHT) * TIME_OPTION_HEIGHT + TIME_COLUMN_PADDING;
|
|
9939
|
+
const max = column.scrollHeight - column.clientHeight;
|
|
9940
|
+
column.scrollTo({ top: Math.max(0, Math.min(max, snapped)), behavior: "smooth" });
|
|
9941
|
+
}
|
|
9942
|
+
function onPointerDown(event) {
|
|
9943
|
+
if (event.button !== 0) return;
|
|
9944
|
+
const column = listRef.current;
|
|
9945
|
+
if (!column) return;
|
|
9946
|
+
drag.current = { startY: event.clientY, startScroll: column.scrollTop, pointerId: event.pointerId, dragging: false, samples: [event.timeStamp, event.clientY], velocity: 0, frame: 0 };
|
|
9947
|
+
}
|
|
9948
|
+
function onPointerMove(event) {
|
|
9949
|
+
const state = drag.current;
|
|
9950
|
+
const column = listRef.current;
|
|
9951
|
+
if (state.pointerId !== event.pointerId || !column) return;
|
|
9952
|
+
const dy = event.clientY - state.startY;
|
|
9953
|
+
if (!state.dragging && Math.abs(dy) > 4) {
|
|
9954
|
+
state.dragging = true;
|
|
9955
|
+
try {
|
|
9956
|
+
column.setPointerCapture(event.pointerId);
|
|
9957
|
+
} catch {
|
|
9958
|
+
}
|
|
9959
|
+
}
|
|
9960
|
+
if (!state.dragging) return;
|
|
9961
|
+
column.scrollTop = state.startScroll - dy;
|
|
9962
|
+
state.samples.push(event.timeStamp, event.clientY);
|
|
9963
|
+
while (state.samples.length > 4 && event.timeStamp - state.samples[0] > 100) state.samples.splice(0, 2);
|
|
9964
|
+
}
|
|
9965
|
+
function onPointerUp(event) {
|
|
9966
|
+
const state = drag.current;
|
|
9967
|
+
const column = listRef.current;
|
|
9968
|
+
if (state.pointerId !== event.pointerId || !column) return;
|
|
9969
|
+
state.pointerId = -1;
|
|
9970
|
+
try {
|
|
9971
|
+
column.releasePointerCapture?.(event.pointerId);
|
|
9972
|
+
} catch {
|
|
9973
|
+
}
|
|
9974
|
+
if (!state.dragging) return;
|
|
9975
|
+
const samples = state.samples;
|
|
9976
|
+
const dt = samples[samples.length - 2] - samples[0];
|
|
9977
|
+
const dy = samples[samples.length - 1] - samples[1];
|
|
9978
|
+
let velocity = dt > 4 ? dy / dt : 0;
|
|
9979
|
+
velocity = Math.max(-2.5, Math.min(2.5, velocity));
|
|
9980
|
+
cancelAnimationFrame(state.frame);
|
|
9981
|
+
let last = performance.now();
|
|
9982
|
+
const step = (now) => {
|
|
9983
|
+
const elapsed = Math.min(32, now - last);
|
|
9984
|
+
last = now;
|
|
9985
|
+
column.scrollTop -= velocity * elapsed;
|
|
9986
|
+
velocity *= Math.pow(0.94, elapsed / 16.7);
|
|
9987
|
+
if (Math.abs(velocity) > 0.04) state.frame = requestAnimationFrame(step);
|
|
9988
|
+
else stopWithSnap();
|
|
9989
|
+
};
|
|
9990
|
+
state.frame = requestAnimationFrame(step);
|
|
9991
|
+
}
|
|
9992
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(import_jsx_runtime42.Fragment, { children: [
|
|
9993
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
9994
|
+
"div",
|
|
9995
|
+
{
|
|
9996
|
+
ref: listRef,
|
|
9997
|
+
role: "listbox",
|
|
9998
|
+
"aria-label": ariaLabel,
|
|
9999
|
+
onPointerDown,
|
|
10000
|
+
onPointerMove,
|
|
10001
|
+
onPointerUp,
|
|
10002
|
+
onPointerCancel: onPointerUp,
|
|
10003
|
+
onClickCapture: (event) => {
|
|
10004
|
+
if (!drag.current.dragging) return;
|
|
10005
|
+
event.preventDefault();
|
|
10006
|
+
event.stopPropagation();
|
|
10007
|
+
drag.current.dragging = false;
|
|
10008
|
+
},
|
|
10009
|
+
children: Array.from({ length: count }, (_, index) => {
|
|
10010
|
+
const next = pad2(index);
|
|
10011
|
+
const candidate = [...siblings];
|
|
10012
|
+
candidate[columnIndex] = next;
|
|
10013
|
+
const selected = next === value;
|
|
10014
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("button", { type: "button", role: "option", disabled: disabledTime?.(candidate.join(":")), "aria-selected": selected, className: selected ? "is-selected" : "", onKeyDown: (event) => {
|
|
10015
|
+
if (!["ArrowDown", "ArrowUp", "Home", "End"].includes(event.key)) return;
|
|
10016
|
+
event.preventDefault();
|
|
10017
|
+
const buttons = Array.from(event.currentTarget.parentElement.querySelectorAll("button:not(:disabled)"));
|
|
10018
|
+
const position = buttons.indexOf(event.currentTarget);
|
|
10019
|
+
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)));
|
|
10020
|
+
buttons[target]?.focus();
|
|
10021
|
+
}, onClick: () => onSelect(next), children: [
|
|
10022
|
+
use12Hours && columnIndex === 0 ? `${pad2(index % 12 || 12)} ${index < 12 ? "AM" : "PM"}` : next,
|
|
10023
|
+
unitLabels && selected ? unit : ""
|
|
10024
|
+
] }, next);
|
|
10025
|
+
})
|
|
10026
|
+
}
|
|
10027
|
+
),
|
|
10028
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)(FloatingScrollbarProvider, { targetRef: listRef })
|
|
10029
|
+
] });
|
|
10030
|
+
}
|
|
9838
10031
|
function TimePanel({
|
|
9839
10032
|
value,
|
|
9840
10033
|
showSecond = false,
|
|
9841
10034
|
ariaLabel = "\u65F6\u95F4",
|
|
9842
10035
|
disabledTime,
|
|
9843
10036
|
use12Hours = false,
|
|
10037
|
+
title,
|
|
10038
|
+
unitLabels = false,
|
|
9844
10039
|
onChange
|
|
9845
10040
|
}) {
|
|
9846
10041
|
const [hour = "00", minute = "00", second = "00"] = value.split(":");
|
|
9847
|
-
const
|
|
9848
|
-
const hourRef = (0, import_react45.useRef)(null);
|
|
9849
|
-
const minuteRef = (0, import_react45.useRef)(null);
|
|
9850
|
-
const secondRef = (0, import_react45.useRef)(null);
|
|
9851
|
-
const columnRefs = [hourRef, minuteRef, secondRef];
|
|
9852
|
-
(0, import_react45.useLayoutEffect)(() => {
|
|
9853
|
-
for (const column of columnsRef.current?.children ?? []) {
|
|
9854
|
-
const selected = column.querySelector('[aria-selected="true"]');
|
|
9855
|
-
const first = column.firstElementChild;
|
|
9856
|
-
if (!selected || !first) continue;
|
|
9857
|
-
const top = selected.offsetTop - first.offsetTop + parseFloat(getComputedStyle(column).paddingTop || "0");
|
|
9858
|
-
const bottom = top + selected.offsetHeight;
|
|
9859
|
-
if (top < column.scrollTop || bottom > column.scrollTop + column.clientHeight) {
|
|
9860
|
-
column.scrollTop = Math.max(0, top - (column.clientHeight - selected.offsetHeight) / 2);
|
|
9861
|
-
}
|
|
9862
|
-
}
|
|
9863
|
-
}, [hour, minute, second, showSecond, ariaLabel]);
|
|
10042
|
+
const siblings = [hour, minute, second];
|
|
9864
10043
|
const columns = [
|
|
9865
|
-
{ label: "\u5C0F\u65F6", value: hour, count: 24, index: 0 },
|
|
9866
|
-
{ label: "\u5206\u949F", value: minute, count: 60, index: 1 },
|
|
9867
|
-
...showSecond ? [{ label: "\u79D2", value: second, count: 60, index: 2 }] : []
|
|
10044
|
+
{ label: "\u5C0F\u65F6", unit: "\u65F6", value: hour, count: 24, index: 0 },
|
|
10045
|
+
{ label: "\u5206\u949F", unit: "\u5206", value: minute, count: 60, index: 1 },
|
|
10046
|
+
...showSecond ? [{ label: "\u79D2", unit: "\u79D2", value: second, count: 60, index: 2 }] : []
|
|
9868
10047
|
];
|
|
9869
10048
|
function update(index, next) {
|
|
9870
10049
|
const values = [hour, minute, second];
|
|
@@ -9872,27 +10051,29 @@ function TimePanel({
|
|
|
9872
10051
|
onChange(values.join(":"));
|
|
9873
10052
|
}
|
|
9874
10053
|
return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("aside", { className: "sia-date-panel__time", "aria-label": ariaLabel, children: [
|
|
9875
|
-
/* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("strong", { children: [
|
|
10054
|
+
title != null ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("strong", { className: "sia-date-panel__time-title", children: title }) : /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("strong", { children: [
|
|
9876
10055
|
use12Hours ? pad2(Number(hour) % 12 || 12) : hour,
|
|
9877
10056
|
":",
|
|
9878
10057
|
minute,
|
|
9879
10058
|
showSecond ? `:${second}` : "",
|
|
9880
10059
|
use12Hours ? Number(hour) < 12 ? " AM" : " PM" : ""
|
|
9881
10060
|
] }),
|
|
9882
|
-
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", {
|
|
9883
|
-
|
|
9884
|
-
|
|
9885
|
-
|
|
9886
|
-
|
|
9887
|
-
|
|
9888
|
-
|
|
9889
|
-
|
|
9890
|
-
|
|
9891
|
-
|
|
9892
|
-
|
|
9893
|
-
|
|
9894
|
-
|
|
9895
|
-
|
|
10061
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: "sia-date-panel__time-columns", children: columns.map((column) => /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
10062
|
+
TimeColumn,
|
|
10063
|
+
{
|
|
10064
|
+
ariaLabel: `${ariaLabel}${column.label}`,
|
|
10065
|
+
columnIndex: column.index,
|
|
10066
|
+
count: column.count,
|
|
10067
|
+
value: column.value,
|
|
10068
|
+
siblings,
|
|
10069
|
+
use12Hours,
|
|
10070
|
+
unit: column.unit,
|
|
10071
|
+
unitLabels,
|
|
10072
|
+
disabledTime,
|
|
10073
|
+
onSelect: (next) => update(column.index, next)
|
|
10074
|
+
},
|
|
10075
|
+
column.label
|
|
10076
|
+
)) })
|
|
9896
10077
|
] });
|
|
9897
10078
|
}
|
|
9898
10079
|
function DatePanelFooter({
|
|
@@ -9912,6 +10093,50 @@ function DatePanelFooter({
|
|
|
9912
10093
|
needConfirm ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("button", { type: "button", className: "sia-date-panel__confirm", disabled: disabledConfirm, onClick: onConfirm, children: confirmText }) : null
|
|
9913
10094
|
] });
|
|
9914
10095
|
}
|
|
10096
|
+
function DateTimePanelFooter({
|
|
10097
|
+
date,
|
|
10098
|
+
time,
|
|
10099
|
+
view,
|
|
10100
|
+
disabled = false,
|
|
10101
|
+
extra,
|
|
10102
|
+
onSwitchDate,
|
|
10103
|
+
onSwitchTime,
|
|
10104
|
+
onClearTime
|
|
10105
|
+
}) {
|
|
10106
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("footer", { className: "sia-date-panel__footer sia-date-panel__footer--datetime", children: [
|
|
10107
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("span", { children: [
|
|
10108
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("button", { type: "button", className: "sia-date-panel__chip", "aria-pressed": view === "date" || void 0, disabled, onClick: onSwitchDate, children: [
|
|
10109
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Icon, { name: "calendar", size: 14, "aria-hidden": "true" }),
|
|
10110
|
+
date
|
|
10111
|
+
] }),
|
|
10112
|
+
extra
|
|
10113
|
+
] }),
|
|
10114
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.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: [
|
|
10115
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Icon, { name: "clock", size: 14, "aria-hidden": "true" }),
|
|
10116
|
+
time,
|
|
10117
|
+
onClearTime && !disabled ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
10118
|
+
"span",
|
|
10119
|
+
{
|
|
10120
|
+
role: "button",
|
|
10121
|
+
tabIndex: 0,
|
|
10122
|
+
"aria-label": "\u6E05\u7A7A\u65F6\u95F4",
|
|
10123
|
+
className: "sia-date-panel__chip-clear",
|
|
10124
|
+
onClick: (event) => {
|
|
10125
|
+
event.stopPropagation();
|
|
10126
|
+
onClearTime();
|
|
10127
|
+
},
|
|
10128
|
+
onKeyDown: (event) => {
|
|
10129
|
+
if (event.key !== "Enter" && event.key !== " ") return;
|
|
10130
|
+
event.preventDefault();
|
|
10131
|
+
event.stopPropagation();
|
|
10132
|
+
onClearTime();
|
|
10133
|
+
},
|
|
10134
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Icon, { name: "circle-close", variant: "filled", size: 13, "aria-hidden": "true" })
|
|
10135
|
+
}
|
|
10136
|
+
) : null
|
|
10137
|
+
] })
|
|
10138
|
+
] });
|
|
10139
|
+
}
|
|
9915
10140
|
|
|
9916
10141
|
// src/components/DatePicker.tsx
|
|
9917
10142
|
var import_jsx_runtime43 = require("react/jsx-runtime");
|
|
@@ -9961,6 +10186,12 @@ function resolvePreset(value) {
|
|
|
9961
10186
|
function resolveRangePreset(value) {
|
|
9962
10187
|
return typeof value === "function" ? value() : value;
|
|
9963
10188
|
}
|
|
10189
|
+
function hasExplicitTime(value) {
|
|
10190
|
+
return /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}/.test(String(value ?? ""));
|
|
10191
|
+
}
|
|
10192
|
+
function isZeroTime(time, showSecond) {
|
|
10193
|
+
return showSecond ? time === "00:00:00" : time.slice(0, 5) === "00:00";
|
|
10194
|
+
}
|
|
9964
10195
|
function DatePicker({
|
|
9965
10196
|
value,
|
|
9966
10197
|
defaultValue,
|
|
@@ -10000,7 +10231,11 @@ function DatePicker({
|
|
|
10000
10231
|
const firstCurrent = Array.isArray(currentValue) ? currentValue[0] : currentValue;
|
|
10001
10232
|
const [viewMonth, setViewMonth] = (0, import_react46.useState)(() => startOfMonth(parseDate2(dayFromValue(firstCurrent)) ?? /* @__PURE__ */ new Date()));
|
|
10002
10233
|
const [draftTime, setDraftTime] = (0, import_react46.useState)(() => timePart(firstCurrent, defaultTimeFrom(showTime)));
|
|
10003
|
-
const
|
|
10234
|
+
const showTimeDefaultProvided = typeof showTime === "object" && showTime.defaultValue !== void 0;
|
|
10235
|
+
const [timeExplicit, setTimeExplicit] = (0, import_react46.useState)(() => showTimeDefaultProvided || hasExplicitTime(typeof initialValue === "string" ? initialValue : void 0));
|
|
10236
|
+
const [dateTimeView, setDateTimeView] = (0, import_react46.useState)("date");
|
|
10237
|
+
const [yearDrill, setYearDrill] = (0, import_react46.useState)(false);
|
|
10238
|
+
const resolvedNeedConfirm = showTime ? false : Boolean(needConfirm);
|
|
10004
10239
|
const showSecond = showSecondFrom(showTime);
|
|
10005
10240
|
const selectedDates = (0, import_react46.useMemo)(() => {
|
|
10006
10241
|
const values = Array.isArray(draftValue) ? draftValue : draftValue ? [draftValue] : [];
|
|
@@ -10021,6 +10256,9 @@ function DatePicker({
|
|
|
10021
10256
|
const current = Array.isArray(currentValue) ? currentValue[0] : currentValue;
|
|
10022
10257
|
setViewMonth(startOfMonth(parseDate2(dayFromValue(current)) ?? /* @__PURE__ */ new Date()));
|
|
10023
10258
|
setDraftTime(timePart(current, defaultTimeFrom(showTime)));
|
|
10259
|
+
setTimeExplicit(showTimeDefaultProvided || hasExplicitTime(typeof current === "string" ? current : void 0));
|
|
10260
|
+
setDateTimeView("date");
|
|
10261
|
+
setYearDrill(false);
|
|
10024
10262
|
}
|
|
10025
10263
|
setVisible(next);
|
|
10026
10264
|
}
|
|
@@ -10032,9 +10270,11 @@ function DatePicker({
|
|
|
10032
10270
|
if (maximum && day.slice(0, length) > String(maximum).slice(0, length)) return true;
|
|
10033
10271
|
return disabledDate?.(day, { type: "date" }) ?? false;
|
|
10034
10272
|
}
|
|
10035
|
-
function buildValue(day, time = draftTime) {
|
|
10273
|
+
function buildValue(day, time = draftTime, explicit = timeExplicit) {
|
|
10036
10274
|
const picked = formatPickerValue(day, picker);
|
|
10037
|
-
|
|
10275
|
+
if (!(showTime && picker === "date")) return picked;
|
|
10276
|
+
if (!explicit && isZeroTime(time, showSecond)) return picked;
|
|
10277
|
+
return withTime(picked, time, showSecond);
|
|
10038
10278
|
}
|
|
10039
10279
|
function selectDate(day, time = draftTime, ensureSelected = false) {
|
|
10040
10280
|
if (isDisabled(day)) return;
|
|
@@ -10050,7 +10290,7 @@ function DatePicker({
|
|
|
10050
10290
|
setDraftValue(nextValue);
|
|
10051
10291
|
if (!resolvedNeedConfirm) {
|
|
10052
10292
|
setCurrentValue(nextValue);
|
|
10053
|
-
changeOpen(false);
|
|
10293
|
+
if (!showTime) changeOpen(false);
|
|
10054
10294
|
}
|
|
10055
10295
|
}
|
|
10056
10296
|
function commitDraft() {
|
|
@@ -10059,6 +10299,72 @@ function DatePicker({
|
|
|
10059
10299
|
setCurrentValue(draftValue);
|
|
10060
10300
|
changeOpen(false);
|
|
10061
10301
|
}
|
|
10302
|
+
function applyDraftTime(next) {
|
|
10303
|
+
setDraftTime(next);
|
|
10304
|
+
setTimeExplicit(true);
|
|
10305
|
+
const day = typeof draftValue === "string" ? dayFromValue(draftValue) : "";
|
|
10306
|
+
if (!day) return;
|
|
10307
|
+
const nextValue = withTime(day, next, showSecond);
|
|
10308
|
+
setDraftValue(nextValue);
|
|
10309
|
+
setCurrentValue(nextValue);
|
|
10310
|
+
}
|
|
10311
|
+
function clearDraftTime() {
|
|
10312
|
+
setDraftTime("00:00:00");
|
|
10313
|
+
setTimeExplicit(false);
|
|
10314
|
+
const day = typeof draftValue === "string" ? dayFromValue(draftValue) : "";
|
|
10315
|
+
if (!day) return;
|
|
10316
|
+
setDraftValue(day);
|
|
10317
|
+
setCurrentValue(day);
|
|
10318
|
+
}
|
|
10319
|
+
function renderCalendarSection() {
|
|
10320
|
+
return picker === "year" || yearDrill ? /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(import_jsx_runtime43.Fragment, { children: [
|
|
10321
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "sia-date-panel__header", children: [
|
|
10322
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)("span", { className: "sia-date-panel__nav", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("button", { type: "button", "aria-label": "\u4E0A\u5341\u5E74", onClick: () => setViewMonth(addMonths(viewMonth, -120)), children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Icon, { name: "chevron-left", size: 15 }) }) }),
|
|
10323
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("strong", { children: [
|
|
10324
|
+
Math.floor(viewMonth.getFullYear() / 10) * 10,
|
|
10325
|
+
"\u5E74 \u2014 ",
|
|
10326
|
+
Math.floor(viewMonth.getFullYear() / 10) * 10 + 9,
|
|
10327
|
+
"\u5E74"
|
|
10328
|
+
] }),
|
|
10329
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)("span", { className: "sia-date-panel__nav", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("button", { type: "button", "aria-label": "\u4E0B\u5341\u5E74", onClick: () => setViewMonth(addMonths(viewMonth, 120)), children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Icon, { name: "chevron-right", size: 15 }) }) })
|
|
10330
|
+
] }),
|
|
10331
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "sia-date-panel__years", children: Array.from({ length: 10 }, (_, index) => {
|
|
10332
|
+
const year = String(Math.floor(viewMonth.getFullYear() / 10) * 10 + index);
|
|
10333
|
+
const day = `${year}-01-01`;
|
|
10334
|
+
const selected = selectedDates.some((value2) => value2.slice(0, 4) === year);
|
|
10335
|
+
return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("span", { className: `sia-date-panel__cell${selected ? " is-selected" : ""}${year === String((/* @__PURE__ */ new Date()).getFullYear()) ? " is-today" : ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("button", { type: "button", "aria-label": `${year}\u5E74`, "aria-pressed": selected, disabled: isDisabled(day), onClick: () => {
|
|
10336
|
+
if (yearDrill) {
|
|
10337
|
+
setViewMonth(new Date(Number(year), viewMonth.getMonth(), 1));
|
|
10338
|
+
setYearDrill(false);
|
|
10339
|
+
} else {
|
|
10340
|
+
selectDate(day);
|
|
10341
|
+
}
|
|
10342
|
+
}, children: year }) }, year);
|
|
10343
|
+
}) })
|
|
10344
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(import_jsx_runtime43.Fragment, { children: [
|
|
10345
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
10346
|
+
CalendarHeader,
|
|
10347
|
+
{
|
|
10348
|
+
month: viewMonth,
|
|
10349
|
+
onTitleClick: picker === "date" ? () => setYearDrill(true) : void 0,
|
|
10350
|
+
onPreviousYear: () => setViewMonth(addMonths(viewMonth, -12)),
|
|
10351
|
+
onPreviousMonth: () => setViewMonth(addMonths(viewMonth, -1)),
|
|
10352
|
+
onNextMonth: () => setViewMonth(addMonths(viewMonth, 1)),
|
|
10353
|
+
onNextYear: () => setViewMonth(addMonths(viewMonth, 12))
|
|
10354
|
+
}
|
|
10355
|
+
),
|
|
10356
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
10357
|
+
CalendarMonth,
|
|
10358
|
+
{
|
|
10359
|
+
month: viewMonth,
|
|
10360
|
+
selectedDates,
|
|
10361
|
+
disabledDate: isDisabled,
|
|
10362
|
+
onSelect: selectDate,
|
|
10363
|
+
onSwipeMonth: picker === "date" ? (direction) => setViewMonth(addMonths(viewMonth, direction)) : void 0
|
|
10364
|
+
}
|
|
10365
|
+
)
|
|
10366
|
+
] });
|
|
10367
|
+
}
|
|
10062
10368
|
function clearValue(event) {
|
|
10063
10369
|
event.stopPropagation();
|
|
10064
10370
|
const empty = multiple ? [] : "";
|
|
@@ -10098,72 +10404,82 @@ function DatePicker({
|
|
|
10098
10404
|
),
|
|
10099
10405
|
floating.label,
|
|
10100
10406
|
allowClear && display && !disabled ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("button", { type: "button", className: "sia-picker__clear", "aria-label": "\u6E05\u9664\u65E5\u671F", onClick: clearValue, children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Icon, { name: "circle-close", variant: "filled", size: 15 }) }) : null,
|
|
10101
|
-
/* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
|
|
10102
|
-
|
|
10103
|
-
|
|
10104
|
-
|
|
10105
|
-
|
|
10106
|
-
|
|
10107
|
-
|
|
10108
|
-
|
|
10407
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
|
|
10408
|
+
PopupPortal,
|
|
10409
|
+
{
|
|
10410
|
+
ref: popupRef,
|
|
10411
|
+
anchorRef: rootRef,
|
|
10412
|
+
open: visible,
|
|
10413
|
+
className: `sia-date-panel${showTime ? " sia-date-panel--datetime" : ""}${presets?.length ? " sia-date-panel--with-presets" : ""}`,
|
|
10414
|
+
role: "dialog",
|
|
10415
|
+
"aria-label": "\u65E5\u671F\u9009\u62E9\u9762\u677F",
|
|
10416
|
+
onKeyDown: (event) => {
|
|
10417
|
+
if (event.key === "Escape") {
|
|
10418
|
+
event.stopPropagation();
|
|
10109
10419
|
changeOpen(false);
|
|
10110
10420
|
}
|
|
10111
|
-
},
|
|
10112
|
-
|
|
10113
|
-
/* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "sia-date-
|
|
10114
|
-
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)("
|
|
10115
|
-
|
|
10116
|
-
|
|
10117
|
-
|
|
10118
|
-
|
|
10119
|
-
|
|
10120
|
-
|
|
10121
|
-
|
|
10421
|
+
},
|
|
10422
|
+
children: [
|
|
10423
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "sia-date-panel__body", children: [
|
|
10424
|
+
presets?.length ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("aside", { className: "sia-date-panel__presets", children: presets.map((preset2, index) => /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("button", { type: "button", onClick: () => {
|
|
10425
|
+
const next = resolvePreset(preset2.value);
|
|
10426
|
+
if (!next || isDisabled(dayFromValue(next))) return;
|
|
10427
|
+
setDraftValue(next);
|
|
10428
|
+
setDraftTime(timePart(next, defaultTimeFrom(showTime)));
|
|
10429
|
+
setTimeExplicit(hasExplicitTime(next));
|
|
10430
|
+
if (!resolvedNeedConfirm) {
|
|
10431
|
+
setCurrentValue(next);
|
|
10432
|
+
changeOpen(false);
|
|
10433
|
+
}
|
|
10434
|
+
}, children: preset2.label }, index)) }) : null,
|
|
10435
|
+
showTime ? /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "sia-date-panel__views", children: [
|
|
10436
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)("section", { className: `sia-date-panel__view sia-date-panel__view--date${dateTimeView === "date" ? " is-active" : ""}`, "aria-hidden": dateTimeView !== "date", children: renderCalendarSection() }),
|
|
10437
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.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_runtime43.jsx)(
|
|
10438
|
+
TimePanel,
|
|
10439
|
+
{
|
|
10440
|
+
value: draftTime,
|
|
10441
|
+
showSecond,
|
|
10442
|
+
title: "\u9009\u62E9\u65F6\u95F4",
|
|
10443
|
+
unitLabels: true,
|
|
10444
|
+
ariaLabel: "\u9009\u62E9\u65F6\u95F4",
|
|
10445
|
+
onChange: applyDraftTime
|
|
10446
|
+
}
|
|
10447
|
+
) })
|
|
10448
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("section", { className: "sia-date-panel__calendar", children: renderCalendarSection() })
|
|
10122
10449
|
] }),
|
|
10123
|
-
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
10124
|
-
|
|
10125
|
-
const day = `${year}-01-01`;
|
|
10126
|
-
const selected = selectedDates.some((value2) => value2.slice(0, 4) === year);
|
|
10127
|
-
return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("span", { className: `sia-date-panel__cell${selected ? " is-selected" : ""}${year === String((/* @__PURE__ */ new Date()).getFullYear()) ? " is-today" : ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("button", { type: "button", "aria-label": `${year}\u5E74`, "aria-pressed": selected, disabled: isDisabled(day), onClick: () => selectDate(day), children: year }) }, year);
|
|
10128
|
-
}) })
|
|
10129
|
-
] }) : /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(import_jsx_runtime43.Fragment, { children: [
|
|
10130
|
-
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
10131
|
-
CalendarHeader,
|
|
10450
|
+
showTime ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
10451
|
+
DateTimePanelFooter,
|
|
10132
10452
|
{
|
|
10133
|
-
|
|
10134
|
-
|
|
10135
|
-
|
|
10136
|
-
|
|
10137
|
-
|
|
10453
|
+
date: (typeof draftValue === "string" ? dayFromValue(draftValue) : "") || dateKey(/* @__PURE__ */ new Date()),
|
|
10454
|
+
time: showSecond ? draftTime : draftTime.slice(0, 5),
|
|
10455
|
+
view: dateTimeView,
|
|
10456
|
+
extra: renderExtraFooter?.(),
|
|
10457
|
+
onSwitchDate: () => setDateTimeView("date"),
|
|
10458
|
+
onSwitchTime: () => setDateTimeView("time"),
|
|
10459
|
+
onClearTime: clearDraftTime
|
|
10138
10460
|
}
|
|
10139
|
-
),
|
|
10140
|
-
|
|
10141
|
-
|
|
10142
|
-
|
|
10143
|
-
|
|
10144
|
-
|
|
10145
|
-
|
|
10146
|
-
|
|
10147
|
-
|
|
10148
|
-
|
|
10149
|
-
|
|
10150
|
-
|
|
10151
|
-
|
|
10152
|
-
|
|
10153
|
-
|
|
10154
|
-
|
|
10155
|
-
|
|
10156
|
-
|
|
10157
|
-
|
|
10158
|
-
|
|
10159
|
-
|
|
10160
|
-
|
|
10161
|
-
selectDate(day, time, true);
|
|
10162
|
-
},
|
|
10163
|
-
onConfirm: commitDraft
|
|
10164
|
-
}
|
|
10165
|
-
)
|
|
10166
|
-
] })
|
|
10461
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
10462
|
+
DatePanelFooter,
|
|
10463
|
+
{
|
|
10464
|
+
extra: renderExtraFooter?.(),
|
|
10465
|
+
showToday,
|
|
10466
|
+
needConfirm: resolvedNeedConfirm,
|
|
10467
|
+
disabledConfirm: Array.isArray(draftValue) ? draftValue.length === 0 : !draftValue,
|
|
10468
|
+
onToday: () => {
|
|
10469
|
+
const now = /* @__PURE__ */ new Date();
|
|
10470
|
+
const day = dateKey(now);
|
|
10471
|
+
if (isDisabled(day)) return;
|
|
10472
|
+
const time = [now.getHours(), now.getMinutes(), now.getSeconds()].map(pad2).join(":");
|
|
10473
|
+
if (showTime) setDraftTime(time);
|
|
10474
|
+
setViewMonth(startOfMonth(now));
|
|
10475
|
+
selectDate(day, time, true);
|
|
10476
|
+
},
|
|
10477
|
+
onConfirm: commitDraft
|
|
10478
|
+
}
|
|
10479
|
+
)
|
|
10480
|
+
]
|
|
10481
|
+
}
|
|
10482
|
+
)
|
|
10167
10483
|
] });
|
|
10168
10484
|
}
|
|
10169
10485
|
function DateRangePicker({
|
|
@@ -10223,8 +10539,7 @@ function DateRangePicker({
|
|
|
10223
10539
|
}
|
|
10224
10540
|
return () => observer.disconnect();
|
|
10225
10541
|
});
|
|
10226
|
-
const [
|
|
10227
|
-
const [presetSelected, setPresetSelected] = (0, import_react46.useState)(false);
|
|
10542
|
+
const [dateTimeView, setDateTimeView] = (0, import_react46.useState)("date");
|
|
10228
10543
|
const [hoverDate, setHoverDate] = (0, import_react46.useState)("");
|
|
10229
10544
|
const [viewMonth, setViewMonth] = (0, import_react46.useState)(() => startOfMonth(parseDate2(dayFromValue(currentValue[0] || currentValue[1])) ?? /* @__PURE__ */ new Date()));
|
|
10230
10545
|
const [endViewMonth, setEndViewMonth] = (0, import_react46.useState)(() => startOfMonth(parseDate2(dayFromValue(currentValue[1])) ?? addMonths(parseDate2(dayFromValue(currentValue[0])) ?? /* @__PURE__ */ new Date(), 1)));
|
|
@@ -10235,7 +10550,7 @@ function DateRangePicker({
|
|
|
10235
10550
|
timePart(currentValue[0], defaultTime),
|
|
10236
10551
|
timePart(currentValue[1], defaultEndTime)
|
|
10237
10552
|
]);
|
|
10238
|
-
const resolvedNeedConfirm =
|
|
10553
|
+
const resolvedNeedConfirm = showTime ? false : Boolean(needConfirm);
|
|
10239
10554
|
const rangeDates = [dayFromValue(draftValue[0]), dayFromValue(draftValue[1])];
|
|
10240
10555
|
const invalidDateTimeRange = Boolean(showTime && draftValue[0] && draftValue[1] && draftValue[0] > draftValue[1]);
|
|
10241
10556
|
(0, import_react46.useEffect)(() => {
|
|
@@ -10252,11 +10567,10 @@ function DateRangePicker({
|
|
|
10252
10567
|
}
|
|
10253
10568
|
function changeOpen(next, endpoint) {
|
|
10254
10569
|
if (next && !visible) {
|
|
10255
|
-
setConfirmedIndex(null);
|
|
10256
|
-
setPresetSelected(false);
|
|
10257
10570
|
setDraftValue(currentValue);
|
|
10258
10571
|
setTimes([timePart(currentValue[0], defaultTime), timePart(currentValue[1], defaultEndTime)]);
|
|
10259
10572
|
setActiveIndex(endpointDisabled[0] ? 1 : endpointDisabled[1] ? 0 : endpoint ?? (currentValue[0] && !currentValue[1] ? 1 : 0));
|
|
10573
|
+
setDateTimeView("date");
|
|
10260
10574
|
const nextStartMonth = startOfMonth(parseDate2(dayFromValue(currentValue[0] || currentValue[1])) ?? /* @__PURE__ */ new Date());
|
|
10261
10575
|
setViewMonth(nextStartMonth);
|
|
10262
10576
|
setEndViewMonth(startOfMonth(parseDate2(dayFromValue(currentValue[1])) ?? addMonths(nextStartMonth, 1)));
|
|
@@ -10272,9 +10586,9 @@ function DateRangePicker({
|
|
|
10272
10586
|
if (maximum && day > String(maximum).slice(0, 10)) return true;
|
|
10273
10587
|
const from = index === 1 ? rangeDates[0] : void 0;
|
|
10274
10588
|
if (dateTimeStep) {
|
|
10275
|
-
const
|
|
10276
|
-
const otherEndpoint = rangeDates[
|
|
10277
|
-
if (otherEndpoint
|
|
10589
|
+
const otherIndex = index === 0 ? 1 : 0;
|
|
10590
|
+
const otherEndpoint = rangeDates[otherIndex];
|
|
10591
|
+
if (otherEndpoint) {
|
|
10278
10592
|
if (index === 0 && day > otherEndpoint || index === 1 && day < otherEndpoint) return true;
|
|
10279
10593
|
if (maxRangeDays && Math.abs(daysBetween(otherEndpoint, day)) >= maxRangeDays) return true;
|
|
10280
10594
|
}
|
|
@@ -10285,10 +10599,9 @@ function DateRangePicker({
|
|
|
10285
10599
|
return showTime ? withTime(day, times[index], showSecond) : day;
|
|
10286
10600
|
}
|
|
10287
10601
|
function updateDraft(next) {
|
|
10288
|
-
setPresetSelected(false);
|
|
10289
10602
|
setDraftValue(next);
|
|
10290
10603
|
onCalendarChange?.(next);
|
|
10291
|
-
if (
|
|
10604
|
+
if (isValidRange(next) && (next[0] !== currentValue[0] || next[1] !== currentValue[1])) {
|
|
10292
10605
|
setCurrentValue(next);
|
|
10293
10606
|
}
|
|
10294
10607
|
}
|
|
@@ -10329,6 +10642,13 @@ function DateRangePicker({
|
|
|
10329
10642
|
nextValue[index] = withTime(day, time, showSecond);
|
|
10330
10643
|
updateDraft(nextValue);
|
|
10331
10644
|
setHoverDate("");
|
|
10645
|
+
const otherIndex = index === 0 ? 1 : 0;
|
|
10646
|
+
if (!nextValue[otherIndex]) {
|
|
10647
|
+
setActiveIndex(otherIndex);
|
|
10648
|
+
const month = startOfMonth(parseDate2(day) ?? /* @__PURE__ */ new Date());
|
|
10649
|
+
(otherIndex === 0 ? setViewMonth : setEndViewMonth)(month);
|
|
10650
|
+
return;
|
|
10651
|
+
}
|
|
10332
10652
|
setActiveIndex(index);
|
|
10333
10653
|
}
|
|
10334
10654
|
function changeTime(index, nextTime) {
|
|
@@ -10365,19 +10685,7 @@ function DateRangePicker({
|
|
|
10365
10685
|
}
|
|
10366
10686
|
return true;
|
|
10367
10687
|
}
|
|
10368
|
-
const otherIndex = activeIndex === 0 ? 1 : 0;
|
|
10369
|
-
const needsOtherConfirmation = Boolean(showTime && !presetSelected && !endpointDisabled[otherIndex] && confirmedIndex !== otherIndex);
|
|
10370
10688
|
function confirm() {
|
|
10371
|
-
if (needsOtherConfirmation) {
|
|
10372
|
-
if (!draftValue[activeIndex] && !allowEmpty[activeIndex]) return;
|
|
10373
|
-
setConfirmedIndex(activeIndex);
|
|
10374
|
-
setActiveIndex(otherIndex);
|
|
10375
|
-
const month = startOfMonth(parseDate2(dayFromValue(draftValue[activeIndex])) ?? /* @__PURE__ */ new Date());
|
|
10376
|
-
if (otherIndex === 0) setViewMonth(month);
|
|
10377
|
-
else setEndViewMonth(month);
|
|
10378
|
-
setHoverDate("");
|
|
10379
|
-
return;
|
|
10380
|
-
}
|
|
10381
10689
|
if (!isValidRange(draftValue)) return;
|
|
10382
10690
|
setCurrentValue(draftValue);
|
|
10383
10691
|
changeOpen(false);
|
|
@@ -10390,13 +10698,11 @@ function DateRangePicker({
|
|
|
10390
10698
|
];
|
|
10391
10699
|
if (!isValidRange(next)) return;
|
|
10392
10700
|
updateDraft(next);
|
|
10393
|
-
setConfirmedIndex(null);
|
|
10394
|
-
setPresetSelected(true);
|
|
10395
10701
|
setTimes([timePart(next[0], defaultTime), timePart(next[1], defaultEndTime)]);
|
|
10396
10702
|
const nextStartMonth = startOfMonth(parseDate2(dayFromValue(next[0] || next[1])) ?? /* @__PURE__ */ new Date());
|
|
10397
10703
|
setViewMonth(nextStartMonth);
|
|
10398
10704
|
setEndViewMonth(startOfMonth(parseDate2(dayFromValue(next[1])) ?? addMonths(nextStartMonth, 1)));
|
|
10399
|
-
if (!
|
|
10705
|
+
if (!resolvedNeedConfirm) {
|
|
10400
10706
|
changeOpen(false);
|
|
10401
10707
|
}
|
|
10402
10708
|
}
|
|
@@ -10411,49 +10717,29 @@ function DateRangePicker({
|
|
|
10411
10717
|
const month = index === 0 ? viewMonth : endViewMonth;
|
|
10412
10718
|
const setMonth = index === 0 ? setViewMonth : setEndViewMonth;
|
|
10413
10719
|
const endpointLabel = index === 0 ? "\u5F00\u59CB" : "\u7ED3\u675F";
|
|
10414
|
-
return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
|
|
10415
|
-
|
|
10416
|
-
|
|
10417
|
-
|
|
10418
|
-
|
|
10419
|
-
|
|
10420
|
-
|
|
10421
|
-
|
|
10422
|
-
|
|
10423
|
-
|
|
10424
|
-
|
|
10425
|
-
|
|
10426
|
-
|
|
10427
|
-
|
|
10428
|
-
|
|
10429
|
-
|
|
10430
|
-
|
|
10431
|
-
|
|
10432
|
-
|
|
10433
|
-
|
|
10434
|
-
|
|
10435
|
-
|
|
10436
|
-
|
|
10437
|
-
range: rangeDates,
|
|
10438
|
-
disabledDate: (day) => isDisabled(day, index, true),
|
|
10439
|
-
onSelect: (day) => selectDateTime(day, index)
|
|
10440
|
-
}
|
|
10441
|
-
)
|
|
10442
|
-
] }),
|
|
10443
|
-
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
10444
|
-
TimePanel,
|
|
10445
|
-
{
|
|
10446
|
-
value: times[index],
|
|
10447
|
-
showSecond,
|
|
10448
|
-
ariaLabel: `${endpointLabel}\u65F6\u95F4`,
|
|
10449
|
-
disabledTime: endpointDisabled[index] ? () => true : void 0,
|
|
10450
|
-
onChange: (nextTime) => changeTime(index, nextTime)
|
|
10451
|
-
}
|
|
10452
|
-
)
|
|
10453
|
-
]
|
|
10454
|
-
},
|
|
10455
|
-
endpointLabel
|
|
10456
|
-
);
|
|
10720
|
+
return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(import_jsx_runtime43.Fragment, { children: [
|
|
10721
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
10722
|
+
CalendarHeader,
|
|
10723
|
+
{
|
|
10724
|
+
month,
|
|
10725
|
+
label: endpointLabel,
|
|
10726
|
+
range: true,
|
|
10727
|
+
onPreviousYear: () => setMonth(addMonths(month, -12)),
|
|
10728
|
+
onPreviousMonth: () => setMonth(addMonths(month, -1)),
|
|
10729
|
+
onNextMonth: () => setMonth(addMonths(month, 1)),
|
|
10730
|
+
onNextYear: () => setMonth(addMonths(month, 12))
|
|
10731
|
+
}
|
|
10732
|
+
),
|
|
10733
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
10734
|
+
CalendarMonth,
|
|
10735
|
+
{
|
|
10736
|
+
month,
|
|
10737
|
+
range: rangeDates,
|
|
10738
|
+
disabledDate: (day) => isDisabled(day, index, true),
|
|
10739
|
+
onSelect: (day) => selectDateTime(day, index)
|
|
10740
|
+
}
|
|
10741
|
+
)
|
|
10742
|
+
] });
|
|
10457
10743
|
}
|
|
10458
10744
|
const displayValue = visible && allowEmpty.some(Boolean) ? draftValue : currentValue;
|
|
10459
10745
|
const startFloating = useFloatingPlaceholder({ mode: placeholderMode, placeholder: placeholder[0], filled: Boolean(displayValue[0]), active: visible });
|
|
@@ -10498,67 +10784,110 @@ function DateRangePicker({
|
|
|
10498
10784
|
}
|
|
10499
10785
|
),
|
|
10500
10786
|
allowClear && (displayValue[0] || displayValue[1]) && !disabled ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("button", { type: "button", className: "sia-picker__clear", "aria-label": "\u6E05\u9664\u65E5\u671F\u8303\u56F4", onClick: clearValue, children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Icon, { name: "circle-close", variant: "filled", size: 15 }) }) : null,
|
|
10501
|
-
/* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
|
|
10502
|
-
|
|
10503
|
-
|
|
10504
|
-
|
|
10505
|
-
|
|
10506
|
-
|
|
10507
|
-
|
|
10508
|
-
|
|
10509
|
-
|
|
10510
|
-
|
|
10511
|
-
|
|
10512
|
-
|
|
10513
|
-
|
|
10514
|
-
|
|
10515
|
-
|
|
10516
|
-
|
|
10517
|
-
/* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("
|
|
10518
|
-
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
10519
|
-
|
|
10520
|
-
{
|
|
10521
|
-
|
|
10522
|
-
|
|
10523
|
-
|
|
10524
|
-
|
|
10525
|
-
|
|
10526
|
-
|
|
10527
|
-
|
|
10528
|
-
|
|
10529
|
-
|
|
10530
|
-
|
|
10531
|
-
|
|
10532
|
-
|
|
10533
|
-
|
|
10534
|
-
|
|
10535
|
-
|
|
10536
|
-
|
|
10537
|
-
|
|
10538
|
-
|
|
10539
|
-
|
|
10540
|
-
|
|
10541
|
-
|
|
10542
|
-
|
|
10543
|
-
|
|
10787
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
|
|
10788
|
+
PopupPortal,
|
|
10789
|
+
{
|
|
10790
|
+
ref: popupRef,
|
|
10791
|
+
anchorRef: rootRef,
|
|
10792
|
+
open: visible,
|
|
10793
|
+
className: `sia-date-panel${showTime ? " sia-date-panel--datetime" : " sia-date-panel--range"}${presets?.length ? " sia-date-panel--with-presets" : ""}`,
|
|
10794
|
+
role: "dialog",
|
|
10795
|
+
"aria-label": "\u65E5\u671F\u8303\u56F4\u9009\u62E9\u9762\u677F",
|
|
10796
|
+
onKeyDown: (event) => {
|
|
10797
|
+
if (event.key === "Escape") {
|
|
10798
|
+
event.stopPropagation();
|
|
10799
|
+
dismissPanel();
|
|
10800
|
+
}
|
|
10801
|
+
},
|
|
10802
|
+
children: [
|
|
10803
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "sia-date-panel__body", children: [
|
|
10804
|
+
presets?.length ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("aside", { className: "sia-date-panel__presets", "aria-label": "\u5FEB\u6377\u65E5\u671F\u8303\u56F4", children: presets.map((preset2, index) => /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("button", { type: "button", onClick: () => applyPreset(preset2), children: preset2.label }, index)) }) : null,
|
|
10805
|
+
showTime ? /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "sia-date-panel__views", children: [
|
|
10806
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)("section", { className: `sia-date-panel__view sia-date-panel__view--date${dateTimeView === "date" ? " is-active" : ""}`, "aria-hidden": dateTimeView !== "date", "aria-label": `${activeIndex === 0 ? "\u5F00\u59CB" : "\u7ED3\u675F"}\u65E5\u671F`, children: renderDateTimeGroup(activeIndex) }, activeIndex === 0 ? "\u5F00\u59CB" : "\u7ED3\u675F"),
|
|
10807
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.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_runtime43.jsx)(
|
|
10808
|
+
TimePanel,
|
|
10809
|
+
{
|
|
10810
|
+
value: times[activeIndex],
|
|
10811
|
+
showSecond,
|
|
10812
|
+
title: `\u9009\u62E9${activeIndex === 0 ? "\u5F00\u59CB" : "\u7ED3\u675F"}\u65F6\u95F4`,
|
|
10813
|
+
unitLabels: true,
|
|
10814
|
+
ariaLabel: `\u9009\u62E9${activeIndex === 0 ? "\u5F00\u59CB" : "\u7ED3\u675F"}\u65F6\u95F4`,
|
|
10815
|
+
disabledTime: endpointDisabled[activeIndex] ? () => true : void 0,
|
|
10816
|
+
onChange: (nextTime) => changeTime(activeIndex, nextTime)
|
|
10817
|
+
}
|
|
10818
|
+
) })
|
|
10819
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "sia-date-panel__range-calendars", children: [
|
|
10820
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("section", { className: "sia-date-panel__calendar", children: [
|
|
10821
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
10822
|
+
CalendarHeader,
|
|
10823
|
+
{
|
|
10824
|
+
month: viewMonth,
|
|
10825
|
+
range: true,
|
|
10826
|
+
onPreviousYear: () => setViewMonth(addMonths(viewMonth, -12)),
|
|
10827
|
+
onPreviousMonth: () => setViewMonth(addMonths(viewMonth, -1))
|
|
10828
|
+
}
|
|
10829
|
+
),
|
|
10830
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(CalendarMonth, { month: viewMonth, range: rangeDates, previewEnd: activeIndex === 1 ? hoverDate : "", disabledDate: isDisabled, onSelect: selectDate, onHover: activeIndex === 1 ? setHoverDate : void 0 })
|
|
10831
|
+
] }),
|
|
10832
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("section", { className: "sia-date-panel__calendar", children: [
|
|
10833
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
10834
|
+
CalendarHeader,
|
|
10835
|
+
{
|
|
10836
|
+
month: addMonths(viewMonth, 1),
|
|
10837
|
+
range: true,
|
|
10838
|
+
onNextMonth: () => setViewMonth(addMonths(viewMonth, 1)),
|
|
10839
|
+
onNextYear: () => setViewMonth(addMonths(viewMonth, 12))
|
|
10840
|
+
}
|
|
10841
|
+
),
|
|
10842
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(CalendarMonth, { month: addMonths(viewMonth, 1), range: rangeDates, previewEnd: activeIndex === 1 ? hoverDate : "", disabledDate: isDisabled, onSelect: selectDate, onHover: activeIndex === 1 ? setHoverDate : void 0 })
|
|
10843
|
+
] })
|
|
10844
|
+
] })
|
|
10544
10845
|
] }),
|
|
10545
|
-
|
|
10546
|
-
|
|
10547
|
-
|
|
10548
|
-
|
|
10549
|
-
|
|
10550
|
-
|
|
10551
|
-
|
|
10552
|
-
|
|
10553
|
-
|
|
10554
|
-
|
|
10555
|
-
|
|
10846
|
+
showTime ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
10847
|
+
DateTimePanelFooter,
|
|
10848
|
+
{
|
|
10849
|
+
date: rangeDates[activeIndex] || dateKey(/* @__PURE__ */ new Date()),
|
|
10850
|
+
time: showSecond ? times[activeIndex] : times[activeIndex].slice(0, 5),
|
|
10851
|
+
view: dateTimeView,
|
|
10852
|
+
disabled: endpointDisabled[activeIndex],
|
|
10853
|
+
extra: /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(import_jsx_runtime43.Fragment, { children: [
|
|
10854
|
+
renderExtraFooter?.(),
|
|
10855
|
+
invalidDateTimeRange ? /* @__PURE__ */ (0, import_jsx_runtime43.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_runtime43.jsxs)("small", { children: [
|
|
10856
|
+
"\u6700\u591A\u9009\u62E9 ",
|
|
10857
|
+
maxRangeDays,
|
|
10858
|
+
" \u5929"
|
|
10859
|
+
] }) : null
|
|
10860
|
+
] }),
|
|
10861
|
+
onSwitchDate: () => setDateTimeView("date"),
|
|
10862
|
+
onSwitchTime: () => setDateTimeView("time")
|
|
10556
10863
|
}
|
|
10557
|
-
|
|
10558
|
-
|
|
10559
|
-
|
|
10560
|
-
|
|
10561
|
-
|
|
10864
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
10865
|
+
DatePanelFooter,
|
|
10866
|
+
{
|
|
10867
|
+
showToday: showToday && !presets?.length,
|
|
10868
|
+
needConfirm: resolvedNeedConfirm || allowEmpty.some(Boolean),
|
|
10869
|
+
disabledConfirm: !isValidRange(draftValue),
|
|
10870
|
+
extra: /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(import_jsx_runtime43.Fragment, { children: [
|
|
10871
|
+
renderExtraFooter?.(),
|
|
10872
|
+
invalidDateTimeRange ? /* @__PURE__ */ (0, import_jsx_runtime43.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_runtime43.jsxs)("small", { children: [
|
|
10873
|
+
"\u6700\u591A\u9009\u62E9 ",
|
|
10874
|
+
maxRangeDays,
|
|
10875
|
+
" \u5929"
|
|
10876
|
+
] }) : null
|
|
10877
|
+
] }),
|
|
10878
|
+
onToday: () => {
|
|
10879
|
+
const now = /* @__PURE__ */ new Date();
|
|
10880
|
+
const day = dateKey(now);
|
|
10881
|
+
if (isDisabled(day, activeIndex, Boolean(showTime))) return;
|
|
10882
|
+
setViewMonth(startOfMonth(now));
|
|
10883
|
+
selectDate(day);
|
|
10884
|
+
},
|
|
10885
|
+
onConfirm: confirm
|
|
10886
|
+
}
|
|
10887
|
+
)
|
|
10888
|
+
]
|
|
10889
|
+
}
|
|
10890
|
+
)
|
|
10562
10891
|
] });
|
|
10563
10892
|
}
|
|
10564
10893
|
((DatePicker2) => {
|
|
@@ -13374,6 +13703,7 @@ function registerSqlLanguages(monaco) {
|
|
|
13374
13703
|
// src/components/Editor.tsx
|
|
13375
13704
|
var import_jsx_runtime52 = require("react/jsx-runtime");
|
|
13376
13705
|
var EDITOR_COMMAND_SHORTCUTS = {
|
|
13706
|
+
undo: "Ctrl+Z",
|
|
13377
13707
|
cut: "Ctrl+X",
|
|
13378
13708
|
copy: "Ctrl+C",
|
|
13379
13709
|
paste: "Ctrl+V",
|
|
@@ -13718,6 +14048,7 @@ function Editor({
|
|
|
13718
14048
|
});
|
|
13719
14049
|
const api = {
|
|
13720
14050
|
focus: () => editor.focus(),
|
|
14051
|
+
canUndo: () => model.canUndo(),
|
|
13721
14052
|
getValue: () => model.getValue(),
|
|
13722
14053
|
getSelection: () => {
|
|
13723
14054
|
const selection = editor.getSelection();
|
|
@@ -13998,6 +14329,7 @@ function Editor({
|
|
|
13998
14329
|
editor.focus();
|
|
13999
14330
|
if (item.command) {
|
|
14000
14331
|
const commandId = {
|
|
14332
|
+
undo: "undo",
|
|
14001
14333
|
cut: "editor.action.clipboardCutAction",
|
|
14002
14334
|
copy: "editor.action.clipboardCopyAction",
|
|
14003
14335
|
paste: "editor.action.clipboardPasteAction",
|
|
@@ -28059,6 +28391,7 @@ function useQueryFormSettings(config, fields, defaultCollapsed, applyCollapsed,
|
|
|
28059
28391
|
if (request !== token.current) return;
|
|
28060
28392
|
setLoadFailed(true);
|
|
28061
28393
|
setError(reason instanceof Error ? reason.message : "\u8BFB\u53D6\u67E5\u8BE2\u8BBE\u7F6E\u5931\u8D25");
|
|
28394
|
+
if (!edit) message.warning("\u67E5\u8BE2\u8BBE\u7F6E\u8BFB\u53D6\u5931\u8D25\uFF0C\u8BF7\u6253\u5F00\u8BBE\u7F6E\u91CD\u8BD5");
|
|
28062
28395
|
current.config.onError?.(reason, "load");
|
|
28063
28396
|
} finally {
|
|
28064
28397
|
if (request === token.current) setLoading(false);
|
|
@@ -28136,53 +28469,50 @@ function useQueryFormSettings(config, fields, defaultCollapsed, applyCollapsed,
|
|
|
28136
28469
|
}
|
|
28137
28470
|
}
|
|
28138
28471
|
) : null;
|
|
28139
|
-
const panel = config ? /* @__PURE__ */ (0, import_jsx_runtime103.
|
|
28140
|
-
|
|
28141
|
-
|
|
28142
|
-
|
|
28143
|
-
|
|
28144
|
-
|
|
28145
|
-
|
|
28146
|
-
|
|
28147
|
-
|
|
28148
|
-
|
|
28149
|
-
|
|
28150
|
-
|
|
28151
|
-
|
|
28152
|
-
|
|
28153
|
-
},
|
|
28154
|
-
|
|
28155
|
-
|
|
28156
|
-
|
|
28157
|
-
|
|
28158
|
-
|
|
28159
|
-
|
|
28160
|
-
|
|
28161
|
-
|
|
28162
|
-
|
|
28163
|
-
"
|
|
28164
|
-
{
|
|
28165
|
-
|
|
28166
|
-
|
|
28167
|
-
|
|
28168
|
-
|
|
28169
|
-
|
|
28170
|
-
|
|
28171
|
-
|
|
28172
|
-
/* @__PURE__ */ (0, import_jsx_runtime103.jsx)("
|
|
28173
|
-
/* @__PURE__ */ (0, import_jsx_runtime103.
|
|
28174
|
-
|
|
28175
|
-
|
|
28176
|
-
|
|
28177
|
-
|
|
28178
|
-
|
|
28179
|
-
|
|
28180
|
-
|
|
28181
|
-
|
|
28182
|
-
|
|
28183
|
-
}
|
|
28184
|
-
)
|
|
28185
|
-
] }) : null;
|
|
28472
|
+
const panel = config ? /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(import_jsx_runtime103.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
|
|
28473
|
+
Modal2,
|
|
28474
|
+
{
|
|
28475
|
+
title: "\u67E5\u8BE2\u8BBE\u7F6E",
|
|
28476
|
+
open,
|
|
28477
|
+
width: 520,
|
|
28478
|
+
okText: "\u4FDD\u5B58",
|
|
28479
|
+
confirmLoading: saving,
|
|
28480
|
+
okButtonProps: { disabled: locked },
|
|
28481
|
+
onOk: save,
|
|
28482
|
+
onOpenChange: (next) => {
|
|
28483
|
+
if (!saveLock.current) setOpen(next);
|
|
28484
|
+
},
|
|
28485
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)("div", { className: "sia-query-settings", children: [
|
|
28486
|
+
loading ? /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("p", { role: "status", children: "\u6B63\u5728\u8BFB\u53D6\u67E5\u8BE2\u8BBE\u7F6E\u2026" }) : null,
|
|
28487
|
+
error ? /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)("div", { role: "alert", className: "sia-query-form__error", children: [
|
|
28488
|
+
error,
|
|
28489
|
+
loadFailed ? /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(Button, { type: "button", variant: "link", onClick: () => void load(true), children: "\u91CD\u8BD5" }) : null
|
|
28490
|
+
] }) : null,
|
|
28491
|
+
/* @__PURE__ */ (0, import_jsx_runtime103.jsx)(Checkbox2, { checked: draft.defaultCollapsed, disabled: locked, onChange: (checked) => setDraft((current) => ({ ...current, defaultCollapsed: checked })), children: "\u9ED8\u8BA4\u6536\u8D77\u67E5\u8BE2\u6761\u4EF6" }),
|
|
28492
|
+
/* @__PURE__ */ (0, import_jsx_runtime103.jsx)("p", { className: "sia-query-settings__hint", children: "\u52FE\u9009\u9700\u8981\u663E\u793A\u7684\u6761\u4EF6\uFF0C\u62D6\u52A8\u6216\u4F7F\u7528\u4E0A\u4E0B\u6309\u94AE\u8C03\u6574\u987A\u5E8F\u3002" }),
|
|
28493
|
+
/* @__PURE__ */ (0, import_jsx_runtime103.jsx)("div", { ref: sort.listRef, className: `sia-query-settings__list${sort.preview ? " is-sorting" : ""}`, children: visibleDraft.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)(
|
|
28494
|
+
"div",
|
|
28495
|
+
{
|
|
28496
|
+
"data-query-field-key": item.key,
|
|
28497
|
+
className: `sia-query-settings__item${sort.preview?.key === item.key ? " is-dragging" : ""}${locked ? " is-disabled" : ""}`,
|
|
28498
|
+
style: sort.preview ? { transform: `translateY(${sort.preview.offsets[item.key] ?? 0}px)` } : void 0,
|
|
28499
|
+
onPointerDown: (event) => sort.start(event, item.key),
|
|
28500
|
+
children: [
|
|
28501
|
+
/* @__PURE__ */ (0, import_jsx_runtime103.jsx)(Icon, { name: "menu", size: 15 }),
|
|
28502
|
+
/* @__PURE__ */ (0, import_jsx_runtime103.jsx)(Checkbox2, { "aria-label": `\u663E\u793A ${item.key}`, checked: item.visible, disabled: locked || hideDisabledKeys.has(item.key), onChange: (checked) => setDraft((current) => ({ ...current, fields: visibleDraft.map((field) => field.key === item.key ? { ...field, visible: checked } : field) })) }),
|
|
28503
|
+
/* @__PURE__ */ (0, import_jsx_runtime103.jsx)("span", { className: "sia-query-settings__name", children: labels.get(item.key) ?? item.key }),
|
|
28504
|
+
/* @__PURE__ */ (0, import_jsx_runtime103.jsxs)("div", { className: "sia-query-settings__order", children: [
|
|
28505
|
+
/* @__PURE__ */ (0, import_jsx_runtime103.jsx)(Button, { type: "button", size: "small", variant: "text", "aria-label": `\u4E0A\u79FB ${item.key}`, disabled: locked || index === 0, icon: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(Icon, { name: "chevron-up" }), onClick: () => move(index, index - 1) }),
|
|
28506
|
+
/* @__PURE__ */ (0, import_jsx_runtime103.jsx)(Button, { type: "button", size: "small", variant: "text", "aria-label": `\u4E0B\u79FB ${item.key}`, disabled: locked || index === visibleDraft.length - 1, icon: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(Icon, { name: "chevron-down" }), onClick: () => move(index, index + 1) })
|
|
28507
|
+
] })
|
|
28508
|
+
]
|
|
28509
|
+
},
|
|
28510
|
+
item.key
|
|
28511
|
+
)) }),
|
|
28512
|
+
/* @__PURE__ */ (0, import_jsx_runtime103.jsx)(Button, { type: "button", disabled: locked, onClick: () => setDraft({ fields: reconcileQueryFields(fields.map((field) => field.key)), defaultCollapsed: defaultCollapsed ?? false }), children: "\u6062\u590D\u9ED8\u8BA4" })
|
|
28513
|
+
] })
|
|
28514
|
+
}
|
|
28515
|
+
) }) : null;
|
|
28186
28516
|
return { snapshot, control, panel };
|
|
28187
28517
|
}
|
|
28188
28518
|
|