@amaoaaaaa/search-table 0.4.0 → 0.5.1

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.
@@ -74,8 +74,13 @@ export type SearchTableProps<T extends TableRow = any> = Omit<ProTableProps<T>,
74
74
  elPaginationProps?: SearchTablePaginationProps;
75
75
  /**
76
76
  * 默认排序
77
+ *
78
+ * @description
79
+ * 仅用于初始化排序状态,并随首次及后续请求以 `sort`、`order` 参数传给 `fetchFn`。
80
+ * 使用后端排序时,对应表格列需设置 `sortable: 'custom'`,且列的 `prop` 应与
81
+ * `sort` 保持一致;排序变化后组件会重新请求后端,由后端返回排序后的分页数据。
77
82
  */
78
- defaultSort?: SortState;
83
+ defaultSort?: SortState<T>;
79
84
  fetchFn: SearchTableFetchFn<T>;
80
85
  /**
81
86
  * 搜索参数处理函数
@@ -6,16 +6,16 @@ export interface SortState<T extends Record<string, any> = Record<string, any>>
6
6
  /**
7
7
  * 排序字段
8
8
  */
9
- sort: keyof T;
9
+ sort: Extract<keyof T, string>;
10
10
  }
11
- export interface UseTableSortOption {
12
- defaultSort?: SortState;
11
+ export interface UseTableSortOption<T extends Record<string, any> = Record<string, any>> {
12
+ defaultSort?: SortState<T>;
13
13
  fetchFn: () => void;
14
14
  onReset?: () => void;
15
15
  }
16
- export declare function useTableSort({ defaultSort, fetchFn, onReset }: UseTableSortOption): {
16
+ export declare function useTableSort<T extends Record<string, any> = Record<string, any>>({ defaultSort, fetchFn, onReset, }: UseTableSortOption<T>): {
17
17
  sortState: {
18
- order: "asc" | "desc";
18
+ order: "asc" | "desc" | "";
19
19
  sort: string;
20
20
  };
21
21
  onSortChange: ({ prop, order, }: {
package/dist/index.d.ts CHANGED
@@ -2,6 +2,7 @@ export { default as SearchTable } from './SearchTable/index.vue';
2
2
  export { default as SearchTableConfigProvider } from './SearchTable/ConfigProvider.vue';
3
3
  export { default as ProTable } from './ProTable/index.vue';
4
4
  export type { ProTableInstance } from './ProTable';
5
+ export type { SortState } from './SearchTable/useTableSort';
5
6
  export type { SearchTableProps, SearchTablePaginationProps, SearchTableSearchProps, SearchTableFetchFn, PageParams, PageResp, } from './SearchTable/types';
6
7
  export type { SearchTableInstance } from './SearchTable';
7
8
  export type { SearchTableConfigProviderProps } from './SearchTable/config';