@jswork/antd-components 1.0.121 → 1.0.122
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 +13 -3
- package/dist/main.d.ts +13 -3
- package/dist/main.esm.js +1 -1
- package/dist/main.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/lib/table.tsx +44 -3
- package/src/main.ts +4 -2
package/package.json
CHANGED
package/src/lib/table.tsx
CHANGED
|
@@ -2,19 +2,21 @@
|
|
|
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
|
|
5
|
+
* @LastEditTime: 2025-10-23 17:02:49
|
|
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 { Table, TableProps
|
|
10
|
+
import { message, Space, Table, TableProps } from 'antd';
|
|
11
11
|
import cx from 'classnames';
|
|
12
|
-
import React from 'react';
|
|
12
|
+
import React, { FC } from 'react';
|
|
13
13
|
import nx from '@jswork/next';
|
|
14
14
|
import '@jswork/next-create-fetcher';
|
|
15
|
+
import { AcConfirmButton } from './confirm-button';
|
|
15
16
|
|
|
16
17
|
declare global {
|
|
17
18
|
interface NxStatic {
|
|
19
|
+
$event: any;
|
|
18
20
|
$nav: any;
|
|
19
21
|
$api: Record<string, any>;
|
|
20
22
|
}
|
|
@@ -22,6 +24,17 @@ declare global {
|
|
|
22
24
|
|
|
23
25
|
const CLASS_NAME = 'ac-table';
|
|
24
26
|
|
|
27
|
+
const locales = {
|
|
28
|
+
'zh-CN': {
|
|
29
|
+
edit: '编辑',
|
|
30
|
+
destroy: '删除',
|
|
31
|
+
},
|
|
32
|
+
'en-US': {
|
|
33
|
+
edit: 'Edit',
|
|
34
|
+
destroy: 'Destroy',
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
|
|
25
38
|
export type AcTableProps = TableProps & {
|
|
26
39
|
/**
|
|
27
40
|
* The identity name.
|
|
@@ -236,6 +249,34 @@ export type AcTableMainProps = Omit<AcTableProps, 'fetcher'> & {
|
|
|
236
249
|
totalPath?: string;
|
|
237
250
|
};
|
|
238
251
|
|
|
252
|
+
|
|
253
|
+
export type AcTableLinksProps = {
|
|
254
|
+
name: string;
|
|
255
|
+
model?: any;
|
|
256
|
+
lang?: string;
|
|
257
|
+
as?: React.ComponentType<any>;
|
|
258
|
+
noEdit?: boolean;
|
|
259
|
+
noDestroy?: boolean;
|
|
260
|
+
}
|
|
261
|
+
|
|
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
|
+
|
|
239
280
|
export const AcTableMain = React.forwardRef<any, AcTableMainProps>(
|
|
240
281
|
(props, ref) => {
|
|
241
282
|
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 } from './lib/table';
|
|
29
|
+
import { AcTable, AcTableMain, AcTableLinks } 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,7 +66,7 @@ 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 } from './lib/table';
|
|
69
|
+
import type { AcTableProps, AcTableMainProps, AcTableLinksProps } from './lib/table';
|
|
70
70
|
|
|
71
71
|
import '@jswork/next';
|
|
72
72
|
import './lib/alert';
|
|
@@ -122,6 +122,7 @@ export {
|
|
|
122
122
|
AcSwitch,
|
|
123
123
|
AcTable,
|
|
124
124
|
AcTableMain,
|
|
125
|
+
AcTableLinks,
|
|
125
126
|
AcTextarea,
|
|
126
127
|
AcTimePicker,
|
|
127
128
|
AcTransfer,
|
|
@@ -191,6 +192,7 @@ export {
|
|
|
191
192
|
AcSwitchProps,
|
|
192
193
|
AcTableProps,
|
|
193
194
|
AcTableMainProps,
|
|
195
|
+
AcTableLinksProps,
|
|
194
196
|
AcTextareaProps,
|
|
195
197
|
AcTimePickerProps,
|
|
196
198
|
AcTransferProps,
|