crud-page-react 0.2.0 → 0.2.1
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/dist/index.d.ts +15 -1
- package/dist/index.esm.js +44 -3
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +44 -3
- package/dist/index.js.map +1 -1
- package/dist/types/schema.d.ts +31 -1
- package/package.json +2 -3
package/dist/types/schema.d.ts
CHANGED
|
@@ -142,7 +142,12 @@ export interface ActionSchema {
|
|
|
142
142
|
danger?: boolean;
|
|
143
143
|
color?: string;
|
|
144
144
|
permission?: ActionPermission;
|
|
145
|
-
|
|
145
|
+
/**
|
|
146
|
+
* 操作按钮显示条件
|
|
147
|
+
* 支持字段值匹配:{ status: ['active', 'pending'] }
|
|
148
|
+
* 支持嵌套字段:{ 'user.role': ['admin'] }
|
|
149
|
+
*/
|
|
150
|
+
condition?: ActionCondition;
|
|
146
151
|
confirm?: {
|
|
147
152
|
title: string;
|
|
148
153
|
content?: string;
|
|
@@ -201,3 +206,28 @@ export declare function getNestedValue(obj: Record<string, unknown>, path: strin
|
|
|
201
206
|
* 'name' → null
|
|
202
207
|
*/
|
|
203
208
|
export declare function getFieldGroupPrefix(key: string): string | null;
|
|
209
|
+
/**
|
|
210
|
+
* 操作按钮显示条件配置
|
|
211
|
+
* 支持两种格式:
|
|
212
|
+
* 1. 字段值匹配:{ fieldName: [value1, value2] } - 当字段值在数组中时显示
|
|
213
|
+
* 2. 自定义表达式:{ expression: "record.status === 'active'" } - 使用表达式判断
|
|
214
|
+
*/
|
|
215
|
+
export interface ActionCondition {
|
|
216
|
+
[fieldName: string]: (string | number | boolean)[];
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* 检查操作按钮是否应该显示
|
|
220
|
+
*
|
|
221
|
+
* @param condition - 条件配置
|
|
222
|
+
* @param record - 当前行数据
|
|
223
|
+
* @returns 是否应该显示该操作
|
|
224
|
+
*
|
|
225
|
+
* @example
|
|
226
|
+
* // 字段值匹配
|
|
227
|
+
* shouldShowAction({ status: ['active', 'pending'] }, { status: 'active' }) → true
|
|
228
|
+
* shouldShowAction({ status: ['active', 'pending'] }, { status: 'deleted' }) → false
|
|
229
|
+
*
|
|
230
|
+
* // 支持嵌套字段(点分路径)
|
|
231
|
+
* shouldShowAction({ 'user.role': ['admin'] }, { user: { role: 'admin' } }) → true
|
|
232
|
+
*/
|
|
233
|
+
export declare function shouldShowAction(condition: ActionCondition | undefined, record: Record<string, unknown>): boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "crud-page-react",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "一个基于 React + Ant Design 的动态 CRUD 组件库,支持通过 JSON Schema 配置生成完整的增删改查界面",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
@@ -53,6 +53,5 @@
|
|
|
53
53
|
"tslib": "^2.8.1",
|
|
54
54
|
"typescript": "^5.3.3"
|
|
55
55
|
},
|
|
56
|
-
"dependencies": {
|
|
57
|
-
}
|
|
56
|
+
"dependencies": {}
|
|
58
57
|
}
|