@zhangt58/svelte-vtable 0.0.4 → 0.1.1

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 CHANGED
@@ -1,16 +1,17 @@
1
1
  # @zhangt58/svelte-vtable
2
2
 
3
- A Svelte 5 library providing virtualized data tables with sorting, selection, search, and pagination controls. Built with Svelte 5 runes for reactive state management.
3
+ A Svelte 5 library providing virtualized data tables with sorting, selection, search, filtering, and pagination controls. Built with Svelte 5 runes for reactive state management.
4
4
 
5
5
  ## Features
6
6
 
7
7
  - 🚀 **Virtualized rendering** - Efficiently handles large datasets
8
8
  - 🔄 **Sorting** - Click column headers to sort
9
9
  - 🔍 **Search** - Built-in search filtering
10
+ - 🎯 **Multi-select filters** - Column-based filtering with OR/AND logic
10
11
  - 📄 **Pagination** - Configurable page controls with ellipsis navigation
11
12
  - ✅ **Selection** - Row selection with callback support
12
13
  - 🎨 **Styling** - Tailwind CSS based with light/dark mode support
13
- - 📱 **Responsive** - Flexible column widths with stretch weights
14
+ - 📱 **Responsive** - Flexible column widths and layouts
14
15
 
15
16
  ## Installation
16
17
 
@@ -30,11 +31,11 @@ npm install svelte@^5.0.0 tailwindcss@^4.0.0 flowbite-svelte@^1.0.0 flowbite-sve
30
31
 
31
32
  ```svelte
32
33
  <script>
33
- import { VirtualDataTable, DataTableControls } from '@zhangt58/svelte-vtable';
34
+ import { DataTable, DataTableControls, DataTableFilters } from '@zhangt58/svelte-vtable';
34
35
 
35
36
  let items = $state([
36
- { id: 1, name: 'Alice', email: 'alice@example.com' },
37
- { id: 2, name: 'Bob', email: 'bob@example.com' },
37
+ { id: 1, name: 'Alice', email: 'alice@example.com', dept: 'Engineering' },
38
+ { id: 2, name: 'Bob', email: 'bob@example.com', dept: 'Sales' },
38
39
  // ... more items
39
40
  ]);
40
41
 
@@ -46,10 +47,24 @@ npm install svelte@^5.0.0 tailwindcss@^4.0.0 flowbite-svelte@^1.0.0 flowbite-sve
46
47
  sortDir: 'asc'
47
48
  });
48
49
 
49
- const visibleKeys = ['name', 'email'];
50
- const colWidths = { name: 1, email: 2 }; // stretch weights
50
+ const visibleKeys = ['name', 'email', 'dept'];
51
+ const colWidths = { name: 1, email: 2, dept: 1 }; // stretch weights
52
+
53
+ // For filtering
54
+ let activeFilters = $state({});
55
+ const columnFilters = [
56
+ { key: 'dept', label: 'Department', uniqueValues: ['Engineering', 'Sales'] }
57
+ ];
51
58
  </script>
52
59
 
60
+ <!-- Multi-select filters -->
61
+ <DataTableFilters
62
+ {columnFilters}
63
+ {activeFilters}
64
+ filterChange={({allFilters}) => activeFilters = allFilters}
65
+ />
66
+
67
+ <!-- Search and pagination controls -->
53
68
  <DataTableControls
54
69
  search={ui.searchQuery}
55
70
  currentPage={ui.currentPage}
@@ -59,7 +74,8 @@ npm install svelte@^5.0.0 tailwindcss@^4.0.0 flowbite-svelte@^1.0.0 flowbite-sve
59
74
  searchchange={(e) => ui.searchQuery = e.search}
60
75
  />
61
76
 
62
- <VirtualDataTable
77
+ <!-- Virtualized table -->
78
+ <DataTable
63
79
  {items}
64
80
  {visibleKeys}
65
81
  sortKey={ui.sortKey}
@@ -72,16 +88,17 @@ npm install svelte@^5.0.0 tailwindcss@^4.0.0 flowbite-svelte@^1.0.0 flowbite-sve
72
88
  <tr onclick={select}>
73
89
  <td>{item.name}</td>
74
90
  <td>{item.email}</td>
91
+ <td>{item.dept}</td>
75
92
  </tr>
76
93
  {/snippet}
77
- </VirtualDataTable>
94
+ </DataTable>
78
95
  ```
