@r2digisolutions/ui 0.27.3 → 0.28.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.
- package/dist/components/container/DataTableShell/DataTableShell.svelte +631 -0
- package/dist/components/container/DataTableShell/DataTableShell.svelte.d.ts +48 -0
- package/dist/components/container/DataTableShell/components/AdvancedFiltersBuilder.svelte +311 -0
- package/dist/components/container/DataTableShell/components/AdvancedFiltersBuilder.svelte.d.ts +7 -0
- package/dist/components/container/DataTableShell/components/ColumnVisibilityMenu.svelte +112 -0
- package/dist/components/container/DataTableShell/components/ColumnVisibilityMenu.svelte.d.ts +8 -0
- package/dist/components/container/DataTableShell/components/ContextMenu.svelte +70 -0
- package/dist/components/container/DataTableShell/components/ContextMenu.svelte.d.ts +30 -0
- package/dist/components/container/DataTableShell/components/DataTableFiltersSidebar.svelte +0 -0
- package/dist/components/container/DataTableShell/components/DataTableFiltersSidebar.svelte.d.ts +26 -0
- package/dist/components/container/DataTableShell/components/DataTableFooter.svelte +36 -0
- package/dist/components/container/DataTableShell/components/DataTableFooter.svelte.d.ts +18 -0
- package/dist/components/container/DataTableShell/components/DataTableToolbar.svelte +822 -0
- package/dist/components/container/DataTableShell/components/DataTableToolbar.svelte.d.ts +30 -0
- package/dist/components/container/DataTableShell/components/Pagination.svelte +117 -0
- package/dist/components/container/DataTableShell/components/Pagination.svelte.d.ts +28 -0
- package/dist/components/container/DataTableShell/components/Submenu.svelte +109 -0
- package/dist/components/container/DataTableShell/components/Submenu.svelte.d.ts +30 -0
- package/dist/components/container/DataTableShell/components/Toolbar.svelte +0 -0
- package/dist/components/container/DataTableShell/components/Toolbar.svelte.d.ts +26 -0
- package/dist/components/container/DataTableShell/core/DataTableController.svelte.d.ts +54 -0
- package/dist/components/container/DataTableShell/core/DataTableController.svelte.js +148 -0
- package/dist/components/container/DataTableShell/core/DataTableEngine.svelte.d.ts +68 -0
- package/dist/components/container/DataTableShell/core/DataTableEngine.svelte.js +319 -0
- package/dist/components/container/DataTableShell/core/DataTableInternal.svelte.d.ts +68 -0
- package/dist/components/container/DataTableShell/core/DataTableInternal.svelte.js +396 -0
- package/dist/components/container/DataTableShell/core/context.d.ts +3 -0
- package/dist/components/container/DataTableShell/core/context.js +12 -0
- package/dist/components/container/DataTableShell/core/filters-types.d.ts +14 -0
- package/dist/components/container/DataTableShell/core/filters-types.js +1 -0
- package/dist/components/container/DataTableShell/core/types.d.ts +60 -0
- package/dist/components/container/DataTableShell/core/types.js +1 -0
- package/dist/components/container/index.d.ts +3 -1
- package/dist/components/container/index.js +3 -1
- package/package.json +13 -13
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
export class DataTableInternal {
|
|
2
|
+
options;
|
|
3
|
+
rows = $state([]);
|
|
4
|
+
loading = $state(false);
|
|
5
|
+
page = $state(1);
|
|
6
|
+
pageSize = $state(20);
|
|
7
|
+
mode = 'pagination';
|
|
8
|
+
sortColumn = $state(null);
|
|
9
|
+
sortDirection = $state('asc');
|
|
10
|
+
search = $state('');
|
|
11
|
+
filters = $state({});
|
|
12
|
+
selectedIds = $state(new Set());
|
|
13
|
+
hiddenColumnIds = $state(new Set());
|
|
14
|
+
columnWidths = $state({});
|
|
15
|
+
multiSelect = false;
|
|
16
|
+
maxVisibleColumns;
|
|
17
|
+
columns = $state([]);
|
|
18
|
+
stickyColumnsIds = [];
|
|
19
|
+
stickyRowsPredicate;
|
|
20
|
+
query = $state(null);
|
|
21
|
+
constructor(options) {
|
|
22
|
+
this.options = options;
|
|
23
|
+
this.columns = options.columns.map((c) => {
|
|
24
|
+
const min = c.minWidth ?? 120;
|
|
25
|
+
const def = c.defaultWidth ?? min ?? 160;
|
|
26
|
+
return {
|
|
27
|
+
minWidth: min,
|
|
28
|
+
defaultWidth: def,
|
|
29
|
+
searchable: true,
|
|
30
|
+
align: c.align ?? 'left',
|
|
31
|
+
...c
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
this.pageSize = options.pageSize ?? 20;
|
|
35
|
+
this.mode = options.mode ?? 'pagination';
|
|
36
|
+
this.multiSelect = options.multiSelect ?? false;
|
|
37
|
+
this.maxVisibleColumns = options.maxVisibleColumns;
|
|
38
|
+
this.stickyColumnsIds = options.stickyColumns ?? [];
|
|
39
|
+
this.stickyRowsPredicate = options.stickyRows;
|
|
40
|
+
}
|
|
41
|
+
getRowId(row, index) {
|
|
42
|
+
if (this.options.idField)
|
|
43
|
+
return this.options.idField(row, index);
|
|
44
|
+
const anyRow = row;
|
|
45
|
+
if (anyRow && anyRow.id != null)
|
|
46
|
+
return String(anyRow.id);
|
|
47
|
+
return String(index);
|
|
48
|
+
}
|
|
49
|
+
setRows(rows) {
|
|
50
|
+
this.rows = rows;
|
|
51
|
+
this.page = 1;
|
|
52
|
+
this.selectedIds = new Set();
|
|
53
|
+
}
|
|
54
|
+
appendRows(rows) {
|
|
55
|
+
this.rows = [...this.rows, ...rows];
|
|
56
|
+
}
|
|
57
|
+
setLoading(value) {
|
|
58
|
+
this.loading = value;
|
|
59
|
+
}
|
|
60
|
+
setMode(mode) {
|
|
61
|
+
this.mode = mode;
|
|
62
|
+
}
|
|
63
|
+
setPage(page) {
|
|
64
|
+
const max = this.pageCount;
|
|
65
|
+
const next = Math.min(Math.max(1, page), max);
|
|
66
|
+
this.page = next;
|
|
67
|
+
}
|
|
68
|
+
nextPage() {
|
|
69
|
+
this.setPage(this.page + 1);
|
|
70
|
+
}
|
|
71
|
+
prevPage() {
|
|
72
|
+
this.setPage(this.page - 1);
|
|
73
|
+
}
|
|
74
|
+
setPageSize(size) {
|
|
75
|
+
this.pageSize = size;
|
|
76
|
+
this.page = 1;
|
|
77
|
+
}
|
|
78
|
+
setSearch(value) {
|
|
79
|
+
this.search = value;
|
|
80
|
+
this.page = 1;
|
|
81
|
+
}
|
|
82
|
+
setFilter(id, value) {
|
|
83
|
+
const copy = { ...this.filters };
|
|
84
|
+
if (!value) {
|
|
85
|
+
delete copy[id];
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
copy[id] = { id, value };
|
|
89
|
+
}
|
|
90
|
+
this.filters = copy;
|
|
91
|
+
this.page = 1;
|
|
92
|
+
}
|
|
93
|
+
clearFilters() {
|
|
94
|
+
this.filters = {};
|
|
95
|
+
}
|
|
96
|
+
setSort(columnId) {
|
|
97
|
+
if (this.sortColumn === columnId) {
|
|
98
|
+
this.sortDirection = this.sortDirection === 'asc' ? 'desc' : 'asc';
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
this.sortColumn = columnId;
|
|
102
|
+
this.sortDirection = 'asc';
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
clearSort() {
|
|
106
|
+
this.sortColumn = null;
|
|
107
|
+
this.sortDirection = 'asc';
|
|
108
|
+
}
|
|
109
|
+
setQuery(query) {
|
|
110
|
+
this.query = query;
|
|
111
|
+
this.page = 1;
|
|
112
|
+
}
|
|
113
|
+
clearQuery() {
|
|
114
|
+
this.query = null;
|
|
115
|
+
this.page = 1;
|
|
116
|
+
}
|
|
117
|
+
toggleRowSelection(id) {
|
|
118
|
+
const next = new Set(this.selectedIds);
|
|
119
|
+
if (next.has(id))
|
|
120
|
+
next.delete(id);
|
|
121
|
+
else
|
|
122
|
+
next.add(id);
|
|
123
|
+
this.selectedIds = next;
|
|
124
|
+
}
|
|
125
|
+
selectAllVisible(rows) {
|
|
126
|
+
const next = new Set(this.selectedIds);
|
|
127
|
+
rows.forEach((row, index) => {
|
|
128
|
+
const id = this.getRowId(row, index);
|
|
129
|
+
next.add(id);
|
|
130
|
+
});
|
|
131
|
+
this.selectedIds = next;
|
|
132
|
+
}
|
|
133
|
+
clearSelection() {
|
|
134
|
+
this.selectedIds = new Set();
|
|
135
|
+
}
|
|
136
|
+
isRowSelected(id) {
|
|
137
|
+
return this.selectedIds.has(id);
|
|
138
|
+
}
|
|
139
|
+
toggleColumnVisibility(id) {
|
|
140
|
+
const next = new Set(this.hiddenColumnIds);
|
|
141
|
+
if (next.has(id))
|
|
142
|
+
next.delete(id);
|
|
143
|
+
else
|
|
144
|
+
next.add(id);
|
|
145
|
+
this.hiddenColumnIds = next;
|
|
146
|
+
}
|
|
147
|
+
hideColumn(id) {
|
|
148
|
+
const next = new Set(this.hiddenColumnIds);
|
|
149
|
+
next.add(id);
|
|
150
|
+
this.hiddenColumnIds = next;
|
|
151
|
+
}
|
|
152
|
+
showColumn(id) {
|
|
153
|
+
const next = new Set(this.hiddenColumnIds);
|
|
154
|
+
next.delete(id);
|
|
155
|
+
this.hiddenColumnIds = next;
|
|
156
|
+
}
|
|
157
|
+
showAllColumns() {
|
|
158
|
+
this.hiddenColumnIds = new Set();
|
|
159
|
+
}
|
|
160
|
+
hideAllColumns() {
|
|
161
|
+
const all = new Set();
|
|
162
|
+
this.columns.forEach((c) => all.add(c.id));
|
|
163
|
+
this.hiddenColumnIds = all;
|
|
164
|
+
}
|
|
165
|
+
setColumnWidth(id, width) {
|
|
166
|
+
const next = { ...this.columnWidths };
|
|
167
|
+
const col = this.columns.find((c) => c.id === id);
|
|
168
|
+
const min = col?.minWidth ?? 120;
|
|
169
|
+
const max = col?.maxWidth ?? 480;
|
|
170
|
+
next[id] = Math.min(Math.max(width, min), max);
|
|
171
|
+
this.columnWidths = next;
|
|
172
|
+
}
|
|
173
|
+
resetColumnWidths() {
|
|
174
|
+
this.columnWidths = {};
|
|
175
|
+
}
|
|
176
|
+
getColumnWidth(id) {
|
|
177
|
+
const raw = this.columnWidths[id];
|
|
178
|
+
if (raw)
|
|
179
|
+
return raw;
|
|
180
|
+
const col = this.columns.find((c) => c.id === id);
|
|
181
|
+
if (!col)
|
|
182
|
+
return 160;
|
|
183
|
+
const base = col.defaultWidth ?? col.minWidth ?? 160;
|
|
184
|
+
return base;
|
|
185
|
+
}
|
|
186
|
+
allColumns = $derived.by(() => this.columns);
|
|
187
|
+
visibleColumns = $derived.by(() => this.columns.filter((c) => !this.hiddenColumnIds.has(c.id)));
|
|
188
|
+
mainColumns = $derived.by(() => {
|
|
189
|
+
if (!this.maxVisibleColumns || this.visibleColumns.length <= this.maxVisibleColumns) {
|
|
190
|
+
return this.visibleColumns;
|
|
191
|
+
}
|
|
192
|
+
return this.visibleColumns.slice(0, this.maxVisibleColumns);
|
|
193
|
+
});
|
|
194
|
+
overflowColumns = $derived.by(() => {
|
|
195
|
+
if (!this.maxVisibleColumns || this.visibleColumns.length <= this.maxVisibleColumns) {
|
|
196
|
+
return [];
|
|
197
|
+
}
|
|
198
|
+
return this.visibleColumns.slice(this.maxVisibleColumns);
|
|
199
|
+
});
|
|
200
|
+
getFieldValue(row, field) {
|
|
201
|
+
const col = this.columns.find((c) => c.id === field);
|
|
202
|
+
if (col && col.accessor)
|
|
203
|
+
return col.accessor(row);
|
|
204
|
+
return row[field];
|
|
205
|
+
}
|
|
206
|
+
evalOperator(value, operator, raw) {
|
|
207
|
+
const v = value;
|
|
208
|
+
const target = raw;
|
|
209
|
+
if (operator === 'is_empty') {
|
|
210
|
+
return v === null || v === undefined || v === '' || (Array.isArray(v) && v.length === 0);
|
|
211
|
+
}
|
|
212
|
+
if (operator === 'is_not_empty') {
|
|
213
|
+
return !(v === null || v === undefined || v === '' || (Array.isArray(v) && v.length === 0));
|
|
214
|
+
}
|
|
215
|
+
if (operator === 'in' || operator === 'not_in') {
|
|
216
|
+
const list = Array.isArray(target)
|
|
217
|
+
? target
|
|
218
|
+
: String(target)
|
|
219
|
+
.split(',')
|
|
220
|
+
.map((x) => x.trim())
|
|
221
|
+
.filter(Boolean);
|
|
222
|
+
const str = v == null ? '' : String(v);
|
|
223
|
+
const result = list.some((x) => String(x) === str);
|
|
224
|
+
return operator === 'in' ? result : !result;
|
|
225
|
+
}
|
|
226
|
+
if (typeof v === 'number' && typeof target === 'number') {
|
|
227
|
+
if (operator === 'equals')
|
|
228
|
+
return v === target;
|
|
229
|
+
if (operator === 'not_equals')
|
|
230
|
+
return v !== target;
|
|
231
|
+
if (operator === 'greater_than')
|
|
232
|
+
return v > target;
|
|
233
|
+
if (operator === 'less_than')
|
|
234
|
+
return v < target;
|
|
235
|
+
}
|
|
236
|
+
const vs = v == null ? '' : String(v).toLowerCase();
|
|
237
|
+
const ts = String(target).toLowerCase();
|
|
238
|
+
if (operator === 'equals')
|
|
239
|
+
return vs === ts;
|
|
240
|
+
if (operator === 'not_equals')
|
|
241
|
+
return vs !== ts;
|
|
242
|
+
if (operator === 'contains')
|
|
243
|
+
return vs.includes(ts);
|
|
244
|
+
if (operator === 'not_contains')
|
|
245
|
+
return !vs.includes(ts);
|
|
246
|
+
if (operator === 'greater_than')
|
|
247
|
+
return vs > ts;
|
|
248
|
+
if (operator === 'less_than')
|
|
249
|
+
return vs < ts;
|
|
250
|
+
if (operator === 'startsWith')
|
|
251
|
+
return vs.startsWith(ts);
|
|
252
|
+
if (operator === 'endsWith')
|
|
253
|
+
return vs.endsWith(ts);
|
|
254
|
+
return true;
|
|
255
|
+
}
|
|
256
|
+
evalFilter(row, filter) {
|
|
257
|
+
const [field, operator, value] = filter;
|
|
258
|
+
const v = this.getFieldValue(row, field);
|
|
259
|
+
return this.evalOperator(v, operator, value);
|
|
260
|
+
}
|
|
261
|
+
evalQueryFilters(row, join, items) {
|
|
262
|
+
if (!items.length)
|
|
263
|
+
return true;
|
|
264
|
+
if (join === 'AND') {
|
|
265
|
+
for (const item of items) {
|
|
266
|
+
let ok = true;
|
|
267
|
+
if (Array.isArray(item))
|
|
268
|
+
ok = this.evalFilter(row, item);
|
|
269
|
+
else
|
|
270
|
+
ok = this.evalQueryGroup(row, item);
|
|
271
|
+
if (!ok)
|
|
272
|
+
return false;
|
|
273
|
+
}
|
|
274
|
+
return true;
|
|
275
|
+
}
|
|
276
|
+
for (const item of items) {
|
|
277
|
+
let ok = false;
|
|
278
|
+
if (Array.isArray(item))
|
|
279
|
+
ok = this.evalFilter(row, item);
|
|
280
|
+
else
|
|
281
|
+
ok = this.evalQueryGroup(row, item);
|
|
282
|
+
if (ok)
|
|
283
|
+
return true;
|
|
284
|
+
}
|
|
285
|
+
return false;
|
|
286
|
+
}
|
|
287
|
+
evalQueryGroup(row, group) {
|
|
288
|
+
return this.evalQueryFilters(row, group.joinOperation, group.filters);
|
|
289
|
+
}
|
|
290
|
+
evalQuery(row, query) {
|
|
291
|
+
if (!query.useQuery || !query.filters.length)
|
|
292
|
+
return true;
|
|
293
|
+
return this.evalQueryFilters(row, query.joinOperation, query.filters);
|
|
294
|
+
}
|
|
295
|
+
filteredRows = $derived.by(() => {
|
|
296
|
+
let data = this.rows;
|
|
297
|
+
const search = this.search.trim().toLowerCase();
|
|
298
|
+
if (search) {
|
|
299
|
+
data = data.filter((row) => {
|
|
300
|
+
return this.visibleColumns.some((col) => {
|
|
301
|
+
if (col.searchable === false)
|
|
302
|
+
return false;
|
|
303
|
+
const value = this.getFieldValue(row, col.id);
|
|
304
|
+
if (value == null)
|
|
305
|
+
return false;
|
|
306
|
+
const str = String(value).toLowerCase();
|
|
307
|
+
return str.includes(search);
|
|
308
|
+
});
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
const filters = Object.values(this.filters);
|
|
312
|
+
if (filters.length) {
|
|
313
|
+
data = data.filter((row) => {
|
|
314
|
+
return filters.every((f) => {
|
|
315
|
+
const col = this.columns.find((c) => c.id === f.id);
|
|
316
|
+
if (!col)
|
|
317
|
+
return true;
|
|
318
|
+
const value = this.getFieldValue(row, col.id);
|
|
319
|
+
if (value == null)
|
|
320
|
+
return false;
|
|
321
|
+
const str = String(value).toLowerCase();
|
|
322
|
+
return str.includes(f.value.toLowerCase());
|
|
323
|
+
});
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
if (this.query && this.query.useQuery && this.query.filters.length) {
|
|
327
|
+
const q = this.query;
|
|
328
|
+
data = data.filter((row) => this.evalQuery(row, q));
|
|
329
|
+
}
|
|
330
|
+
if (this.sortColumn) {
|
|
331
|
+
const col = this.columns.find((c) => c.id === this.sortColumn);
|
|
332
|
+
if (col) {
|
|
333
|
+
const dir = this.sortDirection === 'asc' ? 1 : -1;
|
|
334
|
+
data = [...data].sort((a, b) => {
|
|
335
|
+
const av = this.getFieldValue(a, col.id);
|
|
336
|
+
const bv = this.getFieldValue(b, col.id);
|
|
337
|
+
if (av == null && bv == null)
|
|
338
|
+
return 0;
|
|
339
|
+
if (av == null)
|
|
340
|
+
return -1 * dir;
|
|
341
|
+
if (bv == null)
|
|
342
|
+
return 1 * dir;
|
|
343
|
+
if (typeof av === 'number' && typeof bv === 'number') {
|
|
344
|
+
if (av === bv)
|
|
345
|
+
return 0;
|
|
346
|
+
return av > bv ? dir : -dir;
|
|
347
|
+
}
|
|
348
|
+
const as = String(av).toLowerCase();
|
|
349
|
+
const bs = String(bv).toLowerCase();
|
|
350
|
+
if (as === bs)
|
|
351
|
+
return 0;
|
|
352
|
+
return as > bs ? dir : -dir;
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
return data;
|
|
357
|
+
});
|
|
358
|
+
totalRows = $derived.by(() => this.filteredRows.length);
|
|
359
|
+
pageCount = $derived.by(() => {
|
|
360
|
+
if (this.mode === 'infinite')
|
|
361
|
+
return 1;
|
|
362
|
+
if (!this.totalRows)
|
|
363
|
+
return 1;
|
|
364
|
+
return Math.max(1, Math.ceil(this.totalRows / this.pageSize));
|
|
365
|
+
});
|
|
366
|
+
currentRows = $derived.by(() => {
|
|
367
|
+
if (this.mode === 'infinite')
|
|
368
|
+
return this.filteredRows;
|
|
369
|
+
const start = (this.page - 1) * this.pageSize;
|
|
370
|
+
const end = start + this.pageSize;
|
|
371
|
+
return this.filteredRows.slice(start, end);
|
|
372
|
+
});
|
|
373
|
+
selectedCount = $derived.by(() => this.selectedIds.size);
|
|
374
|
+
allVisibleSelected = $derived.by(() => {
|
|
375
|
+
if (!this.currentRows.length)
|
|
376
|
+
return false;
|
|
377
|
+
let all = true;
|
|
378
|
+
this.currentRows.forEach((row, index) => {
|
|
379
|
+
const id = this.getRowId(row, index);
|
|
380
|
+
if (!this.selectedIds.has(id))
|
|
381
|
+
all = false;
|
|
382
|
+
});
|
|
383
|
+
return all;
|
|
384
|
+
});
|
|
385
|
+
someVisibleSelected = $derived.by(() => {
|
|
386
|
+
if (!this.currentRows.length)
|
|
387
|
+
return false;
|
|
388
|
+
let some = false;
|
|
389
|
+
this.currentRows.forEach((row, index) => {
|
|
390
|
+
const id = this.getRowId(row, index);
|
|
391
|
+
if (this.selectedIds.has(id))
|
|
392
|
+
some = true;
|
|
393
|
+
});
|
|
394
|
+
return some && !this.allVisibleSelected;
|
|
395
|
+
});
|
|
396
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { getContext, setContext } from 'svelte';
|
|
2
|
+
const TABLE_CTX = Symbol('datagrid');
|
|
3
|
+
export function provideTable(controller) {
|
|
4
|
+
setContext(TABLE_CTX, controller);
|
|
5
|
+
}
|
|
6
|
+
export function useTable() {
|
|
7
|
+
const ctx = getContext(TABLE_CTX);
|
|
8
|
+
if (!ctx) {
|
|
9
|
+
throw new Error('DataTable context not found');
|
|
10
|
+
}
|
|
11
|
+
return ctx;
|
|
12
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type FilterOperator = 'equals' | 'contains' | 'greater_than' | 'less_than' | 'startsWith' | 'endsWith' | 'not_equals' | 'is_empty' | 'is_not_empty' | 'not_contains' | 'in' | 'not_in';
|
|
2
|
+
export type Operator = 'AND' | 'OR';
|
|
3
|
+
export type Filter = [string, FilterOperator, string | number | boolean | string[]];
|
|
4
|
+
export type QueryGroup = {
|
|
5
|
+
type: 'group';
|
|
6
|
+
joinOperation: Operator;
|
|
7
|
+
filters: TQueryFilter;
|
|
8
|
+
};
|
|
9
|
+
export type TQueryFilter = (Filter | QueryGroup)[];
|
|
10
|
+
export type QueryStructure = {
|
|
11
|
+
useQuery: boolean;
|
|
12
|
+
joinOperation: Operator;
|
|
13
|
+
filters: TQueryFilter;
|
|
14
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export type SortDirection = 'asc' | 'desc';
|
|
2
|
+
export type DataTableMode = 'pagination' | 'infinite';
|
|
3
|
+
export type ColumnAlign = 'left' | 'center' | 'right';
|
|
4
|
+
export type ColumnType = 'text' | 'number' | 'date' | 'datetime' | 'badge';
|
|
5
|
+
export interface ColumnDef<T> {
|
|
6
|
+
id: keyof T;
|
|
7
|
+
label: string;
|
|
8
|
+
accessor?: (row: T) => unknown;
|
|
9
|
+
sortable?: boolean;
|
|
10
|
+
minWidth?: number;
|
|
11
|
+
maxWidth?: number;
|
|
12
|
+
defaultWidth?: number;
|
|
13
|
+
hidden?: boolean;
|
|
14
|
+
align?: ColumnAlign;
|
|
15
|
+
searchable?: boolean;
|
|
16
|
+
type?: ColumnType;
|
|
17
|
+
format?: (value: unknown, row: T) => string;
|
|
18
|
+
sticky?: 'left' | 'right';
|
|
19
|
+
}
|
|
20
|
+
export interface RowAction<T> {
|
|
21
|
+
id: string;
|
|
22
|
+
label: ((row: T) => any) | string;
|
|
23
|
+
danger?: boolean;
|
|
24
|
+
icon?: (row: T) => unknown;
|
|
25
|
+
onClick?: (row: T) => Promise<void> | void;
|
|
26
|
+
children?: RowAction<T>[];
|
|
27
|
+
}
|
|
28
|
+
export interface DataTableOptions<T> {
|
|
29
|
+
idField?: (row: T, index: number) => string;
|
|
30
|
+
columns: ColumnDef<T>[];
|
|
31
|
+
pageSize?: number;
|
|
32
|
+
mode?: DataTableMode;
|
|
33
|
+
multiSelect?: boolean;
|
|
34
|
+
maxVisibleColumns?: number;
|
|
35
|
+
stickyColumns?: string[];
|
|
36
|
+
stickyRows?: (row: T, index: number) => boolean;
|
|
37
|
+
}
|
|
38
|
+
export interface ColumnFilter {
|
|
39
|
+
id: string;
|
|
40
|
+
value: string;
|
|
41
|
+
}
|
|
42
|
+
export type FilterOperator = 'equals' | 'contains' | 'greater_than' | 'less_than' | 'startsWith' | 'endsWith' | 'not_equals' | 'is_empty' | 'is_not_empty' | 'not_contains' | 'in' | 'not_in';
|
|
43
|
+
export type LogicOperator = 'AND' | 'OR';
|
|
44
|
+
export type Filter = [string, FilterOperator, string | number | boolean];
|
|
45
|
+
export type QueryFilter = Filter | QueryGroup;
|
|
46
|
+
export type TQueryFilter = QueryFilter[];
|
|
47
|
+
export type QueryGroup = {
|
|
48
|
+
type: 'group';
|
|
49
|
+
joinOperation: LogicOperator;
|
|
50
|
+
filters: QueryFilter[];
|
|
51
|
+
};
|
|
52
|
+
export type QueryStructure = {
|
|
53
|
+
useQuery: boolean;
|
|
54
|
+
joinOperation: LogicOperator;
|
|
55
|
+
filters: QueryFilter[];
|
|
56
|
+
};
|
|
57
|
+
export type AnyAction<T> = RowAction<T> & {
|
|
58
|
+
children?: AnyAction<T>[];
|
|
59
|
+
hidden?: ((row: T) => boolean) | boolean;
|
|
60
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import DataTable from './DataTable/DataTable.svelte';
|
|
2
2
|
import TabsStepper from './TabsStepper/TabsStepper.svelte';
|
|
3
|
+
import DataTableShell from './DataTableShell/DataTableShell.svelte';
|
|
4
|
+
import { DataTableController } from './DataTableShell/core/DataTableController.svelte.js';
|
|
3
5
|
export * from './DataTable/core/types.js';
|
|
4
6
|
export * from './TabsStepper/core/types.js';
|
|
5
|
-
export { DataTable, TabsStepper };
|
|
7
|
+
export { DataTable, TabsStepper, DataTableShell, DataTableController };
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import DataTable from './DataTable/DataTable.svelte';
|
|
2
2
|
import TabsStepper from './TabsStepper/TabsStepper.svelte';
|
|
3
|
+
import DataTableShell from './DataTableShell/DataTableShell.svelte';
|
|
4
|
+
import { DataTableController } from './DataTableShell/core/DataTableController.svelte.js';
|
|
3
5
|
export * from './DataTable/core/types.js';
|
|
4
6
|
export * from './TabsStepper/core/types.js';
|
|
5
|
-
export { DataTable, TabsStepper };
|
|
7
|
+
export { DataTable, TabsStepper, DataTableShell, DataTableController };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@r2digisolutions/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"packageManager": "bun@1.3.3",
|
|
6
6
|
"publishConfig": {
|
|
@@ -55,35 +55,35 @@
|
|
|
55
55
|
"@storybook/addon-interactions": "8.6.14",
|
|
56
56
|
"@storybook/addon-svelte-csf": "5.0.10",
|
|
57
57
|
"@storybook/blocks": "8.6.14",
|
|
58
|
-
"@storybook/svelte": "10.1.
|
|
59
|
-
"@storybook/sveltekit": "10.1.
|
|
58
|
+
"@storybook/svelte": "10.1.4",
|
|
59
|
+
"@storybook/sveltekit": "10.1.4",
|
|
60
60
|
"@storybook/test": "8.6.14",
|
|
61
61
|
"@sveltejs/adapter-static": "3.0.10",
|
|
62
|
-
"@sveltejs/kit": "2.49.
|
|
62
|
+
"@sveltejs/kit": "2.49.1",
|
|
63
63
|
"@sveltejs/package": "2.5.7",
|
|
64
64
|
"@sveltejs/vite-plugin-svelte": "6.2.1",
|
|
65
65
|
"@tailwindcss/postcss": "4.1.17",
|
|
66
66
|
"@testing-library/svelte": "5.2.9",
|
|
67
|
-
"@vitest/browser": "4.0.
|
|
67
|
+
"@vitest/browser": "4.0.15",
|
|
68
68
|
"changeset": "0.2.6",
|
|
69
69
|
"eslint": "9.39.1",
|
|
70
70
|
"eslint-config-prettier": "10.1.8",
|
|
71
|
-
"eslint-plugin-svelte": "3.13.
|
|
71
|
+
"eslint-plugin-svelte": "3.13.1",
|
|
72
72
|
"globals": "16.5.0",
|
|
73
73
|
"jsdom": "27.2.0",
|
|
74
74
|
"lucide-svelte": "0.555.0",
|
|
75
|
-
"prettier": "3.7.
|
|
75
|
+
"prettier": "3.7.4",
|
|
76
76
|
"prettier-plugin-svelte": "3.4.0",
|
|
77
|
-
"prettier-plugin-tailwindcss": "0.7.
|
|
77
|
+
"prettier-plugin-tailwindcss": "0.7.2",
|
|
78
78
|
"publint": "0.3.15",
|
|
79
|
-
"storybook": "10.1.
|
|
80
|
-
"svelte": "5.45.
|
|
79
|
+
"storybook": "10.1.4",
|
|
80
|
+
"svelte": "5.45.5",
|
|
81
81
|
"svelte-check": "4.3.4",
|
|
82
82
|
"tailwindcss": "4.1.17",
|
|
83
83
|
"typescript": "5.9.3",
|
|
84
|
-
"typescript-eslint": "8.48.
|
|
85
|
-
"vite": "7.2.
|
|
86
|
-
"vitest": "4.0.
|
|
84
|
+
"typescript-eslint": "8.48.1",
|
|
85
|
+
"vite": "7.2.6",
|
|
86
|
+
"vitest": "4.0.15"
|
|
87
87
|
},
|
|
88
88
|
"dependencies": {
|
|
89
89
|
"@tailwindcss/container-queries": "0.1.1",
|