@jswork/antd-components 1.0.178 → 1.0.180
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 -1
- package/dist/main.d.ts +17 -1
- package/dist/main.esm.js +1 -1
- package/dist/main.esm.js.map +1 -1
- package/package.json +4 -2
- package/src/lib/table-status-switcher.tsx +54 -0
- package/src/main.ts +4 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jswork/antd-components",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.180",
|
|
4
4
|
"main": "dist/main.cjs.js",
|
|
5
5
|
"module": "dist/main.esm.js",
|
|
6
6
|
"types": "dist/main.d.ts",
|
|
@@ -20,12 +20,14 @@
|
|
|
20
20
|
"@ant-design/icons": "*",
|
|
21
21
|
"@ebay/nice-form-react": "*",
|
|
22
22
|
"antd": "*",
|
|
23
|
-
"react-router-dom": "*"
|
|
23
|
+
"react-router-dom": "*",
|
|
24
|
+
"@jswork/react-ant-status-switch": "*"
|
|
24
25
|
},
|
|
25
26
|
"devDependencies": {
|
|
26
27
|
"@ant-design/icons": "^6.1.0",
|
|
27
28
|
"@ebay/nice-form-react": "^2.0.3",
|
|
28
29
|
"@jswork/harmony-events": "^1.2.11",
|
|
30
|
+
"@jswork/react-ant-status-switch": "^1.0.3",
|
|
29
31
|
"@jswork/next": "^1.4.2",
|
|
30
32
|
"@swc/core": "^1.3.93",
|
|
31
33
|
"@types/react": "^18.2.28",
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @Author: aric.zheng 1290657123@qq.com
|
|
3
|
+
* @Date: 2025-10-29 14:09:01
|
|
4
|
+
* @LastEditors: aric.zheng 1290657123@qq.com
|
|
5
|
+
* @LastEditTime: 2025-10-29 14:29:05
|
|
6
|
+
*/
|
|
7
|
+
import ReactAntStatusSwitch from '@jswork/react-ant-status-switch';
|
|
8
|
+
import React, { FC } from 'react';
|
|
9
|
+
import { ReactAntStatusSwitchProps } from '@jswork/react-ant-status-switch/dist/components';
|
|
10
|
+
import nx from '@jswork/next';
|
|
11
|
+
|
|
12
|
+
declare global {
|
|
13
|
+
interface NxStatic {
|
|
14
|
+
$api: Record<string, any>;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export type AcTableStatusSwitcherProps = ReactAntStatusSwitchProps & {
|
|
19
|
+
name: string;
|
|
20
|
+
items: any[];
|
|
21
|
+
model: any;
|
|
22
|
+
statusKey?: string;
|
|
23
|
+
rowKey?: string;
|
|
24
|
+
statusUpdateApi?: string;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const defaultProps = {
|
|
28
|
+
items: [],
|
|
29
|
+
rowKey: 'id',
|
|
30
|
+
status: 'status',
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const AcTableStatusSwitcher: FC<AcTableStatusSwitcherProps> = (props) => {
|
|
34
|
+
const { name, items, model, statusKey, rowKey, statusUpdateApi, ...rest } = { ...defaultProps, ...props };
|
|
35
|
+
const _apiPath = statusUpdateApi || `${name}_update`;
|
|
36
|
+
const handleStatusChange = (e) => {
|
|
37
|
+
const id = model.get(rowKey!);
|
|
38
|
+
const status = e.target.value;
|
|
39
|
+
const payload = { id, [statusKey!]: status };
|
|
40
|
+
nx.$event.emit(`${name}:draft`, { ...model, status });
|
|
41
|
+
nx.$api[_apiPath](payload).then(() => {
|
|
42
|
+
nx.$event.emit(`${name}:refresh`);
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<ReactAntStatusSwitch
|
|
48
|
+
items={items}
|
|
49
|
+
value={nx.get(model, statusKey!)}
|
|
50
|
+
onChange={handleStatusChange}
|
|
51
|
+
{...rest}
|
|
52
|
+
/>
|
|
53
|
+
);
|
|
54
|
+
};
|
package/src/main.ts
CHANGED
|
@@ -82,6 +82,8 @@ import { FormActions } from './lib/form-actions';
|
|
|
82
82
|
import type { FormActionsProps } from './lib/form-actions';
|
|
83
83
|
import { AcTableExtraSearch } from './lib/table-extra-search';
|
|
84
84
|
import type { AcTableExtraSearchProps } from './lib/table-extra-search';
|
|
85
|
+
import { AcTableStatusSwitcher } from './lib/table-status-switcher';
|
|
86
|
+
import type { AcTableStatusSwitcherProps } from './lib/table-status-switcher';
|
|
85
87
|
|
|
86
88
|
export * from './lib/button';
|
|
87
89
|
|
|
@@ -174,6 +176,7 @@ export {
|
|
|
174
176
|
AcUploadFc,
|
|
175
177
|
FormActions,
|
|
176
178
|
AcTableExtraSearch,
|
|
179
|
+
AcTableStatusSwitcher,
|
|
177
180
|
|
|
178
181
|
// ---- commands ----
|
|
179
182
|
useTableCommand,
|
|
@@ -213,6 +216,7 @@ export {
|
|
|
213
216
|
AcUploadProps,
|
|
214
217
|
FormActionsProps,
|
|
215
218
|
AcTableExtraSearchProps,
|
|
219
|
+
AcTableStatusSwitcherProps,
|
|
216
220
|
|
|
217
221
|
// ---- widgets ----
|
|
218
222
|
initWidgets,
|