@qq1948037137/adminsmart-ui 0.1.27 → 0.1.29
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 +5 -1
- package/dist/index.cjs +205 -51
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +58 -2
- package/dist/index.d.ts +58 -2
- package/dist/index.js +197 -44
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/styles/composites.css +49 -0
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,10 @@ 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
|
+
|
|
56
|
+
在 `WorkspaceLayout contentMode="table"` 的内容区嵌入 `CrudWorkspace`,可使用独立的筛选、操作栏、反馈与页脚插槽,`DataTable` 自动填满剩余区域。结果超出高度时在表体内滚动,分页仍保持可见。文档站的「CrudWorkspace 标准 CRUD 工作区」展示同一布局中的搜索、刷新、显隐列、新建、编辑和删除。
|
|
57
|
+
|
|
54
58
|
主应用的本地 tarball 过渡与 npm Registry 升级都必须锁定精确版本、实际包名和完整性,不能仅改依赖字符串而跳过来源校验。本库通过 `adminsmartUiSource: { sha256, gitCommit }` 提供构建源码标记,消费者使用 Registry 的 `dist.integrity` 与 `dist.tarball` 核对字节。该标记是项目来源契约,不是官方 provenance。
|
|
55
59
|
|
|
56
60
|
`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
|
@@ -53,6 +53,7 @@ __export(src_exports, {
|
|
|
53
53
|
ColorPicker: () => ColorPicker,
|
|
54
54
|
ConfigProvider: () => ConfigProvider,
|
|
55
55
|
CrudScaffold: () => CrudScaffold,
|
|
56
|
+
CrudWorkspace: () => CrudWorkspace,
|
|
56
57
|
DataTable: () => DataTable,
|
|
57
58
|
DatePicker: () => DatePicker,
|
|
58
59
|
Descriptions: () => Descriptions,
|
|
@@ -99,6 +100,7 @@ __export(src_exports, {
|
|
|
99
100
|
Steps: () => Steps,
|
|
100
101
|
Switch: () => Switch,
|
|
101
102
|
Table: () => Table,
|
|
103
|
+
TableControls: () => TableControls,
|
|
102
104
|
TableEmpty: () => TableEmpty,
|
|
103
105
|
Tabs: () => Tabs,
|
|
104
106
|
Tag: () => Tag,
|
|
@@ -1375,9 +1377,146 @@ var SearchPanel = (0, import_react7.forwardRef)(function SearchPanel2({ fields,
|
|
|
1375
1377
|
] });
|
|
1376
1378
|
});
|
|
1377
1379
|
|
|
1378
|
-
// src/composites/
|
|
1380
|
+
// src/composites/TableControls.tsx
|
|
1381
|
+
var import_icons4 = require("@ant-design/icons");
|
|
1379
1382
|
var import_react8 = require("react");
|
|
1380
1383
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1384
|
+
function TableControls({
|
|
1385
|
+
searchVisible = true,
|
|
1386
|
+
onSearchVisibleChange,
|
|
1387
|
+
onRefresh,
|
|
1388
|
+
refreshing = false,
|
|
1389
|
+
columns = [],
|
|
1390
|
+
visibleColumns,
|
|
1391
|
+
onVisibleColumnsChange,
|
|
1392
|
+
className,
|
|
1393
|
+
style
|
|
1394
|
+
}) {
|
|
1395
|
+
const [open, setOpen] = (0, import_react8.useState)(false);
|
|
1396
|
+
const triggerRef = (0, import_react8.useRef)(null);
|
|
1397
|
+
const panelRef = (0, import_react8.useRef)(null);
|
|
1398
|
+
const panelId = (0, import_react8.useId)();
|
|
1399
|
+
const editable = columns.filter((column) => !column.disabled);
|
|
1400
|
+
const visible = new Set(visibleColumns ?? columns.map((column) => column.key));
|
|
1401
|
+
const checkedCount = editable.filter((column) => visible.has(column.key)).length;
|
|
1402
|
+
const canSetColumns = editable.length > 0 && Boolean(onVisibleColumnsChange);
|
|
1403
|
+
const searchLabel = searchVisible ? "\u9690\u85CF\u641C\u7D22" : "\u663E\u793A\u641C\u7D22";
|
|
1404
|
+
const setVisible = (keys, checked) => {
|
|
1405
|
+
const next = new Set(visible);
|
|
1406
|
+
for (const key of keys) {
|
|
1407
|
+
if (checked) next.add(key);
|
|
1408
|
+
else next.delete(key);
|
|
1409
|
+
}
|
|
1410
|
+
onVisibleColumnsChange?.(columns.filter((column) => next.has(column.key)).map((column) => column.key));
|
|
1411
|
+
};
|
|
1412
|
+
const closeOnEscape = (event) => {
|
|
1413
|
+
if (event.key !== "Escape") return;
|
|
1414
|
+
event.stopPropagation();
|
|
1415
|
+
setOpen(false);
|
|
1416
|
+
triggerRef.current?.focus();
|
|
1417
|
+
};
|
|
1418
|
+
const panelStyle = {
|
|
1419
|
+
display: "grid",
|
|
1420
|
+
gap: 8,
|
|
1421
|
+
minWidth: 120,
|
|
1422
|
+
maxWidth: "min(320px, calc(100vw - 32px))",
|
|
1423
|
+
maxHeight: "min(380px, 60vh)",
|
|
1424
|
+
overflow: "auto"
|
|
1425
|
+
};
|
|
1426
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className, style: { display: "inline-flex", alignItems: "center", flexShrink: 0, gap: 8, ...style }, children: [
|
|
1427
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Tooltip, { title: searchLabel, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1428
|
+
Button,
|
|
1429
|
+
{
|
|
1430
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_icons4.SearchOutlined, { "aria-hidden": "true" }),
|
|
1431
|
+
"aria-label": searchLabel,
|
|
1432
|
+
"aria-pressed": searchVisible,
|
|
1433
|
+
"data-adminsmart-table-tool": "true",
|
|
1434
|
+
disabled: !onSearchVisibleChange,
|
|
1435
|
+
onClick: () => onSearchVisibleChange?.(!searchVisible)
|
|
1436
|
+
}
|
|
1437
|
+
) }),
|
|
1438
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Tooltip, { title: "\u5237\u65B0\u5217\u8868", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1439
|
+
Button,
|
|
1440
|
+
{
|
|
1441
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_icons4.ReloadOutlined, { "aria-hidden": "true" }),
|
|
1442
|
+
"aria-label": "\u5237\u65B0\u5217\u8868",
|
|
1443
|
+
"data-adminsmart-table-tool": "true",
|
|
1444
|
+
loading: refreshing,
|
|
1445
|
+
disabled: !onRefresh || refreshing,
|
|
1446
|
+
onClick: onRefresh
|
|
1447
|
+
}
|
|
1448
|
+
) }),
|
|
1449
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1450
|
+
Popover,
|
|
1451
|
+
{
|
|
1452
|
+
trigger: "click",
|
|
1453
|
+
placement: "bottomRight",
|
|
1454
|
+
title: "\u8BBE\u7F6E\u663E\u793A\u5217",
|
|
1455
|
+
open: canSetColumns && open,
|
|
1456
|
+
onOpenChange: (next) => setOpen(canSetColumns && next),
|
|
1457
|
+
afterOpenChange: (opened) => {
|
|
1458
|
+
if (opened) panelRef.current?.querySelector("input:not(:disabled)")?.focus();
|
|
1459
|
+
},
|
|
1460
|
+
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: [
|
|
1461
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1462
|
+
Checkbox,
|
|
1463
|
+
{
|
|
1464
|
+
checked: checkedCount === editable.length,
|
|
1465
|
+
indeterminate: checkedCount > 0 && checkedCount < editable.length,
|
|
1466
|
+
onChange: (event) => setVisible(editable.map((column) => column.key), event.target.checked),
|
|
1467
|
+
children: "\u663E\u793A\u5168\u90E8\u53EF\u9009\u5217"
|
|
1468
|
+
}
|
|
1469
|
+
),
|
|
1470
|
+
columns.map((column) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1471
|
+
Checkbox,
|
|
1472
|
+
{
|
|
1473
|
+
checked: visible.has(column.key),
|
|
1474
|
+
disabled: column.disabled,
|
|
1475
|
+
onChange: (event) => setVisible([column.key], event.target.checked),
|
|
1476
|
+
children: column.label
|
|
1477
|
+
},
|
|
1478
|
+
column.key
|
|
1479
|
+
))
|
|
1480
|
+
] }),
|
|
1481
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1482
|
+
Button,
|
|
1483
|
+
{
|
|
1484
|
+
ref: triggerRef,
|
|
1485
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_icons4.SettingOutlined, { "aria-hidden": "true" }),
|
|
1486
|
+
"aria-label": "\u8BBE\u7F6E\u663E\u793A\u5217",
|
|
1487
|
+
"data-adminsmart-table-tool": "true",
|
|
1488
|
+
"aria-haspopup": "dialog",
|
|
1489
|
+
"aria-expanded": canSetColumns && open,
|
|
1490
|
+
"aria-controls": canSetColumns && open ? panelId : void 0,
|
|
1491
|
+
disabled: !canSetColumns,
|
|
1492
|
+
onKeyDown: open ? closeOnEscape : void 0
|
|
1493
|
+
}
|
|
1494
|
+
)
|
|
1495
|
+
}
|
|
1496
|
+
)
|
|
1497
|
+
] });
|
|
1498
|
+
}
|
|
1499
|
+
|
|
1500
|
+
// src/composites/DataTable.tsx
|
|
1501
|
+
var import_react10 = require("react");
|
|
1502
|
+
|
|
1503
|
+
// src/composites/CrudWorkspace.tsx
|
|
1504
|
+
var import_react9 = require("react");
|
|
1505
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1506
|
+
var CrudTableHeightContext = (0, import_react9.createContext)(false);
|
|
1507
|
+
function CrudWorkspace({ label, filters, toolbar, feedback, footer, children, className, ...props }) {
|
|
1508
|
+
const classes = ["adminsmart-crud-workspace", className].filter(Boolean).join(" ");
|
|
1509
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("section", { ...props, className: classes, "aria-label": label, children: [
|
|
1510
|
+
filters != null && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "adminsmart-crud-workspace__filters", children: filters }),
|
|
1511
|
+
toolbar != null && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "adminsmart-crud-workspace__toolbar", children: toolbar }),
|
|
1512
|
+
feedback != null && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "adminsmart-crud-workspace__feedback", children: feedback }),
|
|
1513
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "adminsmart-crud-workspace__results", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CrudTableHeightContext.Provider, { value: true, children }) }),
|
|
1514
|
+
footer != null && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "adminsmart-crud-workspace__footer", children: footer })
|
|
1515
|
+
] });
|
|
1516
|
+
}
|
|
1517
|
+
|
|
1518
|
+
// src/composites/DataTable.tsx
|
|
1519
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1381
1520
|
function tableBodyHeight(availableHeight, chromeHeight) {
|
|
1382
1521
|
return Math.max(0, Math.floor(availableHeight - chromeHeight - 16));
|
|
1383
1522
|
}
|
|
@@ -1398,13 +1537,22 @@ function DataTableInner({
|
|
|
1398
1537
|
scroll,
|
|
1399
1538
|
...tableProps
|
|
1400
1539
|
}, ref) {
|
|
1401
|
-
const containerRef = (0,
|
|
1402
|
-
const [bodyHeight, setBodyHeight] = (0,
|
|
1403
|
-
const
|
|
1404
|
-
|
|
1540
|
+
const containerRef = (0, import_react10.useRef)(null);
|
|
1541
|
+
const [bodyHeight, setBodyHeight] = (0, import_react10.useState)(360);
|
|
1542
|
+
const inWorkspace = (0, import_react10.useContext)(CrudTableHeightContext);
|
|
1543
|
+
const tableHeight = containerHeight ?? (inWorkspace && containerStyle?.height == null ? "100%" : void 0);
|
|
1544
|
+
const hasExplicitHeight = tableHeight != null || containerStyle?.height != null;
|
|
1545
|
+
(0, import_react10.useLayoutEffect)(() => {
|
|
1405
1546
|
const container = containerRef.current;
|
|
1406
1547
|
if (!container || scroll?.y != null) return void 0;
|
|
1407
1548
|
const update = () => {
|
|
1549
|
+
if (hasExplicitHeight) {
|
|
1550
|
+
const height = container.getBoundingClientRect().height;
|
|
1551
|
+
const chromeHeight = tableChromeHeight(container);
|
|
1552
|
+
const nextHeight2 = inWorkspace ? Math.max(0, Math.floor(height - chromeHeight)) : tableBodyHeight(height, chromeHeight);
|
|
1553
|
+
setBodyHeight((current) => current === nextHeight2 ? current : nextHeight2);
|
|
1554
|
+
return;
|
|
1555
|
+
}
|
|
1408
1556
|
const top = container.getBoundingClientRect().top;
|
|
1409
1557
|
let boundary = container.parentElement;
|
|
1410
1558
|
while (boundary && ["", "visible", "clip"].includes(getComputedStyle(boundary).overflowY)) {
|
|
@@ -1413,13 +1561,16 @@ function DataTableInner({
|
|
|
1413
1561
|
const boundaryStyle = boundary ? getComputedStyle(boundary) : null;
|
|
1414
1562
|
const parentBottom = boundary ? boundary.getBoundingClientRect().bottom - Number.parseFloat(boundaryStyle?.paddingBottom || "0") : Number.POSITIVE_INFINITY;
|
|
1415
1563
|
const viewportBottom = window.visualViewport?.height ?? window.innerHeight;
|
|
1416
|
-
const availableHeight =
|
|
1564
|
+
const availableHeight = Math.max(200, Math.min(viewportBottom - 16, parentBottom - 16) - top);
|
|
1417
1565
|
const nextHeight = tableBodyHeight(availableHeight, tableChromeHeight(container));
|
|
1418
1566
|
setBodyHeight((current) => current === nextHeight ? current : nextHeight);
|
|
1419
1567
|
};
|
|
1420
1568
|
const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(update);
|
|
1421
1569
|
observer?.observe(container);
|
|
1422
1570
|
if (container.parentElement) observer?.observe(container.parentElement);
|
|
1571
|
+
if (inWorkspace) {
|
|
1572
|
+
for (const region of container.querySelectorAll(".ant-table-header, .ant-table-pagination, .ant-table-title, .ant-table-footer")) observer?.observe(region);
|
|
1573
|
+
}
|
|
1423
1574
|
window.addEventListener("resize", update);
|
|
1424
1575
|
window.visualViewport?.addEventListener("resize", update);
|
|
1425
1576
|
update();
|
|
@@ -1428,21 +1579,22 @@ function DataTableInner({
|
|
|
1428
1579
|
window.removeEventListener("resize", update);
|
|
1429
1580
|
window.visualViewport?.removeEventListener("resize", update);
|
|
1430
1581
|
};
|
|
1431
|
-
}, [hasExplicitHeight,
|
|
1582
|
+
}, [hasExplicitHeight, inWorkspace, tableHeight, pagination, scroll?.y, tableProps.dataSource?.length]);
|
|
1432
1583
|
const tableScroll = {
|
|
1433
1584
|
...scroll,
|
|
1434
1585
|
x: scroll?.x ?? "max-content",
|
|
1435
1586
|
y: scroll?.y ?? bodyHeight
|
|
1436
1587
|
};
|
|
1437
1588
|
const tablePagination = pagination === false ? false : pagination?.placement || pagination?.position ? pagination : { placement: ["bottomEnd"], ...pagination };
|
|
1438
|
-
return /* @__PURE__ */ (0,
|
|
1589
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1439
1590
|
"div",
|
|
1440
1591
|
{
|
|
1441
1592
|
ref: containerRef,
|
|
1442
1593
|
className: containerClassName,
|
|
1443
1594
|
"data-adminsmart-data-table": "true",
|
|
1444
|
-
|
|
1445
|
-
|
|
1595
|
+
"data-adminsmart-data-table-fill": inWorkspace || void 0,
|
|
1596
|
+
style: { width: "100%", minWidth: 0, overflowX: "hidden", ...tableHeight == null ? {} : { height: tableHeight, overflowY: "hidden" }, ...containerStyle },
|
|
1597
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1446
1598
|
Table,
|
|
1447
1599
|
{
|
|
1448
1600
|
...tableProps,
|
|
@@ -1454,11 +1606,11 @@ function DataTableInner({
|
|
|
1454
1606
|
}
|
|
1455
1607
|
);
|
|
1456
1608
|
}
|
|
1457
|
-
var DataTable = (0,
|
|
1609
|
+
var DataTable = (0, import_react10.forwardRef)(DataTableInner);
|
|
1458
1610
|
|
|
1459
1611
|
// src/composites/WorkspaceLayout.tsx
|
|
1460
1612
|
var import_antd46 = require("antd");
|
|
1461
|
-
var
|
|
1613
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1462
1614
|
var LIGHT_WORKSPACE_BACKGROUND = "#f6f9fe";
|
|
1463
1615
|
function WorkspaceLayout({
|
|
1464
1616
|
header,
|
|
@@ -1490,10 +1642,10 @@ function WorkspaceLayout({
|
|
|
1490
1642
|
"--adminsmart-workspace-bg": themeMode === "dark" ? token.colorBgLayout : LIGHT_WORKSPACE_BACKGROUND
|
|
1491
1643
|
// 夜间不复用日间固定底色。
|
|
1492
1644
|
};
|
|
1493
|
-
return /* @__PURE__ */ (0,
|
|
1494
|
-
/* @__PURE__ */ (0,
|
|
1495
|
-
/* @__PURE__ */ (0,
|
|
1496
|
-
/* @__PURE__ */ (0,
|
|
1645
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(Layout, { className: rootClassName, style: workspaceStyle, "data-theme-mode": themeMode, children: [
|
|
1646
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("header", { className: "adminsmart-workspace__header", children: header }),
|
|
1647
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(Layout, { className: "adminsmart-workspace__body", children: [
|
|
1648
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1497
1649
|
Layout.Sider,
|
|
1498
1650
|
{
|
|
1499
1651
|
theme: themeMode,
|
|
@@ -1505,9 +1657,9 @@ function WorkspaceLayout({
|
|
|
1505
1657
|
children: sidebar
|
|
1506
1658
|
}
|
|
1507
1659
|
),
|
|
1508
|
-
/* @__PURE__ */ (0,
|
|
1660
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(Layout, { className: "adminsmart-workspace__main", children: [
|
|
1509
1661
|
tabs,
|
|
1510
|
-
/* @__PURE__ */ (0,
|
|
1662
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Layout.Content, { className: contentClasses, "data-content-mode": contentMode, children }),
|
|
1511
1663
|
footer
|
|
1512
1664
|
] })
|
|
1513
1665
|
] })
|
|
@@ -1515,7 +1667,7 @@ function WorkspaceLayout({
|
|
|
1515
1667
|
}
|
|
1516
1668
|
|
|
1517
1669
|
// src/composites/CrudScaffold.tsx
|
|
1518
|
-
var
|
|
1670
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1519
1671
|
function CrudScaffold({
|
|
1520
1672
|
label,
|
|
1521
1673
|
description,
|
|
@@ -1527,16 +1679,16 @@ function CrudScaffold({
|
|
|
1527
1679
|
...props
|
|
1528
1680
|
}) {
|
|
1529
1681
|
const classes = ["adminsmart-crud", className].filter(Boolean).join(" ");
|
|
1530
|
-
return /* @__PURE__ */ (0,
|
|
1531
|
-
/* @__PURE__ */ (0,
|
|
1532
|
-
status ? /* @__PURE__ */ (0,
|
|
1533
|
-
/* @__PURE__ */ (0,
|
|
1682
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("main", { ...props, className: classes, "aria-label": label, "aria-description": description, children: [
|
|
1683
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "adminsmart-crud__filters", children: filters }),
|
|
1684
|
+
status ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "adminsmart-crud__status", children: status }) : null,
|
|
1685
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "adminsmart-crud__results", children: results }),
|
|
1534
1686
|
drawer
|
|
1535
1687
|
] });
|
|
1536
1688
|
}
|
|
1537
1689
|
|
|
1538
1690
|
// src/composites/EllipsisText.tsx
|
|
1539
|
-
var
|
|
1691
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1540
1692
|
function EllipsisText({
|
|
1541
1693
|
children,
|
|
1542
1694
|
maxWidth = 240,
|
|
@@ -1548,7 +1700,7 @@ function EllipsisText({
|
|
|
1548
1700
|
const classes = ["adminsmart-ellipsis-text", className].filter(Boolean).join(" ");
|
|
1549
1701
|
const widthValue = typeof maxWidth === "number" ? `${maxWidth}px` : maxWidth;
|
|
1550
1702
|
const textStyle = { "--adminsmart-ellipsis-width": widthValue, ...style };
|
|
1551
|
-
return /* @__PURE__ */ (0,
|
|
1703
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1552
1704
|
Typography.Text,
|
|
1553
1705
|
{
|
|
1554
1706
|
...props,
|
|
@@ -1561,14 +1713,14 @@ function EllipsisText({
|
|
|
1561
1713
|
}
|
|
1562
1714
|
|
|
1563
1715
|
// src/composites/RowActions.tsx
|
|
1564
|
-
var
|
|
1565
|
-
var
|
|
1566
|
-
var
|
|
1716
|
+
var import_icons5 = require("@ant-design/icons");
|
|
1717
|
+
var import_react11 = require("react");
|
|
1718
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1567
1719
|
function collectButtons(children) {
|
|
1568
1720
|
const actions = [];
|
|
1569
|
-
|
|
1570
|
-
if (!(0,
|
|
1571
|
-
if (child.type ===
|
|
1721
|
+
import_react11.Children.forEach(children, (child) => {
|
|
1722
|
+
if (!(0, import_react11.isValidElement)(child)) return;
|
|
1723
|
+
if (child.type === import_react11.Fragment) actions.push(...collectButtons(child.props.children));
|
|
1572
1724
|
else {
|
|
1573
1725
|
if (child.type !== Button && child.type !== "button") throw new TypeError("RowActions \u53EA\u63A5\u53D7\u5DF2\u6309\u6743\u9650\u7B5B\u9009\u7684 Button \u6216 Fragment");
|
|
1574
1726
|
if (!child.props.hidden) actions.push(child);
|
|
@@ -1594,9 +1746,9 @@ function RowActions({ children, maxVisible = 2, moreLabel = "\u66F4\u591A\u64CD\
|
|
|
1594
1746
|
// 菜单仍按官方语义标识需要确认的动作。
|
|
1595
1747
|
}));
|
|
1596
1748
|
const classes = ["adminsmart-row-action-group", className].filter(Boolean).join(" ");
|
|
1597
|
-
return /* @__PURE__ */ (0,
|
|
1749
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(Space, { ...props, className: classes, size, wrap, children: [
|
|
1598
1750
|
direct,
|
|
1599
|
-
overflow.length > 0 && /* @__PURE__ */ (0,
|
|
1751
|
+
overflow.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1600
1752
|
Dropdown,
|
|
1601
1753
|
{
|
|
1602
1754
|
trigger: ["click"],
|
|
@@ -1608,12 +1760,12 @@ function RowActions({ children, maxVisible = 2, moreLabel = "\u66F4\u591A\u64CD\
|
|
|
1608
1760
|
action.props.onClick?.(domEvent);
|
|
1609
1761
|
}
|
|
1610
1762
|
},
|
|
1611
|
-
children: /* @__PURE__ */ (0,
|
|
1763
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Tooltip, { title: moreLabel, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1612
1764
|
Button,
|
|
1613
1765
|
{
|
|
1614
1766
|
type: "text",
|
|
1615
1767
|
size: "small",
|
|
1616
|
-
icon: /* @__PURE__ */ (0,
|
|
1768
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_icons5.EllipsisOutlined, {}),
|
|
1617
1769
|
"aria-label": moreLabel,
|
|
1618
1770
|
"aria-haspopup": "menu",
|
|
1619
1771
|
"data-adminsmart-row-more": "true",
|
|
@@ -1627,7 +1779,7 @@ function RowActions({ children, maxVisible = 2, moreLabel = "\u66F4\u591A\u64CD\
|
|
|
1627
1779
|
|
|
1628
1780
|
// src/schema/SchemaForm.tsx
|
|
1629
1781
|
var import_dayjs = __toESM(require("dayjs"), 1);
|
|
1630
|
-
var
|
|
1782
|
+
var import_react12 = require("react");
|
|
1631
1783
|
|
|
1632
1784
|
// src/schema/model.ts
|
|
1633
1785
|
var FIELD_TYPES = /* @__PURE__ */ new Set([
|
|
@@ -1810,7 +1962,7 @@ function schemaInitialValues(schema) {
|
|
|
1810
1962
|
}
|
|
1811
1963
|
|
|
1812
1964
|
// src/schema/SchemaForm.tsx
|
|
1813
|
-
var
|
|
1965
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1814
1966
|
function fieldRules(field) {
|
|
1815
1967
|
const rules = [];
|
|
1816
1968
|
if (field.required) {
|
|
@@ -1855,32 +2007,32 @@ function dateItemProps(field) {
|
|
|
1855
2007
|
function renderControl(field) {
|
|
1856
2008
|
switch (field.type) {
|
|
1857
2009
|
case "input":
|
|
1858
|
-
return /* @__PURE__ */ (0,
|
|
2010
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Input, { placeholder: field.placeholder });
|
|
1859
2011
|
case "password":
|
|
1860
|
-
return /* @__PURE__ */ (0,
|
|
2012
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Input.Password, { placeholder: field.placeholder });
|
|
1861
2013
|
case "textarea":
|
|
1862
|
-
return /* @__PURE__ */ (0,
|
|
2014
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Input.TextArea, { placeholder: field.placeholder });
|
|
1863
2015
|
case "number":
|
|
1864
|
-
return /* @__PURE__ */ (0,
|
|
2016
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(InputNumber, { placeholder: field.placeholder, min: field.validation?.min, max: field.validation?.max, style: { width: "100%" } });
|
|
1865
2017
|
case "select":
|
|
1866
|
-
return /* @__PURE__ */ (0,
|
|
2018
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Select, { placeholder: field.placeholder, options: field.options });
|
|
1867
2019
|
case "radio":
|
|
1868
|
-
return /* @__PURE__ */ (0,
|
|
2020
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Radio.Group, { options: field.options });
|
|
1869
2021
|
case "checkbox":
|
|
1870
|
-
return /* @__PURE__ */ (0,
|
|
2022
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Checkbox, {});
|
|
1871
2023
|
case "switch":
|
|
1872
|
-
return /* @__PURE__ */ (0,
|
|
2024
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Switch, {});
|
|
1873
2025
|
case "date":
|
|
1874
|
-
return /* @__PURE__ */ (0,
|
|
2026
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(DatePicker, { placeholder: field.placeholder, style: { width: "100%" } });
|
|
1875
2027
|
case "dateRange":
|
|
1876
|
-
return /* @__PURE__ */ (0,
|
|
2028
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(DatePicker.RangePicker, { placeholder: field.placeholder ? [field.placeholder, field.placeholder] : void 0, style: { width: "100%" } });
|
|
1877
2029
|
}
|
|
1878
2030
|
}
|
|
1879
|
-
var SchemaForm = (0,
|
|
2031
|
+
var SchemaForm = (0, import_react12.forwardRef)(function SchemaForm2({ schema, onSubmit, onChange, onFinish, onValuesChange, initialValues, layout = "vertical", ...formProps }, ref) {
|
|
1880
2032
|
const result = validateSchemaForm(schema);
|
|
1881
2033
|
if (!result.valid) throw new Error(`SchemaForm \u914D\u7F6E\u65E0\u6548\uFF1A${result.errors.map((issue) => `${issue.path} ${issue.message}`).join("\uFF1B")}`);
|
|
1882
2034
|
const defaults = schemaInitialValues(schema);
|
|
1883
|
-
return /* @__PURE__ */ (0,
|
|
2035
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
1884
2036
|
Form,
|
|
1885
2037
|
{
|
|
1886
2038
|
...formProps,
|
|
@@ -1898,7 +2050,7 @@ var SchemaForm = (0, import_react10.forwardRef)(function SchemaForm2({ schema, o
|
|
|
1898
2050
|
children: [
|
|
1899
2051
|
schema.fields.map((field) => {
|
|
1900
2052
|
const mapped = mapSchemaField(field);
|
|
1901
|
-
return /* @__PURE__ */ (0,
|
|
2053
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1902
2054
|
Form.Item,
|
|
1903
2055
|
{
|
|
1904
2056
|
name: mapped.name,
|
|
@@ -1911,7 +2063,7 @@ var SchemaForm = (0, import_react10.forwardRef)(function SchemaForm2({ schema, o
|
|
|
1911
2063
|
mapped.name
|
|
1912
2064
|
);
|
|
1913
2065
|
}),
|
|
1914
|
-
/* @__PURE__ */ (0,
|
|
2066
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Form.Item, { children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Button, { type: "primary", htmlType: "submit", children: schema.submitText ?? "\u63D0\u4EA4" }) })
|
|
1915
2067
|
]
|
|
1916
2068
|
}
|
|
1917
2069
|
);
|
|
@@ -1941,6 +2093,7 @@ var SchemaForm = (0, import_react10.forwardRef)(function SchemaForm2({ schema, o
|
|
|
1941
2093
|
ColorPicker,
|
|
1942
2094
|
ConfigProvider,
|
|
1943
2095
|
CrudScaffold,
|
|
2096
|
+
CrudWorkspace,
|
|
1944
2097
|
DataTable,
|
|
1945
2098
|
DatePicker,
|
|
1946
2099
|
Descriptions,
|
|
@@ -1987,6 +2140,7 @@ var SchemaForm = (0, import_react10.forwardRef)(function SchemaForm2({ schema, o
|
|
|
1987
2140
|
Steps,
|
|
1988
2141
|
Switch,
|
|
1989
2142
|
Table,
|
|
2143
|
+
TableControls,
|
|
1990
2144
|
TableEmpty,
|
|
1991
2145
|
Tabs,
|
|
1992
2146
|
Tag,
|