Skip to content

Commit 1cfbad7

Browse files
committed
docs: update docs for filtering and improve version generation
1 parent 4857b5d commit 1cfbad7

File tree

6 files changed

+69
-5
lines changed

6 files changed

+69
-5
lines changed

sites/docs/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ node_modules
99
/build
1010
/.velite
1111

12+
# Generated files
13+
src/lib/shared/config/version.ts
14+
1215
# OS
1316
.DS_Store
1417
Thumbs.db

sites/docs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"dev": "vite dev",
1414
"build": "velite && vite build",
1515
"preview": "vite preview",
16-
"prepare": "svelte-kit sync || echo ''",
16+
"prepare": "node scripts/generate-version.js && svelte-kit sync || true",
1717
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
1818
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
1919
"format": "prettier --config ../../.prettierrc --write .",

sites/docs/src/lib/shared/config/version.ts

Lines changed: 0 additions & 2 deletions
This file was deleted.

sites/docs/src/routes/+page.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@
5656
'Row and cell generation',
5757
'Column visibility toggling',
5858
'Pagination (page size, navigation, reactive state)',
59-
'Column sorting (single and multi-column)'
59+
'Column sorting (single and multi-column)',
60+
'Filtering (global and column-based)'
6061
];
6162
6263
const comingSoon = [
63-
'Filtering (global and column-based)',
6464
'Row selection (single, multi, range)',
6565
'Column resizing and reordering',
6666
'Custom cell and header rendering',

sites/docs/src/routes/docs/examples/full-featured-table/+page.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ This example demonstrates how to combine all the plugins of svelte-reactive-tabl
1818
The full-featured table includes:
1919

2020
- Column visibility toggles
21+
- Name filtering with real-time search
2122
- Pagination with configurable page sizes
2223
- Multi-column sorting
2324
- All plugins working together seamlessly
@@ -40,10 +41,12 @@ The full-featured table includes:
4041
ChevronRight,
4142
ChevronsLeft,
4243
ChevronsRight,
44+
Search,
4345
SlidersHorizontal
4446
} from '@lucide/svelte';
4547
import {
4648
reactiveColumnVisibility,
49+
reactiveFiltering,
4750
reactivePagination,
4851
reactiveSorting,
4952
reactiveTable,
@@ -64,6 +67,8 @@ The full-featured table includes:
6467
hiddenColumns: [] // No hidden columns by default
6568
})
6669
)
70+
// Add filtering plugin
71+
.use(reactiveFiltering())
6772
// Add pagination plugin
6873
.use(
6974
reactivePagination({
@@ -81,6 +86,12 @@ The full-featured table includes:
8186
})
8287
);
8388
89+
// Access the filtering API
90+
const { filtering } = table.plugins;
91+
92+
// Reactive state for name search
93+
let nameSearch = $state('');
94+
8495
// Page size options
8596
const pageSizeOptions = [3, 5, 10];
8697
@@ -106,6 +117,11 @@ The full-featured table includes:
106117
const { sorting } = table.plugins;
107118
return sorting.getSortDirection(accessor);
108119
}
120+
121+
// Sync name search with filtering
122+
$effect(() => {
123+
filtering.setFilter('name', nameSearch.trim());
124+
});
109125
</script>
110126
111127
<!-- Table Component with Integrated Controls -->
@@ -114,9 +130,25 @@ The full-featured table includes:
114130
<div class="px-4 py-4 bg-muted/30 border-b flex flex-wrap justify-between items-center gap-3">
115131
<div class="flex items-center gap-2">
116132
<h2 class="text-sm font-medium">Svelte Reactive Table</h2>
133+
{#if filtering.hasActiveFilters}
134+
<span class="text-xs text-muted-foreground">
135+
({table.rows.length} of {table.allRows.length} shown)
136+
</span>
137+
{/if}
117138
</div>
118139
119140
<div class="flex items-center gap-2">
141+
<!-- Search Input -->
142+
<div class="relative">
143+
<Search class="absolute left-2 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" />
144+
<input
145+
type="text"
146+
bind:value={nameSearch}
147+
placeholder="Search names..."
148+
class="h-8 w-[200px] rounded-md border border-input bg-background pl-8 pr-3 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
149+
/>
150+
</div>
151+
120152
<!-- Column Visibility Dropdown -->
121153
<DropdownMenu.Root>
122154
<DropdownMenu.Trigger>

sites/docs/src/routes/docs/examples/full-featured-table/full-featured-table.svelte

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@
1111
ChevronRight,
1212
ChevronsLeft,
1313
ChevronsRight,
14+
Search,
1415
SlidersHorizontal
1516
} from '@lucide/svelte';
1617
import {
1718
reactiveColumnVisibility,
19+
reactiveFiltering,
1820
reactivePagination,
1921
reactiveSorting,
2022
reactiveTable
@@ -34,6 +36,8 @@
3436
hiddenColumns: [] // No hidden columns by default
3537
})
3638
)
39+
// Add filtering plugin
40+
.use(reactiveFiltering())
3741
.use(
3842
reactivePagination({
3943
pageSize: 5, // Default page size
@@ -49,6 +53,12 @@
4953
})
5054
);
5155
56+
// Access the filtering API
57+
const { filtering } = table.plugins;
58+
59+
// Reactive state for name search
60+
let nameSearch = $state('');
61+
5262
// Page size options
5363
const pageSizeOptions = [3, 5, 10];
5464
@@ -74,6 +84,11 @@
7484
const { sorting } = table.plugins;
7585
return sorting.getSortDirection(accessor);
7686
}
87+
88+
// Sync name search with filtering
89+
$effect(() => {
90+
filtering.setFilter('name', nameSearch.trim());
91+
});
7792
</script>
7893

7994
<!-- Table Component with Integrated Controls -->
@@ -82,9 +97,25 @@
8297
<div class="px-4 py-4 bg-muted/30 border-b flex flex-wrap justify-between items-center gap-3">
8398
<div class="flex items-center gap-2">
8499
<h2 class="text-sm font-medium">Svelte Reactive Table</h2>
100+
{#if filtering.hasActiveFilters}
101+
<span class="text-xs text-muted-foreground">
102+
({table.rows.length} of {table.allRows.length} shown)
103+
</span>
104+
{/if}
85105
</div>
86106

87107
<div class="flex items-center gap-2">
108+
<!-- Search Input -->
109+
<div class="relative">
110+
<Search class="absolute left-2 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" />
111+
<input
112+
type="text"
113+
bind:value={nameSearch}
114+
placeholder="Search names..."
115+
class="h-8 w-[200px] rounded-md border border-input bg-background pl-8 pr-3 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
116+
/>
117+
</div>
118+
88119
<!-- Column Visibility Dropdown -->
89120
<DropdownMenu.Root>
90121
<DropdownMenu.Trigger>

0 commit comments

Comments
 (0)