crud-page-react 0.1.5 → 0.2.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 +33 -0
- package/dist/components/CrudPage.d.ts +3 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.esm.js +18 -13
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +20 -12
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4,8 +4,12 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
4
4
|
var react = require('react');
|
|
5
5
|
var antd = require('antd');
|
|
6
6
|
var icons = require('@ant-design/icons');
|
|
7
|
+
var zhCN = require('antd/locale/zh_CN');
|
|
7
8
|
var dayjs = require('dayjs');
|
|
8
9
|
var customParseFormat = require('dayjs/plugin/customParseFormat');
|
|
10
|
+
var en_US = require('antd/locale/en_US');
|
|
11
|
+
var ja_JP = require('antd/locale/ja_JP');
|
|
12
|
+
var ko_KR = require('antd/locale/ko_KR');
|
|
9
13
|
|
|
10
14
|
/* ─── 工具函数 ──────────────────────────────────────── */
|
|
11
15
|
/**
|
|
@@ -864,7 +868,7 @@ function extractListResponse(json) {
|
|
|
864
868
|
}
|
|
865
869
|
return { list: [], total: 0 };
|
|
866
870
|
}
|
|
867
|
-
const CrudPage = ({ schema, initialData = [], apiRequest: customApiRequest }) => {
|
|
871
|
+
const CrudPage = ({ schema, initialData = [], apiRequest: customApiRequest, locale = zhCN }) => {
|
|
868
872
|
var _a;
|
|
869
873
|
const rowKey = schema.rowKey || 'id';
|
|
870
874
|
// 使用传入的apiRequest或默认的
|
|
@@ -1148,19 +1152,23 @@ const CrudPage = ({ schema, initialData = [], apiRequest: customApiRequest }) =>
|
|
|
1148
1152
|
}, [
|
|
1149
1153
|
request, modalState.mode, schema.api, fetchList, messageApi,
|
|
1150
1154
|
]);
|
|
1151
|
-
return (jsxRuntime.jsxs("div", { style: { padding: 24, background: '#f5f6fa', minHeight: '100vh' }, children: [contextHolder, jsxRuntime.jsxs("div", { style: { display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 16 }, children: [jsxRuntime.jsx(Title, { level: 4, style: { margin: 0 }, children: schema.title }), schema.api.create && (jsxRuntime.jsx(antd.Button, { type: "primary", icon: jsxRuntime.jsx(icons.PlusOutlined, {}), onClick: () => setModalState({ open: true, mode: 'create', record: undefined }), children: schema.createButtonLabel || '新增' }))] }), jsxRuntime.jsx(DynamicFilter, { schema: schema, onSearch: handleSearch, onReset: () => handleSearch({}) }), jsxRuntime.jsx(DynamicTable, { schema: schema, data: data, loading: loading, pagination: {
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1155
|
+
return (jsxRuntime.jsx(antd.ConfigProvider, { locale: locale, children: jsxRuntime.jsxs("div", { style: { padding: 24, background: '#f5f6fa', minHeight: '100vh' }, children: [contextHolder, jsxRuntime.jsxs("div", { style: { display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 16 }, children: [jsxRuntime.jsx(Title, { level: 4, style: { margin: 0 }, children: schema.title }), schema.api.create && (jsxRuntime.jsx(antd.Button, { type: "primary", icon: jsxRuntime.jsx(icons.PlusOutlined, {}), onClick: () => setModalState({ open: true, mode: 'create', record: undefined }), children: schema.createButtonLabel || '新增' }))] }), jsxRuntime.jsx(DynamicFilter, { schema: schema, onSearch: handleSearch, onReset: () => handleSearch({}) }), jsxRuntime.jsx(DynamicTable, { schema: schema, data: data, loading: loading, pagination: {
|
|
1156
|
+
current: page,
|
|
1157
|
+
pageSize,
|
|
1158
|
+
total,
|
|
1159
|
+
onChange: handlePageChange,
|
|
1160
|
+
}, onView: (record) => handleAction({ key: 'view', label: '查看', type: 'view' }, record), onEdit: (record) => handleAction({ key: 'edit', label: '编辑', type: 'edit' }, record), onDelete: (record) => handleDelete(record), onCustomAction: (actionKey, record) => {
|
|
1161
|
+
var _a;
|
|
1162
|
+
const action = (_a = schema.actions) === null || _a === void 0 ? void 0 : _a.find(a => a.key === actionKey);
|
|
1163
|
+
if (action)
|
|
1164
|
+
handleAction(action, record);
|
|
1165
|
+
} }), jsxRuntime.jsx(DynamicForm, { schema: schema, visible: modalState.open, mode: modalState.mode, initialValues: modalState.record, onSubmit: handleFormOk, onCancel: () => setModalState({ open: false, mode: 'create' }) })] }) }));
|
|
1162
1166
|
};
|
|
1163
1167
|
|
|
1168
|
+
exports.zhCN = zhCN;
|
|
1169
|
+
exports.enUS = en_US;
|
|
1170
|
+
exports.jaJP = ja_JP;
|
|
1171
|
+
exports.koKR = ko_KR;
|
|
1164
1172
|
exports.BUILTIN_RULES = BUILTIN_RULES;
|
|
1165
1173
|
exports.CrudPage = CrudPage;
|
|
1166
1174
|
exports.DynamicFilter = DynamicFilter;
|