@jswork/antd-components 1.0.121 → 1.0.123

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jswork/antd-components",
3
- "version": "1.0.121",
3
+ "version": "1.0.123",
4
4
  "main": "dist/main.cjs.js",
5
5
  "module": "dist/main.esm.js",
6
6
  "types": "dist/main.d.ts",
@@ -0,0 +1,59 @@
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:09:33
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 onClick={handleDestroy}>{t('destroy')}</AcConfirmButton>,
53
+ };
54
+
55
+ return <AsComponent {...asProps}>
56
+ {nx.map(actions, (action) => links[action])}
57
+ </AsComponent>;
58
+ };
59
+
package/src/lib/table.tsx CHANGED
@@ -2,12 +2,12 @@
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 16:28:57
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 { Table, TableProps, message } from 'antd';
10
+ import { message, Table, TableProps } from 'antd';
11
11
  import cx from 'classnames';
12
12
  import React from 'react';
13
13
  import nx from '@jswork/next';
@@ -15,6 +15,7 @@ import '@jswork/next-create-fetcher';
15
15
 
16
16
  declare global {
17
17
  interface NxStatic {
18
+ $event: any;
18
19
  $nav: any;
19
20
  $api: Record<string, any>;
20
21
  }
@@ -236,6 +237,16 @@ export type AcTableMainProps = Omit<AcTableProps, 'fetcher'> & {
236
237
  totalPath?: string;
237
238
  };
238
239
 
240
+
241
+ export type AcTableLinksProps = {
242
+ name: string;
243
+ model?: any;
244
+ lang?: string;
245
+ as?: React.ComponentType<any>;
246
+ noEdit?: boolean;
247
+ noDestroy?: boolean;
248
+ }
249
+
239
250
  export const AcTableMain = React.forwardRef<any, AcTableMainProps>(
240
251
  (props, ref) => {
241
252
  const { name, dataPath, totalPath, ...rest } = {
package/src/main.ts CHANGED
@@ -73,6 +73,8 @@ 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
 
@@ -122,6 +124,7 @@ export {
122
124
  AcSwitch,
123
125
  AcTable,
124
126
  AcTableMain,
127
+ AcTableLinks,
125
128
  AcTextarea,
126
129
  AcTimePicker,
127
130
  AcTransfer,
@@ -191,6 +194,7 @@ export {
191
194
  AcSwitchProps,
192
195
  AcTableProps,
193
196
  AcTableMainProps,
197
+ AcTableLinksProps,
194
198
  AcTextareaProps,
195
199
  AcTimePickerProps,
196
200
  AcTransferProps,