@qq1948037137/adminsmart-ui 0.1.32 → 0.1.34
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 +12 -0
- package/dist/index.cjs +122 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +29 -4
- package/dist/index.d.ts +29 -4
- package/dist/index.js +144 -27
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -61,6 +61,18 @@ function Example() {
|
|
|
61
61
|
|
|
62
62
|
`SessionReplay` 默认关闭鼠标轨迹。宿主传入 `mouseTrail` 与已录制的 rrweb `MouseMove` 事件后,播放器以主题主色显示原生轨迹。轨迹跟随录像坐标和播放倍率;拖动时间轴保留该时刻的鼠标位置。文档示例可实时开关轨迹。
|
|
63
63
|
|
|
64
|
+
`Input.TextArea` 默认至少显示五行,并随内容自动调整高度。需要固定行数可传 `rows`,需要自定义增高范围可传 `autoSize`。
|
|
65
|
+
|
|
66
|
+
## 表格序号和分页
|
|
67
|
+
|
|
68
|
+
`Table`、`DataTable` 默认把「序号」作为第一列业务数据,表头和内容均居中。选择框和独立展开控件保留其原生位置。内置分页默认每页 10 条,自动连续编号。业务页面单独调用后端分页时,把实际页码和每页条数传给序号列:
|
|
69
|
+
|
|
70
|
+
```jsx
|
|
71
|
+
<DataTable rowKey="id" dataSource={rows} columns={columns} pagination={false} rowNumber={{ current: pageNum, pageSize }} />
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
`rowNumber={false}` 用于保留自有编号或关闭子表序号。`rowNumber` 也可传 `title` 和数字 `width`。编号取当前表格显示顺序;数据主键和勾选状态仍通过 `rowKey` 管理。
|
|
75
|
+
|
|
64
76
|
## 首次发布与可信自动发布
|
|
65
77
|
|
|
66
78
|
GitHub 工作流通过仓库变量 `NPM_RELEASE_ENABLED` 控制发布;变量未设为 `true` 时,仅显示待设置通知。首次包不存在时,发布状态机只返回 `bootstrap-needed`,不猜版本、不创建版本提交。首次发布前应完成账号 2FA 和 npm CLI 登录,确认源码已提交到私有仓库 `1948037137/adminsmart-ui` 的当前 `main`,然后执行:
|
package/dist/index.cjs
CHANGED
|
@@ -349,10 +349,21 @@ var Form = Object.assign(wrapAntComponent(import_antd5.Form, "Form"), {
|
|
|
349
349
|
|
|
350
350
|
// src/components/Input.ts
|
|
351
351
|
var import_antd6 = require("antd");
|
|
352
|
+
var DEFAULT_TEXT_AREA_ROWS = 5;
|
|
353
|
+
function normalizeTextArea(props) {
|
|
354
|
+
if (props.rows !== void 0 || Object.hasOwn(props, "autoSize")) return props;
|
|
355
|
+
return {
|
|
356
|
+
...props,
|
|
357
|
+
rows: DEFAULT_TEXT_AREA_ROWS,
|
|
358
|
+
// 自动测量前也保持五行,避免初次显示时跳动。
|
|
359
|
+
autoSize: { minRows: DEFAULT_TEXT_AREA_ROWS }
|
|
360
|
+
// 由 Ant 随输入内容增减,不设行数上限。
|
|
361
|
+
};
|
|
362
|
+
}
|
|
352
363
|
var Input = Object.assign(wrapAntComponent(import_antd6.Input, "Input"), {
|
|
353
364
|
Group: wrapAntComponent(import_antd6.Input.Group, "Input.Group"),
|
|
354
365
|
Search: wrapAntComponent(import_antd6.Input.Search, "Input.Search"),
|
|
355
|
-
TextArea: wrapAntComponent(import_antd6.Input.TextArea, "Input.TextArea"),
|
|
366
|
+
TextArea: wrapAntComponent(import_antd6.Input.TextArea, "Input.TextArea", {}, normalizeTextArea),
|
|
356
367
|
Password: wrapAntComponent(import_antd6.Input.Password, "Input.Password"),
|
|
357
368
|
OTP: wrapAntComponent(import_antd6.Input.OTP, "Input.OTP")
|
|
358
369
|
});
|
|
@@ -373,6 +384,7 @@ var import_antd10 = require("antd");
|
|
|
373
384
|
var import_react3 = require("react");
|
|
374
385
|
|
|
375
386
|
// src/internal/paginationTotal.ts
|
|
387
|
+
var DEFAULT_PAGE_SIZE = 10;
|
|
376
388
|
function paginationTotal(total) {
|
|
377
389
|
return `\u5171 ${total} \u6761`;
|
|
378
390
|
}
|
|
@@ -407,19 +419,119 @@ function TableEmpty({ className, description = "\u6682\u65E0\u6570\u636E", image
|
|
|
407
419
|
}
|
|
408
420
|
|
|
409
421
|
// src/components/Table.ts
|
|
422
|
+
var ROW_NUMBER_KEY = "__adminsmart_row_number";
|
|
423
|
+
var DEFAULT_NUMBER_WIDTH = 64;
|
|
410
424
|
function normalizeTableProps(props) {
|
|
411
425
|
const locale = props.locale ?? {};
|
|
412
426
|
const content = locale.emptyText;
|
|
413
427
|
const emptyText = content === void 0 ? (0, import_react3.createElement)(TableEmpty) : typeof content === "string" || typeof content === "number" ? (0, import_react3.createElement)(TableEmpty, { description: content }) : content;
|
|
414
428
|
const pagination = props.pagination;
|
|
415
|
-
const tablePagination = pagination === false ? false : { showTotal: paginationTotal, ...pagination };
|
|
429
|
+
const tablePagination = pagination === false ? false : { defaultPageSize: DEFAULT_PAGE_SIZE, showTotal: paginationTotal, ...pagination };
|
|
416
430
|
return { ...props, locale: { ...locale, emptyText }, pagination: tablePagination };
|
|
417
431
|
}
|
|
432
|
+
function isControlColumn(column) {
|
|
433
|
+
return column === import_antd10.Table.SELECTION_COLUMN || column === import_antd10.Table.EXPAND_COLUMN;
|
|
434
|
+
}
|
|
435
|
+
function NumberedTable({ rowNumber = true, pagination, columns, children, dataSource, expandable, expandIconColumnIndex, onChange, scroll, ...props }) {
|
|
436
|
+
const nativePagination = pagination || void 0;
|
|
437
|
+
const [innerPage, setInnerPage] = (0, import_react3.useState)(() => ({
|
|
438
|
+
current: nativePagination?.defaultCurrent ?? 1,
|
|
439
|
+
// 未显式控制页码时跟踪 native Table 的切页结果。
|
|
440
|
+
size: nativePagination?.defaultPageSize ?? DEFAULT_PAGE_SIZE
|
|
441
|
+
// 以与 Ant 相同的首次实际页大小为准。
|
|
442
|
+
}));
|
|
443
|
+
const [, refreshTreeNumbers] = (0, import_react3.useState)(0);
|
|
444
|
+
const passedChildren = import_react3.Children.toArray(children).filter(import_react3.isValidElement);
|
|
445
|
+
const numberConfig = typeof rowNumber === "object" ? rowNumber : void 0;
|
|
446
|
+
const firstBusiness = columns?.findIndex((column) => !isControlColumn(column)) ?? 0;
|
|
447
|
+
if (!rowNumber || firstBusiness < 0 || columns == null && passedChildren.length === 0) {
|
|
448
|
+
return (0, import_react3.createElement)(import_antd10.Table, { ...props, pagination, columns, children, dataSource, expandable, expandIconColumnIndex, onChange, scroll });
|
|
449
|
+
}
|
|
450
|
+
const pageSize = numberConfig?.pageSize ?? nativePagination?.pageSize ?? innerPage.size;
|
|
451
|
+
const requestedPage = numberConfig?.current ?? (pagination === false ? 1 : nativePagination?.current ?? innerPage.current);
|
|
452
|
+
const maximumPage = pagination === false || numberConfig?.current != null ? requestedPage : Math.max(1, Math.ceil((nativePagination?.total || dataSource?.length || 0) / pageSize));
|
|
453
|
+
const current = Math.min(requestedPage, maximumPage);
|
|
454
|
+
const offset = (current - 1) * pageSize;
|
|
455
|
+
const width = numberConfig?.width ?? DEFAULT_NUMBER_WIDTH;
|
|
456
|
+
const childField = expandable?.childrenColumnName ?? props.childrenColumnName ?? "children";
|
|
457
|
+
const treeRows = Boolean(dataSource?.some((row) => row[childField]));
|
|
458
|
+
const visibleTreeOrder = treeRows ? /* @__PURE__ */ new WeakMap() : void 0;
|
|
459
|
+
const numberColumn = {
|
|
460
|
+
key: ROW_NUMBER_KEY,
|
|
461
|
+
// 序号列不占用宿主字段、不参与筛选或列显隐设置。
|
|
462
|
+
title: numberConfig?.title ?? "\u5E8F\u53F7",
|
|
463
|
+
// 空列表也显示序号表头。
|
|
464
|
+
width,
|
|
465
|
+
// 保证带选择按钮或横向滚动时列尺寸稳定。
|
|
466
|
+
align: "center",
|
|
467
|
+
// Ant 的新列表头和数据单元格一起居中。
|
|
468
|
+
className: "adminsmart-table-row-number",
|
|
469
|
+
// 可供宿主做视觉或无障碍验收的固定类名。
|
|
470
|
+
onCell: visibleTreeOrder ? (row, index) => {
|
|
471
|
+
if (index != null) visibleTreeOrder.set(row, index);
|
|
472
|
+
return {};
|
|
473
|
+
} : void 0,
|
|
474
|
+
render: (_value, row, index) => offset + (visibleTreeOrder?.get(row) ?? index) + 1
|
|
475
|
+
// 跟随排序、筛选及本页展开顺序。
|
|
476
|
+
};
|
|
477
|
+
const numberedColumns = columns == null ? void 0 : [...columns.slice(0, firstBusiness), numberColumn, ...columns.slice(firstBusiness)];
|
|
478
|
+
const numberedChildren = columns == null ? [(0, import_react3.createElement)(import_antd10.Table.Column, numberColumn), ...passedChildren] : children;
|
|
479
|
+
const nativeExpandIndex = expandable?.expandIconColumnIndex ?? expandIconColumnIndex;
|
|
480
|
+
const originalTreeIndex = nativeExpandIndex == null ? props.rowSelection ? 1 : 0 : props.rowSelection && nativeExpandIndex > 0 ? nativeExpandIndex - 1 : nativeExpandIndex;
|
|
481
|
+
const selectionBefore = props.rowSelection && !columns?.includes(import_antd10.Table.SELECTION_COLUMN) ? 1 : 0;
|
|
482
|
+
const actualIntro = firstBusiness + selectionBefore;
|
|
483
|
+
const shiftedTreeIndex = originalTreeIndex >= actualIntro ? originalTreeIndex + 1 : originalTreeIndex;
|
|
484
|
+
const nextExpandIndex = treeRows ? props.rowSelection && shiftedTreeIndex > 0 ? shiftedTreeIndex + 1 : shiftedTreeIndex : nativeExpandIndex != null && nativeExpandIndex > firstBusiness ? nativeExpandIndex + 1 : nativeExpandIndex;
|
|
485
|
+
const numberedExpandable = {
|
|
486
|
+
...expandable,
|
|
487
|
+
...nextExpandIndex == null ? {} : { expandIconColumnIndex: nextExpandIndex },
|
|
488
|
+
// 保留既有展开图标所在的业务列。
|
|
489
|
+
...treeRows ? {
|
|
490
|
+
onExpandedRowsChange: (keys) => {
|
|
491
|
+
refreshTreeNumbers((revision) => revision + 1);
|
|
492
|
+
if (expandable?.onExpandedRowsChange) expandable.onExpandedRowsChange(keys);
|
|
493
|
+
else props.onExpandedRowsChange?.([...keys]);
|
|
494
|
+
}
|
|
495
|
+
} : {}
|
|
496
|
+
// 只跟踪原生展开事件;宿主控制的展开键和回调仍照常执行。
|
|
497
|
+
};
|
|
498
|
+
const handleChange = (next, filters, sorter, extra) => {
|
|
499
|
+
if (pagination !== false) {
|
|
500
|
+
setInnerPage({
|
|
501
|
+
current: next.current ?? 1,
|
|
502
|
+
// Ant 的筛选过程会把当前页重置到 1。
|
|
503
|
+
size: next.pageSize ?? DEFAULT_PAGE_SIZE
|
|
504
|
+
// 原生切换每页条数会同步更新编号偏移。
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
onChange?.(next, filters, sorter, extra);
|
|
508
|
+
};
|
|
509
|
+
return (0, import_react3.createElement)(import_antd10.Table, {
|
|
510
|
+
...props,
|
|
511
|
+
pagination,
|
|
512
|
+
columns: numberedColumns,
|
|
513
|
+
children: numberedChildren,
|
|
514
|
+
dataSource,
|
|
515
|
+
expandable: treeRows || nextExpandIndex != null ? numberedExpandable : expandable,
|
|
516
|
+
onChange: handleChange,
|
|
517
|
+
scroll: typeof scroll?.x === "number" ? { ...scroll, x: scroll.x + width } : scroll
|
|
518
|
+
});
|
|
519
|
+
}
|
|
418
520
|
var Summary = Object.assign(wrapAntComponent(import_antd10.Table.Summary, "Table.Summary"), {
|
|
419
521
|
Row: wrapAntComponent(import_antd10.Table.Summary.Row, "Table.Summary.Row"),
|
|
420
522
|
Cell: wrapAntComponent(import_antd10.Table.Summary.Cell, "Table.Summary.Cell")
|
|
421
523
|
});
|
|
422
|
-
var Table = Object.assign(wrapAntComponent(
|
|
524
|
+
var Table = Object.assign(wrapAntComponent(NumberedTable, "Table", {}, normalizeTableProps), {
|
|
525
|
+
EXPAND_COLUMN: import_antd10.Table.EXPAND_COLUMN,
|
|
526
|
+
// 与 Ant 内部引用相同,否则不能识别占位列。
|
|
527
|
+
SELECTION_COLUMN: import_antd10.Table.SELECTION_COLUMN,
|
|
528
|
+
// 保留显式勾选列的位置控制。
|
|
529
|
+
SELECTION_ALL: import_antd10.Table.SELECTION_ALL,
|
|
530
|
+
// 透传原生全选选项。
|
|
531
|
+
SELECTION_INVERT: import_antd10.Table.SELECTION_INVERT,
|
|
532
|
+
// 透传原生反选选项。
|
|
533
|
+
SELECTION_NONE: import_antd10.Table.SELECTION_NONE,
|
|
534
|
+
// 透传原生清空选项。
|
|
423
535
|
Column: wrapAntComponent(import_antd10.Table.Column, "Table.Column"),
|
|
424
536
|
ColumnGroup: wrapAntComponent(import_antd10.Table.ColumnGroup, "Table.ColumnGroup"),
|
|
425
537
|
Summary
|
|
@@ -478,12 +590,17 @@ var ListItem = Object.assign(wrapAntComponent(import_antd13.List.Item, "List.Ite
|
|
|
478
590
|
});
|
|
479
591
|
function normalizeListProps(props) {
|
|
480
592
|
const pagination = props.pagination;
|
|
481
|
-
return pagination && typeof pagination === "object" ? { ...props, pagination: { showTotal: paginationTotal, ...pagination } } : props;
|
|
593
|
+
return pagination && typeof pagination === "object" ? { ...props, pagination: { defaultPageSize: DEFAULT_PAGE_SIZE, showTotal: paginationTotal, ...pagination } } : props;
|
|
482
594
|
}
|
|
483
595
|
var List = Object.assign(wrapAntComponent(import_antd13.List, "List", {}, normalizeListProps), {
|
|
484
596
|
Item: ListItem
|
|
485
597
|
});
|
|
486
|
-
var Pagination = wrapAntComponent(import_antd13.Pagination, "Pagination", {
|
|
598
|
+
var Pagination = wrapAntComponent(import_antd13.Pagination, "Pagination", {
|
|
599
|
+
defaultPageSize: DEFAULT_PAGE_SIZE,
|
|
600
|
+
// 宿主可用 pageSize 或 defaultPageSize 覆盖初始十条。
|
|
601
|
+
showTotal: paginationTotal
|
|
602
|
+
// 默认展示筛选后的完整记录数。
|
|
603
|
+
});
|
|
487
604
|
var Tree = Object.assign(wrapAntComponent(import_antd13.Tree, "Tree"), {
|
|
488
605
|
DirectoryTree: wrapAntComponent(import_antd13.Tree.DirectoryTree, "Tree.DirectoryTree"),
|
|
489
606
|
TreeNode: wrapAntComponent(import_antd13.Tree.TreeNode, "Tree.TreeNode")
|