@zhangt58/svelte-vtable 0.6.1 → 0.6.2

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.
@@ -83,6 +83,8 @@ export function matchesDateRange(value: any, from: string | null | undefined, to
83
83
  * Supports both value-selection filters (array) and date/datetime range filters
84
84
  * (object with optional `from` and `to` string fields).
85
85
  * @param {Array} data - Array of data objects to filter
86
+ * Selected values are matched by their string form, so numeric, boolean and Date
87
+ * cell values match the option strings derived from them.
86
88
  * @param {Object} activeFilters - Active filters: { columnKey: string[] | {from?, to?} }
87
89
  * @returns {Array} Filtered data array
88
90
  */
@@ -248,6 +248,8 @@ export function matchesDateRange(value, from, to) {
248
248
  * Supports both value-selection filters (array) and date/datetime range filters
249
249
  * (object with optional `from` and `to` string fields).
250
250
  * @param {Array} data - Array of data objects to filter
251
+ * Selected values are matched by their string form, so numeric, boolean and Date
252
+ * cell values match the option strings derived from them.
251
253
  * @param {Object} activeFilters - Active filters: { columnKey: string[] | {from?, to?} }
252
254
  * @returns {Array} Filtered data array
253
255
  */
@@ -265,15 +267,18 @@ export function applyFilters(data, activeFilters) {
265
267
  // Value-based filter (OR logic within column)
266
268
  if (filterValue.length === 0) continue;
267
269
  const itemValue = item[columnKey];
270
+ // Compare as strings: the options come from getUniqueValuesWithCounts,
271
+ // whose Object.keys() turns numbers, booleans and dates into strings.
272
+ const selected = filterValue.map((v) => String(v));
268
273
 
269
274
  if (Array.isArray(itemValue)) {
270
275
  // array value - check if any element matches the filter values
271
- const hasMatch = itemValue.some((v) => filterValue.includes(String(v ?? '')));
276
+ const hasMatch = itemValue.some((v) => selected.includes(String(v ?? '')));
272
277
  if (!hasMatch) return false;
273
278
  } else {
274
279
  // scalar value - treat null/undefined as '(empty)'
275
- const normalizedItemValue = itemValue ?? '(empty)';
276
- if (!filterValue.includes(normalizedItemValue)) return false;
280
+ const normalizedItemValue = itemValue == null ? '(empty)' : String(itemValue);
281
+ if (!selected.includes(normalizedItemValue)) return false;
277
282
  }
278
283
  } else if (typeof filterValue === 'object') {
279
284
  // Date / datetime range filter
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhangt58/svelte-vtable",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "description": "A Svelte 5 library for virtualized data tables with sorting, selection, and pagination controls.",
5
5
  "type": "module",
6
6
  "sideEffects": [