@zhangt58/svelte-vtable 0.1.4 → 0.3.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.
Files changed (36) hide show
  1. package/README.md +177 -44
  2. package/dist/components/DataTable.svelte +489 -0
  3. package/dist/components/DataTable.svelte.d.ts +31 -0
  4. package/dist/components/DataTableControls.svelte +576 -0
  5. package/dist/components/DataTableControls.svelte.d.ts +39 -0
  6. package/dist/components/DataTableFilters.svelte +215 -0
  7. package/dist/components/DataTableFilters.svelte.d.ts +37 -0
  8. package/dist/components/FiltersModal.svelte +65 -0
  9. package/dist/components/FiltersModal.svelte.d.ts +25 -0
  10. package/dist/components/PaginationBar.svelte +86 -0
  11. package/dist/components/PaginationBar.svelte.d.ts +15 -0
  12. package/dist/components/filters/FilterColumn.svelte +53 -0
  13. package/dist/components/filters/FilterColumn.svelte.d.ts +19 -0
  14. package/dist/components/filters/FilterDateRange.svelte +341 -0
  15. package/dist/components/filters/FilterDateRange.svelte.d.ts +19 -0
  16. package/dist/components/filters/FilterValueList.svelte +437 -0
  17. package/dist/components/filters/FilterValueList.svelte.d.ts +33 -0
  18. package/dist/components/filters/useFilterState.svelte.d.ts +25 -0
  19. package/dist/components/filters/useFilterState.svelte.js +132 -0
  20. package/dist/components/flowbite/DataTableControls.svelte +525 -0
  21. package/dist/components/flowbite/DataTableControls.svelte.d.ts +39 -0
  22. package/{src/components → dist/components/flowbite}/FiltersModal.svelte +5 -15
  23. package/dist/components/flowbite/FiltersModal.svelte.d.ts +25 -0
  24. package/dist/filterUtils.d.ts +76 -0
  25. package/{src/lib → dist}/filterUtils.js +48 -46
  26. package/dist/index.d.ts +60 -0
  27. package/dist/index.flowbite.d.ts +3 -0
  28. package/dist/index.flowbite.js +9 -0
  29. package/dist/index.js +49 -0
  30. package/{src/lib → dist}/styles.css +26 -3
  31. package/package.json +38 -17
  32. package/src/components/DataTable.svelte +0 -252
  33. package/src/components/DataTableControls.svelte +0 -500
  34. package/src/components/DataTableFilters.svelte +0 -1225
  35. package/src/lib/dist/styles.css +0 -273
  36. package/src/lib/index.js +0 -16