79
96
 
80
97
  ## Components
81
98
 
82
- ### VirtualDataTable
99
+ ### DataTable (previously named VirtualDataTable)
83
100
 
84
- A virtualized table component for efficient rendering of large datasets.
101
+ A virtualized table component for efficient rendering of large datasets. The component was renamed to `DataTable`; `VirtualDataTable` is still exported for backward compatibility.
85
102
 
86
103
  #### Props
87
104
 
@@ -108,12 +125,63 @@ The `rowSnippet` receives an object with:
108
125
  - `select` - Function to call to select this row
109
126
  - `selected` - Currently selected item (for comparison)
110
127
 
128
+ ### Filter example (filterCallback)
129
+
130
+ Below is a minimal example showing how to wire the `filterCallback` prop on `VirtualDataTable` to apply per-column inline filters emitted by the header inputs. The idea: keep a small `filters` map in your component, compute a derived `filteredItems` list, and update `filters` when the table emits a column filter change.
131
+
132
+ ```svelte
133
+ <script>
134
+ import { DataTable } from '@zhangt58/svelte-vtable';
135
+
136
+ // raw dataset you want to display/filter
137
+ const rawItems = [
138
+ { id: 1, name: 'Alice', email: 'alice@example.com' },
139
+ { id: 2, name: 'Bob', email: 'bob@example.com' },
140
+ { id: 3, name: 'Carol', email: 'carol@example.com' }
141
+ ];
142
+
143
+ // per-column filter values
144
+ let filters = {};
145
+
146
+ // derived, reactive filtered list
147
+ $: filteredItems = rawItems.filter(item =>
148
+ Object.entries(filters).every(([k, v]) => !v || String(item[k] ?? '').toLowerCase().includes(v.toLowerCase()))
149
+ );
150
+
151
+ // called when a ColumnHeader emits a filter event: { key, value }
152
+ function handleFilter({ key, value }) {
153
+ filters = { ...filters, [key]: value };
154
+ }
155
+ </script>
156
+
157
+ <DataTable
158
+ items={filteredItems}
159
+ visibleKeys={['name', 'email']}
160
+ filterCallback={handleFilter}
161
+ >
162
+ {#snippet rowSnippet({item, index, select, selected})}
163
+ <tr onclick={select}>
164
+ <td>{item.name}</td>
165
+ <td>{item.email}</td>
166
+ </tr>
167
+ {/snippet}
168
+ </DataTable>
169
+ ```
170
+
111
171
  #### Column Widths
112
172
 
113
173
  Column widths can be specified as:
114
174
  - **Stretch weights** (numbers): Distributed proportionally, e.g., `{ name: 1, description: 3 }`
115
175
  - **Pixel values** (strings): Fixed widths, e.g., `{ id: '80px', name: '200px' }`
116
176
 
177
+ #### Row Snippet Parameters
178
+
179
+ The `rowSnippet` receives an object with:
180
+ - `item` - The current row data
181
+ - `index` - Row index in the current page
182
+ - `select` - Function to call to select this row
183
+ - `selected` - Currently selected item (for comparison)
184
+
117
185
  ### DataTableControls
118
186
 
119
187
  Controls component for search and pagination.
@@ -129,6 +197,90 @@ Controls component for search and pagination.
129
197
  | `pagechange` | `function` | `() => {}` | Callback for page changes: `({currentPage}) => void` |
130
198
  | `searchchange` | `function` | `() => {}` | Callback for search changes: `({search}) => void` |
131
199
 
