@qq1948037137/adminsmart-ui 0.1.26 → 0.1.28
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 +294 -49
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +43 -2
- package/dist/index.d.ts +43 -2
- package/dist/index.js +311 -67
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @qq1948037137/adminsmart-ui
|
|
2
2
|
|
|
3
|
-
AdminSmart 的 React/Ant Design 组件包。基础控件保留 Ant 的原生属性、ref 与静态 API;跨页面布局由 `SearchPanel`、`DataTable`、`BusinessDrawer` 和 `SchemaForm` 统一;`SessionReplay` 使用固定官方 rrweb 引擎提供只读时间回放。权限和业务数据请求仍由应用负责。
|
|
3
|
+
AdminSmart 的 React/Ant Design 组件包。基础控件保留 Ant 的原生属性、ref 与静态 API;跨页面布局由 `SearchPanel`、`TableControls`、`DataTable`、`BusinessDrawer` 和 `SchemaForm` 统一;`SessionReplay` 使用固定官方 rrweb 引擎提供只读时间回放。权限和业务数据请求仍由应用负责。
|
|
4
4
|
|
|
5
5
|
## npm 安装与宿主别名
|
|
6
6
|
|
|
@@ -51,6 +51,8 @@ function Example() {
|
|
|
51
51
|
|
|
52
52
|
`Pagination`、`Table`、`DataTable` 和显式启用分页的 `List` 默认显示 `共 N 条`,数量来自 Ant 的本地数据总数或业务传入的 `total`,不会把当前页行数当作完整数量。原生 `showTotal={(total, range) => ...}` 可自定义总数文案,显式 `showTotal={undefined}` 可隐藏;表格和列表仍可通过 `pagination={false}` 关闭分页。页码、每页条数、回调、ref 和原生公开类型继续保留,列表未配置分页时不会额外开启分页。
|
|
53
53
|
|
|
54
|
+
将 `TableControls` 放在 `SearchPanel.trailingTools`,将新增、导出等业务操作放在 `SearchPanel.tools`。右侧始终按搜索显隐、刷新、选择列排列。宿主控制搜索显隐、加载和可见列,并可声明不可切换的列。组件示例展示如何连接搜索状态和表格列。
|
|
55
|
+
|
|
54
56
|
主应用的本地 tarball 过渡与 npm Registry 升级都必须锁定精确版本、实际包名和完整性,不能仅改依赖字符串而跳过来源校验。本库通过 `adminsmartUiSource: { sha256, gitCommit }` 提供构建源码标记,消费者使用 Registry 的 `dist.integrity` 与 `dist.tarball` 核对字节。该标记是项目来源契约,不是官方 provenance。
|
|
55
57
|
|
|
56
58
|
`SessionReplay` 接收已授权、已解压的只读对象事件,默认暂停在可见窗口起点。它按需装载 `@rrweb/replay@2.0.1` 的官方 JS/CSS,相关 rrweb、types、utils、rrdom 和 snapshot 协议包也精确锁定为 `2.0.1`;发布验证会检查全新宿主的实际安装树,防止上游范围依赖漂移。组件等待真实容器尺寸和官方快照重建,负责有界跳转、结束重播、倍率、时间标记与全屏;隐藏或切换事件时销毁实例和监听。样式随既有 `@adminsmart/ui/styles/composites.css` 交付。业务宿主仍负责数据请求、权限、解压和录制脱敏;组件不会读取 API、凭据、会话或录制原页面。可操作的 5 秒合成录像见文档站 `SessionReplay 操作回放`,公开输入与引用类型由包类型声明提供。
|
package/dist/index.cjs
CHANGED
|
@@ -99,6 +99,7 @@ __export(src_exports, {
|
|
|
99
99
|
Steps: () => Steps,
|
|
100
100
|
Switch: () => Switch,
|
|
101
101
|
Table: () => Table,
|
|
102
|
+
TableControls: () => TableControls,
|
|
102
103
|
TableEmpty: () => TableEmpty,
|
|
103
104
|
Tabs: () => Tabs,
|
|
104
105
|
Tag: () => Tag,
|
|
@@ -161,6 +162,7 @@ var Button = Object.assign(wrapAntComponent(import_antd.Button, "Button"), {
|
|
|
161
162
|
// src/components/ThemeModeButton.tsx
|
|
162
163
|
var import_icons = require("@ant-design/icons");
|
|
163
164
|
var import_react2 = require("react");
|
|
165
|
+
var import_react_dom = require("react-dom");
|
|
164
166
|
|
|
165
167
|
// src/components/overlay.ts
|
|
166
168
|
var import_antd2 = require("antd");
|
|
@@ -171,14 +173,136 @@ var Tooltip = Object.assign(wrapAntComponent(import_antd2.Tooltip, "Tooltip"), {
|
|
|
171
173
|
|
|
172
174
|
// src/components/ThemeModeButton.tsx
|
|
173
175
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
176
|
+
var documentTransitions = /* @__PURE__ */ new WeakMap();
|
|
177
|
+
var transitionAttribute = "data-adminsmart-theme-transition";
|
|
178
|
+
var transitionStyles = `
|
|
179
|
+
/* \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 */
|
|
180
|
+
html[${transitionAttribute}]::view-transition-old(root),
|
|
181
|
+
html[${transitionAttribute}]::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
|
|
182
|
+
html[${transitionAttribute}='dark']::view-transition-old(root),
|
|
183
|
+
html[${transitionAttribute}='light']::view-transition-new(root) { z-index: 1; }
|
|
184
|
+
html[${transitionAttribute}='dark']::view-transition-new(root),
|
|
185
|
+
html[${transitionAttribute}='light']::view-transition-old(root) { z-index: 2; }
|
|
186
|
+
`;
|
|
187
|
+
function reportThemeError(view, error) {
|
|
188
|
+
if (typeof view.reportError === "function") view.reportError(error);
|
|
189
|
+
else view.setTimeout(() => {
|
|
190
|
+
throw error;
|
|
191
|
+
}, 0);
|
|
192
|
+
}
|
|
193
|
+
function waitForThemeCommit(view) {
|
|
194
|
+
return new Promise((resolve) => {
|
|
195
|
+
let frame;
|
|
196
|
+
let timer;
|
|
197
|
+
const finish = () => {
|
|
198
|
+
if (frame !== void 0) view.cancelAnimationFrame?.(frame);
|
|
199
|
+
if (timer !== void 0) view.clearTimeout(timer);
|
|
200
|
+
resolve();
|
|
201
|
+
};
|
|
202
|
+
timer = view.setTimeout(finish, 100);
|
|
203
|
+
frame = view.requestAnimationFrame(finish);
|
|
204
|
+
});
|
|
205
|
+
}
|
|
174
206
|
var ThemeModeButton = (0, import_react2.forwardRef)(
|
|
175
|
-
function ThemeModeButton2({ mode, onModeChange, tooltipProps, onClick, ...props }, ref) {
|
|
207
|
+
function ThemeModeButton2({ mode, onModeChange, transition = "reveal", transitionDuration = 500, tooltipProps, onClick, ...props }, ref) {
|
|
176
208
|
const nextMode = mode === "dark" ? "light" : "dark";
|
|
177
209
|
const actionLabel = nextMode === "dark" ? "\u5207\u6362\u5230\u591C\u95F4\u4E3B\u9898" : "\u5207\u6362\u5230\u65E5\u95F4\u4E3B\u9898";
|
|
178
210
|
const nextModeIcon = nextMode === "dark" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.MoonOutlined, { "aria-hidden": true }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.SunOutlined, { "aria-hidden": true });
|
|
211
|
+
const activeCleanup = (0, import_react2.useRef)(null);
|
|
212
|
+
const [transitioning, setTransitioning] = (0, import_react2.useState)(false);
|
|
213
|
+
(0, import_react2.useEffect)(() => () => activeCleanup.current?.(), []);
|
|
179
214
|
const handleClick = (event) => {
|
|
180
215
|
onClick?.(event);
|
|
181
|
-
if (
|
|
216
|
+
if (event.defaultPrevented || !onModeChange || activeCleanup.current) return;
|
|
217
|
+
const ownerDocument = event.currentTarget.ownerDocument;
|
|
218
|
+
const view = ownerDocument.defaultView;
|
|
219
|
+
const root = ownerDocument.documentElement;
|
|
220
|
+
const duration = Number.isFinite(transitionDuration) ? transitionDuration : 500;
|
|
221
|
+
if (documentTransitions.has(ownerDocument)) return;
|
|
222
|
+
if (!view || transition === "none" || duration <= 0 || view.matchMedia?.("(prefers-reduced-motion: reduce)").matches || typeof ownerDocument.startViewTransition !== "function" || typeof root.animate !== "function") {
|
|
223
|
+
const result = onModeChange(nextMode);
|
|
224
|
+
if (view) void Promise.resolve(result).catch((error) => reportThemeError(view, error));
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
const bounds = event.currentTarget.getBoundingClientRect();
|
|
228
|
+
const x = event.detail > 0 ? event.clientX : bounds.left + bounds.width / 2;
|
|
229
|
+
const y = event.detail > 0 ? event.clientY : bounds.top + bounds.height / 2;
|
|
230
|
+
const radius = Math.hypot(Math.max(x, view.innerWidth - x), Math.max(y, view.innerHeight - y));
|
|
231
|
+
const previousAttribute = root.getAttribute(transitionAttribute);
|
|
232
|
+
const style = ownerDocument.createElement("style");
|
|
233
|
+
let nativeTransition;
|
|
234
|
+
let animation;
|
|
235
|
+
let cancelled = false;
|
|
236
|
+
let applied = false;
|
|
237
|
+
const cleanup = () => {
|
|
238
|
+
if (cancelled) return;
|
|
239
|
+
cancelled = true;
|
|
240
|
+
animation?.cancel();
|
|
241
|
+
nativeTransition?.skipTransition();
|
|
242
|
+
style.remove();
|
|
243
|
+
if (documentTransitions.get(ownerDocument) === cleanup) {
|
|
244
|
+
documentTransitions.delete(ownerDocument);
|
|
245
|
+
if (previousAttribute === null) root.removeAttribute(transitionAttribute);
|
|
246
|
+
else root.setAttribute(transitionAttribute, previousAttribute);
|
|
247
|
+
}
|
|
248
|
+
if (activeCleanup.current === cleanup) {
|
|
249
|
+
activeCleanup.current = null;
|
|
250
|
+
setTransitioning(false);
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
activeCleanup.current = cleanup;
|
|
254
|
+
documentTransitions.set(ownerDocument, cleanup);
|
|
255
|
+
setTransitioning(true);
|
|
256
|
+
style.textContent = transitionStyles;
|
|
257
|
+
style.dataset.adminsmartThemeTransition = "";
|
|
258
|
+
ownerDocument.head.appendChild(style);
|
|
259
|
+
root.setAttribute(transitionAttribute, nextMode);
|
|
260
|
+
try {
|
|
261
|
+
nativeTransition = ownerDocument.startViewTransition(async () => {
|
|
262
|
+
if (cancelled) return;
|
|
263
|
+
applied = true;
|
|
264
|
+
let result = void 0;
|
|
265
|
+
try {
|
|
266
|
+
(0, import_react_dom.flushSync)(() => {
|
|
267
|
+
result = onModeChange(nextMode);
|
|
268
|
+
});
|
|
269
|
+
await result;
|
|
270
|
+
if (!cancelled && typeof view.requestAnimationFrame === "function") {
|
|
271
|
+
await waitForThemeCommit(view);
|
|
272
|
+
}
|
|
273
|
+
} catch (error) {
|
|
274
|
+
reportThemeError(view, error);
|
|
275
|
+
throw error;
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
void nativeTransition.updateCallbackDone.catch(() => void 0);
|
|
279
|
+
void nativeTransition.ready.then(() => {
|
|
280
|
+
if (cancelled) return;
|
|
281
|
+
const clipPath = [`circle(0px at ${x}px ${y}px)`, `circle(${radius}px at ${x}px ${y}px)`];
|
|
282
|
+
animation = root.animate({ clipPath: nextMode === "dark" ? clipPath : clipPath.reverse() }, {
|
|
283
|
+
duration,
|
|
284
|
+
// 宿主可调整节奏,不替换主题算法。
|
|
285
|
+
easing: "ease-in",
|
|
286
|
+
// 与 Ant 官网圆形过渡保持同类节奏。
|
|
287
|
+
pseudoElement: nextMode === "dark" ? "::view-transition-new(root)" : "::view-transition-old(root)"
|
|
288
|
+
// 只处理深色快照。
|
|
289
|
+
});
|
|
290
|
+
return animation.finished;
|
|
291
|
+
}).catch(() => {
|
|
292
|
+
if (!cancelled && !applied) {
|
|
293
|
+
applied = true;
|
|
294
|
+
const result = onModeChange(nextMode);
|
|
295
|
+
void Promise.resolve(result).catch((error) => reportThemeError(view, error));
|
|
296
|
+
}
|
|
297
|
+
}).finally(cleanup).catch((error) => reportThemeError(view, error));
|
|
298
|
+
void nativeTransition.finished.catch(() => void 0).finally(cleanup);
|
|
299
|
+
} catch {
|
|
300
|
+
cleanup();
|
|
301
|
+
if (!applied) {
|
|
302
|
+
const result = onModeChange(nextMode);
|
|
303
|
+
void Promise.resolve(result).catch((error) => reportThemeError(view, error));
|
|
304
|
+
}
|
|
305
|
+
}
|
|
182
306
|
};
|
|
183
307
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tooltip, { title: actionLabel, ...tooltipProps, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
184
308
|
Button,
|
|
@@ -188,8 +312,11 @@ var ThemeModeButton = (0, import_react2.forwardRef)(
|
|
|
188
312
|
icon: nextModeIcon,
|
|
189
313
|
"aria-label": actionLabel,
|
|
190
314
|
"aria-pressed": mode === "dark",
|
|
315
|
+
"aria-busy": transitioning || void 0,
|
|
191
316
|
...props,
|
|
317
|
+
style: { minWidth: 44, minHeight: 44, ...props.style },
|
|
192
318
|
ref,
|
|
319
|
+
disabled: transitioning ? true : props.disabled,
|
|
193
320
|
onClick: handleClick
|
|
194
321
|
}
|
|
195
322
|
) });
|
|
@@ -1249,9 +1376,126 @@ var SearchPanel = (0, import_react7.forwardRef)(function SearchPanel2({ fields,
|
|
|
1249
1376
|
] });
|
|
1250
1377
|
});
|
|
1251
1378
|
|
|
1252
|
-
// src/composites/
|
|
1379
|
+
// src/composites/TableControls.tsx
|
|
1380
|
+
var import_icons4 = require("@ant-design/icons");
|
|
1253
1381
|
var import_react8 = require("react");
|
|
1254
1382
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1383
|
+
function TableControls({
|
|
1384
|
+
searchVisible = true,
|
|
1385
|
+
onSearchVisibleChange,
|
|
1386
|
+
onRefresh,
|
|
1387
|
+
refreshing = false,
|
|
1388
|
+
columns = [],
|
|
1389
|
+
visibleColumns,
|
|
1390
|
+
onVisibleColumnsChange,
|
|
1391
|
+
className,
|
|
1392
|
+
style
|
|
1393
|
+
}) {
|
|
1394
|
+
const [open, setOpen] = (0, import_react8.useState)(false);
|
|
1395
|
+
const triggerRef = (0, import_react8.useRef)(null);
|
|
1396
|
+
const panelRef = (0, import_react8.useRef)(null);
|
|
1397
|
+
const panelId = (0, import_react8.useId)();
|
|
1398
|
+
const editable = columns.filter((column) => !column.disabled);
|
|
1399
|
+
const visible = new Set(visibleColumns ?? columns.map((column) => column.key));
|
|
1400
|
+
const checkedCount = editable.filter((column) => visible.has(column.key)).length;
|
|
1401
|
+
const canSetColumns = editable.length > 0 && Boolean(onVisibleColumnsChange);
|
|
1402
|
+
const searchLabel = searchVisible ? "\u9690\u85CF\u641C\u7D22" : "\u663E\u793A\u641C\u7D22";
|
|
1403
|
+
const setVisible = (keys, checked) => {
|
|
1404
|
+
const next = new Set(visible);
|
|
1405
|
+
for (const key of keys) {
|
|
1406
|
+
if (checked) next.add(key);
|
|
1407
|
+
else next.delete(key);
|
|
1408
|
+
}
|
|
1409
|
+
onVisibleColumnsChange?.(columns.filter((column) => next.has(column.key)).map((column) => column.key));
|
|
1410
|
+
};
|
|
1411
|
+
const closeOnEscape = (event) => {
|
|
1412
|
+
if (event.key !== "Escape") return;
|
|
1413
|
+
event.stopPropagation();
|
|
1414
|
+
setOpen(false);
|
|
1415
|
+
triggerRef.current?.focus();
|
|
1416
|
+
};
|
|
1417
|
+
const panelStyle = {
|
|
1418
|
+
display: "grid",
|
|
1419
|
+
gap: 8,
|
|
1420
|
+
minWidth: 120,
|
|
1421
|
+
maxWidth: "min(320px, calc(100vw - 32px))",
|
|
1422
|
+
maxHeight: "min(380px, 60vh)",
|
|
1423
|
+
overflow: "auto"
|
|
1424
|
+
};
|
|
1425
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className, style: { display: "inline-flex", alignItems: "center", flexShrink: 0, gap: 8, ...style }, children: [
|
|
1426
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Tooltip, { title: searchLabel, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1427
|
+
Button,
|
|
1428
|
+
{
|
|
1429
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_icons4.SearchOutlined, { "aria-hidden": "true" }),
|
|
1430
|
+
"aria-label": searchLabel,
|
|
1431
|
+
"aria-pressed": searchVisible,
|
|
1432
|
+
disabled: !onSearchVisibleChange,
|
|
1433
|
+
onClick: () => onSearchVisibleChange?.(!searchVisible)
|
|
1434
|
+
}
|
|
1435
|
+
) }),
|
|
1436
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Tooltip, { title: "\u5237\u65B0\u5217\u8868", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1437
|
+
Button,
|
|
1438
|
+
{
|
|
1439
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_icons4.ReloadOutlined, { "aria-hidden": "true" }),
|
|
1440
|
+
"aria-label": "\u5237\u65B0\u5217\u8868",
|
|
1441
|
+
loading: refreshing,
|
|
1442
|
+
disabled: !onRefresh || refreshing,
|
|
1443
|
+
onClick: onRefresh
|
|
1444
|
+
}
|
|
1445
|
+
) }),
|
|
1446
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1447
|
+
Popover,
|
|
1448
|
+
{
|
|
1449
|
+
trigger: "click",
|
|
1450
|
+
placement: "bottomRight",
|
|
1451
|
+
title: "\u8BBE\u7F6E\u663E\u793A\u5217",
|
|
1452
|
+
open: canSetColumns && open,
|
|
1453
|
+
onOpenChange: (next) => setOpen(canSetColumns && next),
|
|
1454
|
+
afterOpenChange: (opened) => {
|
|
1455
|
+
if (opened) panelRef.current?.querySelector("input:not(:disabled)")?.focus();
|
|
1456
|
+
},
|
|
1457
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { ref: panelRef, id: panelId, role: "dialog", "aria-label": "\u8BBE\u7F6E\u663E\u793A\u5217", onKeyDown: closeOnEscape, style: panelStyle, children: [
|
|
1458
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1459
|
+
Checkbox,
|
|
1460
|
+
{
|
|
1461
|
+
checked: checkedCount === editable.length,
|
|
1462
|
+
indeterminate: checkedCount > 0 && checkedCount < editable.length,
|
|
1463
|
+
onChange: (event) => setVisible(editable.map((column) => column.key), event.target.checked),
|
|
1464
|
+
children: "\u663E\u793A\u5168\u90E8\u53EF\u9009\u5217"
|
|
1465
|
+
}
|
|
1466
|
+
),
|
|
1467
|
+
columns.map((column) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1468
|
+
Checkbox,
|
|
1469
|
+
{
|
|
1470
|
+
checked: visible.has(column.key),
|
|
1471
|
+
disabled: column.disabled,
|
|
1472
|
+
onChange: (event) => setVisible([column.key], event.target.checked),
|
|
1473
|
+
children: column.label
|
|
1474
|
+
},
|
|
1475
|
+
column.key
|
|
1476
|
+
))
|
|
1477
|
+
] }),
|
|
1478
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1479
|
+
Button,
|
|
1480
|
+
{
|
|
1481
|
+
ref: triggerRef,
|
|
1482
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_icons4.SettingOutlined, { "aria-hidden": "true" }),
|
|
1483
|
+
"aria-label": "\u8BBE\u7F6E\u663E\u793A\u5217",
|
|
1484
|
+
"aria-haspopup": "dialog",
|
|
1485
|
+
"aria-expanded": canSetColumns && open,
|
|
1486
|
+
"aria-controls": canSetColumns && open ? panelId : void 0,
|
|
1487
|
+
disabled: !canSetColumns,
|
|
1488
|
+
onKeyDown: open ? closeOnEscape : void 0
|
|
1489
|
+
}
|
|
1490
|
+
)
|
|
1491
|
+
}
|
|
1492
|
+
)
|
|
1493
|
+
] });
|
|
1494
|
+
}
|
|
1495
|
+
|
|
1496
|
+
// src/composites/DataTable.tsx
|
|
1497
|
+
var import_react9 = require("react");
|
|
1498
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1255
1499
|
function tableBodyHeight(availableHeight, chromeHeight) {
|
|
1256
1500
|
return Math.max(0, Math.floor(availableHeight - chromeHeight - 16));
|
|
1257
1501
|
}
|
|
@@ -1272,10 +1516,10 @@ function DataTableInner({
|
|
|
1272
1516
|
scroll,
|
|
1273
1517
|
...tableProps
|
|
1274
1518
|
}, ref) {
|
|
1275
|
-
const containerRef = (0,
|
|
1276
|
-
const [bodyHeight, setBodyHeight] = (0,
|
|
1519
|
+
const containerRef = (0, import_react9.useRef)(null);
|
|
1520
|
+
const [bodyHeight, setBodyHeight] = (0, import_react9.useState)(360);
|
|
1277
1521
|
const hasExplicitHeight = containerHeight != null || containerStyle?.height != null;
|
|
1278
|
-
(0,
|
|
1522
|
+
(0, import_react9.useLayoutEffect)(() => {
|
|
1279
1523
|
const container = containerRef.current;
|
|
1280
1524
|
if (!container || scroll?.y != null) return void 0;
|
|
1281
1525
|
const update = () => {
|
|
@@ -1309,14 +1553,14 @@ function DataTableInner({
|
|
|
1309
1553
|
y: scroll?.y ?? bodyHeight
|
|
1310
1554
|
};
|
|
1311
1555
|
const tablePagination = pagination === false ? false : pagination?.placement || pagination?.position ? pagination : { placement: ["bottomEnd"], ...pagination };
|
|
1312
|
-
return /* @__PURE__ */ (0,
|
|
1556
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1313
1557
|
"div",
|
|
1314
1558
|
{
|
|
1315
1559
|
ref: containerRef,
|
|
1316
1560
|
className: containerClassName,
|
|
1317
1561
|
"data-adminsmart-data-table": "true",
|
|
1318
1562
|
style: { width: "100%", minWidth: 0, overflowX: "hidden", ...containerHeight == null ? {} : { height: containerHeight, overflowY: "hidden" }, ...containerStyle },
|
|
1319
|
-
children: /* @__PURE__ */ (0,
|
|
1563
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1320
1564
|
Table,
|
|
1321
1565
|
{
|
|
1322
1566
|
...tableProps,
|
|
@@ -1328,11 +1572,11 @@ function DataTableInner({
|
|
|
1328
1572
|
}
|
|
1329
1573
|
);
|
|
1330
1574
|
}
|
|
1331
|
-
var DataTable = (0,
|
|
1575
|
+
var DataTable = (0, import_react9.forwardRef)(DataTableInner);
|
|
1332
1576
|
|
|
1333
1577
|
// src/composites/WorkspaceLayout.tsx
|
|
1334
1578
|
var import_antd46 = require("antd");
|
|
1335
|
-
var
|
|
1579
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1336
1580
|
var LIGHT_WORKSPACE_BACKGROUND = "#f6f9fe";
|
|
1337
1581
|
function WorkspaceLayout({
|
|
1338
1582
|
header,
|
|
@@ -1364,10 +1608,10 @@ function WorkspaceLayout({
|
|
|
1364
1608
|
"--adminsmart-workspace-bg": themeMode === "dark" ? token.colorBgLayout : LIGHT_WORKSPACE_BACKGROUND
|
|
1365
1609
|
// 夜间不复用日间固定底色。
|
|
1366
1610
|
};
|
|
1367
|
-
return /* @__PURE__ */ (0,
|
|
1368
|
-
/* @__PURE__ */ (0,
|
|
1369
|
-
/* @__PURE__ */ (0,
|
|
1370
|
-
/* @__PURE__ */ (0,
|
|
1611
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Layout, { className: rootClassName, style: workspaceStyle, "data-theme-mode": themeMode, children: [
|
|
1612
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("header", { className: "adminsmart-workspace__header", children: header }),
|
|
1613
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Layout, { className: "adminsmart-workspace__body", children: [
|
|
1614
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1371
1615
|
Layout.Sider,
|
|
1372
1616
|
{
|
|
1373
1617
|
theme: themeMode,
|
|
@@ -1379,9 +1623,9 @@ function WorkspaceLayout({
|
|
|
1379
1623
|
children: sidebar
|
|
1380
1624
|
}
|
|
1381
1625
|
),
|
|
1382
|
-
/* @__PURE__ */ (0,
|
|
1626
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Layout, { className: "adminsmart-workspace__main", children: [
|
|
1383
1627
|
tabs,
|
|
1384
|
-
/* @__PURE__ */ (0,
|
|
1628
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Layout.Content, { className: contentClasses, "data-content-mode": contentMode, children }),
|
|
1385
1629
|
footer
|
|
1386
1630
|
] })
|
|
1387
1631
|
] })
|
|
@@ -1389,7 +1633,7 @@ function WorkspaceLayout({
|
|
|
1389
1633
|
}
|
|
1390
1634
|
|
|
1391
1635
|
// src/composites/CrudScaffold.tsx
|
|
1392
|
-
var
|
|
1636
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1393
1637
|
function CrudScaffold({
|
|
1394
1638
|
label,
|
|
1395
1639
|
description,
|
|
@@ -1401,16 +1645,16 @@ function CrudScaffold({
|
|
|
1401
1645
|
...props
|
|
1402
1646
|
}) {
|
|
1403
1647
|
const classes = ["adminsmart-crud", className].filter(Boolean).join(" ");
|
|
1404
|
-
return /* @__PURE__ */ (0,
|
|
1405
|
-
/* @__PURE__ */ (0,
|
|
1406
|
-
status ? /* @__PURE__ */ (0,
|
|
1407
|
-
/* @__PURE__ */ (0,
|
|
1648
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("main", { ...props, className: classes, "aria-label": label, "aria-description": description, children: [
|
|
1649
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "adminsmart-crud__filters", children: filters }),
|
|
1650
|
+
status ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "adminsmart-crud__status", children: status }) : null,
|
|
1651
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "adminsmart-crud__results", children: results }),
|
|
1408
1652
|
drawer
|
|
1409
1653
|
] });
|
|
1410
1654
|
}
|
|
1411
1655
|
|
|
1412
1656
|
// src/composites/EllipsisText.tsx
|
|
1413
|
-
var
|
|
1657
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1414
1658
|
function EllipsisText({
|
|
1415
1659
|
children,
|
|
1416
1660
|
maxWidth = 240,
|
|
@@ -1422,7 +1666,7 @@ function EllipsisText({
|
|
|
1422
1666
|
const classes = ["adminsmart-ellipsis-text", className].filter(Boolean).join(" ");
|
|
1423
1667
|
const widthValue = typeof maxWidth === "number" ? `${maxWidth}px` : maxWidth;
|
|
1424
1668
|
const textStyle = { "--adminsmart-ellipsis-width": widthValue, ...style };
|
|
1425
|
-
return /* @__PURE__ */ (0,
|
|
1669
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1426
1670
|
Typography.Text,
|
|
1427
1671
|
{
|
|
1428
1672
|
...props,
|
|
@@ -1435,14 +1679,14 @@ function EllipsisText({
|
|
|
1435
1679
|
}
|
|
1436
1680
|
|
|
1437
1681
|
// src/composites/RowActions.tsx
|
|
1438
|
-
var
|
|
1439
|
-
var
|
|
1440
|
-
var
|
|
1682
|
+
var import_icons5 = require("@ant-design/icons");
|
|
1683
|
+
var import_react10 = require("react");
|
|
1684
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1441
1685
|
function collectButtons(children) {
|
|
1442
1686
|
const actions = [];
|
|
1443
|
-
|
|
1444
|
-
if (!(0,
|
|
1445
|
-
if (child.type ===
|
|
1687
|
+
import_react10.Children.forEach(children, (child) => {
|
|
1688
|
+
if (!(0, import_react10.isValidElement)(child)) return;
|
|
1689
|
+
if (child.type === import_react10.Fragment) actions.push(...collectButtons(child.props.children));
|
|
1446
1690
|
else {
|
|
1447
1691
|
if (child.type !== Button && child.type !== "button") throw new TypeError("RowActions \u53EA\u63A5\u53D7\u5DF2\u6309\u6743\u9650\u7B5B\u9009\u7684 Button \u6216 Fragment");
|
|
1448
1692
|
if (!child.props.hidden) actions.push(child);
|
|
@@ -1468,9 +1712,9 @@ function RowActions({ children, maxVisible = 2, moreLabel = "\u66F4\u591A\u64CD\
|
|
|
1468
1712
|
// 菜单仍按官方语义标识需要确认的动作。
|
|
1469
1713
|
}));
|
|
1470
1714
|
const classes = ["adminsmart-row-action-group", className].filter(Boolean).join(" ");
|
|
1471
|
-
return /* @__PURE__ */ (0,
|
|
1715
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(Space, { ...props, className: classes, size, wrap, children: [
|
|
1472
1716
|
direct,
|
|
1473
|
-
overflow.length > 0 && /* @__PURE__ */ (0,
|
|
1717
|
+
overflow.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1474
1718
|
Dropdown,
|
|
1475
1719
|
{
|
|
1476
1720
|
trigger: ["click"],
|
|
@@ -1482,12 +1726,12 @@ function RowActions({ children, maxVisible = 2, moreLabel = "\u66F4\u591A\u64CD\
|
|
|
1482
1726
|
action.props.onClick?.(domEvent);
|
|
1483
1727
|
}
|
|
1484
1728
|
},
|
|
1485
|
-
children: /* @__PURE__ */ (0,
|
|
1729
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Tooltip, { title: moreLabel, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1486
1730
|
Button,
|
|
1487
1731
|
{
|
|
1488
1732
|
type: "text",
|
|
1489
1733
|
size: "small",
|
|
1490
|
-
icon: /* @__PURE__ */ (0,
|
|
1734
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_icons5.EllipsisOutlined, {}),
|
|
1491
1735
|
"aria-label": moreLabel,
|
|
1492
1736
|
"aria-haspopup": "menu",
|
|
1493
1737
|
"data-adminsmart-row-more": "true",
|
|
@@ -1501,7 +1745,7 @@ function RowActions({ children, maxVisible = 2, moreLabel = "\u66F4\u591A\u64CD\
|
|
|
1501
1745
|
|
|
1502
1746
|
// src/schema/SchemaForm.tsx
|
|
1503
1747
|
var import_dayjs = __toESM(require("dayjs"), 1);
|
|
1504
|
-
var
|
|
1748
|
+
var import_react11 = require("react");
|
|
1505
1749
|
|
|
1506
1750
|
// src/schema/model.ts
|
|
1507
1751
|
var FIELD_TYPES = /* @__PURE__ */ new Set([
|
|
@@ -1684,7 +1928,7 @@ function schemaInitialValues(schema) {
|
|
|
1684
1928
|
}
|
|
1685
1929
|
|
|
1686
1930
|
// src/schema/SchemaForm.tsx
|
|
1687
|
-
var
|
|
1931
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1688
1932
|
function fieldRules(field) {
|
|
1689
1933
|
const rules = [];
|
|
1690
1934
|
if (field.required) {
|
|
@@ -1729,32 +1973,32 @@ function dateItemProps(field) {
|
|
|
1729
1973
|
function renderControl(field) {
|
|
1730
1974
|
switch (field.type) {
|
|
1731
1975
|
case "input":
|
|
1732
|
-
return /* @__PURE__ */ (0,
|
|
1976
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Input, { placeholder: field.placeholder });
|
|
1733
1977
|
case "password":
|
|
1734
|
-
return /* @__PURE__ */ (0,
|
|
1978
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Input.Password, { placeholder: field.placeholder });
|
|
1735
1979
|
case "textarea":
|
|
1736
|
-
return /* @__PURE__ */ (0,
|
|
1980
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Input.TextArea, { placeholder: field.placeholder });
|
|
1737
1981
|
case "number":
|
|
1738
|
-
return /* @__PURE__ */ (0,
|
|
1982
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(InputNumber, { placeholder: field.placeholder, min: field.validation?.min, max: field.validation?.max, style: { width: "100%" } });
|
|
1739
1983
|
case "select":
|
|
1740
|
-
return /* @__PURE__ */ (0,
|
|
1984
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Select, { placeholder: field.placeholder, options: field.options });
|
|
1741
1985
|
case "radio":
|
|
1742
|
-
return /* @__PURE__ */ (0,
|
|
1986
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Radio.Group, { options: field.options });
|
|
1743
1987
|
case "checkbox":
|
|
1744
|
-
return /* @__PURE__ */ (0,
|
|
1988
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Checkbox, {});
|
|
1745
1989
|
case "switch":
|
|
1746
|
-
return /* @__PURE__ */ (0,
|
|
1990
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Switch, {});
|
|
1747
1991
|
case "date":
|
|
1748
|
-
return /* @__PURE__ */ (0,
|
|
1992
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(DatePicker, { placeholder: field.placeholder, style: { width: "100%" } });
|
|
1749
1993
|
case "dateRange":
|
|
1750
|
-
return /* @__PURE__ */ (0,
|
|
1994
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(DatePicker.RangePicker, { placeholder: field.placeholder ? [field.placeholder, field.placeholder] : void 0, style: { width: "100%" } });
|
|
1751
1995
|
}
|
|
1752
1996
|
}
|
|
1753
|
-
var SchemaForm = (0,
|
|
1997
|
+
var SchemaForm = (0, import_react11.forwardRef)(function SchemaForm2({ schema, onSubmit, onChange, onFinish, onValuesChange, initialValues, layout = "vertical", ...formProps }, ref) {
|
|
1754
1998
|
const result = validateSchemaForm(schema);
|
|
1755
1999
|
if (!result.valid) throw new Error(`SchemaForm \u914D\u7F6E\u65E0\u6548\uFF1A${result.errors.map((issue) => `${issue.path} ${issue.message}`).join("\uFF1B")}`);
|
|
1756
2000
|
const defaults = schemaInitialValues(schema);
|
|
1757
|
-
return /* @__PURE__ */ (0,
|
|
2001
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
1758
2002
|
Form,
|
|
1759
2003
|
{
|
|
1760
2004
|
...formProps,
|
|
@@ -1772,7 +2016,7 @@ var SchemaForm = (0, import_react10.forwardRef)(function SchemaForm2({ schema, o
|
|
|
1772
2016
|
children: [
|
|
1773
2017
|
schema.fields.map((field) => {
|
|
1774
2018
|
const mapped = mapSchemaField(field);
|
|
1775
|
-
return /* @__PURE__ */ (0,
|
|
2019
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1776
2020
|
Form.Item,
|
|
1777
2021
|
{
|
|
1778
2022
|
name: mapped.name,
|
|
@@ -1785,7 +2029,7 @@ var SchemaForm = (0, import_react10.forwardRef)(function SchemaForm2({ schema, o
|
|
|
1785
2029
|
mapped.name
|
|
1786
2030
|
);
|
|
1787
2031
|
}),
|
|
1788
|
-
/* @__PURE__ */ (0,
|
|
2032
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Form.Item, { children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Button, { type: "primary", htmlType: "submit", children: schema.submitText ?? "\u63D0\u4EA4" }) })
|
|
1789
2033
|
]
|
|
1790
2034
|
}
|
|
1791
2035
|
);
|
|
@@ -1861,6 +2105,7 @@ var SchemaForm = (0, import_react10.forwardRef)(function SchemaForm2({ schema, o
|
|
|
1861
2105
|
Steps,
|
|
1862
2106
|
Switch,
|
|
1863
2107
|
Table,
|
|
2108
|
+
TableControls,
|
|
1864
2109
|
TableEmpty,
|
|
1865
2110
|
Tabs,
|
|
1866
2111
|
Tag,
|