laif-ds 0.2.56 → 0.2.58
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/dist/_virtual/index3.js +5 -5
- package/dist/_virtual/index4.js +5 -5
- package/dist/_virtual/index5.js +4 -4
- package/dist/agent-docs/components/DataTable.md +331 -254
- package/dist/{lib → components}/design-tokens.js +2 -2
- package/dist/components/ui/app-kanban.js +1 -1
- package/dist/components/ui/app-radio-group.js +1 -1
- package/dist/components/ui/app-select.js +1 -1
- package/dist/components/ui/async-select.js +154 -142
- package/dist/components/ui/badge.js +1 -1
- package/dist/components/ui/button.js +2 -2
- package/dist/components/ui/card.js +1 -1
- package/dist/components/ui/checkbox.js +1 -1
- package/dist/components/ui/date-picker.js +2 -8
- package/dist/components/ui/dialog.js +1 -1
- package/dist/components/ui/input.js +1 -1
- package/dist/components/{kanban.js → ui/kanban.js} +7 -7
- package/dist/components/ui/popover.js +1 -1
- package/dist/components/ui/radio-group.js +1 -1
- package/dist/components/ui/select.js +1 -1
- package/dist/components/ui/sheet.js +1 -1
- package/dist/components/ui/switch.js +1 -1
- package/dist/components/ui/tables/data-table/components/data-table-body.js +10 -10
- package/dist/components/ui/tables/data-table/data-table.js +40 -38
- package/dist/components/ui/tables/data-table/data-table.utils.js +22 -19
- package/dist/components/ui/tabs.js +1 -1
- package/dist/components/ui/textarea.js +1 -1
- package/dist/index.d.ts +6 -4
- package/dist/node_modules/eventemitter3/index.js +1 -1
- package/dist/node_modules/hast-util-to-jsx-runtime/lib/index.js +1 -1
- package/dist/node_modules/recharts/es6/util/Events.js +1 -1
- package/dist/node_modules/unified/lib/index.js +1 -1
- package/dist/styles.v3.css +1 -1
- package/package.json +10 -10
package/dist/_virtual/index3.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { getDefaultExportFromCjs as
|
|
3
|
-
import { __require as
|
|
4
|
-
var
|
|
5
|
-
const
|
|
2
|
+
import { getDefaultExportFromCjs as e } from "./_commonjsHelpers.js";
|
|
3
|
+
import { __require as t } from "../node_modules/eventemitter3/index2.js";
|
|
4
|
+
var r = t();
|
|
5
|
+
const m = /* @__PURE__ */ e(r);
|
|
6
6
|
export {
|
|
7
|
-
|
|
7
|
+
m as default
|
|
8
8
|
};
|
package/dist/_virtual/index4.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { getDefaultExportFromCjs as
|
|
3
|
-
import { __require as
|
|
4
|
-
var t =
|
|
5
|
-
const
|
|
2
|
+
import { getDefaultExportFromCjs as r } from "./_commonjsHelpers.js";
|
|
3
|
+
import { __require as e } from "../node_modules/style-to-js/cjs/index.js";
|
|
4
|
+
var t = e();
|
|
5
|
+
const a = /* @__PURE__ */ r(t);
|
|
6
6
|
export {
|
|
7
|
-
|
|
7
|
+
a as default
|
|
8
8
|
};
|
package/dist/_virtual/index5.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { getDefaultExportFromCjs as e } from "./_commonjsHelpers.js";
|
|
3
|
-
import { __require as
|
|
4
|
-
var
|
|
5
|
-
const
|
|
3
|
+
import { __require as r } from "../node_modules/extend/index.js";
|
|
4
|
+
var t = r();
|
|
5
|
+
const x = /* @__PURE__ */ e(t);
|
|
6
6
|
export {
|
|
7
|
-
|
|
7
|
+
x as default
|
|
8
8
|
};
|
|
@@ -1,254 +1,331 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
1
|
+
# DataTable
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
Powerful table built on TanStack Table v8. Supports client-side and server-side modes with a unified API, advanced filtering (badges + builder), global search, multi-column sorting, row selection, column pinning, dynamic pagination, i18n, and loading skeletons.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Props
|
|
10
|
+
|
|
11
|
+
| Prop | Type | Default | Description |
|
|
12
|
+
| ---------------------- | ------------------------------------- | ---------------------- | --------------------------------------------------------------------- |
|
|
13
|
+
| `columns` | `ColumnDef<TData, TValue>[]` | — | TanStack column definitions. Use `meta` to enable features. |
|
|
14
|
+
| `data` | `TData[]` | — | Table data. |
|
|
15
|
+
| `loading` | `boolean` | `false` | Show skeleton rows. |
|
|
16
|
+
| `emptyComponent` | `ReactNode` | `undefined` | Rendered when no rows. |
|
|
17
|
+
| `className` | `string` | `undefined` | Wrapper classes. |
|
|
18
|
+
| `checkable` | `boolean` | `false` | Adds a left checkbox column for row selection. |
|
|
19
|
+
| `rowSelection` | `Record<string, boolean>` | `{}` | Controlled selection map. |
|
|
20
|
+
| `onRowSelectionChange` | `OnChangeFn<Record<string, boolean>>` | `undefined` | Selection change handler (controlled selection). |
|
|
21
|
+
| `onCheckedRowsChange` | `(checkedRows: TData[]) => void` | `undefined` | Returns selected row values (requires `checkable`). |
|
|
22
|
+
| `actions` | `DataTableActions[]` | `[]` | Actions for the actions row. |
|
|
23
|
+
| `hidePagination` | `boolean` | `false` | Hide pagination UI. |
|
|
24
|
+
| `hideActionsRow` | `boolean` | `false` | Hide actions row. |
|
|
25
|
+
| `i18n` | `DataTableI18n` | `defaultDataTableI18n` | Internationalization strings. |
|
|
26
|
+
| `maxSortedColumns` | `number` | `2` | Max number of sorted columns. |
|
|
27
|
+
| `initialState` | `DataTableState<TData>` | `undefined` | Initial filters, sorting, pagination and optional `columnVisibility`. |
|
|
28
|
+
| `serverMode` | `boolean` | `false` | Enable server-side mode. |
|
|
29
|
+
| `serverConfig` | `DataTableServerConfig` | `undefined` | `{ totalItems, onStateChange }` handler for server mode. |
|
|
30
|
+
| `disableAutoPageSize` | `boolean` | `false` | Disable auto pageSize (still updates pageIndex). |
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Column meta
|
|
35
|
+
|
|
36
|
+
Configure columns via `column.meta`:
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
type ColumnMeta = {
|
|
40
|
+
type:
|
|
41
|
+
| "string"
|
|
42
|
+
| "number"
|
|
43
|
+
| "boolean"
|
|
44
|
+
| "date"
|
|
45
|
+
| "datetime"
|
|
46
|
+
| "list_single_select"
|
|
47
|
+
| "list_multi_select"
|
|
48
|
+
| "other";
|
|
49
|
+
sortable?: boolean;
|
|
50
|
+
filterable?: boolean;
|
|
51
|
+
searchable?: boolean;
|
|
52
|
+
pinned?: "left" | "right";
|
|
53
|
+
listOptions?: { value: string; label: string }[];
|
|
54
|
+
};
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Notes:
|
|
58
|
+
|
|
59
|
+
- `id` must match the field key used for filtering/sorting.
|
|
60
|
+
- Header should be a simple string (not JSX) for proper filtering/sorting UI.
|
|
61
|
+
- Filtering nested accessors (e.g., `"user.name"`) is not supported.
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## Behavior
|
|
66
|
+
|
|
67
|
+
- **Filtering**: Badge filters + advanced builder with logical `_and`/`_or`.
|
|
68
|
+
- **Global search**: Across `meta.searchable` columns; strings use `like`, arrays use `array_overlap` (mapped automatically).
|
|
69
|
+
- **Operators**: Full operator set per type, including `eq_null`/`n_eq_null`, list operators (`array_overlap`, `n_array_overlap`), date/time before/after, checked/unchecked.
|
|
70
|
+
- **Sorting**: Multi-column (limited by `maxSortedColumns`).
|
|
71
|
+
- **Selection**: Integrated checkbox column when `checkable`.
|
|
72
|
+
- **Column visibility**: Columns can start hidden via `initialState.columnVisibility` and be toggled from the eye icon popover in the toolbar.
|
|
73
|
+
- **Pinning**: `meta.pinned` supports left/right pinned columns.
|
|
74
|
+
- **Pagination**: Auto page size from container height; respects `disableAutoPageSize`.
|
|
75
|
+
- **Loading**: Skeleton rows adapt to viewport height (no hardcoded length).
|
|
76
|
+
- **i18n**: All labels (sorting/filtering menus included) use `DataTableI18n`.
|
|
77
|
+
- **Datetime**: Supports microseconds format like `2025-08-22T12:53:54.060315` and timezone-safe date handling.
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## Server-side mode
|
|
82
|
+
|
|
83
|
+
When `serverMode=true`, the table emits state to `serverConfig.onStateChange(state)` with:
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
type ServerState = {
|
|
87
|
+
pagination: { pageIndex: number; pageSize: number };
|
|
88
|
+
filters?: IFilterState;
|
|
89
|
+
computedFilter?: SearchFilter;
|
|
90
|
+
computedSorting?: { sort_by: string[]; sort_order: ("asc" | "desc")[] };
|
|
91
|
+
};
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
The table manages debounced emissions and preserves computed values across updates.
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## Examples
|
|
99
|
+
|
|
100
|
+
### Client mode using utilities (columns + filters + initial state)
|
|
101
|
+
|
|
102
|
+
```tsx
|
|
103
|
+
import * as React from "react";
|
|
104
|
+
import type { ColumnDef } from "@tanstack/react-table";
|
|
105
|
+
import {
|
|
106
|
+
DataTable,
|
|
107
|
+
createStringColumn,
|
|
108
|
+
createNumberColumn,
|
|
109
|
+
createSingleSelectColumn,
|
|
110
|
+
createMultiSelectColumn,
|
|
111
|
+
createActionColumn,
|
|
112
|
+
createInitialState,
|
|
113
|
+
createStringFilter,
|
|
114
|
+
createNumberFilter,
|
|
115
|
+
} from "laif-ds";
|
|
116
|
+
import { Button } from "laif-ds";
|
|
117
|
+
|
|
118
|
+
type Person = {
|
|
119
|
+
id: string;
|
|
120
|
+
name: string;
|
|
121
|
+
age: number;
|
|
122
|
+
role: string;
|
|
123
|
+
tags: string[];
|
|
124
|
+
created_at: string;
|
|
125
|
+
active: boolean;
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
const columns = [
|
|
129
|
+
createStringColumn<Person>({
|
|
130
|
+
accessorKey: "name",
|
|
131
|
+
header: "Nome",
|
|
132
|
+
sortable: true,
|
|
133
|
+
filterable: true,
|
|
134
|
+
searchable: true,
|
|
135
|
+
}),
|
|
136
|
+
createNumberColumn<Person>({
|
|
137
|
+
accessorKey: "age",
|
|
138
|
+
header: "Età",
|
|
139
|
+
sortable: true,
|
|
140
|
+
filterable: true,
|
|
141
|
+
}),
|
|
142
|
+
createSingleSelectColumn<Person>({
|
|
143
|
+
accessorKey: "role",
|
|
144
|
+
header: "Ruolo",
|
|
145
|
+
options: ["Admin", "User", "Guest"],
|
|
146
|
+
filterable: true,
|
|
147
|
+
searchable: true,
|
|
148
|
+
}),
|
|
149
|
+
createMultiSelectColumn<Person>({
|
|
150
|
+
accessorKey: "tags",
|
|
151
|
+
header: "Tags",
|
|
152
|
+
options: ["frontend", "backend", "devops"],
|
|
153
|
+
filterable: true,
|
|
154
|
+
}),
|
|
155
|
+
createActionColumn<Person>({
|
|
156
|
+
id: "actions",
|
|
157
|
+
header: "Azioni",
|
|
158
|
+
pinned: "right",
|
|
159
|
+
cell: (row) => <Button size="sm">Edit {row.name}</Button>,
|
|
160
|
+
}),
|
|
161
|
+
] satisfies ColumnDef<Person, any>[];
|
|
162
|
+
|
|
163
|
+
const initialState = createInitialState({
|
|
164
|
+
filters: [
|
|
165
|
+
createStringFilter("name", "name", "Nome", "like", "John"),
|
|
166
|
+
createNumberFilter("age", "age", "Età", "ge", 18),
|
|
167
|
+
],
|
|
168
|
+
searchbarFilter: "developer",
|
|
169
|
+
sorting: [{ column: "name", order: "asc" }],
|
|
170
|
+
pagination: { pageIndex: 0, pageSize: 15 },
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
const actions = [
|
|
174
|
+
{
|
|
175
|
+
label: "Export CSV",
|
|
176
|
+
icon: "FileDown",
|
|
177
|
+
onClick: () => {
|
|
178
|
+
/* ... */
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
label: "Bulk Delete",
|
|
183
|
+
icon: "Trash2",
|
|
184
|
+
onClick: () => {
|
|
185
|
+
/* ... */
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
];
|
|
189
|
+
|
|
190
|
+
export function ClientTable({ data }: { data: Person[] }) {
|
|
191
|
+
return (
|
|
192
|
+
<DataTable
|
|
193
|
+
columns={columns}
|
|
194
|
+
data={data}
|
|
195
|
+
initialState={initialState}
|
|
196
|
+
actions={actions}
|
|
197
|
+
checkable
|
|
198
|
+
onCheckedRowsChange={(rows) => console.log("checked rows", rows)}
|
|
199
|
+
/>
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### Server mode using utilities (state-driven fetch)
|
|
205
|
+
|
|
206
|
+
```tsx
|
|
207
|
+
import * as React from "react";
|
|
208
|
+
import type { ServerState } from "laif-ds";
|
|
209
|
+
import { DataTable, createInitialState } from "laif-ds";
|
|
210
|
+
|
|
211
|
+
export function ServerTable({
|
|
212
|
+
data,
|
|
213
|
+
total,
|
|
214
|
+
}: {
|
|
215
|
+
data: Person[];
|
|
216
|
+
total: number;
|
|
217
|
+
}) {
|
|
218
|
+
const [loading, setLoading] = React.useState(false);
|
|
219
|
+
|
|
220
|
+
const handleState = React.useCallback(async (state: ServerState) => {
|
|
221
|
+
// Use state.pagination, state.computedFilter, state.computedSorting
|
|
222
|
+
// to fetch from your backend
|
|
223
|
+
setLoading(true);
|
|
224
|
+
try {
|
|
225
|
+
await fetch("/api/people", {
|
|
226
|
+
method: "POST",
|
|
227
|
+
headers: { "Content-Type": "application/json" },
|
|
228
|
+
body: JSON.stringify(state),
|
|
229
|
+
});
|
|
230
|
+
// Update your data + total here based on response
|
|
231
|
+
} finally {
|
|
232
|
+
setLoading(false);
|
|
233
|
+
}
|
|
234
|
+
}, []);
|
|
235
|
+
|
|
236
|
+
return (
|
|
237
|
+
<DataTable
|
|
238
|
+
columns={columns}
|
|
239
|
+
data={data}
|
|
240
|
+
loading={loading}
|
|
241
|
+
serverMode
|
|
242
|
+
serverConfig={{ totalItems: total, onStateChange: handleState }}
|
|
243
|
+
initialState={createInitialState({
|
|
244
|
+
pagination: { pageIndex: 0, pageSize: 20 },
|
|
245
|
+
})}
|
|
246
|
+
checkable
|
|
247
|
+
/>
|
|
248
|
+
);
|
|
249
|
+
}
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
### Initial column visibility
|
|
253
|
+
|
|
254
|
+
You can start with some columns hidden and let the user control them via the column-visibility (eye) popover:
|
|
255
|
+
|
|
256
|
+
```tsx
|
|
257
|
+
const initialStateWithHiddenColumns = createInitialState<Person>({
|
|
258
|
+
pagination: { pageIndex: 0, pageSize: 15 },
|
|
259
|
+
sorting: [{ column: "name", order: "asc" }],
|
|
260
|
+
columnVisibility: {
|
|
261
|
+
// these columns will start hidden in the UI
|
|
262
|
+
secret_field: false,
|
|
263
|
+
debug_column: false,
|
|
264
|
+
},
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
export function TableWithHiddenColumns({ data }: { data: Person[] }) {
|
|
268
|
+
return (
|
|
269
|
+
<DataTable
|
|
270
|
+
columns={columns}
|
|
271
|
+
data={data}
|
|
272
|
+
initialState={initialStateWithHiddenColumns}
|
|
273
|
+
/>
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
### Utility recipes (pinning, list options, quick filters)
|
|
279
|
+
|
|
280
|
+
```tsx
|
|
281
|
+
import {
|
|
282
|
+
pinColumns,
|
|
283
|
+
updateColumnListOptions,
|
|
284
|
+
toSelectOptions,
|
|
285
|
+
createFilterBadges,
|
|
286
|
+
createStringFilter,
|
|
287
|
+
createNumberFilter,
|
|
288
|
+
} from "laif-ds";
|
|
289
|
+
|
|
290
|
+
// Pin columns to left/right
|
|
291
|
+
const pinnedColumns = pinColumns(columns, {
|
|
292
|
+
left: ["name"],
|
|
293
|
+
right: ["actions"],
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
// Update list options dynamically (e.g., fetched from API)
|
|
297
|
+
const roleOptions = toSelectOptions(["Admin", "User", "Guest", "Manager"]);
|
|
298
|
+
const columnsWithUpdatedRoles = updateColumnListOptions(
|
|
299
|
+
columns,
|
|
300
|
+
"role",
|
|
301
|
+
roleOptions,
|
|
302
|
+
);
|
|
303
|
+
|
|
304
|
+
// Build multiple filter badges quickly
|
|
305
|
+
const quickFilters = createFilterBadges([
|
|
306
|
+
{
|
|
307
|
+
columnId: "name",
|
|
308
|
+
columnAccessorKey: "name",
|
|
309
|
+
columnLabel: "Nome",
|
|
310
|
+
columnType: "string",
|
|
311
|
+
operator: "like",
|
|
312
|
+
value: "Jane",
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
columnId: "age",
|
|
316
|
+
columnAccessorKey: "age",
|
|
317
|
+
columnLabel: "Età",
|
|
318
|
+
columnType: "number",
|
|
319
|
+
operator: "ge",
|
|
320
|
+
value: 30,
|
|
321
|
+
},
|
|
322
|
+
]);
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
---
|
|
326
|
+
|
|
327
|
+
## Notes
|
|
328
|
+
|
|
329
|
+
- **Performance**: Client mode filters/sorts in-memory; use server mode for large datasets.
|
|
330
|
+
- **UX**: Page size auto-adapts; use `disableAutoPageSize` to manage it manually.
|
|
331
|
+
- **Internationalization**: Provide custom `i18n` for localized actions and labels.
|
|
@@ -41,8 +41,8 @@ const e = {
|
|
|
41
41
|
},
|
|
42
42
|
// Dropdown item specific
|
|
43
43
|
dropdownItem: {
|
|
44
|
-
selected: "bg-d-primary/10 text-d-primary font-medium",
|
|
45
|
-
hover: "data-[selected=true]:bg-d-accent/50 data-[selected=true]:text-d-accent-foreground"
|
|
44
|
+
selected: "bg-d-primary/10 text-d-primary font-medium data-[selected=true]:text-d-primary data-[selected=true]:bg-d-primary/30 hover:text-d-primary hover:bg-d-primary/30",
|
|
45
|
+
hover: "data-[selected=true]:bg-d-accent/50 data-[selected=true]:text-d-accent-foreground hover:bg-d-accent/50 hover:text-d-accent-foreground"
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
48
|
export {
|