perfs
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
import { MaybeRefOrGetter, computed, ref, toValue } from "vue";
|
||||
import { Component, DefineComponent, MaybeRefOrGetter, computed, ref, toValue } from "vue";
|
||||
|
||||
export type HeaderComponent = Component | DefineComponent | string;
|
||||
export type SortDirection = "asc" | "desc";
|
||||
export type UseSortOptions = {
|
||||
defaultSortKey?: string;
|
||||
defaultSortDirection?: SortDirection;
|
||||
ignoredColums?: MaybeRefOrGetter<string[]>;
|
||||
headerComponent?: HeaderComponent;
|
||||
};
|
||||
|
||||
export const useSort = <T>(array: MaybeRefOrGetter<T[]>, options?: UseSortOptions) => {
|
||||
@@ -19,7 +21,8 @@ export const useSort = <T>(array: MaybeRefOrGetter<T[]>, options?: UseSortOption
|
||||
onSort: sortBy,
|
||||
showColumn,
|
||||
currentSortKey: sortKey.value,
|
||||
sortDirection: sortDirection.value
|
||||
sortDirection: sortDirection.value,
|
||||
headerComponent: options?.headerComponent,
|
||||
}));
|
||||
|
||||
const sortedArray = computed(() => toValue(array).sort((a, b) => {
|
||||
|
||||
Reference in New Issue
Block a user