@snowpact/react-tanstack-query-table 1.1.0 → 1.1.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.
package/README.md CHANGED
@@ -24,7 +24,29 @@ pnpm add @snowpact/react-tanstack-query-table
24
24
  npm install @tanstack/react-query @tanstack/react-table react react-dom
25
25
  ```
26
26
 
27
- > **Tailwind CSS** is required. Make sure Tailwind is configured in your app.
27
+ ### Tailwind CSS Configuration
28
+
29
+ Tailwind CSS is required. You must configure Tailwind to scan the package's classes:
30
+
31
+ **In your `tailwind.config.css` (Tailwind v4):**
32
+
33
+ ```css
34
+ /* Include SnowTable classes for Tailwind scanning */
35
+ @source "node_modules/@snowpact/react-tanstack-query-table/dist";
36
+ ```
37
+
38
+ **Or in `tailwind.config.js` (Tailwind v3):**
39
+
40
+ ```js
41
+ module.exports = {
42
+ content: [
43
+ // ... your app files
44
+ './node_modules/@snowpact/react-tanstack-query-table/dist/**/*.js',
45
+ ],
46
+ };
47
+ ```
48
+
49
+ > **Note**: The path may vary depending on your project structure. If using a monorepo or workspace, adjust the path accordingly (e.g., `../../node_modules/...`).
28
50
 
29
51
  ## Quick Start
30
52
 
@@ -48,14 +70,14 @@ setupSnowTable({
48
70
  ### 2. Use a Client Table
49
71
 
50
72
  ```tsx
51
- import { SnowClientTable, SnowColumnConfig } from '@snowpact/react-tanstack-query-table';
73
+ import { SnowClientDataTable, SnowColumnConfig } from '@snowpact/react-tanstack-query-table';
52
74
  import { Edit, Trash } from 'lucide-react';
53
75
 
54
76
  type User = { id: string; name: string; email: string };
55
77
 
56
78
  const columns: SnowColumnConfig<User>[] = [{ key: 'name' }, { key: 'email' }];
57
79
 
58
- <SnowClientTable
80
+ <SnowClientDataTable
59
81
  queryKey={['users']}
60
82
  fetchAllItemsEndpoint={() => fetchUsers()}
61
83
  columnConfig={columns}
@@ -72,27 +94,27 @@ const columns: SnowColumnConfig<User>[] = [{ key: 'name' }, { key: 'email' }];
72
94
 
73
95
  | Mode | Component | Use case | Data handling |
74
96
  | ---------- | ----------------- | ------------- | ----------------------------------------------- |
75
- | **Client** | `SnowClientTable` | < 5,000 items | All data loaded, filtered/sorted locally |
76
- | **Server** | `SnowServerTable` | > 5,000 items | Paginated API, server handles filtering/sorting |
97
+ | **Client** | `SnowClientDataTable` | < 5,000 items | All data loaded, filtered/sorted locally |
98
+ | **Server** | `SnowServerDataTable` | > 5,000 items | Paginated API, server handles filtering/sorting |
77
99
 
78
- ### SnowClientTable
100
+ ### SnowClientDataTable
79
101
 
80
102
  Best for small to medium datasets. Fetches all data once via React Query, then handles pagination, search, and sorting entirely in the browser.
81
103
 
82
104
  ```tsx
83
- <SnowClientTable
105
+ <SnowClientDataTable
84
106
  queryKey={['users']}
85
107
  fetchAllItemsEndpoint={() => api.getUsers()} // Returns User[]
86
108
  columnConfig={columns}
87
109
  />
88
110
  ```
89
111
 
90
- ### SnowServerTable
112
+ ### SnowServerDataTable
91
113
 
92
114
  Best for large datasets. The server handles pagination, search, filtering, and sorting. Returns paginated results with a total count.
93
115
 
94
116
  ```tsx
95
- import { SnowServerTable, ServerFetchParams } from '@snowpact/react-tanstack-query-table';
117
+ import { SnowServerDataTable, ServerFetchParams } from '@snowpact/react-tanstack-query-table';
96
118
 
97
119
  const fetchUsers = async (params: ServerFetchParams) => {
98
120
  // params: { limit, offset, search?, sortBy?, sortOrder?, filters?, prefilter? }
@@ -103,7 +125,7 @@ const fetchUsers = async (params: ServerFetchParams) => {
103
125
  };
104
126
  };
105
127
 
106
- <SnowServerTable queryKey={['users']} fetchServerEndpoint={fetchUsers} columnConfig={columns} />;
128
+ <SnowServerDataTable queryKey={['users']} fetchServerEndpoint={fetchUsers} columnConfig={columns} />;
107
129
  ```