200
+ ### DataTableFilters
201
+
202
+ Multi-select filter component with flexible layout options. Implements OR logic within columns and AND logic across columns.
203
+
204
+ #### Props
205
+
206
+ | Prop | Type | Default | Description |
207
+ |------|------|---------|-------------|
208
+ | `columnFilters` | `Array` | `[]` | Array of filter configurations (see below) |
209
+ | `direction` | `'horizontal' \| 'vertical'` | `'horizontal'` | Layout direction for filter grid |
210
+ | `activeFilters` | `Object` | `{}` | Current active filters `{ columnKey: [selectedValues] }` |
211
+ | `filterChange` | `function` | `() => {}` | Callback when filters change |
212
+ | `className` | `string` | `''` | Additional CSS classes |
213
+ | `showCounts` | `boolean` | `true` | Whether to show value counts |
214
+
215
+ #### columnFilters Structure
216
+
217
+ Each item in `columnFilters` should have:
218
+ ```javascript
219
+ {
220
+ key: 'columnKey', // Column identifier
221
+ label: 'Column Label', // Display label
222
+ uniqueValues: [...], // Array of unique values
223
+ counts: { value: count } // Optional: value frequency map
224
+ }
225
+ ```
226
+
227
+ #### Filter Logic
228
+
229
+ - **OR within column**: Selecting multiple values in one filter matches rows with ANY of those values
230
+ - **AND across columns**: All active column filters must match for a row to pass
231
+
232
+ Example usage with data filtering:
233
+ ```svelte
234
+ <script>
235
+ import { DataTableFilters } from '@zhangt58/svelte-vtable';
236
+
237
+ const data = [
238
+ { name: 'Alice', dept: 'Engineering', status: 'Active' },
239
+ { name: 'Bob', dept: 'Sales', status: 'Active' },
240
+ // ...
241
+ ];
242
+
243
+ let activeFilters = $state({});
244
+
245
+ const columnFilters = [
246
+ {
247
+ key: 'dept',
248
+ label: 'Department',
249
+ uniqueValues: ['Engineering', 'Sales'],
250
+ counts: { 'Engineering': 5, 'Sales': 3 }
251
+ },
252
+ {
253
+ key: 'status',
254
+ label: 'Status',
255
+ uniqueValues: ['Active', 'Inactive'],
256
+ counts: { 'Active': 7, 'Inactive': 1 }
257
+ }
258
+ ];
259
+
260
+ // Apply filters
261
+ const filteredData = $derived(() => {
262
+ return data.filter(item => {
263
+ for (const [key, values] of Object.entries(activeFilters)) {
264
+ if (values?.length > 0 && !values.includes(item[key])) {
265
+ return false; // AND logic across columns
266
+ }
267
+ }
268
+ return true;
269
+ });
270
+ });
271
+ </script>
272
+
273
+ <DataTableFilters
274
+ {columnFilters}
275
+ {activeFilters}
276
+ filterChange={({allFilters}) => activeFilters = allFilters}
277
+ direction="horizontal"
278
+ showCounts={true}
279
+ />
280
+ ```
281
+
282
+ For complete examples, see [DATATABLEFILTERS_README.md](./DATATABLEFILTERS_README.md).
283
+
132
284
  ## Styling (important)
133
285
 
134
286
  This library ships with built-in CSS to provide sensible default visuals (light/dark mode, striping, hover, selection, sticky headers, and pagination control styling). There are two important details to understand so the styles work correctly for both local development and package consumers:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhangt58/svelte-vtable",
3
- "version": "0.0.4",
3
+ "version": "0.1.1",
4
4
  "description": "A Svelte 5 library for virtualized data tables with sorting, selection, and pagination controls.",
5
5
  "type": "module",
6
6
  "svelte": "./src/lib/index.js",
@@ -41,15 +41,20 @@
41
41
  },
42
42
  "homepage": "https://github.com/zhangt58/svelte-vtable#readme",
