@eml-payments/ui-kit 1.7.4 → 1.7.6
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/img/flags.png +0 -0
- package/dist/img/flags.webp +0 -0
- package/dist/img/flags@2x.png +0 -0
- package/dist/img/flags@2x.webp +0 -0
- package/dist/index.css +1 -1
- package/dist/index.d.cts +488 -0
- package/dist/index.d.ts +488 -0
- package/dist/src/components/Table/BaseTable/index.d.ts +1 -0
- package/dist/src/components/Table/BaseTable/index.js +1 -0
- package/dist/src/components/Table/Pagination/PaginationControls.d.ts +3 -0
- package/dist/src/components/Table/Pagination/PaginationControls.js +22 -0
- package/dist/src/components/Table/Pagination/PaginationControls.types.d.ts +24 -0
- package/dist/src/components/Table/Pagination/PaginationControls.types.js +1 -0
- package/dist/src/components/Table/StandardTable/StandardTable.d.ts +1 -1
- package/dist/src/components/Table/StandardTable/StandardTable.stories.d.ts +2 -1
- package/dist/src/components/Table/StandardTable/StandardTable.stories.js +58 -10
- package/dist/src/components/Table/StandardTable/StandardTable.types.d.ts +2 -2
- package/dist/src/components/Table/StandardTable/useStandardTableController.d.ts +1 -1
- package/dist/src/components/Table/StandardTable/useStandardTableController.js +13 -2
- package/dist/src/components/Table/Table.d.ts +4 -0
- package/dist/src/components/Table/Table.js +93 -0
- package/dist/src/components/Table/Table.stories.d.ts +31 -0
- package/dist/src/components/Table/Table.stories.js +479 -0
- package/dist/src/components/Table/Table.types.d.ts +15 -4
- package/dist/src/components/Table/hooks/useInfiniteScrolling.d.ts +29 -0
- package/dist/src/components/Table/hooks/useInfiniteScrolling.js +96 -0
- package/dist/src/components/Table/hooks/usePaginationController.d.ts +16 -0
- package/dist/src/components/Table/hooks/usePaginationController.js +30 -0
- package/dist/src/components/Table/hooks/useTableController.d.ts +26 -0
- package/dist/src/components/Table/hooks/useTableController.js +146 -0
- package/dist/src/components/Table/hooks/useUrlPaginationSync.d.ts +7 -1
- package/dist/src/components/Table/hooks/useUrlPaginationSync.js +52 -10
- package/dist/src/components/Table/types/scopedTableId.types.d.ts +4 -0
- package/dist/src/components/Table/types/scopedTableId.types.js +1 -0
- package/dist/src/components/Tooltip/Tooltip.stories.js +1 -1
- package/package.json +3 -2
|
@@ -230,15 +230,48 @@ const CurrentUrl = () => {
|
|
|
230
230
|
return (_jsxs("div", { style: { fontSize: 12, marginBottom: 8 }, children: ["Current URL: ", _jsx("code", { children: location.search })] }));
|
|
231
231
|
};
|
|
232
232
|
export const WithQueryParamsSync = {
|
|
233
|
+
parameters: {
|
|
234
|
+
docs: {
|
|
235
|
+
description: {
|
|
236
|
+
story: 'Single table with generic URL params "page" and "size". Default behavior when scoped is not provided or scoped={false}.',
|
|
237
|
+
},
|
|
238
|
+
},
|
|
239
|
+
},
|
|
233
240
|
decorators: [
|
|
234
241
|
(Story) => {
|
|
235
|
-
const query = `?
|
|
242
|
+
const query = `?page=2&size=5`;
|
|
236
243
|
globalThis.history.replaceState({}, '', query);
|
|
237
244
|
return _jsx(Story, {});
|
|
238
245
|
},
|
|
239
246
|
],
|
|
240
247
|
render: () => (_jsxs(_Fragment, { children: [_jsx(CurrentUrl, {}), _jsx(StandardTable, { id: "clients", data: data, columns: columns, paginationMode: "client" })] })),
|
|
241
248
|
};
|
|
249
|
+
function MultiTableWithScopedPaginationExample() {
|
|
250
|
+
const productsData = Array.from({ length: 20 }).map((_, i) => ({
|
|
251
|
+
id: `product-${i + 1}`,
|
|
252
|
+
name: `Product ${i + 1}`,
|
|
253
|
+
email: `product${i + 1}@example.com`,
|
|
254
|
+
role: i % 2 === 0 ? 'Featured' : 'Regular',
|
|
255
|
+
}));
|
|
256
|
+
return (_jsxs(_Fragment, { children: [_jsx(CurrentUrl, {}), _jsxs("div", { style: { marginBottom: 40 }, children: [_jsx("h3", { style: { marginBottom: 8 }, children: "Users Table (scoped pagination)" }), _jsx(StandardTable, { id: "users", data: data, columns: columns, paginationMode: "client", rowsPerPage: 5, scoped: true })] }), _jsxs("div", { children: [_jsx("h3", { style: { marginBottom: 8 }, children: "Products Table (scoped pagination)" }), _jsx(StandardTable, { id: "products", data: productsData, columns: columns, paginationMode: "client", rowsPerPage: 5, scoped: true })] })] }));
|
|
257
|
+
}
|
|
258
|
+
export const WithScopedMultiTablePagination = {
|
|
259
|
+
parameters: {
|
|
260
|
+
docs: {
|
|
261
|
+
description: {
|
|
262
|
+
story: 'Multiple tables on one page, each with scoped URL params. When scoped={true}, each table uses its id to generate unique URL keys like usersPage/usersSize and productsPage/productsSize, enabling independent pagination state.',
|
|
263
|
+
},
|
|
264
|
+
},
|
|
265
|
+
},
|
|
266
|
+
decorators: [
|
|
267
|
+
(Story) => {
|
|
268
|
+
const query = `?usersPage=1&usersSize=5&productsPage=1&productsSize=5`;
|
|
269
|
+
globalThis.history.replaceState({}, '', query);
|
|
270
|
+
return _jsx(Story, {});
|
|
271
|
+
},
|
|
272
|
+
],
|
|
273
|
+
render: () => _jsx(MultiTableWithScopedPaginationExample, {}),
|
|
274
|
+
};
|
|
242
275
|
/** Simulates a server fetch with latency. Used by server-side query-param stories. */
|
|
243
276
|
async function fetchServerData(pageIndex, pageSize) {
|
|
244
277
|
await new Promise((r) => setTimeout(r, 500));
|
|
@@ -267,31 +300,46 @@ function ServerPaginationWithQueryParamsExample() {
|
|
|
267
300
|
export const ServerPaginationWithQueryParams = {
|
|
268
301
|
decorators: [
|
|
269
302
|
(Story) => {
|
|
270
|
-
globalThis.history.replaceState({}, '', '?
|
|
303
|
+
globalThis.history.replaceState({}, '', '?page=2&size=5');
|
|
271
304
|
return _jsx(Story, {});
|
|
272
305
|
},
|
|
273
306
|
],
|
|
274
307
|
render: () => _jsx(ServerPaginationWithQueryParamsExample, {}),
|
|
275
308
|
};
|
|
276
|
-
function
|
|
309
|
+
function ServerPaginationMultiTableExample() {
|
|
277
310
|
const [usersRows, setUsersRows] = useState([]);
|
|
278
|
-
const [
|
|
311
|
+
const [usersLoading, setUsersLoading] = useState(false);
|
|
312
|
+
const [productsRows, setProductsRows] = useState([]);
|
|
313
|
+
const [productsLoading, setProductsLoading] = useState(false);
|
|
279
314
|
const fetchUsersData = useCallback(async (pageIndex, pageSize) => {
|
|
280
|
-
|
|
315
|
+
setUsersLoading(true);
|
|
281
316
|
const results = await fetchServerData(pageIndex, pageSize);
|
|
282
317
|
setUsersRows(results);
|
|
283
|
-
|
|
318
|
+
setUsersLoading(false);
|
|
284
319
|
}, []);
|
|
285
|
-
|
|
320
|
+
const fetchProductsData = useCallback(async (pageIndex, pageSize) => {
|
|
321
|
+
setProductsLoading(true);
|
|
322
|
+
const results = await fetchServerData(pageIndex, pageSize);
|
|
323
|
+
setProductsRows(results);
|
|
324
|
+
setProductsLoading(false);
|
|
325
|
+
}, []);
|
|
326
|
+
return (_jsxs(_Fragment, { children: [_jsx(CurrentUrl, {}), _jsxs("div", { style: { marginBottom: 40 }, children: [_jsx("h3", { style: { marginBottom: 8 }, children: "Users (scoped server pagination)" }), _jsx(StandardTable, { id: "users", data: usersRows, columns: columns, paginationMode: "server", rowsPerPage: 5, totalServerRows: 100, onRefetch: fetchUsersData, isLoading: usersLoading, scoped: true })] }), _jsxs("div", { children: [_jsx("h3", { style: { marginBottom: 8 }, children: "Products (scoped server pagination)" }), _jsx(StandardTable, { id: "products", data: productsRows, columns: columns, paginationMode: "server", rowsPerPage: 5, totalServerRows: 100, onRefetch: fetchProductsData, isLoading: productsLoading, scoped: true })] })] }));
|
|
286
327
|
}
|
|
287
|
-
export const
|
|
328
|
+
export const ServerPaginationMultiTableWithQueryParams = {
|
|
329
|
+
parameters: {
|
|
330
|
+
docs: {
|
|
331
|
+
description: {
|
|
332
|
+
story: 'Multiple server-paginated tables with scoped URL params. Each table independently fetches server data while maintaining separate pagination state in the URL.',
|
|
333
|
+
},
|
|
334
|
+
},
|
|
335
|
+
},
|
|
288
336
|
decorators: [
|
|
289
337
|
(Story) => {
|
|
290
|
-
globalThis.history.replaceState({}, '', '?
|
|
338
|
+
globalThis.history.replaceState({}, '', '?usersPage=1&usersSize=5&productsPage=1&productsSize=5');
|
|
291
339
|
return _jsx(Story, {});
|
|
292
340
|
},
|
|
293
341
|
],
|
|
294
|
-
render: () => _jsx(
|
|
342
|
+
render: () => _jsx(ServerPaginationMultiTableExample, {}),
|
|
295
343
|
};
|
|
296
344
|
export const GroupedAccordion = {
|
|
297
345
|
render: () => (_jsx(StandardTable, { id: "grouped-accordion", data: groupingData, columns: groupingColumns, showHeader: false, grouping: ['date'], enableAccordion: true, paginationMode: "client", showGroupedTotal: true })),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { StandardTableProps as BaseStandardTableProps } from '../Table.types';
|
|
2
2
|
export type StandardTableProps<T extends {
|
|
3
3
|
id: string;
|
|
4
|
-
}> =
|
|
4
|
+
}, TId extends string = string> = BaseStandardTableProps<T, TId>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { StandardTableProps } from '../Table.types';
|
|
2
2
|
export declare function useStandardTableController<T extends {
|
|
3
3
|
id: string;
|
|
4
|
-
}>(props: StandardTableProps<T>): {
|
|
4
|
+
}, TId extends string = string>(props: StandardTableProps<T, TId>): {
|
|
5
5
|
table: import("@tanstack/table-core").Table<T>;
|
|
6
6
|
height: string | number | undefined;
|
|
7
7
|
showHeader: boolean;
|
|
@@ -6,7 +6,7 @@ import { usePaginationController } from '../Pagination/usePaginationController';
|
|
|
6
6
|
export function useStandardTableController(props) {
|
|
7
7
|
const { id, data, columns, rowIdKey = 'id', height, showHeader = true,
|
|
8
8
|
// pagination
|
|
9
|
-
paginationMode = 'client', rowsPerPage = 10, totalServerRows, onRefetch,
|
|
9
|
+
paginationMode = 'client', rowsPerPage = 10, scoped, totalServerRows, onRefetch,
|
|
10
10
|
// sorting / grouping
|
|
11
11
|
sorting, onSortingChange, grouping, enableAccordion,
|
|
12
12
|
// search
|
|
@@ -40,9 +40,20 @@ export function useStandardTableController(props) {
|
|
|
40
40
|
ro.observe(parentScrollRef.current);
|
|
41
41
|
return () => ro.disconnect();
|
|
42
42
|
}, []);
|
|
43
|
-
const { initialPageIndex, initialPageSize, syncToUrl } = useUrlPaginationSync(
|
|
43
|
+
const { initialPageIndex, initialPageSize, syncToUrl } = useUrlPaginationSync({
|
|
44
|
+
defaultPageSize: rowsPerPage,
|
|
45
|
+
tableId: id,
|
|
46
|
+
scoped,
|
|
47
|
+
enabled: paginationMode !== 'none',
|
|
48
|
+
});
|
|
44
49
|
const [pageIndex, setPageIndex] = useState(initialPageIndex);
|
|
45
50
|
const [pageSize, setPageSize] = useState(initialPageSize);
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
setPageIndex(initialPageIndex);
|
|
53
|
+
}, [initialPageIndex]);
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
setPageSize(initialPageSize);
|
|
56
|
+
}, [initialPageSize]);
|
|
46
57
|
const [internalSorting, setInternalSorting] = useState(sorting !== null && sorting !== void 0 ? sorting : []);
|
|
47
58
|
const [expanded, setExpanded] = useState(true);
|
|
48
59
|
const stableGrouping = useMemo(() => grouping !== null && grouping !== void 0 ? grouping : [], [grouping]);
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { flexRender } from '@tanstack/react-table';
|
|
3
|
+
import { classNames } from '../../utils/classNames';
|
|
4
|
+
import { PaginationFooter } from './Pagination/PaginationControls';
|
|
5
|
+
import { useTableController } from './hooks/useTableController';
|
|
6
|
+
import { FaChevronDown, FaChevronUp } from 'react-icons/fa';
|
|
7
|
+
import { DropdownWrapper } from '../DropdownWrapper';
|
|
8
|
+
import { FiMoreHorizontal } from 'react-icons/fi';
|
|
9
|
+
import { Button } from '../Button';
|
|
10
|
+
export function Table(props) {
|
|
11
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
12
|
+
const { table, setPageSize, showHeader, height, virtualizationEnabled, rowVirtualizer, hasNextPage, parentScrollRef, loaderRef, infiniteScroll, ...pagination } = useTableController(props);
|
|
13
|
+
let tableContent;
|
|
14
|
+
const noResultsMessage = props.isSearchActive
|
|
15
|
+
? ((_a = props.noSearchResultsMessage) !== null && _a !== void 0 ? _a : 'No results meet your search criteria')
|
|
16
|
+
: ((_b = props.noRowsMessage) !== null && _b !== void 0 ? _b : 'No rows to display');
|
|
17
|
+
if (props.isLoading && props.showSkeletonRows) {
|
|
18
|
+
tableContent = Array.from({ length: 3 }).map(() => (_jsx("tr", { className: "border-t animate-pulse", children: table.getVisibleFlatColumns().map((__c) => (_jsx("td", { className: "px-4 py-2", children: _jsx("div", { className: "h-4 w-3/4 bg-(--uikit-tertiary) rounded" }) }, `skeleton-cell-${__c.id}`))) }, "skeleton-row")));
|
|
19
|
+
}
|
|
20
|
+
else if (!virtualizationEnabled &&
|
|
21
|
+
table.getRowModel().rows.length === 0 &&
|
|
22
|
+
!props.isLoading &&
|
|
23
|
+
(!(infiniteScroll === null || infiniteScroll === void 0 ? void 0 : infiniteScroll.enabled) || !hasNextPage)) {
|
|
24
|
+
tableContent = (_jsx("tr", { children: _jsx("td", { colSpan: table.getVisibleFlatColumns().length + (props.tableActionsDropdown ? 1 : 0), className: "px-4 py-8 text-center text-muted-foreground", children: noResultsMessage }) }));
|
|
25
|
+
}
|
|
26
|
+
else if (!virtualizationEnabled) {
|
|
27
|
+
const renderRow = (row) => {
|
|
28
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
29
|
+
const rows = [];
|
|
30
|
+
const isRowClickable = (_a = props.isRowClickable) === null || _a === void 0 ? void 0 : _a.call(props, row.original);
|
|
31
|
+
if (row.getIsGrouped() && row.groupingColumnId) {
|
|
32
|
+
const column = table.getColumn(row.groupingColumnId);
|
|
33
|
+
const bgColor = (_c = (_b = column === null || column === void 0 ? void 0 : column.columnDef.meta) === null || _b === void 0 ? void 0 : _b.bgColor) !== null && _c !== void 0 ? _c : 'transparent';
|
|
34
|
+
rows.push(_jsx("tr", { className: "border-none", children: _jsx("td", { colSpan: table.getVisibleLeafColumns().length, className: "p-0", children: _jsx("div", { className: "px-4 py-4 text-sm text-muted-foreground", style: { backgroundColor: bgColor }, children: row.getGroupingValue(row.groupingColumnId) }) }) }, `group-${row.id}`));
|
|
35
|
+
row.subRows.forEach((subRow) => {
|
|
36
|
+
rows.push(...renderRow(subRow));
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
rows.push(_jsxs("tr", { className: classNames('border-t', isRowClickable && 'cursor-pointer', row.getIsSelected() && 'bg-(--uikit-primary-10)'), onClick: () => { var _a; return isRowClickable && ((_a = props.onRowClick) === null || _a === void 0 ? void 0 : _a.call(props, row.original)); }, children: [row.getVisibleCells().map((cell) => {
|
|
41
|
+
const width = cell.column.getSize();
|
|
42
|
+
return (_jsx("td", { style: { width }, className: cell.column.id === 'select' ? 'p-1' : 'p-4', children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id));
|
|
43
|
+
}), props.tableActionsDropdown && (_jsx("td", { className: "w-[40px] px-2 py-2 text-right", children: _jsx(DropdownWrapper, { structure: (_d = props.tableActionsDropdown.structure) !== null && _d !== void 0 ? _d : 'default', options: props.tableActionsDropdown.getOptions(row.original), menuAlignment: props.tableActionsDropdown.menuAlignment, isTriggerElementDisabled: typeof props.tableActionsDropdown.isDisabled === 'function'
|
|
44
|
+
? props.tableActionsDropdown.isDisabled(row.original)
|
|
45
|
+
: props.tableActionsDropdown.isDisabled, triggerElement: (_g = (_f = (_e = props.tableActionsDropdown).renderCustomTrigger) === null || _f === void 0 ? void 0 : _f.call(_e, row.original)) !== null && _g !== void 0 ? _g : (_jsx(Button, { "aria-label": "Open actions menu", title: "Open actions menu", size: "icon", variant: "ghost", disabled: typeof props.tableActionsDropdown.isDisabled === 'function'
|
|
46
|
+
? props.tableActionsDropdown.isDisabled(row.original)
|
|
47
|
+
: ((_h = props.tableActionsDropdown.isDisabled) !== null && _h !== void 0 ? _h : false), className: "p-1 focus-visible:outline-hidden focus-visible:ring-0", children: _jsx(FiMoreHorizontal, { size: 16 }) })) }) }))] }, row.original[((_j = props.rowIdKey) !== null && _j !== void 0 ? _j : 'id')]));
|
|
48
|
+
}
|
|
49
|
+
return rows;
|
|
50
|
+
};
|
|
51
|
+
tableContent = table.getRowModel().rows.flatMap(renderRow);
|
|
52
|
+
}
|
|
53
|
+
const virtualItems = virtualizationEnabled && rowVirtualizer ? rowVirtualizer.getVirtualItems() : [];
|
|
54
|
+
const colSpanFull = table.getVisibleFlatColumns().length + (props.tableActionsDropdown ? 1 : 0);
|
|
55
|
+
const paddingTop = virtualItems.length ? virtualItems[0].start : 0;
|
|
56
|
+
const lastVirtual = virtualItems[virtualItems.length - 1];
|
|
57
|
+
const totalSize = (_d = (_c = rowVirtualizer === null || rowVirtualizer === void 0 ? void 0 : rowVirtualizer.getTotalSize) === null || _c === void 0 ? void 0 : _c.call(rowVirtualizer)) !== null && _d !== void 0 ? _d : 0;
|
|
58
|
+
const end = lastVirtual ? lastVirtual.end : 0;
|
|
59
|
+
const paddingBottom = Math.max(totalSize - end, 0);
|
|
60
|
+
const tableRows = table.getRowModel().rows;
|
|
61
|
+
const isTrulyEmpty = tableRows.length === 0 && !props.isLoading && !hasNextPage;
|
|
62
|
+
return (_jsxs("div", { ref: parentScrollRef, style: { height }, className: "relative w-full overflow-auto", children: [props.isLoading && _jsx("div", { className: "mui-loader mt-4" }), _jsx("div", { className: "rounded-t-(--uikit-radius) overflow-y-hidden overflow-x-auto", children: _jsxs("table", { className: classNames('min-w-full text-sm table-fixed bg-[#ffffff]', props.className), role: "table", id: props.id, children: [showHeader && (_jsx("thead", { className: "bg-(--uikit-tertiary)", children: table.getHeaderGroups().map((headerGroup) => (_jsxs("tr", { className: "p-4", children: [headerGroup.headers.map((header) => {
|
|
63
|
+
return (_jsx("th", { scope: "col", style: { width: header.getSize() }, className: classNames('select-none text-[14px] font-bold ', header.id === 'select' ? 'p-0' : ' p-4 text-left cursor-pointer'), onClick: !(infiniteScroll === null || infiniteScroll === void 0 ? void 0 : infiniteScroll.enabled) && header.column.getCanSort()
|
|
64
|
+
? header.column.getToggleSortingHandler()
|
|
65
|
+
: undefined, children: _jsxs("div", { className: classNames('w-full h-full', header.id === 'select'
|
|
66
|
+
? 'flex justify-center items-center'
|
|
67
|
+
: 'flex items-center gap-2'), children: [flexRender(header.column.columnDef.header, header.getContext()), !(infiniteScroll === null || infiniteScroll === void 0 ? void 0 : infiniteScroll.enabled) && header.column.getCanSort() && (_jsx("span", { className: "text-xs", children: {
|
|
68
|
+
asc: _jsx(FaChevronUp, {}),
|
|
69
|
+
desc: _jsx(FaChevronDown, {}),
|
|
70
|
+
}[header.column.getIsSorted()] || null }))] }) }, header.id));
|
|
71
|
+
}), props.tableActionsDropdown && _jsx("th", { className: "w-[40px] px-2 py-2 text-right" })] }, headerGroup.id))) })), _jsx("tbody", { children: virtualizationEnabled && rowVirtualizer ? (_jsxs(_Fragment, { children: [_jsx("tr", { style: { height: `${paddingTop}px` }, children: _jsx("td", { colSpan: colSpanFull }) }), isTrulyEmpty && (_jsx("tr", { children: _jsx("td", { colSpan: colSpanFull, className: "px-4 py-8 text-center text-muted-foreground", children: noResultsMessage }) })), virtualItems.map((vi) => {
|
|
72
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
73
|
+
const isLoaderRow = vi.index >= tableRows.length;
|
|
74
|
+
if (isLoaderRow) {
|
|
75
|
+
return (_jsx("tr", { className: "border-t", children: _jsx("td", { colSpan: colSpanFull, className: "px-4 py-2", children: hasNextPage
|
|
76
|
+
? ((_a = infiniteScroll === null || infiniteScroll === void 0 ? void 0 : infiniteScroll.loadingMoreMessage) !== null && _a !== void 0 ? _a : 'Loading more...')
|
|
77
|
+
: ((_b = infiniteScroll === null || infiniteScroll === void 0 ? void 0 : infiniteScroll.noMoreDataMessage) !== null && _b !== void 0 ? _b : 'Nothing more to load') }) }, `loader-${vi.key}`));
|
|
78
|
+
}
|
|
79
|
+
const row = tableRows[vi.index];
|
|
80
|
+
const isRowClickable = (_c = props.isRowClickable) === null || _c === void 0 ? void 0 : _c.call(props, row.original);
|
|
81
|
+
return (_jsxs("tr", { className: classNames('border-t', isRowClickable && 'cursor-pointer', (row === null || row === void 0 ? void 0 : row.getIsSelected()) && 'bg-(--uikit-primary-10)'), onClick: () => { var _a; return isRowClickable && ((_a = props.onRowClick) === null || _a === void 0 ? void 0 : _a.call(props, row.original)); }, children: [row === null || row === void 0 ? void 0 : row.getVisibleCells().map((cell) => {
|
|
82
|
+
const width = cell.column.getSize();
|
|
83
|
+
return (_jsx("td", { style: { width }, className: cell.column.id === 'select' ? 'p-1' : 'p-4', children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id));
|
|
84
|
+
}), props.tableActionsDropdown && (_jsx("td", { className: "w-[40px] px-2 py-2 text-right", children: _jsx(DropdownWrapper, { structure: (_d = props.tableActionsDropdown.structure) !== null && _d !== void 0 ? _d : 'default', options: props.tableActionsDropdown.getOptions(row.original), menuAlignment: props.tableActionsDropdown.menuAlignment, isTriggerElementDisabled: typeof props.tableActionsDropdown.isDisabled === 'function'
|
|
85
|
+
? props.tableActionsDropdown.isDisabled(row.original)
|
|
86
|
+
: props.tableActionsDropdown.isDisabled, triggerElement: (_g = (_f = (_e = props.tableActionsDropdown).renderCustomTrigger) === null || _f === void 0 ? void 0 : _f.call(_e, row.original)) !== null && _g !== void 0 ? _g : (_jsx(Button, { "aria-label": "Open actions menu", title: "Open actions menu", size: "icon", variant: "ghost", disabled: typeof props.tableActionsDropdown.isDisabled ===
|
|
87
|
+
'function'
|
|
88
|
+
? props.tableActionsDropdown.isDisabled(row.original)
|
|
89
|
+
: ((_h = props.tableActionsDropdown.isDisabled) !== null && _h !== void 0 ? _h : false), className: "p-1 focus-visible:outline-hidden focus-visible:ring-0", children: _jsx(FiMoreHorizontal, { size: 16 }) })) }) }))] }, row.original[((_j = props.rowIdKey) !== null && _j !== void 0 ? _j : 'id')]));
|
|
90
|
+
}), _jsx("tr", { style: { height: `${paddingBottom}px` }, children: _jsx("td", { colSpan: colSpanFull }) })] })) : (_jsxs(_Fragment, { children: [tableContent, (infiniteScroll === null || infiniteScroll === void 0 ? void 0 : infiniteScroll.enabled) && !isTrulyEmpty && (_jsx("tr", { ref: loaderRef, className: "border-t", children: _jsx("td", { colSpan: colSpanFull, className: "px-4 py-2", children: props.isLoading || hasNextPage
|
|
91
|
+
? ((_e = infiniteScroll.loadingMoreMessage) !== null && _e !== void 0 ? _e : 'Loading more...')
|
|
92
|
+
: ((_f = infiniteScroll.noMoreDataMessage) !== null && _f !== void 0 ? _f : 'Nothing more to load') }) }))] })) })] }) }), !((_g = props.infiniteScroll) === null || _g === void 0 ? void 0 : _g.enabled) && (_jsx(PaginationFooter, { tableId: props.id, table: table, paginationMode: props.paginationMode, totalServerRows: props.totalServerRows, onPageSizeChange: setPageSize, ...pagination }))] }));
|
|
93
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Table } from './Table';
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
declare const meta: Meta<typeof Table>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof Table>;
|
|
6
|
+
export declare const Basic: Story;
|
|
7
|
+
export declare const NoRows: Story;
|
|
8
|
+
export declare const LoadingWithSkeleton: Story;
|
|
9
|
+
export declare const ClientPagination: Story;
|
|
10
|
+
export declare const ServerSidePagination: Story;
|
|
11
|
+
export declare const WithCheckboxSelection: Story;
|
|
12
|
+
export declare const WithDisabledSelection: Story;
|
|
13
|
+
export declare const WithSingleRowSelection: Story;
|
|
14
|
+
export declare const WithDefaultRowsSelected: Story;
|
|
15
|
+
export declare const FlexColumnWidths: Story;
|
|
16
|
+
export declare const WithControlledSorting: Story;
|
|
17
|
+
export declare const WithRowActionsDropdown: Story;
|
|
18
|
+
export declare const WithPartiallyDisabledRowActionsDropdown: Story;
|
|
19
|
+
export declare const WithDisabledRowActionsDropdownItem: Story;
|
|
20
|
+
export declare const WithRowClickHandler: Story;
|
|
21
|
+
export declare const WithHiddenHeader: Story;
|
|
22
|
+
export declare const GroupedByDate: Story;
|
|
23
|
+
export declare const WithSearch: Story;
|
|
24
|
+
export declare const ServerSideSearch: Story;
|
|
25
|
+
export declare const ClientPaginationWithQueryParams: StoryObj;
|
|
26
|
+
export declare const ServerPaginationWithQueryParams: StoryObj;
|
|
27
|
+
export declare const TwoTablesWithQueryParams: StoryObj;
|
|
28
|
+
export declare const InfiniteScrollVirtualized: StoryObj;
|
|
29
|
+
export declare const InfiniteScrollNonVirtual: StoryObj;
|
|
30
|
+
export declare const NoRowsInfiniteScrollNonVirtual: StoryObj;
|
|
31
|
+
export declare const NoRowsInfiniteScrollVirtualized: StoryObj;
|