108
130
 
109
131
  ## Actions
@@ -230,7 +252,7 @@ actions={[
230
252
  Enable fuzzy search across all columns:
231
253
 
232
254
  ```tsx
233
- <SnowClientTable enableGlobalSearch texts={{ searchPlaceholder: 'Search users...' }} />
255
+ <SnowClientDataTable enableGlobalSearch texts={{ searchPlaceholder: 'Search users...' }} />
234
256
  ```
235
257
 
236
258
  For custom search values (computed columns):
@@ -251,7 +273,7 @@ const columns: SnowColumnConfig<User>[] = [
251
273
  Multi-select dropdown filters:
252
274
 
253
275
  ```tsx
254
- <SnowClientTable
276
+ <SnowClientDataTable
255
277
  filters={[
256
278
  {
257
279
  key: 'status',
@@ -278,7 +300,7 @@ Multi-select dropdown filters:
278
300
  Quick segmentation via tabs:
279
301
 
280
302
  ```tsx
281
- <SnowClientTable
303
+ <SnowClientDataTable
282
304
  prefilters={[
283
305
  { id: 'all', label: 'All' },
284
306
  { id: 'active', label: 'Active' },
@@ -300,7 +322,7 @@ For server mode, the `prefilter` value is sent to your endpoint.
300
322
  Users can show/hide columns via a settings button. Configuration is saved in cookies.
301
323
 
302
324
  ```tsx
303
- <SnowClientTable
325
+ <SnowClientDataTable
304
326
  enableColumnConfiguration
305
327
  columnConfig={[
306
328
  { key: 'name' }, // Always visible
@@ -315,7 +337,7 @@ Users can show/hide columns via a settings button. Configuration is saved in coo
315
337
  Persist table state (pagination, search, filters, sorting) in URL query params:
316
338
 
317
339
  ```tsx
318
- <SnowClientTable
340
+ <SnowClientDataTable
319
341
  persistState // State saved in URL
320
342
  />
321
343
  ```
@@ -346,13 +368,13 @@ URL params used:
346
368
  ### Sorting
347
369
 
348
370
  ```tsx
349
- <SnowClientTable enableSorting defaultSortBy="createdAt" defaultSortOrder="desc" />
371
+ <SnowClientDataTable enableSorting defaultSortBy="createdAt" defaultSortOrder="desc" />
350
372
  ```
351
373
 
352
374
  ### Pagination
353
375
 
354
376
  ```tsx
355
- <SnowClientTable
377
+ <SnowClientDataTable
356
378
  enablePagination
357
379
  defaultPageSize={25}
358
380
  displayTotalNumber // Show "X elements"
@@ -363,7 +385,7 @@ URL params used:
363
385
  ### Row Click
364
386
 
365
387
  ```tsx
366
- <SnowClientTable
388
+ <SnowClientDataTable
367
389
  onRowClick={item => navigate(`/users/${item.id}`)}
368
390
  activeRowId={selectedUserId} // Highlight active row
369
391
  />
@@ -404,7 +426,7 @@ setupSnowTable({
404
426
 
405
427
  ## API Reference
406
428
 
407
- ### SnowClientTable Props
429
+ ### SnowClientDataTable Props
408
430
 
409
431
  | Prop | Type | Default | Description |
410
432
  | --------------------------- | ----------------------- | -------- | ------------------------------- |
@@ -425,9 +447,9 @@ setupSnowTable({
425
447
  | `defaultSortBy` | `string` | - | Initial sort column |
426
448
  | `defaultSortOrder` | `'asc' \| 'desc'` | `'asc'` | Initial sort direction |
427
449
 
428
- ### SnowServerTable Props
450
+ ### SnowServerDataTable Props
429
451
 
430
- Same as `SnowClientTable`, except:
452
+ Same as `SnowClientDataTable`, except:
431
453
 
432
454
  | Prop | Type | Description |
433
455
  | --------------------- | -------------------------------------------------------------------- | ------------------------ |