43
43
  "peerDependencies": {
44
- "flowbite-svelte": "^1.0.0",
45
- "svelte": "^5.0.0",
46
- "svelte-virtuallists": "^1.0.0",
47
- "tailwindcss": "^4.0.0"
44
+ "flowbite-svelte": "^1.28.1",
45
+ "flowbite-svelte-icons": "^3.0.0",
46
+ "svelte": "^5.43.5",
47
+ "svelte-virtuallists": "^1.4.2",
48
+ "tailwindcss": "^4.1.17"
48
49
  },
49
50
  "devDependencies": {
51
+ "@sveltejs/vite-plugin-svelte": "^6.2.1",
52
+ "flowbite-svelte": "^1.28.1",
53
+ "flowbite-svelte-icons": "^3.0.0",
50
54
  "svelte": "^5.0.0",
51
55
  "svelte-check": "^4.3.4",
52
- "typescript": "^5.0.0"
56
+ "svelte-virtuallists": "^1.4.2",
57
+ "vite": "^7.2.2"
53
58
  },
54
59
  "files": [
55
60
  "src",
@@ -32,6 +32,10 @@
32
32
  selectCallback = DEFAULT_NOOP,
33
33
  // new prop name: sortCallback defaulting to `defaultSort` (alphabetical string sort)
34
34
  sortCallback = defaultSort,
35
+ // New prop: allow consumers to disable virtualization (useful when paginating by fixed item counts)
36
+ // If `virtualize` is false we ask the wrapped VirtualList to render as a normal list/table
37
+ // by setting its `isDisabled` prop. Default: true (virtualization enabled).
38
+ virtualize = true,
35
39
  // <slot> -> @render migration
36
40
  rowSnippet
37
41
  } = $props();
@@ -154,7 +158,10 @@
154
158
 
155
159
  <section class="virtual-data-table {className}" style={style}>
156
160
  {#if items && items.length > 0}
157
- <VirtualList items={items} isTable class="datatable-table max-w-full max-h-full overflow-auto">
161
+ <!-- When `virtualize` is false we instruct VirtualList to render as a normal list/table
162
+ by setting `isDisabled`. This ensures pagination based on item counts shows the
163
+ exact number of rows expected (useful when rows have variable height). -->
164
+ <VirtualList items={items} isTable isDisabled={!virtualize} class="datatable-table max-w-full max-h-full overflow-auto">
158
165
  <!-- colgroup enforces the column widths so table-layout: fixed distributes as intended -->
159
166
  {#snippet header()}
160
167
  <colgroup>
@@ -191,3 +198,4 @@
191
198
  <style>
192
199
  @import '../lib/dist/styles.css';
193
200
  </style>
201
+
@@ -1,18 +1,50 @@
1
1
  <script>
2
- import { Pagination, Search, Badge } from 'flowbite-svelte';
2
+ import { Pagination, Search, Badge, Select } from 'flowbite-svelte';
3
+ import { FilterOutline } from 'flowbite-svelte-icons';
4
+ import FiltersModal from './FiltersModal.svelte';
3
5
  // Inline SVGs are used instead of importing icons to avoid the dependency on flowbite-svelte-icons
4
6
  import { onMount, onDestroy } from 'svelte';
5
7
 
6
- // Props for search, pagination (but no per-page control)
8
+ // Props for search, pagination (perPage made bindable using Svelte 5 rune $bindable)
7
9
  let {
8
10
  search = '',
9
11
  currentPage = 1,
10
- perPage = 25, // Fixed value, not user-configurable
12
+ perPage = $bindable(25),
11
13
  totalItems = 0,
12
14
  pagechange = () => {},
13
- searchchange = () => {}
15
+ searchchange = () => {},
16
+ // control visibility of DataTableFilters above the controls
17
+ filtersVisible = false,
18
+ // callback when toggle changes: filterstoggle({ filtersVisible })
19
+ filterstoggle = () => {},
20
+ // optional DataTableFilters inputs - when provided, this component will render the filters
21
+ columnFilters = [],
22
+ activeFilters = {},
23
+ /** @type {(..._args: any[]) => void} */
24
+ filterChange = (..._args) => {},
25
+ direction = 'horizontal',
26
+ showCounts = true,
27
+ className = '',
28
+ // new callback when perPage changes
29
+ perpagechange = () => {}
14
30
  } = $props();
15
31
 
32
+ const perPageOptions = [
33
+ {value: 10, name: "10 rows"},
34
+ {value: 25, name: "25 rows"},
35
+ {value: 50, name: "50 rows"},
36
+ {value: 100, name: "100 rows"}
37
+ ]
38
+
39
+ // count of active filters (sum of selected values per column)
40
+ const activeFilterCount = $derived(() => {
41
+ try {
42
+ return Object.values(activeFilters || {}).reduce((sum, v) => sum + (Array.isArray(v) ? v.length : 0), 0);
43
+ } catch (e) {
44
+ return 0;
45
+ }
46
+ });
47
+
16
48
  // totalPages derived from totalItems and perPage
17
49
  const totalPages = $derived(() => Math.max(1, Math.ceil(totalItems / perPage)));
18
50
 
@@ -34,6 +66,42 @@
34
66
  if (typeof search !== 'undefined') searchchange?.({ search });
35
67
  });
