@uipath/apollo-wind 2.91.0 → 2.93.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/ui/data-table.cjs +493 -104
- package/dist/components/ui/data-table.d.ts +88 -5
- package/dist/components/ui/data-table.js +491 -105
- package/dist/components/ui/editable-cell.cjs +91 -27
- package/dist/components/ui/editable-cell.d.ts +14 -1
- package/dist/components/ui/editable-cell.js +91 -27
- package/dist/components/ui/index.cjs +22 -22
- package/dist/components/ui/quick-form-field/index.d.ts +1 -1
- package/dist/components/ui/quick-form-field/quick-form-field.cjs +3 -2
- package/dist/components/ui/quick-form-field/quick-form-field.d.ts +2 -1
- package/dist/components/ui/quick-form-field/quick-form-field.js +3 -2
- package/dist/components/ui/quick-form-field/types.d.ts +11 -0
- package/dist/index.cjs +3 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/styles.css +22 -0
- package/package.json +1 -1
|
@@ -26,7 +26,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
27
|
DataTableSelectColumn: ()=>DataTableSelectColumn,
|
|
28
28
|
DataTable: ()=>DataTable,
|
|
29
|
-
DataTableColumnHeader: ()=>DataTableColumnHeader
|
|
29
|
+
DataTableColumnHeader: ()=>DataTableColumnHeader,
|
|
30
|
+
DEFAULT_DATA_TABLE_STRINGS: ()=>DEFAULT_DATA_TABLE_STRINGS
|
|
30
31
|
});
|
|
31
32
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
32
33
|
const external_react_namespaceObject = require("react");
|
|
@@ -36,18 +37,156 @@ const external_checkbox_cjs_namespaceObject = require("./checkbox.cjs");
|
|
|
36
37
|
const external_dropdown_menu_cjs_namespaceObject = require("./dropdown-menu.cjs");
|
|
37
38
|
const external_editable_cell_cjs_namespaceObject = require("./editable-cell.cjs");
|
|
38
39
|
const external_input_cjs_namespaceObject = require("./input.cjs");
|
|
40
|
+
const external_select_cjs_namespaceObject = require("./select.cjs");
|
|
41
|
+
const external_skeleton_cjs_namespaceObject = require("./skeleton.cjs");
|
|
39
42
|
const external_table_cjs_namespaceObject = require("./table.cjs");
|
|
40
43
|
const index_cjs_namespaceObject = require("../../lib/index.cjs");
|
|
41
44
|
const react_table_namespaceObject = require("@tanstack/react-table");
|
|
42
|
-
|
|
45
|
+
const DEFAULT_DATA_TABLE_STRINGS = {
|
|
46
|
+
search: 'Search',
|
|
47
|
+
noResults: 'No results.',
|
|
48
|
+
loading: 'Loading',
|
|
49
|
+
previous: 'Previous',
|
|
50
|
+
next: 'Next',
|
|
51
|
+
page: (page, pageCount)=>`Page ${page} of ${pageCount}`,
|
|
52
|
+
rowsSelected: (selected, total)=>`${selected} of ${total} row(s) selected.`,
|
|
53
|
+
rowsPerPage: 'Rows per page',
|
|
54
|
+
selectAll: 'Select all',
|
|
55
|
+
selectRow: (rowNumber)=>`Select row ${rowNumber}`,
|
|
56
|
+
resizeColumn: (column)=>`Resize ${column} column`,
|
|
57
|
+
editCell: (column, rowNumber)=>`Edit ${column}, row ${rowNumber}`,
|
|
58
|
+
toggleCell: (column, rowNumber)=>`${column}, row ${rowNumber}`,
|
|
59
|
+
scrollRegion: 'Table rows'
|
|
60
|
+
};
|
|
61
|
+
const INTERNAL_META_KEY = '__apolloDataTable';
|
|
62
|
+
function getInternalMeta(table) {
|
|
63
|
+
return table.options.meta?.[INTERNAL_META_KEY];
|
|
64
|
+
}
|
|
65
|
+
function resolveColumnId(def) {
|
|
66
|
+
if (def.id) return def.id;
|
|
67
|
+
const accessorKey = def.accessorKey;
|
|
68
|
+
return 'string' == typeof accessorKey ? accessorKey.replace(/\./g, '_') : void 0;
|
|
69
|
+
}
|
|
70
|
+
function hasAccessor(def) {
|
|
71
|
+
const candidate = def;
|
|
72
|
+
return void 0 !== candidate.accessorKey || void 0 !== candidate.accessorFn;
|
|
73
|
+
}
|
|
74
|
+
function mapLeafColumns(defs, fn) {
|
|
75
|
+
return defs.map((def)=>{
|
|
76
|
+
const children = def.columns;
|
|
77
|
+
if (children?.length) return {
|
|
78
|
+
...def,
|
|
79
|
+
columns: mapLeafColumns(children, fn)
|
|
80
|
+
};
|
|
81
|
+
return fn(def);
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
function flattenLeafColumns(defs) {
|
|
85
|
+
return defs.flatMap((def)=>{
|
|
86
|
+
const children = def.columns;
|
|
87
|
+
return children?.length ? flattenLeafColumns(children) : [
|
|
88
|
+
def
|
|
89
|
+
];
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
function getColumnLabel(column) {
|
|
93
|
+
const meta = column.columnDef.meta;
|
|
94
|
+
if (meta?.label) return meta.label;
|
|
95
|
+
const header = column.columnDef.header;
|
|
96
|
+
return 'string' == typeof header && '' !== header.trim() ? header : column.id;
|
|
97
|
+
}
|
|
98
|
+
const collator = new Intl.Collator(void 0, {
|
|
99
|
+
numeric: true,
|
|
100
|
+
sensitivity: 'base'
|
|
101
|
+
});
|
|
102
|
+
function compareValues(a, b) {
|
|
103
|
+
const aEmpty = null == a || '' === a;
|
|
104
|
+
const bEmpty = null == b || '' === b;
|
|
105
|
+
if (aEmpty || bEmpty) return aEmpty === bEmpty ? 0 : aEmpty ? 1 : -1;
|
|
106
|
+
if ('number' == typeof a && 'number' == typeof b) return a - b;
|
|
107
|
+
if ('bigint' == typeof a && 'bigint' == typeof b) return a < b ? -1 : a > b ? 1 : 0;
|
|
108
|
+
if ('boolean' == typeof a && 'boolean' == typeof b) return Number(a) - Number(b);
|
|
109
|
+
if (a instanceof Date && b instanceof Date) return a.getTime() - b.getTime();
|
|
110
|
+
return collator.compare(String(a), String(b));
|
|
111
|
+
}
|
|
112
|
+
const defaultSortingFn = (rowA, rowB, columnId)=>compareValues(rowA.getValue(columnId), rowB.getValue(columnId));
|
|
113
|
+
const containsTextFilterFn = (row, columnId, filterValue)=>{
|
|
114
|
+
const query = String(filterValue ?? '').toLowerCase();
|
|
115
|
+
if ('' === query) return true;
|
|
116
|
+
const value = row.getValue(columnId);
|
|
117
|
+
if (null == value) return false;
|
|
118
|
+
return String(value).toLowerCase().includes(query);
|
|
119
|
+
};
|
|
120
|
+
containsTextFilterFn.autoRemove = (value)=>!value;
|
|
121
|
+
function EditableCellRenderer(cellContext) {
|
|
122
|
+
const internal = getInternalMeta(cellContext.table);
|
|
123
|
+
const strings = internal?.strings ?? DEFAULT_DATA_TABLE_STRINGS;
|
|
124
|
+
const columnLabel = getColumnLabel(cellContext.column);
|
|
125
|
+
const rowNumber = cellContext.row.index + 1;
|
|
126
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_editable_cell_cjs_namespaceObject.EditableCell, {
|
|
127
|
+
cell: cellContext,
|
|
128
|
+
editLabel: strings.editCell(columnLabel, rowNumber),
|
|
129
|
+
toggleLabel: strings.toggleCell(columnLabel, rowNumber),
|
|
130
|
+
onUpdate: (value)=>{
|
|
131
|
+
internal?.onCellUpdate.current?.(cellContext.row.index, cellContext.column.id, value);
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
const INTERACTIVE_SELECTOR = 'a, button, input, select, textarea, label, summary, [role="button"], [role="checkbox"], [role="switch"], [role="menuitem"], [role="combobox"], [role="separator"], [contenteditable="true"]';
|
|
136
|
+
const RESIZE_STEP = 10;
|
|
137
|
+
const RESIZE_STEP_LARGE = 50;
|
|
138
|
+
const RESIZE_FALLBACK_MIN = 20;
|
|
139
|
+
function DataTable({ columns, data, className, searchKey, searchPlaceholder = 'Search...', searchValue: controlledSearch, onSearchChange, showColumnToggle = true, showPagination = true, pageSize = 10, pageSizeOptions, pagination: controlledPagination, onPaginationChange: controlledOnPaginationChange, manualPagination = false, rowCount, editable = false, onCellUpdate, resizable = false, compact = false, columnToggleText = 'Columns', getRowId, rowSelection: controlledRowSelection, onRowSelectionChange: controlledOnRowSelectionChange, showSelectionCount, sorting: controlledSorting, onSortingChange: controlledOnSortingChange, initialSorting, columnSizing: controlledColumnSizing, onColumnSizingChange: controlledOnColumnSizingChange, columnVisibility: controlledColumnVisibility, onColumnVisibilityChange: controlledOnColumnVisibilityChange, globalFilterFn, allowWrap = false, toolbarContent, maxBodyHeight, onRowClick, loading = false, emptyState, strings: stringOverrides }) {
|
|
43
140
|
const useBlockLayout = void 0 !== maxBodyHeight;
|
|
44
141
|
const blockRowClasses = '[&>tr]:table [&>tr]:w-full [&>tr]:table-fixed';
|
|
142
|
+
const strings = external_react_namespaceObject.useMemo(()=>{
|
|
143
|
+
const merged = {
|
|
144
|
+
...DEFAULT_DATA_TABLE_STRINGS
|
|
145
|
+
};
|
|
146
|
+
if (stringOverrides) for (const key of Object.keys(stringOverrides)){
|
|
147
|
+
const value = stringOverrides[key];
|
|
148
|
+
if (void 0 !== value) merged[key] = value;
|
|
149
|
+
}
|
|
150
|
+
return merged;
|
|
151
|
+
}, [
|
|
152
|
+
stringOverrides
|
|
153
|
+
]);
|
|
45
154
|
const [internalSorting, setInternalSorting] = external_react_namespaceObject.useState(initialSorting ?? []);
|
|
46
|
-
const [columnFilters, setColumnFilters] = external_react_namespaceObject.useState([]);
|
|
47
155
|
const [internalColumnVisibility, setInternalColumnVisibility] = external_react_namespaceObject.useState({});
|
|
48
156
|
const [internalColumnSizing, setInternalColumnSizing] = external_react_namespaceObject.useState({});
|
|
49
157
|
const [internalRowSelection, setInternalRowSelection] = external_react_namespaceObject.useState({});
|
|
50
|
-
const [
|
|
158
|
+
const [internalSearch, setInternalSearch] = external_react_namespaceObject.useState('');
|
|
159
|
+
const [internalPagination, setInternalPagination] = external_react_namespaceObject.useState({
|
|
160
|
+
pageIndex: 0,
|
|
161
|
+
pageSize
|
|
162
|
+
});
|
|
163
|
+
const [appliedPageSize, setAppliedPageSize] = external_react_namespaceObject.useState(pageSize);
|
|
164
|
+
if (appliedPageSize !== pageSize) {
|
|
165
|
+
setAppliedPageSize(pageSize);
|
|
166
|
+
setInternalPagination({
|
|
167
|
+
pageIndex: 0,
|
|
168
|
+
pageSize
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
const isPaginationControlled = void 0 !== controlledPagination;
|
|
172
|
+
const pagination = isPaginationControlled ? controlledPagination : internalPagination;
|
|
173
|
+
const paginationRef = external_react_namespaceObject.useRef(pagination);
|
|
174
|
+
paginationRef.current = pagination;
|
|
175
|
+
const onPaginationChange = external_react_namespaceObject.useCallback((updater)=>{
|
|
176
|
+
if (!isPaginationControlled) setInternalPagination((prev)=>'function' == typeof updater ? updater(prev) : updater);
|
|
177
|
+
controlledOnPaginationChange?.(updater);
|
|
178
|
+
}, [
|
|
179
|
+
isPaginationControlled,
|
|
180
|
+
controlledOnPaginationChange
|
|
181
|
+
]);
|
|
182
|
+
const resetPageIndex = external_react_namespaceObject.useCallback(()=>{
|
|
183
|
+
if (0 !== paginationRef.current.pageIndex) onPaginationChange((prev)=>({
|
|
184
|
+
...prev,
|
|
185
|
+
pageIndex: 0
|
|
186
|
+
}));
|
|
187
|
+
}, [
|
|
188
|
+
onPaginationChange
|
|
189
|
+
]);
|
|
51
190
|
const isRowSelectionControlled = void 0 !== controlledRowSelection;
|
|
52
191
|
const rowSelection = isRowSelectionControlled ? controlledRowSelection : internalRowSelection;
|
|
53
192
|
const rowSelectionRef = external_react_namespaceObject.useRef(rowSelection);
|
|
@@ -65,9 +204,11 @@ function DataTable({ columns, data, searchKey, searchPlaceholder = 'Search...',
|
|
|
65
204
|
const onSortingChange = external_react_namespaceObject.useCallback((updater)=>{
|
|
66
205
|
if (!isSortingControlled) setInternalSorting((prev)=>'function' == typeof updater ? updater(prev) : updater);
|
|
67
206
|
controlledOnSortingChange?.(updater);
|
|
207
|
+
resetPageIndex();
|
|
68
208
|
}, [
|
|
69
209
|
isSortingControlled,
|
|
70
|
-
controlledOnSortingChange
|
|
210
|
+
controlledOnSortingChange,
|
|
211
|
+
resetPageIndex
|
|
71
212
|
]);
|
|
72
213
|
const isColumnSizingControlled = void 0 !== controlledColumnSizing;
|
|
73
214
|
const columnSizing = isColumnSizingControlled ? controlledColumnSizing : internalColumnSizing;
|
|
@@ -90,40 +231,141 @@ function DataTable({ columns, data, searchKey, searchPlaceholder = 'Search...',
|
|
|
90
231
|
const tanstackGlobalFilterFn = external_react_namespaceObject.useMemo(()=>globalFilterFn ? (row, _columnId, filterValue)=>globalFilterFn(row.original, filterValue) : void 0, [
|
|
91
232
|
globalFilterFn
|
|
92
233
|
]);
|
|
234
|
+
const leafColumnDefs = external_react_namespaceObject.useMemo(()=>flattenLeafColumns(columns), [
|
|
235
|
+
columns
|
|
236
|
+
]);
|
|
237
|
+
const globalFilterColumnId = external_react_namespaceObject.useMemo(()=>{
|
|
238
|
+
const def = leafColumnDefs.find((candidate)=>hasAccessor(candidate) && false !== candidate.enableGlobalFilter);
|
|
239
|
+
return def ? resolveColumnId(def) : void 0;
|
|
240
|
+
}, [
|
|
241
|
+
leafColumnDefs
|
|
242
|
+
]);
|
|
243
|
+
const searchColumnExists = external_react_namespaceObject.useMemo(()=>void 0 !== searchKey && leafColumnDefs.some((def)=>resolveColumnId(def) === searchKey), [
|
|
244
|
+
leafColumnDefs,
|
|
245
|
+
searchKey
|
|
246
|
+
]);
|
|
247
|
+
const [internalColumnFilters, setInternalColumnFilters] = external_react_namespaceObject.useState([]);
|
|
248
|
+
const usesColumnSearch = !globalFilterFn && void 0 !== searchKey;
|
|
249
|
+
const search = void 0 !== controlledSearch ? controlledSearch : usesColumnSearch ? String(internalColumnFilters.find((filter)=>filter.id === searchKey)?.value ?? '') : internalSearch;
|
|
250
|
+
const columnFilters = external_react_namespaceObject.useMemo(()=>{
|
|
251
|
+
if (!usesColumnSearch) return internalColumnFilters;
|
|
252
|
+
const others = internalColumnFilters.filter((filter)=>filter.id !== searchKey);
|
|
253
|
+
return searchColumnExists && '' !== search ? [
|
|
254
|
+
...others,
|
|
255
|
+
{
|
|
256
|
+
id: searchKey,
|
|
257
|
+
value: search
|
|
258
|
+
}
|
|
259
|
+
] : others;
|
|
260
|
+
}, [
|
|
261
|
+
usesColumnSearch,
|
|
262
|
+
internalColumnFilters,
|
|
263
|
+
searchKey,
|
|
264
|
+
searchColumnExists,
|
|
265
|
+
search
|
|
266
|
+
]);
|
|
267
|
+
const columnFiltersRef = external_react_namespaceObject.useRef(columnFilters);
|
|
268
|
+
columnFiltersRef.current = columnFilters;
|
|
269
|
+
const handleSearchChange = (value)=>{
|
|
270
|
+
if (void 0 === controlledSearch) if (usesColumnSearch) setInternalColumnFilters((prev)=>[
|
|
271
|
+
...prev.filter((filter)=>filter.id !== searchKey),
|
|
272
|
+
...'' === value ? [] : [
|
|
273
|
+
{
|
|
274
|
+
id: searchKey,
|
|
275
|
+
value
|
|
276
|
+
}
|
|
277
|
+
]
|
|
278
|
+
]);
|
|
279
|
+
else setInternalSearch(value);
|
|
280
|
+
onSearchChange?.(value);
|
|
281
|
+
resetPageIndex();
|
|
282
|
+
};
|
|
283
|
+
const onColumnFiltersChange = (updater)=>{
|
|
284
|
+
const next = 'function' == typeof updater ? updater(columnFiltersRef.current) : updater;
|
|
285
|
+
setInternalColumnFilters(next);
|
|
286
|
+
if (usesColumnSearch && void 0 !== controlledSearch) {
|
|
287
|
+
const value = String(next.find((filter)=>filter.id === searchKey)?.value ?? '');
|
|
288
|
+
if (value !== controlledSearch) onSearchChange?.(value);
|
|
289
|
+
}
|
|
290
|
+
resetPageIndex();
|
|
291
|
+
};
|
|
292
|
+
const onCellUpdateRef = external_react_namespaceObject.useRef(onCellUpdate);
|
|
293
|
+
onCellUpdateRef.current = onCellUpdate;
|
|
294
|
+
const isEditable = editable && void 0 !== onCellUpdate;
|
|
295
|
+
external_react_namespaceObject.useEffect(()=>{
|
|
296
|
+
if (editable && !onCellUpdate) console.warn('DataTable: `editable` has no effect without `onCellUpdate`.');
|
|
297
|
+
if (void 0 !== searchKey && !globalFilterFn && !searchColumnExists) console.warn(`DataTable: \`searchKey\` "${searchKey}" does not match any column id.`);
|
|
298
|
+
}, [
|
|
299
|
+
editable,
|
|
300
|
+
onCellUpdate,
|
|
301
|
+
searchKey,
|
|
302
|
+
globalFilterFn,
|
|
303
|
+
searchColumnExists
|
|
304
|
+
]);
|
|
93
305
|
const processedColumns = external_react_namespaceObject.useMemo(()=>{
|
|
94
|
-
|
|
95
|
-
return columns
|
|
306
|
+
const needsSearchFilter = void 0 !== searchKey && !globalFilterFn;
|
|
307
|
+
if (!isEditable && !needsSearchFilter) return columns;
|
|
308
|
+
return mapLeafColumns(columns, (col)=>{
|
|
309
|
+
let next = col;
|
|
310
|
+
if (needsSearchFilter && resolveColumnId(col) === searchKey && void 0 === col.filterFn) next = {
|
|
311
|
+
...next,
|
|
312
|
+
filterFn: containsTextFilterFn
|
|
313
|
+
};
|
|
96
314
|
const meta = col.meta;
|
|
97
|
-
if (
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
cell: (cellContext)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_editable_cell_cjs_namespaceObject.EditableCell, {
|
|
101
|
-
cell: cellContext,
|
|
102
|
-
onUpdate: (value)=>{
|
|
103
|
-
onCellUpdate(cellContext.row.index, cellContext.column.id, value);
|
|
104
|
-
}
|
|
105
|
-
})
|
|
315
|
+
if (isEditable && meta?.type && !col.cell) next = {
|
|
316
|
+
...next,
|
|
317
|
+
cell: EditableCellRenderer
|
|
106
318
|
};
|
|
319
|
+
return next;
|
|
107
320
|
});
|
|
108
321
|
}, [
|
|
109
322
|
columns,
|
|
110
|
-
|
|
111
|
-
|
|
323
|
+
isEditable,
|
|
324
|
+
searchKey,
|
|
325
|
+
globalFilterFn
|
|
326
|
+
]);
|
|
327
|
+
const tableMeta = external_react_namespaceObject.useMemo(()=>({
|
|
328
|
+
[INTERNAL_META_KEY]: {
|
|
329
|
+
strings,
|
|
330
|
+
onCellUpdate: onCellUpdateRef
|
|
331
|
+
}
|
|
332
|
+
}), [
|
|
333
|
+
strings
|
|
112
334
|
]);
|
|
335
|
+
const paginate = showPagination || isPaginationControlled;
|
|
113
336
|
const table = (0, react_table_namespaceObject.useReactTable)({
|
|
114
337
|
data,
|
|
115
338
|
columns: processedColumns,
|
|
339
|
+
meta: tableMeta,
|
|
340
|
+
getRowId,
|
|
341
|
+
defaultColumn: {
|
|
342
|
+
size: void 0,
|
|
343
|
+
minSize: void 0,
|
|
344
|
+
maxSize: void 0,
|
|
345
|
+
sortingFn: defaultSortingFn
|
|
346
|
+
},
|
|
116
347
|
onSortingChange,
|
|
117
|
-
onColumnFiltersChange
|
|
348
|
+
onColumnFiltersChange,
|
|
349
|
+
onGlobalFilterChange: (updater)=>{
|
|
350
|
+
if (!globalFilterFn) return;
|
|
351
|
+
const next = 'function' == typeof updater ? updater(search) : updater;
|
|
352
|
+
handleSearchChange(String(next ?? ''));
|
|
353
|
+
},
|
|
118
354
|
getCoreRowModel: (0, react_table_namespaceObject.getCoreRowModel)(),
|
|
119
|
-
getPaginationRowModel: (0, react_table_namespaceObject.getPaginationRowModel)(),
|
|
355
|
+
getPaginationRowModel: paginate && !manualPagination ? (0, react_table_namespaceObject.getPaginationRowModel)() : void 0,
|
|
120
356
|
getSortedRowModel: (0, react_table_namespaceObject.getSortedRowModel)(),
|
|
121
357
|
getFilteredRowModel: (0, react_table_namespaceObject.getFilteredRowModel)(),
|
|
122
358
|
onColumnVisibilityChange,
|
|
123
359
|
onColumnSizingChange,
|
|
124
360
|
onRowSelectionChange: setRowSelection,
|
|
125
|
-
|
|
361
|
+
onPaginationChange,
|
|
362
|
+
manualPagination,
|
|
363
|
+
rowCount,
|
|
364
|
+
autoResetPageIndex: false,
|
|
126
365
|
globalFilterFn: tanstackGlobalFilterFn,
|
|
366
|
+
...globalFilterFn ? {
|
|
367
|
+
getColumnCanGlobalFilter: (column)=>column.id === globalFilterColumnId
|
|
368
|
+
} : {},
|
|
127
369
|
enableColumnResizing: resizable,
|
|
128
370
|
columnResizeMode: 'onChange',
|
|
129
371
|
state: {
|
|
@@ -132,31 +374,95 @@ function DataTable({ columns, data, searchKey, searchPlaceholder = 'Search...',
|
|
|
132
374
|
columnVisibility,
|
|
133
375
|
columnSizing,
|
|
134
376
|
rowSelection,
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
initialState: {
|
|
138
|
-
pagination: {
|
|
139
|
-
pageSize
|
|
140
|
-
}
|
|
377
|
+
pagination,
|
|
378
|
+
globalFilter: globalFilterFn ? search : ''
|
|
141
379
|
}
|
|
142
380
|
});
|
|
381
|
+
const pageCount = paginate ? Math.max(table.getPageCount(), 1) : 1;
|
|
382
|
+
const lastPageIndex = pageCount - 1;
|
|
383
|
+
const pageIndexOutOfRange = paginate && !manualPagination && pagination.pageIndex > lastPageIndex;
|
|
384
|
+
if (pageIndexOutOfRange) table.setOptions((prev)=>({
|
|
385
|
+
...prev,
|
|
386
|
+
state: {
|
|
387
|
+
...prev.state,
|
|
388
|
+
pagination: {
|
|
389
|
+
...pagination,
|
|
390
|
+
pageIndex: lastPageIndex
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
}));
|
|
394
|
+
external_react_namespaceObject.useEffect(()=>{
|
|
395
|
+
if (pageIndexOutOfRange) onPaginationChange((prev)=>({
|
|
396
|
+
...prev,
|
|
397
|
+
pageIndex: lastPageIndex
|
|
398
|
+
}));
|
|
399
|
+
}, [
|
|
400
|
+
pageIndexOutOfRange,
|
|
401
|
+
lastPageIndex,
|
|
402
|
+
onPaginationChange
|
|
403
|
+
]);
|
|
404
|
+
const currentPageIndex = pageIndexOutOfRange ? lastPageIndex : pagination.pageIndex;
|
|
405
|
+
const rows = table.getRowModel().rows;
|
|
406
|
+
const visibleColumnCount = Math.max(table.getVisibleLeafColumns().length, 1);
|
|
407
|
+
const hasSelectColumn = leafColumnDefs.some((def)=>'select' === resolveColumnId(def));
|
|
408
|
+
const selectionCountVisible = showSelectionCount ?? (hasSelectColumn || isRowSelectionControlled || Object.keys(rowSelection).length > 0);
|
|
409
|
+
const showSearch = void 0 !== globalFilterFn || void 0 !== searchKey;
|
|
410
|
+
const resizeColumnBy = (header, delta)=>{
|
|
411
|
+
const { column } = header;
|
|
412
|
+
const min = column.columnDef.minSize ?? RESIZE_FALLBACK_MIN;
|
|
413
|
+
const max = column.columnDef.maxSize ?? Number.MAX_SAFE_INTEGER;
|
|
414
|
+
const current = column.getSize();
|
|
415
|
+
const target = 'min' === delta ? min : 'max' === delta ? max : current + delta;
|
|
416
|
+
const next = Math.min(Math.max(target, min), max);
|
|
417
|
+
if (next !== current) table.setColumnSizing((prev)=>({
|
|
418
|
+
...prev,
|
|
419
|
+
[column.id]: next
|
|
420
|
+
}));
|
|
421
|
+
};
|
|
422
|
+
const handleResizeKeyDown = (event, header)=>{
|
|
423
|
+
const step = event.shiftKey ? RESIZE_STEP_LARGE : RESIZE_STEP;
|
|
424
|
+
switch(event.key){
|
|
425
|
+
case 'ArrowLeft':
|
|
426
|
+
resizeColumnBy(header, -step);
|
|
427
|
+
break;
|
|
428
|
+
case 'ArrowRight':
|
|
429
|
+
resizeColumnBy(header, step);
|
|
430
|
+
break;
|
|
431
|
+
case 'Home':
|
|
432
|
+
resizeColumnBy(header, 'min');
|
|
433
|
+
break;
|
|
434
|
+
case 'End':
|
|
435
|
+
if (void 0 === header.column.columnDef.maxSize) return;
|
|
436
|
+
resizeColumnBy(header, 'max');
|
|
437
|
+
break;
|
|
438
|
+
case 'Enter':
|
|
439
|
+
header.column.resetSize();
|
|
440
|
+
break;
|
|
441
|
+
default:
|
|
442
|
+
return;
|
|
443
|
+
}
|
|
444
|
+
event.preventDefault();
|
|
445
|
+
};
|
|
446
|
+
const cellSizeStyle = (column)=>({
|
|
447
|
+
width: resizable ? column.getSize() : column.columnDef.size,
|
|
448
|
+
minWidth: column.columnDef.minSize,
|
|
449
|
+
maxWidth: column.columnDef.maxSize
|
|
450
|
+
});
|
|
451
|
+
const bodyCellClasses = allowWrap ? compact ? 'min-h-8 px-2 py-1' : 'min-h-12 px-4 py-2' : compact ? 'h-8 truncate px-2 py-0' : 'h-12 truncate px-4 py-0';
|
|
452
|
+
const skeletonRowCount = Math.min(Math.max(pagination.pageSize, 1), 5);
|
|
143
453
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
144
454
|
"data-slot": "data-table",
|
|
145
|
-
className:
|
|
455
|
+
className: (0, index_cjs_namespaceObject.cn)('w-full', className),
|
|
146
456
|
children: [
|
|
147
457
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
148
|
-
className: "flex items-center gap-4 py-4",
|
|
458
|
+
className: "flex flex-wrap items-center gap-x-4 gap-y-2 py-4",
|
|
149
459
|
children: [
|
|
150
|
-
|
|
151
|
-
placeholder: searchPlaceholder,
|
|
152
|
-
value: globalFilter,
|
|
153
|
-
onChange: (event)=>setGlobalFilter(event.target.value),
|
|
154
|
-
className: "max-w-sm"
|
|
155
|
-
}) : searchKey && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_input_cjs_namespaceObject.Input, {
|
|
460
|
+
showSearch && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_input_cjs_namespaceObject.Input, {
|
|
156
461
|
placeholder: searchPlaceholder,
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
462
|
+
"aria-label": stringOverrides?.search ?? searchPlaceholder,
|
|
463
|
+
value: search,
|
|
464
|
+
onChange: (event)=>handleSearchChange(event.target.value),
|
|
465
|
+
className: "min-w-0 max-w-sm flex-1 basis-48"
|
|
160
466
|
}),
|
|
161
467
|
toolbarContent,
|
|
162
468
|
showColumnToggle && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_dropdown_menu_cjs_namespaceObject.DropdownMenu, {
|
|
@@ -170,19 +476,23 @@ function DataTable({ columns, data, searchKey, searchPlaceholder = 'Search...',
|
|
|
170
476
|
columnToggleText,
|
|
171
477
|
" ",
|
|
172
478
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.ChevronDown, {
|
|
173
|
-
className: "ml-2 h-4 w-4"
|
|
479
|
+
className: "ml-2 h-4 w-4",
|
|
480
|
+
"aria-hidden": "true"
|
|
174
481
|
})
|
|
175
482
|
]
|
|
176
483
|
})
|
|
177
484
|
}),
|
|
178
485
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_dropdown_menu_cjs_namespaceObject.DropdownMenuContent, {
|
|
179
486
|
align: "end",
|
|
180
|
-
children: table.getAllColumns().filter((column)=>column.getCanHide()).map((column)
|
|
181
|
-
|
|
487
|
+
children: table.getAllColumns().filter((column)=>column.getCanHide()).map((column)=>{
|
|
488
|
+
const label = getColumnLabel(column);
|
|
489
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_dropdown_menu_cjs_namespaceObject.DropdownMenuCheckboxItem, {
|
|
490
|
+
className: label === column.id ? 'capitalize' : void 0,
|
|
182
491
|
checked: column.getIsVisible(),
|
|
183
492
|
onCheckedChange: (value)=>column.toggleVisibility(!!value),
|
|
184
|
-
children:
|
|
185
|
-
}, column.id)
|
|
493
|
+
children: label
|
|
494
|
+
}, column.id);
|
|
495
|
+
})
|
|
186
496
|
})
|
|
187
497
|
]
|
|
188
498
|
})
|
|
@@ -196,33 +506,40 @@ function DataTable({ columns, data, searchKey, searchPlaceholder = 'Search...',
|
|
|
196
506
|
width: table.getTotalSize(),
|
|
197
507
|
tableLayout: 'fixed'
|
|
198
508
|
} : void 0,
|
|
509
|
+
"aria-busy": loading || void 0,
|
|
199
510
|
children: [
|
|
200
511
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_table_cjs_namespaceObject.TableHeader, {
|
|
201
|
-
className: (0, index_cjs_namespaceObject.cn)('sticky top-0 z-10 bg-background', useBlockLayout && `block ${blockRowClasses}`),
|
|
512
|
+
className: (0, index_cjs_namespaceObject.cn)('sticky top-0 z-10 bg-background', useBlockLayout && `block overflow-hidden [scrollbar-gutter:stable] ${blockRowClasses}`),
|
|
202
513
|
children: table.getHeaderGroups().map((headerGroup)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_table_cjs_namespaceObject.TableRow, {
|
|
203
|
-
children: headerGroup.headers.map((header)=>{
|
|
514
|
+
children: headerGroup.headers.map((header, headerIndex)=>{
|
|
204
515
|
const { column } = header;
|
|
516
|
+
const sorted = column.getIsSorted();
|
|
517
|
+
const isLastHeader = headerIndex === headerGroup.headers.length - 1;
|
|
205
518
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_table_cjs_namespaceObject.TableHead, {
|
|
519
|
+
colSpan: header.colSpan > 1 ? header.colSpan : void 0,
|
|
520
|
+
"aria-sort": 'asc' === sorted ? 'ascending' : 'desc' === sorted ? 'descending' : void 0,
|
|
206
521
|
className: (0, index_cjs_namespaceObject.cn)(compact ? 'relative h-8 px-2 py-0' : 'relative py-0', resizable && 'overflow-visible'),
|
|
207
522
|
style: {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
maxWidth: column.columnDef.maxSize
|
|
523
|
+
...cellSizeStyle(column),
|
|
524
|
+
width: resizable ? header.getSize() : column.columnDef.size
|
|
211
525
|
},
|
|
212
526
|
children: [
|
|
213
527
|
header.isPlaceholder ? null : (0, react_table_namespaceObject.flexRender)(header.column.columnDef.header, header.getContext()),
|
|
214
528
|
resizable && header.column.getCanResize() && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
215
529
|
role: "separator",
|
|
216
|
-
"aria-
|
|
217
|
-
"aria-
|
|
218
|
-
"aria-
|
|
219
|
-
"aria-
|
|
530
|
+
"aria-orientation": "vertical",
|
|
531
|
+
"aria-label": strings.resizeColumn(getColumnLabel(column)),
|
|
532
|
+
"aria-valuenow": Math.round(header.getSize()),
|
|
533
|
+
"aria-valuemin": column.columnDef.minSize ?? RESIZE_FALLBACK_MIN,
|
|
534
|
+
"aria-valuemax": column.columnDef.maxSize ?? Math.max(1000, Math.round(header.getSize())),
|
|
220
535
|
tabIndex: 0,
|
|
221
536
|
onMouseDown: header.getResizeHandler(),
|
|
222
537
|
onTouchStart: header.getResizeHandler(),
|
|
223
|
-
|
|
538
|
+
onDoubleClick: ()=>column.resetSize(),
|
|
539
|
+
onKeyDown: (event)=>handleResizeKeyDown(event, header),
|
|
540
|
+
className: (0, index_cjs_namespaceObject.cn)('group absolute top-0 z-10 h-full w-2 cursor-col-resize touch-none select-none outline-none', isLastHeader ? 'right-0' : '-right-1'),
|
|
224
541
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
225
|
-
className: (0, index_cjs_namespaceObject.cn)('h-full
|
|
542
|
+
className: (0, index_cjs_namespaceObject.cn)('h-full transition-all duration-150', isLastHeader ? 'ml-auto' : 'mx-auto', header.column.getIsResizing() ? 'w-0.5 bg-primary' : 'w-px group-hover:w-0.5 group-hover:bg-primary group-focus-visible:w-0.5 group-focus-visible:bg-primary')
|
|
226
543
|
})
|
|
227
544
|
})
|
|
228
545
|
]
|
|
@@ -231,80 +548,133 @@ function DataTable({ columns, data, searchKey, searchPlaceholder = 'Search...',
|
|
|
231
548
|
}, headerGroup.id))
|
|
232
549
|
}),
|
|
233
550
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_table_cjs_namespaceObject.TableBody, {
|
|
234
|
-
className:
|
|
551
|
+
className: (0, index_cjs_namespaceObject.cn)(useBlockLayout && `block overflow-y-auto [scrollbar-gutter:stable] ${blockRowClasses}`, loading && rows.length > 0 && 'opacity-60 transition-opacity'),
|
|
235
552
|
style: useBlockLayout ? {
|
|
236
553
|
maxHeight: maxBodyHeight
|
|
237
554
|
} : void 0,
|
|
238
555
|
tabIndex: useBlockLayout ? 0 : void 0,
|
|
239
|
-
|
|
240
|
-
|
|
556
|
+
"aria-label": useBlockLayout ? strings.scrollRegion : void 0,
|
|
557
|
+
children: rows.length ? rows.map((row)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_table_cjs_namespaceObject.TableRow, {
|
|
558
|
+
"data-state": row.getIsSelected() ? 'selected' : void 0,
|
|
559
|
+
className: onRowClick ? 'cursor-pointer' : void 0,
|
|
560
|
+
tabIndex: onRowClick ? 0 : void 0,
|
|
561
|
+
onClick: onRowClick ? (event)=>{
|
|
562
|
+
const target = event.target;
|
|
563
|
+
if (target.closest(INTERACTIVE_SELECTOR)) return;
|
|
564
|
+
onRowClick(row.original);
|
|
565
|
+
} : void 0,
|
|
566
|
+
onKeyDown: onRowClick ? (event)=>{
|
|
567
|
+
if ('Enter' === event.key && event.target === event.currentTarget) {
|
|
568
|
+
event.preventDefault();
|
|
569
|
+
onRowClick(row.original);
|
|
570
|
+
}
|
|
571
|
+
} : void 0,
|
|
241
572
|
children: row.getVisibleCells().map((cell)=>{
|
|
242
573
|
const { column } = cell;
|
|
243
574
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_table_cjs_namespaceObject.TableCell, {
|
|
244
|
-
className:
|
|
575
|
+
className: bodyCellClasses,
|
|
245
576
|
onMouseEnter: (e)=>{
|
|
246
577
|
if (allowWrap) return;
|
|
247
578
|
const el = e.currentTarget;
|
|
248
579
|
const value = cell.getValue();
|
|
249
580
|
el.title = el.scrollWidth > el.clientWidth && ('string' == typeof value || 'number' == typeof value) ? String(value) : '';
|
|
250
581
|
},
|
|
251
|
-
style:
|
|
252
|
-
width: resizable ? cell.column.getSize() : 150 !== column.getSize() ? column.getSize() : void 0,
|
|
253
|
-
minWidth: column.columnDef.minSize,
|
|
254
|
-
maxWidth: column.columnDef.maxSize
|
|
255
|
-
},
|
|
582
|
+
style: cellSizeStyle(column),
|
|
256
583
|
children: (0, react_table_namespaceObject.flexRender)(cell.column.columnDef.cell, cell.getContext())
|
|
257
584
|
}, cell.id);
|
|
258
585
|
})
|
|
259
|
-
}, row.id)) :
|
|
586
|
+
}, row.id)) : loading ? Array.from({
|
|
587
|
+
length: skeletonRowCount
|
|
588
|
+
}, (_, rowIndex)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_table_cjs_namespaceObject.TableRow, {
|
|
589
|
+
"data-slot": "data-table-loading-row",
|
|
590
|
+
"aria-hidden": "true",
|
|
591
|
+
children: table.getVisibleLeafColumns().map((column)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_table_cjs_namespaceObject.TableCell, {
|
|
592
|
+
className: bodyCellClasses,
|
|
593
|
+
style: cellSizeStyle(column),
|
|
594
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_skeleton_cjs_namespaceObject.Skeleton, {
|
|
595
|
+
className: "h-4 w-full max-w-40"
|
|
596
|
+
})
|
|
597
|
+
}, column.id))
|
|
598
|
+
}, rowIndex)) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_table_cjs_namespaceObject.TableRow, {
|
|
260
599
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_table_cjs_namespaceObject.TableCell, {
|
|
261
|
-
colSpan:
|
|
600
|
+
colSpan: visibleColumnCount,
|
|
262
601
|
className: "h-24 text-center",
|
|
263
|
-
children:
|
|
602
|
+
children: emptyState ?? strings.noResults
|
|
264
603
|
})
|
|
265
604
|
})
|
|
266
605
|
})
|
|
267
606
|
]
|
|
268
607
|
})
|
|
269
608
|
}),
|
|
609
|
+
loading && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("output", {
|
|
610
|
+
className: "sr-only",
|
|
611
|
+
children: strings.loading
|
|
612
|
+
}),
|
|
270
613
|
showPagination && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
271
|
-
className: "flex items-center justify-between
|
|
614
|
+
className: "flex flex-wrap items-center justify-between gap-x-4 gap-y-2 py-4",
|
|
272
615
|
children: [
|
|
273
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.
|
|
616
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
274
617
|
className: "flex-1 text-sm text-muted-foreground",
|
|
275
|
-
children:
|
|
276
|
-
table.getFilteredSelectedRowModel().rows.length,
|
|
277
|
-
" of",
|
|
278
|
-
' ',
|
|
279
|
-
table.getFilteredRowModel().rows.length,
|
|
280
|
-
" row(s) selected."
|
|
281
|
-
]
|
|
618
|
+
children: selectionCountVisible && strings.rowsSelected(table.getFilteredSelectedRowModel().rows.length, table.getFilteredRowModel().rows.length)
|
|
282
619
|
}),
|
|
283
620
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
284
|
-
className: "flex items-center
|
|
621
|
+
className: "flex flex-wrap items-center gap-x-4 gap-y-2",
|
|
285
622
|
children: [
|
|
286
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
623
|
+
pageSizeOptions && pageSizeOptions.length > 0 && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
624
|
+
className: "flex items-center gap-2",
|
|
625
|
+
children: [
|
|
626
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
627
|
+
className: "text-sm text-muted-foreground",
|
|
628
|
+
children: strings.rowsPerPage
|
|
629
|
+
}),
|
|
630
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_select_cjs_namespaceObject.Select, {
|
|
631
|
+
value: String(pagination.pageSize),
|
|
632
|
+
onValueChange: (value)=>onPaginationChange({
|
|
633
|
+
pageIndex: 0,
|
|
634
|
+
pageSize: Number(value)
|
|
635
|
+
}),
|
|
636
|
+
children: [
|
|
637
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectTrigger, {
|
|
638
|
+
className: "h-8 w-auto min-w-[4.5rem] gap-2",
|
|
639
|
+
"aria-label": strings.rowsPerPage,
|
|
640
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectValue, {})
|
|
641
|
+
}),
|
|
642
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectContent, {
|
|
643
|
+
align: "end",
|
|
644
|
+
children: Array.from(new Set([
|
|
645
|
+
...pageSizeOptions,
|
|
646
|
+
pagination.pageSize
|
|
647
|
+
])).sort((a, b)=>a - b).map((option)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_select_cjs_namespaceObject.SelectItem, {
|
|
648
|
+
value: String(option),
|
|
649
|
+
children: option
|
|
650
|
+
}, option))
|
|
651
|
+
})
|
|
652
|
+
]
|
|
653
|
+
})
|
|
654
|
+
]
|
|
292
655
|
}),
|
|
293
656
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
294
|
-
className: "
|
|
657
|
+
className: "flex items-center space-x-2",
|
|
295
658
|
children: [
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
659
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_button_cjs_namespaceObject.Button, {
|
|
660
|
+
variant: "outline",
|
|
661
|
+
size: "sm",
|
|
662
|
+
onClick: ()=>table.previousPage(),
|
|
663
|
+
disabled: currentPageIndex <= 0,
|
|
664
|
+
children: strings.previous
|
|
665
|
+
}),
|
|
666
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
667
|
+
className: "text-sm font-medium",
|
|
668
|
+
children: strings.page(currentPageIndex + 1, pageCount)
|
|
669
|
+
}),
|
|
670
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_button_cjs_namespaceObject.Button, {
|
|
671
|
+
variant: "outline",
|
|
672
|
+
size: "sm",
|
|
673
|
+
onClick: ()=>table.nextPage(),
|
|
674
|
+
disabled: currentPageIndex >= lastPageIndex,
|
|
675
|
+
children: strings.next
|
|
676
|
+
})
|
|
300
677
|
]
|
|
301
|
-
}),
|
|
302
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_button_cjs_namespaceObject.Button, {
|
|
303
|
-
variant: "outline",
|
|
304
|
-
size: "sm",
|
|
305
|
-
onClick: ()=>table.nextPage(),
|
|
306
|
-
disabled: !table.getCanNextPage(),
|
|
307
|
-
children: "Next"
|
|
308
678
|
})
|
|
309
679
|
]
|
|
310
680
|
})
|
|
@@ -315,10 +685,22 @@ function DataTable({ columns, data, searchKey, searchPlaceholder = 'Search...',
|
|
|
315
685
|
}
|
|
316
686
|
function DataTableColumnHeader({ column, title, children }) {
|
|
317
687
|
const sorted = column.getIsSorted();
|
|
318
|
-
|
|
319
|
-
|
|
688
|
+
if (column.getCanSort?.() === false) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("span", {
|
|
689
|
+
"data-slot": "data-table-column-header",
|
|
690
|
+
className: "flex h-8 max-w-full items-center text-sm font-medium",
|
|
691
|
+
children: [
|
|
692
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
693
|
+
className: "truncate min-w-0",
|
|
694
|
+
children: title
|
|
695
|
+
}),
|
|
696
|
+
children
|
|
697
|
+
]
|
|
698
|
+
});
|
|
699
|
+
const handleClick = (event)=>{
|
|
700
|
+
const multi = event.shiftKey && (column.getCanMultiSort?.() ?? false);
|
|
701
|
+
if ('asc' === sorted) column.toggleSorting(true, multi);
|
|
320
702
|
else if ('desc' === sorted) column.clearSorting();
|
|
321
|
-
else column.toggleSorting(false);
|
|
703
|
+
else column.toggleSorting(false, multi);
|
|
322
704
|
};
|
|
323
705
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_button_cjs_namespaceObject.Button, {
|
|
324
706
|
"data-slot": "data-table-column-header",
|
|
@@ -337,11 +719,14 @@ function DataTableColumnHeader({ column, title, children }) {
|
|
|
337
719
|
}),
|
|
338
720
|
children,
|
|
339
721
|
'asc' === sorted ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.ArrowUp, {
|
|
340
|
-
className: "ml-2 h-4 w-4"
|
|
722
|
+
className: "ml-2 h-4 w-4",
|
|
723
|
+
"aria-hidden": "true"
|
|
341
724
|
}) : 'desc' === sorted ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.ArrowDown, {
|
|
342
|
-
className: "ml-2 h-4 w-4"
|
|
725
|
+
className: "ml-2 h-4 w-4",
|
|
726
|
+
"aria-hidden": "true"
|
|
343
727
|
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.ArrowUpDown, {
|
|
344
|
-
className: "ml-2 h-4 w-4"
|
|
728
|
+
className: "ml-2 h-4 w-4",
|
|
729
|
+
"aria-hidden": "true"
|
|
345
730
|
})
|
|
346
731
|
]
|
|
347
732
|
});
|
|
@@ -352,21 +737,25 @@ function DataTableSelectColumn() {
|
|
|
352
737
|
header: ({ table })=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_checkbox_cjs_namespaceObject.Checkbox, {
|
|
353
738
|
checked: table.getIsAllPageRowsSelected() || table.getIsSomePageRowsSelected() && 'indeterminate',
|
|
354
739
|
onCheckedChange: (value)=>table.toggleAllPageRowsSelected(!!value),
|
|
355
|
-
"aria-label":
|
|
740
|
+
"aria-label": (getInternalMeta(table)?.strings ?? DEFAULT_DATA_TABLE_STRINGS).selectAll
|
|
356
741
|
}),
|
|
357
|
-
cell: ({ row })=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_checkbox_cjs_namespaceObject.Checkbox, {
|
|
742
|
+
cell: ({ row, table })=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_checkbox_cjs_namespaceObject.Checkbox, {
|
|
358
743
|
checked: row.getIsSelected(),
|
|
359
744
|
onCheckedChange: (value)=>row.toggleSelected(!!value),
|
|
360
|
-
"aria-label":
|
|
745
|
+
"aria-label": (getInternalMeta(table)?.strings ?? DEFAULT_DATA_TABLE_STRINGS).selectRow(row.index + 1)
|
|
361
746
|
}),
|
|
747
|
+
size: 48,
|
|
362
748
|
enableSorting: false,
|
|
363
|
-
enableHiding: false
|
|
749
|
+
enableHiding: false,
|
|
750
|
+
enableResizing: false
|
|
364
751
|
};
|
|
365
752
|
}
|
|
753
|
+
exports.DEFAULT_DATA_TABLE_STRINGS = __webpack_exports__.DEFAULT_DATA_TABLE_STRINGS;
|
|
366
754
|
exports.DataTable = __webpack_exports__.DataTable;
|
|
367
755
|
exports.DataTableColumnHeader = __webpack_exports__.DataTableColumnHeader;
|
|
368
756
|
exports.DataTableSelectColumn = __webpack_exports__.DataTableSelectColumn;
|
|
369
757
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
758
|
+
"DEFAULT_DATA_TABLE_STRINGS",
|
|
370
759
|
"DataTable",
|
|
371
760
|
"DataTableColumnHeader",
|
|
372
761
|
"DataTableSelectColumn"
|