@jswork/antd-components 1.0.155 → 1.0.157
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/main.cjs.js +1 -1
- package/dist/main.d.mts +2 -0
- package/dist/main.d.ts +2 -0
- package/dist/main.esm.js +1 -1
- package/dist/main.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/lib/table-extras.tsx +3 -1
- package/src/lib/table-links.tsx +21 -11
package/package.json
CHANGED
package/src/lib/table-extras.tsx
CHANGED
|
@@ -19,6 +19,7 @@ export type AcTableExtrasProps = SpaceProps & {
|
|
|
19
19
|
name: string;
|
|
20
20
|
lang?: string;
|
|
21
21
|
as?: React.ComponentType<any>;
|
|
22
|
+
extra?: React.ReactNode;
|
|
22
23
|
asProps?: any;
|
|
23
24
|
actions?: string []
|
|
24
25
|
}
|
|
@@ -29,7 +30,7 @@ const defaultExtras = {
|
|
|
29
30
|
};
|
|
30
31
|
|
|
31
32
|
export const AcTableExtras: FC<AcTableExtrasProps> = (props) => {
|
|
32
|
-
const { name, lang, as, asProps, actions } = { ...defaultExtras, ...props };
|
|
33
|
+
const { name, lang, as, extra, asProps, actions } = { ...defaultExtras, ...props };
|
|
33
34
|
const handleRefresh = () => nx.$event?.emit?.(`${name}:reset`);
|
|
34
35
|
const handleAdd = () => nx.$event?.emit?.(`${name}:add`);
|
|
35
36
|
const handleBack = () => history.back();
|
|
@@ -43,6 +44,7 @@ export const AcTableExtras: FC<AcTableExtrasProps> = (props) => {
|
|
|
43
44
|
return (
|
|
44
45
|
<AsComponent {...asProps}>
|
|
45
46
|
{actions?.map((action) => <Fragment key={action}>{items[action]}</Fragment>)}
|
|
47
|
+
{extra}
|
|
46
48
|
</AsComponent>
|
|
47
49
|
);
|
|
48
50
|
};
|
package/src/lib/table-links.tsx
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
* @LastEditors: aric 1290657123@qq.com
|
|
5
5
|
* @LastEditTime: 2025-10-25 21:52:35
|
|
6
6
|
*/
|
|
7
|
+
import nx from '@jswork/next';
|
|
7
8
|
import { Space } from 'antd';
|
|
8
9
|
import React, { FC } from 'react';
|
|
9
|
-
import nx from '@jswork/next';
|
|
10
10
|
import { AcConfirmButton } from './confirm-button';
|
|
11
11
|
|
|
12
12
|
declare global {
|
|
@@ -26,15 +26,15 @@ const locales = {
|
|
|
26
26
|
},
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
-
|
|
30
29
|
export type AcTableLinksProps = {
|
|
31
30
|
name: string;
|
|
32
31
|
model?: any;
|
|
33
32
|
lang?: string;
|
|
33
|
+
extra?: React.ReactNode;
|
|
34
34
|
as?: React.ComponentType<any>;
|
|
35
35
|
asProps?: any;
|
|
36
|
-
actions?: string
|
|
37
|
-
}
|
|
36
|
+
actions?: string[];
|
|
37
|
+
};
|
|
38
38
|
|
|
39
39
|
const defaultProps = {
|
|
40
40
|
lang: 'zh-CN',
|
|
@@ -42,17 +42,27 @@ const defaultProps = {
|
|
|
42
42
|
};
|
|
43
43
|
|
|
44
44
|
export const AcTableLinks: FC<AcTableLinksProps> = (props) => {
|
|
45
|
-
const { name, as, lang, actions, model, asProps } = { ...defaultProps, ...props };
|
|
45
|
+
const { name, as, lang, actions, model, asProps, extra } = { ...defaultProps, ...props };
|
|
46
46
|
const t = (key: string) => locales[lang][key];
|
|
47
47
|
const AsComponent = as || Space;
|
|
48
48
|
const handleEdit = () => nx.$event?.emit?.(`${name}:edit`, model);
|
|
49
49
|
const handleDestroy = () => nx.$event?.emit?.(`${name}:destroy`, model);
|
|
50
50
|
const items = {
|
|
51
|
-
edit:
|
|
52
|
-
|
|
51
|
+
edit: (
|
|
52
|
+
<a key="edit" onClick={handleEdit}>
|
|
53
|
+
{t('edit')}
|
|
54
|
+
</a>
|
|
55
|
+
),
|
|
56
|
+
destroy: (
|
|
57
|
+
<AcConfirmButton key="destroy" type="anchor" lang={lang} onClick={handleDestroy}>
|
|
58
|
+
{t('destroy')}
|
|
59
|
+
</AcConfirmButton>
|
|
60
|
+
),
|
|
53
61
|
};
|
|
54
|
-
return
|
|
55
|
-
{
|
|
56
|
-
|
|
62
|
+
return (
|
|
63
|
+
<AsComponent {...asProps}>
|
|
64
|
+
{actions.map((action) => items[action])}
|
|
65
|
+
{extra}
|
|
66
|
+
</AsComponent>
|
|
67
|
+
);
|
|
57
68
|
};
|
|
58
|
-
|