@sia.soul/sia-react-ui 0.1.159 → 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.
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 +9 -9
  4. package/dist/chart.js +5 -5
  5. package/dist/{chunk-6PIZGTNT.js → chunk-33WX54AU.js} +5 -5
  6. package/dist/{chunk-PU2V3VB5.js → chunk-4B7ATL6J.js} +1 -1
  7. package/dist/{chunk-XXFYFLZA.js → chunk-5WZR2RHA.js} +2 -2
  8. package/dist/{chunk-YO5OJQEH.js → chunk-CRA7VNOA.js} +1 -1
  9. package/dist/{chunk-ZIH5VLPT.js → chunk-KA3M4TE4.js} +2 -2
  10. package/dist/{chunk-6SSZVJO4.js → chunk-M4IASLGB.js} +3 -3
  11. package/dist/{chunk-UGCKRFZN.js → chunk-MXK6TKMO.js} +5 -5
  12. package/dist/{chunk-CDMCXNRK.js → chunk-Q3LEK2TL.js} +599 -270
  13. package/dist/{chunk-NRLIOMXY.js → chunk-UL54A2YN.js} +2 -2
  14. package/dist/{chunk-4CFFAKIJ.js → chunk-UPXL2QLJ.js} +6 -6
  15. package/dist/{chunk-SRWUDTCS.js → chunk-WMZYYPIW.js} +9 -9
  16. package/dist/{chunk-PJCO6PPW.js → chunk-ZNPNZD6O.js} +30 -15
  17. package/dist/{core-sU1bV7QH.d.ts → core-XtqUDbbD.d.ts} +5 -5
  18. package/dist/{core-B26pkBp_.d.cts → core-r-smfiNN.d.cts} +5 -5
  19. package/dist/core.cjs +27 -13
  20. package/dist/core.css +170 -22
  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 +9 -9
  25. package/dist/game.js +3 -3
  26. package/dist/index.cjs +664 -320
  27. package/dist/index.css +170 -22
  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 +9 -9
  32. package/dist/markdown-editor.js +3 -3
  33. package/dist/rich-text-editor.cjs +40 -13
  34. package/dist/rich-text-editor.js +7 -7
  35. package/dist/{select-date-range-DYrA87Tl.d.ts → select-date-range-CIXBuoef.d.ts} +8 -9
  36. package/dist/{select-date-range-CIwE5nFu.d.cts → select-date-range-Cbh37zmU.d.cts} +8 -9
  37. package/dist/select-date-range.cjs +598 -269
  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
  }
@@ -3866,7 +3866,7 @@ function MenuLevel({
3866
3866
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(MenuEntry, { item, level, parents, props, reserveIcon }, item.key);
3867
3867
  }) });
3868
3868
  }
