@qq1948037137/adminsmart-ui 0.1.22 → 0.1.24
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 +636 -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 +632 -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,577 @@ 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 replayPlaybackWindow(events, startOffsetMs = 0, endOffsetMs) {
|
|
539
|
+
const firstTimestamp = finiteReplayNumber(events[0]?.timestamp);
|
|
540
|
+
const originalTotal = Math.max(0, finiteReplayNumber(events.at(-1)?.timestamp) - firstTimestamp);
|
|
541
|
+
const range = replayRange(originalTotal, startOffsetMs, endOffsetMs);
|
|
542
|
+
if (endOffsetMs === void 0) return { events: structuredClone(events), range };
|
|
543
|
+
const endTimestamp = firstTimestamp + range.end;
|
|
544
|
+
const withinEnd = events.filter((event) => event.timestamp <= endTimestamp);
|
|
545
|
+
if (!withinEnd.some((event) => event.type === 2))
|
|
546
|
+
throw new Error("\u5F53\u524D\u56DE\u653E\u7A97\u53E3\u65E9\u4E8E\u5B8C\u6574\u9875\u9762\u5FEB\u7167\uFF0C\u65E0\u6CD5\u8FD8\u539F\u9875\u9762");
|
|
547
|
+
const completeEvents = withinEnd.filter((event, index) => {
|
|
548
|
+
if (event.type !== 4) return true;
|
|
549
|
+
for (let next = index + 1; next < withinEnd.length; next += 1) {
|
|
550
|
+
if (withinEnd[next].type === 2) return true;
|
|
551
|
+
if (withinEnd[next].type === 4) break;
|
|
552
|
+
}
|
|
553
|
+
return false;
|
|
554
|
+
});
|
|
555
|
+
const copied = structuredClone(completeEvents);
|
|
556
|
+
copied.push({
|
|
557
|
+
type: 5,
|
|
558
|
+
// 官方Custom事件只提供时间调度,不改变页面DOM。
|
|
559
|
+
timestamp: endTimestamp,
|
|
560
|
+
// 请求终点成为官方metadata真实终点,尾部观察时间不缩短。
|
|
561
|
+
data: {
|
|
562
|
+
tag: "adminsmart-replay-boundary",
|
|
563
|
+
// 内部固定标记,不承载业务信息或外部回调。
|
|
564
|
+
payload: null
|
|
565
|
+
// 空载荷不包含用户数据。
|
|
566
|
+
}
|
|
567
|
+
});
|
|
568
|
+
return { events: copied, range };
|
|
569
|
+
}
|
|
570
|
+
function inclusivePauseOffset(events, target) {
|
|
571
|
+
const logicalTarget = Math.max(0, finiteReplayNumber(target));
|
|
572
|
+
const baseline = finiteReplayNumber(events[0]?.timestamp) + logicalTarget;
|
|
573
|
+
let equalEvent = false;
|
|
574
|
+
let increment = 1;
|
|
575
|
+
for (const event of events) {
|
|
576
|
+
if (event.timestamp === baseline) equalEvent = true;
|
|
577
|
+
if (event.timestamp > baseline) {
|
|
578
|
+
increment = Math.min(increment, event.timestamp - baseline);
|
|
579
|
+
break;
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
return equalEvent ? logicalTarget + increment : logicalTarget;
|
|
583
|
+
}
|
|
584
|
+
function replayFit(stageWidth, stageHeight, contentWidth, contentHeight) {
|
|
585
|
+
const width = Math.max(1, finiteReplayNumber(contentWidth, 1));
|
|
586
|
+
const height = Math.max(1, finiteReplayNumber(contentHeight, 1));
|
|
587
|
+
const scale = Math.min(1, Math.max(0, finiteReplayNumber(stageWidth)) / width, Math.max(0, finiteReplayNumber(stageHeight)) / height);
|
|
588
|
+
return {
|
|
589
|
+
scale,
|
|
590
|
+
// 作用于官方公开 wrapper。
|
|
591
|
+
left: Math.max(0, (stageWidth - width * scale) / 2),
|
|
592
|
+
// 水平居中。
|
|
593
|
+
top: Math.max(0, (stageHeight - height * scale) / 2)
|
|
594
|
+
// 垂直居中。
|
|
595
|
+
};
|
|
596
|
+
}
|
|
597
|
+
function replayClock(timeMs) {
|
|
598
|
+
const seconds = Math.floor(Math.max(0, finiteReplayNumber(timeMs)) / 1e3);
|
|
599
|
+
return `${String(Math.floor(seconds / 60)).padStart(2, "0")}:${String(seconds % 60).padStart(2, "0")}`;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
// src/composites/useSessionReplay.ts
|
|
603
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
604
|
+
|
|
605
|
+
// src/composites/sessionReplayEngine.ts
|
|
606
|
+
async function loadReplayEngine() {
|
|
607
|
+
const [, module] = await Promise.all([import("@rrweb/replay/dist/style.css"), import("@rrweb/replay")]);
|
|
608
|
+
return module.Replayer;
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
// src/composites/useSessionReplay.ts
|
|
612
|
+
function initialState(status) {
|
|
613
|
+
return {
|
|
614
|
+
status,
|
|
615
|
+
// 由容器可见性与输入决定。
|
|
616
|
+
currentTimeMs: 0,
|
|
617
|
+
// 新录像从可见起点开始。
|
|
618
|
+
durationMs: 0,
|
|
619
|
+
// 只有官方元数据能够确定时长。
|
|
620
|
+
playing: false,
|
|
621
|
+
// 未恢复快照前不宣称播放中。
|
|
622
|
+
playbackRate: 1
|
|
623
|
+
// 各次录像使用原速。
|
|
624
|
+
};
|
|
625
|
+
}
|
|
626
|
+
function useSessionReplay(options) {
|
|
627
|
+
const [state, setState] = useState(() => initialState("idle"));
|
|
628
|
+
const stateRef = useRef(state);
|
|
629
|
+
const engineRef = useRef(null);
|
|
630
|
+
const runtimeFailureRef = useRef(null);
|
|
631
|
+
const rangeRef = useRef(replayRange(0));
|
|
632
|
+
const replayEventsRef = useRef([]);
|
|
633
|
+
const callbackRef = useRef(options);
|
|
634
|
+
callbackRef.current = options;
|
|
635
|
+
const publish = useCallback((next) => {
|
|
636
|
+
stateRef.current = next;
|
|
637
|
+
setState(next);
|
|
638
|
+
callbackRef.current.onStateChange?.({ ...next });
|
|
639
|
+
}, []);
|
|
640
|
+
useEffect(() => {
|
|
641
|
+
const { active, loading, error, events, stageRef, rootRef, startOffsetMs, endOffsetMs, autoPlay } = options;
|
|
642
|
+
engineRef.current = null;
|
|
643
|
+
runtimeFailureRef.current = null;
|
|
644
|
+
rangeRef.current = replayRange(0);
|
|
645
|
+
replayEventsRef.current = [];
|
|
646
|
+
if (!active) {
|
|
647
|
+
publish(initialState("idle"));
|
|
648
|
+
return;
|
|
649
|
+
}
|
|
650
|
+
if (loading) {
|
|
651
|
+
publish(initialState("loading"));
|
|
652
|
+
return;
|
|
653
|
+
}
|
|
654
|
+
if (error) {
|
|
655
|
+
publish(initialState("error"));
|
|
656
|
+
return;
|
|
657
|
+
}
|
|
658
|
+
if (!events.length) {
|
|
659
|
+
publish(initialState("empty"));
|
|
660
|
+
return;
|
|
661
|
+
}
|
|
662
|
+
let playback;
|
|
663
|
+
let prepared;
|
|
664
|
+
try {
|
|
665
|
+
playback = replayPlaybackWindow(prepareReplayEvents(events), startOffsetMs, endOffsetMs);
|
|
666
|
+
prepared = playback.events;
|
|
667
|
+
} catch (reason) {
|
|
668
|
+
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", "\u5F53\u524D\u56DE\u653E\u7A97\u53E3\u65E9\u4E8E\u5B8C\u6574\u9875\u9762\u5FEB\u7167\uFF0C\u65E0\u6CD5\u8FD8\u539F\u9875\u9762"];
|
|
669
|
+
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" };
|
|
670
|
+
publish(initialState("error"));
|
|
671
|
+
callbackRef.current.onError?.(problem);
|
|
672
|
+
return;
|
|
673
|
+
}
|
|
674
|
+
replayEventsRef.current = prepared;
|
|
675
|
+
publish(initialState("loading"));
|
|
676
|
+
let current = true;
|
|
677
|
+
let failed = false;
|
|
678
|
+
let Constructor = null;
|
|
679
|
+
let player = null;
|
|
680
|
+
let snapshotReady = false;
|
|
681
|
+
let progressTimer;
|
|
682
|
+
let rebuildTimer;
|
|
683
|
+
let fitFrame;
|
|
684
|
+
let autoPlayFrame;
|
|
685
|
+
let observer = null;
|
|
686
|
+
const listeners = [];
|
|
687
|
+
const stopProgress = () => {
|
|
688
|
+
if (progressTimer !== void 0) window.clearInterval(progressTimer);
|
|
689
|
+
progressTimer = void 0;
|
|
690
|
+
};
|
|
691
|
+
const releaseEngine = () => {
|
|
692
|
+
stopProgress();
|
|
693
|
+
if (rebuildTimer !== void 0) window.clearTimeout(rebuildTimer);
|
|
694
|
+
if (fitFrame !== void 0) window.cancelAnimationFrame(fitFrame);
|
|
695
|
+
if (autoPlayFrame !== void 0) window.cancelAnimationFrame(autoPlayFrame);
|
|
696
|
+
if (player) {
|
|
697
|
+
for (const [eventName, handler] of listeners) player.off(eventName, handler);
|
|
698
|
+
try {
|
|
699
|
+
player.destroy();
|
|
700
|
+
} catch {
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
if (engineRef.current === player) engineRef.current = null;
|
|
704
|
+
player = null;
|
|
705
|
+
rootRef.current?.replaceChildren();
|
|
706
|
+
};
|
|
707
|
+
const fail = (code, message) => {
|
|
708
|
+
if (!current || failed) return;
|
|
709
|
+
failed = true;
|
|
710
|
+
releaseEngine();
|
|
711
|
+
observer?.disconnect();
|
|
712
|
+
publish(initialState("error"));
|
|
713
|
+
callbackRef.current.onError?.({ code, message });
|
|
714
|
+
};
|
|
715
|
+
const commandFailure = () => fail("rebuild-failed", "\u56DE\u653E\u9875\u9762\u6062\u590D\u5931\u8D25\uFF0C\u8BF7\u91CD\u65B0\u6253\u5F00\u56DE\u653E");
|
|
716
|
+
runtimeFailureRef.current = commandFailure;
|
|
717
|
+
const fit = () => {
|
|
718
|
+
if (!current || !player || !stageRef.current) return;
|
|
719
|
+
const dimensions = replayFit(stageRef.current.clientWidth, stageRef.current.clientHeight, Number(player.iframe.width), Number(player.iframe.height));
|
|
720
|
+
player.wrapper.style.position = "absolute";
|
|
721
|
+
player.wrapper.style.left = `${dimensions.left}px`;
|
|
722
|
+
player.wrapper.style.top = `${dimensions.top}px`;
|
|
723
|
+
player.wrapper.style.transformOrigin = "top left";
|
|
724
|
+
player.wrapper.style.transform = `scale(${dimensions.scale})`;
|
|
725
|
+
};
|
|
726
|
+
const scheduleFit = () => {
|
|
727
|
+
if (fitFrame !== void 0) window.cancelAnimationFrame(fitFrame);
|
|
728
|
+
fitFrame = window.requestAnimationFrame(() => {
|
|
729
|
+
fitFrame = void 0;
|
|
730
|
+
fit();
|
|
731
|
+
});
|
|
732
|
+
};
|
|
733
|
+
const startProgress = () => {
|
|
734
|
+
stopProgress();
|
|
735
|
+
progressTimer = window.setInterval(() => {
|
|
736
|
+
if (!current || !player || !snapshotReady) return;
|
|
737
|
+
try {
|
|
738
|
+
const time = player.getCurrentTime();
|
|
739
|
+
if (time >= rangeRef.current.end) {
|
|
740
|
+
player.pause(inclusivePauseOffset(prepared, rangeRef.current.end));
|
|
741
|
+
stopProgress();
|
|
742
|
+
publish({ ...stateRef.current, currentTimeMs: rangeRef.current.total, playing: false });
|
|
743
|
+
} else publish({ ...stateRef.current, currentTimeMs: rangeRef.current.toVisible(time) });
|
|
744
|
+
} catch {
|
|
745
|
+
fail("rebuild-failed", "\u56DE\u653E\u9875\u9762\u6062\u590D\u5931\u8D25\uFF0C\u8BF7\u91CD\u65B0\u6253\u5F00\u56DE\u653E");
|
|
746
|
+
}
|
|
747
|
+
}, 100);
|
|
748
|
+
};
|
|
749
|
+
const start = () => {
|
|
750
|
+
if (!current || failed || player || !Constructor || !stageRef.current || !rootRef.current) return;
|
|
751
|
+
if (stageRef.current.clientWidth <= 0 || stageRef.current.clientHeight <= 0) return;
|
|
752
|
+
try {
|
|
753
|
+
player = new Constructor(prepared, {
|
|
754
|
+
root: rootRef.current,
|
|
755
|
+
// 实例只能挂载在自己的专属节点。
|
|
756
|
+
skipInactive: false,
|
|
757
|
+
// 时间轴与用户可见窗口保持一致。
|
|
758
|
+
showDebug: false,
|
|
759
|
+
// 不输出授权录像数据。
|
|
760
|
+
showWarning: false,
|
|
761
|
+
// 友好错误由包装层统一处理。
|
|
762
|
+
mouseTail: false,
|
|
763
|
+
// 不额外生成画布轨迹。
|
|
764
|
+
triggerFocus: false,
|
|
765
|
+
// 回放不能改变宿主焦点。
|
|
766
|
+
UNSAFE_replayCanvas: false,
|
|
767
|
+
// 禁止不受保护的脚本/画布重建。
|
|
768
|
+
logger: { log() {
|
|
769
|
+
}, warn() {
|
|
770
|
+
} }
|
|
771
|
+
// 官方日志不会带事件进入控制台。
|
|
772
|
+
});
|
|
773
|
+
engineRef.current = player;
|
|
774
|
+
rangeRef.current = playback.range;
|
|
775
|
+
const listen = (eventName, handler) => {
|
|
776
|
+
listeners.push([eventName, handler]);
|
|
777
|
+
player.on(eventName, handler);
|
|
778
|
+
};
|
|
779
|
+
listen("fullsnapshot-rebuilded", () => {
|
|
780
|
+
if (!current || !player) return;
|
|
781
|
+
if (!player.iframe.contentDocument?.documentElement || !player.iframe.contentDocument?.body) {
|
|
782
|
+
fail("rebuild-failed", "\u56DE\u653E\u9875\u9762\u5FEB\u7167\u4E0D\u5B8C\u6574\uFF0C\u65E0\u6CD5\u663E\u793A\u753B\u9762");
|
|
783
|
+
return;
|
|
784
|
+
}
|
|
785
|
+
scheduleFit();
|
|
786
|
+
if (snapshotReady) return;
|
|
787
|
+
snapshotReady = true;
|
|
788
|
+
if (rebuildTimer !== void 0) window.clearTimeout(rebuildTimer);
|
|
789
|
+
publish({ ...initialState("ready"), durationMs: rangeRef.current.total });
|
|
790
|
+
if (autoPlay && rangeRef.current.total > 0) autoPlayFrame = window.requestAnimationFrame(() => {
|
|
791
|
+
autoPlayFrame = void 0;
|
|
792
|
+
if (current && player) player.play(rangeRef.current.start);
|
|
793
|
+
});
|
|
794
|
+
});
|
|
795
|
+
listen("resize", scheduleFit);
|
|
796
|
+
listen("start", () => {
|
|
797
|
+
if (!current || !snapshotReady) return;
|
|
798
|
+
publish({ ...stateRef.current, playing: true });
|
|
799
|
+
startProgress();
|
|
800
|
+
});
|
|
801
|
+
listen("pause", () => {
|
|
802
|
+
stopProgress();
|
|
803
|
+
if (current && snapshotReady) publish({ ...stateRef.current, playing: false });
|
|
804
|
+
});
|
|
805
|
+
listen("finish", () => {
|
|
806
|
+
stopProgress();
|
|
807
|
+
if (current && snapshotReady) publish({ ...stateRef.current, currentTimeMs: rangeRef.current.total, playing: false });
|
|
808
|
+
});
|
|
809
|
+
rebuildTimer = window.setTimeout(() => {
|
|
810
|
+
if (!snapshotReady) fail("rebuild-failed", "\u56DE\u653E\u9875\u9762\u672A\u80FD\u5B8C\u6210\u6062\u590D\uFF0C\u8BF7\u91CD\u65B0\u6253\u5F00\u56DE\u653E");
|
|
811
|
+
}, 4e3);
|
|
812
|
+
player.pause(inclusivePauseOffset(prepared, rangeRef.current.start));
|
|
813
|
+
scheduleFit();
|
|
814
|
+
} catch {
|
|
815
|
+
fail("rebuild-failed", "\u56DE\u653E\u9875\u9762\u6062\u590D\u5931\u8D25\uFF0C\u8BF7\u91CD\u65B0\u6253\u5F00\u56DE\u653E");
|
|
816
|
+
}
|
|
817
|
+
};
|
|
818
|
+
const onLayout = () => {
|
|
819
|
+
start();
|
|
820
|
+
scheduleFit();
|
|
821
|
+
};
|
|
822
|
+
if (typeof ResizeObserver === "function" && stageRef.current) {
|
|
823
|
+
observer = new ResizeObserver(onLayout);
|
|
824
|
+
observer.observe(stageRef.current);
|
|
825
|
+
}
|
|
826
|
+
window.addEventListener("resize", onLayout);
|
|
827
|
+
loadReplayEngine().then((value) => {
|
|
828
|
+
if (!current) return;
|
|
829
|
+
Constructor = value;
|
|
830
|
+
start();
|
|
831
|
+
}).catch(() => fail("engine-load", "\u56DE\u653E\u7EC4\u4EF6\u52A0\u8F7D\u5931\u8D25\uFF0C\u8BF7\u91CD\u65B0\u6253\u5F00\u56DE\u653E"));
|
|
832
|
+
return () => {
|
|
833
|
+
current = false;
|
|
834
|
+
observer?.disconnect();
|
|
835
|
+
window.removeEventListener("resize", onLayout);
|
|
836
|
+
if (runtimeFailureRef.current === commandFailure) runtimeFailureRef.current = null;
|
|
837
|
+
if (replayEventsRef.current === prepared) replayEventsRef.current = [];
|
|
838
|
+
releaseEngine();
|
|
839
|
+
};
|
|
840
|
+
}, [options.active, options.loading, options.error, options.events, options.startOffsetMs, options.endOffsetMs, options.autoPlay, options.stageRef, options.rootRef, publish]);
|
|
841
|
+
const play = useCallback(() => {
|
|
842
|
+
if (!engineRef.current || stateRef.current.status !== "ready" || !rangeRef.current.total) return;
|
|
843
|
+
const target = stateRef.current.currentTimeMs >= rangeRef.current.total ? 0 : stateRef.current.currentTimeMs;
|
|
844
|
+
try {
|
|
845
|
+
engineRef.current.play(rangeRef.current.toInternal(target));
|
|
846
|
+
} catch {
|
|
847
|
+
runtimeFailureRef.current?.();
|
|
848
|
+
return;
|
|
849
|
+
}
|
|
850
|
+
publish({ ...stateRef.current, currentTimeMs: target, playing: true });
|
|
851
|
+
}, [publish]);
|
|
852
|
+
const pause = useCallback(() => {
|
|
853
|
+
if (!engineRef.current || stateRef.current.status !== "ready" || !stateRef.current.playing) return;
|
|
854
|
+
let time;
|
|
855
|
+
try {
|
|
856
|
+
time = rangeRef.current.toInternal(rangeRef.current.toVisible(engineRef.current.getCurrentTime()));
|
|
857
|
+
engineRef.current.pause(inclusivePauseOffset(replayEventsRef.current, time));
|
|
858
|
+
} catch {
|
|
859
|
+
runtimeFailureRef.current?.();
|
|
860
|
+
return;
|
|
861
|
+
}
|
|
862
|
+
publish({ ...stateRef.current, currentTimeMs: rangeRef.current.toVisible(time), playing: false });
|
|
863
|
+
}, [publish]);
|
|
864
|
+
const seek = useCallback((timeMs) => {
|
|
865
|
+
if (!engineRef.current || stateRef.current.status !== "ready") return;
|
|
866
|
+
const target = rangeRef.current.toInternal(timeMs);
|
|
867
|
+
try {
|
|
868
|
+
engineRef.current.pause(inclusivePauseOffset(replayEventsRef.current, target));
|
|
869
|
+
} catch {
|
|
870
|
+
runtimeFailureRef.current?.();
|
|
871
|
+
return;
|
|
872
|
+
}
|
|
873
|
+
publish({ ...stateRef.current, currentTimeMs: rangeRef.current.toVisible(target), playing: false });
|
|
874
|
+
}, [publish]);
|
|
875
|
+
const restart = useCallback(() => {
|
|
876
|
+
seek(0);
|
|
877
|
+
play();
|
|
878
|
+
}, [play, seek]);
|
|
879
|
+
const setPlaybackRate = useCallback((rate) => {
|
|
880
|
+
if (!engineRef.current || stateRef.current.status !== "ready" || !Number.isFinite(rate) || rate <= 0 || rate > 4) return;
|
|
881
|
+
try {
|
|
882
|
+
engineRef.current.setConfig({ speed: rate });
|
|
883
|
+
} catch {
|
|
884
|
+
runtimeFailureRef.current?.();
|
|
885
|
+
return;
|
|
886
|
+
}
|
|
887
|
+
publish({ ...stateRef.current, playbackRate: rate });
|
|
888
|
+
}, [publish]);
|
|
889
|
+
const getState = useCallback(() => ({ ...stateRef.current }), []);
|
|
890
|
+
return { state, play, pause, seek, restart, setPlaybackRate, getState };
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
// src/composites/SessionReplay.tsx
|
|
894
|
+
import { jsx as jsx4, jsxs } from "react/jsx-runtime";
|
|
895
|
+
var playbackRates = [0.5, 1, 1.5, 2];
|
|
896
|
+
var SessionReplay = forwardRef4(function SessionReplay2({ events, active = true, loading = false, error, startOffsetMs, endOffsetMs, autoPlay = false, markers = [], extra, onStateChange, onError, className, style }, ref) {
|
|
897
|
+
const { token } = theme.useToken();
|
|
898
|
+
const containerRef = useRef2(null);
|
|
899
|
+
const stageRef = useRef2(null);
|
|
900
|
+
const rootRef = useRef2(null);
|
|
901
|
+
const [problem, setProblem] = useState2(null);
|
|
902
|
+
const [fullscreen, setFullscreen] = useState2(false);
|
|
903
|
+
const reportError = useCallback2((value) => {
|
|
904
|
+
setProblem(value);
|
|
905
|
+
onError?.(value);
|
|
906
|
+
}, [onError]);
|
|
907
|
+
useEffect2(() => {
|
|
908
|
+
setProblem(null);
|
|
909
|
+
}, [events, active, loading, error, startOffsetMs, endOffsetMs]);
|
|
910
|
+
const controls = useSessionReplay({ events, active, loading, error, startOffsetMs, endOffsetMs, autoPlay, stageRef, rootRef, onStateChange, onError: reportError });
|
|
911
|
+
const { state, play, pause, seek, restart, getState, setPlaybackRate } = controls;
|
|
912
|
+
const ready = state.status === "ready";
|
|
913
|
+
const themeStyle = {
|
|
914
|
+
"--adminsmart-replay-bg": token.colorBgLayout,
|
|
915
|
+
// 舞台周围的中性背景。
|
|
916
|
+
"--adminsmart-replay-surface": token.colorBgContainer,
|
|
917
|
+
// 控制区容器背景。
|
|
918
|
+
"--adminsmart-replay-border": token.colorBorderSecondary,
|
|
919
|
+
// 轻量边界。
|
|
920
|
+
"--adminsmart-replay-text": token.colorText,
|
|
921
|
+
// 主信息文字。
|
|
922
|
+
"--adminsmart-replay-muted": token.colorTextSecondary,
|
|
923
|
+
// 次要时间和提示。
|
|
924
|
+
"--adminsmart-replay-primary": token.colorPrimary,
|
|
925
|
+
// 通用时间标记。
|
|
926
|
+
"--adminsmart-replay-warning": token.colorWarning,
|
|
927
|
+
// 警告标记。
|
|
928
|
+
"--adminsmart-replay-error": token.colorError,
|
|
929
|
+
// 错误标记。
|
|
930
|
+
"--adminsmart-replay-radius": `${token.borderRadiusLG}px`,
|
|
931
|
+
// 主题圆角。
|
|
932
|
+
...style
|
|
933
|
+
};
|
|
934
|
+
useImperativeHandle(ref, () => ({ play, pause, seek, restart, getState }), [play, pause, seek, restart, getState]);
|
|
935
|
+
useEffect2(() => {
|
|
936
|
+
if (!active) return;
|
|
937
|
+
const container = containerRef.current;
|
|
938
|
+
const sync = () => setFullscreen(document.fullscreenElement === container);
|
|
939
|
+
document.addEventListener("fullscreenchange", sync);
|
|
940
|
+
sync();
|
|
941
|
+
return () => {
|
|
942
|
+
document.removeEventListener("fullscreenchange", sync);
|
|
943
|
+
if (document.fullscreenElement === container) void document.exitFullscreen?.().catch(() => {
|
|
944
|
+
});
|
|
945
|
+
};
|
|
946
|
+
}, [active]);
|
|
947
|
+
const toggleFullscreen = async () => {
|
|
948
|
+
if (!containerRef.current || !ready) return;
|
|
949
|
+
try {
|
|
950
|
+
if (document.fullscreenElement === containerRef.current) await document.exitFullscreen();
|
|
951
|
+
else await containerRef.current.requestFullscreen();
|
|
952
|
+
if (problem?.code === "fullscreen") setProblem(null);
|
|
953
|
+
} catch {
|
|
954
|
+
reportError({ code: "fullscreen", message: "\u6D4F\u89C8\u5668\u672A\u5141\u8BB8\u5168\u5C4F\uFF0C\u4ECD\u53EF\u5728\u5F53\u524D\u9762\u677F\u64AD\u653E" });
|
|
955
|
+
}
|
|
956
|
+
};
|
|
957
|
+
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";
|
|
958
|
+
const errorText = error || problem?.message || (state.status === "error" ? "\u5F53\u524D\u56DE\u653E\u6570\u636E\u65E0\u6CD5\u8FD8\u539F\u9875\u9762" : "");
|
|
959
|
+
const playLabel = state.playing ? "\u6682\u505C" : state.currentTimeMs >= state.durationMs && ready ? "\u91CD\u65B0\u64AD\u653E" : "\u64AD\u653E";
|
|
960
|
+
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: [
|
|
961
|
+
/* @__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: [
|
|
962
|
+
/* @__PURE__ */ jsx4("div", { ref: rootRef, className: "adminsmart-session-replay__mount" }),
|
|
963
|
+
!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 }) })
|
|
964
|
+
] }),
|
|
965
|
+
/* @__PURE__ */ jsxs("div", { className: "adminsmart-session-replay__controls", children: [
|
|
966
|
+
/* @__PURE__ */ jsxs("div", { className: "adminsmart-session-replay__summary", children: [
|
|
967
|
+
/* @__PURE__ */ jsx4(Tag2, { color: ready ? "processing" : void 0, className: "adminsmart-session-replay__status", children: /* @__PURE__ */ jsx4("span", { "aria-live": "polite", children: statusText }) }),
|
|
968
|
+
/* @__PURE__ */ jsxs(Typography2.Text, { className: "adminsmart-session-replay__clock", children: [
|
|
969
|
+
replayClock(state.currentTimeMs),
|
|
970
|
+
" ",
|
|
971
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
972
|
+
"/ ",
|
|
973
|
+
replayClock(state.durationMs)
|
|
974
|
+
] })
|
|
975
|
+
] }),
|
|
976
|
+
extra && /* @__PURE__ */ jsx4("div", { className: "adminsmart-session-replay__extra", children: extra })
|
|
977
|
+
] }),
|
|
978
|
+
/* @__PURE__ */ jsxs("div", { className: "adminsmart-session-replay__timeline", children: [
|
|
979
|
+
/* @__PURE__ */ jsx4(
|
|
980
|
+
Slider2,
|
|
981
|
+
{
|
|
982
|
+
min: 0,
|
|
983
|
+
max: Math.max(1, state.durationMs),
|
|
984
|
+
value: state.currentTimeMs,
|
|
985
|
+
disabled: !ready,
|
|
986
|
+
onChange: (value) => seek(value),
|
|
987
|
+
tooltip: { formatter: (value) => replayClock(value ?? 0) },
|
|
988
|
+
ariaLabelForHandle: "\u56DE\u653E\u8FDB\u5EA6",
|
|
989
|
+
ariaValueTextFormatterForHandle: (value) => `${replayClock(value)} / ${replayClock(state.durationMs)}`
|
|
990
|
+
}
|
|
991
|
+
),
|
|
992
|
+
/* @__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(
|
|
993
|
+
"button",
|
|
994
|
+
{
|
|
995
|
+
type: "button",
|
|
996
|
+
className: "adminsmart-session-replay__marker",
|
|
997
|
+
"data-tone": marker.tone || "primary",
|
|
998
|
+
style: { left: `${state.durationMs ? Math.min(100, Math.max(0, finiteReplayNumber(marker.timeMs) / state.durationMs * 100)) : 0}%` },
|
|
999
|
+
"aria-label": `${marker.label} ${replayClock(marker.timeMs)}`,
|
|
1000
|
+
disabled: !ready,
|
|
1001
|
+
onClick: () => seek(marker.timeMs)
|
|
1002
|
+
}
|
|
1003
|
+
) }, `${marker.timeMs}-${index}`)) })
|
|
1004
|
+
] }),
|
|
1005
|
+
/* @__PURE__ */ jsxs("div", { className: "adminsmart-session-replay__toolbar", role: "group", "aria-label": "\u56DE\u653E\u64AD\u653E\u63A7\u5236", children: [
|
|
1006
|
+
/* @__PURE__ */ jsxs("div", { className: "adminsmart-session-replay__transport", children: [
|
|
1007
|
+
/* @__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) }) }),
|
|
1008
|
+
/* @__PURE__ */ jsx4(
|
|
1009
|
+
Button2,
|
|
1010
|
+
{
|
|
1011
|
+
type: "primary",
|
|
1012
|
+
icon: state.playing ? /* @__PURE__ */ jsx4(PauseOutlined, { "aria-hidden": true }) : /* @__PURE__ */ jsx4(PlayCircleOutlined, { "aria-hidden": true }),
|
|
1013
|
+
"aria-label": playLabel,
|
|
1014
|
+
disabled: !ready || !state.durationMs,
|
|
1015
|
+
onClick: state.playing ? pause : play,
|
|
1016
|
+
children: playLabel
|
|
1017
|
+
}
|
|
1018
|
+
),
|
|
1019
|
+
/* @__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) }) }),
|
|
1020
|
+
/* @__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 }) })
|
|
1021
|
+
] }),
|
|
1022
|
+
/* @__PURE__ */ jsxs("div", { className: "adminsmart-session-replay__options", children: [
|
|
1023
|
+
/* @__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 }),
|
|
1024
|
+
/* @__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() }) })
|
|
1025
|
+
] })
|
|
1026
|
+
] }),
|
|
1027
|
+
errorText && /* @__PURE__ */ jsx4(Alert2, { type: problem?.code === "fullscreen" ? "warning" : "error", showIcon: true, title: errorText, className: "adminsmart-session-replay__notice" })
|
|
1028
|
+
] })
|
|
1029
|
+
] });
|
|
1030
|
+
});
|
|
1031
|
+
|
|
470
1032
|
// src/composites/SearchPanel.tsx
|
|
471
1033
|
import { DownOutlined, UpOutlined } from "@ant-design/icons";
|
|
472
1034
|
import {
|
|
473
1035
|
Children,
|
|
474
|
-
forwardRef as
|
|
1036
|
+
forwardRef as forwardRef5,
|
|
475
1037
|
isValidElement,
|
|
476
|
-
useEffect,
|
|
477
|
-
useRef,
|
|
478
|
-
useState
|
|
1038
|
+
useEffect as useEffect3,
|
|
1039
|
+
useRef as useRef3,
|
|
1040
|
+
useState as useState3
|
|
479
1041
|
} from "react";
|
|
480
1042
|
|
|
481
1043
|
// src/composites/searchPanelModel.ts
|
|
@@ -487,17 +1049,17 @@ function collapsedSearchFieldLimit(columns) {
|
|
|
487
1049
|
}
|
|
488
1050
|
|
|
489
1051
|
// src/composites/SearchPanel.tsx
|
|
490
|
-
import { jsx as
|
|
491
|
-
var SearchPanel =
|
|
492
|
-
const rootRef =
|
|
493
|
-
const [width, setWidth] =
|
|
494
|
-
const [expanded, setExpanded] =
|
|
1052
|
+
import { jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
1053
|
+
var SearchPanel = forwardRef5(function SearchPanel2({ fields, actions, tools, trailingTools, searchVisible = true, defaultExpanded = false, role = "search", style, ...props }, ref) {
|
|
1054
|
+
const rootRef = useRef3(null);
|
|
1055
|
+
const [width, setWidth] = useState3(0);
|
|
1056
|
+
const [expanded, setExpanded] = useState3(defaultExpanded);
|
|
495
1057
|
const items = Children.toArray(fields);
|
|
496
1058
|
const columns = searchColumnCount(width);
|
|
497
1059
|
const collapsedLimit = collapsedSearchFieldLimit(columns);
|
|
498
1060
|
const hasMore = items.length > collapsedLimit;
|
|
499
1061
|
const fieldWidth = Math.min(240, Math.max(0, width));
|
|
500
|
-
|
|
1062
|
+
useEffect3(() => {
|
|
501
1063
|
const element = rootRef.current;
|
|
502
1064
|
if (!element) return void 0;
|
|
503
1065
|
const update = () => {
|
|
@@ -526,10 +1088,10 @@ var SearchPanel = forwardRef4(function SearchPanel2({ fields, actions, tools, tr
|
|
|
526
1088
|
...style
|
|
527
1089
|
};
|
|
528
1090
|
const hasToolbar = tools != null || trailingTools != null;
|
|
529
|
-
return /* @__PURE__ */
|
|
530
|
-
/* @__PURE__ */
|
|
531
|
-
(items.length > 0 || actions != null) && /* @__PURE__ */
|
|
532
|
-
items.map((item, index) => /* @__PURE__ */
|
|
1091
|
+
return /* @__PURE__ */ jsxs2("div", { ...props, ref: setRootRef, role: hasToolbar ? "toolbar" : role, style: panelStyle, "data-adminsmart-search-panel": "true", children: [
|
|
1092
|
+
/* @__PURE__ */ jsx5("style", { children: "[data-adminsmart-search-field] > .ant-form-item { margin-bottom: 0; }" }),
|
|
1093
|
+
(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: [
|
|
1094
|
+
items.map((item, index) => /* @__PURE__ */ jsx5(
|
|
533
1095
|
"div",
|
|
534
1096
|
{
|
|
535
1097
|
hidden: !expanded && index >= collapsedLimit,
|
|
@@ -539,35 +1101,35 @@ var SearchPanel = forwardRef4(function SearchPanel2({ fields, actions, tools, tr
|
|
|
539
1101
|
},
|
|
540
1102
|
isValidElement(item) ? item.key ?? index : index
|
|
541
1103
|
)),
|
|
542
|
-
/* @__PURE__ */
|
|
543
|
-
hasMore ? /* @__PURE__ */
|
|
1104
|
+
/* @__PURE__ */ jsxs2("div", { "data-adminsmart-search-actions": "true", style: { display: "flex", alignItems: "center", gap: 8, minHeight: 32 }, children: [
|
|
1105
|
+
hasMore ? /* @__PURE__ */ jsx5(
|
|
544
1106
|
Button,
|
|
545
1107
|
{
|
|
546
1108
|
type: "link",
|
|
547
|
-
icon: expanded ? /* @__PURE__ */
|
|
1109
|
+
icon: expanded ? /* @__PURE__ */ jsx5(UpOutlined, {}) : /* @__PURE__ */ jsx5(DownOutlined, {}),
|
|
548
1110
|
"aria-expanded": expanded,
|
|
549
1111
|
onClick: () => setExpanded((value) => !value),
|
|
550
1112
|
children: expanded ? "\u6536\u8D77\u7B5B\u9009" : "\u5C55\u5F00\u7B5B\u9009"
|
|
551
1113
|
}
|
|
552
1114
|
) : null,
|
|
553
|
-
/* @__PURE__ */
|
|
1115
|
+
/* @__PURE__ */ jsx5("span", { style: { display: "inline-flex", alignItems: "center", gap: 8 }, children: actions })
|
|
554
1116
|
] })
|
|
555
1117
|
] }),
|
|
556
|
-
hasToolbar && /* @__PURE__ */
|
|
557
|
-
/* @__PURE__ */
|
|
558
|
-
/* @__PURE__ */
|
|
1118
|
+
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: [
|
|
1119
|
+
/* @__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 }),
|
|
1120
|
+
/* @__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
1121
|
] })
|
|
560
1122
|
] });
|
|
561
1123
|
});
|
|
562
1124
|
|
|
563
1125
|
// src/composites/DataTable.tsx
|
|
564
1126
|
import {
|
|
565
|
-
forwardRef as
|
|
1127
|
+
forwardRef as forwardRef6,
|
|
566
1128
|
useLayoutEffect,
|
|
567
|
-
useRef as
|
|
568
|
-
useState as
|
|
1129
|
+
useRef as useRef4,
|
|
1130
|
+
useState as useState4
|
|
569
1131
|
} from "react";
|
|
570
|
-
import { jsx as
|
|
1132
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
571
1133
|
function tableBodyHeight(availableHeight, chromeHeight) {
|
|
572
1134
|
return Math.max(0, Math.floor(availableHeight - chromeHeight - 16));
|
|
573
1135
|
}
|
|
@@ -588,8 +1150,8 @@ function DataTableInner({
|
|
|
588
1150
|
scroll,
|
|
589
1151
|
...tableProps
|
|
590
1152
|
}, ref) {
|
|
591
|
-
const containerRef =
|
|
592
|
-
const [bodyHeight, setBodyHeight] =
|
|
1153
|
+
const containerRef = useRef4(null);
|
|
1154
|
+
const [bodyHeight, setBodyHeight] = useState4(360);
|
|
593
1155
|
const hasExplicitHeight = containerHeight != null || containerStyle?.height != null;
|
|
594
1156
|
useLayoutEffect(() => {
|
|
595
1157
|
const container = containerRef.current;
|
|
@@ -625,14 +1187,14 @@ function DataTableInner({
|
|
|
625
1187
|
y: scroll?.y ?? bodyHeight
|
|
626
1188
|
};
|
|
627
1189
|
const tablePagination = pagination === false ? false : pagination?.placement || pagination?.position ? pagination : { placement: ["bottomEnd"], ...pagination };
|
|
628
|
-
return /* @__PURE__ */
|
|
1190
|
+
return /* @__PURE__ */ jsx6(
|
|
629
1191
|
"div",
|
|
630
1192
|
{
|
|
631
1193
|
ref: containerRef,
|
|
632
1194
|
className: containerClassName,
|
|
633
1195
|
"data-adminsmart-data-table": "true",
|
|
634
1196
|
style: { width: "100%", minWidth: 0, overflowX: "hidden", ...containerHeight == null ? {} : { height: containerHeight, overflowY: "hidden" }, ...containerStyle },
|
|
635
|
-
children: /* @__PURE__ */
|
|
1197
|
+
children: /* @__PURE__ */ jsx6(
|
|
636
1198
|
Table,
|
|
637
1199
|
{
|
|
638
1200
|
...tableProps,
|
|
@@ -644,11 +1206,11 @@ function DataTableInner({
|
|
|
644
1206
|
}
|
|
645
1207
|
);
|
|
646
1208
|
}
|
|
647
|
-
var DataTable =
|
|
1209
|
+
var DataTable = forwardRef6(DataTableInner);
|
|
648
1210
|
|
|
649
1211
|
// src/composites/WorkspaceLayout.tsx
|
|
650
|
-
import { theme } from "antd";
|
|
651
|
-
import { jsx as
|
|
1212
|
+
import { theme as theme2 } from "antd";
|
|
1213
|
+
import { jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
652
1214
|
var LIGHT_WORKSPACE_BACKGROUND = "#f6f9fe";
|
|
653
1215
|
function WorkspaceLayout({
|
|
654
1216
|
header,
|
|
@@ -666,7 +1228,7 @@ function WorkspaceLayout({
|
|
|
666
1228
|
contentClassName,
|
|
667
1229
|
height
|
|
668
1230
|
}) {
|
|
669
|
-
const { token } =
|
|
1231
|
+
const { token } = theme2.useToken();
|
|
670
1232
|
const rootClassName = ["adminsmart-workspace", className].filter(Boolean).join(" ");
|
|
671
1233
|
const contentClasses = ["adminsmart-workspace__content", contentClassName].filter(Boolean).join(" ");
|
|
672
1234
|
const siderClasses = ["adminsmart-workspace__sider", siderProps?.className].filter(Boolean).join(" ");
|
|
@@ -680,10 +1242,10 @@ function WorkspaceLayout({
|
|
|
680
1242
|
"--adminsmart-workspace-bg": themeMode === "dark" ? token.colorBgLayout : LIGHT_WORKSPACE_BACKGROUND
|
|
681
1243
|
// 夜间不复用日间固定底色。
|
|
682
1244
|
};
|
|
683
|
-
return /* @__PURE__ */
|
|
684
|
-
/* @__PURE__ */
|
|
685
|
-
/* @__PURE__ */
|
|
686
|
-
/* @__PURE__ */
|
|
1245
|
+
return /* @__PURE__ */ jsxs3(Layout, { className: rootClassName, style: workspaceStyle, "data-theme-mode": themeMode, children: [
|
|
1246
|
+
/* @__PURE__ */ jsx7("header", { className: "adminsmart-workspace__header", children: header }),
|
|
1247
|
+
/* @__PURE__ */ jsxs3(Layout, { className: "adminsmart-workspace__body", children: [
|
|
1248
|
+
/* @__PURE__ */ jsx7(
|
|
687
1249
|
Layout.Sider,
|
|
688
1250
|
{
|
|
689
1251
|
theme: themeMode,
|
|
@@ -695,9 +1257,9 @@ function WorkspaceLayout({
|
|
|
695
1257
|
children: sidebar
|
|
696
1258
|
}
|
|
697
1259
|
),
|
|
698
|
-
/* @__PURE__ */
|
|
1260
|
+
/* @__PURE__ */ jsxs3(Layout, { className: "adminsmart-workspace__main", children: [
|
|
699
1261
|
tabs,
|
|
700
|
-
/* @__PURE__ */
|
|
1262
|
+
/* @__PURE__ */ jsx7(Layout.Content, { className: contentClasses, "data-content-mode": contentMode, children }),
|
|
701
1263
|
footer
|
|
702
1264
|
] })
|
|
703
1265
|
] })
|
|
@@ -705,7 +1267,7 @@ function WorkspaceLayout({
|
|
|
705
1267
|
}
|
|
706
1268
|
|
|
707
1269
|
// src/composites/CrudScaffold.tsx
|
|
708
|
-
import { jsx as
|
|
1270
|
+
import { jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
709
1271
|
function CrudScaffold({
|
|
710
1272
|
label,
|
|
711
1273
|
description,
|
|
@@ -717,16 +1279,16 @@ function CrudScaffold({
|
|
|
717
1279
|
...props
|
|
718
1280
|
}) {
|
|
719
1281
|
const classes = ["adminsmart-crud", className].filter(Boolean).join(" ");
|
|
720
|
-
return /* @__PURE__ */
|
|
721
|
-
/* @__PURE__ */
|
|
722
|
-
status ? /* @__PURE__ */
|
|
723
|
-
/* @__PURE__ */
|
|
1282
|
+
return /* @__PURE__ */ jsxs4("main", { ...props, className: classes, "aria-label": label, "aria-description": description, children: [
|
|
1283
|
+
/* @__PURE__ */ jsx8("div", { className: "adminsmart-crud__filters", children: filters }),
|
|
1284
|
+
status ? /* @__PURE__ */ jsx8("div", { className: "adminsmart-crud__status", children: status }) : null,
|
|
1285
|
+
/* @__PURE__ */ jsx8("div", { className: "adminsmart-crud__results", children: results }),
|
|
724
1286
|
drawer
|
|
725
1287
|
] });
|
|
726
1288
|
}
|
|
727
1289
|
|
|
728
1290
|
// src/composites/EllipsisText.tsx
|
|
729
|
-
import { jsx as
|
|
1291
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
730
1292
|
function EllipsisText({
|
|
731
1293
|
children,
|
|
732
1294
|
maxWidth = 240,
|
|
@@ -738,7 +1300,7 @@ function EllipsisText({
|
|
|
738
1300
|
const classes = ["adminsmart-ellipsis-text", className].filter(Boolean).join(" ");
|
|
739
1301
|
const widthValue = typeof maxWidth === "number" ? `${maxWidth}px` : maxWidth;
|
|
740
1302
|
const textStyle = { "--adminsmart-ellipsis-width": widthValue, ...style };
|
|
741
|
-
return /* @__PURE__ */
|
|
1303
|
+
return /* @__PURE__ */ jsx9(
|
|
742
1304
|
Typography.Text,
|
|
743
1305
|
{
|
|
744
1306
|
...props,
|
|
@@ -753,7 +1315,7 @@ function EllipsisText({
|
|
|
753
1315
|
// src/composites/RowActions.tsx
|
|
754
1316
|
import { EllipsisOutlined } from "@ant-design/icons";
|
|
755
1317
|
import { Children as Children2, Fragment, isValidElement as isValidElement2 } from "react";
|
|
756
|
-
import { jsx as
|
|
1318
|
+
import { jsx as jsx10, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
757
1319
|
function collectButtons(children) {
|
|
758
1320
|
const actions = [];
|
|
759
1321
|
Children2.forEach(children, (child) => {
|
|
@@ -784,9 +1346,9 @@ function RowActions({ children, maxVisible = 2, moreLabel = "\u66F4\u591A\u64CD\
|
|
|
784
1346
|
// 菜单仍按官方语义标识需要确认的动作。
|
|
785
1347
|
}));
|
|
786
1348
|
const classes = ["adminsmart-row-action-group", className].filter(Boolean).join(" ");
|
|
787
|
-
return /* @__PURE__ */
|
|
1349
|
+
return /* @__PURE__ */ jsxs5(Space, { ...props, className: classes, size, wrap, children: [
|
|
788
1350
|
direct,
|
|
789
|
-
overflow.length > 0 && /* @__PURE__ */
|
|
1351
|
+
overflow.length > 0 && /* @__PURE__ */ jsx10(
|
|
790
1352
|
Dropdown,
|
|
791
1353
|
{
|
|
792
1354
|
trigger: ["click"],
|
|
@@ -798,12 +1360,12 @@ function RowActions({ children, maxVisible = 2, moreLabel = "\u66F4\u591A\u64CD\
|
|
|
798
1360
|
action.props.onClick?.(domEvent);
|
|
799
1361
|
}
|
|
800
1362
|
},
|
|
801
|
-
children: /* @__PURE__ */
|
|
1363
|
+
children: /* @__PURE__ */ jsx10(Tooltip, { title: moreLabel, children: /* @__PURE__ */ jsx10(
|
|
802
1364
|
Button,
|
|
803
1365
|
{
|
|
804
1366
|
type: "text",
|
|
805
1367
|
size: "small",
|
|
806
|
-
icon: /* @__PURE__ */
|
|
1368
|
+
icon: /* @__PURE__ */ jsx10(EllipsisOutlined, {}),
|
|
807
1369
|
"aria-label": moreLabel,
|
|
808
1370
|
"aria-haspopup": "menu",
|
|
809
1371
|
"data-adminsmart-row-more": "true",
|
|
@@ -817,7 +1379,7 @@ function RowActions({ children, maxVisible = 2, moreLabel = "\u66F4\u591A\u64CD\
|
|
|
817
1379
|
|
|
818
1380
|
// src/schema/SchemaForm.tsx
|
|
819
1381
|
import dayjs from "dayjs";
|
|
820
|
-
import { forwardRef as
|
|
1382
|
+
import { forwardRef as forwardRef7 } from "react";
|
|
821
1383
|
|
|
822
1384
|
// src/schema/model.ts
|
|
823
1385
|
var FIELD_TYPES = /* @__PURE__ */ new Set([
|
|
@@ -1000,7 +1562,7 @@ function schemaInitialValues(schema) {
|
|
|
1000
1562
|
}
|
|
1001
1563
|
|
|
1002
1564
|
// src/schema/SchemaForm.tsx
|
|
1003
|
-
import { jsx as
|
|
1565
|
+
import { jsx as jsx11, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1004
1566
|
function fieldRules(field) {
|
|
1005
1567
|
const rules = [];
|
|
1006
1568
|
if (field.required) {
|
|
@@ -1045,32 +1607,32 @@ function dateItemProps(field) {
|
|
|
1045
1607
|
function renderControl(field) {
|
|
1046
1608
|
switch (field.type) {
|
|
1047
1609
|
case "input":
|
|
1048
|
-
return /* @__PURE__ */
|
|
1610
|
+
return /* @__PURE__ */ jsx11(Input, { placeholder: field.placeholder });
|
|
1049
1611
|
case "password":
|
|
1050
|
-
return /* @__PURE__ */
|
|
1612
|
+
return /* @__PURE__ */ jsx11(Input.Password, { placeholder: field.placeholder });
|
|
1051
1613
|
case "textarea":
|
|
1052
|
-
return /* @__PURE__ */
|
|
1614
|
+
return /* @__PURE__ */ jsx11(Input.TextArea, { placeholder: field.placeholder });
|
|
1053
1615
|
case "number":
|
|
1054
|
-
return /* @__PURE__ */
|
|
1616
|
+
return /* @__PURE__ */ jsx11(InputNumber, { placeholder: field.placeholder, min: field.validation?.min, max: field.validation?.max, style: { width: "100%" } });
|
|
1055
1617
|
case "select":
|
|
1056
|
-
return /* @__PURE__ */
|
|
1618
|
+
return /* @__PURE__ */ jsx11(Select, { placeholder: field.placeholder, options: field.options });
|
|
1057
1619
|
case "radio":
|
|
1058
|
-
return /* @__PURE__ */
|
|
1620
|
+
return /* @__PURE__ */ jsx11(Radio.Group, { options: field.options });
|
|
1059
1621
|
case "checkbox":
|
|
1060
|
-
return /* @__PURE__ */
|
|
1622
|
+
return /* @__PURE__ */ jsx11(Checkbox, {});
|
|
1061
1623
|
case "switch":
|
|
1062
|
-
return /* @__PURE__ */
|
|
1624
|
+
return /* @__PURE__ */ jsx11(Switch, {});
|
|
1063
1625
|
case "date":
|
|
1064
|
-
return /* @__PURE__ */
|
|
1626
|
+
return /* @__PURE__ */ jsx11(DatePicker, { placeholder: field.placeholder, style: { width: "100%" } });
|
|
1065
1627
|
case "dateRange":
|
|
1066
|
-
return /* @__PURE__ */
|
|
1628
|
+
return /* @__PURE__ */ jsx11(DatePicker.RangePicker, { placeholder: field.placeholder ? [field.placeholder, field.placeholder] : void 0, style: { width: "100%" } });
|
|
1067
1629
|
}
|
|
1068
1630
|
}
|
|
1069
|
-
var SchemaForm =
|
|
1631
|
+
var SchemaForm = forwardRef7(function SchemaForm2({ schema, onSubmit, onChange, onFinish, onValuesChange, initialValues, layout = "vertical", ...formProps }, ref) {
|
|
1070
1632
|
const result = validateSchemaForm(schema);
|
|
1071
1633
|
if (!result.valid) throw new Error(`SchemaForm \u914D\u7F6E\u65E0\u6548\uFF1A${result.errors.map((issue) => `${issue.path} ${issue.message}`).join("\uFF1B")}`);
|
|
1072
1634
|
const defaults = schemaInitialValues(schema);
|
|
1073
|
-
return /* @__PURE__ */
|
|
1635
|
+
return /* @__PURE__ */ jsxs6(
|
|
1074
1636
|
Form,
|
|
1075
1637
|
{
|
|
1076
1638
|
...formProps,
|
|
@@ -1088,7 +1650,7 @@ var SchemaForm = forwardRef6(function SchemaForm2({ schema, onSubmit, onChange,
|
|
|
1088
1650
|
children: [
|
|
1089
1651
|
schema.fields.map((field) => {
|
|
1090
1652
|
const mapped = mapSchemaField(field);
|
|
1091
|
-
return /* @__PURE__ */
|
|
1653
|
+
return /* @__PURE__ */ jsx11(
|
|
1092
1654
|
Form.Item,
|
|
1093
1655
|
{
|
|
1094
1656
|
name: mapped.name,
|
|
@@ -1101,7 +1663,7 @@ var SchemaForm = forwardRef6(function SchemaForm2({ schema, onSubmit, onChange,
|
|
|
1101
1663
|
mapped.name
|
|
1102
1664
|
);
|
|
1103
1665
|
}),
|
|
1104
|
-
/* @__PURE__ */
|
|
1666
|
+
/* @__PURE__ */ jsx11(Form.Item, { children: /* @__PURE__ */ jsx11(Button, { type: "primary", htmlType: "submit", children: schema.submitText ?? "\u63D0\u4EA4" }) })
|
|
1105
1667
|
]
|
|
1106
1668
|
}
|
|
1107
1669
|
);
|
|
@@ -1166,6 +1728,7 @@ export {
|
|
|
1166
1728
|
SearchPanel,
|
|
1167
1729
|
Segmented,
|
|
1168
1730
|
Select,
|
|
1731
|
+
SessionReplay,
|
|
1169
1732
|
Skeleton,
|
|
1170
1733
|
Slider,
|
|
1171
1734
|
Space,
|
|
@@ -1193,7 +1756,7 @@ export {
|
|
|
1193
1756
|
mapSchemaField,
|
|
1194
1757
|
schemaInitialValues,
|
|
1195
1758
|
tableBodyHeight,
|
|
1196
|
-
|
|
1759
|
+
theme3 as theme,
|
|
1197
1760
|
validateSchemaForm
|
|
1198
1761
|
};
|
|
1199
1762
|
//# sourceMappingURL=index.js.map
|