@jswork/antd-components 1.0.122 → 1.0.124
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 +17 -11
- package/dist/main.d.ts +17 -11
- package/dist/main.esm.js +1 -1
- package/dist/main.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/lib/table-links.tsx +58 -0
- package/src/lib/table.tsx +3 -33
- package/src/main.ts +4 -2
package/package.json
CHANGED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @Author: aric 1290657123@qq.com
|
|
3
|
+
* @Date: 2025-10-03 07:11:26
|
|
4
|
+
* @LastEditors: aric 1290657123@qq.com
|
|
5
|
+
* @LastEditTime: 2025-10-23 17:22:28
|
|
6
|
+
*/
|
|
7
|
+
import { Space } from 'antd';
|
|
8
|
+
import React, { FC } from 'react';
|
|
9
|
+
import nx from '@jswork/next';
|
|
10
|
+
import { AcConfirmButton } from './confirm-button';
|
|
11
|
+
|
|
12
|
+
declare global {
|
|
13
|
+
interface NxStatic {
|
|
14
|
+
$event: any;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const locales = {
|
|
19
|
+
'zh-CN': {
|
|
20
|
+
edit: '编辑',
|
|
21
|
+
destroy: '删除',
|
|
22
|
+
},
|
|
23
|
+
'en-US': {
|
|
24
|
+
edit: 'Edit',
|
|
25
|
+
destroy: 'Destroy',
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
export type AcTableLinksProps = {
|
|
31
|
+
name: string;
|
|
32
|
+
model?: any;
|
|
33
|
+
lang?: string;
|
|
34
|
+
as?: React.ComponentType<any>;
|
|
35
|
+
asProps?: React.ComponentType<any>;
|
|
36
|
+
actions?: string []
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const defaultLinks = {
|
|
40
|
+
lang: 'zh-CN',
|
|
41
|
+
actions: ['edit', 'destroy'],
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const AcTableLinks: FC<AcTableLinksProps> = (props) => {
|
|
45
|
+
const { name, as, lang, actions, model, asProps } = { ...defaultLinks, ...props };
|
|
46
|
+
const t = (key: string) => locales[lang][key];
|
|
47
|
+
const AsComponent = as || Space;
|
|
48
|
+
const handleEdit = () => nx.$event?.emit?.(`${name}:toEdit`, model);
|
|
49
|
+
const handleDestroy = () => nx.$event?.emit?.(`${name}:toDestroy`, model);
|
|
50
|
+
const links = {
|
|
51
|
+
edit: <a onClick={handleEdit}>{t('edit')}</a>,
|
|
52
|
+
destroy: <AcConfirmButton lang={lang} onClick={handleDestroy}>{t('destroy')}</AcConfirmButton>,
|
|
53
|
+
};
|
|
54
|
+
return <AsComponent {...asProps}>
|
|
55
|
+
{actions.map(((action) => links[action]))}
|
|
56
|
+
</AsComponent>;
|
|
57
|
+
};
|
|
58
|
+
|
package/src/lib/table.tsx
CHANGED
|
@@ -2,17 +2,16 @@
|
|
|
2
2
|
* @Author: aric 1290657123@qq.com
|
|
3
3
|
* @Date: 2025-10-03 07:11:26
|
|
4
4
|
* @LastEditors: aric 1290657123@qq.com
|
|
5
|
-
* @LastEditTime: 2025-10-23 17:
|
|
5
|
+
* @LastEditTime: 2025-10-23 17:07:52
|
|
6
6
|
*/
|
|
7
7
|
import type { EventMittNamespace } from '@jswork/event-mitt';
|
|
8
8
|
import { ReactHarmonyEvents } from '@jswork/harmony-events';
|
|
9
9
|
import UrlSyncFlat from '@jswork/url-sync-flat';
|
|
10
|
-
import { message,
|
|
10
|
+
import { message, Table, TableProps } from 'antd';
|
|
11
11
|
import cx from 'classnames';
|
|
12
|
-
import React
|
|
12
|
+
import React from 'react';
|
|
13
13
|
import nx from '@jswork/next';
|
|
14
14
|
import '@jswork/next-create-fetcher';
|
|
15
|
-
import { AcConfirmButton } from './confirm-button';
|
|
16
15
|
|
|
17
16
|
declare global {
|
|
18
17
|
interface NxStatic {
|
|
@@ -24,17 +23,6 @@ declare global {
|
|
|
24
23
|
|
|
25
24
|
const CLASS_NAME = 'ac-table';
|
|
26
25
|
|
|
27
|
-
const locales = {
|
|
28
|
-
'zh-CN': {
|
|
29
|
-
edit: '编辑',
|
|
30
|
-
destroy: '删除',
|
|
31
|
-
},
|
|
32
|
-
'en-US': {
|
|
33
|
-
edit: 'Edit',
|
|
34
|
-
destroy: 'Destroy',
|
|
35
|
-
},
|
|
36
|
-
};
|
|
37
|
-
|
|
38
26
|
export type AcTableProps = TableProps & {
|
|
39
27
|
/**
|
|
40
28
|
* The identity name.
|
|
@@ -259,24 +247,6 @@ export type AcTableLinksProps = {
|
|
|
259
247
|
noDestroy?: boolean;
|
|
260
248
|
}
|
|
261
249
|
|
|
262
|
-
const defaultLinks = {
|
|
263
|
-
lang: 'zh-CN',
|
|
264
|
-
noEdit: false,
|
|
265
|
-
noDestroy: false,
|
|
266
|
-
};
|
|
267
|
-
|
|
268
|
-
export const AcTableLinks: FC<AcTableLinksProps> = (props) => {
|
|
269
|
-
const { name, as, lang, noEdit, noDestroy, model } = { ...defaultLinks, ...props };
|
|
270
|
-
const t = (key: string) => locales[lang][key];
|
|
271
|
-
const AsComponent = as || Space;
|
|
272
|
-
const handleEdit = () => nx.$event.emit(`${name}:toEdit`, model);
|
|
273
|
-
const handleDestroy = () => nx.$event.emit(`${name}:toDestroy`, model);
|
|
274
|
-
return <AsComponent>
|
|
275
|
-
{!noEdit && (<a onClick={handleEdit}>{t('edit')}</a>)}
|
|
276
|
-
{!noDestroy && <AcConfirmButton onClick={handleDestroy}>{t('destroy')}</AcConfirmButton>}
|
|
277
|
-
</AsComponent>;
|
|
278
|
-
};
|
|
279
|
-
|
|
280
250
|
export const AcTableMain = React.forwardRef<any, AcTableMainProps>(
|
|
281
251
|
(props, ref) => {
|
|
282
252
|
const { name, dataPath, totalPath, ...rest } = {
|
package/src/main.ts
CHANGED
|
@@ -26,7 +26,7 @@ import { AcSelect, AcSelectFc } from './lib/select';
|
|
|
26
26
|
import { AcSlider, AcSliderFc } from './lib/slider';
|
|
27
27
|
import { AcSliderRange, AcSliderRangeFc } from './lib/slider-range';
|
|
28
28
|
import { AcSwitch, AcSwitchFc } from './lib/switch';
|
|
29
|
-
import { AcTable, AcTableMain
|
|
29
|
+
import { AcTable, AcTableMain } from './lib/table';
|
|
30
30
|
import { AcTextarea, AcTextareaFc } from './lib/textarea';
|
|
31
31
|
import { AcTimePicker, AcTimePickerFc } from './lib/time-picker';
|
|
32
32
|
import { AcTransfer, AcTransferFc } from './lib/transfer';
|
|
@@ -66,13 +66,15 @@ import type { AcTreeProps } from './lib/tree';
|
|
|
66
66
|
import type { AcTreeSelectProps } from './lib/tree-select';
|
|
67
67
|
import type { AcUploadDraggerProps } from './lib/upload-dragger';
|
|
68
68
|
import type { AcUploadProps } from './lib/upload';
|
|
69
|
-
import type { AcTableProps, AcTableMainProps
|
|
69
|
+
import type { AcTableProps, AcTableMainProps } from './lib/table';
|
|
70
70
|
|
|
71
71
|
import '@jswork/next';
|
|
72
72
|
import './lib/alert';
|
|
73
73
|
|
|
74
74
|
// commands
|
|
75
75
|
import useTableCommand from './lib/use-table-command';
|
|
76
|
+
import { AcTableLinks } from './lib/table-links';
|
|
77
|
+
import type { AcTableLinksProps } from './lib/table-links';
|
|
76
78
|
|
|
77
79
|
export * from './lib/button';
|
|
78
80
|
|