From 78ef9eb8341623c3c965fccdb44c3ecebce1e0a9 Mon Sep 17 00:00:00 2001 From: louis phi Date: Wed, 3 Dec 2025 23:50:59 +0700 Subject: [PATCH] add new prop initial sorting --- src/components/streaming-table/StreamingTable.tsx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/components/streaming-table/StreamingTable.tsx b/src/components/streaming-table/StreamingTable.tsx index fb2495e..fe36eee 100644 --- a/src/components/streaming-table/StreamingTable.tsx +++ b/src/components/streaming-table/StreamingTable.tsx @@ -36,6 +36,8 @@ export type StreamingTableProps = { initialPage?: number; /** Enable sorting (default: false) */ enableSorting?: boolean; + /** Initial sorting state (default: null) */ + initialSorting?: SortingState; } & Omit; const StreamingTable = (props: StreamingTableProps) => { @@ -52,14 +54,20 @@ const StreamingTable = (props: StreamingTableProps) => { "pageSize", "initialPage", "enableSorting", + "initialSorting", ]); const store: StreamingTableStore = createStreamingTableStore(); // Sorting state - const [sortingState, setSortingState] = createSignal({ - columnId: null, - direction: null, + const [sortingState, setSortingState] = createSignal( + local.initialSorting ?? { columnId: null, direction: null } + ); + + createEffect(() => { + if (local.initialSorting) { + setSortingState(local.initialSorting); + } }); const config = {