@shotleybuilder/svelte-table-kit 0.13.2 → 0.14.0

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.
@@ -67,6 +67,7 @@ let configInitialized = false;
67
67
  let grouping = writable([]);
68
68
  let expanded = writable(true);
69
69
  let groupBarExpanded = false;
70
+ let globalFilter = "";
70
71
  let cellContextMenu = {
71
72
  show: false,
72
73
  x: 0,
@@ -193,6 +194,7 @@ let draggedColumnId = null;
193
194
  const options = writable({
194
195
  data: filteredData,
195
196
  columns,
197
+ globalFilterFn: "includesString",
196
198
  columnResizeMode: "onChange",
197
199
  enableColumnResizing: features.columnResizing !== false,
198
200
  enableGrouping: features.grouping !== false,
@@ -208,7 +210,15 @@ const options = writable({
208
210
  columnFilters: $columnFilters,
209
211
  columnOrder: $columnOrder,
210
212
  grouping: $grouping,
211
- expanded: $expanded
213
+ expanded: $expanded,
214
+ globalFilter
215
+ },
216
+ onGlobalFilterChange: (updater) => {
217
+ if (updater instanceof Function) {
218
+ globalFilter = updater(globalFilter);
219
+ } else {
220
+ globalFilter = updater;
221
+ }
212
222
  },
213
223
  onSortingChange: (updater) => {
214
224
  if (updater instanceof Function) {
@@ -276,7 +286,8 @@ $: options.update((old) => ({
276
286
  columnFilters: $columnFilters,
277
287
  columnOrder: $columnOrder,
278
288
  grouping: $grouping,
279
- expanded: $expanded
289
+ expanded: $expanded,
290
+ globalFilter
280
291
  }
281
292
  }));
282
293
  const table = createSvelteTable(options);
@@ -352,6 +363,7 @@ $: if (onStateChange) {
352
363
  columnSizing: $columnSizing,
353
364
  columnFilters: $filterConditions,
354
365
  sorting: $sorting.map((s) => ({ columnId: s.id, direction: s.desc ? "desc" : "asc" })),
366
+ globalFilter,
355
367
  pagination: $table.getState().pagination
356
368
  });
357
369
  }
@@ -359,13 +371,39 @@ $: if (onStateChange) {
359
371
 
360
372
  <div class="table-kit-container align-{align}">
361
373
  <!-- Filters and Controls -->
362
- {#if features.filtering !== false || features.grouping !== false || features.columnVisibility !== false || (features.sorting !== false && features.sortingMode === 'control')}
374
+ {#if features.filtering !== false || features.grouping !== false || features.columnVisibility !== false || (features.sorting !== false && features.sortingMode === 'control') || features.globalSearch === true}
363
375
  <div class="table-kit-toolbar">
364
376
  <!-- Slot for custom left-side controls (e.g., view selector, save buttons) -->
365
377
  <div class="table-kit-custom-controls">
366
378
  <slot name="toolbar-left" />
367
379
  </div>
368
380
 
381
+ <!-- Global Search -->
382
+ {#if features.globalSearch === true}
383
+ <div class="table-kit-global-search">
384
+ <svg class="search-icon" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
385
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" />
386
+ </svg>
387
+ <input
388
+ type="text"
389
+ class="search-input"
390
+ placeholder="Search all columns..."
391
+ bind:value={globalFilter}
392
+ />
393
+ {#if globalFilter}
394
+ <button
395
+ class="search-clear"
396
+ on:click={() => (globalFilter = '')}
397
+ title="Clear search"
398
+ >
399
+ <svg fill="none" stroke="currentColor" viewBox="0 0 24 24">
400
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
401
+ </svg>
402
+ </button>
403
+ {/if}
404
+ </div>
405
+ {/if}
406
+
369
407
  <!-- Filter Controls -->
370
408
  {#if features.filtering !== false}
371
409
  <div class="table-kit-filters">
@@ -950,6 +988,69 @@ $: if (onStateChange) {
950
988
  margin-right: auto;
951
989
  }
952
990
 
991
+ /* Global search */
992
+ .table-kit-global-search {
993
+ position: relative;
994
+ display: flex;
995
+ align-items: center;
996
+ flex-shrink: 0;
997
+ }
998
+
999
+ .table-kit-global-search .search-icon {
1000
+ position: absolute;
1001
+ left: 0.5rem;
1002
+ width: 1rem;
1003
+ height: 1rem;
1004
+ color: #9ca3af;
1005
+ pointer-events: none;
1006
+ }
1007
+
1008
+ .table-kit-global-search .search-input {
1009
+ padding: 0.375rem 1.75rem 0.375rem 1.75rem;
1010
+ border: 1px solid #d1d5db;
1011
+ border-radius: 0.375rem;
1012
+ font-size: 0.8125rem;
1013
+ line-height: 1.25rem;
1014
+ width: 220px;
1015
+ outline: none;
1016
+ transition: border-color 0.15s, box-shadow 0.15s;
1017
+ }
1018
+
1019
+ .table-kit-global-search .search-input:focus {
1020
+ border-color: #3b82f6;
1021
+ box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
1022
+ }
1023
+
1024
+ .table-kit-global-search .search-input::placeholder {
1025
+ color: #9ca3af;
1026
+ }
1027
+
1028
+ .table-kit-global-search .search-clear {
1029
+ position: absolute;
1030
+ right: 0.375rem;
1031
+ display: flex;
1032
+ align-items: center;
1033
+ justify-content: center;
1034
+ width: 1.125rem;
1035
+ height: 1.125rem;
1036
+ border: none;
1037
+ background: none;
1038
+ color: #9ca3af;
1039
+ cursor: pointer;
1040
+ padding: 0;
1041
+ border-radius: 50%;
1042
+ }
1043
+
1044
+ .table-kit-global-search .search-clear:hover {
1045
+ color: #4b5563;
1046
+ background: #f3f4f6;
1047
+ }
1048
+
1049
+ .table-kit-global-search .search-clear svg {
1050
+ width: 0.875rem;
1051
+ height: 0.875rem;
1052
+ }
1053
+
953
1054
  .table-kit-filters {
954
1055
  flex: 1;
955
1056
  }
package/dist/types.d.ts CHANGED
@@ -25,6 +25,7 @@ export interface TableFeatures {
25
25
  pagination?: boolean;
26
26
  rowSelection?: boolean;
27
27
  grouping?: boolean;
28
+ globalSearch?: boolean;
28
29
  columnPinning?: boolean;
29
30
  }
30
31
  export interface TableConfig {
@@ -105,6 +106,7 @@ export interface TableState {
105
106
  columnSizing: Record<string, number>;
106
107
  columnFilters: FilterCondition[];
107
108
  sorting: SortConfig[];
109
+ globalFilter: string;
108
110
  pagination: {
109
111
  pageIndex: number;
110
112
  pageSize: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shotleybuilder/svelte-table-kit",
3
- "version": "0.13.2",
3
+ "version": "0.14.0",
4
4
  "description": "A comprehensive, AI-configurable data table component for Svelte and SvelteKit, built on TanStack Table v8",
5
5
  "author": "Sertantai",
6
6
  "license": "MIT",