@zhangt58/svelte-vtable 0.3.3 → 0.3.4

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.
@@ -33,7 +33,7 @@
33
33
  aria-labelledby="vtable-modal-title"
34
34
  >
35
35
  <div
36
- class="vtable-modal-panel bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-3xl pointer-events-auto overflow-hidden"
36
+ class="vtable-modal-panel bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-sm sm:max-w-2xl lg:max-w-4xl xl:max-w-5xl pointer-events-auto overflow-hidden"
37
37
  >
38
38
  <div
39
39
  class="flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700"
@@ -13,9 +13,18 @@ export function getUniqueValuesWithCounts(data, key) {
13
13
 
14
14
  data.forEach((item) => {
15
15
  const value = item[key];
16
- // Handle null/undefined
17
- const normalizedValue = value ?? '(empty)';
18
- countMap[normalizedValue] = (countMap[normalizedValue] || 0) + 1;
16
+
17
+ if (Array.isArray(value)) {
18
+ // If the value is an array, count each element separately
19
+ for (const v of value) {
20
+ const normalizedV = String(v ?? '');
21
+ countMap[normalizedV] = (countMap[normalizedV] || 0) + 1;
22
+ }
23
+ } else {
24
+ // Handle null/undefined
25
+ const normalizedValue = value ?? '(empty)';
26
+ countMap[normalizedValue] = (countMap[normalizedValue] || 0) + 1;
27
+ }
19
28
  });
20
29
 
21
30
  return {
@@ -150,8 +159,18 @@ export function applyFilters(data, activeFilters) {
150
159
  // Value-based filter (OR logic within column)
151
160
  if (filterValue.length === 0) continue;
152
161
  const itemValue = item[columnKey];
153
- const normalizedItemValue = itemValue ?? '(empty)';
154
- if (!filterValue.includes(normalizedItemValue)) return false;
162
+
163
+ if (Array.isArray(itemValue)) {
164
+ // array value - check if any element matches the filter values
165
+ const hasMatch = itemValue.some((v) =>
166
+ filterValue.includes(String(v ?? ''))
167
+ );
168
+ if (!hasMatch) return false;
169
+ } else {
170
+ // scalar value - treat null/undefined as '(empty)'
171
+ const normalizedItemValue = itemValue ?? '(empty)';
172
+ if (!filterValue.includes(normalizedItemValue)) return false;
173
+ }
155
174
  } else if (typeof filterValue === 'object') {
156
175
  // Date / datetime range filter
157
176
  const { from, to } = filterValue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhangt58/svelte-vtable",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "description": "A Svelte 5 library for virtualized data tables with sorting, selection, and pagination controls.",
5
5
  "type": "module",
6
6
  "sideEffects": [