@qq1948037137/adminsmart-ui 0.1.27 → 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 +166 -47
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +36 -1
- package/dist/index.d.ts +36 -1
- package/dist/index.js +158 -40
- 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,
|
|
@@ -1375,9 +1376,126 @@ var SearchPanel = (0, import_react7.forwardRef)(function SearchPanel2({ fields,
|
|
|
1375
1376
|
] });
|
|
1376
1377
|
});
|
|
1377
1378
|
|
|
1378
|
-
// src/composites/
|
|
1379
|
+
// src/composites/TableControls.tsx
|
|
1380
|
+
var import_icons4 = require("@ant-design/icons");
|
|
1379
1381
|
var import_react8 = require("react");
|
|
1380
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");
|
|
1381
1499
|
function tableBodyHeight(availableHeight, chromeHeight) {
|
|
1382
1500
|
return Math.max(0, Math.floor(availableHeight - chromeHeight - 16));
|
|
1383
1501
|
}
|
|
@@ -1398,10 +1516,10 @@ function DataTableInner({
|
|
|
1398
1516
|
scroll,
|
|
1399
1517
|
...tableProps
|
|
1400
1518
|
}, ref) {
|
|
1401
|
-
const containerRef = (0,
|
|
1402
|
-
const [bodyHeight, setBodyHeight] = (0,
|
|
1519
|
+
const containerRef = (0, import_react9.useRef)(null);
|
|
1520
|
+
const [bodyHeight, setBodyHeight] = (0, import_react9.useState)(360);
|
|
1403
1521
|
const hasExplicitHeight = containerHeight != null || containerStyle?.height != null;
|
|
1404
|
-
(0,
|
|
1522
|
+
(0, import_react9.useLayoutEffect)(() => {
|
|
1405
1523
|
const container = containerRef.current;
|
|
1406
1524
|
if (!container || scroll?.y != null) return void 0;
|
|
1407
1525
|
const update = () => {
|
|
@@ -1435,14 +1553,14 @@ function DataTableInner({
|
|
|
1435
1553
|
y: scroll?.y ?? bodyHeight
|
|
1436
1554
|
};
|
|
1437
1555
|
const tablePagination = pagination === false ? false : pagination?.placement || pagination?.position ? pagination : { placement: ["bottomEnd"], ...pagination };
|
|
1438
|
-
return /* @__PURE__ */ (0,
|
|
1556
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1439
1557
|
"div",
|
|
1440
1558
|
{
|
|
1441
1559
|
ref: containerRef,
|
|
1442
1560
|
className: containerClassName,
|
|
1443
1561
|
"data-adminsmart-data-table": "true",
|
|
1444
1562
|
style: { width: "100%", minWidth: 0, overflowX: "hidden", ...containerHeight == null ? {} : { height: containerHeight, overflowY: "hidden" }, ...containerStyle },
|
|
1445
|
-
children: /* @__PURE__ */ (0,
|
|
1563
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1446
1564
|
Table,
|
|
1447
1565
|
{
|
|
1448
1566
|
...tableProps,
|
|
@@ -1454,11 +1572,11 @@ function DataTableInner({
|
|
|
1454
1572
|
}
|
|
1455
1573
|
);
|
|
1456
1574
|
}
|
|
1457
|
-
var DataTable = (0,
|
|
1575
|
+
var DataTable = (0, import_react9.forwardRef)(DataTableInner);
|
|
1458
1576
|
|
|
1459
1577
|
// src/composites/WorkspaceLayout.tsx
|
|
1460
1578
|
var import_antd46 = require("antd");
|
|
1461
|
-
var
|
|
1579
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1462
1580
|
var LIGHT_WORKSPACE_BACKGROUND = "#f6f9fe";
|
|
1463
1581
|
function WorkspaceLayout({
|
|
1464
1582
|
header,
|
|
@@ -1490,10 +1608,10 @@ function WorkspaceLayout({
|
|
|
1490
1608
|
"--adminsmart-workspace-bg": themeMode === "dark" ? token.colorBgLayout : LIGHT_WORKSPACE_BACKGROUND
|
|
1491
1609
|
// 夜间不复用日间固定底色。
|
|
1492
1610
|
};
|
|
1493
|
-
return /* @__PURE__ */ (0,
|
|
1494
|
-
/* @__PURE__ */ (0,
|
|
1495
|
-
/* @__PURE__ */ (0,
|
|
1496
|
-
/* @__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)(
|
|
1497
1615
|
Layout.Sider,
|
|
1498
1616
|
{
|
|
1499
1617
|
theme: themeMode,
|
|
@@ -1505,9 +1623,9 @@ function WorkspaceLayout({
|
|
|
1505
1623
|
children: sidebar
|
|
1506
1624
|
}
|
|
1507
1625
|
),
|
|
1508
|
-
/* @__PURE__ */ (0,
|
|
1626
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Layout, { className: "adminsmart-workspace__main", children: [
|
|
1509
1627
|
tabs,
|
|
1510
|
-
/* @__PURE__ */ (0,
|
|
1628
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Layout.Content, { className: contentClasses, "data-content-mode": contentMode, children }),
|
|
1511
1629
|
footer
|
|
1512
1630
|
] })
|
|
1513
1631
|
] })
|
|
@@ -1515,7 +1633,7 @@ function WorkspaceLayout({
|
|
|
1515
1633
|
}
|
|
1516
1634
|
|
|
1517
1635
|
// src/composites/CrudScaffold.tsx
|
|
1518
|
-
var
|
|
1636
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1519
1637
|
function CrudScaffold({
|
|
1520
1638
|
label,
|
|
1521
1639
|
description,
|
|
@@ -1527,16 +1645,16 @@ function CrudScaffold({
|
|
|
1527
1645
|
...props
|
|
1528
1646
|
}) {
|
|
1529
1647
|
const classes = ["adminsmart-crud", className].filter(Boolean).join(" ");
|
|
1530
|
-
return /* @__PURE__ */ (0,
|
|
1531
|
-
/* @__PURE__ */ (0,
|
|
1532
|
-
status ? /* @__PURE__ */ (0,
|
|
1533
|
-
/* @__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 }),
|
|
1534
1652
|
drawer
|
|
1535
1653
|
] });
|
|
1536
1654
|
}
|
|
1537
1655
|
|
|
1538
1656
|
// src/composites/EllipsisText.tsx
|
|
1539
|
-
var
|
|
1657
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1540
1658
|
function EllipsisText({
|
|
1541
1659
|
children,
|
|
1542
1660
|
maxWidth = 240,
|
|
@@ -1548,7 +1666,7 @@ function EllipsisText({
|
|
|
1548
1666
|
const classes = ["adminsmart-ellipsis-text", className].filter(Boolean).join(" ");
|
|
1549
1667
|
const widthValue = typeof maxWidth === "number" ? `${maxWidth}px` : maxWidth;
|
|
1550
1668
|
const textStyle = { "--adminsmart-ellipsis-width": widthValue, ...style };
|
|
1551
|
-
return /* @__PURE__ */ (0,
|
|
1669
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1552
1670
|
Typography.Text,
|
|
1553
1671
|
{
|
|
1554
1672
|
...props,
|
|
@@ -1561,14 +1679,14 @@ function EllipsisText({
|
|
|
1561
1679
|
}
|
|
1562
1680
|
|
|
1563
1681
|
// src/composites/RowActions.tsx
|
|
1564
|
-
var
|
|
1565
|
-
var
|
|
1566
|
-
var
|
|
1682
|
+
var import_icons5 = require("@ant-design/icons");
|
|
1683
|
+
var import_react10 = require("react");
|
|
1684
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1567
1685
|
function collectButtons(children) {
|
|
1568
1686
|
const actions = [];
|
|
1569
|
-
|
|
1570
|
-
if (!(0,
|
|
1571
|
-
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));
|
|
1572
1690
|
else {
|
|
1573
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");
|
|
1574
1692
|
if (!child.props.hidden) actions.push(child);
|
|
@@ -1594,9 +1712,9 @@ function RowActions({ children, maxVisible = 2, moreLabel = "\u66F4\u591A\u64CD\
|
|
|
1594
1712
|
// 菜单仍按官方语义标识需要确认的动作。
|
|
1595
1713
|
}));
|
|
1596
1714
|
const classes = ["adminsmart-row-action-group", className].filter(Boolean).join(" ");
|
|
1597
|
-
return /* @__PURE__ */ (0,
|
|
1715
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(Space, { ...props, className: classes, size, wrap, children: [
|
|
1598
1716
|
direct,
|
|
1599
|
-
overflow.length > 0 && /* @__PURE__ */ (0,
|
|
1717
|
+
overflow.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1600
1718
|
Dropdown,
|
|
1601
1719
|
{
|
|
1602
1720
|
trigger: ["click"],
|
|
@@ -1608,12 +1726,12 @@ function RowActions({ children, maxVisible = 2, moreLabel = "\u66F4\u591A\u64CD\
|
|
|
1608
1726
|
action.props.onClick?.(domEvent);
|
|
1609
1727
|
}
|
|
1610
1728
|
},
|
|
1611
|
-
children: /* @__PURE__ */ (0,
|
|
1729
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Tooltip, { title: moreLabel, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1612
1730
|
Button,
|
|
1613
1731
|
{
|
|
1614
1732
|
type: "text",
|
|
1615
1733
|
size: "small",
|
|
1616
|
-
icon: /* @__PURE__ */ (0,
|
|
1734
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_icons5.EllipsisOutlined, {}),
|
|
1617
1735
|
"aria-label": moreLabel,
|
|
1618
1736
|
"aria-haspopup": "menu",
|
|
1619
1737
|
"data-adminsmart-row-more": "true",
|
|
@@ -1627,7 +1745,7 @@ function RowActions({ children, maxVisible = 2, moreLabel = "\u66F4\u591A\u64CD\
|
|
|
1627
1745
|
|
|
1628
1746
|
// src/schema/SchemaForm.tsx
|
|
1629
1747
|
var import_dayjs = __toESM(require("dayjs"), 1);
|
|
1630
|
-
var
|
|
1748
|
+
var import_react11 = require("react");
|
|
1631
1749
|
|
|
1632
1750
|
// src/schema/model.ts
|
|
1633
1751
|
var FIELD_TYPES = /* @__PURE__ */ new Set([
|
|
@@ -1810,7 +1928,7 @@ function schemaInitialValues(schema) {
|
|
|
1810
1928
|
}
|
|
1811
1929
|
|
|
1812
1930
|
// src/schema/SchemaForm.tsx
|
|
1813
|
-
var
|
|
1931
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1814
1932
|
function fieldRules(field) {
|
|
1815
1933
|
const rules = [];
|
|
1816
1934
|
if (field.required) {
|
|
@@ -1855,32 +1973,32 @@ function dateItemProps(field) {
|
|
|
1855
1973
|
function renderControl(field) {
|
|
1856
1974
|
switch (field.type) {
|
|
1857
1975
|
case "input":
|
|
1858
|
-
return /* @__PURE__ */ (0,
|
|
1976
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Input, { placeholder: field.placeholder });
|
|
1859
1977
|
case "password":
|
|
1860
|
-
return /* @__PURE__ */ (0,
|
|
1978
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Input.Password, { placeholder: field.placeholder });
|
|
1861
1979
|
case "textarea":
|
|
1862
|
-
return /* @__PURE__ */ (0,
|
|
1980
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Input.TextArea, { placeholder: field.placeholder });
|
|
1863
1981
|
case "number":
|
|
1864
|
-
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%" } });
|
|
1865
1983
|
case "select":
|
|
1866
|
-
return /* @__PURE__ */ (0,
|
|
1984
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Select, { placeholder: field.placeholder, options: field.options });
|
|
1867
1985
|
case "radio":
|
|
1868
|
-
return /* @__PURE__ */ (0,
|
|
1986
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Radio.Group, { options: field.options });
|
|
1869
1987
|
case "checkbox":
|
|
1870
|
-
return /* @__PURE__ */ (0,
|
|
1988
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Checkbox, {});
|
|
1871
1989
|
case "switch":
|
|
1872
|
-
return /* @__PURE__ */ (0,
|
|
1990
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Switch, {});
|
|
1873
1991
|
case "date":
|
|
1874
|
-
return /* @__PURE__ */ (0,
|
|
1992
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(DatePicker, { placeholder: field.placeholder, style: { width: "100%" } });
|
|
1875
1993
|
case "dateRange":
|
|
1876
|
-
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%" } });
|
|
1877
1995
|
}
|
|
1878
1996
|
}
|
|
1879
|
-
var SchemaForm = (0,
|
|
1997
|
+
var SchemaForm = (0, import_react11.forwardRef)(function SchemaForm2({ schema, onSubmit, onChange, onFinish, onValuesChange, initialValues, layout = "vertical", ...formProps }, ref) {
|
|
1880
1998
|
const result = validateSchemaForm(schema);
|
|
1881
1999
|
if (!result.valid) throw new Error(`SchemaForm \u914D\u7F6E\u65E0\u6548\uFF1A${result.errors.map((issue) => `${issue.path} ${issue.message}`).join("\uFF1B")}`);
|
|
1882
2000
|
const defaults = schemaInitialValues(schema);
|
|
1883
|
-
return /* @__PURE__ */ (0,
|
|
2001
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
1884
2002
|
Form,
|
|
1885
2003
|
{
|
|
1886
2004
|
...formProps,
|
|
@@ -1898,7 +2016,7 @@ var SchemaForm = (0, import_react10.forwardRef)(function SchemaForm2({ schema, o
|
|
|
1898
2016
|
children: [
|
|
1899
2017
|
schema.fields.map((field) => {
|
|
1900
2018
|
const mapped = mapSchemaField(field);
|
|
1901
|
-
return /* @__PURE__ */ (0,
|
|
2019
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1902
2020
|
Form.Item,
|
|
1903
2021
|
{
|
|
1904
2022
|
name: mapped.name,
|
|
@@ -1911,7 +2029,7 @@ var SchemaForm = (0, import_react10.forwardRef)(function SchemaForm2({ schema, o
|
|
|
1911
2029
|
mapped.name
|
|
1912
2030
|
);
|
|
1913
2031
|
}),
|
|
1914
|
-
/* @__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" }) })
|
|
1915
2033
|
]
|
|
1916
2034
|
}
|
|
1917
2035
|
);
|
|
@@ -1987,6 +2105,7 @@ var SchemaForm = (0, import_react10.forwardRef)(function SchemaForm2({ schema, o
|
|
|
1987
2105
|
Steps,
|
|
1988
2106
|
Switch,
|
|
1989
2107
|
Table,
|
|
2108
|
+
TableControls,
|
|
1990
2109
|
TableEmpty,
|
|
1991
2110
|
Tabs,
|
|
1992
2111
|
Tag,
|