crud-page-react 0.1.3 → 0.1.5
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 +1 -1
- package/dist/index.esm.js +9 -20
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +8 -19
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/index.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import { useState, useEffect, useRef, useCallback } from 'react';
|
|
3
3
|
import { DatePicker, Form, Row, Col, Space, Button, Input, Switch, Radio, Select, InputNumber, Tooltip, Popconfirm, Dropdown, Table, message, Tag, Modal, Divider, Card, Checkbox, Typography } from 'antd';
|
|
4
|
-
import { SearchOutlined, ReloadOutlined,
|
|
4
|
+
import { SearchOutlined, ReloadOutlined, EyeOutlined, EditOutlined, DeleteOutlined, CopyOutlined, MoreOutlined, FormOutlined, CodeOutlined, PlusOutlined } from '@ant-design/icons';
|
|
5
5
|
import dayjs from 'dayjs';
|
|
6
6
|
import customParseFormat from 'dayjs/plugin/customParseFormat';
|
|
7
7
|
|
|
@@ -251,24 +251,13 @@ function DynamicTable({ schema, data, loading, pagination, onView, onEdit, onDel
|
|
|
251
251
|
// 分离基础操作和自定义操作
|
|
252
252
|
const basicActions = actions.filter(action => action.type === 'view' || action.type === 'edit' || action.type === 'delete');
|
|
253
253
|
const customActions = actions.filter(action => action.type === 'custom');
|
|
254
|
-
//
|
|
255
|
-
const dropdownItems =
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
})),
|
|
262
|
-
...(customActions.length > 0 ? [{
|
|
263
|
-
type: 'divider',
|
|
264
|
-
}] : []),
|
|
265
|
-
{
|
|
266
|
-
key: 'copy-json',
|
|
267
|
-
label: '复制 JSON',
|
|
268
|
-
icon: jsx(CopyOutlined, {}),
|
|
269
|
-
onClick: () => copyJson(record),
|
|
270
|
-
}
|
|
271
|
-
];
|
|
254
|
+
// 构建下拉菜单项(仅包含自定义操作)
|
|
255
|
+
const dropdownItems = customActions.map(action => ({
|
|
256
|
+
key: action.key,
|
|
257
|
+
label: action.label,
|
|
258
|
+
onClick: () => onCustomAction === null || onCustomAction === void 0 ? void 0 : onCustomAction(action.key, record),
|
|
259
|
+
danger: action.danger,
|
|
260
|
+
}));
|
|
272
261
|
return (jsxs(Space, { size: 4, children: [basicActions.map((action) => {
|
|
273
262
|
var _a, _b, _c;
|
|
274
263
|
if (action.type === 'view') {
|
|
@@ -281,7 +270,7 @@ function DynamicTable({ schema, data, loading, pagination, onView, onEdit, onDel
|
|
|
281
270
|
return (jsx(Popconfirm, { title: (_b = (_a = action.confirm) === null || _a === void 0 ? void 0 : _a.title) !== null && _b !== void 0 ? _b : '确定删除?', description: (_c = action.confirm) === null || _c === void 0 ? void 0 : _c.content, onConfirm: () => onDelete(record), okText: "\u786E\u5B9A", cancelText: "\u53D6\u6D88", okButtonProps: { danger: true }, children: jsx(Tooltip, { title: action.label, children: jsx(Button, { type: "link", size: "small", danger: true, icon: jsx(DeleteOutlined, {}) }) }) }, action.key));
|
|
282
271
|
}
|
|
283
272
|
return null;
|
|
284
|
-
}), jsx(Dropdown, { menu: { items: dropdownItems }, trigger: ['click'], placement: "bottomRight", children: jsx(Tooltip, { title: "\u5176\u5B83\u64CD\u4F5C", children: jsx(Button, { type: "link", size: "small", icon: jsx(MoreOutlined, {}) }) }) })] }));
|
|
273
|
+
}), jsx(Tooltip, { title: "\u590D\u5236 JSON", children: jsx(Button, { type: "link", size: "small", icon: jsx(CopyOutlined, {}), onClick: () => copyJson(record) }) }), customActions.length > 0 && (jsx(Dropdown, { menu: { items: dropdownItems }, trigger: ['click'], placement: "bottomRight", children: jsx(Tooltip, { title: "\u5176\u5B83\u64CD\u4F5C", children: jsx(Button, { type: "link", size: "small", icon: jsx(MoreOutlined, {}) }) }) }))] }));
|
|
285
274
|
},
|
|
286
275
|
});
|
|
287
276
|
return (jsx(Table, { rowKey: (_a = schema.rowKey) !== null && _a !== void 0 ? _a : 'id', columns: columns, dataSource: data, loading: loading, scroll: { x: 'max-content' }, pagination: {
|