3869
- function Menu({
3869
+ function MenuInner({
3870
3870
  items,
3871
3871
  mode = "vertical",
3872
3872
  gridColumns = 2,
@@ -3889,9 +3889,14 @@ function Menu({
3889
3889
  className = "",
3890
3890
  style,
3891
3891
  ...rest
3892
- }) {
3892
+ }, ref) {
3893
3893
  const menuId = (0, import_react15.useId)();
3894
3894
  const rootRef = (0, import_react15.useRef)(null);
3895
+ const setRootRef = (node) => {
3896
+ rootRef.current = node;
3897
+ if (typeof ref === "function") ref(node);
3898
+ else if (ref) ref.current = node;
3899
+ };
3895
3900
  const [selected, setSelected] = useControllableState({ value: selectedKeys, defaultValue: defaultSelectedKeys });
3896
3901
  const [open, setOpen] = useControllableState({ value: openKeys, defaultValue: defaultOpenKeys, onChange: (next) => onOpenChange?.([...next]) });
3897
3902
  const pendingOpenRef = (0, import_react15.useRef)(open);
@@ -4010,11 +4015,12 @@ function Menu({
4010
4015
  }
4011
4016
  }
4012
4017
  const gridStyle = mode === "grid" ? { "--sia-menu-grid-columns": gridColumns === "auto" ? "repeat(auto-fill, minmax(88px, 1fr))" : `repeat(${Number.isFinite(gridColumns) ? Math.max(1, Math.floor(Number(gridColumns))) : 2}, minmax(0, 1fr))` } : {};
4013
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("ul", { ref: rootRef, className: `sia-menu sia-menu-motion-surface sia-menu--${mode} sia-menu--${theme}${inlineCollapsed ? " sia-menu--collapsed" : ""} ${className}`.trim(), role: "menu", ...withTitleTooltip(rest), onKeyDown: handleMenuKeyDown, style: { ...gridStyle, ...style }, "data-sia-menu-owner": menuId, children: [
4018
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("ul", { ref: setRootRef, className: `sia-menu sia-menu-motion-surface sia-menu--${mode} sia-menu--${theme}${inlineCollapsed ? " sia-menu--collapsed" : ""} ${className}`.trim(), role: "menu", ...withTitleTooltip(rest), onKeyDown: handleMenuKeyDown, style: { ...gridStyle, ...style }, "data-sia-menu-owner": menuId, children: [
4014
4019
  /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(MenuLevel, { items, level: 0, parents: [], props: { interactionCursor, menuId, mode, theme, multiple, selectable, inlineCollapsed, inlineIndent, triggerSubMenuAction, selected, open, select, toggle } }),
4015
4020
  /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(MenuSelectionMotion, { rootRef, enabled: !multiple })
4016
4021
  ] });
4017
4022
  }
4023
+ var Menu = (0, import_react15.forwardRef)(MenuInner);
4018
4024
  function Steps({ items, current = 0, initial: initial3 = 0, direction = "horizontal", labelPlacement = "vertical", type = "default", size = "default", status = "process", progressDot = false, onChange, className = "", ...props }) {
4019
4025
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: `sia-steps sia-steps--${direction} sia-steps--${type} sia-steps--${size} sia-steps--label-${labelPlacement} ${className}`.trim(), ...withTitleTooltip(props), children: items.map((item, rawIndex) => {
4020
4026
  const index = rawIndex + initial3;
@@ -4096,6 +4102,7 @@ function DropdownInternal({
4096
4102
  const rootRef = (0, import_react17.useRef)(null);
4097
4103
  const contextAnchorRef = (0, import_react17.useRef)(null);
4098
4104
  const popupRef = (0, import_react17.useRef)(null);
4105
+ const menuListRef = (0, import_react17.useRef)(null);
4099
4106
  const openTimerRef = (0, import_react17.useRef)(void 0);
4100
4107
  const closeTimerRef = (0, import_react17.useRef)(void 0);
4101
4108
  const [internalOpen, setInternalOpen] = (0, import_react17.useState)(defaultOpen);
@@ -4222,6 +4229,7 @@ function DropdownInternal({
4222
4229
  const menuNode = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
4223
4230
  Menu,
4224
4231
  {
4232
+ ref: menuListRef,
4225
4233
  mode: "vertical",
4226
4234
  theme: menu.theme,
4227
4235
  items: menu.items,
@@ -4286,7 +4294,13 @@ function DropdownInternal({
4286
4294
  if (!disabled && triggerSet.has("hover")) scheduleClose();
4287
4295
  },
4288
4296
  onClick: (event) => event.stopPropagation(),
4289
- children: popupRender ? popupRender(menuNode) : menuNode
4297
+ children: popupRender ? popupRender(/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
4298
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(FloatingScrollbarProvider, { targetRef: menuListRef }),
4299
+ menuNode
4300
+ ] })) : /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
4301
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(FloatingScrollbarProvider, { targetRef: menuListRef }),
4302
+ menuNode
4303
+ ] })
4290
4304
  },
4291
4305
  contextPoint ? `context-${contextPoint.x}-${contextPoint.y}` : "trigger"
4292
4306
  )
@@ -9742,8 +9756,51 @@ function CalendarMonth({
9742
9756
  previewEnd,
9743
9757
  disabledDate,
9744
9758
  onSelect,
9745
- onHover
9759
+ onHover,
9760
+ onSwipeMonth
9746
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
+ }
9747
9804
  const first = startOfMonth(month);
9748
9805
  const mondayIndex = (first.getDay() + 6) % 7;
9749
9806
  const gridStart = addDays(first, -mondayIndex);
@@ -9752,43 +9809,61 @@ function CalendarMonth({
9752
9809
  const end = range[1] || previewEnd || "";
9753
9810
  const low = start && end ? start <= end ? start : end : "";
9754
9811
  const high = start && end ? start <= end ? end : start : "";
9755
- return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: "sia-date-panel__month", children: [
9756
- /* @__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)) }),
9757
- /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: "sia-date-panel__days", children: Array.from({ length: 42 }, (_, index) => {
9758
- const date = addDays(gridStart, index);
9759
- const key = dateKey(date);
9760
- const outside = date.getMonth() !== month.getMonth();
9761
- const disabled = disabledDate?.(key) ?? false;
9762
- const selected = selectedDates.includes(key);
9763
- const rangeStart = Boolean(start && key === start);
9764
- const rangeEnd = Boolean(range[1] && key === range[1]);
9765
- const inRange = Boolean(low && high && key >= low && key <= high);
9766
- return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
9767
- "span",
9768
- {
9769
- 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" : ""}`,
9770
- children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
9771
- "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
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
9839
+ "span",
9772
9840
  {
9773
- type: "button",
9774
- "aria-label": key,
9775
- "aria-pressed": selected || rangeStart || rangeEnd || void 0,
9776
- disabled,
9777
- onClick: () => onSelect(key),
9778
- onMouseEnter: () => onHover?.(key),
9779
- children: date.getDate()
9780
- }
9781
- )
9782
- },
9783
- key
9784
- );
9785
- }) })
9786
- ] });
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
+ );
9787
9861
  }
9788
9862
  function CalendarHeader({
9789
9863
  month,
9790
9864
  label,
9791
9865
  range = false,
9866
+ onTitleClick,
9792
9867
  onPreviousYear,
9793
9868
  onPreviousMonth,
9794
9869
  onNextMonth,
@@ -9802,7 +9877,15 @@ function CalendarHeader({
9802
9877
  ] }) : null,
9803
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
9804
9879
  ] }),
9805
- /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("strong", { children: [
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: [
9806
9889
  label ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("small", { children: label }) : null,
9807
9890
  /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("span", { children: [
9808
9891
  month.getFullYear(),
@@ -9821,36 +9904,146 @@ function CalendarHeader({
9821
9904
  range ? null : null
9822
9905
  ] });
9823
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
+ }
9824
10031
  function TimePanel({
9825
10032
  value,
9826
10033
  showSecond = false,
9827
10034
  ariaLabel = "\u65F6\u95F4",
9828
10035
  disabledTime,
9829
10036
  use12Hours = false,
10037
+ title,
10038
+ unitLabels = false,
9830
10039
  onChange
9831
10040
  }) {
9832
10041
  const [hour = "00", minute = "00", second = "00"] = value.split(":");
9833
- const columnsRef = (0, import_react45.useRef)(null);
9834
- const hourRef = (0, import_react45.useRef)(null);
9835
- const minuteRef = (0, import_react45.useRef)(null);
9836
- const secondRef = (0, import_react45.useRef)(null);
9837
- const columnRefs = [hourRef, minuteRef, secondRef];
9838
- (0, import_react45.useLayoutEffect)(() => {
9839
- for (const column of columnsRef.current?.children ?? []) {
9840
- const selected = column.querySelector('[aria-selected="true"]');
9841
- const first = column.firstElementChild;
9842
- if (!selected || !first) continue;
9843
- const top = selected.offsetTop - first.offsetTop + parseFloat(getComputedStyle(column).paddingTop || "0");
9844
- const bottom = top + selected.offsetHeight;
9845
- if (top < column.scrollTop || bottom > column.scrollTop + column.clientHeight) {
9846
- column.scrollTop = Math.max(0, top - (column.clientHeight - selected.offsetHeight) / 2);
9847
- }
9848
- }
9849
- }, [hour, minute, second, showSecond, ariaLabel]);
10042
+ const siblings = [hour, minute, second];
9850
10043
  const columns = [
9851
- { label: "\u5C0F\u65F6", value: hour, count: 24, index: 0 },
9852
- { label: "\u5206\u949F", value: minute, count: 60, index: 1 },
9853
- ...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 }] : []
9854
10047
  ];
9855
10048
  function update(index, next) {
9856
10049
  const values = [hour, minute, second];
@@ -9858,27 +10051,29 @@ function TimePanel({
9858
10051
  onChange(values.join(":"));
9859
10052
  }
9860
10053
  return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("aside", { className: "sia-date-panel__time", "aria-label": ariaLabel, children: [
9861
- /* @__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: [
9862
10055
  use12Hours ? pad2(Number(hour) % 12 || 12) : hour,
9863
10056
  ":",
9864
10057
  minute,
9865
10058
  showSecond ? `:${second}` : "",
9866
10059
  use12Hours ? Number(hour) < 12 ? " AM" : " PM" : ""
9867
10060
  ] }),
9868
- /* @__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) => {
9869
- const next = pad2(index);
9870
- const candidate = [hour, minute, second];
9871
- candidate[column.index] = next;
9872
- 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) => {
9873
- if (!["ArrowDown", "ArrowUp", "Home", "End"].includes(event.key)) return;
9874
- event.preventDefault();
9875
- const buttons = Array.from(event.currentTarget.parentElement.querySelectorAll("button:not(:disabled)"));
9876
- const position = buttons.indexOf(event.currentTarget);
9877
- 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)));
9878
- buttons[target]?.focus();
9879
- }, onClick: () => update(column.index, next), children: use12Hours && column.index === 0 ? `${pad2(index % 12 || 12)} ${index < 12 ? "AM" : "PM"}` : next }, next);
9880
- }) }, column.label)) }),
9881
- columns.map((column) => /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(FloatingScrollbarProvider, { targetRef: columnRefs[column.index] }, column.index))
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
+ )) })
9882
10077
  ] });
9883
10078
  }
9884
10079
  function DatePanelFooter({
@@ -9898,6 +10093,50 @@ function DatePanelFooter({
9898
10093
  needConfirm ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("button", { type: "button", className: "sia-date-panel__confirm", disabled: disabledConfirm, onClick: onConfirm, children: confirmText }) : null
9899
10094
  ] });
9900
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
+ }
9901
10140
 
9902
10141
  // src/components/DatePicker.tsx
9903
10142
  var import_jsx_runtime43 = require("react/jsx-runtime");
@@ -9947,6 +10186,12 @@ function resolvePreset(value) {
9947
10186
  function resolveRangePreset(value) {
9948
10187
  return typeof value === "function" ? value() : value;
9949
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
+ }
9950
10195
  function DatePicker({
9951
10196
  value,
9952
10197
  defaultValue,
@@ -9986,7 +10231,11 @@ function DatePicker({
9986
10231
  const firstCurrent = Array.isArray(currentValue) ? currentValue[0] : currentValue;
9987
10232
  const [viewMonth, setViewMonth] = (0, import_react46.useState)(() => startOfMonth(parseDate2(dayFromValue(firstCurrent)) ?? /* @__PURE__ */ new Date()));
9988
10233
  const [draftTime, setDraftTime] = (0, import_react46.useState)(() => timePart(firstCurrent, defaultTimeFrom(showTime)));
9989
- const resolvedNeedConfirm = needConfirm ?? Boolean(showTime);
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);
9990
10239
  const showSecond = showSecondFrom(showTime);
9991
10240
  const selectedDates = (0, import_react46.useMemo)(() => {
9992
10241
  const values = Array.isArray(draftValue) ? draftValue : draftValue ? [draftValue] : [];
@@ -10007,6 +10256,9 @@ function DatePicker({
10007
10256
  const current = Array.isArray(currentValue) ? currentValue[0] : currentValue;
10008
10257
  setViewMonth(startOfMonth(parseDate2(dayFromValue(current)) ?? /* @__PURE__ */ new Date()));
10009
10258
  setDraftTime(timePart(current, defaultTimeFrom(showTime)));
10259
+ setTimeExplicit(showTimeDefaultProvided || hasExplicitTime(typeof current === "string" ? current : void 0));
10260
+ setDateTimeView("date");
10261
+ setYearDrill(false);
10010
10262
  }
10011
10263
  setVisible(next);
10012
10264
  }
@@ -10018,9 +10270,11 @@ function DatePicker({
10018
10270
  if (maximum && day.slice(0, length) > String(maximum).slice(0, length)) return true;
10019
10271
  return disabledDate?.(day, { type: "date" }) ?? false;
10020
10272
  }
10021
- function buildValue(day, time = draftTime) {
10273
+ function buildValue(day, time = draftTime, explicit = timeExplicit) {
10022
10274
  const picked = formatPickerValue(day, picker);
10023
- return showTime && picker === "date" ? withTime(picked, time, showSecond) : picked;
10275
+ if (!(showTime && picker === "date")) return picked;
10276
+ if (!explicit && isZeroTime(time, showSecond)) return picked;
10277
+ return withTime(picked, time, showSecond);
10024
10278
  }
10025
10279
  function selectDate(day, time = draftTime, ensureSelected = false) {
10026
10280
  if (isDisabled(day)) return;
@@ -10036,7 +10290,7 @@ function DatePicker({
10036
10290
  setDraftValue(nextValue);
10037
10291
  if (!resolvedNeedConfirm) {
10038
10292
  setCurrentValue(nextValue);
10039
- changeOpen(false);
10293
+ if (!showTime) changeOpen(false);
10040
10294
  }
10041
10295
  }
10042
10296
  function commitDraft() {
@@ -10045,6 +10299,72 @@ function DatePicker({
10045
10299
  setCurrentValue(draftValue);
10046
10300
  changeOpen(false);
10047
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
+ }
10048
10368
  function clearValue(event) {
10049
10369
  event.stopPropagation();
10050
10370
  const empty = multiple ? [] : "";
@@ -10084,72 +10404,82 @@ function DatePicker({
10084
10404
  ),
10085
10405
  floating.label,
10086
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,
10087
- /* @__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: [
10088
- /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "sia-date-panel__body", children: [
10089
- 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: () => {
10090
- const next = resolvePreset(preset2.value);
10091
- if (!next || isDisabled(dayFromValue(next))) return;
10092
- setDraftValue(next);
10093
- if (!resolvedNeedConfirm) {
10094
- setCurrentValue(next);
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();
10095
10419
  changeOpen(false);
10096
10420
  }
10097
- }, children: preset2.label }, index)) }) : null,
10098
- /* @__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: [
10099
- /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "sia-date-panel__header", children: [
10100
- /* @__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 }) }) }),
10101
- /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("strong", { children: [
10102
- Math.floor(viewMonth.getFullYear() / 10) * 10,
10103
- "\u5E74 \u2014 ",
10104
- Math.floor(viewMonth.getFullYear() / 10) * 10 + 9,
10105
- "\u5E74"
10106
- ] }),
10107
- /* @__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 }) }) })
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() })
10108
10449
  ] }),
10109
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "sia-date-panel__years", children: Array.from({ length: 10 }, (_, index) => {
10110
- const year = String(Math.floor(viewMonth.getFullYear() / 10) * 10 + index);
10111
- const day = `${year}-01-01`;
10112
- const selected = selectedDates.some((value2) => value2.slice(0, 4) === year);
10113
- 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);
10114
- }) })
10115
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(import_jsx_runtime43.Fragment, { children: [
10116
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
10117
- CalendarHeader,
10450
+ showTime ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
10451
+ DateTimePanelFooter,
10118
10452
  {
10119
- month: viewMonth,
10120
- onPreviousYear: () => setViewMonth(addMonths(viewMonth, -12)),
10121
- onPreviousMonth: () => setViewMonth(addMonths(viewMonth, -1)),
10122
- onNextMonth: () => setViewMonth(addMonths(viewMonth, 1)),
10123
- onNextYear: () => setViewMonth(addMonths(viewMonth, 12))
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
10124
10460
  }
10125
- ),
10126
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(CalendarMonth, { month: viewMonth, selectedDates, disabledDate: isDisabled, onSelect: selectDate })
10127
- ] }) }),
10128
- showTime ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(TimePanel, { value: draftTime, showSecond, onChange: (next) => {
10129
- setDraftTime(next);
10130
- if (typeof draftValue === "string" && draftValue) setDraftValue(withTime(dayFromValue(draftValue), next, showSecond));
10131
- } }) : null
10132
- ] }),
10133
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
10134
- DatePanelFooter,
10135
- {
10136
- extra: renderExtraFooter?.(),
10137
- showToday,
10138
- needConfirm: resolvedNeedConfirm,
10139
- disabledConfirm: Array.isArray(draftValue) ? draftValue.length === 0 : !draftValue,
10140
- onToday: () => {
10141
- const now = /* @__PURE__ */ new Date();
10142
- const day = dateKey(now);
10143
- if (isDisabled(day)) return;
10144
- const time = [now.getHours(), now.getMinutes(), now.getSeconds()].map(pad2).join(":");
10145
- if (showTime) setDraftTime(time);
10146
- setViewMonth(startOfMonth(now));
10147
- selectDate(day, time, true);
10148
- },
10149
- onConfirm: commitDraft
10150
- }
10151
- )
10152
- ] })
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
+ )
10153
10483
  ] });
10154
10484
  }
10155
10485
  function DateRangePicker({
@@ -10209,8 +10539,7 @@ function DateRangePicker({
10209
10539
  }
10210
10540
  return () => observer.disconnect();
10211
10541
  });
10212
- const [confirmedIndex, setConfirmedIndex] = (0, import_react46.useState)(null);
10213
- const [presetSelected, setPresetSelected] = (0, import_react46.useState)(false);
10542
+ const [dateTimeView, setDateTimeView] = (0, import_react46.useState)("date");
10214
10543
  const [hoverDate, setHoverDate] = (0, import_react46.useState)("");
10215
10544
  const [viewMonth, setViewMonth] = (0, import_react46.useState)(() => startOfMonth(parseDate2(dayFromValue(currentValue[0] || currentValue[1])) ?? /* @__PURE__ */ new Date()));
10216
10545
  const [endViewMonth, setEndViewMonth] = (0, import_react46.useState)(() => startOfMonth(parseDate2(dayFromValue(currentValue[1])) ?? addMonths(parseDate2(dayFromValue(currentValue[0])) ?? /* @__PURE__ */ new Date(), 1)));
@@ -10221,7 +10550,7 @@ function DateRangePicker({
10221
10550
  timePart(currentValue[0], defaultTime),
10222
10551
  timePart(currentValue[1], defaultEndTime)
10223
10552
  ]);
10224
- const resolvedNeedConfirm = needConfirm ?? Boolean(showTime);
10553
+ const resolvedNeedConfirm = showTime ? false : Boolean(needConfirm);
10225
10554
  const rangeDates = [dayFromValue(draftValue[0]), dayFromValue(draftValue[1])];
10226
10555
  const invalidDateTimeRange = Boolean(showTime && draftValue[0] && draftValue[1] && draftValue[0] > draftValue[1]);
10227
10556
  (0, import_react46.useEffect)(() => {
@@ -10238,11 +10567,10 @@ function DateRangePicker({
10238
10567
  }
10239
10568
  function changeOpen(next, endpoint) {
10240
10569
  if (next && !visible) {
10241
- setConfirmedIndex(null);
10242
- setPresetSelected(false);
10243
10570
  setDraftValue(currentValue);
10244
10571
  setTimes([timePart(currentValue[0], defaultTime), timePart(currentValue[1], defaultEndTime)]);
10245
10572
  setActiveIndex(endpointDisabled[0] ? 1 : endpointDisabled[1] ? 0 : endpoint ?? (currentValue[0] && !currentValue[1] ? 1 : 0));
10573
+ setDateTimeView("date");
10246
10574
  const nextStartMonth = startOfMonth(parseDate2(dayFromValue(currentValue[0] || currentValue[1])) ?? /* @__PURE__ */ new Date());
10247
10575
  setViewMonth(nextStartMonth);
10248
10576
  setEndViewMonth(startOfMonth(parseDate2(dayFromValue(currentValue[1])) ?? addMonths(nextStartMonth, 1)));
@@ -10258,9 +10586,9 @@ function DateRangePicker({
10258
10586
  if (maximum && day > String(maximum).slice(0, 10)) return true;
10259
10587
  const from = index === 1 ? rangeDates[0] : void 0;
10260
10588
  if (dateTimeStep) {
10261
- const otherIndex2 = index === 0 ? 1 : 0;
10262
- const otherEndpoint = rangeDates[otherIndex2];
10263
- if (otherEndpoint && (endpointDisabled[otherIndex2] || confirmedIndex === otherIndex2)) {
10589
+ const otherIndex = index === 0 ? 1 : 0;
10590
+ const otherEndpoint = rangeDates[otherIndex];
10591
+ if (otherEndpoint) {
10264
10592
  if (index === 0 && day > otherEndpoint || index === 1 && day < otherEndpoint) return true;
10265
10593
  if (maxRangeDays && Math.abs(daysBetween(otherEndpoint, day)) >= maxRangeDays) return true;
10266
10594
  }
@@ -10271,10 +10599,9 @@ function DateRangePicker({
10271
10599
  return showTime ? withTime(day, times[index], showSecond) : day;
10272
10600
  }
10273
10601
  function updateDraft(next) {
10274
- setPresetSelected(false);
10275
10602
  setDraftValue(next);
10276
10603
  onCalendarChange?.(next);
10277
- if (!showTime && isValidRange(next) && (next[0] !== currentValue[0] || next[1] !== currentValue[1])) {
10604
+ if (isValidRange(next) && (next[0] !== currentValue[0] || next[1] !== currentValue[1])) {
10278
10605
  setCurrentValue(next);
10279
10606
  }
10280
10607
  }
@@ -10315,6 +10642,13 @@ function DateRangePicker({
10315
10642
  nextValue[index] = withTime(day, time, showSecond);
10316
10643
  updateDraft(nextValue);
10317
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
+ }
10318
10652
  setActiveIndex(index);
10319
10653
  }
10320
10654
  function changeTime(index, nextTime) {
@@ -10351,19 +10685,7 @@ function DateRangePicker({
10351
10685
  }
10352
10686
  return true;
10353
10687
  }
10354
- const otherIndex = activeIndex === 0 ? 1 : 0;
10355
- const needsOtherConfirmation = Boolean(showTime && !presetSelected && !endpointDisabled[otherIndex] && confirmedIndex !== otherIndex);
10356
10688
  function confirm() {
10357
- if (needsOtherConfirmation) {
10358
- if (!draftValue[activeIndex] && !allowEmpty[activeIndex]) return;
10359
- setConfirmedIndex(activeIndex);
10360
- setActiveIndex(otherIndex);
10361
- const month = startOfMonth(parseDate2(dayFromValue(draftValue[activeIndex])) ?? /* @__PURE__ */ new Date());
10362
- if (otherIndex === 0) setViewMonth(month);
10363
- else setEndViewMonth(month);
10364
- setHoverDate("");
10365
- return;
10366
- }
10367
10689
  if (!isValidRange(draftValue)) return;
10368
10690
  setCurrentValue(draftValue);
10369
10691
  changeOpen(false);
@@ -10376,13 +10698,11 @@ function DateRangePicker({
10376
10698
  ];
10377
10699
  if (!isValidRange(next)) return;
10378
10700
  updateDraft(next);
10379
- setConfirmedIndex(null);
10380
- setPresetSelected(true);
10381
10701
  setTimes([timePart(next[0], defaultTime), timePart(next[1], defaultEndTime)]);
10382
10702
  const nextStartMonth = startOfMonth(parseDate2(dayFromValue(next[0] || next[1])) ?? /* @__PURE__ */ new Date());
10383
10703
  setViewMonth(nextStartMonth);
10384
10704
  setEndViewMonth(startOfMonth(parseDate2(dayFromValue(next[1])) ?? addMonths(nextStartMonth, 1)));
10385
- if (!showTime && !resolvedNeedConfirm) {
10705
+ if (!resolvedNeedConfirm) {
10386
10706
  changeOpen(false);
10387
10707
  }
10388
10708
  }
@@ -10397,49 +10717,29 @@ function DateRangePicker({
10397
10717
  const month = index === 0 ? viewMonth : endViewMonth;
10398
10718
  const setMonth = index === 0 ? setViewMonth : setEndViewMonth;
10399
10719
  const endpointLabel = index === 0 ? "\u5F00\u59CB" : "\u7ED3\u675F";
10400
- return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
10401
- "div",
10402
- {
10403
- className: `sia-date-panel__range-date-time-group${activeIndex === index ? " is-active" : ""}`,
10404
- "aria-label": `${endpointLabel}\u65E5\u671F\u65F6\u95F4`,
10405
- children: [
10406
- /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("section", { className: "sia-date-panel__calendar", children: [
10407
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
10408
- CalendarHeader,
10409
- {
10410
- month,
10411
- label: endpointLabel,
10412
- range: true,
10413
- onPreviousYear: () => setMonth(addMonths(month, -12)),
10414
- onPreviousMonth: () => setMonth(addMonths(month, -1)),
10415
- onNextMonth: () => setMonth(addMonths(month, 1)),
10416
- onNextYear: () => setMonth(addMonths(month, 12))
10417
- }
10418
- ),
10419
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
10420
- CalendarMonth,
10421
- {
10422
- month,
10423
- range: rangeDates,
10424
- disabledDate: (day) => isDisabled(day, index, true),
10425
- onSelect: (day) => selectDateTime(day, index)
10426
- }
10427
- )
10428
- ] }),
10429
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
10430
- TimePanel,
10431
- {
10432
- value: times[index],
10433
- showSecond,
10434
- ariaLabel: `${endpointLabel}\u65F6\u95F4`,
10435
- disabledTime: endpointDisabled[index] ? () => true : void 0,
10436
- onChange: (nextTime) => changeTime(index, nextTime)
10437
- }
10438
- )
10439
- ]
10440
- },
10441
- endpointLabel
10442
- );
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
+ ] });
10443
10743
  }
10444
10744
  const displayValue = visible && allowEmpty.some(Boolean) ? draftValue : currentValue;
10445
10745
  const startFloating = useFloatingPlaceholder({ mode: placeholderMode, placeholder: placeholder[0], filled: Boolean(displayValue[0]), active: visible });
@@ -10484,67 +10784,110 @@ function DateRangePicker({
10484
10784
  }
10485
10785
  ),
10486
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,
10487
- /* @__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: [
10488
- /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "sia-date-panel__body", children: [
10489
- 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,
10490
- 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: [
10491
- /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("section", { className: "sia-date-panel__calendar", children: [
10492
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
10493
- CalendarHeader,
10494
- {
10495
- month: viewMonth,
10496
- range: true,
10497
- onPreviousYear: () => setViewMonth(addMonths(viewMonth, -12)),
10498
- onPreviousMonth: () => setViewMonth(addMonths(viewMonth, -1))
10499
- }
10500
- ),
10501
- /* @__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 })
10502
- ] }),
10503
- /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("section", { className: "sia-date-panel__calendar", children: [
10504
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
10505
- CalendarHeader,
10506
- {
10507
- month: addMonths(viewMonth, 1),
10508
- range: true,
10509
- onNextMonth: () => setViewMonth(addMonths(viewMonth, 1)),
10510
- onNextYear: () => setViewMonth(addMonths(viewMonth, 12))
10511
- }
10512
- ),
10513
- /* @__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 })
10514
- ] })
10515
- ] })
10516
- ] }),
10517
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
10518
- DatePanelFooter,
10519
- {
10520
- showToday: showToday && !presets?.length,
10521
- needConfirm: Boolean(showTime) || resolvedNeedConfirm || allowEmpty.some(Boolean),
10522
- disabledConfirm: needsOtherConfirmation ? !draftValue[activeIndex] && !allowEmpty[activeIndex] : !isValidRange(draftValue),
10523
- extra: /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(import_jsx_runtime43.Fragment, { children: [
10524
- renderExtraFooter?.(),
10525
- 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: [
10526
- "\u6700\u591A\u9009\u62E9 ",
10527
- maxRangeDays,
10528
- " \u5929"
10529
- ] }) : null
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
+ ] })
10530
10845
  ] }),
10531
- onToday: () => {
10532
- const now = /* @__PURE__ */ new Date();
10533
- const day = dateKey(now);
10534
- if (isDisabled(day, activeIndex, Boolean(showTime))) return;
10535
- if (showTime) {
10536
- const time = [now.getHours(), now.getMinutes(), now.getSeconds()].map(pad2).join(":");
10537
- (activeIndex === 0 ? setViewMonth : setEndViewMonth)(startOfMonth(now));
10538
- selectDateTime(day, activeIndex, time);
10539
- } else {
10540
- setViewMonth(startOfMonth(now));
10541
- selectDate(day);
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")
10542
10863
  }
10543
- },
10544
- onConfirm: confirm
10545
- }
10546
- )
10547
- ] })
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
+ )
10548
10891
  ] });
10549
10892
  }
10550
10893
  ((DatePicker2) => {
@@ -13360,6 +13703,7 @@ function registerSqlLanguages(monaco) {
13360
13703
  // src/components/Editor.tsx
13361
13704
  var import_jsx_runtime52 = require("react/jsx-runtime");
13362
13705
  var EDITOR_COMMAND_SHORTCUTS = {
13706
+ undo: "Ctrl+Z",
13363
13707
  cut: "Ctrl+X",
13364
13708
  copy: "Ctrl+C",
13365
13709
  paste: "Ctrl+V",
@@ -13704,6 +14048,7 @@ function Editor({
13704
14048
  });
13705
14049
  const api = {
13706
14050
  focus: () => editor.focus(),
14051
+ canUndo: () => model.canUndo(),
13707
14052
  getValue: () => model.getValue(),
13708
14053
  getSelection: () => {
13709
14054
  const selection = editor.getSelection();
@@ -13984,6 +14329,7 @@ function Editor({
13984
14329
  editor.focus();
13985
14330
  if (item.command) {
13986
14331
  const commandId = {
14332
+ undo: "undo",
13987
14333
  cut: "editor.action.clipboardCutAction",
13988
14334
  copy: "editor.action.clipboardCopyAction",
13989
14335
  paste: "editor.action.clipboardPasteAction",
@@ -28045,6 +28391,7 @@ function useQueryFormSettings(config, fields, defaultCollapsed, applyCollapsed,
28045
28391
  if (request !== token.current) return;
28046
28392
  setLoadFailed(true);
28047
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");
28048
28395
  current.config.onError?.(reason, "load");
28049
28396
  } finally {
28050
28397
  if (request === token.current) setLoading(false);
@@ -28122,53 +28469,50 @@ function useQueryFormSettings(config, fields, defaultCollapsed, applyCollapsed,
28122
28469
  }
28123
28470
  }
28124
28471
  ) : null;
28125
- const panel = config ? /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)(import_jsx_runtime103.Fragment, { children: [
28126
- !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,
28127
- /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
28128
- Modal2,
28129
- {
28130
- title: "\u67E5\u8BE2\u8BBE\u7F6E",
28131
- open,
28132
- width: 520,
28133
- okText: "\u4FDD\u5B58",
28134
- confirmLoading: saving,
28135
- okButtonProps: { disabled: locked },
28136
- onOk: save,
28137
- onOpenChange: (next) => {
28138
- if (!saveLock.current) setOpen(next);
28139
- },
28140
- children: /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)("div", { className: "sia-query-settings", children: [
28141
- loading ? /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("p", { role: "status", children: "\u6B63\u5728\u8BFB\u53D6\u67E5\u8BE2\u8BBE\u7F6E\u2026" }) : null,
28142
- error ? /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)("div", { role: "alert", className: "sia-query-form__error", children: [
28143
- error,
28144
- loadFailed ? /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(Button, { type: "button", variant: "link", onClick: () => void load(true), children: "\u91CD\u8BD5" }) : null
28145
- ] }) : null,
28146
- /* @__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" }),
28147
- /* @__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" }),
28148
- /* @__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)(
28149
- "div",
28150
- {
28151
- "data-query-field-key": item.key,
28152
- className: `sia-query-settings__item${sort.preview?.key === item.key ? " is-dragging" : ""}${locked ? " is-disabled" : ""}`,
28153
- style: sort.preview ? { transform: `translateY(${sort.preview.offsets[item.key] ?? 0}px)` } : void 0,
28154
- onPointerDown: (event) => sort.start(event, item.key),
28155
- children: [
28156
- /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(Icon, { name: "menu", size: 15 }),
28157
- /* @__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) })) }),
28158
- /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("span", { className: "sia-query-settings__name", children: labels.get(item.key) ?? item.key }),
28159
- /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)("div", { className: "sia-query-settings__order", children: [
28160
- /* @__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) }),
28161
- /* @__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) })
28162
- ] })
28163
- ]
28164
- },
28165
- item.key
28166
- )) }),
28167
- /* @__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" })
28168
- ] })
28169
- }
28170
- )
28171
- ] }) : 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;
28172
28516
  return { snapshot, control, panel };
28173
28517
  }
28174
28518