@sia.soul/sia-react-ui 0.1.160 → 0.1.163

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/{Select-DIdEbGwf.d.cts → Select-Dxevc0f6.d.cts} +1 -1
  2. package/dist/{Select-BCVUoK0I.d.ts → Select-tsENCXQI.d.ts} +1 -1
  3. package/dist/chart.cjs +10 -10
  4. package/dist/chart.js +5 -5
  5. package/dist/{chunk-EMBCJFJM.js → chunk-23FQ5ARA.js} +4 -4
  6. package/dist/{chunk-H6UTSSZM.js → chunk-2EC653G5.js} +5 -5
  7. package/dist/{chunk-SRWUDTCS.js → chunk-CUAXJCSH.js} +10 -10
  8. package/dist/{chunk-KDIJYXKW.js → chunk-DKQ5UCN6.js} +618 -273
  9. package/dist/{chunk-ZIH5VLPT.js → chunk-G5EJJFUI.js} +2 -2
  10. package/dist/{chunk-NRLIOMXY.js → chunk-J6BPKBEL.js} +2 -2
  11. package/dist/{chunk-6SSZVJO4.js → chunk-NHGCGOF2.js} +3 -3
  12. package/dist/{chunk-YO5OJQEH.js → chunk-OHAESA5R.js} +1 -1
  13. package/dist/{chunk-PU2V3VB5.js → chunk-PAWEP65C.js} +1 -1
  14. package/dist/{chunk-REAWVQH2.js → chunk-SX4LLT3H.js} +5 -5
  15. package/dist/{chunk-XXFYFLZA.js → chunk-V4I32DPL.js} +2 -2
  16. package/dist/{chunk-P5ZCOIKQ.js → chunk-WR5YBY2A.js} +6 -6
  17. package/dist/{core--AEiGVOU.d.ts → core-XtqUDbbD.d.ts} +3 -3
  18. package/dist/{core-DolUEUCo.d.cts → core-r-smfiNN.d.cts} +3 -3
  19. package/dist/core.cjs +10 -10
  20. package/dist/core.css +245 -29
  21. package/dist/core.d.cts +2 -2
  22. package/dist/core.d.ts +2 -2
  23. package/dist/core.js +8 -8
  24. package/dist/game.cjs +10 -10
  25. package/dist/game.js +3 -3
  26. package/dist/index.cjs +666 -320
  27. package/dist/index.css +245 -29
  28. package/dist/index.d.cts +13 -8
  29. package/dist/index.d.ts +13 -8
  30. package/dist/index.js +60 -59
  31. package/dist/markdown-editor.cjs +10 -10
  32. package/dist/markdown-editor.js +3 -3
  33. package/dist/rich-text-editor.cjs +10 -10
  34. package/dist/rich-text-editor.js +7 -7
  35. package/dist/{select-date-range-CIwE5nFu.d.cts → select-date-range-C9lTBQFX.d.cts} +10 -11
  36. package/dist/{select-date-range-DYrA87Tl.d.ts → select-date-range-CQCGGkkt.d.ts} +10 -11
  37. package/dist/select-date-range.cjs +618 -273
  38. package/dist/select-date-range.d.cts +2 -2
  39. package/dist/select-date-range.d.ts +2 -2
  40. package/dist/select-date-range.js +8 -8
  41. 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.88;
728
- var popupTravelOffset = 6;
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.11, 1.085)", offset: 0.68 },
738
- { opacity: 1, transform: "scale(.945, .965)", offset: 0.86 },
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.065)`, offset: 0.68 },
759
- { transform: `translate${axis}(0) scale${axis}(.975)`, offset: 0.86 },
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 ? 18 : -6}px) scale(${modal ? 0.9 : 0.88})`, offset: 0 },
766
- { opacity: 1, transform: modal ? "scale(1.075, 1.05)" : "scale(1.11, 1.085)", offset: 0.68 },
767
- { opacity: 1, transform: modal ? "scale(.965, .98)" : "scale(.945, .965)", offset: 0.86 },
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
  }
@@ -982,7 +982,7 @@ var PopupPortal = (0, import_react4.forwardRef)(function PopupPortal2({
982
982
  cancelAnimationFrame(frame);
983
983
  observer.disconnect();
984
984
  };
985
- }, [anchorRef, offset, motion.present, placement, viewportPadding]);
985
+ }, [anchorRef, offset, motion.present, placement, viewportPadding, position?.availableHeight, position?.placement]);
986
986
  if (!motion.present || typeof document === "undefined") return null;
