@@ -11,7 +11,10 @@ import type {
1111import flattenJson from "./util/flatten-json" ;
1212import type { FlatJson } from "./util/flatten-json" ;
1313import { createFilterFunction } from "./util/filter-utils" ;
14- import { QueryParamsWatcher } from "./util/query-params" ;
14+ import {
15+ QueryParamsWatcher ,
16+ queryParamsToPartialConfig ,
17+ } from "./util/query-params" ;
1518
1619// Default pivot configuration
1720const DEFAULT_PIVOT_CONFIG : PivotConfig = {
@@ -75,6 +78,9 @@ export class GlobalState {
7578 this . appliedFilterConfig = this . filterConfig . slice ( ) ;
7679 makeAutoObservable ( this ) ;
7780 this . queryParamsWatcher = new QueryParamsWatcher ( this ) ;
81+
82+ // Apply query params from URL if they exist
83+ this . applyQueryParamsFromUrl ( ) ;
7884 }
7985
8086 // Computed getters for individual configs
@@ -243,6 +249,49 @@ export class GlobalState {
243249 this . isConnected = connected ;
244250 }
245251
252+ // Apply query params to global configuration
253+ applyQueryParams ( queryParams : Record < string , string > ) {
254+ debugger ;
255+ const partialConfig = queryParamsToPartialConfig ( queryParams ) ;
256+
257+ // Apply each section of the partial config
258+ if ( partialConfig . pivotConfig ) {
259+ this . updatePivotConfig ( partialConfig . pivotConfig ) ;
260+ }
261+
262+ if ( partialConfig . filterConfig ) {
263+ this . updateFilterConfig ( partialConfig . filterConfig ) ;
264+ }
265+
266+ if ( partialConfig . paginationConfig ) {
267+ this . updatePaginationConfig ( partialConfig . paginationConfig ) ;
268+ }
269+
270+ if ( partialConfig . sortConfig ) {
271+ this . updateSortConfig ( partialConfig . sortConfig ) ;
272+ }
273+ }
274+
275+ // Extract query params from URL and apply them to global configuration
276+ private applyQueryParamsFromUrl ( ) {
277+ if ( typeof window === "undefined" ) {
278+ return ; // Skip on server-side rendering
279+ }
280+
281+ const urlParams = new URLSearchParams ( window . location . search ) ;
282+ const queryParams : Record < string , string > = { } ;
283+
284+ // Convert URLSearchParams to Record<string, string>
285+ for ( const [ key , value ] of urlParams . entries ( ) ) {
286+ queryParams [ key ] = value ;
287+ }
288+
289+ // Only apply if there are query params
290+ if ( Object . keys ( queryParams ) . length > 0 ) {
291+ this . applyQueryParams ( queryParams ) ;
292+ }
293+ }
294+
246295 upsertRows ( dataset : EvaluationRow [ ] ) {
247296 runInAction ( ( ) => {
248297 this . isLoading = true ;
0 commit comments