36
68
 
69
+ // call filterstoggle when filtersVisible changes (avoid on:change typing issues)
70
+ let _prevFiltersVisible = undefined;
71
+ $effect(() => {
72
+ // initialize previous value on first run without emitting
73
+ if (_prevFiltersVisible === undefined) {
74
+ _prevFiltersVisible = filtersVisible;
75
+ return;
76
+ }
77
+ if (filtersVisible !== _prevFiltersVisible) {
78
+ try { filterstoggle?.({ filtersVisible }); } catch (err) {}
79
+ _prevFiltersVisible = filtersVisible;
80
+ }
81
+ });
82
+
83
+ // Watch perPage changes: reset to first page and notify parent
84
+ let _prevPerPage = undefined;
85
+ $effect(() => {
86
+ if (_prevPerPage === undefined) {
87
+ _prevPerPage = perPage;
88
+ return;
89
+ }
90
+ if (perPage !== _prevPerPage) {
91
+ // coerce to number just in case
92
+ perPage = +perPage || 25;
93
+ _prevPerPage = perPage;
94
+ // reset to page 1 (common UX) and notify parent
95
+ currentPage = 1;
96
+ try {
97
+ perpagechange?.({ perPage });
98
+ } catch (err) {}
99
+ try {
100
+ pagechange?.({ currentPage });
101
+ } catch (err) {}
102
+ }
103
+ });
104
+
37
105
  // Calculate range for display
38
106
  const startItem = $derived(() => totalItems === 0 ? 0 : (currentPage - 1) * perPage + 1);
39
107
  const endItem = $derived(() => Math.min(currentPage * perPage, totalItems));
@@ -43,6 +111,7 @@
43
111
 
44
112
  // stable id to query the pagination DOM if needed (fallback)
45
113
  const paginationId = `pagination-${Math.random().toString(36).slice(2,9)}`;
114
+ const perPageSelectId = `dpc-perpage-${Math.random().toString(36).slice(2,7)}`;
46
115
 
47
116
  // pages array for Pagination component (condensed with ellipses)
