@qq1948037137/adminsmart-ui 0.1.25 → 0.1.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -13,8 +13,12 @@ type ThemeMode = 'light' | 'dark';
13
13
  interface ThemeModeButtonProps extends ButtonProps {
14
14
  /** 宿主当前生效的主题;按钮本身不读取或保存浏览器偏好。 */
15
15
  mode: ThemeMode;
16
- /** 用户点击后请求的下一主题;宿主负责更新受控状态与持久化。 */
16
+ /** 请求下一主题;宿主负责更新受控状态与持久化,异步回调应在主题提交后完成。 */
17
17
  onModeChange?: (mode: ThemeMode) => void;
18
+ /** 默认使用原生快照圆形过渡;none 立即切换,不影响宿主的主题算法。 */
19
+ transition?: 'reveal' | 'none';
20
+ /** 圆形过渡毫秒数;默认 500,非正数直接切换,非有限值沿用默认值。 */
21
+ transitionDuration?: number;
18
22
  /** 原生 Tooltip 属性,可覆盖默认提示、触发方式和浮层配置。 */
19
23
  tooltipProps?: Omit<TooltipProps, 'children'>;
20
24
  }
@@ -23,6 +27,8 @@ interface ThemeModeButtonProps extends ButtonProps {
23
27
  *
24
28
  * @param props.mode 当前外观,用于选择下一主题、图标和按下状态。
25
29
  * @param props.onModeChange 点击未被原生 onClick 取消时通知宿主切换主题。
30
+ * @param props.transition 默认 reveal;none 及减少动态效果偏好均立即通知宿主。
31
+ * @param props.transitionDuration 圆形快照动画时长,非正数关闭动画。
26
32
  * @param props.tooltipProps 可覆盖默认 Tooltip 的完整原生浮层属性。
27
33
  * @param props.onClick 原生点击回调,优先执行;preventDefault 可取消主题请求。
28
34
  * @param props 其余 Ant Button 属性原样透传,显式属性覆盖图标、大小和 aria 默认值。
@@ -80,6 +86,7 @@ declare const Timeline: typeof Timeline$1;
80
86
  declare const Card: typeof Card$1;
81
87
  declare const Descriptions: typeof Descriptions$1;
82
88
  declare const List: typeof List$1;
89
+ /** 默认显示完整记录总数,原生 showTotal 回调或显式 undefined 可以覆盖;所有页码与事件仍由 Ant 处理。 */
83
90
  declare const Pagination: typeof Pagination$1;
84
91
  declare const Tree: typeof Tree$1;
85
92
 
package/dist/index.d.ts CHANGED
@@ -13,8 +13,12 @@ type ThemeMode = 'light' | 'dark';
13
13
  interface ThemeModeButtonProps extends ButtonProps {
14
14
  /** 宿主当前生效的主题;按钮本身不读取或保存浏览器偏好。 */
15
15
  mode: ThemeMode;
16
- /** 用户点击后请求的下一主题;宿主负责更新受控状态与持久化。 */
16
+ /** 请求下一主题;宿主负责更新受控状态与持久化,异步回调应在主题提交后完成。 */
17
17
  onModeChange?: (mode: ThemeMode) => void;
18
+ /** 默认使用原生快照圆形过渡;none 立即切换,不影响宿主的主题算法。 */
19
+ transition?: 'reveal' | 'none';
20
+ /** 圆形过渡毫秒数;默认 500,非正数直接切换,非有限值沿用默认值。 */
21
+ transitionDuration?: number;
18
22
  /** 原生 Tooltip 属性,可覆盖默认提示、触发方式和浮层配置。 */
19
23
  tooltipProps?: Omit<TooltipProps, 'children'>;
20
24
  }
@@ -23,6 +27,8 @@ interface ThemeModeButtonProps extends ButtonProps {
23
27
  *
24
28
  * @param props.mode 当前外观,用于选择下一主题、图标和按下状态。
25
29
  * @param props.onModeChange 点击未被原生 onClick 取消时通知宿主切换主题。
30
+ * @param props.transition 默认 reveal;none 及减少动态效果偏好均立即通知宿主。
31
+ * @param props.transitionDuration 圆形快照动画时长,非正数关闭动画。
26
32
  * @param props.tooltipProps 可覆盖默认 Tooltip 的完整原生浮层属性。
27
33
  * @param props.onClick 原生点击回调,优先执行;preventDefault 可取消主题请求。
28
34
  * @param props 其余 Ant Button 属性原样透传,显式属性覆盖图标、大小和 aria 默认值。
@@ -80,6 +86,7 @@ declare const Timeline: typeof Timeline$1;
80
86
  declare const Card: typeof Card$1;
81
87
  declare const Descriptions: typeof Descriptions$1;
82
88
  declare const List: typeof List$1;
89
+ /** 默认显示完整记录总数,原生 showTotal 回调或显式 undefined 可以覆盖;所有页码与事件仍由 Ant 处理。 */
83
90
  declare const Pagination: typeof Pagination$1;
84
91
  declare const Tree: typeof Tree$1;
85
92
 
package/dist/index.js CHANGED
@@ -36,7 +36,8 @@ var Button = Object.assign(wrapAntComponent(AntButton, "Button"), {
36
36
 
37
37
  // src/components/ThemeModeButton.tsx
38
38
  import { MoonOutlined, SunOutlined } from "@ant-design/icons";
39
- import { forwardRef as forwardRef2 } from "react";
39
+ import { forwardRef as forwardRef2, useEffect, useRef, useState } from "react";
40
+ import { flushSync } from "react-dom";
40
41
 
41
42
  // src/components/overlay.ts
42
43
  import { Popover as AntPopover, Tooltip as AntTooltip } from "antd";
@@ -47,14 +48,136 @@ var Tooltip = Object.assign(wrapAntComponent(AntTooltip, "Tooltip"), {
47
48
 
48
49
  // src/components/ThemeModeButton.tsx
49
50
  import { jsx } from "react/jsx-runtime";
51
+ var documentTransitions = /* @__PURE__ */ new WeakMap();
52
+ var transitionAttribute = "data-adminsmart-theme-transition";
53
+ var transitionStyles = `
54
+ /* \u53EA\u6539\u53D8\u672C\u7EC4\u4EF6\u6301\u6709\u7684\u539F\u751F\u9875\u9762\u5FEB\u7167\uFF0C\u4E0D\u7ED9\u4E1A\u52A1\u63A7\u4EF6\u65BD\u52A0\u5168\u5C40\u52A8\u753B\u3002 */
55
+ html[${transitionAttribute}]::view-transition-old(root),
56
+ html[${transitionAttribute}]::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
57
+ html[${transitionAttribute}='dark']::view-transition-old(root),
58
+ html[${transitionAttribute}='light']::view-transition-new(root) { z-index: 1; }
59
+ html[${transitionAttribute}='dark']::view-transition-new(root),
60
+ html[${transitionAttribute}='light']::view-transition-old(root) { z-index: 2; }
61
+ `;
62
+ function reportThemeError(view, error) {
63
+ if (typeof view.reportError === "function") view.reportError(error);
64
+ else view.setTimeout(() => {
65
+ throw error;
66
+ }, 0);
67
+ }
68
+ function waitForThemeCommit(view) {
69
+ return new Promise((resolve) => {
70
+ let frame;
71
+ let timer;
72
+ const finish = () => {
73
+ if (frame !== void 0) view.cancelAnimationFrame?.(frame);
74
+ if (timer !== void 0) view.clearTimeout(timer);
75
+ resolve();
76
+ };
77
+ timer = view.setTimeout(finish, 100);
78
+ frame = view.requestAnimationFrame(finish);
79
+ });
80
+ }
50
81
  var ThemeModeButton = forwardRef2(
51
- function ThemeModeButton2({ mode, onModeChange, tooltipProps, onClick, ...props }, ref) {
82
+ function ThemeModeButton2({ mode, onModeChange, transition = "reveal", transitionDuration = 500, tooltipProps, onClick, ...props }, ref) {
52
83
  const nextMode = mode === "dark" ? "light" : "dark";
53
84
  const actionLabel = nextMode === "dark" ? "\u5207\u6362\u5230\u591C\u95F4\u4E3B\u9898" : "\u5207\u6362\u5230\u65E5\u95F4\u4E3B\u9898";
54
85
  const nextModeIcon = nextMode === "dark" ? /* @__PURE__ */ jsx(MoonOutlined, { "aria-hidden": true }) : /* @__PURE__ */ jsx(SunOutlined, { "aria-hidden": true });
86
+ const activeCleanup = useRef(null);
87
+ const [transitioning, setTransitioning] = useState(false);
88
+ useEffect(() => () => activeCleanup.current?.(), []);
55
89
  const handleClick = (event) => {
56
90
  onClick?.(event);
57
- if (!event.defaultPrevented) onModeChange?.(nextMode);
91
+ if (event.defaultPrevented || !onModeChange || activeCleanup.current) return;
92
+ const ownerDocument = event.currentTarget.ownerDocument;
93
+ const view = ownerDocument.defaultView;
94
+ const root = ownerDocument.documentElement;
95
+ const duration = Number.isFinite(transitionDuration) ? transitionDuration : 500;
96
+ if (documentTransitions.has(ownerDocument)) return;
97
+ if (!view || transition === "none" || duration <= 0 || view.matchMedia?.("(prefers-reduced-motion: reduce)").matches || typeof ownerDocument.startViewTransition !== "function" || typeof root.animate !== "function") {
98
+ const result = onModeChange(nextMode);
99
+ if (view) void Promise.resolve(result).catch((error) => reportThemeError(view, error));
100
+ return;
101
+ }
102
+ const bounds = event.currentTarget.getBoundingClientRect();
103
+ const x = event.detail > 0 ? event.clientX : bounds.left + bounds.width / 2;
104
+ const y = event.detail > 0 ? event.clientY : bounds.top + bounds.height / 2;
105
+ const radius = Math.hypot(Math.max(x, view.innerWidth - x), Math.max(y, view.innerHeight - y));
106
+ const previousAttribute = root.getAttribute(transitionAttribute);
107
+ const style = ownerDocument.createElement("style");
108
+ let nativeTransition;
109
+ let animation;
110
+ let cancelled = false;
111
+ let applied = false;
112
+ const cleanup = () => {
113
+ if (cancelled) return;
114
+ cancelled = true;
115
+ animation?.cancel();
116
+ nativeTransition?.skipTransition();
117
+ style.remove();
118
+ if (documentTransitions.get(ownerDocument) === cleanup) {
119
+ documentTransitions.delete(ownerDocument);
120
+ if (previousAttribute === null) root.removeAttribute(transitionAttribute);
121
+ else root.setAttribute(transitionAttribute, previousAttribute);
122
+ }
123
+ if (activeCleanup.current === cleanup) {
124
+ activeCleanup.current = null;
125
+ setTransitioning(false);
126
+ }
127
+ };
128
+ activeCleanup.current = cleanup;
129
+ documentTransitions.set(ownerDocument, cleanup);
130
+ setTransitioning(true);
131
+ style.textContent = transitionStyles;
132
+ style.dataset.adminsmartThemeTransition = "";
133
+ ownerDocument.head.appendChild(style);
134
+ root.setAttribute(transitionAttribute, nextMode);
135
+ try {
136
+ nativeTransition = ownerDocument.startViewTransition(async () => {
137
+ if (cancelled) return;
138
+ applied = true;
139
+ let result = void 0;
140
+ try {
141
+ flushSync(() => {
142
+ result = onModeChange(nextMode);
143
+ });
144
+ await result;
145
+ if (!cancelled && typeof view.requestAnimationFrame === "function") {
146
+ await waitForThemeCommit(view);
147
+ }
148
+ } catch (error) {
149
+ reportThemeError(view, error);
150
+ throw error;
151
+ }
152
+ });
153
+ void nativeTransition.updateCallbackDone.catch(() => void 0);
154
+ void nativeTransition.ready.then(() => {
155
+ if (cancelled) return;
156
+ const clipPath = [`circle(0px at ${x}px ${y}px)`, `circle(${radius}px at ${x}px ${y}px)`];
157
+ animation = root.animate({ clipPath: nextMode === "dark" ? clipPath : clipPath.reverse() }, {
158
+ duration,
159
+ // 宿主可调整节奏,不替换主题算法。
160
+ easing: "ease-in",
161
+ // 与 Ant 官网圆形过渡保持同类节奏。
162
+ pseudoElement: nextMode === "dark" ? "::view-transition-new(root)" : "::view-transition-old(root)"
163
+ // 只处理深色快照。
164
+ });
165
+ return animation.finished;
166
+ }).catch(() => {
167
+ if (!cancelled && !applied) {
168
+ applied = true;
169
+ const result = onModeChange(nextMode);
170
+ void Promise.resolve(result).catch((error) => reportThemeError(view, error));
171
+ }
172
+ }).finally(cleanup).catch((error) => reportThemeError(view, error));
173
+ void nativeTransition.finished.catch(() => void 0).finally(cleanup);
174
+ } catch {
175
+ cleanup();
176
+ if (!applied) {
177
+ const result = onModeChange(nextMode);
178
+ void Promise.resolve(result).catch((error) => reportThemeError(view, error));
179
+ }
180
+ }
58
181
  };
59
182
  return /* @__PURE__ */ jsx(Tooltip, { title: actionLabel, ...tooltipProps, children: /* @__PURE__ */ jsx(
60
183
  Button,
@@ -64,8 +187,11 @@ var ThemeModeButton = forwardRef2(
64
187
  icon: nextModeIcon,
65
188
  "aria-label": actionLabel,
66
189
  "aria-pressed": mode === "dark",
190
+ "aria-busy": transitioning || void 0,
67
191
  ...props,
192
+ style: { minWidth: 44, minHeight: 44, ...props.style },
68
193
  ref,
194
+ disabled: transitioning ? true : props.disabled,
69
195
  onClick: handleClick
70
196
  }
71
197
  ) });
@@ -117,6 +243,11 @@ var Select = Object.assign(wrapAntComponent(AntSelect, "Select"), {
117
243
  import { Table as AntTable } from "antd";
118
244
  import { createElement as createElement2 } from "react";
119
245
 
246
+ // src/internal/paginationTotal.ts
247
+ function paginationTotal(total) {
248
+ return `\u5171 ${total} \u6761`;
249
+ }
250
+
120
251
  // src/components/feedback.ts
121
252
  import {
122
253
  Alert as AntAlert,
@@ -161,7 +292,9 @@ function normalizeTableProps(props) {
161
292
  const locale = props.locale ?? {};
162
293
  const content = locale.emptyText;
163
294
  const emptyText = content === void 0 ? createElement2(TableEmpty) : typeof content === "string" || typeof content === "number" ? createElement2(TableEmpty, { description: content }) : content;
164
- return { ...props, locale: { ...locale, emptyText } };
295
+ const pagination = props.pagination;
296
+ const tablePagination = pagination === false ? false : { showTotal: paginationTotal, ...pagination };
297
+ return { ...props, locale: { ...locale, emptyText }, pagination: tablePagination };
165
298
  }
166
299
  var Summary = Object.assign(wrapAntComponent(AntTable.Summary, "Table.Summary"), {
167
300
  Row: wrapAntComponent(AntTable.Summary.Row, "Table.Summary.Row"),
@@ -240,10 +373,14 @@ var Descriptions = Object.assign(wrapAntComponent(AntDescriptions, "Descriptions
240
373
  var ListItem = Object.assign(wrapAntComponent(AntList.Item, "List.Item"), {
241
374
  Meta: wrapAntComponent(AntList.Item.Meta, "List.Item.Meta")
242
375
  });
243
- var List = Object.assign(wrapAntComponent(AntList, "List"), {
376
+ function normalizeListProps(props) {
377
+ const pagination = props.pagination;
378
+ return pagination && typeof pagination === "object" ? { ...props, pagination: { showTotal: paginationTotal, ...pagination } } : props;
379
+ }
380
+ var List = Object.assign(wrapAntComponent(AntList, "List", {}, normalizeListProps), {
244
381
  Item: ListItem
245
382
  });
246
- var Pagination = wrapAntComponent(AntPagination, "Pagination");
383
+ var Pagination = wrapAntComponent(AntPagination, "Pagination", { showTotal: paginationTotal });
247
384
  var Tree = Object.assign(wrapAntComponent(AntTree, "Tree"), {
248
385
  DirectoryTree: wrapAntComponent(AntTree.DirectoryTree, "Tree.DirectoryTree"),
249
386
  TreeNode: wrapAntComponent(AntTree.TreeNode, "Tree.TreeNode")
@@ -468,7 +605,7 @@ var BusinessDrawer = forwardRef3(function BusinessDrawer2({ sizeVariant = "stand
468
605
  });
469
606
 
470
607
  // src/composites/SessionReplay.tsx
471
- import { forwardRef as forwardRef4, useCallback as useCallback2, useEffect as useEffect2, useImperativeHandle, useRef as useRef2, useState as useState2 } from "react";
608
+ import { forwardRef as forwardRef4, useCallback as useCallback2, useEffect as useEffect3, useImperativeHandle, useRef as useRef3, useState as useState3 } from "react";
472
609
  import { FullscreenExitOutlined, FullscreenOutlined, PauseOutlined, PlayCircleOutlined, RedoOutlined, StepBackwardOutlined, StepForwardOutlined } from "@ant-design/icons";
473
610
  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
611
 
@@ -619,7 +756,7 @@ function replayClock(timeMs) {
619
756
  }
620
757
 
621
758
  // src/composites/useSessionReplay.ts
622
- import { useCallback, useEffect, useRef, useState } from "react";
759
+ import { useCallback, useEffect as useEffect2, useRef as useRef2, useState as useState2 } from "react";
623
760
 
624
761
  // src/composites/sessionReplayEngine.ts
625
762
  async function loadReplayEngine() {
@@ -643,20 +780,20 @@ function initialState(status) {
643
780
  };
644
781
  }
645
782
  function useSessionReplay(options) {
646
- const [state, setState] = useState(() => initialState("idle"));
647
- const stateRef = useRef(state);
648
- const engineRef = useRef(null);
649
- const runtimeFailureRef = useRef(null);
650
- const rangeRef = useRef(replayRange(0));
651
- const replayEventsRef = useRef([]);
652
- const callbackRef = useRef(options);
783
+ const [state, setState] = useState2(() => initialState("idle"));
784
+ const stateRef = useRef2(state);
785
+ const engineRef = useRef2(null);
786
+ const runtimeFailureRef = useRef2(null);
787
+ const rangeRef = useRef2(replayRange(0));
788
+ const replayEventsRef = useRef2([]);
789
+ const callbackRef = useRef2(options);
653
790
  callbackRef.current = options;
654
791
  const publish = useCallback((next) => {
655
792
  stateRef.current = next;
656
793
  setState(next);
657
794
  callbackRef.current.onStateChange?.({ ...next });
658
795
  }, []);
659
- useEffect(() => {
796
+ useEffect2(() => {
660
797
  const { active, loading, error, events, stageRef, rootRef, startOffsetMs, endOffsetMs, autoPlay } = options;
661
798
  engineRef.current = null;
662
799
  runtimeFailureRef.current = null;
@@ -927,16 +1064,16 @@ import { jsx as jsx4, jsxs } from "react/jsx-runtime";
927
1064
  var playbackRates = [0.5, 1, 1.5, 2];
928
1065
  var SessionReplay = forwardRef4(function SessionReplay2({ events, active = true, loading = false, error, startOffsetMs, endOffsetMs, autoPlay = false, markers = [], extra, onStateChange, onError, className, style }, ref) {
929
1066
  const { token } = theme.useToken();
930
- const containerRef = useRef2(null);
931
- const stageRef = useRef2(null);
932
- const rootRef = useRef2(null);
933
- const [problem, setProblem] = useState2(null);
934
- const [fullscreen, setFullscreen] = useState2(false);
1067
+ const containerRef = useRef3(null);
1068
+ const stageRef = useRef3(null);
1069
+ const rootRef = useRef3(null);
1070
+ const [problem, setProblem] = useState3(null);
1071
+ const [fullscreen, setFullscreen] = useState3(false);
935
1072
  const reportError = useCallback2((value) => {
936
1073
  setProblem(value);
937
1074
  onError?.(value);
938
1075
  }, [onError]);
939
- useEffect2(() => {
1076
+ useEffect3(() => {
940
1077
  setProblem(null);
941
1078
  }, [events, active, loading, error, startOffsetMs, endOffsetMs]);
942
1079
  const controls = useSessionReplay({ events, active, loading, error, startOffsetMs, endOffsetMs, autoPlay, stageRef, rootRef, onStateChange, onError: reportError });
@@ -964,7 +1101,7 @@ var SessionReplay = forwardRef4(function SessionReplay2({ events, active = true,
964
1101
  ...style
965
1102
  };
966
1103
  useImperativeHandle(ref, () => ({ play, pause, seek, restart, getState }), [play, pause, seek, restart, getState]);
967
- useEffect2(() => {
1104
+ useEffect3(() => {
968
1105
  if (!active) return;
969
1106
  const container = containerRef.current;
970
1107
  const sync = () => setFullscreen(document.fullscreenElement === container);
@@ -1067,9 +1204,9 @@ import {
1067
1204
  Children,
1068
1205
  forwardRef as forwardRef5,
1069
1206
  isValidElement,
1070
- useEffect as useEffect3,
1071
- useRef as useRef3,
1072
- useState as useState3
1207
+ useEffect as useEffect4,
1208
+ useRef as useRef4,
1209
+ useState as useState4
1073
1210
  } from "react";
1074
1211
 
1075
1212
  // src/composites/searchPanelModel.ts
@@ -1083,15 +1220,15 @@ function collapsedSearchFieldLimit(columns) {
1083
1220
  // src/composites/SearchPanel.tsx
1084
1221
  import { jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
1085
1222
  var SearchPanel = forwardRef5(function SearchPanel2({ fields, actions, tools, trailingTools, searchVisible = true, defaultExpanded = false, role = "search", style, ...props }, ref) {
1086
- const rootRef = useRef3(null);
1087
- const [width, setWidth] = useState3(0);
1088
- const [expanded, setExpanded] = useState3(defaultExpanded);
1223
+ const rootRef = useRef4(null);
1224
+ const [width, setWidth] = useState4(0);
1225
+ const [expanded, setExpanded] = useState4(defaultExpanded);
1089
1226
  const items = Children.toArray(fields);
1090
1227
  const columns = searchColumnCount(width);
1091
1228
  const collapsedLimit = collapsedSearchFieldLimit(columns);
1092
1229
  const hasMore = items.length > collapsedLimit;
1093
1230
  const fieldWidth = Math.min(240, Math.max(0, width));
1094
- useEffect3(() => {
1231
+ useEffect4(() => {
1095
1232
  const element = rootRef.current;
1096
1233
  if (!element) return void 0;
1097
1234
  const update = () => {
@@ -1158,8 +1295,8 @@ var SearchPanel = forwardRef5(function SearchPanel2({ fields, actions, tools, tr
1158
1295
  import {
1159
1296
  forwardRef as forwardRef6,
1160
1297
  useLayoutEffect,
1161
- useRef as useRef4,
1162
- useState as useState4
1298
+ useRef as useRef5,
1299
+ useState as useState5
1163
1300
  } from "react";
1164
1301
  import { jsx as jsx6 } from "react/jsx-runtime";
1165
1302
  function tableBodyHeight(availableHeight, chromeHeight) {
@@ -1182,8 +1319,8 @@ function DataTableInner({
1182
1319
  scroll,
1183
1320
  ...tableProps
1184
1321
  }, ref) {
1185
- const containerRef = useRef4(null);
1186
- const [bodyHeight, setBodyHeight] = useState4(360);
1322
+ const containerRef = useRef5(null);
1323
+ const [bodyHeight, setBodyHeight] = useState5(360);
1187
1324
  const hasExplicitHeight = containerHeight != null || containerStyle?.height != null;
1188
1325
  useLayoutEffect(() => {
1189
1326
  const container = containerRef.current;