@fe-free/core 1.4.0 → 1.4.3
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/CHANGELOG.md +13 -0
- package/package.json +3 -3
- package/src/crud/crud.stories.tsx +8 -0
- package/src/crud/crud.tsx +2 -0
- package/src/crud/crud_detail.tsx +60 -1
- package/src/crud/types.tsx +12 -0
- package/src/tailwind.config.js +0 -2
- package/src/tailwindcss.stories.tsx +0 -1
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fe-free/core",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"author": "",
|
|
@@ -28,7 +28,6 @@
|
|
|
28
28
|
"ahooks": "^3.7.8",
|
|
29
29
|
"axios": "^1.6.5",
|
|
30
30
|
"classnames": "^2.5.1",
|
|
31
|
-
"dayjs": "~1.11.10",
|
|
32
31
|
"lodash-es": "^4.17.21",
|
|
33
32
|
"react-ace": "^11.0.1",
|
|
34
33
|
"react-markdown": "^9.0.1",
|
|
@@ -36,11 +35,12 @@
|
|
|
36
35
|
"react-syntax-highlighter": "^15.5.0",
|
|
37
36
|
"vanilla-jsoneditor": "^0.23.1",
|
|
38
37
|
"zustand": "^4.5.4",
|
|
39
|
-
"@fe-free/tool": "1.4.
|
|
38
|
+
"@fe-free/tool": "1.4.3"
|
|
40
39
|
},
|
|
41
40
|
"peerDependencies": {
|
|
42
41
|
"@ant-design/pro-components": "^2.8.7",
|
|
43
42
|
"antd": "^5.25.1",
|
|
43
|
+
"dayjs": "~1.11.10",
|
|
44
44
|
"react": "^18.2.0"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
@@ -387,7 +387,13 @@ export const CustomText: Story = {
|
|
|
387
387
|
request: fakeRequest,
|
|
388
388
|
}}
|
|
389
389
|
createButton={<Button type="primary">新建</Button>}
|
|
390
|
+
createProps={{
|
|
391
|
+
submitText: '自定义新建确定',
|
|
392
|
+
resetText: '自定义新建取消',
|
|
393
|
+
}}
|
|
390
394
|
readProps={{
|
|
395
|
+
submitText: '自定义查看确定',
|
|
396
|
+
resetText: '自定义查看取消',
|
|
391
397
|
operateText: '查看',
|
|
392
398
|
}}
|
|
393
399
|
deleteProps={{
|
|
@@ -397,6 +403,8 @@ export const CustomText: Story = {
|
|
|
397
403
|
}}
|
|
398
404
|
updateProps={{
|
|
399
405
|
operateText: '编辑',
|
|
406
|
+
submitText: '自定义编辑确定',
|
|
407
|
+
resetText: '自定义编辑取消',
|
|
400
408
|
successText: '编辑成功',
|
|
401
409
|
}}
|
|
402
410
|
requestDeleteByRecord={fakeDeleteByRecord}
|
package/src/crud/crud.tsx
CHANGED
|
@@ -54,6 +54,7 @@ function CRUDComponent<
|
|
|
54
54
|
requestUpdateById,
|
|
55
55
|
detailFormInstance,
|
|
56
56
|
createProps,
|
|
57
|
+
readProps,
|
|
57
58
|
updateProps,
|
|
58
59
|
}),
|
|
59
60
|
[
|
|
@@ -63,6 +64,7 @@ function CRUDComponent<
|
|
|
63
64
|
requestUpdateById,
|
|
64
65
|
detailFormInstance,
|
|
65
66
|
createProps,
|
|
67
|
+
readProps,
|
|
66
68
|
updateProps,
|
|
67
69
|
],
|
|
68
70
|
);
|
package/src/crud/crud_detail.tsx
CHANGED
|
@@ -3,7 +3,7 @@ import { message, Spin } from 'antd';
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import { isString } from 'lodash-es';
|
|
5
5
|
import { useCallback, useMemo, useState } from 'react';
|
|
6
|
-
import type { CRUDProps } from './
|
|
6
|
+
import type { CRUDProps } from './types';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* create 创建
|
|
@@ -20,6 +20,7 @@ interface CRUDDetailProps
|
|
|
20
20
|
CRUDProps,
|
|
21
21
|
| 'requestGetByRecord'
|
|
22
22
|
| 'createProps'
|
|
23
|
+
| 'readProps'
|
|
23
24
|
| 'requestCreateByValues'
|
|
24
25
|
| 'updateProps'
|
|
25
26
|
| 'requestUpdateById'
|
|
@@ -44,6 +45,7 @@ function CRUDDetail(props: CRUDDetailProps) {
|
|
|
44
45
|
detailForm,
|
|
45
46
|
requestGetByRecord,
|
|
46
47
|
createProps,
|
|
48
|
+
readProps,
|
|
47
49
|
requestCreateByValues,
|
|
48
50
|
updateProps,
|
|
49
51
|
requestUpdateById,
|
|
@@ -170,6 +172,61 @@ function CRUDDetail(props: CRUDDetailProps) {
|
|
|
170
172
|
};
|
|
171
173
|
}, []);
|
|
172
174
|
|
|
175
|
+
const title = useMemo(() => {
|
|
176
|
+
if (action === 'create') {
|
|
177
|
+
return '新建';
|
|
178
|
+
}
|
|
179
|
+
if (action === 'read') {
|
|
180
|
+
return '查看';
|
|
181
|
+
}
|
|
182
|
+
if (action === 'update') {
|
|
183
|
+
return '编辑';
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return '';
|
|
187
|
+
}, [action]);
|
|
188
|
+
|
|
189
|
+
const submitter = useMemo(() => {
|
|
190
|
+
const result = {
|
|
191
|
+
searchConfig: {
|
|
192
|
+
submitText: '确定',
|
|
193
|
+
resetText: '取消',
|
|
194
|
+
},
|
|
195
|
+
};
|
|
196
|
+
if (action === 'create') {
|
|
197
|
+
if (createProps?.submitText) {
|
|
198
|
+
result.searchConfig.submitText = createProps.submitText;
|
|
199
|
+
}
|
|
200
|
+
if (createProps?.resetText) {
|
|
201
|
+
result.searchConfig.resetText = createProps.resetText;
|
|
202
|
+
}
|
|
203
|
+
} else if (action === 'read') {
|
|
204
|
+
if (readProps?.submitText) {
|
|
205
|
+
result.searchConfig.submitText = readProps.submitText;
|
|
206
|
+
}
|
|
207
|
+
if (readProps?.resetText) {
|
|
208
|
+
result.searchConfig.resetText = readProps.resetText;
|
|
209
|
+
}
|
|
210
|
+
} else if (action === 'update') {
|
|
211
|
+
if (updateProps?.submitText) {
|
|
212
|
+
result.searchConfig.submitText = updateProps.submitText;
|
|
213
|
+
}
|
|
214
|
+
if (updateProps?.resetText) {
|
|
215
|
+
result.searchConfig.resetText = updateProps.resetText;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
return result;
|
|
220
|
+
}, [
|
|
221
|
+
action,
|
|
222
|
+
createProps?.resetText,
|
|
223
|
+
createProps?.submitText,
|
|
224
|
+
readProps?.resetText,
|
|
225
|
+
readProps?.submitText,
|
|
226
|
+
updateProps?.resetText,
|
|
227
|
+
updateProps?.submitText,
|
|
228
|
+
]);
|
|
229
|
+
|
|
173
230
|
return (
|
|
174
231
|
<DrawerForm
|
|
175
232
|
form={form}
|
|
@@ -181,6 +238,8 @@ function CRUDDetail(props: CRUDDetailProps) {
|
|
|
181
238
|
readonly={action === 'read' && !!id}
|
|
182
239
|
// 关闭销毁,否则会有很奇怪的 onFinish 闭包问题,怀疑 pro components bug
|
|
183
240
|
drawerProps={drawerProps}
|
|
241
|
+
title={title}
|
|
242
|
+
submitter={submitter}
|
|
184
243
|
>
|
|
185
244
|
{children}
|
|
186
245
|
</DrawerForm>
|
package/src/crud/types.tsx
CHANGED
|
@@ -30,6 +30,10 @@ interface CRUDProps<DataSource = any, Key = string> {
|
|
|
30
30
|
createButton?: ReactNode;
|
|
31
31
|
/** create 更多设置 */
|
|
32
32
|
createProps?: {
|
|
33
|
+
/** 保存按钮文本 */
|
|
34
|
+
submitText?: string;
|
|
35
|
+
/** 重置按钮文本 */
|
|
36
|
+
resetText?: string;
|
|
33
37
|
/** 成功文案 */
|
|
34
38
|
successText?: string | (() => string);
|
|
35
39
|
};
|
|
@@ -59,6 +63,10 @@ interface CRUDProps<DataSource = any, Key = string> {
|
|
|
59
63
|
operateText?: string;
|
|
60
64
|
/** 打开方式, action 为 read_detail 有效 */
|
|
61
65
|
target?: '_blank';
|
|
66
|
+
/** 保存按钮文本 */
|
|
67
|
+
submitText?: string;
|
|
68
|
+
/** 重置按钮文本 */
|
|
69
|
+
resetText?: string;
|
|
62
70
|
};
|
|
63
71
|
|
|
64
72
|
// *** Update 更新 ***
|
|
@@ -70,6 +78,10 @@ interface CRUDProps<DataSource = any, Key = string> {
|
|
|
70
78
|
updateProps?: {
|
|
71
79
|
/** 文本 */
|
|
72
80
|
operateText?: string;
|
|
81
|
+
/** 保存按钮文本 */
|
|
82
|
+
submitText?: string;
|
|
83
|
+
/** 重置按钮文本 */
|
|
84
|
+
resetText?: string;
|
|
73
85
|
/** 成功文案 */
|
|
74
86
|
successText?: string | (() => string);
|
|
75
87
|
};
|
package/src/tailwind.config.js
CHANGED
|
@@ -11,7 +11,6 @@ export const Default = () => {
|
|
|
11
11
|
<span className="text-primary">text-primary</span>
|
|
12
12
|
<span className="text-secondary">text-secondary</span>
|
|
13
13
|
<span className="text-desc">text-desc</span>
|
|
14
|
-
<span className="text-price">text-price</span>
|
|
15
14
|
</div>
|
|
16
15
|
</div>
|
|
17
16
|
);
|