@eml-payments/ui-kit 0.1.23 → 0.1.24
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/src/components/Table/Table.js +6 -4
- package/dist/src/components/Table/Table.stories.d.ts +1 -0
- package/dist/src/components/Table/Table.stories.js +4 -1
- package/dist/src/components/Table/Table.types.d.ts +1 -0
- package/dist/src/components/Table/hooks/useTableController.d.ts +2 -1
- package/dist/src/components/Table/hooks/useTableController.js +2 -1
- package/dist/src/components/Tooltip/Tooltip.stories.js +1 -1
- package/package.json +1 -1
|
@@ -9,7 +9,7 @@ import { FiMoreHorizontal } from 'react-icons/fi';
|
|
|
9
9
|
import { Button } from '../Button';
|
|
10
10
|
export function Table(props) {
|
|
11
11
|
var _a;
|
|
12
|
-
const { table, setPageSize, ...pagination } = useTableController(props);
|
|
12
|
+
const { table, setPageSize, showHeader, ...pagination } = useTableController(props);
|
|
13
13
|
let tableContent;
|
|
14
14
|
if (props.isLoading && props.showSkeletonRows) {
|
|
15
15
|
tableContent = Array.from({ length: 3 }).map((_c) => (_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-[var(--uikit-tertiary)] rounded" }) }, `skeleton-cell-${__c.id}`))) }, `skeleton-row`)));
|
|
@@ -26,8 +26,10 @@ export function Table(props) {
|
|
|
26
26
|
}), props.tableActionsDropdown && (_jsx("td", { className: "w-[40px] px-2 py-2 text-right", children: _jsx(DropdownWrapper, { structure: (_a = props.tableActionsDropdown.structure) !== null && _a !== void 0 ? _a : 'default', options: props.tableActionsDropdown.getOptions(row.original), triggerElement: (_e = (_d = (_b = props.tableActionsDropdown).renderCustomTrigger) === null || _d === void 0 ? void 0 : _d.call(_b, row.original)) !== null && _e !== void 0 ? _e : (_jsx(Button, { size: "icon", variant: "ghost", className: "p-1 focus-visible:outline-none focus-visible:ring-0", children: _jsx(FiMoreHorizontal, { size: 16 }) })) }) }))] }, row.original[((_f = props.rowIdKey) !== null && _f !== void 0 ? _f : 'id')]));
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
|
-
return (_jsxs("div", { className: "relative w-full overflow-auto", children: [props.isLoading && _jsx("div", { className: "mui-loader" }), _jsx("div", { className: "rounded-[var(--uikit-radius)] overflow-hidden border", children: _jsxs("table", { className: classNames('min-w-full text-sm table-fixed', props.className), role: "table", id: props.id, children: [_jsx("thead", { className: "bg-[var(--uikit-tertiary)]", children: table.getHeaderGroups().map((headerGroup) => (_jsxs("tr", { children: [headerGroup.headers.map((header) => {
|
|
30
|
-
return (_jsx("th", { style: { width: header.getSize() }, className: classNames('select-none text-[16px]', header.id === 'select'
|
|
29
|
+
return (_jsxs("div", { className: "relative w-full overflow-auto", children: [props.isLoading && _jsx("div", { className: "mui-loader" }), _jsx("div", { className: "rounded-[var(--uikit-radius)] overflow-hidden border", children: _jsxs("table", { className: classNames('min-w-full text-sm table-fixed', props.className), role: "table", id: props.id, children: [showHeader && (_jsx("thead", { className: "bg-[var(--uikit-tertiary)]", children: table.getHeaderGroups().map((headerGroup) => (_jsxs("tr", { children: [headerGroup.headers.map((header) => {
|
|
30
|
+
return (_jsx("th", { style: { width: header.getSize() }, className: classNames('select-none text-[16px]', header.id === 'select'
|
|
31
|
+
? 'p-0'
|
|
32
|
+
: 'px-4 py-2 text-left cursor-pointer'), onClick: header.column.getCanSort()
|
|
31
33
|
? header.column.getToggleSortingHandler()
|
|
32
34
|
: undefined, children: _jsxs("div", { className: classNames('w-full h-full', header.id === 'select'
|
|
33
35
|
? 'flex justify-center items-center'
|
|
@@ -35,5 +37,5 @@ export function Table(props) {
|
|
|
35
37
|
asc: _jsx(FaChevronUp, {}),
|
|
36
38
|
desc: _jsx(FaChevronDown, {}),
|
|
37
39
|
}[header.column.getIsSorted()] || null }))] }) }, header.id));
|
|
38
|
-
}), props.tableActionsDropdown && _jsx("th", { className: "w-[40px] px-2 py-2 text-right" })] }, headerGroup.id))) }), _jsx("tbody", { children: tableContent })] }) }), _jsx(PaginationFooter, { tableId: props.id, table: table, paginationMode: props.paginationMode, totalServerRows: props.totalServerRows, onPageSizeChange: setPageSize, ...pagination })] }));
|
|
40
|
+
}), props.tableActionsDropdown && _jsx("th", { className: "w-[40px] px-2 py-2 text-right" })] }, headerGroup.id))) })), _jsx("tbody", { children: tableContent })] }) }), _jsx(PaginationFooter, { tableId: props.id, table: table, paginationMode: props.paginationMode, totalServerRows: props.totalServerRows, onPageSizeChange: setPageSize, ...pagination })] }));
|
|
39
41
|
}
|
|
@@ -136,9 +136,12 @@ export const WithRowActionsDropdown = {
|
|
|
136
136
|
};
|
|
137
137
|
export const WithRowClickHandler = {
|
|
138
138
|
render: () => {
|
|
139
|
-
return (_jsx(Table, { id: "clickable-rows-table", data: data, columns: columns, onRowClick: row => {
|
|
139
|
+
return (_jsx(Table, { id: "clickable-rows-table", data: data, columns: columns, onRowClick: (row) => {
|
|
140
140
|
console.log('Row clicked:', row);
|
|
141
141
|
alert(`Clicked on ${row.name}`);
|
|
142
142
|
} }));
|
|
143
143
|
},
|
|
144
144
|
};
|
|
145
|
+
export const WithHiddenHeader = {
|
|
146
|
+
render: () => _jsx(Table, { id: "header-hidden-table", data: data, columns: columns, showHeader: false }),
|
|
147
|
+
};
|
|
@@ -2,7 +2,7 @@ import { type SortingState } from '@tanstack/react-table';
|
|
|
2
2
|
import type { TableProps } from '../Table.types';
|
|
3
3
|
export declare function useTableController<T extends {
|
|
4
4
|
id: string;
|
|
5
|
-
}>({ data, columns, checkboxSelection, checkboxPosition, paginationMode, sorting, onSortingChange, onSelectionChange, enableRowSelection, rowsPerPage, isMultiRowSelection, selectedRowIds, rowIdKey, totalServerRows, onRefetch, }: TableProps<T>): {
|
|
5
|
+
}>({ data, columns, checkboxSelection, checkboxPosition, paginationMode, sorting, onSortingChange, onSelectionChange, enableRowSelection, rowsPerPage, isMultiRowSelection, selectedRowIds, rowIdKey, totalServerRows, onRefetch, showHeader, }: TableProps<T>): {
|
|
6
6
|
pageIndex: number;
|
|
7
7
|
pageSize: number;
|
|
8
8
|
canNextPage: boolean;
|
|
@@ -13,4 +13,5 @@ export declare function useTableController<T extends {
|
|
|
13
13
|
setPageSize: import("react").Dispatch<import("react").SetStateAction<number>>;
|
|
14
14
|
setPageIndex: import("react").Dispatch<import("react").SetStateAction<number>>;
|
|
15
15
|
sorting: SortingState;
|
|
16
|
+
showHeader: boolean;
|
|
16
17
|
};
|
|
@@ -2,7 +2,7 @@ import { useEffect, useState } from 'react';
|
|
|
2
2
|
import { useReactTable, getCoreRowModel, getSortedRowModel, getPaginationRowModel, } from '@tanstack/react-table';
|
|
3
3
|
import { applyFlexSizes, getCheckboxSelectionColumn } from '../table.helpers';
|
|
4
4
|
import { usePaginationController } from './usePaginationController';
|
|
5
|
-
export function useTableController({ data, columns, checkboxSelection, checkboxPosition = 'start', paginationMode = 'client', sorting, onSortingChange, onSelectionChange, enableRowSelection, rowsPerPage = 10, isMultiRowSelection = true, selectedRowIds, rowIdKey = 'id', totalServerRows, onRefetch, }) {
|
|
5
|
+
export function useTableController({ data, columns, checkboxSelection, checkboxPosition = 'start', paginationMode = 'client', sorting, onSortingChange, onSelectionChange, enableRowSelection, rowsPerPage = 10, isMultiRowSelection = true, selectedRowIds, rowIdKey = 'id', totalServerRows, onRefetch, showHeader = true, }) {
|
|
6
6
|
const safeData = Array.isArray(data) ? data : [];
|
|
7
7
|
const [tableColumns, setTableColumns] = useState(() => applyFlexSizes(columns !== null && columns !== void 0 ? columns : []));
|
|
8
8
|
const [internalSorting, setInternalSorting] = useState(sorting !== null && sorting !== void 0 ? sorting : []);
|
|
@@ -82,6 +82,7 @@ export function useTableController({ data, columns, checkboxSelection, checkboxP
|
|
|
82
82
|
setPageSize,
|
|
83
83
|
setPageIndex,
|
|
84
84
|
sorting: sorting !== null && sorting !== void 0 ? sorting : internalSorting,
|
|
85
|
+
showHeader,
|
|
85
86
|
...pagination,
|
|
86
87
|
};
|
|
87
88
|
}
|
|
@@ -12,7 +12,7 @@ export const Default = {
|
|
|
12
12
|
render: () => (_jsx(TooltipStoryWrapper, { content: "Simple tooltip", children: _jsx(Button, { children: "Hover me" }) })),
|
|
13
13
|
};
|
|
14
14
|
export const LongTextResponsive = {
|
|
15
|
-
render: () => (_jsx(TooltipStoryWrapper, { content: "This tooltip contains a longer message that wraps gracefully across multiple lines. On smaller\
|
|
15
|
+
render: () => (_jsx(TooltipStoryWrapper, { content: "This tooltip contains a longer message that wraps gracefully across multiple lines. On smaller\n\t\tscreens, it narrows and stacks vertically so it's easier to read\u2014especially useful for\n\t\taccessibility, mobile devices, or multi-language support.", side: "top", children: _jsx(Button, { children: "Hover me" }) })),
|
|
16
16
|
};
|
|
17
17
|
export const OnDifferentSides = {
|
|
18
18
|
render: () => (_jsxs("div", { className: "grid grid-cols-2 gap-4", children: [_jsx(TooltipStoryWrapper, { content: "Top tooltip", side: "top", children: _jsx(Button, { children: "Top" }) }), _jsx(TooltipStoryWrapper, { content: "Bottom tooltip", side: "bottom", children: _jsx(Button, { children: "Bottom" }) }), _jsx(TooltipStoryWrapper, { content: "Left tooltip", side: "left", children: _jsx(Button, { children: "Left" }) }), _jsx(TooltipStoryWrapper, { content: "Right tooltip", side: "right", children: _jsx(Button, { children: "Right" }) })] })),
|