@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
@@ -1,1225 +0,0 @@
1
- <script>
2
- import { Badge } from 'flowbite-svelte';
3
- import { ChevronDownOutline, ArrowDownOutline } from 'flowbite-svelte-icons';
4
- import { onDestroy } from 'svelte';
5
-
6
- // shared default no-op function
7
- const DEFAULT_NOOP = (..._args) => {};
8
-
9
- // Props using Svelte 5 $props()
10
- let {
11
- // columnFilters: array of { key, label, uniqueValues }
12
- // where uniqueValues is an array of unique values for that column
13
- columnFilters = [],
14
- // layout direction: 'horizontal' or 'vertical'
15
- direction = 'horizontal',
16
- // current active filters: { columnKey: [selectedValues] }
17
- activeFilters = {},
18
- // Callback when filters change
19
- filterChange = DEFAULT_NOOP,
20
- // Optional callback when sort mode/dir changes: ( { columnKey, mode, dir } )
21
- sortChange = DEFAULT_NOOP,
22
- // CSS class for the container
23
- className = '',
24
- // Whether to show filter counts
25
- showCounts = true,
26
- // Virtualization props (defaults)
27
- virtualThreshold = 500,
28
- virtualItemHeight = 36,
29
- virtualOverscan = 5,
30
- // Debounce milliseconds for emitting filterChange (0 = immediate)
31
- emitDebounce = 100,
32
- // If the number of options exceeds this threshold, the options are not generated by default
33
- // and the user must click "Load options" to populate them. Set to 0 to always populate.
34
- populateThreshold = 200,
35
- // If true, render dropdowns inline (in-flow) so opening them expands the parent container.
36
- // If false, render as absolutely-positioned overlays (old behavior).
37
- dropdownInline = true,
38
- // Relative-range quick-set presets shown in the datetime range picker.
39
- // Each entry: { label: string, value: number, unit: 'hour'|'day'|'week'|'month'|'year' }
40
- // Presets with unit 'hour' are only shown for 'datetimerange' columns.
41
- relativeRangePresets = /** @type {Array<{label:string,value:number,unit:string}>} */ ([
42
- { label: '1h', value: 1, unit: 'hour' },
43
- { label: '6h', value: 6, unit: 'hour' },
44
- { label: '12h', value: 12, unit: 'hour' },
45
- { label: '1d', value: 1, unit: 'day' },
46
- { label: '7d', value: 7, unit: 'day' },
47
- { label: '30d', value: 30, unit: 'day' },
48
- { label: '1y', value: 1, unit: 'year' },
49
- ]),
50
- } = $props();
51
-
52
- // Internal state for selected options per column
53
- let selections = $state({});
54
-
55
- // Track whether options have been loaded (populated) per-column when the list is large
56
- let loadedOptions = $state({});
57
-
58
- // Auto-enable loading for small lists when columnFilters change
59
- $effect(() => {
60
- const initial = {};
61
- for (const col of columnFilters) {
62
- const len = Array.isArray(col.uniqueValues) ? col.uniqueValues.length : 0;
63
- initial[col.key] = populateThreshold <= 0 || len <= populateThreshold;
64
- }
65
- loadedOptions = initial;
66
- });
67
-
68
- // --- Debounced emission helpers ---
69
- let _emitTimer = null;
70
- let _pendingEmit = null;
71
-
72
- function scheduleEmit(columnKey, selectedValues) {
73
- // capture latest state snapshot
74
- _pendingEmit = { columnKey, selectedValues, allFilters: selections };
75
-
76
- if (!emitDebounce || emitDebounce <= 0) {
77
- // immediate
78
- flushEmit();
79
- return;
80
- }
81
-
82
- if (_emitTimer) clearTimeout(_emitTimer);
83
- _emitTimer = setTimeout(() => flushEmit(), emitDebounce);
84
- }
85
-
86
- function flushEmit() {
87
- if (!_pendingEmit) return;
88
- const payload = _pendingEmit;
89
- _pendingEmit = null;
90
- if (_emitTimer) {
91
- clearTimeout(_emitTimer);
92
- _emitTimer = null;
93
- }
94
-
95
- try {
96
- /** @type {any} */ (filterChange)(payload);
97
- } catch (err) {
98
- try {
99
- console.error('filterChange threw:', err);
100
- } catch (e) {}
101
- }
102
- }
103
-
104
- // cleanup on destroy to avoid timers running after unmount
105
- onDestroy(() => {
106
- if (_emitTimer) clearTimeout(_emitTimer);
107
- // flush any pending emit synchronously
108
- flushEmit();
109
- });
110
-
111
- // Helper: is this column a date/datetime range filter?
112
- function isDateRangeColumn(col) {
113
- return col.type === 'daterange' || col.type === 'datetimerange';
114
- }
115
-
116
- // Initialize selections from activeFilters
117
- $effect(() => {
118
- const newSelections = {};
119
- for (const col of columnFilters) {
120
- newSelections[col.key] = activeFilters[col.key] ?? (isDateRangeColumn(col) ? {} : []);
121
- }
122
- selections = newSelections;
123
- });
124
-
125
- // Toggle selection for a specific column and value
126
- function toggleSelection(columnKey, value) {
127
- const current = selections[columnKey] || [];
128
- let updated;
129
-
130
- if (current.includes(value)) {
131
- // Remove the value
132
- updated = current.filter((v) => v !== value);
133
- } else {
134
- // Add the value
135
- updated = [...current, value];
136
- }
137
-
138
- selections = { ...selections, [columnKey]: updated };
139
-
140
- // Schedule debounced filter change emission
141
- scheduleEmit(columnKey, updated);
142
- }
143
-
144
- // Clear all selections for a column
145
- function clearColumn(columnKey) {
146
- const col = columnFilters.find((c) => c.key === columnKey);
147
- const empty = isDateRangeColumn(col) ? {} : [];
148
- selections = { ...selections, [columnKey]: empty };
149
- scheduleEmit(columnKey, empty);
150
- }
151
-
152
- // Clear all filters
153
- function clearAllFilters() {
154
- const cleared = {};
155
- for (const col of columnFilters) {
156
- cleared[col.key] = isDateRangeColumn(col) ? {} : [];
157
- }
158
- selections = cleared;
159
-
160
- // emit after debounce (columnKey null indicates global clear)
161
- scheduleEmit(null, []);
162
- }
163
-
164
- // Check if any filters are active
165
- const hasActiveFilters = $derived(() => {
166
- return Object.values(selections).some((val) => {
167
- if (Array.isArray(val)) return val.length > 0;
168
- if (val && typeof val === 'object') return !!(val.from || val.to);
169
- return false;
170
- });
171
- });
172
-
173
- // Count active filters
174
- const activeFilterCount = $derived(() => {
175
- return Object.values(selections).reduce((sum, val) => {
176
- if (Array.isArray(val)) return sum + (val?.length || 0);
177
- if (val && typeof val === 'object' && (val.from || val.to)) return sum + 1;
178
- return sum;
179
- }, 0);
180
- });
181
-
182
- // Toggle dropdown visibility for a column
183
- let openDropdowns = $state({});
184
-
185
- // Simple toggle/close functions — dropdowns are controlled only by their
186
- // toggle button and programmatic calls (e.g. Show All / Collapse All).
187
- function toggleDropdown(columnKey) {
188
- const wasOpen = openDropdowns[columnKey];
189
- openDropdowns = { ...openDropdowns, [columnKey]: !wasOpen };
190
- }
191
-
192
- // Sorting state for each column's dropdown
193
- let sortModes = $state({});
194
- // Per-column sort direction: 'asc' or 'desc'
195
- let sortDirs = $state({});
196
-
197
- // Inline header search queries per column (small text filter for options)
198
- let searchQueries = $state({});
199
-
200
- // --- Virtualization settings and state ---
201
- // (virtual props are provided via the main $props() destructure above)
202
-
203
- // DOM refs for per-column scroll containers
204
- let listRefs = $state({});
205
-
206
- // Per-column scroll state: { scrollTop, height }
207
- let virtualScroll = $state({});
208
-
209
- // Svelte action to register list containers and keep virtualScroll updated
210
- function registerList(node, params) {
211
- const key = params && params.key;
212
- if (!key) return { destroy() {} };
213
-
214
- listRefs = { ...listRefs, [key]: node };
215
-
216
- function updateState() {
217
- virtualScroll = {
218
- ...virtualScroll,
219
- [key]: { scrollTop: node.scrollTop, height: node.clientHeight },
220
- };
221
- }
222
-
223
- // initialize
224
- updateState();
225
-
226
- const onScroll = () => updateState();
227
- const onResize = () => updateState();
228
-
229
- node.addEventListener('scroll', onScroll);
230
- // Observe size changes (in case container height changes)
231
- const ro = new ResizeObserver(onResize);
232
- ro.observe(node);
233
-
234
- return {
235
- update(newParams) {
236
- // allow key to be updated (unlikely)
237
- if (!newParams || newParams.key !== key) {
238
- node.removeEventListener('scroll', onScroll);
239
- ro.disconnect();
240
- delete listRefs[key];
241
- }
242
- },
243
- destroy() {
244
- node.removeEventListener('scroll', onScroll);
245
- ro.disconnect();
246
- delete listRefs[key];
247
- // remove virtualScroll entry
248
- const copy = { ...virtualScroll };
249
- delete copy[key];
250
- virtualScroll = copy;
251
- },
252
- };
253
- }
254
-
255
- // Compute virtual slice for a column when the values exceed threshold
256
- function getVirtualSlice(column, values) {
257
- if (!values || values.length <= virtualThreshold) return null;
258
- const vs = virtualScroll[column.key] || { scrollTop: 0, height: 200 };
259
- const itemH = virtualItemHeight;
260
- const height = vs.height || 200;
261
- const overscan = virtualOverscan;
262
-
263
- const start = Math.max(0, Math.floor(vs.scrollTop / itemH) - overscan);
264
- const visibleCount = Math.ceil(height / itemH) + overscan * 2;
265
- const end = Math.min(values.length, start + visibleCount);
266
- const slice = values.slice(start, end);
267
- const top = start * itemH;
268
- const totalHeight = values.length * itemH;
269
-
270
- return { slice, start, end, top, totalHeight };
271
- }
272
-
273
- // --- Helper: extract a numeric sort key from a value ---
274
- // Returns the number itself if numeric, the first number found in a string,
275
- // or 0 if no number can be found.
276
- function extractNumber(v) {
277
- if (v === null || v === undefined) return 0;
278
- if (typeof v === 'number') return v;
279
- const s = String(v);
280
- const match = s.match(/-?\d+(\.\d+)?/);
281
- return match ? parseFloat(match[0]) : 0;
282
- }
283
-
284
- // --- Helper: return the values for a column after applying search + sort ---
285
- function getSortedValues(column) {
286
- // column.uniqueValues is expected to be an array of possible values
287
- const raw = Array.isArray(column.uniqueValues) ? column.uniqueValues.slice() : [];
288
-
289
- // apply search filter if present
290
- const q = (searchQueries[column.key] || '').toString().trim().toLowerCase();
291
- let filtered = raw;
292
- if (q) {
293
- filtered = raw.filter((v) => {
294
- const text = v === null || v === undefined ? '(empty)' : String(v);
295
- return text.toLowerCase().includes(q);
296
- });
297
- }
298
-
299
- // determine sort mode and direction
300
- const mode = sortModes[column.key] || 'name';
301
- const dir = (sortDirs[column.key] || 'asc') === 'asc' ? 1 : -1;
302
-
303
- // stable sort: map-index technique
304
- const withIndex = filtered.map((v, i) => ({ v, i }));
305
-
306
- withIndex.sort((a, b) => {
307
- const va = a.v;
308
- const vb = b.v;
309
-
310
- if (mode === 'count' && column.counts) {
311
- const ca = Number(column.counts[va] ?? 0);
312
- const cb = Number(column.counts[vb] ?? 0);
313
- if (ca !== cb) return (ca - cb) * dir * -1; // higher counts first when desc
314
- // fallback to name compare
315
- }
316
-
317
- if (mode === 'number') {
318
- const na = extractNumber(va);
319
- const nb = extractNumber(vb);
320
- if (na !== nb) return (na - nb) * dir;
321
- // fallback to name compare for equal numeric values
322
- }
323
-
324
- // compare by name
325
- const sa = va === null || va === undefined ? '(empty)' : String(va);
326
- const sb = vb === null || vb === undefined ? '(empty)' : String(vb);
327
- const la = sa.toLowerCase();
328
- const lb = sb.toLowerCase();
329
- if (la < lb) return -1 * dir;
330
- if (la > lb) return 1 * dir;
331
- // maintain stable order
332
- return a.i - b.i;
333
- });
334
-
335
- return withIndex.map((x) => x.v);
336
- }
337
-
338
- // Toggle sort mode for a column. If the same mode is clicked again,
339
- // flip the direction; otherwise set the mode and default to 'desc'.
340
- function toggleSortMode(columnKey, mode) {
341
- const prevMode = sortModes[columnKey];
342
- if (prevMode === mode) {
343
- // flip direction
344
- const prevDir = sortDirs[columnKey] || 'desc';
345
- const nextDir = prevDir === 'asc' ? 'desc' : 'asc';
346
- sortDirs = { ...sortDirs, [columnKey]: nextDir };
347
- } else {
348
- sortModes = { ...sortModes, [columnKey]: mode };
349
- // default first click to descending (common expectation for counts)
350
- sortDirs = { ...sortDirs, [columnKey]: 'desc' };
351
- }
352
- // ensure the mode is set (for first-time clicks)
353
- sortModes = { ...sortModes, [columnKey]: mode };
354
-
355
- const newDir = sortDirs[columnKey] || 'asc';
356
- try {
357
- // notify parent if it wants to react to sort changes
358
- /** @type {any} */ (sortChange)({ columnKey, mode, dir: newDir });
359
- } catch (err) {
360
- try {
361
- console.debug('sortChange callback threw', err);
362
- } catch (e) {}
363
- }
364
- // debug log
365
- try {
366
- console.debug('toggleSortMode', columnKey, mode, sortDirs[columnKey]);
367
- } catch (e) {}
368
- }
369
-
370
- // Clear selection for a column (from within dropdown)
371
- function clearSelection(columnKey) {
372
- clearColumn(columnKey);
373
- }
374
-
375
- // Check all values for a column
376
- function checkAll(columnKey, values) {
377
- const all = Array.isArray(values) ? values.slice() : [];
378
- selections = { ...selections, [columnKey]: all };
379
- scheduleEmit(columnKey, all);
380
- }
381
-
382
- // Invert selection for a column (values is the full option list)
383
- function invertSelection(columnKey, values) {
384
- const current = new Set(selections[columnKey] || []);
385
- const next = [];
386
- for (const v of Array.isArray(values) ? values : []) {
387
- if (!current.has(v)) next.push(v);
388
- }
389
- selections = { ...selections, [columnKey]: next };
390
- scheduleEmit(columnKey, next);
391
- }
392
-
393
- // Uncheck all -> reuse clearColumn
394
- function checkNone(columnKey) {
395
- clearColumn(columnKey);
396
- }
397
-
398
- // Handle a date/datetime range input change
399
- function handleDateRangeChange(columnKey, field, value) {
400
- const current = selections[columnKey] || {};
401
- const updated = { ...current, [field]: value };
402
- selections = { ...selections, [columnKey]: updated };
403
- scheduleEmit(columnKey, updated);
404
- }
405
-
406
- // --- Date-range slider helpers ---
407
-
408
- // Parse a date-filter string (e.g. "2024-01-15" or "2024-01-15T08:30") to a ms timestamp.
409
- // Uses the same rule as filterUtils.matchesDateRange: a bare YYYY-MM-DD string is treated as
410
- // local midnight (appended with "T00:00:00") so slider thumb positions stay consistent with
411
- // how records are matched.
412
- function parseFilterDate(str) {
413
- if (!str) return NaN;
414
- return /^\d{4}-\d{2}-\d{2}$/.test(str)
415
- ? new Date(str + 'T00:00:00').getTime()
416
- : new Date(str).getTime();
417
- }
418
-
419
- // Format a timestamp back to the value expected by <input type="date"> or
420
- // <input type="datetime-local">.
421
- function formatAsInputValue(ms, inputType) {
422
- const d = new Date(ms);
423
- const pad = (n) => String(n).padStart(2, '0');
424
- const dateStr = `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`;
425
- if (inputType === 'datetime-local') {
426
- return `${dateStr}T${pad(d.getHours())}:${pad(d.getMinutes())}`;
427
- }
428
- return dateStr;
429
- }
430
-
431
- // Handle the "from" slider thumb moving.
432
- function handleFromSlider(columnKey, pct, minMs, maxMs, inputType) {
433
- const current = selections[columnKey] || {};
434
- const toMs = parseFilterDate(current.to);
435
- let newFromMs = minMs + (pct / 100) * (maxMs - minMs);
436
- // Clamp: from must not exceed to
437
- if (!isNaN(toMs) && newFromMs > toMs) newFromMs = toMs;
438
- const newFrom = formatAsInputValue(newFromMs, inputType);
439
- const updated = { ...current, from: newFrom };
440
- selections = { ...selections, [columnKey]: updated };
441
- scheduleEmit(columnKey, updated);
442
- }
443
-
444
- // Handle the "to" slider thumb moving.
445
- function handleToSlider(columnKey, pct, minMs, maxMs, inputType) {
446
- const current = selections[columnKey] || {};
447
- const fromMs = parseFilterDate(current.from);
448
- let newToMs = minMs + (pct / 100) * (maxMs - minMs);
449
- // Clamp: to must not be less than from
450
- if (!isNaN(fromMs) && newToMs < fromMs) newToMs = fromMs;
451
- const newTo = formatAsInputValue(newToMs, inputType);
452
- const updated = { ...current, to: newTo };
453
- selections = { ...selections, [columnKey]: updated };
454
- scheduleEmit(columnKey, updated);
455
- }
456
-
457
- // Set the date range from a relative preset (e.g. "last 7 days" → from=now-7d, to=now).
458
- function setRelativeRange(columnKey, value, unit) {
459
- const now = new Date();
460
- const from = new Date(now);
461
- switch (unit) {
462
- case 'hour':
463
- from.setHours(from.getHours() - value);
464
- break;
465
- case 'day':
466
- from.setDate(from.getDate() - value);
467
- break;
468
- case 'week':
469
- from.setDate(from.getDate() - value * 7);
470
- break;
471
- case 'month':
472
- from.setMonth(from.getMonth() - value);
473
- break;
474
- case 'year':
475
- from.setFullYear(from.getFullYear() - value);
476
- break;
477
- }
478
- const col = columnFilters.find((c) => c.key === columnKey);
479
- const inputType = col?.type === 'datetimerange' ? 'datetime-local' : 'date';
480
- const updated = {
481
- from: formatAsInputValue(from.getTime(), inputType),
482
- to: formatAsInputValue(now.getTime(), inputType),
483
- };
484
- selections = { ...selections, [columnKey]: updated };
485
- scheduleEmit(columnKey, updated);
486
- }
487
-
488
- // Return the relative presets applicable to a given column type.
489
- function getApplicablePresets(colType) {
490
- return relativeRangePresets.filter((p) => p.unit !== 'hour' || colType === 'datetimerange');
491
- }
492
-
493
- // Show all dropdowns
494
- function showAllDropdowns() {
495
- const allOpen = {};
496
- for (const col of columnFilters) {
497
- allOpen[col.key] = true;
498
- }
499
- openDropdowns = allOpen;
500
- }
501
-
502
- // Collapse all dropdowns
503
- function collapseAllDropdowns() {
504
- openDropdowns = {};
505
- }
506
-
507
- // Check if all dropdowns are open
508
- const allDropdownsOpen = $derived.by(() => {
509
- return columnFilters.every((col) => openDropdowns[col.key]);
510
- });
511
-
512
- // Check if all dropdowns are closed
513
- const allDropdownsClosed = $derived.by(() => {
514
- return columnFilters.every((col) => !openDropdowns[col.key]);
515
- });
516
- </script>
517
-
518
- <div
519
- class="p-2 bg-gray-50 rounded-md border border-gray-200 dark:bg-gray-800 dark:border-gray-700 {className}"
520
- class:horizontal={direction === 'horizontal'}
521
- class:vertical={direction === 'vertical'}
522
- >
523
- <div class="flex justify-between items-center mb-2 flex-wrap gap-1">
524
- <!-- Left controls: Show All, Close All -->
525
- <div class="flex items-center gap-1 flex-wrap">
526
- <button
527
- class="px-3 py-1 text-sm text-green-600 bg-transparent border border-green-600 rounded-md hover:bg-green-600 hover:text-white transition-all cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-transparent disabled:hover:text-green-600"
528
- disabled={allDropdownsOpen}
529
- onclick={showAllDropdowns}
530
- title="Show all filter dropdowns"
531
- >
532
- Show All
533
- </button>
534
- <button
535
- class="px-3 py-1 text-sm text-gray-600 bg-transparent border border-gray-600 rounded-md hover:bg-gray-600 hover:text-white transition-all cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-transparent disabled:hover:text-gray-600"
536
- disabled={allDropdownsClosed}
537
- onclick={collapseAllDropdowns}
538
- title="Close all filter dropdowns"
539
- >
540
- Close All
541
- </button>
542
- </div>
543
-
544
- <!-- Right controls: active badge and Clear All -->
545
- <div class="flex items-center gap-2 flex-wrap">
546
- {#if hasActiveFilters()}
547
- <Badge color="blue" rounded>{activeFilterCount()} active</Badge>
548
- <button
549
- class="px-3 py-1 text-sm text-red-600 bg-transparent border border-red-600 rounded-md hover:bg-red-600 hover:text-white transition-all cursor-pointer"
550
- onclick={clearAllFilters}
551
- title="Clear all filters"
552
- >
553
- Clear All
554
- </button>
555
- {/if}
556
- </div>
557
- </div>
558
-
559
- <div
560
- class="grid gap-2"
561
- class:grid-horizontal={direction === 'horizontal'}
562
- class:grid-vertical={direction === 'vertical'}
563
- >
564
- {#each columnFilters as column (column.key)}
565
- {@const _sel = selections[column.key]}
566
- {@const isActive = Array.isArray(_sel) ? _sel.length > 0 : !!(_sel?.from || _sel?.to)}
567
- {@const isOpen = openDropdowns[column.key]}
568
- {@const sortedValues = getSortedValues(column)}
569
- {@const currentSortMode = sortModes[column.key] || 'name'}
570
- {@const currentSortDir = sortDirs[column.key] || 'asc'}
571
-
572
- <div class="flex flex-col min-w-0 relative">
573
- <button
574
- id="filter-{column.key}"
575
- class="w-full flex justify-between items-center px-3 py-2 text-sm text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-md hover:border-gray-400 dark:hover:border-gray-500 focus:outline-none focus:border-blue-500 dark:focus:border-blue-400 focus:ring-2 focus:ring-blue-100 dark:focus:ring-blue-900 transition-all cursor-pointer gap-2 {isActive
576
- ? 'border-green-500 dark:border-green-400 bg-green-50 dark:bg-green-900/20'
577
- : ''}"
578
- onclick={() => toggleDropdown(column.key)}
579
- type="button"
580
- >
581
- <span class="flex-1 text-left whitespace-nowrap overflow-hidden text-ellipsis min-w-0">
582
- {column.label || column.key}
583
- </span>
584
- {#if isActive}
585
- {#if Array.isArray(_sel)}
586
- <Badge color="green" rounded class="ml-1">{_sel.length}</Badge>
587
- {:else}
588
- <Badge color="green" rounded class="ml-1">range</Badge>
589
- {/if}
590
- {/if}
591
- <ChevronDownOutline
592
- class="w-5 h-5 shrink-0 transition-transform {isOpen ? 'rotate-180' : ''}"
593
- />
594
- </button>
595
-
596
- {#if isOpen}
597
- <div
598
- class={[
599
- dropdownInline ? '' : 'absolute top-full left-0 right-0',
600
- 'mt-1 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-md shadow-lg dark:shadow-gray-900 flex flex-col dropdown-menu',
601
- isDateRangeColumn(column) ? 'overflow-y-auto' : 'max-h-64',
602
- ]
603
- .filter(Boolean)
604
- .join(' ')}
605
- tabindex="-1"
606
- data-column={column.key}
607
- >
608
- {#if isDateRangeColumn(column)}
609
- <!-- Date / datetime range picker UI -->
610
- {@const inputType = column.type === 'datetimerange' ? 'datetime-local' : 'date'}
611
- {@const dateRange = selections[column.key] || {}}
612
- {@const minMs = parseFilterDate(column.minValue)}
613
- {@const maxMs = parseFilterDate(column.maxValue)}
614
- {@const totalMs = maxMs - minMs}
615
- {@const fromMs = parseFilterDate(dateRange.from)}
616
- {@const toMs = parseFilterDate(dateRange.to)}
617
- {@const fromPct =
618
- totalMs > 0 && !isNaN(fromMs)
619
- ? Math.max(0, Math.min(100, ((fromMs - minMs) / totalMs) * 100))
620
- : 0}
621
- {@const toPct =
622
- totalMs > 0 && !isNaN(toMs)
623
- ? Math.max(0, Math.min(100, ((toMs - minMs) / totalMs) * 100))
624
- : 100}
625
- {@const applicablePresets = getApplicablePresets(column.type)}
626
- <div class="p-3 flex flex-col gap-2">
627
- <!-- From input + Earliest shortcut -->
628
- <div class="flex items-center gap-2">
629
- <label
630
- class="text-xs font-medium text-gray-500 dark:text-gray-400 w-8 shrink-0"
631
- for="filter-{column.key}-from"
632
- >
633
- From
634
- </label>
635
- <input
636
- id="filter-{column.key}-from"
637
- type={inputType}
638
- class="flex-1 min-w-0 px-2 py-1 text-xs border border-gray-200 dark:border-gray-600 rounded bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 focus:outline-none focus:border-blue-500 dark:focus:border-blue-400"
639
- value={dateRange.from || ''}
640
- oninput={(e) =>
641
- handleDateRangeChange(column.key, 'from', e.currentTarget.value)}
642
- />
643
- {#if column.minValue}
644
- <button
645
- type="button"
646
- class="shrink-0 px-2 py-0.5 text-xs rounded border border-indigo-400 text-indigo-700 dark:text-indigo-300 hover:bg-indigo-50 dark:hover:bg-indigo-900/20 transition-colors flex items-center"
647
- title="Set From to the earliest record ({column.minValue})"
648
- aria-label="Set From to the earliest record"
649
- onclick={() => handleDateRangeChange(column.key, 'from', column.minValue)}
650
- >
651
- <!-- Double-chevron-left icon (Earliest) -->
652
- <svg
653
- class="w-4 h-4 text-indigo-700 dark:text-indigo-300"
654
- viewBox="0 0 24 24"
655
- fill="none"
656
- aria-hidden="true"
657
- >
658
- <path
659
- d="M11.5 7.5L7 12l4.5 4.5"
660
- stroke="currentColor"
661
- stroke-width="2"
662
- stroke-linecap="round"
663
- stroke-linejoin="round"
664
- fill="none"
665
- />
666
- <path
667
- d="M17.5 7.5L13 12l4.5 4.5"
668
- stroke="currentColor"
669
- stroke-width="2"
670
- stroke-linecap="round"
671
- stroke-linejoin="round"
672
- fill="none"
673
- />
674
- </svg>
675
- </button>
676
- {/if}
677
- </div>
678
- <!-- To input + Latest shortcut -->
679
- <div class="flex items-center gap-2">
680
- <label
681
- class="text-xs font-medium text-gray-500 dark:text-gray-400 w-8 shrink-0"
682
- for="filter-{column.key}-to"
683
- >
684
- To
685
- </label>
686
- <input
687
- id="filter-{column.key}-to"
688
- type={inputType}
689
- class="flex-1 min-w-0 px-2 py-1 text-xs border border-gray-200 dark:border-gray-600 rounded bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 focus:outline-none focus:border-blue-500 dark:focus:border-blue-400"
690
- value={dateRange.to || ''}
691
- oninput={(e) => handleDateRangeChange(column.key, 'to', e.currentTarget.value)}
692
- />
693
- {#if column.maxValue}
694
- <button
695
- type="button"
696
- class="shrink-0 px-2 py-0.5 text-xs rounded border border-indigo-400 text-indigo-700 dark:text-indigo-300 hover:bg-indigo-50 dark:hover:bg-indigo-900/20 transition-colors flex items-center"
697
- title="Set To to the latest record ({column.maxValue})"
698
- aria-label="Set To to the latest record"
699
- onclick={() => handleDateRangeChange(column.key, 'to', column.maxValue)}
700
- >
701
- <!-- Double-chevron-right icon (Latest) -->
702
- <svg
703
- class="w-4 h-4 text-indigo-700 dark:text-indigo-300"
704
- viewBox="0 0 24 24"
705
- fill="none"
706
- aria-hidden="true"
707
- >
708
- <path
709
- d="M12.5 7.5L17 12l-4.5 4.5"
710
- stroke="currentColor"
711
- stroke-width="2"
712
- stroke-linecap="round"
713
- stroke-linejoin="round"
714
- fill="none"
715
- />
716
- <path
717
- d="M6.5 7.5L11 12l-4.5 4.5"
718
- stroke="currentColor"
719
- stroke-width="2"
720
- stroke-linecap="round"
721
- stroke-linejoin="round"
722
- fill="none"
723
- />
724
- </svg>
725
- </button>
726
- {/if}
727
- </div>
728
-
729
- <!-- Dual-range slider (only when column provides min/max) -->
730
- {#if column.minValue && column.maxValue && totalMs > 0}
731
- <div class="dual-range-wrapper" aria-label="Date range slider">
732
- <!-- Background track -->
733
- <div class="dual-range-track-bg"></div>
734
- <!-- Active-range highlight -->
735
- <div
736
- class="dual-range-track-fill"
737
- style="left:{fromPct}%; right:{100 - toPct}%"
738
- ></div>
739
- <!-- From thumb -->
740
- <input
741
- type="range"
742
- class="dual-range-input"
743
- min="0"
744
- max="100"
745
- step="0.02"
746
- value={fromPct}
747
- style="z-index:{fromPct >= toPct - 2 ? 4 : 3}"
748
- oninput={(e) =>
749
- handleFromSlider(
750
- column.key,
751
- parseFloat(e.currentTarget.value),
752
- minMs,
753
- maxMs,
754
- inputType,
755
- )}
756
- aria-label="Range start"
757
- />
758
- <!-- To thumb -->
759
- <input
760
- type="range"
761
- class="dual-range-input"
762
- min="0"
763
- max="100"
764
- step="0.02"
765
- value={toPct}
766
- style="z-index:{fromPct >= toPct - 2 ? 3 : 4}"
767
- oninput={(e) =>
768
- handleToSlider(
769
- column.key,
770
- parseFloat(e.currentTarget.value),
771
- minMs,
772
- maxMs,
773
- inputType,
774
- )}
775
- aria-label="Range end"
776
- />
777
- </div>
778
- {/if}
779
-
780
- <!-- Relative-range quick buttons -->
781
- {#if applicablePresets.length > 0}
782
- <div
783
- class="flex flex-wrap gap-1 pt-1 border-t border-gray-100 dark:border-gray-600"
784
- >
785
- {#each applicablePresets as preset (preset.label)}
786
- <button
787
- type="button"
788
- class="px-2 py-0.5 text-xs rounded border border-blue-400 text-blue-700 dark:text-blue-300 hover:bg-blue-50 dark:hover:bg-blue-900/20 transition-colors"
789
- title="Last {preset.value} {preset.unit}{preset.value !== 1 ? 's' : ''}"
790
- onclick={() => setRelativeRange(column.key, preset.value, preset.unit)}
791
- >
792
- Last {preset.label}
793
- </button>
794
- {/each}
795
- </div>
796
- {/if}
797
-
798
- {#if dateRange.from || dateRange.to}
799
- <button
800
- type="button"
801
- class="self-start px-2 py-0.5 text-xs text-red-600 border border-red-400 rounded hover:bg-red-50 dark:hover:bg-red-900/20 transition-colors"
802
- onclick={() => clearColumn(column.key)}
803
- >
804
- Clear range
805
- </button>
806
- {/if}
807
- </div>
808
- {:else}
809
- <!-- Value-selection filter UI (checkboxes) -->
810
- <div class="px-1 py-1 border-b border-gray-200 dark:border-gray-600">
811
- <div class="flex items-center gap-1 w-full min-w-0">
812
- <input
813
- type="text"
814
- placeholder="Filter..."
815
- class="p-1 flex-1 min-w-0 px-2 py-1 text-xs border border-gray-200 dark:border-gray-600 rounded bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200 focus:outline-none focus:border-blue-500"
816
- bind:value={searchQueries[column.key]}
817
- />
818
-
819
- <div class="flex items-center gap-1">
820
- <button
821
- class="p-0.5 flex-1 flex items-center justify-center gap-1 text-sm text-gray-600 dark:text-gray-400 bg-transparent border border-gray-200 dark:border-gray-700 rounded hover:bg-gray-100 dark:hover:bg-gray-700 hover:border-gray-300 dark:hover:border-gray-600 hover:text-gray-700 dark:hover:text-gray-300 transition-all"
822
- class:bg-blue-100={currentSortMode === 'name'}
823
- class:dark:bg-blue-900={currentSortMode === 'name'}
824
- onclick={() => toggleSortMode(column.key, 'name')}
825
- title="Sort by name"
826
- type="button"
827
- >
828
- <span
829
- class="flex flex-col items-center leading-none font-semibold"
830
- style="font-size:0.6rem;"
831
- >
832
- <span>A</span>
833
- <span>Z</span>
834
- </span>
835
- <ArrowDownOutline
836
- class={'w-3 h-3 transition-transform ' +
837
- (currentSortMode === 'name'
838
- ? 'text-blue-900 dark:text-blue-100'
839
- : 'text-gray-400 dark:text-gray-500')}
840
- style={currentSortMode === 'name' && currentSortDir === 'asc'
841
- ? 'transform: rotate(180deg);'
842
- : ''}
843
- aria-hidden="true"
844
- />
845
- </button>
846
-
847
- <button
848
- class="p-0.5 flex-1 flex items-center justify-center gap-1 text-sm text-gray-600 dark:text-gray-400 bg-transparent border border-gray-200 dark:border-gray-700 rounded hover:bg-gray-100 dark:hover:bg-gray-700 hover:border-gray-300 dark:hover:border-gray-600 hover:text-gray-700 dark:hover:text-gray-300 transition-all"
849
- class:bg-blue-100={currentSortMode === 'number'}
850
- class:dark:bg-blue-900={currentSortMode === 'number'}
851
- onclick={() => toggleSortMode(column.key, 'number')}
852
- title="Sort by number"
853
- aria-label="Sort by number"
854
- type="button"
855
- >
856
- <span
857
- class="flex flex-col items-center leading-none font-semibold"
858
- style="font-size:0.6rem;"
859
- >
860
- <span>0</span>
861
- <span>9</span>
862
- </span>
863
- <ArrowDownOutline
864
- class={'w-3 h-3 transition-transform ' +
865
- (currentSortMode === 'number'
866
- ? 'text-blue-900 dark:text-blue-100'
867
- : 'text-gray-400 dark:text-gray-500')}
868
- style={currentSortMode === 'number' && currentSortDir === 'asc'
869
- ? 'transform: rotate(180deg);'
870
- : ''}
871
- aria-hidden="true"
872
- />
873
- </button>
874
-
875
- {#if showCounts && column.counts}
876
- <button
877
- class="p-0.5 flex-1 flex items-center justify-center gap-1 text-sm text-gray-600 dark:text-gray-400 bg-transparent border border-gray-200 dark:border-gray-700 rounded hover:bg-gray-100 dark:hover:bg-gray-700 hover:border-gray-300 dark:hover:border-gray-600 hover:text-gray-700 dark:hover:text-gray-300 transition-all"
878
- class:bg-blue-100={currentSortMode === 'count'}
879
- class:dark:bg-blue-900={currentSortMode === 'count'}
880
- onclick={() => toggleSortMode(column.key, 'count')}
881
- title="Sort by count"
882
- type="button"
883
- >
884
- <span class="text-sm font-semibold">#</span>
885
- <ArrowDownOutline
886
- class={'w-3 h-3 transition-transform ' +
887
- (currentSortMode === 'count'
888
- ? 'text-blue-900 dark:text-blue-100'
889
- : 'text-gray-400 dark:text-gray-500')}
890
- style={currentSortMode === 'count' && currentSortDir === 'asc'
891
- ? 'transform: rotate(180deg);'
892
- : ''}
893
- aria-hidden="true"
894
- />
895
- </button>
896
- {/if}
897
- </div>
898
- </div>
899
- </div>
900
-
901
- <!-- Action row: Check all / Invert / Uncheck all (icon buttons) -->
902
- <div class="px-2 py-1 border-b border-gray-100 dark:border-gray-600">
903
- <div class="flex items-center justify-between">
904
- <div class="flex items-center gap-1">
905
- <button
906
- type="button"
907
- class="p-1 rounded-md flex items-center gap-1 text-gray-600 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-600 disabled:opacity-50 disabled:cursor-not-allowed"
908
- onclick={() => checkAll(column.key, sortedValues)}
909
- disabled={sortedValues.length === 0}
910
- aria-label="Check all"
911
- title="Check all"
912
- >
913
- <!-- Checked square icon (higher contrast) -->
914
- <svg
915
- class="w-4 h-4 text-gray-800 dark:text-white"
916
- viewBox="0 0 24 24"
917
- fill="none"
918
- aria-hidden="true"
919
- >
920
- <rect
921
- x="3"
922
- y="3"
923
- width="18"
924
- height="18"
925
- rx="2"
926
- stroke="currentColor"
927
- stroke-width="2.5"
928
- fill="none"
929
- />
930
- <path
931
- d="M7 13l3 3 7-7"
932
- stroke="currentColor"
933
- stroke-width="2"
934
- stroke-linecap="round"
935
- stroke-linejoin="round"
936
- fill="none"
937
- />
938
- </svg>
939
- <span class="text-sm text-gray-800 dark:text-gray-100 select-none">All</span>
940
- </button>
941
-
942
- <button
943
- type="button"
944
- class="p-1 rounded-md flex items-center gap-1 text-gray-600 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-600 disabled:opacity-50 disabled:cursor-not-allowed"
945
- onclick={() => invertSelection(column.key, sortedValues)}
946
- disabled={sortedValues.length === 0}
947
- aria-label="Invert selection"
948
- title="Invert selection"
949
- >
950
- <!-- Half-checked square icon (left half filled) - higher contrast -->
951
- <svg
952
- class="w-4 h-4 text-gray-800 dark:text-white"
953
- viewBox="0 0 24 24"
954
- fill="none"
955
- aria-hidden="true"
956
- >
957
- <rect
958
- x="3"
959
- y="3"
960
- width="18"
961
- height="18"
962
- rx="2"
963
- stroke="currentColor"
964
- stroke-width="2.5"
965
- fill="none"
966
- />
967
- <rect
968
- x="4"
969
- y="4"
970
- width="8.5"
971
- height="16"
972
- fill="currentColor"
973
- opacity="0.28"
974
- stroke="none"
975
- />
976
- <path
977
- d="M7 13l3 3 7-7"
978
- stroke="currentColor"
979
- stroke-width="2"
980
- stroke-linecap="round"
981
- stroke-linejoin="round"
982
- fill="none"
983
- />
984
- </svg>
985
- <span class="text-sm text-gray-800 dark:text-gray-100 select-none"
986
- >Invert</span
987
- >
988
- </button>
989
-
990
- <button
991
- type="button"
992
- class="p-1 rounded-md flex items-center gap-1 text-gray-600 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-600 disabled:opacity-50 disabled:cursor-not-allowed"
993
- onclick={() => checkNone(column.key)}
994
- disabled={sortedValues.length === 0}
995
- aria-label="Uncheck all"
996
- title="Uncheck all"
997
- >
998
- <!-- Empty square icon (higher contrast stroke) -->
999
- <svg
1000
- class="w-4 h-4 text-gray-800 dark:text-white"
1001
- viewBox="0 0 24 24"
1002
- fill="none"
1003
- aria-hidden="true"
1004
- >
1005
- <rect
1006
- x="3"
1007
- y="3"
1008
- width="18"
1009
- height="18"
1010
- rx="2"
1011
- stroke="currentColor"
1012
- stroke-width="2"
1013
- fill="none"
1014
- />
1015
- </svg>
1016
- <span class="text-sm text-gray-800 dark:text-gray-100 select-none">None</span>
1017
- </button>
1018
- </div>
1019
-
1020
- <div class="pr-1">
1021
- <Badge color="blue" rounded title="Total options">{sortedValues.length}</Badge>
1022
- </div>
1023
- </div>
1024
- </div>
1025
-
1026
- <div
1027
- class="p-1 overflow-y-auto flex-1 max-h-48"
1028
- use:registerList={{ key: column.key }}
1029
- >
1030
- {#if sortedValues.length > populateThreshold && !loadedOptions[column.key]}
1031
- <div class="p-1 text-sm text-gray-700 dark:text-gray-200">
1032
- Too many options ({sortedValues.length}) to render by default.
1033
- <button
1034
- class="ml-2 px-2 py-1 text-xs rounded bg-gray-100 dark:bg-gray-600 text-gray-800 dark:text-white border border-gray-200 hover:bg-gray-200 dark:hover:bg-gray-500"
1035
- type="button"
1036
- onclick={() => (loadedOptions = { ...loadedOptions, [column.key]: true })}
1037
- >
1038
- Load options
1039
- </button>
1040
- </div>
1041
- {:else if sortedValues.length > virtualThreshold}
1042
- {@const v = getVirtualSlice(column, sortedValues)}
1043
-
1044
- <div style="height:{v.totalHeight}px; position:relative;">
1045
- <div style="position:absolute; top:{v.top}px; left:0; right:0;">
1046
- {#each v.slice as value, idx (idx)}
1047
- {@const isSelected = selections[column.key]?.includes(value)}
1048
- {@const displayValue =
1049
- value === null || value === undefined ? '(empty)' : String(value)}
1050
-
1051
- <label
1052
- class="flex items-center gap-1 px-2 py-1 cursor-pointer rounded-sm hover:bg-gray-100 dark:hover:bg-gray-600 transition-colors"
1053
- style="height:{virtualItemHeight}px; box-sizing:border-box;"
1054
- >
1055
- <input
1056
- type="checkbox"
1057
- checked={isSelected}
1058
- onchange={() => toggleSelection(column.key, value)}
1059
- class="w-4 h-4 shrink-0 cursor-pointer accent-blue-500"
1060
- />
1061
- <span
1062
- class="flex-1 text-sm text-gray-700 dark:text-gray-300 select-none min-w-0 overflow-hidden text-ellipsis"
1063
- >{displayValue}</span
1064
- >
1065
- {#if showCounts && column.counts && column.counts[value] !== undefined}
1066
- <span class="text-xs text-gray-500 dark:text-gray-400 ml-auto shrink-0"
1067
- >({column.counts[value]})</span
1068
- >
1069
- {/if}
1070
- </label>
1071
- {/each}
1072
- </div>
1073
- </div>
1074
- {:else if sortedValues.length > 0}
1075
- {#each sortedValues as value, idx (idx)}
1076
- {@const isSelected = selections[column.key]?.includes(value)}
1077
- {@const displayValue =
1078
- value === null || value === undefined ? '(empty)' : String(value)}
1079
-
1080
- <label
1081
- class="flex items-center gap-1 px-2 py-1 cursor-pointer rounded-sm hover:bg-gray-100 dark:hover:bg-gray-600 transition-colors"
1082
- >
1083
- <input
1084
- type="checkbox"
1085
- checked={isSelected}
1086
- onchange={() => toggleSelection(column.key, value)}
1087
- class="w-4 h-4 shrink-0 cursor-pointer accent-blue-500"
1088
- />
1089
- <span
1090
- class="flex-1 text-sm text-gray-700 dark:text-gray-300 select-none min-w-0 overflow-hidden text-ellipsis"
1091
- >{displayValue}</span
1092
- >
1093
- {#if showCounts && column.counts && column.counts[value] !== undefined}
1094
- <span class="text-xs text-gray-500 dark:text-gray-400 ml-auto shrink-0"
1095
- >({column.counts[value]})</span
1096
- >
1097
- {/if}
1098
- </label>
1099
- {/each}
1100
- {:else}
1101
- <div class="p-4 text-center text-sm text-gray-400 dark:text-gray-500">
1102
- No values available
1103
- </div>
1104
- {/if}
1105
- </div>
1106
- {/if}
1107
- </div>
1108
- {/if}
1109
- </div>
1110
- {/each}
1111
- </div>
1112
- </div>
1113
-
1114
- <style>
1115
- /* Grid layout classes */
1116
- .grid-horizontal {
1117
- grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
1118
- }
1119
-
1120
- .grid-vertical {
1121
- grid-template-columns: 1fr;
1122
- }
1123
-
1124
- /* Dropdown menu positioning */
1125
- .dropdown-menu {
1126
- z-index: 9999;
1127
- }
1128
-
1129
- /* Responsive adjustments */
1130
- @media (max-width: 768px) {
1131
- .grid-horizontal {
1132
- grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
1133
- }
1134
- }
1135
-
1136
- @media (max-width: 640px) {
1137
- .grid-horizontal {
1138
- grid-template-columns: 1fr;
1139
- }
1140
- }
1141
-
1142
- /* ── Dual-range slider ─────────────────────────────────────────────────── */
1143
- .dual-range-wrapper {
1144
- position: relative;
1145
- height: 20px;
1146
- display: flex;
1147
- align-items: center;
1148
- margin: 4px 0;
1149
- }
1150
-
1151
- .dual-range-track-bg {
1152
- position: absolute;
1153
- left: 0;
1154
- right: 0;
1155
- height: 4px;
1156
- border-radius: 2px;
1157
- background: #d1d5db; /* gray-300 */
1158
- }
1159
-
1160
- :global(.dark) .dual-range-track-bg {
1161
- background: #4b5563; /* gray-600 */
1162
- }
1163
-
1164
- .dual-range-track-fill {
1165
- position: absolute;
1166
- height: 4px;
1167
- border-radius: 2px;
1168
- background: #60a5fa; /* blue-400 */
1169
- pointer-events: none;
1170
- }
1171
-
1172
- :global(.dark) .dual-range-track-fill {
1173
- background: #3b82f6; /* blue-500 */
1174
- }
1175
-
1176
- .dual-range-input {
1177
- position: absolute;
1178
- left: 0;
1179
- width: 100%;
1180
- height: 4px;
1181
- background: none;
1182
- pointer-events: none;
1183
- appearance: none;
1184
- -webkit-appearance: none;
1185
- outline: none;
1186
- margin: 0;
1187
- padding: 0;
1188
- }
1189
-
1190
- /* Webkit thumb */
1191
- .dual-range-input::-webkit-slider-thumb {
1192
- -webkit-appearance: none;
1193
- appearance: none;
1194
- pointer-events: all;
1195
- width: 16px;
1196
- height: 16px;
1197
- border-radius: 50%;
1198
- background: #3b82f6; /* blue-500 */
1199
- cursor: pointer;
1200
- border: 2px solid #ffffff;
1201
- box-shadow: 0 0 0 1px #3b82f6;
1202
- transition: background 0.15s;
1203
- }
1204
-
1205
- .dual-range-input::-webkit-slider-thumb:hover {
1206
- background: #2563eb; /* blue-600 */
1207
- }
1208
-
1209
- /* Firefox thumb */
1210
- .dual-range-input::-moz-range-thumb {
1211
- pointer-events: all;
1212
- width: 14px;
1213
- height: 14px;
1214
- border-radius: 50%;
1215
- background: #3b82f6;
1216
- cursor: pointer;
1217
- border: 2px solid #ffffff;
1218
- box-shadow: 0 0 0 1px #3b82f6;
1219
- transition: background 0.15s;
1220
- }
1221
-
1222
- .dual-range-input::-moz-range-thumb:hover {
1223
- background: #2563eb;
1224
- }
1225
- </style>