@semi-kit/hooks 1.4.4 → 1.4.6
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/lib/selection.d.mts +14 -11
- package/lib/selection.mjs +1 -1
- package/package.json +1 -1
package/lib/selection.d.mts
CHANGED
|
@@ -1,23 +1,16 @@
|
|
|
1
1
|
import { Ref } from "vue";
|
|
2
|
-
import { RowData } from "naive-ui/es/data-table/src/interface";
|
|
3
2
|
type MixedArray = (string | number)[];
|
|
4
|
-
interface UseTableSelectionReturn {
|
|
3
|
+
interface UseTableSelectionReturn<T> {
|
|
5
4
|
/**
|
|
6
5
|
* 选择 key 列表
|
|
7
6
|
*/
|
|
8
7
|
selectedKeys: Ref<MixedArray>;
|
|
9
|
-
/**
|
|
10
|
-
* 获取行数据 key 值
|
|
11
|
-
* @param row - 行数据
|
|
12
|
-
* @returns key 值
|
|
13
|
-
*/
|
|
14
|
-
rowKey: (row: RowData) => any;
|
|
15
8
|
/**
|
|
16
9
|
* 选中项改变回调函数
|
|
17
10
|
* @param keys - 选中的 key 列表
|
|
18
11
|
* @param rows - 选中的行数据列表
|
|
19
12
|
*/
|
|
20
|
-
checkedChange: (keys: MixedArray, rows:
|
|
13
|
+
checkedChange: (keys: MixedArray, rows: T[]) => void;
|
|
21
14
|
/**
|
|
22
15
|
* 清空选中项
|
|
23
16
|
*/
|
|
@@ -31,7 +24,17 @@ interface UseTableSelectionReturn {
|
|
|
31
24
|
* 获取选中行数据列表
|
|
32
25
|
* @returns 选中数据列表
|
|
33
26
|
*/
|
|
34
|
-
getSelectedRows: () =>
|
|
27
|
+
getSelectedRows: () => T[];
|
|
28
|
+
/**
|
|
29
|
+
* 更新选中 key 列表
|
|
30
|
+
* @param keys - 新的 key 列表
|
|
31
|
+
*/
|
|
32
|
+
updateSelectedKeys: (keys: MixedArray) => void;
|
|
33
|
+
/**
|
|
34
|
+
* 更新选中行数据列表
|
|
35
|
+
* @param rows - 新的行数据列表
|
|
36
|
+
*/
|
|
37
|
+
updateSelectedRows: (rows: T[]) => void;
|
|
35
38
|
}
|
|
36
|
-
declare const useTableSelection: (
|
|
39
|
+
declare const useTableSelection: <T>() => UseTableSelectionReturn<T>;
|
|
37
40
|
export { UseTableSelectionReturn, useTableSelection };
|
package/lib/selection.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ref,toRaw}from"vue";const useTableSelection=
|
|
1
|
+
import{ref,toRaw}from"vue";const useTableSelection=()=>{let n=ref([]),r=ref([]);return{selectedKeys:n,clearSelected:()=>{n.value=[],r.value=[]},checkedChange:(e,t)=>{n.value=e,r.value=t},getSelectedKeys:()=>toRaw(n.value),getSelectedRows:()=>r.value?.map(e=>toRaw(e)),updateSelectedKeys:e=>n.value=e,updateSelectedRows:e=>r.value=e}};export{useTableSelection};
|