987
987
  return (0, import_react_dom.createPortal)(
988
988
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
@@ -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,63 @@ 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)("div", { className: "sia-date-panel__month", children: [
9770
- /* @__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)) }),
9771
- /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: "sia-date-panel__days", children: Array.from({ length: 42 }, (_, index) => {
9772
- const date = addDays(gridStart, index);
9773
- const key = dateKey(date);
9774
- const outside = date.getMonth() !== month.getMonth();
9775
- const disabled = disabledDate?.(key) ?? false;
9776
- const selected = selectedDates.includes(key);
9777
- const rangeStart = Boolean(start && key === start);
9778
- const rangeEnd = Boolean(range[1] && key === range[1]);
9779
- const inRange = Boolean(low && high && key >= low && key <= high);
9780
- return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
9781
- "span",
9782
- {
9783
- 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" : ""}`,
9784
- children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
9785
- "button",
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
+ const segmentStart = inRange && (index % 7 === 0 || key === low);
9839
+ const segmentEnd = inRange && (index % 7 === 6 || key === high);
9840
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
9841
+ "span",
9786
9842
  {
9787
- type: "button",
9788
- "aria-label": key,
9789
- "aria-pressed": selected || rangeStart || rangeEnd || void 0,
9790
- disabled,
9791
- onClick: () => onSelect(key),
9792
- onMouseEnter: () => onHover?.(key),
9793
- children: date.getDate()
9794
- }
9795
- )
9796
- },
9797
- key
9798
- );
9799
- }) })
9800
- ] });
9843
+ className: `sia-date-panel__cell${outside ? " is-outside" : ""}${selected ? " is-selected" : ""}${rangeStart ? " is-range-start" : ""}${rangeEnd ? " is-range-end" : ""}${inRange ? " is-in-range" : ""}${segmentStart ? " is-range-segment-start" : ""}${segmentEnd ? " is-range-segment-end" : ""}${key === today ? " is-today" : ""}`,
9844
+ children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
9845
+ "button",
9846
+ {
9847
+ type: "button",
9848
+ "aria-label": key,
9849
+ "aria-pressed": selected || rangeStart || rangeEnd || void 0,
9850
+ disabled,
9851
+ onClick: () => onSelect(key),
9852
+ onMouseEnter: () => onHover?.(key),
9853
+ children: date.getDate()
9854
+ }
9855
+ )
9856
+ },
9857
+ key
9858
+ );
9859
+ }) })
9860
+ ]
9861
+ }
9862
+ );
9801
9863
  }
9802
9864
  function CalendarHeader({
9803
9865
  month,
9804
9866
  label,
9805
9867
  range = false,
9868
+ onTitleClick,
9806
9869
  onPreviousYear,
9807
9870
  onPreviousMonth,
9808
9871
  onNextMonth,
@@ -9816,7 +9879,15 @@ function CalendarHeader({
9816
9879
  ] }) : null,
9817
9880
  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
9881
  ] }),
9819
- /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("strong", { children: [
9882
+ onTitleClick ? /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("button", { type: "button", className: "sia-date-panel__title", "aria-label": "\u9009\u62E9\u5E74\u4EFD", onClick: onTitleClick, children: [
9883
+ label ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("small", { children: label }) : null,
9884
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("span", { children: [
9885
+ month.getFullYear(),
9886
+ "\u5E74\xA0 ",
9887
+ month.getMonth() + 1,
9888
+ "\u6708"
9889
+ ] })
9890
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("strong", { children: [
9820
9891
  label ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("small", { children: label }) : null,
9821
9892
  /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("span", { children: [
9822
9893
  month.getFullYear(),
@@ -9835,36 +9906,146 @@ function CalendarHeader({
9835
9906
  range ? null : null
9836
9907
  ] });
9837
9908
  }
9909
+ var TIME_OPTION_HEIGHT = 32;
9910
+ var TIME_COLUMN_PADDING = 4;
9911
+ function TimeColumn({
9912
+ ariaLabel,
9913
+ columnIndex,
9914
+ count,
9915
+ value,
9916
+ siblings,
9917
+ use12Hours = false,
9918
+ unit = "",
9919
+ unitLabels = false,
9920
+ disabledTime,
9921
+ onSelect
9922
+ }) {
9923
+ const listRef = (0, import_react45.useRef)(null);
9924
+ const drag = (0, import_react45.useRef)({ startY: 0, startScroll: 0, pointerId: -1, dragging: false, samples: [], velocity: 0, frame: 0 });
9925
+ (0, import_react45.useLayoutEffect)(() => {
9926
+ const column = listRef.current;
9927
+ const selected = column?.querySelector('[aria-selected="true"]');
9928
+ const first = column?.firstElementChild;
9929
+ if (!column || !selected || !first) return;
9930
+ const top = selected.offsetTop - first.offsetTop + parseFloat(getComputedStyle(column).paddingTop || "0");
9931
+ const bottom = top + selected.offsetHeight;
9932
+ if (top < column.scrollTop || bottom > column.scrollTop + column.clientHeight) {
9933
+ column.scrollTop = Math.max(0, top - (column.clientHeight - selected.offsetHeight) / 2);
9934
+ }
9935
+ }, [value, count]);
9936
+ (0, import_react45.useEffect)(() => () => cancelAnimationFrame(drag.current.frame), []);
9937
+ function stopWithSnap() {
9938
+ const column = listRef.current;
9939
+ if (!column) return;
9940
+ const snapped = Math.round((column.scrollTop - TIME_COLUMN_PADDING) / TIME_OPTION_HEIGHT) * TIME_OPTION_HEIGHT + TIME_COLUMN_PADDING;
9941
+ const max = column.scrollHeight - column.clientHeight;
9942
+ column.scrollTo({ top: Math.max(0, Math.min(max, snapped)), behavior: "smooth" });
9943
+ }
9944
+ function onPointerDown(event) {
9945
+ if (event.button !== 0) return;
9946
+ const column = listRef.current;
9947
+ if (!column) return;
9948
+ drag.current = { startY: event.clientY, startScroll: column.scrollTop, pointerId: event.pointerId, dragging: false, samples: [event.timeStamp, event.clientY], velocity: 0, frame: 0 };
9949
+ }
9950
+ function onPointerMove(event) {
9951
+ const state = drag.current;
9952
+ const column = listRef.current;
9953
+ if (state.pointerId !== event.pointerId || !column) return;
9954
+ const dy = event.clientY - state.startY;
9955
+ if (!state.dragging && Math.abs(dy) > 4) {
9956
+ state.dragging = true;
9957
+ try {
9958
+ column.setPointerCapture(event.pointerId);
9959
+ } catch {
9960
+ }
9961
+ }
9962
+ if (!state.dragging) return;
9963
+ column.scrollTop = state.startScroll - dy;
9964
+ state.samples.push(event.timeStamp, event.clientY);
9965
+ while (state.samples.length > 4 && event.timeStamp - state.samples[0] > 100) state.samples.splice(0, 2);
9966
+ }
9967
+ function onPointerUp(event) {
9968
+ const state = drag.current;
9969
+ const column = listRef.current;
9970
+ if (state.pointerId !== event.pointerId || !column) return;
9971
+ state.pointerId = -1;
9972
+ try {
9973
+ column.releasePointerCapture?.(event.pointerId);
9974
+ } catch {
9975
+ }
9976
+ if (!state.dragging) return;
9977
+ const samples = state.samples;
9978
+ const dt = samples[samples.length - 2] - samples[0];
9979
+ const dy = samples[samples.length - 1] - samples[1];
9980
+ let velocity = dt > 4 ? dy / dt : 0;
9981
+ velocity = Math.max(-2.5, Math.min(2.5, velocity));
9982
+ cancelAnimationFrame(state.frame);
9983
+ let last = performance.now();
9984
+ const step = (now) => {
9985
+ const elapsed = Math.min(32, now - last);
9986
+ last = now;
9987
+ column.scrollTop -= velocity * elapsed;
9988
+ velocity *= Math.pow(0.94, elapsed / 16.7);
9989
+ if (Math.abs(velocity) > 0.04) state.frame = requestAnimationFrame(step);
9990
+ else stopWithSnap();
9991
+ };
9992
+ state.frame = requestAnimationFrame(step);
9993
+ }
9994
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(import_jsx_runtime42.Fragment, { children: [
9995
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
9996
+ "div",
9997
+ {
9998
+ ref: listRef,
9999
+ role: "listbox",
10000
+ "aria-label": ariaLabel,
10001
+ onPointerDown,
10002
+ onPointerMove,
10003
+ onPointerUp,
10004
+ onPointerCancel: onPointerUp,
10005
+ onClickCapture: (event) => {
10006
+ if (!drag.current.dragging) return;
10007
+ event.preventDefault();
10008
+ event.stopPropagation();
10009
+ drag.current.dragging = false;
10010
+ },
10011
+ children: Array.from({ length: count }, (_, index) => {
10012
+ const next = pad2(index);
10013
+ const candidate = [...siblings];
10014
+ candidate[columnIndex] = next;
10015
+ const selected = next === value;
10016
+ 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) => {
10017
+ if (!["ArrowDown", "ArrowUp", "Home", "End"].includes(event.key)) return;
10018
+ event.preventDefault();
10019
+ const buttons = Array.from(event.currentTarget.parentElement.querySelectorAll("button:not(:disabled)"));
10020
+ const position = buttons.indexOf(event.currentTarget);
10021
+ 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)));
10022
+ buttons[target]?.focus();
10023
+ }, onClick: () => onSelect(next), children: [
10024
+ use12Hours && columnIndex === 0 ? `${pad2(index % 12 || 12)} ${index < 12 ? "AM" : "PM"}` : next,
10025
+ unitLabels && selected ? unit : ""
10026
+ ] }, next);
10027
+ })
10028
+ }
10029
+ ),
10030
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(FloatingScrollbarProvider, { targetRef: listRef })
10031
+ ] });
10032
+ }
9838
10033
  function TimePanel({
9839
10034
  value,
9840
10035
  showSecond = false,
9841
10036
  ariaLabel = "\u65F6\u95F4",
9842
10037
  disabledTime,
9843
10038
  use12Hours = false,
10039
+ title,
10040
+ unitLabels = false,
9844
10041
  onChange
9845
10042
  }) {
9846
10043
  const [hour = "00", minute = "00", second = "00"] = value.split(":");
9847
- const columnsRef = (0, import_react45.useRef)(null);
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]);
10044
+ const siblings = [hour, minute, second];
9864
10045
  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 }] : []
10046
+ { label: "\u5C0F\u65F6", unit: "\u65F6", value: hour, count: 24, index: 0 },
10047
+ { label: "\u5206\u949F", unit: "\u5206", value: minute, count: 60, index: 1 },
10048
+ ...showSecond ? [{ label: "\u79D2", unit: "\u79D2", value: second, count: 60, index: 2 }] : []
9868
10049
  ];
9869
10050
  function update(index, next) {
9870
10051
  const values = [hour, minute, second];
@@ -9872,27 +10053,29 @@ function TimePanel({
9872
10053
  onChange(values.join(":"));
9873
10054
  }
9874
10055
  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: [
10056
+ 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
10057
  use12Hours ? pad2(Number(hour) % 12 || 12) : hour,
9877
10058
  ":",
9878
10059
  minute,
9879
10060
  showSecond ? `:${second}` : "",
9880
10061
  use12Hours ? Number(hour) < 12 ? " AM" : " PM" : ""
9881
10062
  ] }),
9882
- /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { ref: columnsRef, className: "sia-date-panel__time-columns", children: columns.map((column) => /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { ref: columnRefs[column.index], role: "listbox", "aria-label": `${ariaLabel}${column.label}`, children: Array.from({ length: column.count }, (_, index) => {
9883
- const next = pad2(index);
9884
- const candidate = [hour, minute, second];
9885
- candidate[column.index] = next;
9886
- return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("button", { type: "button", role: "option", disabled: disabledTime?.(candidate.join(":")), "aria-selected": next === column.value, className: next === column.value ? "is-selected" : "", onKeyDown: (event) => {
9887
- if (!["ArrowDown", "ArrowUp", "Home", "End"].includes(event.key)) return;
9888
- event.preventDefault();
9889
- const buttons = Array.from(event.currentTarget.parentElement.querySelectorAll("button:not(:disabled)"));
9890
- const position = buttons.indexOf(event.currentTarget);
9891
- 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)));
9892
- buttons[target]?.focus();
9893
- }, onClick: () => update(column.index, next), children: use12Hours && column.index === 0 ? `${pad2(index % 12 || 12)} ${index < 12 ? "AM" : "PM"}` : next }, next);
9894
- }) }, column.label)) }),
9895
- columns.map((column) => /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(FloatingScrollbarProvider, { targetRef: columnRefs[column.index] }, column.index))
10063
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: "sia-date-panel__time-columns", children: columns.map((column) => /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10064
+ TimeColumn,
10065
+ {
10066
+ ariaLabel: `${ariaLabel}${column.label}`,
10067
+ columnIndex: column.index,
10068
+ count: column.count,
10069
+ value: column.value,
10070
+ siblings,
10071
+ use12Hours,
10072
+ unit: column.unit,
10073
+ unitLabels,
10074
+ disabledTime,
10075
+ onSelect: (next) => update(column.index, next)
10076
+ },
10077
+ column.label
10078
+ )) })
9896
10079
  ] });
9897
10080
  }
9898
10081
  function DatePanelFooter({
@@ -9912,6 +10095,50 @@ function DatePanelFooter({
9912
10095
  needConfirm ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("button", { type: "button", className: "sia-date-panel__confirm", disabled: disabledConfirm, onClick: onConfirm, children: confirmText }) : null
9913
10096
  ] });
9914
10097
  }
10098
+ function DateTimePanelFooter({
10099
+ date,
10100
+ time,
10101
+ view,
10102
+ disabled = false,
10103
+ extra,
10104
+ onSwitchDate,
10105
+ onSwitchTime,
10106
+ onClearTime
10107
+ }) {
10108
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("footer", { className: "sia-date-panel__footer sia-date-panel__footer--datetime", children: [
10109
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("span", { children: [
10110
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("button", { type: "button", className: "sia-date-panel__chip", "aria-pressed": view === "date" || void 0, disabled, onClick: onSwitchDate, children: [
10111
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Icon, { name: "calendar", size: 14, "aria-hidden": "true" }),
10112
+ date
10113
+ ] }),
10114
+ extra
10115
+ ] }),
10116
+ /* @__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: [
10117
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Icon, { name: "clock", size: 14, "aria-hidden": "true" }),
10118
+ time,
10119
+ onClearTime && !disabled ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
10120
+ "span",
10121
+ {
10122
+ role: "button",
10123
+ tabIndex: 0,
10124
+ "aria-label": "\u6E05\u7A7A\u65F6\u95F4",
10125
+ className: "sia-date-panel__chip-clear",
10126
+ onClick: (event) => {
10127
+ event.stopPropagation();
10128
+ onClearTime();
10129
+ },
10130
+ onKeyDown: (event) => {
10131
+ if (event.key !== "Enter" && event.key !== " ") return;
10132
+ event.preventDefault();
10133
+ event.stopPropagation();
10134
+ onClearTime();
10135
+ },
10136
+ children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Icon, { name: "circle-close", variant: "filled", size: 13, "aria-hidden": "true" })
10137
+ }
10138
+ ) : null
10139
+ ] })
10140
+ ] });
10141
+ }
9915
10142
 
9916
10143
  // src/components/DatePicker.tsx
9917
10144
  var import_jsx_runtime43 = require("react/jsx-runtime");
@@ -9961,6 +10188,12 @@ function resolvePreset(value) {
9961
10188
  function resolveRangePreset(value) {
9962
10189
  return typeof value === "function" ? value() : value;
9963
10190
  }
10191
+ function hasExplicitTime(value) {
10192
+ return /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}/.test(String(value ?? ""));
10193
+ }
10194
+ function isZeroTime(time, showSecond) {
10195
+ return showSecond ? time === "00:00:00" : time.slice(0, 5) === "00:00";
10196
+ }
9964
10197
  function DatePicker({
9965
10198
  value,
9966
10199
  defaultValue,
@@ -10000,7 +10233,11 @@ function DatePicker({
10000
10233
  const firstCurrent = Array.isArray(currentValue) ? currentValue[0] : currentValue;
10001
10234
  const [viewMonth, setViewMonth] = (0, import_react46.useState)(() => startOfMonth(parseDate2(dayFromValue(firstCurrent)) ?? /* @__PURE__ */ new Date()));
10002
10235
  const [draftTime, setDraftTime] = (0, import_react46.useState)(() => timePart(firstCurrent, defaultTimeFrom(showTime)));
10003
- const resolvedNeedConfirm = needConfirm ?? Boolean(showTime);
10236
+ const showTimeDefaultProvided = typeof showTime === "object" && showTime.defaultValue !== void 0;
10237
+ const [timeExplicit, setTimeExplicit] = (0, import_react46.useState)(() => showTimeDefaultProvided || hasExplicitTime(typeof initialValue === "string" ? initialValue : void 0));
10238
+ const [dateTimeView, setDateTimeView] = (0, import_react46.useState)("date");
10239
+ const [yearDrill, setYearDrill] = (0, import_react46.useState)(false);
10240
+ const resolvedNeedConfirm = showTime ? false : Boolean(needConfirm);
10004
10241
  const showSecond = showSecondFrom(showTime);
10005
10242
  const selectedDates = (0, import_react46.useMemo)(() => {
10006
10243
  const values = Array.isArray(draftValue) ? draftValue : draftValue ? [draftValue] : [];
@@ -10021,6 +10258,9 @@ function DatePicker({
10021
10258
  const current = Array.isArray(currentValue) ? currentValue[0] : currentValue;
10022
10259
  setViewMonth(startOfMonth(parseDate2(dayFromValue(current)) ?? /* @__PURE__ */ new Date()));
10023
10260
  setDraftTime(timePart(current, defaultTimeFrom(showTime)));
10261
+ setTimeExplicit(showTimeDefaultProvided || hasExplicitTime(typeof current === "string" ? current : void 0));
10262
+ setDateTimeView("date");
10263
+ setYearDrill(false);
10024
10264
  }
10025
10265
  setVisible(next);
10026
10266
  }
@@ -10032,9 +10272,11 @@ function DatePicker({
10032
10272
  if (maximum && day.slice(0, length) > String(maximum).slice(0, length)) return true;
10033
10273
  return disabledDate?.(day, { type: "date" }) ?? false;
10034
10274
  }
10035
- function buildValue(day, time = draftTime) {
10275
+ function buildValue(day, time = draftTime, explicit = timeExplicit) {
10036
10276
  const picked = formatPickerValue(day, picker);
10037
- return showTime && picker === "date" ? withTime(picked, time, showSecond) : picked;
10277
+ if (!(showTime && picker === "date")) return picked;
10278
+ if (!explicit && isZeroTime(time, showSecond)) return picked;
10279
+ return withTime(picked, time, showSecond);
10038
10280
  }
10039
10281
  function selectDate(day, time = draftTime, ensureSelected = false) {
10040
10282
  if (isDisabled(day)) return;
@@ -10050,7 +10292,7 @@ function DatePicker({
10050
10292
  setDraftValue(nextValue);
10051
10293
  if (!resolvedNeedConfirm) {
10052
10294
  setCurrentValue(nextValue);
10053
- changeOpen(false);
10295
+ if (!showTime) changeOpen(false);
10054
10296
  }
10055
10297
  }
10056
10298
  function commitDraft() {
@@ -10059,6 +10301,72 @@ function DatePicker({
10059
10301
  setCurrentValue(draftValue);
10060
10302
  changeOpen(false);
10061
10303
  }
10304
+ function applyDraftTime(next) {
10305
+ setDraftTime(next);
10306
+ setTimeExplicit(true);
10307
+ const day = typeof draftValue === "string" ? dayFromValue(draftValue) : "";
10308
+ if (!day) return;
10309
+ const nextValue = withTime(day, next, showSecond);
10310
+ setDraftValue(nextValue);
10311
+ setCurrentValue(nextValue);
10312
+ }
10313
+ function clearDraftTime() {
10314
+ setDraftTime("00:00:00");
10315
+ setTimeExplicit(false);
10316
+ const day = typeof draftValue === "string" ? dayFromValue(draftValue) : "";
10317
+ if (!day) return;
10318
+ setDraftValue(day);
10319
+ setCurrentValue(day);
10320
+ }
10321
+ function renderCalendarSection() {
10322
+ return picker === "year" || yearDrill ? /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(import_jsx_runtime43.Fragment, { children: [
10323
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "sia-date-panel__header", children: [
10324
+ /* @__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 }) }) }),
10325
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("strong", { children: [
10326
+ Math.floor(viewMonth.getFullYear() / 10) * 10,
10327
+ "\u5E74 \u2014 ",
10328
+ Math.floor(viewMonth.getFullYear() / 10) * 10 + 9,
10329
+ "\u5E74"
10330
+ ] }),
10331
+ /* @__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 }) }) })
10332
+ ] }),
10333
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "sia-date-panel__years", children: Array.from({ length: 10 }, (_, index) => {
10334
+ const year = String(Math.floor(viewMonth.getFullYear() / 10) * 10 + index);
10335
+ const day = `${year}-01-01`;
10336
+ const selected = selectedDates.some((value2) => value2.slice(0, 4) === year);
10337
+ 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: () => {
10338
+ if (yearDrill) {
10339
+ setViewMonth(new Date(Number(year), viewMonth.getMonth(), 1));
10340
+ setYearDrill(false);
10341
+ } else {
10342
+ selectDate(day);
10343
+ }
10344
+ }, children: year }) }, year);
10345
+ }) })
10346
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(import_jsx_runtime43.Fragment, { children: [
10347
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
10348
+ CalendarHeader,
10349
+ {
10350
+ month: viewMonth,
10351
+ onTitleClick: picker === "date" ? () => setYearDrill(true) : void 0,
10352
+ onPreviousYear: () => setViewMonth(addMonths(viewMonth, -12)),
10353
+ onPreviousMonth: () => setViewMonth(addMonths(viewMonth, -1)),
10354
+ onNextMonth: () => setViewMonth(addMonths(viewMonth, 1)),
10355
+ onNextYear: () => setViewMonth(addMonths(viewMonth, 12))
10356
+ }
10357
+ ),
10358
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
10359
+ CalendarMonth,
10360
+ {
10361
+ month: viewMonth,
10362
+ selectedDates,
10363
+ disabledDate: isDisabled,
10364
+ onSelect: selectDate,
10365
+ onSwipeMonth: picker === "date" ? (direction) => setViewMonth(addMonths(viewMonth, direction)) : void 0
10366
+ }
10367
+ )
10368
+ ] });
10369
+ }
10062
10370
  function clearValue(event) {
10063
10371
  event.stopPropagation();
10064
10372
  const empty = multiple ? [] : "";
@@ -10098,72 +10406,82 @@ function DatePicker({
10098
10406
  ),
10099
10407
  floating.label,
10100
10408
  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)(PopupPortal, { ref: popupRef, anchorRef: rootRef, open: visible, className: `sia-date-panel${showTime ? " sia-date-panel--with-time" : ""}${presets?.length ? " sia-date-panel--with-presets" : ""}`, role: "dialog", "aria-label": "\u65E5\u671F\u9009\u62E9\u9762\u677F", children: [
10102
- /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "sia-date-panel__body", children: [
10103
- 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: () => {
10104
- const next = resolvePreset(preset2.value);
10105
- if (!next || isDisabled(dayFromValue(next))) return;
10106
- setDraftValue(next);
10107
- if (!resolvedNeedConfirm) {
10108
- setCurrentValue(next);
10409
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
10410
+ PopupPortal,
10411
+ {
10412
+ ref: popupRef,
10413
+ anchorRef: rootRef,
10414
+ open: visible,
10415
+ className: `sia-date-panel${showTime ? " sia-date-panel--datetime" : ""}${presets?.length ? " sia-date-panel--with-presets" : ""}`,
10416
+ role: "dialog",
10417
+ "aria-label": "\u65E5\u671F\u9009\u62E9\u9762\u677F",
10418
+ onKeyDown: (event) => {
10419
+ if (event.key === "Escape") {
10420
+ event.stopPropagation();
10109
10421
  changeOpen(false);
10110
10422
  }
10111
- }, children: preset2.label }, index)) }) : null,
10112
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("section", { className: "sia-date-panel__calendar", children: picker === "year" ? /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(import_jsx_runtime43.Fragment, { children: [
10113
- /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "sia-date-panel__header", children: [
10114
- /* @__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 }) }) }),
10115
- /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("strong", { children: [
10116
- Math.floor(viewMonth.getFullYear() / 10) * 10,
10117
- "\u5E74 \u2014 ",
10118
- Math.floor(viewMonth.getFullYear() / 10) * 10 + 9,
10119
- "\u5E74"
10120
- ] }),
10121
- /* @__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 }) }) })
10423
+ },
10424
+ children: [
10425
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "sia-date-panel__body", children: [
10426
+ 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: () => {
10427
+ const next = resolvePreset(preset2.value);
10428
+ if (!next || isDisabled(dayFromValue(next))) return;
10429
+ setDraftValue(next);
10430
+ setDraftTime(timePart(next, defaultTimeFrom(showTime)));
10431
+ setTimeExplicit(hasExplicitTime(next));
10432
+ if (!resolvedNeedConfirm) {
10433
+ setCurrentValue(next);
10434
+ changeOpen(false);
10435
+ }
10436
+ }, children: preset2.label }, index)) }) : null,
10437
+ showTime ? /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "sia-date-panel__views", children: [
10438
+ /* @__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() }),
10439
+ /* @__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)(
10440
+ TimePanel,
10441
+ {
10442
+ value: draftTime,
10443
+ showSecond,
10444
+ title: "\u9009\u62E9\u65F6\u95F4",
10445
+ unitLabels: true,
10446
+ ariaLabel: "\u9009\u62E9\u65F6\u95F4",
10447
+ onChange: applyDraftTime
10448
+ }
10449
+ ) })
10450
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("section", { className: "sia-date-panel__calendar", children: renderCalendarSection() })
10122
10451
  ] }),
10123
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "sia-date-panel__years", children: Array.from({ length: 10 }, (_, index) => {
10124
- const year = String(Math.floor(viewMonth.getFullYear() / 10) * 10 + index);
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,
10452
+ showTime ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
10453
+ DateTimePanelFooter,
10132
10454
  {
10133
- month: viewMonth,
10134
- onPreviousYear: () => setViewMonth(addMonths(viewMonth, -12)),
10135
- onPreviousMonth: () => setViewMonth(addMonths(viewMonth, -1)),
10136
- onNextMonth: () => setViewMonth(addMonths(viewMonth, 1)),
10137
- onNextYear: () => setViewMonth(addMonths(viewMonth, 12))
10455
+ date: (typeof draftValue === "string" ? dayFromValue(draftValue) : "") || dateKey(/* @__PURE__ */ new Date()),
10456
+ time: showSecond ? draftTime : draftTime.slice(0, 5),
10457
+ view: dateTimeView,
10458
+ extra: renderExtraFooter?.(),
10459
+ onSwitchDate: () => setDateTimeView("date"),
10460
+ onSwitchTime: () => setDateTimeView("time"),
10461
+ onClearTime: clearDraftTime
10138
10462
  }
10139
- ),
10140
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(CalendarMonth, { month: viewMonth, selectedDates, disabledDate: isDisabled, onSelect: selectDate })
10141
- ] }) }),
10142
- showTime ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(TimePanel, { value: draftTime, showSecond, onChange: (next) => {
10143
- setDraftTime(next);
10144
- if (typeof draftValue === "string" && draftValue) setDraftValue(withTime(dayFromValue(draftValue), next, showSecond));
10145
- } }) : null
10146
- ] }),
10147
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
10148
- DatePanelFooter,
10149
- {
10150
- extra: renderExtraFooter?.(),
10151
- showToday,
10152
- needConfirm: resolvedNeedConfirm,
10153
- disabledConfirm: Array.isArray(draftValue) ? draftValue.length === 0 : !draftValue,
10154
- onToday: () => {
10155
- const now = /* @__PURE__ */ new Date();
10156
- const day = dateKey(now);
10157
- if (isDisabled(day)) return;
10158
- const time = [now.getHours(), now.getMinutes(), now.getSeconds()].map(pad2).join(":");
10159
- if (showTime) setDraftTime(time);
10160
- setViewMonth(startOfMonth(now));
10161
- selectDate(day, time, true);
10162
- },
10163
- onConfirm: commitDraft
10164
- }
10165
- )
10166
- ] })
10463
+ ) : /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
10464
+ DatePanelFooter,
10465
+ {
10466
+ extra: renderExtraFooter?.(),
10467
+ showToday,
10468
+ needConfirm: resolvedNeedConfirm,
10469
+ disabledConfirm: Array.isArray(draftValue) ? draftValue.length === 0 : !draftValue,
10470
+ onToday: () => {
10471
+ const now = /* @__PURE__ */ new Date();
10472
+ const day = dateKey(now);
10473
+ if (isDisabled(day)) return;
10474
+ const time = [now.getHours(), now.getMinutes(), now.getSeconds()].map(pad2).join(":");
10475
+ if (showTime) setDraftTime(time);
10476
+ setViewMonth(startOfMonth(now));
10477
+ selectDate(day, time, true);
10478
+ },
10479
+ onConfirm: commitDraft
10480
+ }
10481
+ )
10482
+ ]
10483
+ }
10484
+ )
10167
10485
  ] });
