@sia.soul/sia-react-ui 0.1.142 → 0.1.143
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{Button-BiL3Wjsd.d.ts → Button-C8W8ZHWV.d.ts} +1 -1
- package/dist/{Button-O_pNB3SQ.d.cts → Button-CxKBjLda.d.cts} +1 -1
- package/dist/{Select-DeD4O8FL.d.ts → Select-CTSd8zum.d.ts} +14 -10
- package/dist/{Select-Y0e9kaxE.d.cts → Select-bKLket9n.d.cts} +14 -10
- package/dist/chart.cjs +1051 -335
- package/dist/chart.js +5 -5
- package/dist/chunk-4OHS7RXE.js +1004 -0
- package/dist/{chunk-WIRIEIRO.js → chunk-4TYHSAR3.js} +5 -5
- package/dist/{chunk-TUGCP3GB.js → chunk-566S64IP.js} +5 -5
- package/dist/{chunk-CZ2ITBRW.js → chunk-7SEGBB6V.js} +34 -5
- package/dist/{chunk-KY6A5IJH.js → chunk-ETQJ2DQ2.js} +1 -1
- package/dist/{chunk-WD56MJO2.js → chunk-F52O2MOV.js} +7 -3
- package/dist/{chunk-PQBCD54U.js → chunk-JRXYM5YH.js} +167 -64
- package/dist/{chunk-SCEHVGKV.js → chunk-LKLPCYEP.js} +2 -2
- package/dist/{chunk-3KYG7IU7.js → chunk-MD4CGSOR.js} +105 -61
- package/dist/{chunk-PGP4TEPP.js → chunk-ORSQAJ22.js} +154 -494
- package/dist/{chunk-SO7IJZIR.js → chunk-PD3K5U5Y.js} +2 -2
- package/dist/{chunk-UVHC6OEX.js → chunk-WCYVBO2N.js} +342 -123
- package/dist/{core-DYo5C4Si.d.cts → core-COaZfusa.d.cts} +51 -24
- package/dist/{core-sWwvVAmP.d.ts → core-CvfsQGuT.d.ts} +51 -24
- package/dist/core.cjs +1996 -1250
- package/dist/core.css +413 -344
- package/dist/core.d.cts +3 -3
- package/dist/core.d.ts +3 -3
- package/dist/core.js +18 -9
- package/dist/game.cjs +1984 -1169
- package/dist/game.css +182 -177
- package/dist/game.d.cts +1 -1
- package/dist/game.d.ts +1 -1
- package/dist/game.js +8 -3
- package/dist/index.cjs +4654 -3541
- package/dist/index.css +413 -344
- package/dist/index.d.cts +77 -80
- package/dist/index.d.ts +77 -80
- package/dist/index.js +1075 -713
- package/dist/markdown-editor.cjs +727 -40
- package/dist/markdown-editor.js +8 -3
- package/dist/rich-text-editor.cjs +1265 -308
- package/dist/rich-text-editor.js +12 -7
- package/dist/{select-date-range-X6a9Y-Te.d.ts → select-date-range-C8cacfmb.d.ts} +1 -1
- package/dist/{select-date-range-DiBQQ0Rn.d.cts → select-date-range-Dad0IdD4.d.cts} +1 -1
- package/dist/select-date-range.cjs +1277 -806
- package/dist/select-date-range.d.cts +3 -3
- package/dist/select-date-range.d.ts +3 -3
- package/dist/select-date-range.js +13 -8
- package/package.json +9 -2
- package/dist/chunk-NZMUW5XI.js +0 -292
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Popover,
|
|
3
3
|
Tooltip
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-ORSQAJ22.js";
|
|
5
5
|
import {
|
|
6
6
|
Dropdown
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-WCYVBO2N.js";
|
|
8
8
|
import {
|
|
9
9
|
TextArea
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-LKLPCYEP.js";
|
|
11
11
|
import {
|
|
12
12
|
Icon,
|
|
13
13
|
useOverlayLifecycle
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-JRXYM5YH.js";
|
|
15
15
|
import {
|
|
16
16
|
Button
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-7SEGBB6V.js";
|
|
18
18
|
import {
|
|
19
19
|
useControlSize,
|
|
20
20
|
useControllableState,
|
|
21
|
+
useOverlayMotion,
|
|
21
22
|
withTitleTooltip
|
|
22
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-4OHS7RXE.js";
|
|
23
24
|
|
|
24
25
|
// src/components/Toolbar.tsx
|
|
25
26
|
import { useLayoutEffect, useRef, useState } from "react";
|
|
@@ -698,6 +699,8 @@ function Progress({
|
|
|
698
699
|
}
|
|
699
700
|
function Spin({ spinning = true, size = "default", tip, indicator, delay = 0, fullscreen = false, className = "", children, ...props }) {
|
|
700
701
|
const [visible, setVisible] = useState4(delay === 0 && spinning);
|
|
702
|
+
const motionRef = useRef3(null);
|
|
703
|
+
const motion = useOverlayMotion(visible, motionRef, "fade");
|
|
701
704
|
useEffect2(() => {
|
|
702
705
|
if (!spinning) {
|
|
703
706
|
setVisible(false);
|
|
@@ -706,7 +709,7 @@ function Spin({ spinning = true, size = "default", tip, indicator, delay = 0, fu
|
|
|
706
709
|
const timer = window.setTimeout(() => setVisible(true), delay);
|
|
707
710
|
return () => window.clearTimeout(timer);
|
|
708
711
|
}, [delay, spinning]);
|
|
709
|
-
const spinner =
|
|
712
|
+
const spinner = motion.present ? /* @__PURE__ */ jsxs5("div", { ref: !fullscreen && !children ? motionRef : void 0, className: `sia-spin sia-spin--${size}`, role: "status", "aria-live": "polite", children: [
|
|
710
713
|
indicator ?? /* @__PURE__ */ jsxs5("span", { className: "sia-spin__indicator", children: [
|
|
711
714
|
/* @__PURE__ */ jsx5("i", {}),
|
|
712
715
|
/* @__PURE__ */ jsx5("i", {}),
|
|
@@ -715,11 +718,11 @@ function Spin({ spinning = true, size = "default", tip, indicator, delay = 0, fu
|
|
|
715
718
|
] }),
|
|
716
719
|
tip ? /* @__PURE__ */ jsx5("span", { className: "sia-spin__tip", children: tip }) : null
|
|
717
720
|
] }) : null;
|
|
718
|
-
if (fullscreen) return
|
|
721
|
+
if (fullscreen) return motion.present && typeof document !== "undefined" ? createPortal(/* @__PURE__ */ jsx5("div", { ref: motionRef, className: "sia-spin-fullscreen", style: { pointerEvents: visible ? void 0 : "none" }, children: spinner }), document.body) : null;
|
|
719
722
|
if (!children) return /* @__PURE__ */ jsx5("div", { className: `sia-spin-wrap ${className}`.trim(), ...withTitleTooltip(props), children: spinner });
|
|
720
723
|
return /* @__PURE__ */ jsxs5("div", { className: `sia-spin-container${visible ? " is-spinning" : ""} ${className}`.trim(), ...withTitleTooltip(props), children: [
|
|
721
724
|
children,
|
|
722
|
-
|
|
725
|
+
motion.present ? /* @__PURE__ */ jsx5("div", { ref: motionRef, className: "sia-spin-mask", style: { pointerEvents: visible ? void 0 : "none" }, children: spinner }) : null
|
|
723
726
|
] });
|
|
724
727
|
}
|
|
725
728
|
function escapeXml(value) {
|
|
@@ -749,22 +752,23 @@ function emitNotifications() {
|
|
|
749
752
|
}
|
|
750
753
|
function closeNotification(key) {
|
|
751
754
|
const entry = notificationEntries.find((item) => item.key === key);
|
|
752
|
-
|
|
755
|
+
if (!entry || entry.closing) return;
|
|
756
|
+
notificationEntries = notificationEntries.map((item) => item.key === key ? { ...item, closing: true } : item);
|
|
753
757
|
window.clearTimeout(notificationTimers.get(key));
|
|
754
758
|
notificationTimers.delete(key);
|
|
755
759
|
emitNotifications();
|
|
756
760
|
entry?.onClose?.();
|
|
757
761
|
}
|
|
758
|
-
function
|
|
759
|
-
const
|
|
762
|
+
function NotificationNotice({ item }) {
|
|
763
|
+
const ref = useRef3(null);
|
|
764
|
+
const motion = useOverlayMotion(!item.closing, ref, "message");
|
|
760
765
|
useEffect2(() => {
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
return /* @__PURE__ */ jsx5(Fragment2, { children: placements.map((placement) => /* @__PURE__ */ jsx5("div", { className: `sia-notification sia-notification--${placement}`, children: entries.filter((item) => (item.placement ?? "topRight") === placement).map((item) => /* @__PURE__ */ jsxs5("div", { className: `sia-notification__notice sia-notification__notice--${item.type ?? "info"}`, role: item.role ?? "alert", onClick: item.onClick, children: [
|
|
766
|
+
if (motion.present || !item.closing) return;
|
|
767
|
+
notificationEntries = notificationEntries.filter((candidate) => candidate.key !== item.key || !candidate.closing);
|
|
768
|
+
emitNotifications();
|
|
769
|
+
}, [motion.present, item.key, item.closing]);
|
|
770
|
+
if (!motion.present) return null;
|
|
771
|
+
return /* @__PURE__ */ jsxs5("div", { ref, style: { animation: "none", pointerEvents: item.closing ? "none" : void 0 }, "aria-hidden": item.closing || void 0, className: `sia-notification__notice sia-notification__notice--${item.type ?? "info"}`, role: item.role ?? "alert", onClick: item.onClick, children: [
|
|
768
772
|
/* @__PURE__ */ jsx5("span", { className: "sia-notification__icon", children: item.icon ?? /* @__PURE__ */ jsx5(Icon, { name: item.type === "success" ? "circle-check" : item.type === "warning" ? "warning" : item.type === "error" ? "circle-close" : "info", variant: "filled" }) }),
|
|
769
773
|
/* @__PURE__ */ jsxs5("div", { children: [
|
|
770
774
|
/* @__PURE__ */ jsx5("strong", { children: item.message }),
|
|
@@ -775,7 +779,18 @@ function NotificationHost() {
|
|
|
775
779
|
event.stopPropagation();
|
|
776
780
|
closeNotification(item.key);
|
|
777
781
|
}, children: item.closeIcon ?? /* @__PURE__ */ jsx5(Icon, { name: "close", size: 14 }) })
|
|
778
|
-
] }
|
|
782
|
+
] });
|
|
783
|
+
}
|
|
784
|
+
function NotificationHost() {
|
|
785
|
+
const [entries, setEntries] = useState4(notificationEntries);
|
|
786
|
+
useEffect2(() => {
|
|
787
|
+
notificationListeners.add(setEntries);
|
|
788
|
+
return () => {
|
|
789
|
+
notificationListeners.delete(setEntries);
|
|
790
|
+
};
|
|
791
|
+
}, []);
|
|
792
|
+
const placements = ["topLeft", "topRight", "bottomLeft", "bottomRight"];
|
|
793
|
+
return /* @__PURE__ */ jsx5(Fragment2, { children: placements.map((placement) => /* @__PURE__ */ jsx5("div", { className: `sia-notification sia-notification--${placement}`, children: entries.filter((item) => (item.placement ?? "topRight") === placement).map((item) => /* @__PURE__ */ jsx5(NotificationNotice, { item }, item.key)) }, placement)) });
|
|
779
794
|
}
|
|
780
795
|
function ensureNotificationHost() {
|
|
781
796
|
if (typeof document === "undefined" || notificationHost) return;
|
|
@@ -818,6 +833,8 @@ var notification = {
|
|
|
818
833
|
function Tour({ open = false, steps, current, defaultCurrent = 0, mask = true, closable = true, disabledInteraction = false, onChange, onClose, onFinish }) {
|
|
819
834
|
const [index, setIndex] = useControllableState({ value: current, defaultValue: defaultCurrent, onChange });
|
|
820
835
|
const [, force] = useState4(0);
|
|
836
|
+
const motionRef = useRef3(null);
|
|
837
|
+
const motion = useOverlayMotion(open, motionRef, "fade");
|
|
821
838
|
useEffect2(() => {
|
|
822
839
|
if (!open) return;
|
|
823
840
|
const update = () => force((value) => value + 1);
|
|
@@ -828,13 +845,13 @@ function Tour({ open = false, steps, current, defaultCurrent = 0, mask = true, c
|
|
|
828
845
|
window.removeEventListener("scroll", update, true);
|
|
829
846
|
};
|
|
830
847
|
}, [open]);
|
|
831
|
-
if (!
|
|
848
|
+
if (!motion.present || !steps[index] || typeof document === "undefined") return null;
|
|
832
849
|
const step = steps[index];
|
|
833
850
|
const target = typeof step.target === "function" ? step.target() : step.target;
|
|
834
851
|
const rect = target?.getBoundingClientRect();
|
|
835
852
|
const placement = step.placement ?? (rect ? "bottom" : "center");
|
|
836
853
|
const panelStyle = placement === "center" || !rect ? { top: "50%", left: "50%", transform: "translate(-50%, -50%)" } : placement.startsWith("bottom") ? { top: rect.bottom + 14, left: rect.left + rect.width / 2, transform: "translateX(-50%)" } : placement.startsWith("top") ? { top: rect.top - 14, left: rect.left + rect.width / 2, transform: "translate(-50%, -100%)" } : placement === "left" ? { top: rect.top + rect.height / 2, left: rect.left - 14, transform: "translate(-100%, -50%)" } : { top: rect.top + rect.height / 2, left: rect.right + 14, transform: "translateY(-50%)" };
|
|
837
|
-
return createPortal(/* @__PURE__ */ jsxs5("div", { className: "sia-tour", role: "dialog", "aria-modal": "true", children: [
|
|
854
|
+
return createPortal(/* @__PURE__ */ jsxs5("div", { ref: motionRef, className: "sia-tour", role: "dialog", "aria-modal": "true", ...!open ? { inert: "" } : {}, children: [
|
|
838
855
|
mask && !rect ? /* @__PURE__ */ jsx5("div", { className: "sia-tour__mask" }) : null,
|
|
839
856
|
rect ? /* @__PURE__ */ jsx5("div", { className: "sia-tour__target", style: { top: rect.top - 5, left: rect.left - 5, width: rect.width + 10, height: rect.height + 10, pointerEvents: disabledInteraction ? "auto" : "none", boxShadow: mask ? "0 0 0 5px var(--sia-color-surface), 0 0 0 9999px rgb(0 0 0 / 46%)" : "0 0 0 5px var(--sia-color-surface)" } }) : null,
|
|
840
857
|
/* @__PURE__ */ jsxs5("div", { className: "sia-tour__panel", style: panelStyle, children: [
|
|
@@ -1077,6 +1094,7 @@ function Collapse({ items, activeKey, defaultActiveKey = [], accordion = false,
|
|
|
1077
1094
|
}
|
|
1078
1095
|
function ImagePreview({ open, src, alt = "", onOpenChange, current = 0, count = 1, onCurrentChange }) {
|
|
1079
1096
|
const previewRef = useRef4(null);
|
|
1097
|
+
const motion = useOverlayMotion(open, previewRef, "fade");
|
|
1080
1098
|
const stageRef = useRef4(null);
|
|
1081
1099
|
const [natural, setNatural] = useState5({ src: "", width: 0, height: 0 });
|
|
1082
1100
|
const [area, setArea] = useState5({ width: 0, height: 0 });
|
|
@@ -1086,7 +1104,9 @@ function ImagePreview({ open, src, alt = "", onOpenChange, current = 0, count =
|
|
|
1086
1104
|
const [pan, setPan] = useState5({ x: 0, y: 0 });
|
|
1087
1105
|
const [failed, setFailed] = useState5(false);
|
|
1088
1106
|
const drag = useRef4();
|
|
1089
|
-
useOverlayLifecycle(
|
|
1107
|
+
useOverlayLifecycle(motion.present, previewRef, () => {
|
|
1108
|
+
if (open) onOpenChange(false);
|
|
1109
|
+
});
|
|
1090
1110
|
const reset = () => {
|
|
1091
1111
|
setZoom(1);
|
|
1092
1112
|
setRotation(0);
|
|
@@ -1095,8 +1115,10 @@ function ImagePreview({ open, src, alt = "", onOpenChange, current = 0, count =
|
|
|
1095
1115
|
drag.current = void 0;
|
|
1096
1116
|
};
|
|
1097
1117
|
useEffect3(() => {
|
|
1098
|
-
|
|
1099
|
-
|
|
1118
|
+
if (open) {
|
|
1119
|
+
reset();
|
|
1120
|
+
setFailed(false);
|
|
1121
|
+
}
|
|
1100
1122
|
}, [open, src]);
|
|
1101
1123
|
useEffect3(() => {
|
|
1102
1124
|
if (!open || !onCurrentChange || count < 2) return;
|
|
@@ -1126,8 +1148,8 @@ function ImagePreview({ open, src, alt = "", onOpenChange, current = 0, count =
|
|
|
1126
1148
|
const sideways = Math.abs(rotation % 180) === 90;
|
|
1127
1149
|
const fit = ready ? Math.min(1, area.width / (sideways ? natural.height : natural.width), area.height / (sideways ? natural.width : natural.height)) : 0;
|
|
1128
1150
|
const changeZoom = (factor) => setZoom((value) => Math.max(0.25, Math.min(8, value * factor)));
|
|
1129
|
-
if (!
|
|
1130
|
-
return createPortal2(/* @__PURE__ */ jsxs6("div", { ref: previewRef, className: "sia-image-preview", role: "dialog", "aria-modal": "true", "aria-label": "\u56FE\u7247\u9884\u89C8", tabIndex: -1, onClick: () => onOpenChange(false), children: [
|
|
1151
|
+
if (!motion.present || !src || typeof document === "undefined") return null;
|
|
1152
|
+
return createPortal2(/* @__PURE__ */ jsxs6("div", { ref: previewRef, className: "sia-image-preview", style: { animation: "none", pointerEvents: open ? void 0 : "none" }, ...!open ? { inert: "" } : {}, role: "dialog", "aria-modal": "true", "aria-label": "\u56FE\u7247\u9884\u89C8", tabIndex: -1, onClick: () => onOpenChange(false), children: [
|
|
1131
1153
|
/* @__PURE__ */ jsx6(Button, { variant: "text", className: "sia-image-preview__close", "aria-label": "\u5173\u95ED\u9884\u89C8", onClick: (event) => {
|
|
1132
1154
|
event.stopPropagation();
|
|
1133
1155
|
onOpenChange(false);
|
|
@@ -1275,6 +1297,7 @@ function Image({ fallback, placeholder, preview = true, rootClassName = "", clas
|
|
|
1275
1297
|
}
|
|
1276
1298
|
|
|
1277
1299
|
// src/components/Message.tsx
|
|
1300
|
+
import { useEffect as useEffect4, useRef as useRef5 } from "react";
|
|
1278
1301
|
import { createRoot as createRoot2 } from "react-dom/client";
|
|
1279
1302
|
import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1280
1303
|
var messageSeed = 0;
|
|
@@ -1301,20 +1324,36 @@ function ensureMessageRoot() {
|
|
|
1301
1324
|
}
|
|
1302
1325
|
return true;
|
|
1303
1326
|
}
|
|
1304
|
-
function
|
|
1305
|
-
|
|
1306
|
-
|
|
1327
|
+
function MessageView({ item }) {
|
|
1328
|
+
const ref = useRef5(null);
|
|
1329
|
+
const motion = useOverlayMotion(!item.closing, ref, "toast", "bottom", true, (open) => {
|
|
1330
|
+
if (open) return;
|
|
1331
|
+
messageItems = messageItems.filter((candidate) => candidate.key !== item.key || !candidate.closing);
|
|
1332
|
+
renderMessages();
|
|
1333
|
+
});
|
|
1334
|
+
useEffect4(() => {
|
|
1335
|
+
if (motion.present || !item.closing) return;
|
|
1336
|
+
messageItems = messageItems.filter((candidate) => candidate.key !== item.key || !candidate.closing);
|
|
1337
|
+
renderMessages();
|
|
1338
|
+
}, [motion.present, item.key, item.closing]);
|
|
1339
|
+
if (!motion.present) return null;
|
|
1340
|
+
return /* @__PURE__ */ jsxs7("div", { ref, style: { animation: "none", pointerEvents: item.closing ? "none" : void 0 }, "aria-hidden": item.closing || void 0, className: `sia-message sia-message--${item.type}`, role: item.type === "loading" ? "status" : "alert", children: [
|
|
1307
1341
|
/* @__PURE__ */ jsx7("span", { className: "sia-message__icon", "aria-hidden": "true", children: messageIcons[item.type] }),
|
|
1308
1342
|
/* @__PURE__ */ jsx7("span", { className: "sia-message__content", children: item.content }),
|
|
1309
1343
|
item.closable ? /* @__PURE__ */ jsx7("button", { type: "button", className: "sia-message__close", "aria-label": "\u5173\u95ED\u63D0\u793A", onClick: () => closeMessage(item.key), children: /* @__PURE__ */ jsx7(Icon, { name: "close", size: 14 }) }) : null
|
|
1310
|
-
] }
|
|
1344
|
+
] });
|
|
1311
1345
|
}
|
|
1312
|
-
function
|
|
1346
|
+
function renderMessages() {
|
|
1347
|
+
if (!ensureMessageRoot()) return;
|
|
1348
|
+
messageRoot.render(/* @__PURE__ */ jsx7("div", { className: "sia-message-list", "aria-live": "polite", children: messageItems.map((item) => /* @__PURE__ */ jsx7(MessageView, { item }, item.key)) }));
|
|
1349
|
+
}
|
|
1350
|
+
function closeMessage(key, immediate = false) {
|
|
1313
1351
|
const item = messageItems.find((candidate) => candidate.key === key);
|
|
1352
|
+
if (!item || item.closing) return;
|
|
1314
1353
|
const timer = messageTimers.get(key);
|
|
1315
1354
|
if (timer !== void 0) window.clearTimeout(timer);
|
|
1316
1355
|
messageTimers.delete(key);
|
|
1317
|
-
messageItems = messageItems.filter((candidate) => candidate.key !== key);
|
|
1356
|
+
messageItems = immediate ? messageItems.filter((candidate) => candidate.key !== key) : messageItems.map((candidate) => candidate.key === key ? { ...candidate, closing: true } : candidate);
|
|
1318
1357
|
item?.onClose?.();
|
|
1319
1358
|
renderMessages();
|
|
1320
1359
|
}
|
|
@@ -1333,14 +1372,15 @@ function openMessage(input) {
|
|
|
1333
1372
|
const existingIndex = messageItems.findIndex((candidate) => candidate.key === key);
|
|
1334
1373
|
if (existingIndex >= 0) messageItems = messageItems.map((candidate, index) => index === existingIndex ? item : candidate);
|
|
1335
1374
|
else messageItems = [...messageItems, item];
|
|
1336
|
-
|
|
1375
|
+
messageItems = messageItems.filter((candidate) => !candidate.closing);
|
|
1376
|
+
while (messageItems.length > maxCount) closeMessage(messageItems[0].key, true);
|
|
1337
1377
|
renderMessages();
|
|
1338
1378
|
scheduleMessage(item);
|
|
1339
1379
|
return {
|
|
1340
1380
|
close: () => closeMessage(key),
|
|
1341
1381
|
update(next) {
|
|
1342
1382
|
const current = messageItems.find((candidate) => candidate.key === key);
|
|
1343
|
-
if (!current) return;
|
|
1383
|
+
if (!current || current.closing) return;
|
|
1344
1384
|
const updated = { ...current, ...next, key, type: next.type ?? current.type };
|
|
1345
1385
|
messageItems = messageItems.map((candidate) => candidate.key === key ? updated : candidate);
|
|
1346
1386
|
renderMessages();
|
|
@@ -1380,7 +1420,7 @@ var message = {
|
|
|
1380
1420
|
};
|
|
1381
1421
|
|
|
1382
1422
|
// src/components/Upload.tsx
|
|
1383
|
-
import { forwardRef, useEffect as
|
|
1423
|
+
import { forwardRef, useEffect as useEffect5, useImperativeHandle, useRef as useRef6, useState as useState6 } from "react";
|
|
1384
1424
|
|
|
1385
1425
|
// src/components/uploadFiles.ts
|
|
1386
1426
|
function acceptsUploadFile(file, accept) {
|
|
@@ -1515,7 +1555,7 @@ import { Fragment as Fragment4, jsx as jsx8, jsxs as jsxs8 } from "react/jsx-run
|
|
|
1515
1555
|
var LIST_IGNORE = /* @__PURE__ */ Symbol("SIA_UPLOAD_LIST_IGNORE");
|
|
1516
1556
|
function useThumbnail(file, accept) {
|
|
1517
1557
|
const [local, setLocal] = useState6();
|
|
1518
|
-
|
|
1558
|
+
useEffect5(() => {
|
|
1519
1559
|
if (!file?.thumbUrl && file?.originFileObj?.type.startsWith("image/")) {
|
|
1520
1560
|
const url = URL.createObjectURL(file.originFileObj);
|
|
1521
1561
|
setLocal(url);
|
|
@@ -1529,7 +1569,7 @@ function UploadItem({ file, files, props, actions }) {
|
|
|
1529
1569
|
const source = useThumbnail(file, props.accept);
|
|
1530
1570
|
const [failed, setFailed] = useState6(false);
|
|
1531
1571
|
const [downloading, setDownloading] = useState6(false);
|
|
1532
|
-
const downloadingRef =
|
|
1572
|
+
const downloadingRef = useRef6(false);
|
|
1533
1573
|
const canPreview = !!(source || file.url || file.originFileObj || props.onPreview);
|
|
1534
1574
|
const canDownload = !!(file.url || file.originFileObj || props.downloadRequest);
|
|
1535
1575
|
async function download() {
|
|
@@ -1545,7 +1585,7 @@ function UploadItem({ file, files, props, actions }) {
|
|
|
1545
1585
|
setDownloading(false);
|
|
1546
1586
|
}
|
|
1547
1587
|
}
|
|
1548
|
-
|
|
1588
|
+
useEffect5(() => setFailed(false), [source]);
|
|
1549
1589
|
const node = /* @__PURE__ */ jsxs8("div", { className: `sia-upload__item sia-upload__item--${file.status ?? "ready"}`, children: [
|
|
1550
1590
|
props.listType !== "text" ? /* @__PURE__ */ jsx8(Button, { variant: "text", className: "sia-upload__thumbnail", "aria-label": `\u9884\u89C8\u7F29\u7565\u56FE ${file.name}`, onClick: actions.preview, disabled: !canPreview, children: source && !failed ? /* @__PURE__ */ jsx8("img", { src: source, alt: file.name, onError: () => setFailed(true) }) : /* @__PURE__ */ jsx8(Icon, { name: file.type?.startsWith("image/") ? "image" : "file", size: 28 }) }) : /* @__PURE__ */ jsx8("span", { className: "sia-upload__file-icon", children: /* @__PURE__ */ jsx8(Icon, { name: file.status === "done" ? "circle-check" : "file", size: 24 }) }),
|
|
1551
1591
|
/* @__PURE__ */ jsx8("span", { className: "sia-upload__name", ...withTitleTooltip({ title: file.relativePath || file.name }), children: file.url ? /* @__PURE__ */ jsx8("a", { href: file.url, target: "_blank", rel: "noreferrer", children: file.name }) : file.name }),
|
|
@@ -1607,19 +1647,19 @@ var UploadRoot = forwardRef(function UploadRoot2({
|
|
|
1607
1647
|
const cardWidth = cardDimension(typeof cardSize === "number" ? cardSize : cardSize?.width);
|
|
1608
1648
|
const cardHeight = cardDimension(typeof cardSize === "number" ? cardSize : cardSize?.height);
|
|
1609
1649
|
const compactCard = listType === "picture-card" && (cardWidth < 88 || cardHeight < 88);
|
|
1610
|
-
const inputRef =
|
|
1650
|
+
const inputRef = useRef6(null);
|
|
1611
1651
|
const [internalFiles, setInternalFiles] = useState6(defaultFileList);
|
|
1612
1652
|
const files = fileList ?? internalFiles;
|
|
1613
|
-
const filesRef =
|
|
1653
|
+
const filesRef = useRef6(files);
|
|
1614
1654
|
filesRef.current = files;
|
|
1615
|
-
const tasks =
|
|
1616
|
-
const mounted =
|
|
1655
|
+
const tasks = useRef6(/* @__PURE__ */ new Map());
|
|
1656
|
+
const mounted = useRef6(true);
|
|
1617
1657
|
const [dragging, setDragging] = useState6(false);
|
|
1618
1658
|
const [preview, setPreview] = useState6();
|
|
1619
1659
|
const previewSource = useThumbnail(preview, accept);
|
|
1620
1660
|
const limit = maxCount2 === void 0 || !Number.isFinite(maxCount2) ? Infinity : Math.max(0, Math.floor(maxCount2));
|
|
1621
1661
|
const full = files.length >= limit;
|
|
1622
|
-
const current =
|
|
1662
|
+
const current = useRef6({ disabled, directory, recursive });
|
|
1623
1663
|
current.current = { disabled, directory, recursive };
|
|
1624
1664
|
function cancel(uid) {
|
|
1625
1665
|
const task = tasks.current.get(uid);
|
|
@@ -1631,14 +1671,14 @@ var UploadRoot = forwardRef(function UploadRoot2({
|
|
|
1631
1671
|
}
|
|
1632
1672
|
task?.finish();
|
|
1633
1673
|
}
|
|
1634
|
-
|
|
1674
|
+
useEffect5(() => {
|
|
1635
1675
|
mounted.current = true;
|
|
1636
1676
|
return () => {
|
|
1637
1677
|
mounted.current = false;
|
|
1638
1678
|
[...tasks.current.keys()].forEach(cancel);
|
|
1639
1679
|
};
|
|
1640
1680
|
}, []);
|
|
1641
|
-
|
|
1681
|
+
useEffect5(() => {
|
|
1642
1682
|
for (const uid of tasks.current.keys()) if (!files.some((file) => file.uid === uid)) cancel(uid);
|
|
1643
1683
|
if (preview && !files.some((file) => file.uid === preview.uid)) setPreview(void 0);
|
|
1644
1684
|
}, [files, preview]);
|
|
@@ -1913,7 +1953,7 @@ function Breadcrumb({ items, separator = "/", itemRender, className = "", ...pro
|
|
|
1913
1953
|
}
|
|
1914
1954
|
|
|
1915
1955
|
// src/components/Typography.tsx
|
|
1916
|
-
import { useEffect as
|
|
1956
|
+
import { useEffect as useEffect6, useLayoutEffect as useLayoutEffect3, useRef as useRef7, useState as useState7 } from "react";
|
|
1917
1957
|
import { Fragment as Fragment6, jsx as jsx10, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1918
1958
|
function TypographyContent({
|
|
1919
1959
|
as: Tag2 = "span",
|
|
@@ -1933,9 +1973,9 @@ function TypographyContent({
|
|
|
1933
1973
|
className = "",
|
|
1934
1974
|
...props
|
|
1935
1975
|
}) {
|
|
1936
|
-
const contentRef =
|
|
1937
|
-
const editRef =
|
|
1938
|
-
const timer =
|
|
1976
|
+
const contentRef = useRef7(null);
|
|
1977
|
+
const editRef = useRef7(null);
|
|
1978
|
+
const timer = useRef7();
|
|
1939
1979
|
const [localText, setLocalText] = useState7();
|
|
1940
1980
|
const [draft, setDraft] = useState7("");
|
|
1941
1981
|
const [editing, setEditing] = useState7(false);
|
|
@@ -1948,10 +1988,10 @@ function TypographyContent({
|
|
|
1948
1988
|
const requestedRows = typeof ellipsis === "object" ? ellipsis.rows ?? 1 : 1;
|
|
1949
1989
|
const rows = Number.isFinite(requestedRows) ? Math.max(1, Math.floor(requestedRows)) : 1;
|
|
1950
1990
|
const expandable = typeof ellipsis === "object" && ellipsis.expandable;
|
|
1951
|
-
|
|
1991
|
+
useEffect6(() => {
|
|
1952
1992
|
setLocalText(void 0);
|
|
1953
1993
|
}, [children]);
|
|
1954
|
-
|
|
1994
|
+
useEffect6(() => () => clearTimeout(timer.current), []);
|
|
1955
1995
|
useLayoutEffect3(() => {
|
|
1956
1996
|
const element = contentRef.current;
|
|
1957
1997
|
if (!element || !ellipsis || !expandable || editing || expanded) return;
|
|
@@ -2070,7 +2110,7 @@ var Typography = Object.assign(TypographyRoot, {
|
|
|
2070
2110
|
});
|
|
2071
2111
|
|
|
2072
2112
|
// src/components/FloatButton.tsx
|
|
2073
|
-
import { createContext as createContext2, forwardRef as forwardRef2, useContext as useContext2, useEffect as
|
|
2113
|
+
import { createContext as createContext2, forwardRef as forwardRef2, useContext as useContext2, useEffect as useEffect7, useId as useId3, useRef as useRef8, useState as useState8 } from "react";
|
|
2074
2114
|
import { jsx as jsx11, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
2075
2115
|
var GroupShape = createContext2(void 0);
|
|
2076
2116
|
var FloatButtonRoot = forwardRef2(function FloatButton({
|
|
@@ -2124,10 +2164,12 @@ function FloatButtonGroup({
|
|
|
2124
2164
|
...props
|
|
2125
2165
|
}) {
|
|
2126
2166
|
const [visible, setVisible] = useControllableState({ value: open, defaultValue: defaultOpen, onChange: onOpenChange });
|
|
2127
|
-
const rootRef =
|
|
2128
|
-
const triggerRef =
|
|
2167
|
+
const rootRef = useRef8(null);
|
|
2168
|
+
const triggerRef = useRef8(null);
|
|
2169
|
+
const listRef = useRef8(null);
|
|
2170
|
+
const motion = useOverlayMotion(!trigger || visible, listRef, "popup", placement, true, void 0, !!trigger);
|
|
2129
2171
|
const id = useId3();
|
|
2130
|
-
|
|
2172
|
+
useEffect7(() => {
|
|
2131
2173
|
if (!trigger || !visible) return;
|
|
2132
2174
|
const close = (event) => {
|
|
2133
2175
|
if (!rootRef.current?.contains(event.target)) setVisible(false);
|
|
@@ -2162,7 +2204,7 @@ function FloatButtonGroup({
|
|
|
2162
2204
|
}
|
|
2163
2205
|
},
|
|
2164
2206
|
children: [
|
|
2165
|
-
|
|
2207
|
+
motion.present ? /* @__PURE__ */ jsx11("div", { ref: listRef, id, className: "sia-float-button-group__list", "aria-hidden": !!trigger && !visible || void 0, ...trigger && !visible ? { inert: "" } : {}, style: { animation: "none", transformOrigin: placement === "top" ? "bottom center" : placement === "bottom" ? "top center" : placement === "left" ? "right center" : "left center" }, children }) : null,
|
|
2166
2208
|
trigger ? /* @__PURE__ */ jsx11(
|
|
2167
2209
|
FloatButtonRoot,
|
|
2168
2210
|
{
|
|
@@ -2182,7 +2224,9 @@ function FloatButtonGroup({
|
|
|
2182
2224
|
}
|
|
2183
2225
|
function FloatButtonBackTop({ target, visibilityHeight = 400, behavior = "smooth", onClick, icon, tooltip = "\u8FD4\u56DE\u9876\u90E8", ...props }) {
|
|
2184
2226
|
const [visible, setVisible] = useState8(false);
|
|
2185
|
-
|
|
2227
|
+
const buttonRef = useRef8(null);
|
|
2228
|
+
const motion = useOverlayMotion(visible, buttonRef, "fade");
|
|
2229
|
+
useEffect7(() => {
|
|
2186
2230
|
const element = target ? target() : window;
|
|
2187
2231
|
if (!element) return;
|
|
2188
2232
|
const update = () => setVisible((element === window ? window.scrollY : element.scrollTop) >= visibilityHeight);
|
|
@@ -2190,8 +2234,8 @@ function FloatButtonBackTop({ target, visibilityHeight = 400, behavior = "smooth
|
|
|
2190
2234
|
element.addEventListener("scroll", update, { passive: true });
|
|
2191
2235
|
return () => element.removeEventListener("scroll", update);
|
|
2192
2236
|
}, [target, visibilityHeight]);
|
|
2193
|
-
if (!
|
|
2194
|
-
return /* @__PURE__ */ jsx11(FloatButtonRoot, { ...props, tooltip, icon: icon ?? /* @__PURE__ */ jsx11(Icon, { name: "arrow-up", size: 20 }), onClick: (event) => {
|
|
2237
|
+
if (!motion.present) return null;
|
|
2238
|
+
return /* @__PURE__ */ jsx11(FloatButtonRoot, { ...props, ref: buttonRef, ...!visible ? { inert: "", "aria-hidden": true } : {}, tooltip, icon: icon ?? /* @__PURE__ */ jsx11(Icon, { name: "arrow-up", size: 20 }), onClick: (event) => {
|
|
2195
2239
|
onClick?.(event);
|
|
2196
2240
|
if (event.defaultPrevented) return;
|
|
2197
2241
|
const element = target ? target() : window;
|
|
@@ -2201,7 +2245,7 @@ function FloatButtonBackTop({ target, visibilityHeight = 400, behavior = "smooth
|
|
|
2201
2245
|
var FloatButton2 = Object.assign(FloatButtonRoot, {
|
|
2202
2246
|
/** 组合多个子项并统一管理布局或选择状态。 */
|
|
2203
2247
|
Group: FloatButtonGroup,
|
|
2204
|
-
/**
|
|
2248
|
+
/** 滚动超过指定距离后以 180ms 淡入的返回顶部按钮;回到阈值内按同一轨迹反向淡出,减少动态效果时直接切换。 */
|
|
2205
2249
|
BackTop: FloatButtonBackTop
|
|
2206
2250
|
});
|
|
2207
2251
|
|