48
117
  const pages = $derived(() => {
@@ -135,7 +204,7 @@
135
204
 
136
205
  // Now map pageLis to pageList entries in order
137
206
  pageLis.forEach((p, idx) => {
138
- const { li, btn, text } = p;
207
+ const btn = p.btn;
139
208
  const pageObj = pageList[idx];
140
209
  if (!pageObj) return;
141
210
  // clear previous decorations
@@ -221,31 +290,25 @@
221
290
  const ul = li.parentElement;
222
291
  if (!ul) return;
223
292
  const lis = Array.from(ul.children);
224
- // Find prev/next by detecting non-numeric/non-ellipsis buttons
225
- const pageList = pages();
226
- // Build ordered list of page-button lis (numeric and ellipsis)
293
+ // Build a list of page-button <li>s (skip prev/next controls) by checking their textContent
227
294
  const pageLis = [];
228
- for (const item of lis) {
229
- const btn = item.querySelector('button, a');
295
+ for (const liItem of lis) {
296
+ const btn = liItem.querySelector('button, a');
230
297
  if (!btn) continue;
231
298
  const text = (btn.textContent || '').trim();
232
- if (/^\d+$/.test(text) || text === '…') pageLis.push({ li: item, btn, text });
299
+ // consider numeric pages and ellipsis as page buttons
300
+ if (/^\d+$/.test(text) || text === '…') pageLis.push({ li: liItem, btn, text });
233
301
  }
234
302
 
235
- // If clicked on prev/next controls, detect by checking whether clicked li is not in pageLis
303
+ // Map clicked li to decide what to do. If clicked is not a page button (i.e. prev/next),
304
+ // do nothing here because the Pagination component already calls the `previous`/`next` callbacks.
236
305
  const clickedIsPage = pageLis.some(p => p.li === li);
237
306
  if (!clickedIsPage) {
238
- // determine if it was prev (first li) or next (last li)
239
- const firstLi = lis[0];
240
- const lastLi = lis[lis.length - 1];
241
- if (li === firstLi) {
242
- previous();
243
- } else if (li === lastLi) {
244
- next();
245
- }
246
- return;
307
+ return; // rely on Pagination's built-in previous/next handling to avoid double-invocation
247
308
  }
248
309
 
310
+ const pageList = pages();
311
+
249
312
  // Map clicked li to page index
250
313
  const pageIdx = pageLis.findIndex(p => p.li === li);
251
314
  if (pageIdx < 0 || pageIdx >= pageList.length) return;
@@ -262,48 +325,94 @@
262
325
  // No external tooltip component in use; we rely on native title attribute for ellipses
263
326
  </script>
264
327
 
265
- <div class="flex items-center w-full gap-3 px-0 py-0">
266
- <!-- Search field on the left -->
267
- <div class="flex-1">
268
- <Search size="sm" bind:value={search} placeholder="Search..." clearable
269
- clearableOnClick={() => { search = ''; searchchange?.({ search }); }} />
270
- </div>
271
-
272
- <!-- Range count badge -->
273
- <div class="flex-2">
274
- <Badge rounded color="gray">
275
- Showing {startItem()} to {endItem()} of {totalItems}
276
- </Badge>
277
- </div>
278
-
279
- <!-- Pagination navigation: use Pagination with chevrons and page buttons -->
280
- <div bind:this={paginationContainerEl} data-pagination-id={paginationId} class="flex items-center gap-0.5" aria-label="Pagination">
281
- <Pagination
282
- pages={pages()}
283
- {previous}
284
- {next}
285
- ariaLabel="Pagination"
286
- onclick={handlePaginationClick}
287
- >
288
- {#snippet prevContent()}
289
- <span class="sr-only">Previous</span>
290
- <!-- Left chevron SVG (replaces ChevronLeftOutline) -->
291
- <svg class="shrink-0 h-6 w-6" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" aria-hidden="true">
292
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="1" d="M15 19l-7-7 7-7" />
293
- </svg>
294
- {/snippet}
295
-
296
- {#snippet nextContent()}
297
- <span class="sr-only">Next</span>
298
- <!-- Right chevron SVG (replaces ChevronRightOutline) -->
299
- <svg class="shrink-0 h-6 w-6" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" aria-hidden="true">
300
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="1" d="M9 5l7 7-7 7" />
301
- </svg>
302
- {/snippet}
303
- </Pagination>
328
+ <div class="w-full">
329
+ <div class="flex items-center w-full gap-3 px-0 py-0">
330
+ <!-- Search field on the left -->
331
+ <div class="flex-1">
332
+ <div class="flex items-center gap-2">
333
+ <!-- Styled button to open/close filters modal -->
334
+ <div class="flex items-center gap-1 relative">
335
+ <button
336
+ type="button"
337
+ class={
338
+ "inline-flex items-center gap-2 px-3 py-1 text-sm rounded-md border transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-green-500 dark:focus-visible:ring-green-400 " +
339
+ (filtersVisible
340
+ ? 'bg-slate-100 dark:bg-slate-700 border-slate-300 dark:border-slate-600 text-slate-900 dark:text-slate-100'
341
+ : 'bg-transparent border-transparent text-slate-700 dark:text-slate-300 hover:bg-slate-100 dark:hover:bg-slate-700')
342
+ }
343
+ aria-pressed={filtersVisible}
344
+ aria-label="Toggle filters"
345
+ title="Filters"
346
+ onclick={() => { filtersVisible = !filtersVisible; }}
347
+ >
348
+ <!-- Funnel icon (Flowbite icon component) -->
349
+ <FilterOutline class="h-4 w-4 shrink-0" />
350
+ <span class="text-sm">Filters</span>
351
+ </button>
352
+
353
+ {#if activeFilterCount() > 0}
354
+ <!-- positioned badge -->
355
+ <span class="absolute top-0 right-0 -translate-y-1/2 translate-x-1/2 inline-flex items-center justify-center h-5 min-w-[1.25rem] px-1.5 rounded-full bg-green-600 text-white text-xs font-medium">{activeFilterCount()}</span>
356
+ {/if}
357
+ </div>
358
+
359
+ <Search size="sm" bind:value={search} placeholder="Search..." clearable
360
+ clearableOnClick={() => { search = ''; searchchange?.({ search }); }} />
361
+ </div>
362
+ </div>
363
+
364
+ <!-- Range count badge + per-page selector -->
365
+ <div class="flex-2 flex items-center gap-2">
366
+ <Badge rounded color="gray">
367
+ Showing {startItem()} to {endItem()} of {totalItems}
368
+ </Badge>
369
+
370
+ <!-- Per-page selector -->
371
+ <div class="flex items-center gap-2">
372
+ <Select id={perPageSelectId} size="sm"
373
+ items={perPageOptions} bind:value={perPage}
374
+ />
375
+ </div>
376
+ </div>
377
+
378
+ <!-- Pagination navigation: use Pagination with chevrons and page buttons -->
379
+ <div bind:this={paginationContainerEl} data-pagination-id={paginationId} class="flex items-center gap-0.5" aria-label="Pagination">
380
+ <Pagination
381
+ pages={pages()}
382
+ {previous}
383
+ {next}
384
+ ariaLabel="Pagination"
385
+ onclick={handlePaginationClick}
386
+ >
387
+ {#snippet prevContent()}
388
+ <span class="sr-only">Previous</span>
389
+ <!-- Left chevron SVG (replaces ChevronLeftOutline) -->
390
+ <svg class="shrink-0 h-6 w-6" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" aria-hidden="true">
391
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="1" d="M15 19l-7-7 7-7" />
392
+ </svg>
393
+ {/snippet}
394
+
395
+ {#snippet nextContent()}
396
+ <span class="sr-only">Next</span>
397
+ <!-- Right chevron SVG (replaces ChevronRightOutline) -->
398
+ <svg class="shrink-0 h-6 w-6" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" aria-hidden="true">
399
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="1" d="M9 5l7 7-7 7" />
400
+ </svg>
401
+ {/snippet}
402
+ </Pagination>
403
+ </div>
304
404
  </div>
305
405
  </div>
306
406
 
407
+ <FiltersModal bind:open={filtersVisible}
408
+ columnFilters={columnFilters}
409
+ activeFilters={activeFilters}
410
+ filterChange={(...args) => { try { return filterChange(...args); } catch (e) {} }}
411
+ direction={direction}
412
+ showCounts={showCounts}
413
+ className={className}
414
+ />
415
+
307
416
  <style>
308
- @import '../lib/dist/styles.css';
309
- </style>
417
+ @import '../lib/dist/styles.css';
418
+ </style>