@@ -0,0 +1,576 @@
1
+ <script>
2
+ import FiltersModal from './FiltersModal.svelte';
3
+ import PaginationBar from './PaginationBar.svelte';
4
+
5
+ // Props for search, pagination (perPage made bindable using Svelte 5 rune $bindable)
6
+ let {
7
+ search = '',
8
+ currentPage = 1,
9
+ perPage = $bindable(25),
10
+ totalItems = 0,
11
+ onpage = undefined,
12
+ onsearch = undefined,
13
+ // control visibility of DataTableFilters above the controls
14
+ filtersVisible = false,
15
+ // callback when toggle changes: onfilterstoggle({ visible })
16
+ onfilterstoggle = undefined,
17
+ // optional DataTableFilters inputs - when provided, this component will render the filters
18
+ columnFilters = [],
19
+ activeFilters = {},
20
+ // onfilter({ key, values, allFilters }) — passed through to DataTableFilters
21
+ /** @type {((..._args: any[]) => void) | undefined} */
22
+ onfilter = undefined,
23
+ direction = 'horizontal',
24
+ showCounts = true,
25
+ className = '',
26
+ // callback when perPage changes: onperpage({ perPage })
27
+ onperpage = undefined,
28
+ } = $props();
29
+
30
+ const perPageOptions = [
31
+ { value: 10, name: '10 rows' },
32
+ { value: 25, name: '25 rows' },
33
+ { value: 50, name: '50 rows' },
34
+ { value: 100, name: '100 rows' },
35
+ ];
36
+
37
+ // count of active filters (sum of selected values per column, including daterange/datetimerange)
38
+ const activeFilterCount = $derived.by(() => {
39
+ try {
40
+ return Object.values(activeFilters || {}).reduce((sum, v) => {
41
+ if (Array.isArray(v)) return sum + v.length;
42
+ if (v && typeof v === 'object' && (v.from || v.to)) return sum + 1;
43
+ return sum;
44
+ }, 0);
45
+ } catch (e) {
46
+ return 0;
47
+ }
48
+ });
49
+
50
+ // totalPages derived from totalItems and perPage
51
+ const totalPages = $derived(Math.max(1, Math.ceil(totalItems / perPage)));
52
+
53
+ // clamp currentPage into valid range whenever currentPage or totalPages change
54
+ $effect(() => {
55
+ currentPage = Math.min(Math.max(1, +currentPage || 1), totalPages);
56
+ });
57
+
58
+ function goTo(p) {
59
+ const np = Math.min(Math.max(1, Math.floor(p)), totalPages);
60
+ if (np !== currentPage) {
61
+ currentPage = np;
62
+ if (onpage !== undefined) {
63
+ onpage({ page: np });
64
+ }
65
+ }
66
+ }
67
+
68
+ // emit search changes for parent when search updates
69
+ $effect(() => {
70
+ if (typeof search !== 'undefined') {
71
+ if (onsearch !== undefined) {
72
+ onsearch({ search });
73
+ }
74
+ }
75
+ });
76
+
77
+ // call onfilterstoggle when filtersVisible changes (avoid on:change typing issues)
78
+ let _prevFiltersVisible = undefined;
79
+ $effect(() => {
80
+ // initialize previous value on first run without emitting
81
+ if (_prevFiltersVisible === undefined) {
82
+ _prevFiltersVisible = filtersVisible;
83
+ return;
84
+ }
85
+ if (filtersVisible !== _prevFiltersVisible) {
86
+ if (onfilterstoggle !== undefined) {
87
+ try {
88
+ onfilterstoggle({ visible: filtersVisible });
89
+ } catch (err) {}
90
+ }
91
+ _prevFiltersVisible = filtersVisible;
92
+ }
93
+ });
94
+
95
+ // Watch perPage changes: reset to first page and notify parent
96
+ let _prevPerPage = undefined;
97
+ $effect(() => {
98
+ if (_prevPerPage === undefined) {
99
+ _prevPerPage = perPage;
100
+ return;
101
+ }
102
+ if (perPage !== _prevPerPage) {
103
+ // coerce to number just in case
104
+ perPage = +perPage || 25;
105
+ _prevPerPage = perPage;
106
+ // reset to page 1 (common UX) and notify parent
107
+ currentPage = 1;
108
+ if (onperpage !== undefined) {
109
+ try {
110
+ onperpage({ perPage });
111
+ } catch (err) {}
112
+ }
113
+ if (onpage !== undefined) {
114
+ try {
115
+ onpage({ page: currentPage });
116
+ } catch (err) {}
117
+ }
118
+ }
119
+ });
120
+
121
+ // Calculate range for display
122
+ const startItem = $derived(totalItems === 0 ? 0 : (currentPage - 1) * perPage + 1);
123
+ const endItem = $derived(Math.min(currentPage * perPage, totalItems));
124
+
125
+ // visiblePages: number of middle numeric buttons to show (not counting first/last)
126
+ const visiblePages = 5;
127
+
128
+ const perPageSelectId = `dpc-perpage-${Math.random().toString(36).slice(2, 7)}`;
129
+
130
+ // pages array for Pagination component (condensed with ellipses)
131
+ const pages = $derived.by(() => {
132
+ const total = totalPages;
133
+ const current = Math.min(Math.max(1, Math.floor(currentPage)), total);
134
+
135
+ // If small number of pages, show all
136
+ if (total <= visiblePages + 2) {
137
+ return Array.from({ length: total }, (_, i) => ({
138
+ name: String(i + 1),
139
+ active: i + 1 === current,
140
+ }));
141
+ }
142
+
143
+ const pagesArr = [];
144
+ // always show first
145
+ pagesArr.push({ name: '1', active: current === 1 });
146
+
147
+ const half = Math.floor(visiblePages / 2);
148
+ let start = Math.max(2, current - half);
149
+ let end = Math.min(total - 1, current + half);
150
+
151
+ // adjust window when near the boundaries
152
+ if (current - 1 <= half) {
153
+ start = 2;
154
+ end = 1 + visiblePages;
155
+ }
156
+ if (total - current <= half) {
157
+ end = total - 1;
158
+ start = total - visiblePages;
159
+ }
160
+
161
+ if (start > 2) {
162
+ // compute left jump (midpoint of hidden range 2..start-1)
163
+ const leftHiddenStart = 2;
164
+ const leftHiddenEnd = start - 1;
165
+ const leftJump = Math.max(leftHiddenStart, Math.floor((leftHiddenStart + leftHiddenEnd) / 2));
166
+ pagesArr.push({ name: '…', active: false, ellipsis: 'left', jump: leftJump });
167
+ }
168
+
169
+ for (let i = start; i <= end; i++) pagesArr.push({ name: String(i), active: i === current });
170
+
171
+ if (end < total - 1) {
172
+ // compute right jump (midpoint of hidden range end+1..total-1)
173
+ const rightHiddenStart = end + 1;
174
+ const rightHiddenEnd = total - 1;
175
+ const rightJump = Math.min(
176
+ rightHiddenEnd,
177
+ Math.ceil((rightHiddenStart + rightHiddenEnd) / 2),
178
+ );
179
+ pagesArr.push({ name: '…', active: false, ellipsis: 'right', jump: rightJump });
180
+ }
181
+
182
+ // always show last
183
+ pagesArr.push({ name: String(total), active: current === total });
184
+
185
+ return pagesArr;
186
+ });
187
+
188
+ // No external tooltip component in use; we rely on native title attribute for ellipses
189
+ </script>
190
+
191
+ <div class="w-full">
192
+ <div class="flex items-center w-full gap-3 px-0 py-0">
193
+ <!-- Search field on the left -->
194
+ <div class="flex-1">
195
+ <div class="flex items-center gap-2">
196
+ <!-- Styled button to open/close filters modal -->
197
+ <div class="flex items-center gap-1 relative">
198
+ <button
199
+ type="button"
200
+ class={'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 ' +
201
+ (filtersVisible
202
+ ? 'bg-slate-100 dark:bg-slate-700 border-slate-300 dark:border-slate-600 text-slate-900 dark:text-slate-100'
203
+ : 'bg-transparent border-transparent text-slate-700 dark:text-slate-300 hover:bg-slate-100 dark:hover:bg-slate-700')}
204
+ aria-pressed={filtersVisible}
205
+ aria-label="Toggle filters"
206
+ title="Filters"
207
+ onclick={() => {
208
+ filtersVisible = !filtersVisible;
209
+ }}
210
+ >
211
+ <!-- Funnel icon (inline SVG) -->
212
+ <svg
213
+ class="h-4 w-4 shrink-0"
214
+ xmlns="http://www.w3.org/2000/svg"
215
+ fill="none"
216
+ viewBox="0 0 24 24"
217
+ stroke="currentColor"
218
+ aria-hidden="true"
219
+ >
220
+ <path
221
+ stroke-linecap="round"
222
+ stroke-linejoin="round"
223
+ stroke-width="2"
224
+ d="M3 4a1 1 0 011-1h16a1 1 0 011 1v2a1 1 0 01-.293.707L13 13.414V19a1 1 0 01-.553.894l-4 2A1 1 0 017 21v-7.586L3.293 6.707A1 1 0 013 6V4z"
225
+ />
226
+ </svg>
227
+ <span class="text-sm">Filters</span>
228
+ </button>
229
+
230
+ {#if activeFilterCount > 0}
231
+ <!-- positioned badge -->
232
+ <span
233
+ 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 text-white text-xs font-medium"
234
+ style="background-color: var(--vtable-color-accent);">{activeFilterCount}</span
235
+ >
236
+ {/if}
237
+ </div>
238
+
239
+ <div class="vtable-search-wrapper relative flex items-center">
240
+ <svg
241
+ class="absolute left-3 h-4 w-4 text-gray-400 pointer-events-none"
242
+ xmlns="http://www.w3.org/2000/svg"
243
+ fill="none"
244
+ viewBox="0 0 24 24"
245
+ stroke="currentColor"
246
+ aria-hidden="true"
247
+ >
248
+ <path
249
+ stroke-linecap="round"
250
+ stroke-linejoin="round"
251
+ stroke-width="2"
252
+ d="M21 21l-4.35-4.35M17 11A6 6 0 115 11a6 6 0 0112 0z"
253
+ />
254
+ </svg>
255
+ <input
256
+ type="search"
257
+ class="vtable-search-input pl-9 pr-8 py-1 text-sm rounded-md border border-gray-300 bg-white dark:bg-gray-700 dark:border-gray-600 dark:text-gray-100 w-full"
258
+ placeholder="Search..."
259
+ bind:value={search}
260
+ />
261
+ {#if search}
262
+ <button
263
+ type="button"
264
+ class="absolute right-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-200 focus:outline-none"
265
+ aria-label="Clear search"
266
+ onclick={() => {
267
+ search = '';
268
+ if (onsearch !== undefined) {
269
+ onsearch({ search: '' });
270
+ }
271
+ }}
272
+ >
273
+ <svg class="h-4 w-4" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" aria-hidden="true">
274
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
275
+ </svg>
276
+ </button>
277
+ {/if}
278
+ </div>
279
+ </div>
280
+ </div>
281
+
282
+ <!-- Range count badge + per-page selector -->
283
+ <div class="flex-2 flex items-center gap-2">
284
+ <span
285
+ class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-200 whitespace-nowrap"
286
+ >
287
+ Showing {startItem} to {endItem} of {totalItems}
288
+ </span>
289
+
290
+ <!-- Per-page selector -->
291
+ <div class="flex items-center gap-2">
292
+ <select
293
+ id={perPageSelectId}
294
+ class="vtable-perpage-select py-1 pl-3 pr-7 text-sm rounded-md border border-gray-300 bg-white dark:bg-gray-700 dark:border-gray-600 dark:text-gray-100"
295
+ bind:value={perPage}
296
+ >
297
+ {#each perPageOptions as opt}
298
+ <option value={opt.value}>{opt.name}</option>
299
+ {/each}
300
+ </select>
301
+ </div>
302
+ </div>
303
+
304
+ <!-- Pagination navigation -->
305
+ <PaginationBar {pages} {currentPage} onpage={goTo} />
306
+ </div>
307
+ </div>
308
+
309
+ <FiltersModal
310
+ bind:open={filtersVisible}
311
+ {columnFilters}
312
+ {activeFilters}
313
+ {onfilter}
314
+ {direction}
315
+ {showCounts}
316
+ {className}
317
+ />
318
+
319
+ <style>/* ── Theming contract — override these on :root or any wrapper element ── */
320
+ :root {
321
+ --vtable-color-accent: #16a34a; /* green-600 */
322
+ --vtable-color-accent-light: #dcfce7; /* green-100 */
323
+ --vtable-color-accent-border: #22c55e; /* green-500 */
324
+ --vtable-color-accent-text: #15803d; /* green-700 */
325
+
326
+ --vtable-color-danger: #dc2626; /* red-600 */
327
+ --vtable-color-info: #3b82f6; /* blue-500 */
328
+
329
+ --vtable-radius: 0.375rem; /* rounded-md */
330
+ --vtable-row-height: 2.25rem; /* default row height hint for virtual scroll */
331
+ }
332
+ .virtual-data-table {
333
+ display: block;
334
+ min-width: 0;
335
+ height: 100%;
336
+ overflow: auto;
337
+ }
338
+ :global(.datatable-table) {
339
+ display: table;
340
+ width: 100%;
341
+ min-width: 0;
342
+ border-collapse: collapse;
343
+ box-sizing: border-box;
344
+ font-size: 0.875rem; /* 14px - smaller, more compact */
345
+ font-family:
346
+ -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
347
+ line-height: 1.4;
348
+ border: none;
349
+ }
350
+ /* Sticky header support */
351
+ :global(.datatable-table) thead.sticky-header {
352
+ position: sticky;
353
+ top: 0;
354
+ z-index: 20;
355
+ }
356
+ /* Header visual styles - only bottom border */
357
+ :global(.datatable-table) thead th {
358
+ background-color: #f8f9fa;
359
+ font-size: 0.8125rem; /* 13px */
360
+ font-weight: 600;
361
+ text-transform: uppercase;
362
+ letter-spacing: 0.025em;
363
+ border-top: none;
364
+ border-left: none;
365
+ border-right: none;
366
+ border-bottom: 1px solid #dee2e6;
367
+ padding: 0.5rem 0.5rem;
368
+ text-align: left;
369
+ white-space: normal; /* Allow header text to wrap */
370
+ overflow: visible;
371
+ box-shadow: 0 2px 2px -1px rgba(0, 0, 0, 0.1); /* Keep border visible on scroll */
372
+ }
373
+ /* Row striping - alternating colors */
374
+ /* VirtualList may wrap rows, so we target tr directly */
375
+ :global(.datatable-table tbody tr:nth-of-type(even)) {
376
+ background-color: #ffffff;
377
+ }
378
+ :global(.datatable-table tbody tr:nth-of-type(odd)) {
379
+ background-color: #f8f9fa;
380
+ }
381
+ /* Also ensure tr elements themselves have background */
382
+ :global(.datatable-table tbody tr) {
383
+ background-color: inherit;
384
+ }
385
+ /* Hover effect */
386
+ :global(.datatable-table tbody tr:hover) {
387
+ background-color: #e7f1ff !important;
388
+ transition: background-color 0.15s ease-in-out;
389
+ }
390
+ /* Selesky-500 row overrides striping and hover */
391
+ :global(.datatable-table tbody tr.selected-row) {
392
+ background-color: #e0f2fe !important; /* light sky background */
393
+ box-shadow: inset 4px 0 0 0 #0369a1; /* left accent */
394
+ }
395
+ :global(.dark) :global(.datatable-table tbody tr.selected-row) {
396
+ /* brighter, higher-contrast selection in dark mode */
397
+ background-color: rgba(14, 165, 233, 0.22) !important; /* stronger visible blue */
398
+ box-shadow: inset 6px 0 0 0 rgba(56, 189, 248, 0.85); /* stronger left accent */
399
+ transition:
400
+ background-color 0.12s ease-in-out,
401
+ box-shadow 0.12s ease-in-out;
402
+ }
403
+ /* Also apply to cells to defeat any cell-level background from striping and ensure readable text */
404
+ :global(.datatable-table tbody tr.selected-row) td {
405
+ background-color: #e0f2fe !important;
406
+ }
407
+ :global(.dark) :global(.datatable-table tbody tr.selected-row) td {
408
+ background-color: rgba(14, 165, 233, 0.22) !important;
409
+ color: #f0fbff !important; /* ensure high-contrast, very light text */
410
+ border-bottom-color: rgba(255, 255, 255, 0.06);
411
+ }
412
+ /* Body cell defaults - only bottom border */
413
+ :global(.datatable-table tbody td) {
414
+ padding: 0.5rem 0.5rem;
415
+ border-top: none;
416
+ border-left: none;
417
+ border-right: none;
418
+ border-bottom: 1px solid #e9ecef;
419
+ vertical-align: middle;
420
+ text-align: left;
421
+ font-size: 0.875rem; /* 14px */
422
+ overflow: hidden;
423
+ white-space: normal; /* Allow wrapping by default */
424
+ word-wrap: break-word;
425
+ box-sizing: border-box;
426
+ }
427
+ /* No-wrap variant for cells that should truncate */
428
+ :global(.datatable-table tbody td.nowrap) {
429
+ white-space: nowrap;
430
+ text-overflow: ellipsis;
431
+ }
432
+ /* Compact variant */
433
+ :global(.datatable-table.compact tbody td) {
434
+ padding: 0.1rem 0.3rem;
435
+ }
436
+ /* Header content alignment helper */
437
+ :global(.datatable-table thead th > div) {
438
+ display: inline-flex;
439
+ align-items: center;
440
+ gap: 0.25rem;
441
+ }
442
+ /* Allow certain long cells to wrap fully if explicitly requested */
443
+ :global(.datatable-table td.wrap) {
444
+ white-space: normal;
445
+ word-break: break-word;
446
+ }
447
+ /* Dark mode variants for the datatable */
448
+ :global(.dark) :global(.datatable-table thead th) {
449
+ background-color: #1f2937;
450
+ border-bottom-color: #374151;
451
+ color: #f9fafb;
452
+ box-shadow: 0 2px 2px -1px rgba(0, 0, 0, 0.3); /* Darker shadow for dark mode */
453
+ }
454
+ :global(.dark) :global(.datatable-table tbody tr:nth-of-type(even)) {
455
+ background-color: #111827;
456
+ }
457
+ :global(.dark) :global(.datatable-table tbody tr:nth-of-type(odd)) {
458
+ background-color: #1f2937;
459
+ }
460
+ :global(.dark) :global(.datatable-table tbody tr:hover) {
461
+ background-color: #374151 !important;
462
+ }
463
+ :global(.dark) :global(.datatable-table tbody td) {
464
+ border-bottom-color: #374151;
465
+ color: #e5e7eb;
466
+ }
467
+ /* Shared control styles (inputs, pagination, column filters) used by page components */
468
+ /* Accent-color focus ring for search input and per-page select — respects --vtable-color-accent */
469
+ :global(.vtable-search-input:focus),
470
+ :global(.vtable-perpage-select:focus) {
471
+ border-color: var(--vtable-color-accent-border);
472
+ box-shadow: 0 0 0 2px color-mix(in srgb, var(--vtable-color-accent) 20%, transparent);
473
+ outline: none;
474
+ }
475
+ :global(.datatable-input) {
476
+ padding: 0.375rem 0.75rem;
477
+ font-size: 0.95rem;
478
+ border: 1px solid #ced4da;
479
+ border-radius: 0.25rem;
480
+ }
481
+ :global(.datatable-input:focus) {
482
+ border-color: #86b7fe;
483
+ outline: 0;
484
+ box-shadow: 0 0 0.1rem 0.2rem rgba(13, 110, 253, 0.25);
485
+ }
486
+ :global(.search-filtering-row) {
487
+ background-color: #f8f9fa;
488
+ }
489
+ :global(.search-filtering-row th) {
490
+ padding: 0.1rem 0.1rem;
491
+ border-bottom: 1px solid #dee2e6;
492
+ }
493
+ :global(.column-filter) {
494
+ width: 95%;
495
+ padding: 0.2rem 0.25rem;
496
+ font-size: 0.8rem;
497
+ border: 1px solid #ced4da;
498
+ border-radius: 0.25rem;
499
+ }
500
+ :global(.column-filter::placeholder) {
501
+ color: #adb5bd;
502
+ font-size: 0.75rem;
503
+ font-style: italic;
504
+ }
505
+ :global(.datatable-pagination) {
506
+ display: flex;
507
+ gap: 0.1rem;
508
+ margin-top: 0.6rem;
509
+ }
510
+ :global(.datatable-pagination li a),
511
+ :global(.datatable-pagination li button) {
512
+ padding: 0.3rem 0.7rem;
513
+ border: 1px solid #dee2e6;
514
+ border-radius: 0;
515
+ background-color: #fff;
516
+ color: #0d6efd;
517
+ text-decoration: none;
518
+ }
519
+ :global(.datatable-pagination li a:hover),
520
+ :global(.datatable-pagination li button:hover) {
521
+ background-color: #e9ecef;
522
+ }
523
+ :global(.datatable-pagination .datatable-active a),
524
+ :global(.datatable-pagination .datatable-active button) {
525
+ background-color: #0d6efd;
526
+ border-color: #0d6efd;
527
+ color: #fff;
528
+ }
529
+ /* Force the active/current page to use the accent tokens (override flowbite's primary/orange).
530
+ Intentionally specific to reliably win over third-party rules. */
531
+ :global([data-pagination-id] ul li [aria-current='page']) {
532
+ background-color: var(--vtable-color-accent-light) !important;
533
+ color: var(--vtable-color-accent) !important;
534
+ border-color: transparent !important;
535
+ }
536
+ /* Ensure Prev/Next controls visually match the numeric buttons' border and rhythm
537
+ (keeps border, radius and min-width consistent). This is minimal and won't
538
+ override hover/text colors managed by Tailwind classes applied at runtime. */
539
+ :global([data-pagination-id] ul li:first-child > button),
540
+ :global([data-pagination-id] ul li:first-child > a),
541
+ :global([data-pagination-id] ul li:last-child > button),
542
+ :global([data-pagination-id] ul li:last-child > a) {
543
+ border: 1px solid #d1d5db; /* border-gray-300 */
544
+ min-width: 2rem; /* align with numeric buttons' min width */
545
+ background: transparent;
546
+ padding: 0.25rem 0.5rem; /* keep comfortable hit area */
547
+ }
548
+ /* Light mode: hover/focus for Prev/Next match numeric button hover */
549
+ :global([data-pagination-id] ul li:first-child > button:hover),
550
+ :global([data-pagination-id] ul li:first-child > a:hover),
551
+ :global([data-pagination-id] ul li:last-child > button:hover),
552
+ :global([data-pagination-id] ul li:last-child > a:hover),
553
+ :global([data-pagination-id] ul li:first-child > button:focus),
554
+ :global([data-pagination-id] ul li:first-child > a:focus),
555
+ :global([data-pagination-id] ul li:last-child > button:focus),
556
+ :global([data-pagination-id] ul li:last-child > a:focus) {
557
+ background-color: #f3f4f6; /* tailwind gray-100 */
558
+ outline: none;
559
+ }
560
+ /* Ellipsis styling: make clickable and visually lighter (JS sets data-ellipsis/data-jump) */
561
+ :global([data-pagination-id] ul li [data-ellipsis='true']) {
562
+ cursor: pointer;
563
+ background: transparent !important;
564
+ color: inherit;
565
+ opacity: 0.9;
566
+ font-size: 0.875rem;
567
+ padding: 0.25rem 0.5rem;
568
+ }
569
+ /* Chevron sizing for Prev/Next so icons sit comfortably in the buttons */
570
+ :global([data-pagination-id] ul li:first-child svg),
571
+ :global([data-pagination-id] ul li:last-child svg) {
572
+ height: 1.25rem;
573
+ width: 1.25rem;
574
+ display: block;
575
+ }
576
+ </style>
@@ -0,0 +1,39 @@
1
+ export default DataTableControls;
2
+ type DataTableControls = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<$$ComponentProps>): void;
5
+ };
6
+ declare const DataTableControls: import("svelte").Component<{
7
+ search?: string;
8
+ currentPage?: number;
9
+ perPage?: number;
10
+ totalItems?: number;
11
+ onpage?: any;
12
+ onsearch?: any;
13
+ filtersVisible?: boolean;
14
+ onfilterstoggle?: any;
15
+ columnFilters?: any[];
16
+ activeFilters?: Record<string, any>;
17
+ onfilter?: any;
18
+ direction?: string;
19
+ showCounts?: boolean;
20
+ className?: string;
21
+ onperpage?: any;
22
+ }, {}, "perPage">;
23
+ type $$ComponentProps = {
24
+ search?: string;
25
+ currentPage?: number;
26
+ perPage?: number;
27
+ totalItems?: number;
28
+ onpage?: any;
29
+ onsearch?: any;
30
+ filtersVisible?: boolean;
31
+ onfilterstoggle?: any;
32
+ columnFilters?: any[];
33
+ activeFilters?: Record<string, any>;
34
+ onfilter?: any;
35
+ direction?: string;
36
+ showCounts?: boolean;
37
+ className?: string;
38
+ onperpage?: any;
39
+ };