10168
10486
  }
10169
10487
  function DateRangePicker({
@@ -10223,11 +10541,10 @@ function DateRangePicker({
10223
10541
  }
10224
10542
  return () => observer.disconnect();
10225
10543
  });
10226
- const [confirmedIndex, setConfirmedIndex] = (0, import_react46.useState)(null);
10227
- const [presetSelected, setPresetSelected] = (0, import_react46.useState)(false);
10544
+ const [dateTimeViews, setDateTimeViews] = (0, import_react46.useState)(["date", "date"]);
10228
10545
  const [hoverDate, setHoverDate] = (0, import_react46.useState)("");
10229
10546
  const [viewMonth, setViewMonth] = (0, import_react46.useState)(() => startOfMonth(parseDate2(dayFromValue(currentValue[0] || currentValue[1])) ?? /* @__PURE__ */ new Date()));
10230
- const [endViewMonth, setEndViewMonth] = (0, import_react46.useState)(() => startOfMonth(parseDate2(dayFromValue(currentValue[1])) ?? addMonths(parseDate2(dayFromValue(currentValue[0])) ?? /* @__PURE__ */ new Date(), 1)));
10547
+ const [endViewMonth, setEndViewMonth] = (0, import_react46.useState)(() => startOfMonth(parseDate2(dayFromValue(currentValue[1])) ?? (showTime ? parseDate2(dayFromValue(currentValue[0])) ?? /* @__PURE__ */ new Date() : addMonths(parseDate2(dayFromValue(currentValue[0])) ?? /* @__PURE__ */ new Date(), 1))));
10231
10548
  const showSecond = showSecondFrom(showTime);
10232
10549
  const defaultTime = defaultTimeFrom(showTime);
10233
10550
  const defaultEndTime = defaultTimeFrom(showTime, 1);
@@ -10235,7 +10552,7 @@ function DateRangePicker({
10235
10552
  timePart(currentValue[0], defaultTime),
10236
10553
  timePart(currentValue[1], defaultEndTime)
10237
10554
  ]);
10238
- const resolvedNeedConfirm = needConfirm ?? Boolean(showTime);
10555
+ const resolvedNeedConfirm = showTime ? false : Boolean(needConfirm);
10239
10556
  const rangeDates = [dayFromValue(draftValue[0]), dayFromValue(draftValue[1])];
10240
10557
  const invalidDateTimeRange = Boolean(showTime && draftValue[0] && draftValue[1] && draftValue[0] > draftValue[1]);
10241
10558
  (0, import_react46.useEffect)(() => {
@@ -10252,14 +10569,13 @@ function DateRangePicker({
10252
10569
  }
10253
10570
  function changeOpen(next, endpoint) {
10254
10571
  if (next && !visible) {
10255
- setConfirmedIndex(null);
10256
- setPresetSelected(false);
10257
10572
  setDraftValue(currentValue);
10258
10573
  setTimes([timePart(currentValue[0], defaultTime), timePart(currentValue[1], defaultEndTime)]);
10259
10574
  setActiveIndex(endpointDisabled[0] ? 1 : endpointDisabled[1] ? 0 : endpoint ?? (currentValue[0] && !currentValue[1] ? 1 : 0));
10575
+ setDateTimeViews(["date", "date"]);
10260
10576
  const nextStartMonth = startOfMonth(parseDate2(dayFromValue(currentValue[0] || currentValue[1])) ?? /* @__PURE__ */ new Date());
10261
10577
  setViewMonth(nextStartMonth);
10262
- setEndViewMonth(startOfMonth(parseDate2(dayFromValue(currentValue[1])) ?? addMonths(nextStartMonth, 1)));
10578
+ setEndViewMonth(startOfMonth(parseDate2(dayFromValue(currentValue[1])) ?? (showTime ? nextStartMonth : addMonths(nextStartMonth, 1))));
10263
10579
  }
10264
10580
  if (next && endpoint !== void 0 && !endpointDisabled[endpoint]) setActiveIndex(endpoint);
10265
10581
  setVisible(next);
@@ -10272,9 +10588,9 @@ function DateRangePicker({
10272
10588
  if (maximum && day > String(maximum).slice(0, 10)) return true;
10273
10589
  const from = index === 1 ? rangeDates[0] : void 0;
10274
10590
  if (dateTimeStep) {
10275
- const otherIndex2 = index === 0 ? 1 : 0;
10276
- const otherEndpoint = rangeDates[otherIndex2];
10277
- if (otherEndpoint && (endpointDisabled[otherIndex2] || confirmedIndex === otherIndex2)) {
10591
+ const otherIndex = index === 0 ? 1 : 0;
10592
+ const otherEndpoint = rangeDates[otherIndex];
10593
+ if (otherEndpoint) {
10278
10594
  if (index === 0 && day > otherEndpoint || index === 1 && day < otherEndpoint) return true;
10279
10595
  if (maxRangeDays && Math.abs(daysBetween(otherEndpoint, day)) >= maxRangeDays) return true;
10280
10596
  }
@@ -10285,10 +10601,9 @@ function DateRangePicker({
10285
10601
  return showTime ? withTime(day, times[index], showSecond) : day;
10286
10602
  }
10287
10603
  function updateDraft(next) {
10288
- setPresetSelected(false);
10289
10604
  setDraftValue(next);
10290
10605
  onCalendarChange?.(next);
10291
- if (!showTime && isValidRange(next) && (next[0] !== currentValue[0] || next[1] !== currentValue[1])) {
10606
+ if (isValidRange(next) && (next[0] !== currentValue[0] || next[1] !== currentValue[1])) {
10292
10607
  setCurrentValue(next);
10293
10608
  }
10294
10609
  }
@@ -10365,19 +10680,7 @@ function DateRangePicker({
10365
10680
  }
10366
10681
  return true;
10367
10682
  }
10368
- const otherIndex = activeIndex === 0 ? 1 : 0;
10369
- const needsOtherConfirmation = Boolean(showTime && !presetSelected && !endpointDisabled[otherIndex] && confirmedIndex !== otherIndex);
10370
10683
  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
10684
  if (!isValidRange(draftValue)) return;
10382
10685
  setCurrentValue(draftValue);
10383
10686
  changeOpen(false);
@@ -10390,13 +10693,11 @@ function DateRangePicker({
10390
10693
  ];
10391
10694
  if (!isValidRange(next)) return;
10392
10695
  updateDraft(next);
10393
- setConfirmedIndex(null);
10394
- setPresetSelected(true);
10395
10696
  setTimes([timePart(next[0], defaultTime), timePart(next[1], defaultEndTime)]);
10396
10697
  const nextStartMonth = startOfMonth(parseDate2(dayFromValue(next[0] || next[1])) ?? /* @__PURE__ */ new Date());
10397
10698
  setViewMonth(nextStartMonth);
10398
- setEndViewMonth(startOfMonth(parseDate2(dayFromValue(next[1])) ?? addMonths(nextStartMonth, 1)));
10399
- if (!showTime && !resolvedNeedConfirm) {
10699
+ setEndViewMonth(startOfMonth(parseDate2(dayFromValue(next[1])) ?? (showTime ? nextStartMonth : addMonths(nextStartMonth, 1))));
10700
+ if (!resolvedNeedConfirm) {
10400
10701
  changeOpen(false);
10401
10702
  }
10402
10703
  }
@@ -10411,49 +10712,66 @@ function DateRangePicker({
10411
10712
  const month = index === 0 ? viewMonth : endViewMonth;
10412
10713
  const setMonth = index === 0 ? setViewMonth : setEndViewMonth;
10413
10714
  const endpointLabel = index === 0 ? "\u5F00\u59CB" : "\u7ED3\u675F";
10414
- return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
10415
- "div",
10416
- {
10417
- className: `sia-date-panel__range-date-time-group${activeIndex === index ? " is-active" : ""}`,
10418
- "aria-label": `${endpointLabel}\u65E5\u671F\u65F6\u95F4`,
10419
- children: [
10420
- /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("section", { className: "sia-date-panel__calendar", children: [
10421
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
10422
- CalendarHeader,
10423
- {
10424
- month,
10425
- label: endpointLabel,
10426
- range: true,
10427
- onPreviousYear: () => setMonth(addMonths(month, -12)),
10428
- onPreviousMonth: () => setMonth(addMonths(month, -1)),
10429
- onNextMonth: () => setMonth(addMonths(month, 1)),
10430
- onNextYear: () => setMonth(addMonths(month, 12))
10431
- }
10432
- ),
10433
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
10434
- CalendarMonth,
10435
- {
10436
- month,
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
- );
10715
+ return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(import_jsx_runtime43.Fragment, { children: [
10716
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
10717
+ CalendarHeader,
10718
+ {
10719
+ month,
10720
+ label: endpointLabel,
10721
+ range: true,
10722
+ onPreviousYear: () => setMonth(addMonths(month, -12)),
10723
+ onPreviousMonth: () => setMonth(addMonths(month, -1)),
10724
+ onNextMonth: () => setMonth(addMonths(month, 1)),
10725
+ onNextYear: () => setMonth(addMonths(month, 12))
10726
+ }
10727
+ ),
10728
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
10729
+ CalendarMonth,
10730
+ {
10731
+ month,
10732
+ range: rangeDates,
10733
+ disabledDate: (day) => isDisabled(day, index, true),
10734
+ onSelect: (day) => selectDateTime(day, index)
10735
+ }
10736
+ )
10737
+ ] });
10738
+ }
10739
+ function switchDateTimeView(index, view) {
10740
+ if (endpointDisabled[index]) return;
10741
+ setActiveIndex(index);
10742
+ setDateTimeViews((previous) => index === 0 ? [view, previous[1]] : [previous[0], view]);
10743
+ }
10744
+ function renderDateTimeEndpoint(index) {
10745
+ const label = index === 0 ? "\u5F00\u59CB" : "\u7ED3\u675F";
10746
+ const view = dateTimeViews[index];
10747
+ return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("section", { className: "sia-date-panel__endpoint", "aria-label": `${label}\u65E5\u671F\u65F6\u95F4`, children: [
10748
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "sia-date-panel__views", children: [
10749
+ /* @__PURE__ */ (0, import_jsx_runtime43.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) }),
10750
+ /* @__PURE__ */ (0, import_jsx_runtime43.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_runtime43.jsx)(
10751
+ TimePanel,
10752
+ {
10753
+ value: times[index],
10754
+ showSecond,
10755
+ title: `\u9009\u62E9${label}\u65F6\u95F4`,
10756
+ unitLabels: true,
10757
+ ariaLabel: `\u9009\u62E9${label}\u65F6\u95F4`,
10758
+ disabledTime: endpointDisabled[index] ? () => true : void 0,
10759
+ onChange: (nextTime) => changeTime(index, nextTime)
10760
+ }
10761
+ ) })
10762
+ ] }),
10763
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
10764
+ DateTimePanelFooter,
10765
+ {
10766
+ date: rangeDates[index] || dateKey(/* @__PURE__ */ new Date()),
10767
+ time: showSecond ? times[index] : times[index].slice(0, 5),
10768
+ view,
10769
+ disabled: endpointDisabled[index],
10770
+ onSwitchDate: () => switchDateTimeView(index, "date"),
10771
+ onSwitchTime: () => switchDateTimeView(index, "time")
10772
+ }
10773
+ )
10774
+ ] }, index);
10457
10775
  }
10458
10776
  const displayValue = visible && allowEmpty.some(Boolean) ? draftValue : currentValue;
10459
10777
  const startFloating = useFloatingPlaceholder({ mode: placeholderMode, placeholder: placeholder[0], filled: Boolean(displayValue[0]), active: visible });
@@ -10498,67 +10816,94 @@ function DateRangePicker({
10498
10816
  }
10499
10817
  ),
10500
10818
  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)(PopupPortal, { ref: popupRef, anchorRef: rootRef, open: visible, className: `sia-date-panel sia-date-panel--range${showTime ? " sia-date-panel--with-time sia-date-panel--range-time-compact" : ""}${presets?.length ? " sia-date-panel--with-presets" : ""}`, role: "dialog", "aria-label": "\u65E5\u671F\u8303\u56F4\u9009\u62E9\u9762\u677F", children: [
10502
- /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "sia-date-panel__body", children: [
10503
- 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,
10504
- showTime ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "sia-date-panel__range-date-time", children: renderDateTimeGroup(activeIndex) }) : /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "sia-date-panel__range-calendars", children: [
10505
- /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("section", { className: "sia-date-panel__calendar", children: [
10506
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
10507
- CalendarHeader,
10508
- {
10509
- month: viewMonth,
10510
- range: true,
10511
- onPreviousYear: () => setViewMonth(addMonths(viewMonth, -12)),
10512
- onPreviousMonth: () => setViewMonth(addMonths(viewMonth, -1))
10513
- }
10514
- ),
10515
- /* @__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 })
10516
- ] }),
10517
- /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("section", { className: "sia-date-panel__calendar", children: [
10518
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
10519
- CalendarHeader,
10520
- {
10521
- month: addMonths(viewMonth, 1),
10522
- range: true,
10523
- onNextMonth: () => setViewMonth(addMonths(viewMonth, 1)),
10524
- onNextYear: () => setViewMonth(addMonths(viewMonth, 12))
10525
- }
10526
- ),
10527
- /* @__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 })
10528
- ] })
10529
- ] })
10530
- ] }),
10531
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
10532
- DatePanelFooter,
10533
- {
10534
- showToday: showToday && !presets?.length,
10535
- needConfirm: Boolean(showTime) || resolvedNeedConfirm || allowEmpty.some(Boolean),
10536
- disabledConfirm: needsOtherConfirmation ? !draftValue[activeIndex] && !allowEmpty[activeIndex] : !isValidRange(draftValue),
10537
- extra: /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(import_jsx_runtime43.Fragment, { children: [
10538
- renderExtraFooter?.(),
10539
- 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: [
10540
- "\u6700\u591A\u9009\u62E9 ",
10541
- maxRangeDays,
10542
- " \u5929"
10543
- ] }) : null
10819
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
10820
+ PopupPortal,
10821
+ {
10822
+ ref: popupRef,
10823
+ anchorRef: rootRef,
10824
+ open: visible,
10825
+ className: `sia-date-panel${showTime ? " sia-date-panel--datetime-range" : " sia-date-panel--range"}${presets?.length ? " sia-date-panel--with-presets" : ""}`,
10826
+ role: "dialog",
10827
+ "aria-label": "\u65E5\u671F\u8303\u56F4\u9009\u62E9\u9762\u677F",
10828
+ onKeyDown: (event) => {
10829
+ if (event.key === "Escape") {
10830
+ event.stopPropagation();
10831
+ dismissPanel();
10832
+ }
10833
+ },
10834
+ children: [
10835
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "sia-date-panel__body", children: [
10836
+ 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,
10837
+ showTime ? /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "sia-date-panel__datetime-endpoints", children: [
10838
+ renderDateTimeEndpoint(0),
10839
+ renderDateTimeEndpoint(1)
10840
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "sia-date-panel__range-calendars", children: [
10841
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("section", { className: "sia-date-panel__calendar", children: [
10842
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
10843
+ CalendarHeader,
10844
+ {
10845
+ month: viewMonth,
10846
+ range: true,
10847
+ onPreviousYear: () => setViewMonth(addMonths(viewMonth, -12)),
10848
+ onPreviousMonth: () => setViewMonth(addMonths(viewMonth, -1))
10849
+ }
10850
+ ),
10851
+ /* @__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 })
10852
+ ] }),
10853
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("section", { className: "sia-date-panel__calendar", children: [
10854
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
10855
+ CalendarHeader,
10856
+ {
10857
+ month: addMonths(viewMonth, 1),
10858
+ range: true,
10859
+ onNextMonth: () => setViewMonth(addMonths(viewMonth, 1)),
10860
+ onNextYear: () => setViewMonth(addMonths(viewMonth, 12))
10861
+ }
10862
+ ),
10863
+ /* @__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 })
10864
+ ] })
10865
+ ] })
10544
10866
  ] }),
10545
- onToday: () => {
10546
- const now = /* @__PURE__ */ new Date();
10547
- const day = dateKey(now);
10548
- if (isDisabled(day, activeIndex, Boolean(showTime))) return;
10549
- if (showTime) {
10550
- const time = [now.getHours(), now.getMinutes(), now.getSeconds()].map(pad2).join(":");
10551
- (activeIndex === 0 ? setViewMonth : setEndViewMonth)(startOfMonth(now));
10552
- selectDateTime(day, activeIndex, time);
10553
- } else {
10554
- setViewMonth(startOfMonth(now));
10555
- selectDate(day);
10867
+ showTime ? renderExtraFooter || invalidDateTimeRange || maxRangeDays ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
10868
+ DatePanelFooter,
10869
+ {
10870
+ showToday: false,
10871
+ extra: /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(import_jsx_runtime43.Fragment, { children: [
10872
+ renderExtraFooter?.(),
10873
+ 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: [
10874
+ "\u6700\u591A\u9009\u62E9 ",
10875
+ maxRangeDays,
10876
+ " \u5929"
10877
+ ] }) : null
10878
+ ] })
10556
10879
  }
10557
- },
10558
- onConfirm: confirm
10559
- }
10560
- )
10561
- ] })
10880
+ ) : null : /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
10881
+ DatePanelFooter,
10882
+ {
10883
+ showToday: showToday && !presets?.length,
10884
+ needConfirm: resolvedNeedConfirm || allowEmpty.some(Boolean),
10885
+ disabledConfirm: !isValidRange(draftValue),
10886
+ extra: /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(import_jsx_runtime43.Fragment, { children: [
10887
+ renderExtraFooter?.(),
10888
+ 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: [
10889
+ "\u6700\u591A\u9009\u62E9 ",
10890
+ maxRangeDays,
10891
+ " \u5929"
10892
+ ] }) : null
10893
+ ] }),
10894
+ onToday: () => {
10895
+ const now = /* @__PURE__ */ new Date();
10896
+ const day = dateKey(now);
10897
+ if (isDisabled(day, activeIndex, Boolean(showTime))) return;
10898
+ setViewMonth(startOfMonth(now));
10899
+ selectDate(day);
10900
+ },
10901
+ onConfirm: confirm
10902
+ }
10903
+ )
10904
+ ]
10905
+ }
10906
+ )
10562
10907
  ] });
