@wordrhyme/auto-crud 1.12.1 → 1.13.0
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 +25 -11
- package/dist/index.cjs +302 -131
- package/dist/index.d.cts +75 -62
- package/dist/index.d.ts +61 -48
- package/dist/index.js +303 -133
- package/dist/styles.css +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -278,6 +278,8 @@ interface AutoCrudTableProps<TSchema> {
|
|
|
278
278
|
form?: {
|
|
279
279
|
overrides?: Record<string, any>; // 表单覆盖配置
|
|
280
280
|
columns?: number; // 表单列数
|
|
281
|
+
labelAlign?: 'left' | 'top' | 'right'; // 默认 top;left/right 为左右布局及标签文字对齐
|
|
282
|
+
labelWidth?: number | string; // 左右布局的标签宽度,数字单位为 px
|
|
281
283
|
};
|
|
282
284
|
/**
|
|
283
285
|
* 行操作配置,或统一配置 toolbar/row/batch。
|
|
@@ -1509,27 +1511,39 @@ function CustomTable({ data }) {
|
|
|
1509
1511
|
### 使用 AutoForm 组件
|
|
1510
1512
|
|
|
1511
1513
|
```typescript
|
|
1512
|
-
import { AutoForm
|
|
1513
|
-
import { createForm } from "@formily/core";
|
|
1514
|
+
import { AutoForm } from "@wordrhyme/auto-crud";
|
|
1514
1515
|
|
|
1515
1516
|
function CustomForm() {
|
|
1516
|
-
const form = createForm();
|
|
1517
|
-
const formSchema = createFormSchema(taskSchema, {
|
|
1518
|
-
exclude: ["id", "createdAt"],
|
|
1519
|
-
layout: "grid",
|
|
1520
|
-
gridColumns: 2,
|
|
1521
|
-
});
|
|
1522
|
-
|
|
1523
1517
|
return (
|
|
1524
1518
|
<AutoForm
|
|
1525
|
-
|
|
1526
|
-
|
|
1519
|
+
schema={taskSchema}
|
|
1520
|
+
gridColumns={2}
|
|
1527
1521
|
onSubmit={(values) => console.log(values)}
|
|
1528
1522
|
/>
|
|
1529
1523
|
);
|
|
1530
1524
|
}
|
|
1531
1525
|
```
|
|
1532
1526
|
|
|
1527
|
+
详情使用同一条 Formily 渲染链路,通过 `mode="view"` 启用 `readPretty`,无需传入 `onSubmit`,也不会显示提交按钮:
|
|
1528
|
+
|
|
1529
|
+
```tsx
|
|
1530
|
+
<AutoForm
|
|
1531
|
+
mode="view"
|
|
1532
|
+
schema={taskSchema}
|
|
1533
|
+
initialValues={selectedTask}
|
|
1534
|
+
fields={fields}
|
|
1535
|
+
gridColumns={2}
|
|
1536
|
+
/>
|
|
1537
|
+
```
|
|
1538
|
+
|
|
1539
|
+
创建、编辑排除 ID 和审计托管字段;详情保留 ID、创建时间和更新时间。`form: false` 和字段级 `form['x-hidden']` 只影响创建、编辑;全局 `hidden` 和 `permissions.deny` 仍限制详情字段。其他表单覆盖配置、布局、scope 和选项标签继续共用。
|
|
1540
|
+
|
|
1541
|
+
内置字段提供阅读态映射;通过 `components.register()` 注册的自定义组件应使用 Formily `mapReadPretty` 实现自己的阅读态。`AutoCrudTable` 详情仍展示当前选中记录,不会额外请求单条接口。
|
|
1542
|
+
|
|
1543
|
+
详情默认单列,列数由 `AutoCrudTable` 的 `form.columns` 或 `AutoForm` 的 `gridColumns` 控制,使用浅色标签和宽松间距;长文本、数组和对象默认占满整行,字段 `gridSpan` 可指定跨度。单选标签显示为文字,多选标签使用轻量徽标。长内容自动换行;弹窗最高为视口高度的 85%,超出后正文滚动,标题保持可见。
|
|
1544
|
+
|
|
1545
|
+
`AutoCrudTable` 的 `form.labelAlign` 和 `form.labelWidth` 同时作用于创建、编辑及详情弹窗。例如 `form={{ columns: 1, labelAlign: 'left', labelWidth: 100 }}` 表示单列、左侧标签文字左对齐,标签宽度为 100px。`top` 表示上下布局(默认),`right` 表示左侧标签文字右对齐;`labelWidth` 仅在 `left` / `right` 布局时生效。
|
|
1546
|
+
|
|
1533
1547
|
### 使用 useDataTable Hook
|
|
1534
1548
|
|
|
1535
1549
|
```typescript
|