diff --git a/src/components/Table.astro b/src/components/Table.astro index 9bf3312..40a47d2 100644 --- a/src/components/Table.astro +++ b/src/components/Table.astro @@ -18,6 +18,7 @@ const { tableClassNames = "", hideHeader = false, rowClick = "", + defaultSort = {}, } = Astro.props as TableProps; const id = `table-${Math.random().toString(36).slice(2, 9)}`; @@ -155,6 +156,7 @@ const id = `table-${Math.random().toString(36).slice(2, 9)}`; columnsRendererKey, classInfos, rowClick, + defaultSort, }} > const start = () => { @@ -173,7 +175,7 @@ const id = `table-${Math.random().toString(36).slice(2, 9)}`; let rowsPerPage = pagignations ? parseInt(pageSizeSelector.value) : 9999; - let sort = {}; // { key: "asc" | "desc" } + let sort = defaultSort; // { key: "asc" | "desc" } let totalRows = data.length; let currentData = [...data]; diff --git a/src/types/table/types.ts b/src/types/table/types.ts index cfbbb3e..b2b655f 100644 --- a/src/types/table/types.ts +++ b/src/types/table/types.ts @@ -38,6 +38,7 @@ export interface TableProps { tableClassNames?: string; hideHeader?: boolean; rowClick?: string; + defaultSort?: Record } export type Sort = {