10563
10908
  }
10564
10909
  ((DatePicker2) => {
@@ -13374,6 +13719,7 @@ function registerSqlLanguages(monaco) {
13374
13719
  // src/components/Editor.tsx
13375
13720
  var import_jsx_runtime52 = require("react/jsx-runtime");
13376
13721
  var EDITOR_COMMAND_SHORTCUTS = {
13722
+ undo: "Ctrl+Z",
13377
13723
  cut: "Ctrl+X",
13378
13724
  copy: "Ctrl+C",
13379
13725
  paste: "Ctrl+V",
@@ -13718,6 +14064,7 @@ function Editor({
13718
14064
  });
13719
14065
  const api = {
13720
14066
  focus: () => editor.focus(),
14067
+ canUndo: () => model.canUndo(),
13721
14068
  getValue: () => model.getValue(),
13722
14069
  getSelection: () => {
13723
14070
  const selection = editor.getSelection();
@@ -13998,6 +14345,7 @@ function Editor({
13998
14345
  editor.focus();
13999
14346
  if (item.command) {
14000
14347
  const commandId = {
14348
+ undo: "undo",
14001
14349
  cut: "editor.action.clipboardCutAction",
14002
14350
  copy: "editor.action.clipboardCopyAction",
14003
14351
  paste: "editor.action.clipboardPasteAction",
@@ -28059,6 +28407,7 @@ function useQueryFormSettings(config, fields, defaultCollapsed, applyCollapsed,
28059
28407
  if (request !== token.current) return;
28060
28408
  setLoadFailed(true);
28061
28409
  setError(reason instanceof Error ? reason.message : "\u8BFB\u53D6\u67E5\u8BE2\u8BBE\u7F6E\u5931\u8D25");
28410
+ if (!edit) message.warning("\u67E5\u8BE2\u8BBE\u7F6E\u8BFB\u53D6\u5931\u8D25\uFF0C\u8BF7\u6253\u5F00\u8BBE\u7F6E\u91CD\u8BD5");
28062
28411
  current.config.onError?.(reason, "load");
28063
28412
  } finally {
28064
28413
  if (request === token.current) setLoading(false);
@@ -28136,53 +28485,50 @@ function useQueryFormSettings(config, fields, defaultCollapsed, applyCollapsed,
28136
28485
  }
28137
28486
  }
28138
28487
  ) : null;
28139
- const panel = config ? /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)(import_jsx_runtime103.Fragment, { children: [
28140
- !open && error ? /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("span", { className: "sia-query-form__error", role: "alert", children: "\u67E5\u8BE2\u8BBE\u7F6E\u8BFB\u53D6\u5931\u8D25\uFF0C\u8BF7\u6253\u5F00\u8BBE\u7F6E\u91CD\u8BD5" }) : null,
28141
- /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
28142
- Modal2,
28143
- {
28144
- title: "\u67E5\u8BE2\u8BBE\u7F6E",
28145
- open,
28146
- width: 520,
28147
- okText: "\u4FDD\u5B58",
28148
- confirmLoading: saving,
28149
- okButtonProps: { disabled: locked },
28150
- onOk: save,
28151
- onOpenChange: (next) => {
28152
- if (!saveLock.current) setOpen(next);
28153
- },
28154
- children: /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)("div", { className: "sia-query-settings", children: [
28155
- loading ? /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("p", { role: "status", children: "\u6B63\u5728\u8BFB\u53D6\u67E5\u8BE2\u8BBE\u7F6E\u2026" }) : null,
28156
- error ? /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)("div", { role: "alert", className: "sia-query-form__error", children: [
28157
- error,
28158
- loadFailed ? /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(Button, { type: "button", variant: "link", onClick: () => void load(true), children: "\u91CD\u8BD5" }) : null
28159
- ] }) : null,
28160
- /* @__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" }),
28161
- /* @__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" }),
28162
- /* @__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)(
28163
- "div",
28164
- {
28165
- "data-query-field-key": item.key,
28166
- className: `sia-query-settings__item${sort.preview?.key === item.key ? " is-dragging" : ""}${locked ? " is-disabled" : ""}`,
28167
- style: sort.preview ? { transform: `translateY(${sort.preview.offsets[item.key] ?? 0}px)` } : void 0,
28168
- onPointerDown: (event) => sort.start(event, item.key),
28169
- children: [
28170
- /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(Icon, { name: "menu", size: 15 }),
28171
- /* @__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) })) }),
28172
- /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("span", { className: "sia-query-settings__name", children: labels.get(item.key) ?? item.key }),
28173
- /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)("div", { className: "sia-query-settings__order", children: [
28174
- /* @__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) }),
28175
- /* @__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) })
28176
- ] })
28177
- ]
28178
- },
28179
- item.key
28180
- )) }),
28181
- /* @__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" })
28182
- ] })
28183
- }
28184
- )
28185
- ] }) : null;
28488
+ const panel = config ? /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(import_jsx_runtime103.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
28489
+ Modal2,
28490
+ {
28491
+ title: "\u67E5\u8BE2\u8BBE\u7F6E",
28492
+ open,
28493
+ width: 520,
28494
+ okText: "\u4FDD\u5B58",
28495
+ confirmLoading: saving,
28496
+ okButtonProps: { disabled: locked },
28497
+ onOk: save,
28498
+ onOpenChange: (next) => {
28499
+ if (!saveLock.current) setOpen(next);
28500
+ },
28501
+ children: /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)("div", { className: "sia-query-settings", children: [
28502
+ loading ? /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("p", { role: "status", children: "\u6B63\u5728\u8BFB\u53D6\u67E5\u8BE2\u8BBE\u7F6E\u2026" }) : null,
28503
+ error ? /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)("div", { role: "alert", className: "sia-query-form__error", children: [
28504
+ error,
28505
+ loadFailed ? /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(Button, { type: "button", variant: "link", onClick: () => void load(true), children: "\u91CD\u8BD5" }) : null
28506
+ ] }) : null,
28507
+ /* @__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" }),
28508
+ /* @__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" }),
28509
+ /* @__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)(
28510
+ "div",
28511
+ {
28512
+ "data-query-field-key": item.key,
28513
+ className: `sia-query-settings__item${sort.preview?.key === item.key ? " is-dragging" : ""}${locked ? " is-disabled" : ""}`,
28514
+ style: sort.preview ? { transform: `translateY(${sort.preview.offsets[item.key] ?? 0}px)` } : void 0,
28515
+ onPointerDown: (event) => sort.start(event, item.key),
28516
+ children: [
28517
+ /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(Icon, { name: "menu", size: 15 }),
28518
+ /* @__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) })) }),
28519
+ /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("span", { className: "sia-query-settings__name", children: labels.get(item.key) ?? item.key }),
28520
+ /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)("div", { className: "sia-query-settings__order", children: [
28521
+ /* @__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) }),
28522
+ /* @__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) })
28523
+ ] })
28524
+ ]
28525
+ },
28526
+ item.key
28527
+ )) }),
28528
+ /* @__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" })
28529
+ ] })
28530
+ }
28531
+ ) }) : null;
28186
28532
  return { snapshot, control, panel };
28187
28533
  }
28188
28534