@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.cjs
CHANGED
|
@@ -89,6 +89,7 @@ __export(src_exports, {
|
|
|
89
89
|
SearchPanel: () => SearchPanel,
|
|
90
90
|
Segmented: () => Segmented,
|
|
91
91
|
Select: () => Select,
|
|
92
|
+
SessionReplay: () => SessionReplay,
|
|
92
93
|
Skeleton: () => Skeleton,
|
|
93
94
|
Slider: () => Slider,
|
|
94
95
|
Space: () => Space,
|
|
@@ -116,7 +117,7 @@ __export(src_exports, {
|
|
|
116
117
|
mapSchemaField: () => mapSchemaField,
|
|
117
118
|
schemaInitialValues: () => schemaInitialValues,
|
|
118
119
|
tableBodyHeight: () => tableBodyHeight,
|
|
119
|
-
theme: () =>
|
|
120
|
+
theme: () => import_antd47.theme,
|
|
120
121
|
validateSchemaForm: () => validateSchemaForm
|
|
121
122
|
});
|
|
122
123
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -529,7 +530,7 @@ var import_antd44 = require("antd");
|
|
|
529
530
|
var Watermark = wrapAntComponent(import_antd44.Watermark, "Watermark");
|
|
530
531
|
|
|
531
532
|
// src/index.ts
|
|
532
|
-
var
|
|
533
|
+
var import_antd47 = require("antd");
|
|
533
534
|
|
|
534
535
|
// src/composites/BusinessDrawer.tsx
|
|
535
536
|
var import_react4 = require("react");
|
|
@@ -557,10 +558,538 @@ var BusinessDrawer = (0, import_react4.forwardRef)(function BusinessDrawer2({ si
|
|
|
557
558
|
);
|
|
558
559
|
});
|
|
559
560
|
|
|
560
|
-
// src/composites/
|
|
561
|
+
// src/composites/SessionReplay.tsx
|
|
562
|
+
var import_react6 = require("react");
|
|
561
563
|
var import_icons2 = require("@ant-design/icons");
|
|
564
|
+
var import_antd45 = require("antd");
|
|
565
|
+
|
|
566
|
+
// src/composites/sessionReplayModel.ts
|
|
567
|
+
function finiteReplayNumber(value, fallback = 0) {
|
|
568
|
+
return typeof value === "number" && Number.isFinite(value) ? value : fallback;
|
|
569
|
+
}
|
|
570
|
+
function prepareReplayEvents(events) {
|
|
571
|
+
if (!Array.isArray(events) || events.length < 2) throw new Error("\u5F53\u524D\u56DE\u653E\u6CA1\u6709\u8DB3\u591F\u7684\u9875\u9762\u4E8B\u4EF6");
|
|
572
|
+
let previous = -Infinity;
|
|
573
|
+
for (const event of events) {
|
|
574
|
+
if (!event || typeof event !== "object" || !Number.isFinite(event.timestamp) || event.timestamp < previous)
|
|
575
|
+
throw new Error("\u5F53\u524D\u56DE\u653E\u4E8B\u4EF6\u65F6\u95F4\u65E0\u6548\uFF0C\u65E0\u6CD5\u8FD8\u539F\u9875\u9762");
|
|
576
|
+
previous = event.timestamp;
|
|
577
|
+
}
|
|
578
|
+
const copied = structuredClone(events);
|
|
579
|
+
const normalizeNode = (node) => {
|
|
580
|
+
if (!node || typeof node !== "object") return node;
|
|
581
|
+
const value = node;
|
|
582
|
+
if (String(value.tagName || "").toLowerCase() === "script") return null;
|
|
583
|
+
if (value.type === 1) {
|
|
584
|
+
value.name = "html";
|
|
585
|
+
value.publicId = "";
|
|
586
|
+
value.systemId = "";
|
|
587
|
+
}
|
|
588
|
+
if (value.type === 0 && value.compatMode !== "CSS1Compat" && value.compatMode !== "BackCompat")
|
|
589
|
+
delete value.compatMode;
|
|
590
|
+
if (Array.isArray(value.childNodes)) value.childNodes = value.childNodes.map(normalizeNode).filter(Boolean);
|
|
591
|
+
return value;
|
|
592
|
+
};
|
|
593
|
+
let hasSnapshot = false;
|
|
594
|
+
for (const event of copied) {
|
|
595
|
+
const data = event.data;
|
|
596
|
+
if (!data || typeof data !== "object") continue;
|
|
597
|
+
if (data.node) {
|
|
598
|
+
data.node = normalizeNode(data.node);
|
|
599
|
+
const node = data.node;
|
|
600
|
+
if (event.type === 2 && node?.type === 0 && Array.isArray(node.childNodes) && node.childNodes.length)
|
|
601
|
+
hasSnapshot = true;
|
|
602
|
+
}
|
|
603
|
+
if (Array.isArray(data.adds)) data.adds = data.adds.map((entry) => {
|
|
604
|
+
const addition = entry;
|
|
605
|
+
return { ...addition, node: normalizeNode(addition.node) };
|
|
606
|
+
}).filter((entry) => entry.node);
|
|
607
|
+
}
|
|
608
|
+
if (!hasSnapshot) throw new Error("\u5F53\u524D\u56DE\u653E\u7F3A\u5C11\u5B8C\u6574\u9875\u9762\u5FEB\u7167\uFF0C\u65E0\u6CD5\u8FD8\u539F\u9875\u9762");
|
|
609
|
+
return copied;
|
|
610
|
+
}
|
|
611
|
+
function replayRange(totalTime, startOffsetMs = 0, endOffsetMs) {
|
|
612
|
+
const duration = Math.max(0, finiteReplayNumber(totalTime));
|
|
613
|
+
const start = Math.min(duration, Math.max(0, finiteReplayNumber(startOffsetMs)));
|
|
614
|
+
const end = Math.min(duration, Math.max(start, finiteReplayNumber(endOffsetMs, duration)));
|
|
615
|
+
const total = end - start;
|
|
616
|
+
return {
|
|
617
|
+
start,
|
|
618
|
+
// 恢复到此内部时间后开始显示进度。
|
|
619
|
+
end,
|
|
620
|
+
// 所有播放和跳转不得越过此边界。
|
|
621
|
+
total,
|
|
622
|
+
// 控制栏显示此窗口长度。
|
|
623
|
+
toInternal: (visible) => start + Math.min(total, Math.max(0, finiteReplayNumber(visible))),
|
|
624
|
+
// 可见转内部。
|
|
625
|
+
toVisible: (internal) => Math.min(total, Math.max(0, finiteReplayNumber(internal) - start))
|
|
626
|
+
// 内部转可见。
|
|
627
|
+
};
|
|
628
|
+
}
|
|
629
|
+
function inclusivePauseOffset(events, target) {
|
|
630
|
+
const logicalTarget = Math.max(0, finiteReplayNumber(target));
|
|
631
|
+
const baseline = finiteReplayNumber(events[0]?.timestamp) + logicalTarget;
|
|
632
|
+
let equalEvent = false;
|
|
633
|
+
let increment = 1;
|
|
634
|
+
for (const event of events) {
|
|
635
|
+
if (event.timestamp === baseline) equalEvent = true;
|
|
636
|
+
if (event.timestamp > baseline) {
|
|
637
|
+
increment = Math.min(increment, event.timestamp - baseline);
|
|
638
|
+
break;
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
return equalEvent ? logicalTarget + increment : logicalTarget;
|
|
642
|
+
}
|
|
643
|
+
function replayFit(stageWidth, stageHeight, contentWidth, contentHeight) {
|
|
644
|
+
const width = Math.max(1, finiteReplayNumber(contentWidth, 1));
|
|
645
|
+
const height = Math.max(1, finiteReplayNumber(contentHeight, 1));
|
|
646
|
+
const scale = Math.min(1, Math.max(0, finiteReplayNumber(stageWidth)) / width, Math.max(0, finiteReplayNumber(stageHeight)) / height);
|
|
647
|
+
return {
|
|
648
|
+
scale,
|
|
649
|
+
// 作用于官方公开 wrapper。
|
|
650
|
+
left: Math.max(0, (stageWidth - width * scale) / 2),
|
|
651
|
+
// 水平居中。
|
|
652
|
+
top: Math.max(0, (stageHeight - height * scale) / 2)
|
|
653
|
+
// 垂直居中。
|
|
654
|
+
};
|
|
655
|
+
}
|
|
656
|
+
function replayClock(timeMs) {
|
|
657
|
+
const seconds = Math.floor(Math.max(0, finiteReplayNumber(timeMs)) / 1e3);
|
|
658
|
+
return `${String(Math.floor(seconds / 60)).padStart(2, "0")}:${String(seconds % 60).padStart(2, "0")}`;
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
// src/composites/useSessionReplay.ts
|
|
562
662
|
var import_react5 = require("react");
|
|
563
663
|
|
|
664
|
+
// src/composites/sessionReplayEngine.ts
|
|
665
|
+
async function loadReplayEngine() {
|
|
666
|
+
const [, module2] = await Promise.all([import("@rrweb/replay/dist/style.css"), import("@rrweb/replay")]);
|
|
667
|
+
return module2.Replayer;
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
// src/composites/useSessionReplay.ts
|
|
671
|
+
function initialState(status) {
|
|
672
|
+
return {
|
|
673
|
+
status,
|
|
674
|
+
// 由容器可见性与输入决定。
|
|
675
|
+
currentTimeMs: 0,
|
|
676
|
+
// 新录像从可见起点开始。
|
|
677
|
+
durationMs: 0,
|
|
678
|
+
// 只有官方元数据能够确定时长。
|
|
679
|
+
playing: false,
|
|
680
|
+
// 未恢复快照前不宣称播放中。
|
|
681
|
+
playbackRate: 1
|
|
682
|
+
// 各次录像使用原速。
|
|
683
|
+
};
|
|
684
|
+
}
|
|
685
|
+
function useSessionReplay(options) {
|
|
686
|
+
const [state, setState] = (0, import_react5.useState)(() => initialState("idle"));
|
|
687
|
+
const stateRef = (0, import_react5.useRef)(state);
|
|
688
|
+
const engineRef = (0, import_react5.useRef)(null);
|
|
689
|
+
const runtimeFailureRef = (0, import_react5.useRef)(null);
|
|
690
|
+
const rangeRef = (0, import_react5.useRef)(replayRange(0));
|
|
691
|
+
const replayEventsRef = (0, import_react5.useRef)([]);
|
|
692
|
+
const callbackRef = (0, import_react5.useRef)(options);
|
|
693
|
+
callbackRef.current = options;
|
|
694
|
+
const publish = (0, import_react5.useCallback)((next) => {
|
|
695
|
+
stateRef.current = next;
|
|
696
|
+
setState(next);
|
|
697
|
+
callbackRef.current.onStateChange?.({ ...next });
|
|
698
|
+
}, []);
|
|
699
|
+
(0, import_react5.useEffect)(() => {
|
|
700
|
+
const { active, loading, error, events, stageRef, rootRef, startOffsetMs, endOffsetMs, autoPlay } = options;
|
|
701
|
+
engineRef.current = null;
|
|
702
|
+
runtimeFailureRef.current = null;
|
|
703
|
+
rangeRef.current = replayRange(0);
|
|
704
|
+
replayEventsRef.current = [];
|
|
705
|
+
if (!active) {
|
|
706
|
+
publish(initialState("idle"));
|
|
707
|
+
return;
|
|
708
|
+
}
|
|
709
|
+
if (loading) {
|
|
710
|
+
publish(initialState("loading"));
|
|
711
|
+
return;
|
|
712
|
+
}
|
|
713
|
+
if (error) {
|
|
714
|
+
publish(initialState("error"));
|
|
715
|
+
return;
|
|
716
|
+
}
|
|
717
|
+
if (!events.length) {
|
|
718
|
+
publish(initialState("empty"));
|
|
719
|
+
return;
|
|
720
|
+
}
|
|
721
|
+
let prepared;
|
|
722
|
+
try {
|
|
723
|
+
prepared = prepareReplayEvents(events);
|
|
724
|
+
} catch (reason) {
|
|
725
|
+
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"];
|
|
726
|
+
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" };
|
|
727
|
+
publish(initialState("error"));
|
|
728
|
+
callbackRef.current.onError?.(problem);
|
|
729
|
+
return;
|
|
730
|
+
}
|
|
731
|
+
replayEventsRef.current = prepared;
|
|
732
|
+
publish(initialState("loading"));
|
|
733
|
+
let current = true;
|
|
734
|
+
let failed = false;
|
|
735
|
+
let Constructor = null;
|
|
736
|
+
let player = null;
|
|
737
|
+
let snapshotReady = false;
|
|
738
|
+
let progressTimer;
|
|
739
|
+
let rebuildTimer;
|
|
740
|
+
let fitFrame;
|
|
741
|
+
let autoPlayFrame;
|
|
742
|
+
let observer = null;
|
|
743
|
+
const listeners = [];
|
|
744
|
+
const stopProgress = () => {
|
|
745
|
+
if (progressTimer !== void 0) window.clearInterval(progressTimer);
|
|
746
|
+
progressTimer = void 0;
|
|
747
|
+
};
|
|
748
|
+
const releaseEngine = () => {
|
|
749
|
+
stopProgress();
|
|
750
|
+
if (rebuildTimer !== void 0) window.clearTimeout(rebuildTimer);
|
|
751
|
+
if (fitFrame !== void 0) window.cancelAnimationFrame(fitFrame);
|
|
752
|
+
if (autoPlayFrame !== void 0) window.cancelAnimationFrame(autoPlayFrame);
|
|
753
|
+
if (player) {
|
|
754
|
+
for (const [eventName, handler] of listeners) player.off(eventName, handler);
|
|
755
|
+
try {
|
|
756
|
+
player.destroy();
|
|
757
|
+
} catch {
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
if (engineRef.current === player) engineRef.current = null;
|
|
761
|
+
player = null;
|
|
762
|
+
rootRef.current?.replaceChildren();
|
|
763
|
+
};
|
|
764
|
+
const fail = (code, message) => {
|
|
765
|
+
if (!current || failed) return;
|
|
766
|
+
failed = true;
|
|
767
|
+
releaseEngine();
|
|
768
|
+
observer?.disconnect();
|
|
769
|
+
publish(initialState("error"));
|
|
770
|
+
callbackRef.current.onError?.({ code, message });
|
|
771
|
+
};
|
|
772
|
+
const commandFailure = () => fail("rebuild-failed", "\u56DE\u653E\u9875\u9762\u6062\u590D\u5931\u8D25\uFF0C\u8BF7\u91CD\u65B0\u6253\u5F00\u56DE\u653E");
|
|
773
|
+
runtimeFailureRef.current = commandFailure;
|
|
774
|
+
const fit = () => {
|
|
775
|
+
if (!current || !player || !stageRef.current) return;
|
|
776
|
+
const dimensions = replayFit(stageRef.current.clientWidth, stageRef.current.clientHeight, Number(player.iframe.width), Number(player.iframe.height));
|
|
777
|
+
player.wrapper.style.position = "absolute";
|
|
778
|
+
player.wrapper.style.left = `${dimensions.left}px`;
|
|
779
|
+
player.wrapper.style.top = `${dimensions.top}px`;
|
|
780
|
+
player.wrapper.style.transformOrigin = "top left";
|
|
781
|
+
player.wrapper.style.transform = `scale(${dimensions.scale})`;
|
|
782
|
+
};
|
|
783
|
+
const scheduleFit = () => {
|
|
784
|
+
if (fitFrame !== void 0) window.cancelAnimationFrame(fitFrame);
|
|
785
|
+
fitFrame = window.requestAnimationFrame(() => {
|
|
786
|
+
fitFrame = void 0;
|
|
787
|
+
fit();
|
|
788
|
+
});
|
|
789
|
+
};
|
|
790
|
+
const startProgress = () => {
|
|
791
|
+
stopProgress();
|
|
792
|
+
progressTimer = window.setInterval(() => {
|
|
793
|
+
if (!current || !player || !snapshotReady) return;
|
|
794
|
+
try {
|
|
795
|
+
const time = player.getCurrentTime();
|
|
796
|
+
if (time >= rangeRef.current.end) {
|
|
797
|
+
player.pause(inclusivePauseOffset(prepared, rangeRef.current.end));
|
|
798
|
+
stopProgress();
|
|
799
|
+
publish({ ...stateRef.current, currentTimeMs: rangeRef.current.total, playing: false });
|
|
800
|
+
} else publish({ ...stateRef.current, currentTimeMs: rangeRef.current.toVisible(time) });
|
|
801
|
+
} catch {
|
|
802
|
+
fail("rebuild-failed", "\u56DE\u653E\u9875\u9762\u6062\u590D\u5931\u8D25\uFF0C\u8BF7\u91CD\u65B0\u6253\u5F00\u56DE\u653E");
|
|
803
|
+
}
|
|
804
|
+
}, 100);
|
|
805
|
+
};
|
|
806
|
+
const start = () => {
|
|
807
|
+
if (!current || failed || player || !Constructor || !stageRef.current || !rootRef.current) return;
|
|
808
|
+
if (stageRef.current.clientWidth <= 0 || stageRef.current.clientHeight <= 0) return;
|
|
809
|
+
try {
|
|
810
|
+
player = new Constructor(prepared, {
|
|
811
|
+
root: rootRef.current,
|
|
812
|
+
// 实例只能挂载在自己的专属节点。
|
|
813
|
+
skipInactive: false,
|
|
814
|
+
// 时间轴与用户可见窗口保持一致。
|
|
815
|
+
showDebug: false,
|
|
816
|
+
// 不输出授权录像数据。
|
|
817
|
+
showWarning: false,
|
|
818
|
+
// 友好错误由包装层统一处理。
|
|
819
|
+
mouseTail: false,
|
|
820
|
+
// 不额外生成画布轨迹。
|
|
821
|
+
triggerFocus: false,
|
|
822
|
+
// 回放不能改变宿主焦点。
|
|
823
|
+
UNSAFE_replayCanvas: false,
|
|
824
|
+
// 禁止不受保护的脚本/画布重建。
|
|
825
|
+
logger: { log() {
|
|
826
|
+
}, warn() {
|
|
827
|
+
} }
|
|
828
|
+
// 官方日志不会带事件进入控制台。
|
|
829
|
+
});
|
|
830
|
+
engineRef.current = player;
|
|
831
|
+
rangeRef.current = replayRange(player.getMetaData().totalTime, startOffsetMs, endOffsetMs);
|
|
832
|
+
const listen = (eventName, handler) => {
|
|
833
|
+
listeners.push([eventName, handler]);
|
|
834
|
+
player.on(eventName, handler);
|
|
835
|
+
};
|
|
836
|
+
listen("fullsnapshot-rebuilded", () => {
|
|
837
|
+
if (!current || !player) return;
|
|
838
|
+
if (!player.iframe.contentDocument?.documentElement || !player.iframe.contentDocument?.body) {
|
|
839
|
+
fail("rebuild-failed", "\u56DE\u653E\u9875\u9762\u5FEB\u7167\u4E0D\u5B8C\u6574\uFF0C\u65E0\u6CD5\u663E\u793A\u753B\u9762");
|
|
840
|
+
return;
|
|
841
|
+
}
|
|
842
|
+
scheduleFit();
|
|
843
|
+
if (snapshotReady) return;
|
|
844
|
+
snapshotReady = true;
|
|
845
|
+
if (rebuildTimer !== void 0) window.clearTimeout(rebuildTimer);
|
|
846
|
+
publish({ ...initialState("ready"), durationMs: rangeRef.current.total });
|
|
847
|
+
if (autoPlay && rangeRef.current.total > 0) autoPlayFrame = window.requestAnimationFrame(() => {
|
|
848
|
+
autoPlayFrame = void 0;
|
|
849
|
+
if (current && player) player.play(rangeRef.current.start);
|
|
850
|
+
});
|
|
851
|
+
});
|
|
852
|
+
listen("resize", scheduleFit);
|
|
853
|
+
listen("start", () => {
|
|
854
|
+
if (!current || !snapshotReady) return;
|
|
855
|
+
publish({ ...stateRef.current, playing: true });
|
|
856
|
+
startProgress();
|
|
857
|
+
});
|
|
858
|
+
listen("pause", () => {
|
|
859
|
+
stopProgress();
|
|
860
|
+
if (current && snapshotReady) publish({ ...stateRef.current, playing: false });
|
|
861
|
+
});
|
|
862
|
+
listen("finish", () => {
|
|
863
|
+
stopProgress();
|
|
864
|
+
if (current && snapshotReady) publish({ ...stateRef.current, currentTimeMs: rangeRef.current.total, playing: false });
|
|
865
|
+
});
|
|
866
|
+
rebuildTimer = window.setTimeout(() => {
|
|
867
|
+
if (!snapshotReady) fail("rebuild-failed", "\u56DE\u653E\u9875\u9762\u672A\u80FD\u5B8C\u6210\u6062\u590D\uFF0C\u8BF7\u91CD\u65B0\u6253\u5F00\u56DE\u653E");
|
|
868
|
+
}, 4e3);
|
|
869
|
+
player.pause(inclusivePauseOffset(prepared, rangeRef.current.start));
|
|
870
|
+
scheduleFit();
|
|
871
|
+
} catch {
|
|
872
|
+
fail("rebuild-failed", "\u56DE\u653E\u9875\u9762\u6062\u590D\u5931\u8D25\uFF0C\u8BF7\u91CD\u65B0\u6253\u5F00\u56DE\u653E");
|
|
873
|
+
}
|
|
874
|
+
};
|
|
875
|
+
const onLayout = () => {
|
|
876
|
+
start();
|
|
877
|
+
scheduleFit();
|
|
878
|
+
};
|
|
879
|
+
if (typeof ResizeObserver === "function" && stageRef.current) {
|
|
880
|
+
observer = new ResizeObserver(onLayout);
|
|
881
|
+
observer.observe(stageRef.current);
|
|
882
|
+
}
|
|
883
|
+
window.addEventListener("resize", onLayout);
|
|
884
|
+
loadReplayEngine().then((value) => {
|
|
885
|
+
if (!current) return;
|
|
886
|
+
Constructor = value;
|
|
887
|
+
start();
|
|
888
|
+
}).catch(() => fail("engine-load", "\u56DE\u653E\u7EC4\u4EF6\u52A0\u8F7D\u5931\u8D25\uFF0C\u8BF7\u91CD\u65B0\u6253\u5F00\u56DE\u653E"));
|
|
889
|
+
return () => {
|
|
890
|
+
current = false;
|
|
891
|
+
observer?.disconnect();
|
|
892
|
+
window.removeEventListener("resize", onLayout);
|
|
893
|
+
if (runtimeFailureRef.current === commandFailure) runtimeFailureRef.current = null;
|
|
894
|
+
if (replayEventsRef.current === prepared) replayEventsRef.current = [];
|
|
895
|
+
releaseEngine();
|
|
896
|
+
};
|
|
897
|
+
}, [options.active, options.loading, options.error, options.events, options.startOffsetMs, options.endOffsetMs, options.autoPlay, options.stageRef, options.rootRef, publish]);
|
|
898
|
+
const play = (0, import_react5.useCallback)(() => {
|
|
899
|
+
if (!engineRef.current || stateRef.current.status !== "ready" || !rangeRef.current.total) return;
|
|
900
|
+
const target = stateRef.current.currentTimeMs >= rangeRef.current.total ? 0 : stateRef.current.currentTimeMs;
|
|
901
|
+
try {
|
|
902
|
+
engineRef.current.play(rangeRef.current.toInternal(target));
|
|
903
|
+
} catch {
|
|
904
|
+
runtimeFailureRef.current?.();
|
|
905
|
+
return;
|
|
906
|
+
}
|
|
907
|
+
publish({ ...stateRef.current, currentTimeMs: target, playing: true });
|
|
908
|
+
}, [publish]);
|
|
909
|
+
const pause = (0, import_react5.useCallback)(() => {
|
|
910
|
+
if (!engineRef.current || stateRef.current.status !== "ready" || !stateRef.current.playing) return;
|
|
911
|
+
let time;
|
|
912
|
+
try {
|
|
913
|
+
time = rangeRef.current.toInternal(rangeRef.current.toVisible(engineRef.current.getCurrentTime()));
|
|
914
|
+
engineRef.current.pause(inclusivePauseOffset(replayEventsRef.current, time));
|
|
915
|
+
} catch {
|
|
916
|
+
runtimeFailureRef.current?.();
|
|
917
|
+
return;
|
|
918
|
+
}
|
|
919
|
+
publish({ ...stateRef.current, currentTimeMs: rangeRef.current.toVisible(time), playing: false });
|
|
920
|
+
}, [publish]);
|
|
921
|
+
const seek = (0, import_react5.useCallback)((timeMs) => {
|
|
922
|
+
if (!engineRef.current || stateRef.current.status !== "ready") return;
|
|
923
|
+
const target = rangeRef.current.toInternal(timeMs);
|
|
924
|
+
try {
|
|
925
|
+
engineRef.current.pause(inclusivePauseOffset(replayEventsRef.current, target));
|
|
926
|
+
} catch {
|
|
927
|
+
runtimeFailureRef.current?.();
|
|
928
|
+
return;
|
|
929
|
+
}
|
|
930
|
+
publish({ ...stateRef.current, currentTimeMs: rangeRef.current.toVisible(target), playing: false });
|
|
931
|
+
}, [publish]);
|
|
932
|
+
const restart = (0, import_react5.useCallback)(() => {
|
|
933
|
+
seek(0);
|
|
934
|
+
play();
|
|
935
|
+
}, [play, seek]);
|
|
936
|
+
const setPlaybackRate = (0, import_react5.useCallback)((rate) => {
|
|
937
|
+
if (!engineRef.current || stateRef.current.status !== "ready" || !Number.isFinite(rate) || rate <= 0 || rate > 4) return;
|
|
938
|
+
try {
|
|
939
|
+
engineRef.current.setConfig({ speed: rate });
|
|
940
|
+
} catch {
|
|
941
|
+
runtimeFailureRef.current?.();
|
|
942
|
+
return;
|
|
943
|
+
}
|
|
944
|
+
publish({ ...stateRef.current, playbackRate: rate });
|
|
945
|
+
}, [publish]);
|
|
946
|
+
const getState = (0, import_react5.useCallback)(() => ({ ...stateRef.current }), []);
|
|
947
|
+
return { state, play, pause, seek, restart, setPlaybackRate, getState };
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
// src/composites/SessionReplay.tsx
|
|
951
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
952
|
+
var playbackRates = [0.5, 1, 1.5, 2];
|
|
953
|
+
var SessionReplay = (0, import_react6.forwardRef)(function SessionReplay2({ events, active = true, loading = false, error, startOffsetMs, endOffsetMs, autoPlay = false, markers = [], extra, onStateChange, onError, className, style }, ref) {
|
|
954
|
+
const { token } = import_antd45.theme.useToken();
|
|
955
|
+
const containerRef = (0, import_react6.useRef)(null);
|
|
956
|
+
const stageRef = (0, import_react6.useRef)(null);
|
|
957
|
+
const rootRef = (0, import_react6.useRef)(null);
|
|
958
|
+
const [problem, setProblem] = (0, import_react6.useState)(null);
|
|
959
|
+
const [fullscreen, setFullscreen] = (0, import_react6.useState)(false);
|
|
960
|
+
const reportError = (0, import_react6.useCallback)((value) => {
|
|
961
|
+
setProblem(value);
|
|
962
|
+
onError?.(value);
|
|
963
|
+
}, [onError]);
|
|
964
|
+
(0, import_react6.useEffect)(() => {
|
|
965
|
+
setProblem(null);
|
|
966
|
+
}, [events, active, loading, error, startOffsetMs, endOffsetMs]);
|
|
967
|
+
const controls = useSessionReplay({ events, active, loading, error, startOffsetMs, endOffsetMs, autoPlay, stageRef, rootRef, onStateChange, onError: reportError });
|
|
968
|
+
const { state, play, pause, seek, restart, getState, setPlaybackRate } = controls;
|
|
969
|
+
const ready = state.status === "ready";
|
|
970
|
+
const themeStyle = {
|
|
971
|
+
"--adminsmart-replay-bg": token.colorBgLayout,
|
|
972
|
+
// 舞台周围的中性背景。
|
|
973
|
+
"--adminsmart-replay-surface": token.colorBgContainer,
|
|
974
|
+
// 控制区容器背景。
|
|
975
|
+
"--adminsmart-replay-border": token.colorBorderSecondary,
|
|
976
|
+
// 轻量边界。
|
|
977
|
+
"--adminsmart-replay-text": token.colorText,
|
|
978
|
+
// 主信息文字。
|
|
979
|
+
"--adminsmart-replay-muted": token.colorTextSecondary,
|
|
980
|
+
// 次要时间和提示。
|
|
981
|
+
"--adminsmart-replay-primary": token.colorPrimary,
|
|
982
|
+
// 通用时间标记。
|
|
983
|
+
"--adminsmart-replay-warning": token.colorWarning,
|
|
984
|
+
// 警告标记。
|
|
985
|
+
"--adminsmart-replay-error": token.colorError,
|
|
986
|
+
// 错误标记。
|
|
987
|
+
"--adminsmart-replay-radius": `${token.borderRadiusLG}px`,
|
|
988
|
+
// 主题圆角。
|
|
989
|
+
...style
|
|
990
|
+
};
|
|
991
|
+
(0, import_react6.useImperativeHandle)(ref, () => ({ play, pause, seek, restart, getState }), [play, pause, seek, restart, getState]);
|
|
992
|
+
(0, import_react6.useEffect)(() => {
|
|
993
|
+
if (!active) return;
|
|
994
|
+
const container = containerRef.current;
|
|
995
|
+
const sync = () => setFullscreen(document.fullscreenElement === container);
|
|
996
|
+
document.addEventListener("fullscreenchange", sync);
|
|
997
|
+
sync();
|
|
998
|
+
return () => {
|
|
999
|
+
document.removeEventListener("fullscreenchange", sync);
|
|
1000
|
+
if (document.fullscreenElement === container) void document.exitFullscreen?.().catch(() => {
|
|
1001
|
+
});
|
|
1002
|
+
};
|
|
1003
|
+
}, [active]);
|
|
1004
|
+
const toggleFullscreen = async () => {
|
|
1005
|
+
if (!containerRef.current || !ready) return;
|
|
1006
|
+
try {
|
|
1007
|
+
if (document.fullscreenElement === containerRef.current) await document.exitFullscreen();
|
|
1008
|
+
else await containerRef.current.requestFullscreen();
|
|
1009
|
+
if (problem?.code === "fullscreen") setProblem(null);
|
|
1010
|
+
} catch {
|
|
1011
|
+
reportError({ code: "fullscreen", message: "\u6D4F\u89C8\u5668\u672A\u5141\u8BB8\u5168\u5C4F\uFF0C\u4ECD\u53EF\u5728\u5F53\u524D\u9762\u677F\u64AD\u653E" });
|
|
1012
|
+
}
|
|
1013
|
+
};
|
|
1014
|
+
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";
|
|
1015
|
+
const errorText = error || problem?.message || (state.status === "error" ? "\u5F53\u524D\u56DE\u653E\u6570\u636E\u65E0\u6CD5\u8FD8\u539F\u9875\u9762" : "");
|
|
1016
|
+
const playLabel = state.playing ? "\u6682\u505C" : state.currentTimeMs >= state.durationMs && ready ? "\u91CD\u65B0\u64AD\u653E" : "\u64AD\u653E";
|
|
1017
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.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: [
|
|
1018
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { ref: stageRef, className: "adminsmart-session-replay__stage", "aria-label": "\u64CD\u4F5C\u56DE\u653E\u753B\u9762", "aria-busy": loading || state.status === "loading", children: [
|
|
1019
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { ref: rootRef, className: "adminsmart-session-replay__mount" }),
|
|
1020
|
+
!ready && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "adminsmart-session-replay__placeholder", role: "status", children: loading || state.status === "loading" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_antd45.Spin, { description: "\u6B63\u5728\u6062\u590D\u56DE\u653E\u753B\u9762" }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_antd45.Empty, { description: errorText || (state.status === "empty" ? "\u6682\u65E0\u53EF\u64AD\u653E\u56DE\u653E\u6570\u636E" : "\u7B49\u5F85\u53EF\u89C1\u56DE\u653E\u7A97\u53E3"), image: import_antd45.Empty.PRESENTED_IMAGE_SIMPLE }) })
|
|
1021
|
+
] }),
|
|
1022
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "adminsmart-session-replay__controls", children: [
|
|
1023
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "adminsmart-session-replay__summary", children: [
|
|
1024
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_antd45.Tag, { color: ready ? "processing" : void 0, className: "adminsmart-session-replay__status", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "aria-live": "polite", children: statusText }) }),
|
|
1025
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_antd45.Typography.Text, { className: "adminsmart-session-replay__clock", children: [
|
|
1026
|
+
replayClock(state.currentTimeMs),
|
|
1027
|
+
" ",
|
|
1028
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { children: [
|
|
1029
|
+
"/ ",
|
|
1030
|
+
replayClock(state.durationMs)
|
|
1031
|
+
] })
|
|
1032
|
+
] }),
|
|
1033
|
+
extra && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "adminsmart-session-replay__extra", children: extra })
|
|
1034
|
+
] }),
|
|
1035
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "adminsmart-session-replay__timeline", children: [
|
|
1036
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1037
|
+
import_antd45.Slider,
|
|
1038
|
+
{
|
|
1039
|
+
min: 0,
|
|
1040
|
+
max: Math.max(1, state.durationMs),
|
|
1041
|
+
value: state.currentTimeMs,
|
|
1042
|
+
disabled: !ready,
|
|
1043
|
+
onChange: (value) => seek(value),
|
|
1044
|
+
tooltip: { formatter: (value) => replayClock(value ?? 0) },
|
|
1045
|
+
ariaLabelForHandle: "\u56DE\u653E\u8FDB\u5EA6",
|
|
1046
|
+
ariaValueTextFormatterForHandle: (value) => `${replayClock(value)} / ${replayClock(state.durationMs)}`
|
|
1047
|
+
}
|
|
1048
|
+
),
|
|
1049
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("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__ */ (0, import_jsx_runtime4.jsx)(import_antd45.Tooltip, { title: `${marker.label} \xB7 ${replayClock(marker.timeMs)}`, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1050
|
+
"button",
|
|
1051
|
+
{
|
|
1052
|
+
type: "button",
|
|
1053
|
+
className: "adminsmart-session-replay__marker",
|
|
1054
|
+
"data-tone": marker.tone || "primary",
|
|
1055
|
+
style: { left: `${state.durationMs ? Math.min(100, Math.max(0, finiteReplayNumber(marker.timeMs) / state.durationMs * 100)) : 0}%` },
|
|
1056
|
+
"aria-label": `${marker.label} ${replayClock(marker.timeMs)}`,
|
|
1057
|
+
disabled: !ready,
|
|
1058
|
+
onClick: () => seek(marker.timeMs)
|
|
1059
|
+
}
|
|
1060
|
+
) }, `${marker.timeMs}-${index}`)) })
|
|
1061
|
+
] }),
|
|
1062
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "adminsmart-session-replay__toolbar", role: "group", "aria-label": "\u56DE\u653E\u64AD\u653E\u63A7\u5236", children: [
|
|
1063
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "adminsmart-session-replay__transport", children: [
|
|
1064
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_antd45.Tooltip, { title: "\u540E\u9000 5 \u79D2", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_antd45.Button, { icon: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_icons2.StepBackwardOutlined, { "aria-hidden": true }), "aria-label": "\u540E\u9000 5 \u79D2", disabled: !ready, onClick: () => seek(state.currentTimeMs - 5e3) }) }),
|
|
1065
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1066
|
+
import_antd45.Button,
|
|
1067
|
+
{
|
|
1068
|
+
type: "primary",
|
|
1069
|
+
icon: state.playing ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_icons2.PauseOutlined, { "aria-hidden": true }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_icons2.PlayCircleOutlined, { "aria-hidden": true }),
|
|
1070
|
+
"aria-label": playLabel,
|
|
1071
|
+
disabled: !ready || !state.durationMs,
|
|
1072
|
+
onClick: state.playing ? pause : play,
|
|
1073
|
+
children: playLabel
|
|
1074
|
+
}
|
|
1075
|
+
),
|
|
1076
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_antd45.Tooltip, { title: "\u524D\u8FDB 5 \u79D2", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_antd45.Button, { icon: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_icons2.StepForwardOutlined, { "aria-hidden": true }), "aria-label": "\u524D\u8FDB 5 \u79D2", disabled: !ready, onClick: () => seek(state.currentTimeMs + 5e3) }) }),
|
|
1077
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_antd45.Tooltip, { title: "\u4ECE\u5934\u64AD\u653E", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_antd45.Button, { type: "text", icon: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_icons2.RedoOutlined, { "aria-hidden": true }), "aria-label": "\u4ECE\u5934\u64AD\u653E", disabled: !ready || !state.durationMs, onClick: restart }) })
|
|
1078
|
+
] }),
|
|
1079
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "adminsmart-session-replay__options", children: [
|
|
1080
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_antd45.Select, { 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 }),
|
|
1081
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_antd45.Tooltip, { title: fullscreen ? "\u9000\u51FA\u5168\u5C4F" : "\u5168\u5C4F\u64AD\u653E", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_antd45.Button, { type: "text", icon: fullscreen ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_icons2.FullscreenExitOutlined, { "aria-hidden": true }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_icons2.FullscreenOutlined, { "aria-hidden": true }), "aria-label": fullscreen ? "\u9000\u51FA\u5168\u5C4F" : "\u5168\u5C4F\u64AD\u653E", disabled: !ready, onClick: () => void toggleFullscreen() }) })
|
|
1082
|
+
] })
|
|
1083
|
+
] }),
|
|
1084
|
+
errorText && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_antd45.Alert, { type: problem?.code === "fullscreen" ? "warning" : "error", showIcon: true, title: errorText, className: "adminsmart-session-replay__notice" })
|
|
1085
|
+
] })
|
|
1086
|
+
] });
|
|
1087
|
+
});
|
|
1088
|
+
|
|
1089
|
+
// src/composites/SearchPanel.tsx
|
|
1090
|
+
var import_icons3 = require("@ant-design/icons");
|
|
1091
|
+
var import_react7 = require("react");
|
|
1092
|
+
|
|
564
1093
|
// src/composites/searchPanelModel.ts
|
|
565
1094
|
function searchColumnCount(width) {
|
|
566
1095
|
return Math.min(6, Math.max(1, Math.floor((Math.max(0, width) + 16) / 256)));
|
|
@@ -570,17 +1099,17 @@ function collapsedSearchFieldLimit(columns) {
|
|
|
570
1099
|
}
|
|
571
1100
|
|
|
572
1101
|
// src/composites/SearchPanel.tsx
|
|
573
|
-
var
|
|
574
|
-
var SearchPanel = (0,
|
|
575
|
-
const rootRef = (0,
|
|
576
|
-
const [width, setWidth] = (0,
|
|
577
|
-
const [expanded, setExpanded] = (0,
|
|
578
|
-
const items =
|
|
1102
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1103
|
+
var SearchPanel = (0, import_react7.forwardRef)(function SearchPanel2({ fields, actions, tools, trailingTools, searchVisible = true, defaultExpanded = false, role = "search", style, ...props }, ref) {
|
|
1104
|
+
const rootRef = (0, import_react7.useRef)(null);
|
|
1105
|
+
const [width, setWidth] = (0, import_react7.useState)(0);
|
|
1106
|
+
const [expanded, setExpanded] = (0, import_react7.useState)(defaultExpanded);
|
|
1107
|
+
const items = import_react7.Children.toArray(fields);
|
|
579
1108
|
const columns = searchColumnCount(width);
|
|
580
1109
|
const collapsedLimit = collapsedSearchFieldLimit(columns);
|
|
581
1110
|
const hasMore = items.length > collapsedLimit;
|
|
582
1111
|
const fieldWidth = Math.min(240, Math.max(0, width));
|
|
583
|
-
(0,
|
|
1112
|
+
(0, import_react7.useEffect)(() => {
|
|
584
1113
|
const element = rootRef.current;
|
|
585
1114
|
if (!element) return void 0;
|
|
586
1115
|
const update = () => {
|
|
@@ -609,10 +1138,10 @@ var SearchPanel = (0, import_react5.forwardRef)(function SearchPanel2({ fields,
|
|
|
609
1138
|
...style
|
|
610
1139
|
};
|
|
611
1140
|
const hasToolbar = tools != null || trailingTools != null;
|
|
612
|
-
return /* @__PURE__ */ (0,
|
|
613
|
-
/* @__PURE__ */ (0,
|
|
614
|
-
(items.length > 0 || actions != null) && /* @__PURE__ */ (0,
|
|
615
|
-
items.map((item, index) => /* @__PURE__ */ (0,
|
|
1141
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { ...props, ref: setRootRef, role: hasToolbar ? "toolbar" : role, style: panelStyle, "data-adminsmart-search-panel": "true", children: [
|
|
1142
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("style", { children: "[data-adminsmart-search-field] > .ant-form-item { margin-bottom: 0; }" }),
|
|
1143
|
+
(items.length > 0 || actions != null) && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { role: hasToolbar ? role : void 0, "aria-hidden": !searchVisible, style: { display: searchVisible ? "flex" : "none", width: "100%", flexWrap: "wrap", alignItems: "end", gap: "12px 16px" }, children: [
|
|
1144
|
+
items.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
616
1145
|
"div",
|
|
617
1146
|
{
|
|
618
1147
|
hidden: !expanded && index >= collapsedLimit,
|
|
@@ -620,32 +1149,32 @@ var SearchPanel = (0, import_react5.forwardRef)(function SearchPanel2({ fields,
|
|
|
620
1149
|
style: { minWidth: 0, width: fieldWidth || "min(240px, 100%)", flex: "0 0 auto" },
|
|
621
1150
|
children: item
|
|
622
1151
|
},
|
|
623
|
-
(0,
|
|
1152
|
+
(0, import_react7.isValidElement)(item) ? item.key ?? index : index
|
|
624
1153
|
)),
|
|
625
|
-
/* @__PURE__ */ (0,
|
|
626
|
-
hasMore ? /* @__PURE__ */ (0,
|
|
1154
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { "data-adminsmart-search-actions": "true", style: { display: "flex", alignItems: "center", gap: 8, minHeight: 32 }, children: [
|
|
1155
|
+
hasMore ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
627
1156
|
Button,
|
|
628
1157
|
{
|
|
629
1158
|
type: "link",
|
|
630
|
-
icon: expanded ? /* @__PURE__ */ (0,
|
|
1159
|
+
icon: expanded ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_icons3.UpOutlined, {}) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_icons3.DownOutlined, {}),
|
|
631
1160
|
"aria-expanded": expanded,
|
|
632
1161
|
onClick: () => setExpanded((value) => !value),
|
|
633
1162
|
children: expanded ? "\u6536\u8D77\u7B5B\u9009" : "\u5C55\u5F00\u7B5B\u9009"
|
|
634
1163
|
}
|
|
635
1164
|
) : null,
|
|
636
|
-
/* @__PURE__ */ (0,
|
|
1165
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { style: { display: "inline-flex", alignItems: "center", gap: 8 }, children: actions })
|
|
637
1166
|
] })
|
|
638
1167
|
] }),
|
|
639
|
-
hasToolbar && /* @__PURE__ */ (0,
|
|
640
|
-
/* @__PURE__ */ (0,
|
|
641
|
-
/* @__PURE__ */ (0,
|
|
1168
|
+
hasToolbar && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { "data-adminsmart-toolbar-row": "true", style: { display: "flex", width: "100%", minWidth: 0, alignItems: "center", justifyContent: "space-between", flexWrap: "wrap", gap: 12 }, children: [
|
|
1169
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("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 }),
|
|
1170
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { role: "group", "aria-label": "\u8868\u683C\u5DE5\u5177", style: { display: "flex", alignItems: "center", flexWrap: "wrap", gap: 12, marginLeft: "auto", minHeight: 32 }, children: trailingTools })
|
|
642
1171
|
] })
|
|
643
1172
|
] });
|
|
644
1173
|
});
|
|
645
1174
|
|
|
646
1175
|
// src/composites/DataTable.tsx
|
|
647
|
-
var
|
|
648
|
-
var
|
|
1176
|
+
var import_react8 = require("react");
|
|
1177
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
649
1178
|
function tableBodyHeight(availableHeight, chromeHeight) {
|
|
650
1179
|
return Math.max(0, Math.floor(availableHeight - chromeHeight - 16));
|
|
651
1180
|
}
|
|
@@ -666,10 +1195,10 @@ function DataTableInner({
|
|
|
666
1195
|
scroll,
|
|
667
1196
|
...tableProps
|
|
668
1197
|
}, ref) {
|
|
669
|
-
const containerRef = (0,
|
|
670
|
-
const [bodyHeight, setBodyHeight] = (0,
|
|
1198
|
+
const containerRef = (0, import_react8.useRef)(null);
|
|
1199
|
+
const [bodyHeight, setBodyHeight] = (0, import_react8.useState)(360);
|
|
671
1200
|
const hasExplicitHeight = containerHeight != null || containerStyle?.height != null;
|
|
672
|
-
(0,
|
|
1201
|
+
(0, import_react8.useLayoutEffect)(() => {
|
|
673
1202
|
const container = containerRef.current;
|
|
674
1203
|
if (!container || scroll?.y != null) return void 0;
|
|
675
1204
|
const update = () => {
|
|
@@ -703,14 +1232,14 @@ function DataTableInner({
|
|
|
703
1232
|
y: scroll?.y ?? bodyHeight
|
|
704
1233
|
};
|
|
705
1234
|
const tablePagination = pagination === false ? false : pagination?.placement || pagination?.position ? pagination : { placement: ["bottomEnd"], ...pagination };
|
|
706
|
-
return /* @__PURE__ */ (0,
|
|
1235
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
707
1236
|
"div",
|
|
708
1237
|
{
|
|
709
1238
|
ref: containerRef,
|
|
710
1239
|
className: containerClassName,
|
|
711
1240
|
"data-adminsmart-data-table": "true",
|
|
712
1241
|
style: { width: "100%", minWidth: 0, overflowX: "hidden", ...containerHeight == null ? {} : { height: containerHeight, overflowY: "hidden" }, ...containerStyle },
|
|
713
|
-
children: /* @__PURE__ */ (0,
|
|
1242
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
714
1243
|
Table,
|
|
715
1244
|
{
|
|
716
1245
|
...tableProps,
|
|
@@ -722,11 +1251,11 @@ function DataTableInner({
|
|
|
722
1251
|
}
|
|
723
1252
|
);
|
|
724
1253
|
}
|
|
725
|
-
var DataTable = (0,
|
|
1254
|
+
var DataTable = (0, import_react8.forwardRef)(DataTableInner);
|
|
726
1255
|
|
|
727
1256
|
// src/composites/WorkspaceLayout.tsx
|
|
728
|
-
var
|
|
729
|
-
var
|
|
1257
|
+
var import_antd46 = require("antd");
|
|
1258
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
730
1259
|
var LIGHT_WORKSPACE_BACKGROUND = "#f6f9fe";
|
|
731
1260
|
function WorkspaceLayout({
|
|
732
1261
|
header,
|
|
@@ -744,7 +1273,7 @@ function WorkspaceLayout({
|
|
|
744
1273
|
contentClassName,
|
|
745
1274
|
height
|
|
746
1275
|
}) {
|
|
747
|
-
const { token } =
|
|
1276
|
+
const { token } = import_antd46.theme.useToken();
|
|
748
1277
|
const rootClassName = ["adminsmart-workspace", className].filter(Boolean).join(" ");
|
|
749
1278
|
const contentClasses = ["adminsmart-workspace__content", contentClassName].filter(Boolean).join(" ");
|
|
750
1279
|
const siderClasses = ["adminsmart-workspace__sider", siderProps?.className].filter(Boolean).join(" ");
|
|
@@ -758,10 +1287,10 @@ function WorkspaceLayout({
|
|
|
758
1287
|
"--adminsmart-workspace-bg": themeMode === "dark" ? token.colorBgLayout : LIGHT_WORKSPACE_BACKGROUND
|
|
759
1288
|
// 夜间不复用日间固定底色。
|
|
760
1289
|
};
|
|
761
|
-
return /* @__PURE__ */ (0,
|
|
762
|
-
/* @__PURE__ */ (0,
|
|
763
|
-
/* @__PURE__ */ (0,
|
|
764
|
-
/* @__PURE__ */ (0,
|
|
1290
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Layout, { className: rootClassName, style: workspaceStyle, "data-theme-mode": themeMode, children: [
|
|
1291
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("header", { className: "adminsmart-workspace__header", children: header }),
|
|
1292
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Layout, { className: "adminsmart-workspace__body", children: [
|
|
1293
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
765
1294
|
Layout.Sider,
|
|
766
1295
|
{
|
|
767
1296
|
theme: themeMode,
|
|
@@ -773,9 +1302,9 @@ function WorkspaceLayout({
|
|
|
773
1302
|
children: sidebar
|
|
774
1303
|
}
|
|
775
1304
|
),
|
|
776
|
-
/* @__PURE__ */ (0,
|
|
1305
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Layout, { className: "adminsmart-workspace__main", children: [
|
|
777
1306
|
tabs,
|
|
778
|
-
/* @__PURE__ */ (0,
|
|
1307
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Layout.Content, { className: contentClasses, "data-content-mode": contentMode, children }),
|
|
779
1308
|
footer
|
|
780
1309
|
] })
|
|
781
1310
|
] })
|
|
@@ -783,7 +1312,7 @@ function WorkspaceLayout({
|
|
|
783
1312
|
}
|
|
784
1313
|
|
|
785
1314
|
// src/composites/CrudScaffold.tsx
|
|
786
|
-
var
|
|
1315
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
787
1316
|
function CrudScaffold({
|
|
788
1317
|
label,
|
|
789
1318
|
description,
|
|
@@ -795,16 +1324,16 @@ function CrudScaffold({
|
|
|
795
1324
|
...props
|
|
796
1325
|
}) {
|
|
797
1326
|
const classes = ["adminsmart-crud", className].filter(Boolean).join(" ");
|
|
798
|
-
return /* @__PURE__ */ (0,
|
|
799
|
-
/* @__PURE__ */ (0,
|
|
800
|
-
status ? /* @__PURE__ */ (0,
|
|
801
|
-
/* @__PURE__ */ (0,
|
|
1327
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("main", { ...props, className: classes, "aria-label": label, "aria-description": description, children: [
|
|
1328
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "adminsmart-crud__filters", children: filters }),
|
|
1329
|
+
status ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "adminsmart-crud__status", children: status }) : null,
|
|
1330
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "adminsmart-crud__results", children: results }),
|
|
802
1331
|
drawer
|
|
803
1332
|
] });
|
|
804
1333
|
}
|
|
805
1334
|
|
|
806
1335
|
// src/composites/EllipsisText.tsx
|
|
807
|
-
var
|
|
1336
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
808
1337
|
function EllipsisText({
|
|
809
1338
|
children,
|
|
810
1339
|
maxWidth = 240,
|
|
@@ -816,7 +1345,7 @@ function EllipsisText({
|
|
|
816
1345
|
const classes = ["adminsmart-ellipsis-text", className].filter(Boolean).join(" ");
|
|
817
1346
|
const widthValue = typeof maxWidth === "number" ? `${maxWidth}px` : maxWidth;
|
|
818
1347
|
const textStyle = { "--adminsmart-ellipsis-width": widthValue, ...style };
|
|
819
|
-
return /* @__PURE__ */ (0,
|
|
1348
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
820
1349
|
Typography.Text,
|
|
821
1350
|
{
|
|
822
1351
|
...props,
|
|
@@ -829,14 +1358,14 @@ function EllipsisText({
|
|
|
829
1358
|
}
|
|
830
1359
|
|
|
831
1360
|
// src/composites/RowActions.tsx
|
|
832
|
-
var
|
|
833
|
-
var
|
|
834
|
-
var
|
|
1361
|
+
var import_icons4 = require("@ant-design/icons");
|
|
1362
|
+
var import_react9 = require("react");
|
|
1363
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
835
1364
|
function collectButtons(children) {
|
|
836
1365
|
const actions = [];
|
|
837
|
-
|
|
838
|
-
if (!(0,
|
|
839
|
-
if (child.type ===
|
|
1366
|
+
import_react9.Children.forEach(children, (child) => {
|
|
1367
|
+
if (!(0, import_react9.isValidElement)(child)) return;
|
|
1368
|
+
if (child.type === import_react9.Fragment) actions.push(...collectButtons(child.props.children));
|
|
840
1369
|
else {
|
|
841
1370
|
if (child.type !== Button && child.type !== "button") throw new TypeError("RowActions \u53EA\u63A5\u53D7\u5DF2\u6309\u6743\u9650\u7B5B\u9009\u7684 Button \u6216 Fragment");
|
|
842
1371
|
if (!child.props.hidden) actions.push(child);
|
|
@@ -862,9 +1391,9 @@ function RowActions({ children, maxVisible = 2, moreLabel = "\u66F4\u591A\u64CD\
|
|
|
862
1391
|
// 菜单仍按官方语义标识需要确认的动作。
|
|
863
1392
|
}));
|
|
864
1393
|
const classes = ["adminsmart-row-action-group", className].filter(Boolean).join(" ");
|
|
865
|
-
return /* @__PURE__ */ (0,
|
|
1394
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(Space, { ...props, className: classes, size, wrap, children: [
|
|
866
1395
|
direct,
|
|
867
|
-
overflow.length > 0 && /* @__PURE__ */ (0,
|
|
1396
|
+
overflow.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
868
1397
|
Dropdown,
|
|
869
1398
|
{
|
|
870
1399
|
trigger: ["click"],
|
|
@@ -876,12 +1405,12 @@ function RowActions({ children, maxVisible = 2, moreLabel = "\u66F4\u591A\u64CD\
|
|
|
876
1405
|
action.props.onClick?.(domEvent);
|
|
877
1406
|
}
|
|
878
1407
|
},
|
|
879
|
-
children: /* @__PURE__ */ (0,
|
|
1408
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Tooltip, { title: moreLabel, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
880
1409
|
Button,
|
|
881
1410
|
{
|
|
882
1411
|
type: "text",
|
|
883
1412
|
size: "small",
|
|
884
|
-
icon: /* @__PURE__ */ (0,
|
|
1413
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_icons4.EllipsisOutlined, {}),
|
|
885
1414
|
"aria-label": moreLabel,
|
|
886
1415
|
"aria-haspopup": "menu",
|
|
887
1416
|
"data-adminsmart-row-more": "true",
|
|
@@ -895,7 +1424,7 @@ function RowActions({ children, maxVisible = 2, moreLabel = "\u66F4\u591A\u64CD\
|
|
|
895
1424
|
|
|
896
1425
|
// src/schema/SchemaForm.tsx
|
|
897
1426
|
var import_dayjs = __toESM(require("dayjs"), 1);
|
|
898
|
-
var
|
|
1427
|
+
var import_react10 = require("react");
|
|
899
1428
|
|
|
900
1429
|
// src/schema/model.ts
|
|
901
1430
|
var FIELD_TYPES = /* @__PURE__ */ new Set([
|
|
@@ -1078,7 +1607,7 @@ function schemaInitialValues(schema) {
|
|
|
1078
1607
|
}
|
|
1079
1608
|
|
|
1080
1609
|
// src/schema/SchemaForm.tsx
|
|
1081
|
-
var
|
|
1610
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1082
1611
|
function fieldRules(field) {
|
|
1083
1612
|
const rules = [];
|
|
1084
1613
|
if (field.required) {
|
|
@@ -1123,32 +1652,32 @@ function dateItemProps(field) {
|
|
|
1123
1652
|
function renderControl(field) {
|
|
1124
1653
|
switch (field.type) {
|
|
1125
1654
|
case "input":
|
|
1126
|
-
return /* @__PURE__ */ (0,
|
|
1655
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Input, { placeholder: field.placeholder });
|
|
1127
1656
|
case "password":
|
|
1128
|
-
return /* @__PURE__ */ (0,
|
|
1657
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Input.Password, { placeholder: field.placeholder });
|
|
1129
1658
|
case "textarea":
|
|
1130
|
-
return /* @__PURE__ */ (0,
|
|
1659
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Input.TextArea, { placeholder: field.placeholder });
|
|
1131
1660
|
case "number":
|
|
1132
|
-
return /* @__PURE__ */ (0,
|
|
1661
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(InputNumber, { placeholder: field.placeholder, min: field.validation?.min, max: field.validation?.max, style: { width: "100%" } });
|
|
1133
1662
|
case "select":
|
|
1134
|
-
return /* @__PURE__ */ (0,
|
|
1663
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Select, { placeholder: field.placeholder, options: field.options });
|
|
1135
1664
|
case "radio":
|
|
1136
|
-
return /* @__PURE__ */ (0,
|
|
1665
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Radio.Group, { options: field.options });
|
|
1137
1666
|
case "checkbox":
|
|
1138
|
-
return /* @__PURE__ */ (0,
|
|
1667
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Checkbox, {});
|
|
1139
1668
|
case "switch":
|
|
1140
|
-
return /* @__PURE__ */ (0,
|
|
1669
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Switch, {});
|
|
1141
1670
|
case "date":
|
|
1142
|
-
return /* @__PURE__ */ (0,
|
|
1671
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DatePicker, { placeholder: field.placeholder, style: { width: "100%" } });
|
|
1143
1672
|
case "dateRange":
|
|
1144
|
-
return /* @__PURE__ */ (0,
|
|
1673
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DatePicker.RangePicker, { placeholder: field.placeholder ? [field.placeholder, field.placeholder] : void 0, style: { width: "100%" } });
|
|
1145
1674
|
}
|
|
1146
1675
|
}
|
|
1147
|
-
var SchemaForm = (0,
|
|
1676
|
+
var SchemaForm = (0, import_react10.forwardRef)(function SchemaForm2({ schema, onSubmit, onChange, onFinish, onValuesChange, initialValues, layout = "vertical", ...formProps }, ref) {
|
|
1148
1677
|
const result = validateSchemaForm(schema);
|
|
1149
1678
|
if (!result.valid) throw new Error(`SchemaForm \u914D\u7F6E\u65E0\u6548\uFF1A${result.errors.map((issue) => `${issue.path} ${issue.message}`).join("\uFF1B")}`);
|
|
1150
1679
|
const defaults = schemaInitialValues(schema);
|
|
1151
|
-
return /* @__PURE__ */ (0,
|
|
1680
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
1152
1681
|
Form,
|
|
1153
1682
|
{
|
|
1154
1683
|
...formProps,
|
|
@@ -1166,7 +1695,7 @@ var SchemaForm = (0, import_react8.forwardRef)(function SchemaForm2({ schema, on
|
|
|
1166
1695
|
children: [
|
|
1167
1696
|
schema.fields.map((field) => {
|
|
1168
1697
|
const mapped = mapSchemaField(field);
|
|
1169
|
-
return /* @__PURE__ */ (0,
|
|
1698
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1170
1699
|
Form.Item,
|
|
1171
1700
|
{
|
|
1172
1701
|
name: mapped.name,
|
|
@@ -1179,7 +1708,7 @@ var SchemaForm = (0, import_react8.forwardRef)(function SchemaForm2({ schema, on
|
|
|
1179
1708
|
mapped.name
|
|
1180
1709
|
);
|
|
1181
1710
|
}),
|
|
1182
|
-
/* @__PURE__ */ (0,
|
|
1711
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Form.Item, { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Button, { type: "primary", htmlType: "submit", children: schema.submitText ?? "\u63D0\u4EA4" }) })
|
|
1183
1712
|
]
|
|
1184
1713
|
}
|
|
1185
1714
|
);
|
|
@@ -1245,6 +1774,7 @@ var SchemaForm = (0, import_react8.forwardRef)(function SchemaForm2({ schema, on
|
|
|
1245
1774
|
SearchPanel,
|
|
1246
1775
|
Segmented,
|
|
1247
1776
|
Select,
|
|
1777
|
+
SessionReplay,
|
|
1248
1778
|
Skeleton,
|
|
1249
1779
|
Slider,
|
|
1250
1780
|
Space,
|