ag-grid-url-sync 0.2.3 โ 0.3.0
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.
- package/README.md +302 -22
- package/dist/core/ag-grid-url-sync.d.ts +16 -1
- package/dist/core/ag-grid-url-sync.js +33 -3
- package/dist/core/ag-grid-url-sync.js.map +1 -1
- package/dist/core/grid-integration.js +40 -3
- package/dist/core/grid-integration.js.map +1 -1
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.js +2 -0
- package/dist/core/index.js.map +1 -1
- package/dist/core/serialization/formats.d.ts +29 -0
- package/dist/core/serialization/formats.js +87 -0
- package/dist/core/serialization/formats.js.map +1 -0
- package/dist/core/serialization/grouped.d.ts +36 -0
- package/dist/core/serialization/grouped.js +152 -0
- package/dist/core/serialization/grouped.js.map +1 -0
- package/dist/core/serialization/index.d.ts +7 -0
- package/dist/core/serialization/index.js +7 -0
- package/dist/core/serialization/index.js.map +1 -0
- package/dist/core/types.d.ts +71 -1
- package/dist/core/types.js +10 -0
- package/dist/core/types.js.map +1 -1
- package/dist/core/url-generator.js +57 -5
- package/dist/core/url-generator.js.map +1 -1
- package/dist/core/url-parser.js +12 -0
- package/dist/core/url-parser.js.map +1 -1
- package/dist/core/validation.d.ts +12 -1
- package/dist/core/validation.js +41 -2
- package/dist/core/validation.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/react/types.d.ts +12 -1
- package/dist/react/use-ag-grid-url-sync.js +34 -3
- package/dist/react/use-ag-grid-url-sync.js.map +1 -1
- package/package.json +18 -2
package/README.md
CHANGED
|
@@ -9,7 +9,8 @@ A lightweight TypeScript library for synchronizing AG Grid text and number filte
|
|
|
9
9
|
- ๐ **Complete text filter support** - All 8 AG Grid text operations (contains, equals, not contains, not equal, starts with, ends with, blank, not blank)
|
|
10
10
|
- ๐ข **Complete number filter support** - All 9 AG Grid number operations (equals, not equal, greater than, greater than or equal, less than, less than or equal, in range, blank, not blank)
|
|
11
11
|
- ๐ข **Complete date filter support** - All 9 AG Grid date operations (equals, not equal, before, before or equal, after, after or equal, in range, blank, not blank) with strict ISO date validation (YYYY-MM-DD)
|
|
12
|
-
-
|
|
12
|
+
- ๏ฟฝ **Grouped serialization** - Package all filters into a single URL parameter with querystring, JSON, or base64 encoding
|
|
13
|
+
- ๏ฟฝ๐ Manual URL generation for sharing filter states
|
|
13
14
|
- โ๏ธ Bidirectional sync between grid and URL
|
|
14
15
|
- ๐ ๏ธ Framework agnostic - works with any AG Grid setup
|
|
15
16
|
- โ๏ธ **React hook** - dedicated `useAGGridUrlSync` with state management
|
|
@@ -17,7 +18,7 @@ A lightweight TypeScript library for synchronizing AG Grid text and number filte
|
|
|
17
18
|
- ๐ฆ Graceful error handling with configurable error callbacks
|
|
18
19
|
- ๐งน Clean, human-readable URL format
|
|
19
20
|
- โก High performance - handles 100+ filters efficiently (<20ms)
|
|
20
|
-
- ๐ง Configurable URL prefixes
|
|
21
|
+
- ๐ง Configurable URL prefixes
|
|
21
22
|
- ๐ก๏ธ Robust edge case handling (special characters, malformed URLs)
|
|
22
23
|
- ๐ฆ Lightweight bundle size (~3KB gzipped)
|
|
23
24
|
|
|
@@ -256,6 +257,203 @@ urlSync.applyFilters({
|
|
|
256
257
|
urlSync.clearFilters()
|
|
257
258
|
```
|
|
258
259
|
|
|
260
|
+
## Grouped Serialization
|
|
261
|
+
|
|
262
|
+
Grouped serialization provides an alternative to individual URL parameters by packaging all filters into a single URL parameter. This is particularly useful for applications with many filters or when you need more compact URLs.
|
|
263
|
+
|
|
264
|
+
### Why Use Grouped Serialization?
|
|
265
|
+
|
|
266
|
+
**Individual serialization** (default):
|
|
267
|
+
|
|
268
|
+
```
|
|
269
|
+
https://app.com/data?f_name_contains=john&f_age_gt=25&f_salary_gte=80000&f_created_after=2024-01-01
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
**Grouped serialization**:
|
|
273
|
+
|
|
274
|
+
```
|
|
275
|
+
https://app.com/data?grid_filters=f_name_contains%3Djohn%26f_age_gt%3D25%26f_salary_gte%3D80000%26f_created_after%3D2024-01-01
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
Benefits of grouped serialization:
|
|
279
|
+
|
|
280
|
+
- **Cleaner URLs** with a single parameter instead of many
|
|
281
|
+
- **Better for sharing** - easier to copy/paste and less prone to URL manipulation
|
|
282
|
+
|
|
283
|
+
- **Format flexibility** - choose between querystring, JSON, or base64 encoding
|
|
284
|
+
- **Future-proof** - easier to extend with additional metadata
|
|
285
|
+
|
|
286
|
+
### Configuration
|
|
287
|
+
|
|
288
|
+
```typescript
|
|
289
|
+
interface AGGridUrlSyncConfig {
|
|
290
|
+
// Serialization mode
|
|
291
|
+
serialization?: 'individual' | 'grouped' // default: 'individual'
|
|
292
|
+
|
|
293
|
+
// Format for grouped serialization
|
|
294
|
+
format?: 'querystring' | 'json' | 'base64' // default: 'querystring'
|
|
295
|
+
|
|
296
|
+
// Parameter name for grouped mode
|
|
297
|
+
groupedParam?: string // default: 'grid_filters'
|
|
298
|
+
|
|
299
|
+
// ... other existing options
|
|
300
|
+
}
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
### Format Options
|
|
304
|
+
|
|
305
|
+
#### QueryString Format (Default)
|
|
306
|
+
|
|
307
|
+
Filters are URL-encoded as a query string within the parameter:
|
|
308
|
+
|
|
309
|
+
```typescript
|
|
310
|
+
const urlSync = createUrlSync(gridApi, {
|
|
311
|
+
serialization: 'grouped',
|
|
312
|
+
format: 'querystring' // default
|
|
313
|
+
})
|
|
314
|
+
|
|
315
|
+
// Result: ?grid_filters=f_name_contains%3Djohn%26f_age_gt%3D25
|
|
316
|
+
// Decoded: f_name_contains=john&f_age_gt=25
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
#### JSON Format
|
|
320
|
+
|
|
321
|
+
Filters are JSON-encoded, ideal for complex filter states:
|
|
322
|
+
|
|
323
|
+
```typescript
|
|
324
|
+
const urlSync = createUrlSync(gridApi, {
|
|
325
|
+
serialization: 'grouped',
|
|
326
|
+
format: 'json'
|
|
327
|
+
})
|
|
328
|
+
|
|
329
|
+
// Result: ?grid_filters=%7B%22name%22%3A%7B%22filterType%22%3A%22text%22...
|
|
330
|
+
// Decoded: {"name":{"filterType":"text","type":"contains","filter":"john"}...}
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
#### Base64 Format
|
|
334
|
+
|
|
335
|
+
Filters are JSON-encoded then base64-encoded for maximum compactness:
|
|
336
|
+
|
|
337
|
+
```typescript
|
|
338
|
+
const urlSync = createUrlSync(gridApi, {
|
|
339
|
+
serialization: 'grouped',
|
|
340
|
+
format: 'base64'
|
|
341
|
+
})
|
|
342
|
+
|
|
343
|
+
// Result: ?grid_filters=eyJuYW1lIjp7ImZpbHRlclR5cGUiOiJ0ZXh0Ii...
|
|
344
|
+
// Most compact representation, ideal for sharing
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
### Basic Usage
|
|
348
|
+
|
|
349
|
+
```typescript
|
|
350
|
+
import { createUrlSync } from 'ag-grid-url-sync'
|
|
351
|
+
|
|
352
|
+
// Basic grouped serialization
|
|
353
|
+
const urlSync = createUrlSync(gridApi, {
|
|
354
|
+
serialization: 'grouped'
|
|
355
|
+
})
|
|
356
|
+
|
|
357
|
+
// Generate grouped URL
|
|
358
|
+
const url = urlSync.generateUrl('https://app.com/data')
|
|
359
|
+
// Result: https://app.com/data?grid_filters=f_name_contains%3Djohn%26f_age_gt%3D25
|
|
360
|
+
|
|
361
|
+
// Apply filters from grouped URL
|
|
362
|
+
urlSync.applyFromUrl(url)
|
|
363
|
+
|
|
364
|
+
// Get current serialization mode and format
|
|
365
|
+
console.log(urlSync.getSerializationMode()) // 'grouped'
|
|
366
|
+
console.log(urlSync.getCurrentFormat()) // 'querystring'
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
### Advanced Examples
|
|
370
|
+
|
|
371
|
+
#### Format Conversion Utility
|
|
372
|
+
|
|
373
|
+
```typescript
|
|
374
|
+
// Convert current filters to any format
|
|
375
|
+
const jsonFormat = urlSync.getFiltersAsFormat('json')
|
|
376
|
+
const base64Format = urlSync.getFiltersAsFormat('base64')
|
|
377
|
+
const querystringFormat = urlSync.getFiltersAsFormat('querystring')
|
|
378
|
+
|
|
379
|
+
console.log('JSON:', jsonFormat)
|
|
380
|
+
console.log('Base64:', base64Format)
|
|
381
|
+
console.log('QueryString:', querystringFormat)
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
#### Dynamic Format Switching
|
|
385
|
+
|
|
386
|
+
```typescript
|
|
387
|
+
// Start with individual mode
|
|
388
|
+
const urlSync = createUrlSync(gridApi, {
|
|
389
|
+
serialization: 'individual'
|
|
390
|
+
})
|
|
391
|
+
|
|
392
|
+
// Switch to grouped mode when needed
|
|
393
|
+
const groupedSync = createUrlSync(gridApi, {
|
|
394
|
+
serialization: 'grouped',
|
|
395
|
+
format: 'base64',
|
|
396
|
+
groupedParam: 'filters'
|
|
397
|
+
})
|
|
398
|
+
|
|
399
|
+
// Use utility to maintain filters across mode changes
|
|
400
|
+
const currentFilters = urlSync.getFiltersAsFormat('json')
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
### Granular Import: Grouped Serialization
|
|
404
|
+
|
|
405
|
+
You can import grouped serialization utilities and format serializers directly for advanced use cases or custom integrations:
|
|
406
|
+
|
|
407
|
+
```typescript
|
|
408
|
+
import {
|
|
409
|
+
serializeGrouped,
|
|
410
|
+
deserializeGrouped
|
|
411
|
+
} from 'ag-grid-url-sync/serialization'
|
|
412
|
+
import {
|
|
413
|
+
QueryStringSerializer,
|
|
414
|
+
JsonSerializer,
|
|
415
|
+
Base64Serializer
|
|
416
|
+
} from 'ag-grid-url-sync/serialization/formats'
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
---
|
|
420
|
+
|
|
421
|
+
### Error Handling for Grouped Serialization
|
|
422
|
+
|
|
423
|
+
You can provide a custom error handler to gracefully handle malformed grouped parameters or serialization errors. The library will throw an `InvalidSerializationError` for invalid formats:
|
|
424
|
+
|
|
425
|
+
```typescript
|
|
426
|
+
import { InvalidSerializationError } from 'ag-grid-url-sync/types'
|
|
427
|
+
|
|
428
|
+
const urlSync = createUrlSync(gridApi, {
|
|
429
|
+
serialization: 'grouped',
|
|
430
|
+
format: 'json',
|
|
431
|
+
onParseError: error => {
|
|
432
|
+
if (error instanceof InvalidSerializationError) {
|
|
433
|
+
// Handle grouped serialization error
|
|
434
|
+
alert('Invalid filter data in URL!')
|
|
435
|
+
} else {
|
|
436
|
+
// Handle other errors
|
|
437
|
+
console.error(error)
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
})
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
### Exports
|
|
444
|
+
|
|
445
|
+
The package supports granular subpath exports for advanced usage and optimal bundle size:
|
|
446
|
+
|
|
447
|
+
- `ag-grid-url-sync/serialization` โ grouped serialization utilities
|
|
448
|
+
- `ag-grid-url-sync/serialization/formats` โ format-specific serializers
|
|
449
|
+
- `ag-grid-url-sync/validation` โ validation helpers
|
|
450
|
+
- `ag-grid-url-sync/url-parser` โ URL parsing utilities
|
|
451
|
+
- `ag-grid-url-sync/url-generator` โ URL generation utilities
|
|
452
|
+
- `ag-grid-url-sync/grid-integration` โ AG Grid integration helpers
|
|
453
|
+
- `ag-grid-url-sync/types` โ TypeScript types
|
|
454
|
+
|
|
455
|
+
Refer to the [package.json](./package.json) for the full export map.
|
|
456
|
+
|
|
259
457
|
## React Integration
|
|
260
458
|
|
|
261
459
|
For React applications, use the dedicated `useAGGridUrlSync` hook that provides a complete solution with React-specific features and state management.
|
|
@@ -360,7 +558,9 @@ const {
|
|
|
360
558
|
currentUrl,
|
|
361
559
|
hasFilters,
|
|
362
560
|
parseUrlFilters,
|
|
363
|
-
applyFilters
|
|
561
|
+
applyFilters,
|
|
562
|
+
getFiltersAsFormat,
|
|
563
|
+
getCurrentFormat
|
|
364
564
|
} = useAGGridUrlSync(gridApi, options)
|
|
365
565
|
```
|
|
366
566
|
|
|
@@ -376,22 +576,27 @@ interface UseAGGridUrlSyncOptions {
|
|
|
376
576
|
// React-specific options
|
|
377
577
|
autoApplyOnMount?: boolean // Default: false
|
|
378
578
|
enabledWhenReady?: boolean // Default: true
|
|
579
|
+
onError?: (error: Error, context: string) => void // Advanced error handling
|
|
379
580
|
}
|
|
380
581
|
```
|
|
381
582
|
|
|
382
583
|
#### Hook Return Values
|
|
383
584
|
|
|
384
|
-
| Property
|
|
385
|
-
|
|
|
386
|
-
| `shareUrl`
|
|
387
|
-
| `getQueryParams`
|
|
388
|
-
| `applyUrlFilters`
|
|
389
|
-
| `clearFilters`
|
|
390
|
-
| `isReady`
|
|
391
|
-
| `currentUrl`
|
|
392
|
-
| `hasFilters`
|
|
393
|
-
| `parseUrlFilters`
|
|
394
|
-
| `applyFilters`
|
|
585
|
+
| Property | Type | Description |
|
|
586
|
+
| -------------------- | -------------------------------- | ----------------------------------------------- | ---------------------------------------------------------- | -------------------------------------------------------------- |
|
|
587
|
+
| `shareUrl` | `(baseUrl?: string) => string` | Generate shareable URL with current filters |
|
|
588
|
+
| `getQueryParams` | `() => string` | Get filter state as query parameters |
|
|
589
|
+
| `applyUrlFilters` | `(url?: string) => void` | Apply filters from URL to grid |
|
|
590
|
+
| `clearFilters` | `() => void` | Clear all text filters |
|
|
591
|
+
| `isReady` | `boolean` | Whether grid API is available and hook is ready |
|
|
592
|
+
| `currentUrl` | `string` | Current URL with filters applied |
|
|
593
|
+
| `hasFilters` | `boolean` | Whether grid has any active text filters |
|
|
594
|
+
| `parseUrlFilters` | `(url: string) => FilterState` | Parse filters from URL without applying |
|
|
595
|
+
| `applyFilters` | `(filters: FilterState) => void` | Apply filter state object to grid |
|
|
596
|
+
| `getFiltersAsFormat` | `(format: 'querystring' | 'json' | 'base64') => string` | Serialize filters to any supported format (for sharing/export) |
|
|
597
|
+
| `getCurrentFormat` | `() => 'individual' | 'grouped'` | Get the current serialization mode (individual or grouped) |
|
|
598
|
+
|
|
599
|
+
> **Note:** `getFiltersAsFormat` and `getCurrentFormat` are especially useful for grouped serialization, format conversion, and advanced sharing scenarios.
|
|
395
600
|
|
|
396
601
|
### React Features
|
|
397
602
|
|
|
@@ -402,6 +607,66 @@ interface UseAGGridUrlSyncOptions {
|
|
|
402
607
|
- **๐ก๏ธ Error Boundaries**: Graceful error handling with configurable callbacks
|
|
403
608
|
- **๐ Filter Status**: `hasFilters` tracks whether any filters are active
|
|
404
609
|
|
|
610
|
+
### React with Grouped Serialization
|
|
611
|
+
|
|
612
|
+
The React hook fully supports grouped serialization with all format options:
|
|
613
|
+
|
|
614
|
+
```tsx
|
|
615
|
+
import React, { useState } from 'react'
|
|
616
|
+
import { AgGridReact } from 'ag-grid-react'
|
|
617
|
+
import { useAGGridUrlSync } from 'ag-grid-url-sync/react'
|
|
618
|
+
|
|
619
|
+
function AdvancedGridComponent() {
|
|
620
|
+
const [gridApi, setGridApi] = useState(null)
|
|
621
|
+
|
|
622
|
+
// Grouped serialization with base64 format
|
|
623
|
+
const { shareUrl, applyUrlFilters, clearFilters, hasFilters, isReady } =
|
|
624
|
+
useAGGridUrlSync(gridApi, {
|
|
625
|
+
serialization: 'grouped',
|
|
626
|
+
format: 'base64',
|
|
627
|
+
groupedParam: 'grid_state',
|
|
628
|
+
autoApplyOnMount: true
|
|
629
|
+
})
|
|
630
|
+
|
|
631
|
+
const handleShareCompact = async () => {
|
|
632
|
+
// Base64 format creates very compact URLs
|
|
633
|
+
const url = shareUrl()
|
|
634
|
+
await navigator.clipboard.writeText(url)
|
|
635
|
+
alert('Compact filter URL copied!')
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
const handleShareJSON = async () => {
|
|
639
|
+
// Get filters in JSON format for debugging
|
|
640
|
+
const jsonFilters = urlSync?.getFiltersAsFormat?.('json')
|
|
641
|
+
console.log('Current filters as JSON:', jsonFilters)
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
return (
|
|
645
|
+
<div>
|
|
646
|
+
<div style={{ marginBottom: '10px' }}>
|
|
647
|
+
<button onClick={handleShareCompact} disabled={!isReady}>
|
|
648
|
+
๐ Share Compact URL
|
|
649
|
+
</button>
|
|
650
|
+
<button onClick={handleShareJSON} disabled={!isReady}>
|
|
651
|
+
๐ Debug Filters
|
|
652
|
+
</button>
|
|
653
|
+
<button onClick={clearFilters} disabled={!hasFilters}>
|
|
654
|
+
๐๏ธ Clear Filters
|
|
655
|
+
</button>
|
|
656
|
+
</div>
|
|
657
|
+
|
|
658
|
+
{/* Grid component */}
|
|
659
|
+
<div className="ag-theme-alpine" style={{ height: 400, width: '100%' }}>
|
|
660
|
+
<AgGridReact
|
|
661
|
+
onGridReady={params => setGridApi(params.api)}
|
|
662
|
+
// ... grid configuration
|
|
663
|
+
/>
|
|
664
|
+
</div>
|
|
665
|
+
</div>
|
|
666
|
+
)
|
|
667
|
+
}
|
|
668
|
+
```
|
|
669
|
+
|
|
405
670
|
### Advanced React Example
|
|
406
671
|
|
|
407
672
|
```tsx
|
|
@@ -488,7 +753,7 @@ Mixed filters: https://app.com/page?f_name_contains=john&f_salary_gte=75000&f_ag
|
|
|
488
753
|
|
|
489
754
|
Parameter structure:
|
|
490
755
|
|
|
491
|
-
- Prefix: `f_` (configurable
|
|
756
|
+
- Prefix: `f_` (configurable)
|
|
492
757
|
- Format: `f_{columnName}_{operation}={value}`
|
|
493
758
|
- **Text Operations**: `contains`, `eq`, `neq`, `startsWith`, `endsWith`, `notContains`, `blank`, `notBlank`
|
|
494
759
|
- **Number Operations**: `eq`, `neq`, `gt`, `gte`, `lt`, `lte`, `range`, `blank`, `notBlank`
|
|
@@ -583,8 +848,22 @@ urlSync.destroy()
|
|
|
583
848
|
|
|
584
849
|
```typescript
|
|
585
850
|
interface AGGridUrlSyncConfig {
|
|
851
|
+
// Serialization mode (default: 'individual')
|
|
852
|
+
// 'individual': Each filter becomes a separate URL parameter
|
|
853
|
+
// 'grouped': All filters are packaged into a single URL parameter
|
|
854
|
+
serialization?: 'individual' | 'grouped'
|
|
855
|
+
|
|
856
|
+
// Format for grouped serialization (default: 'querystring')
|
|
857
|
+
// 'querystring': URL-encoded querystring format (most compatible)
|
|
858
|
+
// 'json': JSON-encoded format (good for complex filters)
|
|
859
|
+
// 'base64': Base64-encoded JSON (most compact)
|
|
860
|
+
format?: 'querystring' | 'json' | 'base64'
|
|
861
|
+
|
|
862
|
+
// Parameter name for grouped mode (default: 'grid_filters')
|
|
863
|
+
groupedParam?: string
|
|
864
|
+
|
|
586
865
|
// Prefix for URL parameters (default: 'f_')
|
|
587
|
-
//
|
|
866
|
+
// In grouped mode, this affects individual parameter names within the group
|
|
588
867
|
paramPrefix?: string
|
|
589
868
|
|
|
590
869
|
// Maximum length for filter values (default: 200)
|
|
@@ -607,12 +886,13 @@ Comprehensive demonstration showcasing all features:
|
|
|
607
886
|
- **Complete text filter support** - All 8 AG Grid text operations (contains, equals, not contains, not equal, starts with, ends with, blank, not blank)
|
|
608
887
|
- **Complete number filter support** - All 9 AG Grid number operations (equals, not equal, greater than, greater than or equal, less than, less than or equal, in range, blank, not blank)
|
|
609
888
|
- **Complete date filter support** - All 9 AG Grid date operations (equals, not equal, before, before or equal, after, after or equal, in range, blank, not blank)
|
|
610
|
-
- **
|
|
611
|
-
- **
|
|
612
|
-
- **
|
|
613
|
-
- **
|
|
614
|
-
- **
|
|
615
|
-
- **
|
|
889
|
+
- **Grouped serialization** - Package all filters into a single URL parameter with querystring, JSON, or base64 encoding
|
|
890
|
+
- **Manual URL generation** - Generate shareable URLs with current filter states
|
|
891
|
+
- **Bidirectional sync** - Automatic synchronization between AG Grid and URL
|
|
892
|
+
- **Framework agnostic** - Works with any AG Grid setup, no dependencies
|
|
893
|
+
- **High performance** - Efficiently handles 100+ filters with <20ms latency
|
|
894
|
+
- **Robust error handling** - Graceful handling of malformed URLs and special characters
|
|
895
|
+
- **Lightweight** - Minimal bundle size (~3KB gzipped), ideal for modern web applications
|
|
616
896
|
|
|
617
897
|
### โ๏ธ [React Integration](./examples/react-basic/basic-grid.tsx)
|
|
618
898
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { GridApi } from 'ag-grid-community';
|
|
2
|
-
import type { AGGridUrlSyncConfig, FilterState } from './types.js';
|
|
2
|
+
import type { AGGridUrlSyncConfig, FilterState, SerializationFormat, SerializationMode } from './types.js';
|
|
3
3
|
/**
|
|
4
4
|
* AGGridUrlSync class for synchronizing AG Grid text filters with URL parameters
|
|
5
5
|
*/
|
|
@@ -40,6 +40,21 @@ export declare class AGGridUrlSync {
|
|
|
40
40
|
* Cleans up any resources or event listeners
|
|
41
41
|
*/
|
|
42
42
|
destroy(): void;
|
|
43
|
+
/**
|
|
44
|
+
* Gets the current serialization mode
|
|
45
|
+
* @returns The current serialization mode
|
|
46
|
+
*/
|
|
47
|
+
getSerializationMode(): SerializationMode;
|
|
48
|
+
/**
|
|
49
|
+
* Gets the current format (for grouped mode)
|
|
50
|
+
* @returns The current format
|
|
51
|
+
*/
|
|
52
|
+
getCurrentFormat(): SerializationFormat; /**
|
|
53
|
+
* Gets filters in a specific format (useful for sharing/export)
|
|
54
|
+
* @param format - The format to serialize to
|
|
55
|
+
* @returns Serialized filter string
|
|
56
|
+
*/
|
|
57
|
+
getFiltersAsFormat(format: SerializationFormat): string;
|
|
43
58
|
}
|
|
44
59
|
/**
|
|
45
60
|
* Factory function to create a new AGGridUrlSync instance
|
|
@@ -2,6 +2,7 @@ import { DEFAULT_CONFIG } from './validation.js';
|
|
|
2
2
|
import { parseUrlFilters } from './url-parser.js';
|
|
3
3
|
import { generateUrl } from './url-generator.js';
|
|
4
4
|
import { getFilterModel, applyFilterModel } from './grid-integration.js';
|
|
5
|
+
import { serializeGrouped } from './serialization/grouped.js';
|
|
5
6
|
/**
|
|
6
7
|
* AGGridUrlSync class for synchronizing AG Grid text filters with URL parameters
|
|
7
8
|
*/
|
|
@@ -15,9 +16,8 @@ export class AGGridUrlSync {
|
|
|
15
16
|
constructor(gridApi, config = {}) {
|
|
16
17
|
this.config = {
|
|
17
18
|
gridApi,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
onParseError: config.onParseError ?? (() => { })
|
|
19
|
+
...DEFAULT_CONFIG,
|
|
20
|
+
...config
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
@@ -67,6 +67,36 @@ export class AGGridUrlSync {
|
|
|
67
67
|
destroy() {
|
|
68
68
|
// Currently no cleanup needed, but included for future use
|
|
69
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Gets the current serialization mode
|
|
72
|
+
* @returns The current serialization mode
|
|
73
|
+
*/
|
|
74
|
+
getSerializationMode() {
|
|
75
|
+
return this.config.serialization;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Gets the current format (for grouped mode)
|
|
79
|
+
* @returns The current format
|
|
80
|
+
*/
|
|
81
|
+
getCurrentFormat() {
|
|
82
|
+
return this.config.format;
|
|
83
|
+
} /**
|
|
84
|
+
* Gets filters in a specific format (useful for sharing/export)
|
|
85
|
+
* @param format - The format to serialize to
|
|
86
|
+
* @returns Serialized filter string
|
|
87
|
+
*/
|
|
88
|
+
getFiltersAsFormat(format) {
|
|
89
|
+
const filterState = getFilterModel(this.config);
|
|
90
|
+
// Create temporary config for the requested format
|
|
91
|
+
const tempConfig = {
|
|
92
|
+
...this.config,
|
|
93
|
+
format,
|
|
94
|
+
serialization: 'grouped'
|
|
95
|
+
};
|
|
96
|
+
// Use the serialization module
|
|
97
|
+
const result = serializeGrouped(filterState, tempConfig);
|
|
98
|
+
return result.value;
|
|
99
|
+
}
|
|
70
100
|
}
|
|
71
101
|
/**
|
|
72
102
|
* Factory function to create a new AGGridUrlSync instance
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ag-grid-url-sync.js","sourceRoot":"","sources":["../../src/core/ag-grid-url-sync.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ag-grid-url-sync.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AA;IAChC,CAAC;IAED;;;OAGG;IACH,YAAY,CAAC,WAAwB;QACnC,gBAAgB,CAAC,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;IAC5C,CAAC;IAED;;OAEG;IACH,YAAY;QACV,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,CAAA;IACvB,CAAC;IAED;;OAEG;IACH,OAAO;QACL,2DAA2D;IAC7D,CAAC;IAED;;;OAGG;IACH,oBAAoB;QAClB,OAAO,IAAI,CAAC,MAAM,CAAC,aAAa,CAAA;IAClC,CAAC;IAED;;;OAGG;IACH,gBAAgB;QACd,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAA;IAC3B,CAAC,CAAC;;;;OAIC;IACH,kBAAkB,CAAC,MAA2B;QAC5C,MAAM,WAAW,GAAG,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QAE/C,mDAAmD;QACnD,MAAM,UAAU,GAAG;YACjB,GAAG,IAAI,CAAC,MAAM;YACd,MAAM;YACN,aAAa,EAAE,SAAkB;SAClC,CAAA;QAED,+BAA+B;QAC/B,MAAM,MAAM,GAAG,gBAAgB,CAAC,WAAW,EAAE,UAAU,CAAC,CAAA;QAExD,OAAO,MAAM,CAAC,KAAK,CAAA;IACrB,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAC3B,OAAgB,EAChB,MAA4B;IAE5B,OAAO,IAAI,aAAa,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;AAC3C,CAAC"}
|
|
@@ -1,4 +1,23 @@
|
|
|
1
1
|
import { AG_GRID_OPERATION_NAMES, REVERSE_AG_GRID_OPERATION_NAMES, TEXT_FILTER_OPERATIONS, NUMBER_FILTER_OPERATIONS, DATE_FILTER_OPERATIONS } from './types.js';
|
|
2
|
+
// Map AG Grid number operations to our internal number operations
|
|
3
|
+
// Since AG Grid uses generic names, we need to be explicit about number operations
|
|
4
|
+
const AG_GRID_TO_NUMBER_OPERATION_MAP = {
|
|
5
|
+
lessThan: 'lessThan',
|
|
6
|
+
lessThanOrEqual: 'lessThanOrEqual',
|
|
7
|
+
greaterThan: 'greaterThan',
|
|
8
|
+
greaterThanOrEqual: 'greaterThanOrEqual',
|
|
9
|
+
inRange: 'inRange',
|
|
10
|
+
equals: 'eq',
|
|
11
|
+
notEqual: 'notEqual',
|
|
12
|
+
blank: 'blank',
|
|
13
|
+
notBlank: 'notBlank'
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Type guard to check if a value is a valid number operation key
|
|
17
|
+
*/
|
|
18
|
+
function isValidNumberOperation(operation) {
|
|
19
|
+
return Boolean(operation && operation in AG_GRID_TO_NUMBER_OPERATION_MAP);
|
|
20
|
+
}
|
|
2
21
|
/**
|
|
3
22
|
* Converts a date string to ISO format (YYYY-MM-DD)
|
|
4
23
|
* Handles both date strings and undefined values
|
|
@@ -87,14 +106,32 @@ export function getFilterModel(config) {
|
|
|
87
106
|
}
|
|
88
107
|
// Handle number filters
|
|
89
108
|
else if (filterType === 'number') {
|
|
90
|
-
//
|
|
91
|
-
|
|
109
|
+
// For number filters, we need to handle the mapping carefully since
|
|
110
|
+
// AG Grid uses the same operation names for numbers and dates
|
|
111
|
+
// Use the explicit number mapping instead of the reverse AG Grid mapping
|
|
112
|
+
const internalOperation = isValidNumberOperation(type)
|
|
113
|
+
? AG_GRID_TO_NUMBER_OPERATION_MAP[type]
|
|
114
|
+
: null;
|
|
115
|
+
// If the operation type is not recognized, report the error
|
|
116
|
+
if (!internalOperation) {
|
|
117
|
+
if (config.onParseError) {
|
|
118
|
+
config.onParseError(new Error(`Unknown number filter operation '${type}' for column '${column}'. ` +
|
|
119
|
+
`Supported operations: ${Object.keys(AG_GRID_TO_NUMBER_OPERATION_MAP).join(', ')}`));
|
|
120
|
+
}
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
92
123
|
// Use type predicate to validate and narrow the type
|
|
93
124
|
if (internalOperation && isNumberFilterOperation(internalOperation)) {
|
|
125
|
+
// Validate that the filter value is actually a number
|
|
126
|
+
const numericValue = typeof value === 'number' ? value : Number(value);
|
|
127
|
+
// Skip invalid number filters
|
|
128
|
+
if (isNaN(numericValue)) {
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
94
131
|
const numberFilter = {
|
|
95
132
|
filterType: 'number',
|
|
96
133
|
type: internalOperation, // Now properly typed as NumberFilterOperation
|
|
97
|
-
filter:
|
|
134
|
+
filter: numericValue
|
|
98
135
|
};
|
|
99
136
|
// Handle range operations
|
|
100
137
|
if (internalOperation === 'inRange' && typeof filterTo === 'number') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grid-integration.js","sourceRoot":"","sources":["../../src/core/grid-integration.ts"],"names":[],"mappings":"AAYA,OAAO,EACL,uBAAuB,EACvB,+BAA+B,EAC/B,sBAAsB,EACtB,wBAAwB,EACxB,sBAAsB,EACvB,MAAM,YAAY,CAAA;AAGnB;;;;GAIG;AACH,SAAS,eAAe,CAAC,GAAuB;IAC9C,IAAI,CAAC,GAAG;QAAE,OAAO,EAAE,CAAA;IACnB,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAA;IAC/C,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,EAAE,CAAA;AAC1C,CAAC;AAED;;GAEG;AACH,SAAS,qBAAqB,CAC5B,SAA0B;IAE1B,OAAO,sBAAsB,CAAC,QAAQ,CAAC,SAAgC,CAAC,CAAA;AAC1E,CAAC;AAED;;GAEG;AACH,SAAS,uBAAuB,CAC9B,SAA0B;IAE1B,OAAO,wBAAwB,CAAC,QAAQ,CAAC,SAAkC,CAAC,CAAA;AAC9E,CAAC;AAED;;GAEG;AACH,SAAS,qBAAqB,CAC5B,SAA0B;IAE1B,OAAO,sBAAsB,CAAC,QAAQ,CAAC,SAAgC,CAAC,CAAA;AAC1E,CAAC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gIAAgI,CAC7K,CAAA;gBACD,SAAQ;YACV,CAAC;YAED,IAAI,MAAM,CAAC,UAAU,KAAK,QAAQ,IAAI,YAAY,KAAK,QAAQ,EAAE,CAAC;gBAChE,OAAO,CAAC,IAAI,CACV,WAAW,MAAM,eAAe,YAAY,kIAAkI,CAC/K,CAAA;gBACD,SAAQ;YACV,CAAC;YAED,kCAAkC;YAClC,MAAM,YAAY,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAA;YAClD,IAAI,YAAY,EAAE,CAAC;gBACjB,KAAK,CAAC,MAAM,CAAC,GAAG,YAAY,CAAA;YAC9B,CAAC;QACH,CAAC;QAED,oCAAoC;QACpC,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,CAAA;IACtC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,MAAM,CAAC,YAAY,EAAE,CAAC;YACxB,MAAM,CAAC,YAAY,CAAC,KAAc,CAAC,CAAA;QACrC,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/dist/core/index.d.ts
CHANGED
|
@@ -4,3 +4,4 @@ export { validateFilterValue, DEFAULT_CONFIG } from './validation.js';
|
|
|
4
4
|
export { parseUrlFilters, parseFilterParam } from './url-parser.js';
|
|
5
5
|
export { serializeFilters, generateUrl } from './url-generator.js';
|
|
6
6
|
export { getFilterModel, applyFilterModel } from './grid-integration.js';
|
|
7
|
+
export * from './serialization/index.js';
|
package/dist/core/index.js
CHANGED
|
@@ -8,4 +8,6 @@ export { parseUrlFilters, parseFilterParam } from './url-parser.js';
|
|
|
8
8
|
export { serializeFilters, generateUrl } from './url-generator.js';
|
|
9
9
|
// AG Grid integration utilities
|
|
10
10
|
export { getFilterModel, applyFilterModel } from './grid-integration.js';
|
|
11
|
+
// Grouped serialization utilities
|
|
12
|
+
export * from './serialization/index.js';
|
|
11
13
|
//# sourceMappingURL=index.js.map
|
package/dist/core/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAEpE,cAAc,YAAY,CAAA;AAE1B,uBAAuB;AACvB,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAErE,wBAAwB;AACxB,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAEnE,2BAA2B;AAC3B,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAElE,gCAAgC;AAChC,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAEpE,cAAc,YAAY,CAAA;AAE1B,uBAAuB;AACvB,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAErE,wBAAwB;AACxB,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAEnE,2BAA2B;AAC3B,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAElE,gCAAgC;AAChC,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAExE,kCAAkC;AAClC,cAAc,0BAA0B,CAAA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { FilterState, SerializationFormat, FormatSerializer } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* QueryString format serializer
|
|
4
|
+
* Reuses existing URL generation logic but groups into single parameter
|
|
5
|
+
*/
|
|
6
|
+
export declare class QueryStringSerializer implements FormatSerializer {
|
|
7
|
+
readonly format: SerializationFormat;
|
|
8
|
+
serialize(filterState: FilterState): string;
|
|
9
|
+
deserialize(value: string): FilterState;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* JSON format serializer
|
|
13
|
+
* Serializes FilterState directly as JSON
|
|
14
|
+
*/
|
|
15
|
+
export declare class JsonSerializer implements FormatSerializer {
|
|
16
|
+
readonly format: SerializationFormat;
|
|
17
|
+
serialize(filterState: FilterState): string;
|
|
18
|
+
deserialize(value: string): FilterState;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Base64 format serializer
|
|
22
|
+
* JSON encoded then base64 encoded for maximum compactness
|
|
23
|
+
*/
|
|
24
|
+
export declare class Base64Serializer implements FormatSerializer {
|
|
25
|
+
readonly format: SerializationFormat;
|
|
26
|
+
private jsonSerializer;
|
|
27
|
+
serialize(filterState: FilterState): string;
|
|
28
|
+
deserialize(value: string): FilterState;
|
|
29
|
+
}
|