@qq1948037137/adminsmart-ui 0.1.21 → 0.1.23
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/README.md +3 -1
- package/dist/index.cjs +602 -72
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +86 -2
- package/dist/index.d.ts +86 -2
- package/dist/index.js +598 -69
- package/dist/index.js.map +1 -1
- package/package.json +10 -4
- package/styles/composites.css +131 -0
package/dist/index.js
CHANGED
|
@@ -439,7 +439,7 @@ import { Watermark as AntWatermark } from "antd";
|
|
|
439
439
|
var Watermark = wrapAntComponent(AntWatermark, "Watermark");
|
|
440
440
|
|
|
441
441
|
// src/index.ts
|
|
442
|
-
import { theme as
|
|
442
|
+
import { theme as theme3 } from "antd";
|
|
443
443
|
|
|
444
444
|
// src/composites/BusinessDrawer.tsx
|
|
445
445
|
import { forwardRef as forwardRef3 } from "react";
|
|
@@ -467,15 +467,543 @@ var BusinessDrawer = forwardRef3(function BusinessDrawer2({ sizeVariant = "stand
|
|
|
467
467
|
);
|
|
468
468
|
});
|
|
469
469
|
|
|
470
|
+
// src/composites/SessionReplay.tsx
|
|
471
|
+
import { forwardRef as forwardRef4, useCallback as useCallback2, useEffect as useEffect2, useImperativeHandle, useRef as useRef2, useState as useState2 } from "react";
|
|
472
|
+
import { FullscreenExitOutlined, FullscreenOutlined, PauseOutlined, PlayCircleOutlined, RedoOutlined, StepBackwardOutlined, StepForwardOutlined } from "@ant-design/icons";
|
|
473
|
+
import { Alert as Alert2, Button as Button2, Empty as Empty2, Select as Select2, Slider as Slider2, Spin as Spin2, Tag as Tag2, Tooltip as Tooltip2, Typography as Typography2, theme } from "antd";
|
|
474
|
+
|
|
475
|
+
// src/composites/sessionReplayModel.ts
|
|
476
|
+
function finiteReplayNumber(value, fallback = 0) {
|
|
477
|
+
return typeof value === "number" && Number.isFinite(value) ? value : fallback;
|
|
478
|
+
}
|
|
479
|
+
function prepareReplayEvents(events) {
|
|
480
|
+
if (!Array.isArray(events) || events.length < 2) throw new Error("\u5F53\u524D\u56DE\u653E\u6CA1\u6709\u8DB3\u591F\u7684\u9875\u9762\u4E8B\u4EF6");
|
|
481
|
+
let previous = -Infinity;
|
|
482
|
+
for (const event of events) {
|
|
483
|
+
if (!event || typeof event !== "object" || !Number.isFinite(event.timestamp) || event.timestamp < previous)
|
|
484
|
+
throw new Error("\u5F53\u524D\u56DE\u653E\u4E8B\u4EF6\u65F6\u95F4\u65E0\u6548\uFF0C\u65E0\u6CD5\u8FD8\u539F\u9875\u9762");
|
|
485
|
+
previous = event.timestamp;
|
|
486
|
+
}
|
|
487
|
+
const copied = structuredClone(events);
|
|
488
|
+
const normalizeNode = (node) => {
|
|
489
|
+
if (!node || typeof node !== "object") return node;
|
|
490
|
+
const value = node;
|
|
491
|
+
if (String(value.tagName || "").toLowerCase() === "script") return null;
|
|
492
|
+
if (value.type === 1) {
|
|
493
|
+
value.name = "html";
|
|
494
|
+
value.publicId = "";
|
|
495
|
+
value.systemId = "";
|
|
496
|
+
}
|
|
497
|
+
if (value.type === 0 && value.compatMode !== "CSS1Compat" && value.compatMode !== "BackCompat")
|
|
498
|
+
delete value.compatMode;
|
|
499
|
+
if (Array.isArray(value.childNodes)) value.childNodes = value.childNodes.map(normalizeNode).filter(Boolean);
|
|
500
|
+
return value;
|
|
501
|
+
};
|
|
502
|
+
let hasSnapshot = false;
|
|
503
|
+
for (const event of copied) {
|
|
504
|
+
const data = event.data;
|
|
505
|
+
if (!data || typeof data !== "object") continue;
|
|
506
|
+
if (data.node) {
|
|
507
|
+
data.node = normalizeNode(data.node);
|
|
508
|
+
const node = data.node;
|
|
509
|
+
if (event.type === 2 && node?.type === 0 && Array.isArray(node.childNodes) && node.childNodes.length)
|
|
510
|
+
hasSnapshot = true;
|
|
511
|
+
}
|
|
512
|
+
if (Array.isArray(data.adds)) data.adds = data.adds.map((entry) => {
|
|
513
|
+
const addition = entry;
|
|
514
|
+
return { ...addition, node: normalizeNode(addition.node) };
|
|
515
|
+
}).filter((entry) => entry.node);
|
|
516
|
+
}
|
|
517
|
+
if (!hasSnapshot) throw new Error("\u5F53\u524D\u56DE\u653E\u7F3A\u5C11\u5B8C\u6574\u9875\u9762\u5FEB\u7167\uFF0C\u65E0\u6CD5\u8FD8\u539F\u9875\u9762");
|
|
518
|
+
return copied;
|
|
519
|
+
}
|
|
520
|
+
function replayRange(totalTime, startOffsetMs = 0, endOffsetMs) {
|
|
521
|
+
const duration = Math.max(0, finiteReplayNumber(totalTime));
|
|
522
|
+
const start = Math.min(duration, Math.max(0, finiteReplayNumber(startOffsetMs)));
|
|
523
|
+
const end = Math.min(duration, Math.max(start, finiteReplayNumber(endOffsetMs, duration)));
|
|
524
|
+
const total = end - start;
|
|
525
|
+
return {
|
|
526
|
+
start,
|
|
527
|
+
// 恢复到此内部时间后开始显示进度。
|
|
528
|
+
end,
|
|
529
|
+
// 所有播放和跳转不得越过此边界。
|
|
530
|
+
total,
|
|
531
|
+
// 控制栏显示此窗口长度。
|
|
532
|
+
toInternal: (visible) => start + Math.min(total, Math.max(0, finiteReplayNumber(visible))),
|
|
533
|
+
// 可见转内部。
|
|
534
|
+
toVisible: (internal) => Math.min(total, Math.max(0, finiteReplayNumber(internal) - start))
|
|
535
|
+
// 内部转可见。
|
|
536
|
+
};
|
|
537
|
+
}
|
|
538
|
+
function inclusivePauseOffset(events, target) {
|
|
539
|
+
const logicalTarget = Math.max(0, finiteReplayNumber(target));
|
|
540
|
+
const baseline = finiteReplayNumber(events[0]?.timestamp) + logicalTarget;
|
|
541
|
+
let equalEvent = false;
|
|
542
|
+
let increment = 1;
|
|
543
|
+
for (const event of events) {
|
|
544
|
+
if (event.timestamp === baseline) equalEvent = true;
|
|
545
|
+
if (event.timestamp > baseline) {
|
|
546
|
+
increment = Math.min(increment, event.timestamp - baseline);
|
|
547
|
+
break;
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
return equalEvent ? logicalTarget + increment : logicalTarget;
|
|
551
|
+
}
|
|
552
|
+
function replayFit(stageWidth, stageHeight, contentWidth, contentHeight) {
|
|
553
|
+
const width = Math.max(1, finiteReplayNumber(contentWidth, 1));
|
|
554
|
+
const height = Math.max(1, finiteReplayNumber(contentHeight, 1));
|
|
555
|
+
const scale = Math.min(1, Math.max(0, finiteReplayNumber(stageWidth)) / width, Math.max(0, finiteReplayNumber(stageHeight)) / height);
|
|
556
|
+
return {
|
|
557
|
+
scale,
|
|
558
|
+
// 作用于官方公开 wrapper。
|
|
559
|
+
left: Math.max(0, (stageWidth - width * scale) / 2),
|
|
560
|
+
// 水平居中。
|
|
561
|
+
top: Math.max(0, (stageHeight - height * scale) / 2)
|
|
562
|
+
// 垂直居中。
|
|
563
|
+
};
|
|
564
|
+
}
|
|
565
|
+
function replayClock(timeMs) {
|
|
566
|
+
const seconds = Math.floor(Math.max(0, finiteReplayNumber(timeMs)) / 1e3);
|
|
567
|
+
return `${String(Math.floor(seconds / 60)).padStart(2, "0")}:${String(seconds % 60).padStart(2, "0")}`;
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
// src/composites/useSessionReplay.ts
|
|
571
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
572
|
+
|
|
573
|
+
// src/composites/sessionReplayEngine.ts
|
|
574
|
+
async function loadReplayEngine() {
|
|
575
|
+
const [, module] = await Promise.all([import("@rrweb/replay/dist/style.css"), import("@rrweb/replay")]);
|
|
576
|
+
return module.Replayer;
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
// src/composites/useSessionReplay.ts
|
|
580
|
+
function initialState(status) {
|
|
581
|
+
return {
|
|
582
|
+
status,
|
|
583
|
+
// 由容器可见性与输入决定。
|
|
584
|
+
currentTimeMs: 0,
|
|
585
|
+
// 新录像从可见起点开始。
|
|
586
|
+
durationMs: 0,
|
|
587
|
+
// 只有官方元数据能够确定时长。
|
|
588
|
+
playing: false,
|
|
589
|
+
// 未恢复快照前不宣称播放中。
|
|
590
|
+
playbackRate: 1
|
|
591
|
+
// 各次录像使用原速。
|
|
592
|
+
};
|
|
593
|
+
}
|
|
594
|
+
function useSessionReplay(options) {
|
|
595
|
+
const [state, setState] = useState(() => initialState("idle"));
|
|
596
|
+
const stateRef = useRef(state);
|
|
597
|
+
const engineRef = useRef(null);
|
|
598
|
+
const runtimeFailureRef = useRef(null);
|
|
599
|
+
const rangeRef = useRef(replayRange(0));
|
|
600
|
+
const replayEventsRef = useRef([]);
|
|
601
|
+
const callbackRef = useRef(options);
|
|
602
|
+
callbackRef.current = options;
|
|
603
|
+
const publish = useCallback((next) => {
|
|
604
|
+
stateRef.current = next;
|
|
605
|
+
setState(next);
|
|
606
|
+
callbackRef.current.onStateChange?.({ ...next });
|
|
607
|
+
}, []);
|
|
608
|
+
useEffect(() => {
|
|
609
|
+
const { active, loading, error, events, stageRef, rootRef, startOffsetMs, endOffsetMs, autoPlay } = options;
|
|
610
|
+
engineRef.current = null;
|
|
611
|
+
runtimeFailureRef.current = null;
|
|
612
|
+
rangeRef.current = replayRange(0);
|
|
613
|
+
replayEventsRef.current = [];
|
|
614
|
+
if (!active) {
|
|
615
|
+
publish(initialState("idle"));
|
|
616
|
+
return;
|
|
617
|
+
}
|
|
618
|
+
if (loading) {
|
|
619
|
+
publish(initialState("loading"));
|
|
620
|
+
return;
|
|
621
|
+
}
|
|
622
|
+
if (error) {
|
|
623
|
+
publish(initialState("error"));
|
|
624
|
+
return;
|
|
625
|
+
}
|
|
626
|
+
if (!events.length) {
|
|
627
|
+
publish(initialState("empty"));
|
|
628
|
+
return;
|
|
629
|
+
}
|
|
630
|
+
let prepared;
|
|
631
|
+
try {
|
|
632
|
+
prepared = prepareReplayEvents(events);
|
|
633
|
+
} catch (reason) {
|
|
634
|
+
const knownMessages = ["\u5F53\u524D\u56DE\u653E\u6CA1\u6709\u8DB3\u591F\u7684\u9875\u9762\u4E8B\u4EF6", "\u5F53\u524D\u56DE\u653E\u4E8B\u4EF6\u65F6\u95F4\u65E0\u6548\uFF0C\u65E0\u6CD5\u8FD8\u539F\u9875\u9762", "\u5F53\u524D\u56DE\u653E\u7F3A\u5C11\u5B8C\u6574\u9875\u9762\u5FEB\u7167\uFF0C\u65E0\u6CD5\u8FD8\u539F\u9875\u9762"];
|
|
635
|
+
const problem = { code: "invalid-events", message: reason instanceof Error && knownMessages.includes(reason.message) ? reason.message : "\u5F53\u524D\u56DE\u653E\u6570\u636E\u65E0\u6CD5\u8FD8\u539F\u9875\u9762" };
|
|
636
|
+
publish(initialState("error"));
|
|
637
|
+
callbackRef.current.onError?.(problem);
|
|
638
|
+
return;
|
|
639
|
+
}
|
|
640
|
+
replayEventsRef.current = prepared;
|
|
641
|
+
publish(initialState("loading"));
|
|
642
|
+
let current = true;
|
|
643
|
+
let failed = false;
|
|
644
|
+
let Constructor = null;
|
|
645
|
+
let player = null;
|
|
646
|
+
let snapshotReady = false;
|
|
647
|
+
let progressTimer;
|
|
648
|
+
let rebuildTimer;
|
|
649
|
+
let fitFrame;
|
|
650
|
+
let autoPlayFrame;
|
|
651
|
+
let observer = null;
|
|
652
|
+
const listeners = [];
|
|
653
|
+
const stopProgress = () => {
|
|
654
|
+
if (progressTimer !== void 0) window.clearInterval(progressTimer);
|
|
655
|
+
progressTimer = void 0;
|
|
656
|
+
};
|
|
657
|
+
const releaseEngine = () => {
|
|
658
|
+
stopProgress();
|
|
659
|
+
if (rebuildTimer !== void 0) window.clearTimeout(rebuildTimer);
|
|
660
|
+
if (fitFrame !== void 0) window.cancelAnimationFrame(fitFrame);
|
|
661
|
+
if (autoPlayFrame !== void 0) window.cancelAnimationFrame(autoPlayFrame);
|
|
662
|
+
if (player) {
|
|
663
|
+
for (const [eventName, handler] of listeners) player.off(eventName, handler);
|
|
664
|
+
try {
|
|
665
|
+
player.destroy();
|
|
666
|
+
} catch {
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
if (engineRef.current === player) engineRef.current = null;
|
|
670
|
+
player = null;
|
|
671
|
+
rootRef.current?.replaceChildren();
|
|
672
|
+
};
|
|
673
|
+
const fail = (code, message) => {
|
|
674
|
+
if (!current || failed) return;
|
|
675
|
+
failed = true;
|
|
676
|
+
releaseEngine();
|
|
677
|
+
observer?.disconnect();
|
|
678
|
+
publish(initialState("error"));
|
|
679
|
+
callbackRef.current.onError?.({ code, message });
|
|
680
|
+
};
|
|
681
|
+
const commandFailure = () => fail("rebuild-failed", "\u56DE\u653E\u9875\u9762\u6062\u590D\u5931\u8D25\uFF0C\u8BF7\u91CD\u65B0\u6253\u5F00\u56DE\u653E");
|
|
682
|
+
runtimeFailureRef.current = commandFailure;
|
|
683
|
+
const fit = () => {
|
|
684
|
+
if (!current || !player || !stageRef.current) return;
|
|
685
|
+
const dimensions = replayFit(stageRef.current.clientWidth, stageRef.current.clientHeight, Number(player.iframe.width), Number(player.iframe.height));
|
|
686
|
+
player.wrapper.style.position = "absolute";
|
|
687
|
+
player.wrapper.style.left = `${dimensions.left}px`;
|
|
688
|
+
player.wrapper.style.top = `${dimensions.top}px`;
|
|
689
|
+
player.wrapper.style.transformOrigin = "top left";
|
|
690
|
+
player.wrapper.style.transform = `scale(${dimensions.scale})`;
|
|
691
|
+
};
|
|
692
|
+
const scheduleFit = () => {
|
|
693
|
+
if (fitFrame !== void 0) window.cancelAnimationFrame(fitFrame);
|
|
694
|
+
fitFrame = window.requestAnimationFrame(() => {
|
|
695
|
+
fitFrame = void 0;
|
|
696
|
+
fit();
|
|
697
|
+
});
|
|
698
|
+
};
|
|
699
|
+
const startProgress = () => {
|
|
700
|
+
stopProgress();
|
|
701
|
+
progressTimer = window.setInterval(() => {
|
|
702
|
+
if (!current || !player || !snapshotReady) return;
|
|
703
|
+
try {
|
|
704
|
+
const time = player.getCurrentTime();
|
|
705
|
+
if (time >= rangeRef.current.end) {
|
|
706
|
+
player.pause(inclusivePauseOffset(prepared, rangeRef.current.end));
|
|
707
|
+
stopProgress();
|
|
708
|
+
publish({ ...stateRef.current, currentTimeMs: rangeRef.current.total, playing: false });
|
|
709
|
+
} else publish({ ...stateRef.current, currentTimeMs: rangeRef.current.toVisible(time) });
|
|
710
|
+
} catch {
|
|
711
|
+
fail("rebuild-failed", "\u56DE\u653E\u9875\u9762\u6062\u590D\u5931\u8D25\uFF0C\u8BF7\u91CD\u65B0\u6253\u5F00\u56DE\u653E");
|
|
712
|
+
}
|
|
713
|
+
}, 100);
|
|
714
|
+
};
|
|
715
|
+
const start = () => {
|
|
716
|
+
if (!current || failed || player || !Constructor || !stageRef.current || !rootRef.current) return;
|
|
717
|
+
if (stageRef.current.clientWidth <= 0 || stageRef.current.clientHeight <= 0) return;
|
|
718
|
+
try {
|
|
719
|
+
player = new Constructor(prepared, {
|
|
720
|
+
root: rootRef.current,
|
|
721
|
+
// 实例只能挂载在自己的专属节点。
|
|
722
|
+
skipInactive: false,
|
|
723
|
+
// 时间轴与用户可见窗口保持一致。
|
|
724
|
+
showDebug: false,
|
|
725
|
+
// 不输出授权录像数据。
|
|
726
|
+
showWarning: false,
|
|
727
|
+
// 友好错误由包装层统一处理。
|
|
728
|
+
mouseTail: false,
|
|
729
|
+
// 不额外生成画布轨迹。
|
|
730
|
+
triggerFocus: false,
|
|
731
|
+
// 回放不能改变宿主焦点。
|
|
732
|
+
UNSAFE_replayCanvas: false,
|
|
733
|
+
// 禁止不受保护的脚本/画布重建。
|
|
734
|
+
logger: { log() {
|
|
735
|
+
}, warn() {
|
|
736
|
+
} }
|
|
737
|
+
// 官方日志不会带事件进入控制台。
|
|
738
|
+
});
|
|
739
|
+
engineRef.current = player;
|
|
740
|
+
rangeRef.current = replayRange(player.getMetaData().totalTime, startOffsetMs, endOffsetMs);
|
|
741
|
+
const listen = (eventName, handler) => {
|
|
742
|
+
listeners.push([eventName, handler]);
|
|
743
|
+
player.on(eventName, handler);
|
|
744
|
+
};
|
|
745
|
+
listen("fullsnapshot-rebuilded", () => {
|
|
746
|
+
if (!current || !player) return;
|
|
747
|
+
if (!player.iframe.contentDocument?.documentElement || !player.iframe.contentDocument?.body) {
|
|
748
|
+
fail("rebuild-failed", "\u56DE\u653E\u9875\u9762\u5FEB\u7167\u4E0D\u5B8C\u6574\uFF0C\u65E0\u6CD5\u663E\u793A\u753B\u9762");
|
|
749
|
+
return;
|
|
750
|
+
}
|
|
751
|
+
scheduleFit();
|
|
752
|
+
if (snapshotReady) return;
|
|
753
|
+
snapshotReady = true;
|
|
754
|
+
if (rebuildTimer !== void 0) window.clearTimeout(rebuildTimer);
|
|
755
|
+
publish({ ...initialState("ready"), durationMs: rangeRef.current.total });
|
|
756
|
+
if (autoPlay && rangeRef.current.total > 0) autoPlayFrame = window.requestAnimationFrame(() => {
|
|
757
|
+
autoPlayFrame = void 0;
|
|
758
|
+
if (current && player) player.play(rangeRef.current.start);
|
|
759
|
+
});
|
|
760
|
+
});
|
|
761
|
+
listen("resize", scheduleFit);
|
|
762
|
+
listen("start", () => {
|
|
763
|
+
if (!current || !snapshotReady) return;
|
|
764
|
+
publish({ ...stateRef.current, playing: true });
|
|
765
|
+
startProgress();
|
|
766
|
+
});
|
|
767
|
+
listen("pause", () => {
|
|
768
|
+
stopProgress();
|
|
769
|
+
if (current && snapshotReady) publish({ ...stateRef.current, playing: false });
|
|
770
|
+
});
|
|
771
|
+
listen("finish", () => {
|
|
772
|
+
stopProgress();
|
|
773
|
+
if (current && snapshotReady) publish({ ...stateRef.current, currentTimeMs: rangeRef.current.total, playing: false });
|
|
774
|
+
});
|
|
775
|
+
rebuildTimer = window.setTimeout(() => {
|
|
776
|
+
if (!snapshotReady) fail("rebuild-failed", "\u56DE\u653E\u9875\u9762\u672A\u80FD\u5B8C\u6210\u6062\u590D\uFF0C\u8BF7\u91CD\u65B0\u6253\u5F00\u56DE\u653E");
|
|
777
|
+
}, 4e3);
|
|
778
|
+
player.pause(inclusivePauseOffset(prepared, rangeRef.current.start));
|
|
779
|
+
scheduleFit();
|
|
780
|
+
} catch {
|
|
781
|
+
fail("rebuild-failed", "\u56DE\u653E\u9875\u9762\u6062\u590D\u5931\u8D25\uFF0C\u8BF7\u91CD\u65B0\u6253\u5F00\u56DE\u653E");
|
|
782
|
+
}
|
|
783
|
+
};
|
|
784
|
+
const onLayout = () => {
|
|
785
|
+
start();
|
|
786
|
+
scheduleFit();
|
|
787
|
+
};
|
|
788
|
+
if (typeof ResizeObserver === "function" && stageRef.current) {
|
|
789
|
+
observer = new ResizeObserver(onLayout);
|
|
790
|
+
observer.observe(stageRef.current);
|
|
791
|
+
}
|
|
792
|
+
window.addEventListener("resize", onLayout);
|
|
793
|
+
loadReplayEngine().then((value) => {
|
|
794
|
+
if (!current) return;
|
|
795
|
+
Constructor = value;
|
|
796
|
+
start();
|
|
797
|
+
}).catch(() => fail("engine-load", "\u56DE\u653E\u7EC4\u4EF6\u52A0\u8F7D\u5931\u8D25\uFF0C\u8BF7\u91CD\u65B0\u6253\u5F00\u56DE\u653E"));
|
|
798
|
+
return () => {
|
|
799
|
+
current = false;
|
|
800
|
+
observer?.disconnect();
|
|
801
|
+
window.removeEventListener("resize", onLayout);
|
|
802
|
+
if (runtimeFailureRef.current === commandFailure) runtimeFailureRef.current = null;
|
|
803
|
+
if (replayEventsRef.current === prepared) replayEventsRef.current = [];
|
|
804
|
+
releaseEngine();
|
|
805
|
+
};
|
|
806
|
+
}, [options.active, options.loading, options.error, options.events, options.startOffsetMs, options.endOffsetMs, options.autoPlay, options.stageRef, options.rootRef, publish]);
|
|
807
|
+
const play = useCallback(() => {
|
|
808
|
+
if (!engineRef.current || stateRef.current.status !== "ready" || !rangeRef.current.total) return;
|
|
809
|
+
const target = stateRef.current.currentTimeMs >= rangeRef.current.total ? 0 : stateRef.current.currentTimeMs;
|
|
810
|
+
try {
|
|
811
|
+
engineRef.current.play(rangeRef.current.toInternal(target));
|
|
812
|
+
} catch {
|
|
813
|
+
runtimeFailureRef.current?.();
|
|
814
|
+
return;
|
|
815
|
+
}
|
|
816
|
+
publish({ ...stateRef.current, currentTimeMs: target, playing: true });
|
|
817
|
+
}, [publish]);
|
|
818
|
+
const pause = useCallback(() => {
|
|
819
|
+
if (!engineRef.current || stateRef.current.status !== "ready" || !stateRef.current.playing) return;
|
|
820
|
+
let time;
|
|
821
|
+
try {
|
|
822
|
+
time = rangeRef.current.toInternal(rangeRef.current.toVisible(engineRef.current.getCurrentTime()));
|
|
823
|
+
engineRef.current.pause(inclusivePauseOffset(replayEventsRef.current, time));
|
|
824
|
+
} catch {
|
|
825
|
+
runtimeFailureRef.current?.();
|
|
826
|
+
return;
|
|
827
|
+
}
|
|
828
|
+
publish({ ...stateRef.current, currentTimeMs: rangeRef.current.toVisible(time), playing: false });
|
|
829
|
+
}, [publish]);
|
|
830
|
+
const seek = useCallback((timeMs) => {
|
|
831
|
+
if (!engineRef.current || stateRef.current.status !== "ready") return;
|
|
832
|
+
const target = rangeRef.current.toInternal(timeMs);
|
|
833
|
+
try {
|
|
834
|
+
engineRef.current.pause(inclusivePauseOffset(replayEventsRef.current, target));
|
|
835
|
+
} catch {
|
|
836
|
+
runtimeFailureRef.current?.();
|
|
837
|
+
return;
|
|
838
|
+
}
|
|
839
|
+
publish({ ...stateRef.current, currentTimeMs: rangeRef.current.toVisible(target), playing: false });
|
|
840
|
+
}, [publish]);
|
|
841
|
+
const restart = useCallback(() => {
|
|
842
|
+
seek(0);
|
|
843
|
+
play();
|
|
844
|
+
}, [play, seek]);
|
|
845
|
+
const setPlaybackRate = useCallback((rate) => {
|
|
846
|
+
if (!engineRef.current || stateRef.current.status !== "ready" || !Number.isFinite(rate) || rate <= 0 || rate > 4) return;
|
|
847
|
+
try {
|
|
848
|
+
engineRef.current.setConfig({ speed: rate });
|
|
849
|
+
} catch {
|
|
850
|
+
runtimeFailureRef.current?.();
|
|
851
|
+
return;
|
|
852
|
+
}
|
|
853
|
+
publish({ ...stateRef.current, playbackRate: rate });
|
|
854
|
+
}, [publish]);
|
|
855
|
+
const getState = useCallback(() => ({ ...stateRef.current }), []);
|
|
856
|
+
return { state, play, pause, seek, restart, setPlaybackRate, getState };
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
// src/composites/SessionReplay.tsx
|
|
860
|
+
import { jsx as jsx4, jsxs } from "react/jsx-runtime";
|
|
861
|
+
var playbackRates = [0.5, 1, 1.5, 2];
|
|
862
|
+
var SessionReplay = forwardRef4(function SessionReplay2({ events, active = true, loading = false, error, startOffsetMs, endOffsetMs, autoPlay = false, markers = [], extra, onStateChange, onError, className, style }, ref) {
|
|
863
|
+
const { token } = theme.useToken();
|
|
864
|
+
const containerRef = useRef2(null);
|
|
865
|
+
const stageRef = useRef2(null);
|
|
866
|
+
const rootRef = useRef2(null);
|
|
867
|
+
const [problem, setProblem] = useState2(null);
|
|
868
|
+
const [fullscreen, setFullscreen] = useState2(false);
|
|
869
|
+
const reportError = useCallback2((value) => {
|
|
870
|
+
setProblem(value);
|
|
871
|
+
onError?.(value);
|
|
872
|
+
}, [onError]);
|
|
873
|
+
useEffect2(() => {
|
|
874
|
+
setProblem(null);
|
|
875
|
+
}, [events, active, loading, error, startOffsetMs, endOffsetMs]);
|
|
876
|
+
const controls = useSessionReplay({ events, active, loading, error, startOffsetMs, endOffsetMs, autoPlay, stageRef, rootRef, onStateChange, onError: reportError });
|
|
877
|
+
const { state, play, pause, seek, restart, getState, setPlaybackRate } = controls;
|
|
878
|
+
const ready = state.status === "ready";
|
|
879
|
+
const themeStyle = {
|
|
880
|
+
"--adminsmart-replay-bg": token.colorBgLayout,
|
|
881
|
+
// 舞台周围的中性背景。
|
|
882
|
+
"--adminsmart-replay-surface": token.colorBgContainer,
|
|
883
|
+
// 控制区容器背景。
|
|
884
|
+
"--adminsmart-replay-border": token.colorBorderSecondary,
|
|
885
|
+
// 轻量边界。
|
|
886
|
+
"--adminsmart-replay-text": token.colorText,
|
|
887
|
+
// 主信息文字。
|
|
888
|
+
"--adminsmart-replay-muted": token.colorTextSecondary,
|
|
889
|
+
// 次要时间和提示。
|
|
890
|
+
"--adminsmart-replay-primary": token.colorPrimary,
|
|
891
|
+
// 通用时间标记。
|
|
892
|
+
"--adminsmart-replay-warning": token.colorWarning,
|
|
893
|
+
// 警告标记。
|
|
894
|
+
"--adminsmart-replay-error": token.colorError,
|
|
895
|
+
// 错误标记。
|
|
896
|
+
"--adminsmart-replay-radius": `${token.borderRadiusLG}px`,
|
|
897
|
+
// 主题圆角。
|
|
898
|
+
...style
|
|
899
|
+
};
|
|
900
|
+
useImperativeHandle(ref, () => ({ play, pause, seek, restart, getState }), [play, pause, seek, restart, getState]);
|
|
901
|
+
useEffect2(() => {
|
|
902
|
+
if (!active) return;
|
|
903
|
+
const container = containerRef.current;
|
|
904
|
+
const sync = () => setFullscreen(document.fullscreenElement === container);
|
|
905
|
+
document.addEventListener("fullscreenchange", sync);
|
|
906
|
+
sync();
|
|
907
|
+
return () => {
|
|
908
|
+
document.removeEventListener("fullscreenchange", sync);
|
|
909
|
+
if (document.fullscreenElement === container) void document.exitFullscreen?.().catch(() => {
|
|
910
|
+
});
|
|
911
|
+
};
|
|
912
|
+
}, [active]);
|
|
913
|
+
const toggleFullscreen = async () => {
|
|
914
|
+
if (!containerRef.current || !ready) return;
|
|
915
|
+
try {
|
|
916
|
+
if (document.fullscreenElement === containerRef.current) await document.exitFullscreen();
|
|
917
|
+
else await containerRef.current.requestFullscreen();
|
|
918
|
+
if (problem?.code === "fullscreen") setProblem(null);
|
|
919
|
+
} catch {
|
|
920
|
+
reportError({ code: "fullscreen", message: "\u6D4F\u89C8\u5668\u672A\u5141\u8BB8\u5168\u5C4F\uFF0C\u4ECD\u53EF\u5728\u5F53\u524D\u9762\u677F\u64AD\u653E" });
|
|
921
|
+
}
|
|
922
|
+
};
|
|
923
|
+
const statusText = loading || state.status === "loading" ? "\u6B63\u5728\u6062\u590D\u753B\u9762" : ready ? state.playing ? "\u64AD\u653E\u4E2D" : "\u5DF2\u6682\u505C" : state.status === "empty" ? "\u6682\u65E0\u5F55\u50CF" : state.status === "error" ? "\u65E0\u6CD5\u64AD\u653E" : "\u7B49\u5F85\u56DE\u653E";
|
|
924
|
+
const errorText = error || problem?.message || (state.status === "error" ? "\u5F53\u524D\u56DE\u653E\u6570\u636E\u65E0\u6CD5\u8FD8\u539F\u9875\u9762" : "");
|
|
925
|
+
const playLabel = state.playing ? "\u6682\u505C" : state.currentTimeMs >= state.durationMs && ready ? "\u91CD\u65B0\u64AD\u653E" : "\u64AD\u653E";
|
|
926
|
+
return /* @__PURE__ */ jsxs("div", { ref: containerRef, className: ["adminsmart-session-replay", className].filter(Boolean).join(" "), style: themeStyle, "data-adminsmart-session-replay": true, "data-replay-status": state.status, children: [
|
|
927
|
+
/* @__PURE__ */ jsxs("div", { ref: stageRef, className: "adminsmart-session-replay__stage", "aria-label": "\u64CD\u4F5C\u56DE\u653E\u753B\u9762", "aria-busy": loading || state.status === "loading", children: [
|
|
928
|
+
/* @__PURE__ */ jsx4("div", { ref: rootRef, className: "adminsmart-session-replay__mount" }),
|
|
929
|
+
!ready && /* @__PURE__ */ jsx4("div", { className: "adminsmart-session-replay__placeholder", role: "status", children: loading || state.status === "loading" ? /* @__PURE__ */ jsx4(Spin2, { description: "\u6B63\u5728\u6062\u590D\u56DE\u653E\u753B\u9762" }) : /* @__PURE__ */ jsx4(Empty2, { description: errorText || (state.status === "empty" ? "\u6682\u65E0\u53EF\u64AD\u653E\u56DE\u653E\u6570\u636E" : "\u7B49\u5F85\u53EF\u89C1\u56DE\u653E\u7A97\u53E3"), image: Empty2.PRESENTED_IMAGE_SIMPLE }) })
|
|
930
|
+
] }),
|
|
931
|
+
/* @__PURE__ */ jsxs("div", { className: "adminsmart-session-replay__controls", children: [
|
|
932
|
+
/* @__PURE__ */ jsxs("div", { className: "adminsmart-session-replay__summary", children: [
|
|
933
|
+
/* @__PURE__ */ jsx4(Tag2, { color: ready ? "processing" : void 0, className: "adminsmart-session-replay__status", children: /* @__PURE__ */ jsx4("span", { "aria-live": "polite", children: statusText }) }),
|
|
934
|
+
/* @__PURE__ */ jsxs(Typography2.Text, { className: "adminsmart-session-replay__clock", children: [
|
|
935
|
+
replayClock(state.currentTimeMs),
|
|
936
|
+
" ",
|
|
937
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
938
|
+
"/ ",
|
|
939
|
+
replayClock(state.durationMs)
|
|
940
|
+
] })
|
|
941
|
+
] }),
|
|
942
|
+
extra && /* @__PURE__ */ jsx4("div", { className: "adminsmart-session-replay__extra", children: extra })
|
|
943
|
+
] }),
|
|
944
|
+
/* @__PURE__ */ jsxs("div", { className: "adminsmart-session-replay__timeline", children: [
|
|
945
|
+
/* @__PURE__ */ jsx4(
|
|
946
|
+
Slider2,
|
|
947
|
+
{
|
|
948
|
+
min: 0,
|
|
949
|
+
max: Math.max(1, state.durationMs),
|
|
950
|
+
value: state.currentTimeMs,
|
|
951
|
+
disabled: !ready,
|
|
952
|
+
onChange: (value) => seek(value),
|
|
953
|
+
tooltip: { formatter: (value) => replayClock(value ?? 0) },
|
|
954
|
+
ariaLabelForHandle: "\u56DE\u653E\u8FDB\u5EA6",
|
|
955
|
+
ariaValueTextFormatterForHandle: (value) => `${replayClock(value)} / ${replayClock(state.durationMs)}`
|
|
956
|
+
}
|
|
957
|
+
),
|
|
958
|
+
/* @__PURE__ */ jsx4("div", { className: "adminsmart-session-replay__markers", "aria-label": "\u56DE\u653E\u65F6\u95F4\u6807\u8BB0", children: markers.filter((marker) => Number.isFinite(marker.timeMs)).map((marker, index) => /* @__PURE__ */ jsx4(Tooltip2, { title: `${marker.label} \xB7 ${replayClock(marker.timeMs)}`, children: /* @__PURE__ */ jsx4(
|
|
959
|
+
"button",
|
|
960
|
+
{
|
|
961
|
+
type: "button",
|
|
962
|
+
className: "adminsmart-session-replay__marker",
|
|
963
|
+
"data-tone": marker.tone || "primary",
|
|
964
|
+
style: { left: `${state.durationMs ? Math.min(100, Math.max(0, finiteReplayNumber(marker.timeMs) / state.durationMs * 100)) : 0}%` },
|
|
965
|
+
"aria-label": `${marker.label} ${replayClock(marker.timeMs)}`,
|
|
966
|
+
disabled: !ready,
|
|
967
|
+
onClick: () => seek(marker.timeMs)
|
|
968
|
+
}
|
|
969
|
+
) }, `${marker.timeMs}-${index}`)) })
|
|
970
|
+
] }),
|
|
971
|
+
/* @__PURE__ */ jsxs("div", { className: "adminsmart-session-replay__toolbar", role: "group", "aria-label": "\u56DE\u653E\u64AD\u653E\u63A7\u5236", children: [
|
|
972
|
+
/* @__PURE__ */ jsxs("div", { className: "adminsmart-session-replay__transport", children: [
|
|
973
|
+
/* @__PURE__ */ jsx4(Tooltip2, { title: "\u540E\u9000 5 \u79D2", children: /* @__PURE__ */ jsx4(Button2, { icon: /* @__PURE__ */ jsx4(StepBackwardOutlined, { "aria-hidden": true }), "aria-label": "\u540E\u9000 5 \u79D2", disabled: !ready, onClick: () => seek(state.currentTimeMs - 5e3) }) }),
|
|
974
|
+
/* @__PURE__ */ jsx4(
|
|
975
|
+
Button2,
|
|
976
|
+
{
|
|
977
|
+
type: "primary",
|
|
978
|
+
icon: state.playing ? /* @__PURE__ */ jsx4(PauseOutlined, { "aria-hidden": true }) : /* @__PURE__ */ jsx4(PlayCircleOutlined, { "aria-hidden": true }),
|
|
979
|
+
"aria-label": playLabel,
|
|
980
|
+
disabled: !ready || !state.durationMs,
|
|
981
|
+
onClick: state.playing ? pause : play,
|
|
982
|
+
children: playLabel
|
|
983
|
+
}
|
|
984
|
+
),
|
|
985
|
+
/* @__PURE__ */ jsx4(Tooltip2, { title: "\u524D\u8FDB 5 \u79D2", children: /* @__PURE__ */ jsx4(Button2, { icon: /* @__PURE__ */ jsx4(StepForwardOutlined, { "aria-hidden": true }), "aria-label": "\u524D\u8FDB 5 \u79D2", disabled: !ready, onClick: () => seek(state.currentTimeMs + 5e3) }) }),
|
|
986
|
+
/* @__PURE__ */ jsx4(Tooltip2, { title: "\u4ECE\u5934\u64AD\u653E", children: /* @__PURE__ */ jsx4(Button2, { type: "text", icon: /* @__PURE__ */ jsx4(RedoOutlined, { "aria-hidden": true }), "aria-label": "\u4ECE\u5934\u64AD\u653E", disabled: !ready || !state.durationMs, onClick: restart }) })
|
|
987
|
+
] }),
|
|
988
|
+
/* @__PURE__ */ jsxs("div", { className: "adminsmart-session-replay__options", children: [
|
|
989
|
+
/* @__PURE__ */ jsx4(Select2, { size: "small", value: state.playbackRate, disabled: !ready, "aria-label": "\u64AD\u653E\u901F\u5EA6", options: playbackRates.map((value) => ({ value, label: `${value}\xD7` })), onChange: setPlaybackRate, popupMatchSelectWidth: false }),
|
|
990
|
+
/* @__PURE__ */ jsx4(Tooltip2, { title: fullscreen ? "\u9000\u51FA\u5168\u5C4F" : "\u5168\u5C4F\u64AD\u653E", children: /* @__PURE__ */ jsx4(Button2, { type: "text", icon: fullscreen ? /* @__PURE__ */ jsx4(FullscreenExitOutlined, { "aria-hidden": true }) : /* @__PURE__ */ jsx4(FullscreenOutlined, { "aria-hidden": true }), "aria-label": fullscreen ? "\u9000\u51FA\u5168\u5C4F" : "\u5168\u5C4F\u64AD\u653E", disabled: !ready, onClick: () => void toggleFullscreen() }) })
|
|
991
|
+
] })
|
|
992
|
+
] }),
|
|
993
|
+
errorText && /* @__PURE__ */ jsx4(Alert2, { type: problem?.code === "fullscreen" ? "warning" : "error", showIcon: true, title: errorText, className: "adminsmart-session-replay__notice" })
|
|
994
|
+
] })
|
|
995
|
+
] });
|
|
996
|
+
});
|
|
997
|
+
|
|
470
998
|
// src/composites/SearchPanel.tsx
|
|
471
999
|
import { DownOutlined, UpOutlined } from "@ant-design/icons";
|
|
472
1000
|
import {
|
|
473
1001
|
Children,
|
|
474
|
-
forwardRef as
|
|
1002
|
+
forwardRef as forwardRef5,
|
|
475
1003
|
isValidElement,
|
|
476
|
-
useEffect,
|
|
477
|
-
useRef,
|
|
478
|
-
useState
|
|
1004
|
+
useEffect as useEffect3,
|
|
1005
|
+
useRef as useRef3,
|
|
1006
|
+
useState as useState3
|
|
479
1007
|
} from "react";
|
|
480
1008
|
|
|
481
1009
|
// src/composites/searchPanelModel.ts
|
|
@@ -487,17 +1015,17 @@ function collapsedSearchFieldLimit(columns) {
|
|
|
487
1015
|
}
|
|
488
1016
|
|
|
489
1017
|
// src/composites/SearchPanel.tsx
|
|
490
|
-
import { jsx as
|
|
491
|
-
var SearchPanel =
|
|
492
|
-
const rootRef =
|
|
493
|
-
const [width, setWidth] =
|
|
494
|
-
const [expanded, setExpanded] =
|
|
1018
|
+
import { jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
1019
|
+
var SearchPanel = forwardRef5(function SearchPanel2({ fields, actions, tools, trailingTools, searchVisible = true, defaultExpanded = false, role = "search", style, ...props }, ref) {
|
|
1020
|
+
const rootRef = useRef3(null);
|
|
1021
|
+
const [width, setWidth] = useState3(0);
|
|
1022
|
+
const [expanded, setExpanded] = useState3(defaultExpanded);
|
|
495
1023
|
const items = Children.toArray(fields);
|
|
496
1024
|
const columns = searchColumnCount(width);
|
|
497
1025
|
const collapsedLimit = collapsedSearchFieldLimit(columns);
|
|
498
1026
|
const hasMore = items.length > collapsedLimit;
|
|
499
1027
|
const fieldWidth = Math.min(240, Math.max(0, width));
|
|
500
|
-
|
|
1028
|
+
useEffect3(() => {
|
|
501
1029
|
const element = rootRef.current;
|
|
502
1030
|
if (!element) return void 0;
|
|
503
1031
|
const update = () => {
|
|
@@ -526,10 +1054,10 @@ var SearchPanel = forwardRef4(function SearchPanel2({ fields, actions, tools, tr
|
|
|
526
1054
|
...style
|
|
527
1055
|
};
|
|
528
1056
|
const hasToolbar = tools != null || trailingTools != null;
|
|
529
|
-
return /* @__PURE__ */
|
|
530
|
-
/* @__PURE__ */
|
|
531
|
-
(items.length > 0 || actions != null) && /* @__PURE__ */
|
|
532
|
-
items.map((item, index) => /* @__PURE__ */
|
|
1057
|
+
return /* @__PURE__ */ jsxs2("div", { ...props, ref: setRootRef, role: hasToolbar ? "toolbar" : role, style: panelStyle, "data-adminsmart-search-panel": "true", children: [
|
|
1058
|
+
/* @__PURE__ */ jsx5("style", { children: "[data-adminsmart-search-field] > .ant-form-item { margin-bottom: 0; }" }),
|
|
1059
|
+
(items.length > 0 || actions != null) && /* @__PURE__ */ jsxs2("div", { role: hasToolbar ? role : void 0, "aria-hidden": !searchVisible, style: { display: searchVisible ? "flex" : "none", width: "100%", flexWrap: "wrap", alignItems: "end", gap: "12px 16px" }, children: [
|
|
1060
|
+
items.map((item, index) => /* @__PURE__ */ jsx5(
|
|
533
1061
|
"div",
|
|
534
1062
|
{
|
|
535
1063
|
hidden: !expanded && index >= collapsedLimit,
|
|
@@ -539,35 +1067,35 @@ var SearchPanel = forwardRef4(function SearchPanel2({ fields, actions, tools, tr
|
|
|
539
1067
|
},
|
|
540
1068
|
isValidElement(item) ? item.key ?? index : index
|
|
541
1069
|
)),
|
|
542
|
-
/* @__PURE__ */
|
|
543
|
-
hasMore ? /* @__PURE__ */
|
|
1070
|
+
/* @__PURE__ */ jsxs2("div", { "data-adminsmart-search-actions": "true", style: { display: "flex", alignItems: "center", gap: 8, minHeight: 32 }, children: [
|
|
1071
|
+
hasMore ? /* @__PURE__ */ jsx5(
|
|
544
1072
|
Button,
|
|
545
1073
|
{
|
|
546
1074
|
type: "link",
|
|
547
|
-
icon: expanded ? /* @__PURE__ */
|
|
1075
|
+
icon: expanded ? /* @__PURE__ */ jsx5(UpOutlined, {}) : /* @__PURE__ */ jsx5(DownOutlined, {}),
|
|
548
1076
|
"aria-expanded": expanded,
|
|
549
1077
|
onClick: () => setExpanded((value) => !value),
|
|
550
1078
|
children: expanded ? "\u6536\u8D77\u7B5B\u9009" : "\u5C55\u5F00\u7B5B\u9009"
|
|
551
1079
|
}
|
|
552
1080
|
) : null,
|
|
553
|
-
/* @__PURE__ */
|
|
1081
|
+
/* @__PURE__ */ jsx5("span", { style: { display: "inline-flex", alignItems: "center", gap: 8 }, children: actions })
|
|
554
1082
|
] })
|
|
555
1083
|
] }),
|
|
556
|
-
hasToolbar && /* @__PURE__ */
|
|
557
|
-
/* @__PURE__ */
|
|
558
|
-
/* @__PURE__ */
|
|
1084
|
+
hasToolbar && /* @__PURE__ */ jsxs2("div", { "data-adminsmart-toolbar-row": "true", style: { display: "flex", width: "100%", minWidth: 0, alignItems: "center", justifyContent: "space-between", flexWrap: "wrap", gap: 12 }, children: [
|
|
1085
|
+
/* @__PURE__ */ jsx5("div", { role: "group", "aria-label": "\u529F\u80FD\u64CD\u4F5C", "data-adminsmart-toolbar-actions": "true", style: { display: "flex", alignItems: "center", flexWrap: "wrap", gap: 12, minHeight: 32 }, children: tools }),
|
|
1086
|
+
/* @__PURE__ */ jsx5("div", { role: "group", "aria-label": "\u8868\u683C\u5DE5\u5177", style: { display: "flex", alignItems: "center", flexWrap: "wrap", gap: 12, marginLeft: "auto", minHeight: 32 }, children: trailingTools })
|
|
559
1087
|
] })
|
|
560
1088
|
] });
|
|
561
1089
|
});
|
|
562
1090
|
|
|
563
1091
|
// src/composites/DataTable.tsx
|
|
564
1092
|
import {
|
|
565
|
-
forwardRef as
|
|
1093
|
+
forwardRef as forwardRef6,
|
|
566
1094
|
useLayoutEffect,
|
|
567
|
-
useRef as
|
|
568
|
-
useState as
|
|
1095
|
+
useRef as useRef4,
|
|
1096
|
+
useState as useState4
|
|
569
1097
|
} from "react";
|
|
570
|
-
import { jsx as
|
|
1098
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
571
1099
|
function tableBodyHeight(availableHeight, chromeHeight) {
|
|
572
1100
|
return Math.max(0, Math.floor(availableHeight - chromeHeight - 16));
|
|
573
1101
|
}
|
|
@@ -588,8 +1116,8 @@ function DataTableInner({
|
|
|
588
1116
|
scroll,
|
|
589
1117
|
...tableProps
|
|
590
1118
|
}, ref) {
|
|
591
|
-
const containerRef =
|
|
592
|
-
const [bodyHeight, setBodyHeight] =
|
|
1119
|
+
const containerRef = useRef4(null);
|
|
1120
|
+
const [bodyHeight, setBodyHeight] = useState4(360);
|
|
593
1121
|
const hasExplicitHeight = containerHeight != null || containerStyle?.height != null;
|
|
594
1122
|
useLayoutEffect(() => {
|
|
595
1123
|
const container = containerRef.current;
|
|
@@ -625,14 +1153,14 @@ function DataTableInner({
|
|
|
625
1153
|
y: scroll?.y ?? bodyHeight
|
|
626
1154
|
};
|
|
627
1155
|
const tablePagination = pagination === false ? false : pagination?.placement || pagination?.position ? pagination : { placement: ["bottomEnd"], ...pagination };
|
|
628
|
-
return /* @__PURE__ */
|
|
1156
|
+
return /* @__PURE__ */ jsx6(
|
|
629
1157
|
"div",
|
|
630
1158
|
{
|
|
631
1159
|
ref: containerRef,
|
|
632
1160
|
className: containerClassName,
|
|
633
1161
|
"data-adminsmart-data-table": "true",
|
|
634
1162
|
style: { width: "100%", minWidth: 0, overflowX: "hidden", ...containerHeight == null ? {} : { height: containerHeight, overflowY: "hidden" }, ...containerStyle },
|
|
635
|
-
children: /* @__PURE__ */
|
|
1163
|
+
children: /* @__PURE__ */ jsx6(
|
|
636
1164
|
Table,
|
|
637
1165
|
{
|
|
638
1166
|
...tableProps,
|
|
@@ -644,11 +1172,11 @@ function DataTableInner({
|
|
|
644
1172
|
}
|
|
645
1173
|
);
|
|
646
1174
|
}
|
|
647
|
-
var DataTable =
|
|
1175
|
+
var DataTable = forwardRef6(DataTableInner);
|
|
648
1176
|
|
|
649
1177
|
// src/composites/WorkspaceLayout.tsx
|
|
650
|
-
import { theme } from "antd";
|
|
651
|
-
import { jsx as
|
|
1178
|
+
import { theme as theme2 } from "antd";
|
|
1179
|
+
import { jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
652
1180
|
var LIGHT_WORKSPACE_BACKGROUND = "#f6f9fe";
|
|
653
1181
|
function WorkspaceLayout({
|
|
654
1182
|
header,
|
|
@@ -666,7 +1194,7 @@ function WorkspaceLayout({
|
|
|
666
1194
|
contentClassName,
|
|
667
1195
|
height
|
|
668
1196
|
}) {
|
|
669
|
-
const { token } =
|
|
1197
|
+
const { token } = theme2.useToken();
|
|
670
1198
|
const rootClassName = ["adminsmart-workspace", className].filter(Boolean).join(" ");
|
|
671
1199
|
const contentClasses = ["adminsmart-workspace__content", contentClassName].filter(Boolean).join(" ");
|
|
672
1200
|
const siderClasses = ["adminsmart-workspace__sider", siderProps?.className].filter(Boolean).join(" ");
|
|
@@ -680,10 +1208,10 @@ function WorkspaceLayout({
|
|
|
680
1208
|
"--adminsmart-workspace-bg": themeMode === "dark" ? token.colorBgLayout : LIGHT_WORKSPACE_BACKGROUND
|
|
681
1209
|
// 夜间不复用日间固定底色。
|
|
682
1210
|
};
|
|
683
|
-
return /* @__PURE__ */
|
|
684
|
-
/* @__PURE__ */
|
|
685
|
-
/* @__PURE__ */
|
|
686
|
-
/* @__PURE__ */
|
|
1211
|
+
return /* @__PURE__ */ jsxs3(Layout, { className: rootClassName, style: workspaceStyle, "data-theme-mode": themeMode, children: [
|
|
1212
|
+
/* @__PURE__ */ jsx7("header", { className: "adminsmart-workspace__header", children: header }),
|
|
1213
|
+
/* @__PURE__ */ jsxs3(Layout, { className: "adminsmart-workspace__body", children: [
|
|
1214
|
+
/* @__PURE__ */ jsx7(
|
|
687
1215
|
Layout.Sider,
|
|
688
1216
|
{
|
|
689
1217
|
theme: themeMode,
|
|
@@ -695,9 +1223,9 @@ function WorkspaceLayout({
|
|
|
695
1223
|
children: sidebar
|
|
696
1224
|
}
|
|
697
1225
|
),
|
|
698
|
-
/* @__PURE__ */
|
|
1226
|
+
/* @__PURE__ */ jsxs3(Layout, { className: "adminsmart-workspace__main", children: [
|
|
699
1227
|
tabs,
|
|
700
|
-
/* @__PURE__ */
|
|
1228
|
+
/* @__PURE__ */ jsx7(Layout.Content, { className: contentClasses, "data-content-mode": contentMode, children }),
|
|
701
1229
|
footer
|
|
702
1230
|
] })
|
|
703
1231
|
] })
|
|
@@ -705,7 +1233,7 @@ function WorkspaceLayout({
|
|
|
705
1233
|
}
|
|
706
1234
|
|
|
707
1235
|
// src/composites/CrudScaffold.tsx
|
|
708
|
-
import { jsx as
|
|
1236
|
+
import { jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
709
1237
|
function CrudScaffold({
|
|
710
1238
|
label,
|
|
711
1239
|
description,
|
|
@@ -717,16 +1245,16 @@ function CrudScaffold({
|
|
|
717
1245
|
...props
|
|
718
1246
|
}) {
|
|
719
1247
|
const classes = ["adminsmart-crud", className].filter(Boolean).join(" ");
|
|
720
|
-
return /* @__PURE__ */
|
|
721
|
-
/* @__PURE__ */
|
|
722
|
-
status ? /* @__PURE__ */
|
|
723
|
-
/* @__PURE__ */
|
|
1248
|
+
return /* @__PURE__ */ jsxs4("main", { ...props, className: classes, "aria-label": label, "aria-description": description, children: [
|
|
1249
|
+
/* @__PURE__ */ jsx8("div", { className: "adminsmart-crud__filters", children: filters }),
|
|
1250
|
+
status ? /* @__PURE__ */ jsx8("div", { className: "adminsmart-crud__status", children: status }) : null,
|
|
1251
|
+
/* @__PURE__ */ jsx8("div", { className: "adminsmart-crud__results", children: results }),
|
|
724
1252
|
drawer
|
|
725
1253
|
] });
|
|
726
1254
|
}
|
|
727
1255
|
|
|
728
1256
|
// src/composites/EllipsisText.tsx
|
|
729
|
-
import { jsx as
|
|
1257
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
730
1258
|
function EllipsisText({
|
|
731
1259
|
children,
|
|
732
1260
|
maxWidth = 240,
|
|
@@ -738,7 +1266,7 @@ function EllipsisText({
|
|
|
738
1266
|
const classes = ["adminsmart-ellipsis-text", className].filter(Boolean).join(" ");
|
|
739
1267
|
const widthValue = typeof maxWidth === "number" ? `${maxWidth}px` : maxWidth;
|
|
740
1268
|
const textStyle = { "--adminsmart-ellipsis-width": widthValue, ...style };
|
|
741
|
-
return /* @__PURE__ */
|
|
1269
|
+
return /* @__PURE__ */ jsx9(
|
|
742
1270
|
Typography.Text,
|
|
743
1271
|
{
|
|
744
1272
|
...props,
|
|
@@ -753,7 +1281,7 @@ function EllipsisText({
|
|
|
753
1281
|
// src/composites/RowActions.tsx
|
|
754
1282
|
import { EllipsisOutlined } from "@ant-design/icons";
|
|
755
1283
|
import { Children as Children2, Fragment, isValidElement as isValidElement2 } from "react";
|
|
756
|
-
import { jsx as
|
|
1284
|
+
import { jsx as jsx10, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
757
1285
|
function collectButtons(children) {
|
|
758
1286
|
const actions = [];
|
|
759
1287
|
Children2.forEach(children, (child) => {
|
|
@@ -784,9 +1312,9 @@ function RowActions({ children, maxVisible = 2, moreLabel = "\u66F4\u591A\u64CD\
|
|
|
784
1312
|
// 菜单仍按官方语义标识需要确认的动作。
|
|
785
1313
|
}));
|
|
786
1314
|
const classes = ["adminsmart-row-action-group", className].filter(Boolean).join(" ");
|
|
787
|
-
return /* @__PURE__ */
|
|
1315
|
+
return /* @__PURE__ */ jsxs5(Space, { ...props, className: classes, size, wrap, children: [
|
|
788
1316
|
direct,
|
|
789
|
-
overflow.length > 0 && /* @__PURE__ */
|
|
1317
|
+
overflow.length > 0 && /* @__PURE__ */ jsx10(
|
|
790
1318
|
Dropdown,
|
|
791
1319
|
{
|
|
792
1320
|
trigger: ["click"],
|
|
@@ -798,12 +1326,12 @@ function RowActions({ children, maxVisible = 2, moreLabel = "\u66F4\u591A\u64CD\
|
|
|
798
1326
|
action.props.onClick?.(domEvent);
|
|
799
1327
|
}
|
|
800
1328
|
},
|
|
801
|
-
children: /* @__PURE__ */
|
|
1329
|
+
children: /* @__PURE__ */ jsx10(Tooltip, { title: moreLabel, children: /* @__PURE__ */ jsx10(
|
|
802
1330
|
Button,
|
|
803
1331
|
{
|
|
804
1332
|
type: "text",
|
|
805
1333
|
size: "small",
|
|
806
|
-
icon: /* @__PURE__ */
|
|
1334
|
+
icon: /* @__PURE__ */ jsx10(EllipsisOutlined, {}),
|
|
807
1335
|
"aria-label": moreLabel,
|
|
808
1336
|
"aria-haspopup": "menu",
|
|
809
1337
|
"data-adminsmart-row-more": "true",
|
|
@@ -817,7 +1345,7 @@ function RowActions({ children, maxVisible = 2, moreLabel = "\u66F4\u591A\u64CD\
|
|
|
817
1345
|
|
|
818
1346
|
// src/schema/SchemaForm.tsx
|
|
819
1347
|
import dayjs from "dayjs";
|
|
820
|
-
import { forwardRef as
|
|
1348
|
+
import { forwardRef as forwardRef7 } from "react";
|
|
821
1349
|
|
|
822
1350
|
// src/schema/model.ts
|
|
823
1351
|
var FIELD_TYPES = /* @__PURE__ */ new Set([
|
|
@@ -1000,7 +1528,7 @@ function schemaInitialValues(schema) {
|
|
|
1000
1528
|
}
|
|
1001
1529
|
|
|
1002
1530
|
// src/schema/SchemaForm.tsx
|
|
1003
|
-
import { jsx as
|
|
1531
|
+
import { jsx as jsx11, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1004
1532
|
function fieldRules(field) {
|
|
1005
1533
|
const rules = [];
|
|
1006
1534
|
if (field.required) {
|
|
@@ -1045,32 +1573,32 @@ function dateItemProps(field) {
|
|
|
1045
1573
|
function renderControl(field) {
|
|
1046
1574
|
switch (field.type) {
|
|
1047
1575
|
case "input":
|
|
1048
|
-
return /* @__PURE__ */
|
|
1576
|
+
return /* @__PURE__ */ jsx11(Input, { placeholder: field.placeholder });
|
|
1049
1577
|
case "password":
|
|
1050
|
-
return /* @__PURE__ */
|
|
1578
|
+
return /* @__PURE__ */ jsx11(Input.Password, { placeholder: field.placeholder });
|
|
1051
1579
|
case "textarea":
|
|
1052
|
-
return /* @__PURE__ */
|
|
1580
|
+
return /* @__PURE__ */ jsx11(Input.TextArea, { placeholder: field.placeholder });
|
|
1053
1581
|
case "number":
|
|
1054
|
-
return /* @__PURE__ */
|
|
1582
|
+
return /* @__PURE__ */ jsx11(InputNumber, { placeholder: field.placeholder, min: field.validation?.min, max: field.validation?.max, style: { width: "100%" } });
|
|
1055
1583
|
case "select":
|
|
1056
|
-
return /* @__PURE__ */
|
|
1584
|
+
return /* @__PURE__ */ jsx11(Select, { placeholder: field.placeholder, options: field.options });
|
|
1057
1585
|
case "radio":
|
|
1058
|
-
return /* @__PURE__ */
|
|
1586
|
+
return /* @__PURE__ */ jsx11(Radio.Group, { options: field.options });
|
|
1059
1587
|
case "checkbox":
|
|
1060
|
-
return /* @__PURE__ */
|
|
1588
|
+
return /* @__PURE__ */ jsx11(Checkbox, {});
|
|
1061
1589
|
case "switch":
|
|
1062
|
-
return /* @__PURE__ */
|
|
1590
|
+
return /* @__PURE__ */ jsx11(Switch, {});
|
|
1063
1591
|
case "date":
|
|
1064
|
-
return /* @__PURE__ */
|
|
1592
|
+
return /* @__PURE__ */ jsx11(DatePicker, { placeholder: field.placeholder, style: { width: "100%" } });
|
|
1065
1593
|
case "dateRange":
|
|
1066
|
-
return /* @__PURE__ */
|
|
1594
|
+
return /* @__PURE__ */ jsx11(DatePicker.RangePicker, { placeholder: field.placeholder ? [field.placeholder, field.placeholder] : void 0, style: { width: "100%" } });
|
|
1067
1595
|
}
|
|
1068
1596
|
}
|
|
1069
|
-
var SchemaForm =
|
|
1597
|
+
var SchemaForm = forwardRef7(function SchemaForm2({ schema, onSubmit, onChange, onFinish, onValuesChange, initialValues, layout = "vertical", ...formProps }, ref) {
|
|
1070
1598
|
const result = validateSchemaForm(schema);
|
|
1071
1599
|
if (!result.valid) throw new Error(`SchemaForm \u914D\u7F6E\u65E0\u6548\uFF1A${result.errors.map((issue) => `${issue.path} ${issue.message}`).join("\uFF1B")}`);
|
|
1072
1600
|
const defaults = schemaInitialValues(schema);
|
|
1073
|
-
return /* @__PURE__ */
|
|
1601
|
+
return /* @__PURE__ */ jsxs6(
|
|
1074
1602
|
Form,
|
|
1075
1603
|
{
|
|
1076
1604
|
...formProps,
|
|
@@ -1088,7 +1616,7 @@ var SchemaForm = forwardRef6(function SchemaForm2({ schema, onSubmit, onChange,
|
|
|
1088
1616
|
children: [
|
|
1089
1617
|
schema.fields.map((field) => {
|
|
1090
1618
|
const mapped = mapSchemaField(field);
|
|
1091
|
-
return /* @__PURE__ */
|
|
1619
|
+
return /* @__PURE__ */ jsx11(
|
|
1092
1620
|
Form.Item,
|
|
1093
1621
|
{
|
|
1094
1622
|
name: mapped.name,
|
|
@@ -1101,7 +1629,7 @@ var SchemaForm = forwardRef6(function SchemaForm2({ schema, onSubmit, onChange,
|
|
|
1101
1629
|
mapped.name
|
|
1102
1630
|
);
|
|
1103
1631
|
}),
|
|
1104
|
-
/* @__PURE__ */
|
|
1632
|
+
/* @__PURE__ */ jsx11(Form.Item, { children: /* @__PURE__ */ jsx11(Button, { type: "primary", htmlType: "submit", children: schema.submitText ?? "\u63D0\u4EA4" }) })
|
|
1105
1633
|
]
|
|
1106
1634
|
}
|
|
1107
1635
|
);
|
|
@@ -1166,6 +1694,7 @@ export {
|
|
|
1166
1694
|
SearchPanel,
|
|
1167
1695
|
Segmented,
|
|
1168
1696
|
Select,
|
|
1697
|
+
SessionReplay,
|
|
1169
1698
|
Skeleton,
|
|
1170
1699
|
Slider,
|
|
1171
1700
|
Space,
|
|
@@ -1193,7 +1722,7 @@ export {
|
|
|
1193
1722
|
mapSchemaField,
|
|
1194
1723
|
schemaInitialValues,
|
|
1195
1724
|
tableBodyHeight,
|
|
1196
|
-
|
|
1725
|
+
theme3 as theme,
|
|
1197
1726
|
validateSchemaForm
|
|
1198
1727
|
};
|
|
1199
1728
|
//# sourceMappingURL=index.js.map
|