@synerise/ds-table-new 0.1.0 → 1.0.2
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/CHANGELOG.md +10 -0
- package/README.md +57 -1
- package/dist/Table.d.ts +1 -1
- package/dist/Table.js +29 -3
- package/dist/Table.styles.d.ts +0 -1
- package/dist/Table.styles.js +0 -5
- package/dist/Table.types.d.ts +164 -10
- package/dist/VirtualTable.d.ts +1 -1
- package/dist/VirtualTable.js +33 -3
- package/dist/components/BackToTopButton/BackToTopButton.d.ts +11 -0
- package/dist/components/BackToTopButton/BackToTopButton.js +34 -0
- package/dist/components/BackToTopButton/BackToTopButton.styles.d.ts +3 -0
- package/dist/components/BackToTopButton/BackToTopButton.styles.js +8 -0
- package/dist/components/BaseTable/BaseTable.d.ts +1 -1
- package/dist/components/BaseTable/BaseTable.js +10 -5
- package/dist/components/BaseTable/BaseTable.styles.js +1 -1
- package/dist/components/Cell/LabelsWithShowMore/Modal/Modal.js +9 -14
- package/dist/components/ItemsMenu/ItemsMenu.d.ts +7 -0
- package/dist/components/ItemsMenu/ItemsMenu.js +9 -0
- package/dist/components/ItemsMenu/ItemsMenu.styles.d.ts +3 -0
- package/dist/components/ItemsMenu/ItemsMenu.styles.js +10 -0
- package/dist/components/TableBody/TableBody.d.ts +1 -1
- package/dist/components/TableBody/TableBody.js +26 -5
- package/dist/components/TableBody/TableBody.styles.d.ts +4 -1
- package/dist/components/TableBody/TableBody.styles.js +2 -2
- package/dist/components/TableBody/TableCell/TableCell.d.ts +2 -1
- package/dist/components/TableBody/TableCell/TableCell.js +2 -1
- package/dist/components/TableBody/TableCell/TableCell.styles.d.ts +4 -1
- package/dist/components/TableBody/TableCell/TableCell.styles.js +7 -2
- package/dist/components/TableBody/TableRow/TableRow.d.ts +1 -3
- package/dist/components/TableBody/TableRow/TableRow.js +3 -5
- package/dist/components/TableBody/TableRow/TableRowVirtual.js +3 -2
- package/dist/components/TableBody/TableRowSelection/TableRowSelection.js +2 -1
- package/dist/components/TableColumns/TableColumns.js +2 -1
- package/dist/components/TableColumns/TableColumns.styles.d.ts +4 -1
- package/dist/components/TableColumns/TableColumns.styles.js +7 -2
- package/dist/components/TableHeader/TableHeader.d.ts +1 -1
- package/dist/components/TableHeader/TableHeader.js +14 -6
- package/dist/components/TableHeader/TableHeaderSelection/TableHeaderSelection.js +37 -16
- package/dist/components/TableHeader/TableLimit/TableLimit.js +4 -3
- package/dist/components/TableHeader/TableLimit/TableLimit.styles.d.ts +0 -1
- package/dist/components/TableHeader/TableLimit/TableLimit.styles.js +0 -5
- package/dist/components/TableHorizontalScroll/TableHorizontalScroll.js +7 -11
- package/dist/components/TreeTable/TreeTable.d.ts +3 -0
- package/dist/components/TreeTable/TreeTable.js +106 -0
- package/dist/components/TreeTable/TreeTable.styles.d.ts +15 -0
- package/dist/components/TreeTable/TreeTable.styles.js +46 -0
- package/dist/components/TreeTable/TreeTable.types.d.ts +26 -0
- package/dist/components/TreeTable/TreeTable.types.js +1 -0
- package/dist/hooks/useDefaultTexts.js +19 -15
- package/dist/hooks/useTable.d.ts +7 -2
- package/dist/hooks/useTable.js +23 -2
- package/dist/hooks/useTableHighlight.d.ts +5 -0
- package/dist/hooks/useTableHighlight.js +33 -0
- package/dist/hooks/useTableSearch.d.ts +13 -0
- package/dist/hooks/useTableSearch.js +36 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/types/table.d.ts +1 -0
- package/dist/utils/legacyColumnConfigAdapter.d.ts +1 -1
- package/dist/utils/legacyColumnConfigAdapter.js +8 -5
- package/package.json +6 -7
|
@@ -20,7 +20,7 @@ const TableSkeleton = /* @__PURE__ */ styled(DSSkeleton).withConfig({
|
|
|
20
20
|
const StyledTable = /* @__PURE__ */ styled.table.withConfig({
|
|
21
21
|
displayName: "BaseTablestyles__StyledTable",
|
|
22
22
|
componentId: "sc-1oa5lc2-4"
|
|
23
|
-
})(["width:var(--table-size);border-spacing:0;border-collapse:separate;"]);
|
|
23
|
+
})(["width:var(--table-size);border-spacing:0;border-collapse:separate;@keyframes ds-table-row-highlight{0%{background-color:transparent;}5%{background-color:var( --ds-highlight-color,", " );}30%{background-color:var( --ds-highlight-color,", " );}100%{background-color:transparent;}}tr.ds-table-row-highlight td{transition:background 0.3s ease-in-out;animation:ds-table-row-highlight var(--ds-highlight-duration,600ms) ease-in-out forwards;}"], (props) => props.theme.palette["blue-050"], (props) => props.theme.palette["blue-050"]);
|
|
24
24
|
const TableColumnsHorizontalScroll = /* @__PURE__ */ styled(TableHorizontalScroll).withConfig({
|
|
25
25
|
displayName: "BaseTablestyles__TableColumnsHorizontalScroll",
|
|
26
26
|
componentId: "sc-1oa5lc2-5"
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { useMemo, useCallback } from "react";
|
|
3
3
|
import Modal from "@synerise/ds-modal";
|
|
4
|
-
import SearchInput from "@synerise/ds-search/dist/Elements/SearchInput/SearchInput";
|
|
5
4
|
import { VirtualTable } from "../../../../VirtualTable.js";
|
|
6
5
|
const DetailsModal = ({
|
|
7
6
|
visible,
|
|
@@ -12,25 +11,21 @@ const DetailsModal = ({
|
|
|
12
11
|
labelKey,
|
|
13
12
|
loading
|
|
14
13
|
}) => {
|
|
15
|
-
const [searchQuery, setSearchQuery] = useState("");
|
|
16
14
|
const columns = useMemo(() => [{
|
|
17
15
|
id: labelKey,
|
|
18
16
|
accessorKey: labelKey,
|
|
19
17
|
cell: (info) => renderItem(info.getValue(), info.row.original)
|
|
20
18
|
}], [renderItem, labelKey]);
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}) : items;
|
|
26
|
-
}, [items, labelKey, searchQuery]);
|
|
19
|
+
const matchesSearchQuery = useCallback((query, row) => {
|
|
20
|
+
const value = row[labelKey];
|
|
21
|
+
return typeof value === "string" && value.toLowerCase().includes(query.toLowerCase());
|
|
22
|
+
}, [labelKey]);
|
|
27
23
|
return /* @__PURE__ */ jsx(Modal, { size: "small", visible, title: texts.modalTitle, closable: true, onCancel: hide, bodyStyle: {
|
|
28
24
|
padding: 0
|
|
29
|
-
}, footer: null, children: /* @__PURE__ */ jsx(VirtualTable, { maxHeight: 500, cellHeight: 64, data:
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}, closeOnClickOutside: true }), hideColumnNames: true }) });
|
|
25
|
+
}, footer: null, children: /* @__PURE__ */ jsx(VirtualTable, { maxHeight: 500, cellHeight: 64, data: items, title: `${items.length} ${texts.records}`, columns, isLoading: loading, hideTitleBar: true, rowKey: "key", matchesSearchQuery, searchProps: {
|
|
26
|
+
clearTooltip: texts.searchClear,
|
|
27
|
+
placeholder: texts.searchPlaceholder
|
|
28
|
+
}, hideColumnNames: true }) });
|
|
34
29
|
};
|
|
35
30
|
export {
|
|
36
31
|
DetailsModal
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { ItemsMenu as ItemsMenu$1 } from "./ItemsMenu.styles.js";
|
|
3
|
+
const ItemsMenu = ({
|
|
4
|
+
children,
|
|
5
|
+
withLeftPadding
|
|
6
|
+
}) => /* @__PURE__ */ jsx(ItemsMenu$1, { $withLeftPadding: withLeftPadding, children });
|
|
7
|
+
export {
|
|
8
|
+
ItemsMenu
|
|
9
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
const ItemsMenu = /* @__PURE__ */ styled.div.withConfig({
|
|
3
|
+
displayName: "ItemsMenustyles__ItemsMenu",
|
|
4
|
+
componentId: "sc-1bl2h39-0"
|
|
5
|
+
})(["display:flex;flex-direction:row;align-items:center;justify-content:flex-start;gap:8px;", ""], ({
|
|
6
|
+
$withLeftPadding
|
|
7
|
+
}) => $withLeftPadding && "padding-left: 24px;");
|
|
8
|
+
export {
|
|
9
|
+
ItemsMenu
|
|
10
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { TableBodyProps } from '../../Table.types';
|
|
3
|
-
export declare const TableBody: <TData extends object, TValue>({ cellHeight, infiniteScroll, onRowClick, getRowTooltipProps, emptyDataComponent, texts, }: TableBodyProps<TData, TValue>) => React.JSX.Element;
|
|
3
|
+
export declare const TableBody: <TData extends object, TValue>({ cellHeight, infiniteScroll, onRowClick, getRowTooltipProps, withBodyScroll, tableBodyScrollRef, maxHeight, emptyDataComponent, texts, }: TableBodyProps<TData, TValue>) => React.JSX.Element;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useRef } from "react";
|
|
3
2
|
import { DEFAULT_CELL_HEIGHT } from "../../Table.const.js";
|
|
4
3
|
import { useTableContext } from "../../contexts/TableContext.js";
|
|
5
4
|
import { TBody } from "./TableBody.styles.js";
|
|
@@ -11,6 +10,9 @@ const TableBody = ({
|
|
|
11
10
|
infiniteScroll,
|
|
12
11
|
onRowClick,
|
|
13
12
|
getRowTooltipProps,
|
|
13
|
+
withBodyScroll,
|
|
14
|
+
tableBodyScrollRef,
|
|
15
|
+
maxHeight,
|
|
14
16
|
emptyDataComponent,
|
|
15
17
|
texts
|
|
16
18
|
}) => {
|
|
@@ -18,17 +20,36 @@ const TableBody = ({
|
|
|
18
20
|
table,
|
|
19
21
|
rowVirtualizer
|
|
20
22
|
} = useTableContext();
|
|
21
|
-
const tbodyRef = useRef(null);
|
|
22
23
|
const virtualItems = rowVirtualizer ? rowVirtualizer.getVirtualItems() : [];
|
|
23
|
-
const
|
|
24
|
-
|
|
24
|
+
const flatRows = table.getRowModel().flatRows;
|
|
25
|
+
const expandedState = table.getState().expanded;
|
|
26
|
+
const isExpandedMap = typeof expandedState === "object" ? expandedState : null;
|
|
27
|
+
const nonVirtualRows = !rowVirtualizer && isExpandedMap && flatRows.some((row) => row.depth > 0) ? flatRows.filter((row) => {
|
|
28
|
+
if (row.depth === 0) {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
let current = row.getParentRow();
|
|
32
|
+
while (current) {
|
|
33
|
+
if (!isExpandedMap[current.id]) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
current = current.getParentRow();
|
|
37
|
+
}
|
|
38
|
+
return true;
|
|
39
|
+
}) : flatRows;
|
|
40
|
+
const allRows = rowVirtualizer ? flatRows : nonVirtualRows;
|
|
41
|
+
return allRows.length ? /* @__PURE__ */ jsx(TBody, { "data-testid": "ds-table-body", ref: (node) => {
|
|
42
|
+
if (tableBodyScrollRef) {
|
|
43
|
+
tableBodyScrollRef.current = node;
|
|
44
|
+
}
|
|
45
|
+
}, $maxHeight: maxHeight, withBodyScroll, role: "rowgroup", "data-popup-container": true, style: rowVirtualizer && virtualItems.length ? {
|
|
25
46
|
height: `${rowVirtualizer.getTotalSize()}px`,
|
|
26
47
|
position: "relative"
|
|
27
48
|
} : void 0, children: rowVirtualizer && virtualItems.length ? (
|
|
28
49
|
// Virtualized: place spacer and absolutely-positioned rows
|
|
29
50
|
virtualItems.map((virtual) => {
|
|
30
51
|
const row = allRows[virtual.index];
|
|
31
|
-
return /* @__PURE__ */ jsx(TableRowVirtual, { virtual, cellHeight, row, texts, onRowClick, getRowTooltipProps, rowIndex: virtual.index, infiniteScroll, isLast: virtual.index === allRows.length - 1, isExpanded: row.getIsExpanded(), isParentExpanded: row.getIsAllParentsExpanded() }, row.id);
|
|
52
|
+
return /* @__PURE__ */ jsx(TableRowVirtual, { virtual, cellHeight, row, texts, onRowClick, getRowTooltipProps, rowIndex: virtual.index, infiniteScroll, isLast: virtual.index === allRows.length - 1, isSelected: row.getIsSelected(), isExpanded: row.getIsExpanded(), isParentExpanded: row.getIsAllParentsExpanded() }, row.id);
|
|
32
53
|
})
|
|
33
54
|
) : (
|
|
34
55
|
// Non-virtualized: render all rows in the normal flow
|
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
export declare const Tr: import('styled-components').StyledComponent<"tr", any, {}, never>;
|
|
2
|
-
export declare const TBody: import('styled-components').StyledComponent<"tbody", any, {
|
|
2
|
+
export declare const TBody: import('styled-components').StyledComponent<"tbody", any, {
|
|
3
|
+
$maxHeight?: number;
|
|
4
|
+
withBodyScroll?: boolean;
|
|
5
|
+
}, never>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import styled from "styled-components";
|
|
1
|
+
import styled, { css } from "styled-components";
|
|
2
2
|
import { commonRowStyles } from "../../Table.styles.js";
|
|
3
3
|
import { Td } from "./TableCell/TableCell.styles.js";
|
|
4
4
|
const Tr = /* @__PURE__ */ styled.tr.withConfig({
|
|
@@ -8,7 +8,7 @@ const Tr = /* @__PURE__ */ styled.tr.withConfig({
|
|
|
8
8
|
const TBody = /* @__PURE__ */ styled.tbody.withConfig({
|
|
9
9
|
displayName: "TableBodystyles__TBody",
|
|
10
10
|
componentId: "sc-1dty8xx-1"
|
|
11
|
-
})(["position:relative;"]);
|
|
11
|
+
})(["position:relative;", ""], (props) => props.withBodyScroll && css(["display:block;max-height:", "px;overflow-y:scroll;"], props.$maxHeight ?? 800));
|
|
12
12
|
export {
|
|
13
13
|
TBody,
|
|
14
14
|
Tr
|
|
@@ -11,6 +11,7 @@ type TableCellProps = WithHTMLAttributes<HTMLTableCellElement, {
|
|
|
11
11
|
leftOffset?: number;
|
|
12
12
|
cellKey?: string;
|
|
13
13
|
headerIndex?: number;
|
|
14
|
+
align?: 'left' | 'center' | 'right';
|
|
14
15
|
}>;
|
|
15
|
-
export declare const TableCell: React.MemoExoticComponent<({ children, width, height, isSorted, colSpan, isPinned, headerIndex, rightOffset, leftOffset, cellKey, ...rest }: TableCellProps) => React.JSX.Element>;
|
|
16
|
+
export declare const TableCell: React.MemoExoticComponent<({ children, width, height, isSorted, colSpan, isPinned, headerIndex, rightOffset, leftOffset, cellKey, align, ...rest }: TableCellProps) => React.JSX.Element>;
|
|
16
17
|
export {};
|
|
@@ -12,8 +12,9 @@ const TableCell = memo(({
|
|
|
12
12
|
rightOffset,
|
|
13
13
|
leftOffset,
|
|
14
14
|
cellKey,
|
|
15
|
+
align,
|
|
15
16
|
...rest
|
|
16
|
-
}) => /* @__PURE__ */ jsx(Td, { $height: height, $width: width, isSorted, role: "cell", colSpan, isPinned, rightOffset, leftOffset, headerIndex, ...rest, children: /* @__PURE__ */ jsx(CellWrapper, { children }) }, cellKey));
|
|
17
|
+
}) => /* @__PURE__ */ jsx(Td, { $height: height, $width: width, $align: align, isSorted, role: "cell", colSpan, isPinned, rightOffset, leftOffset, headerIndex, ...rest, children: /* @__PURE__ */ jsx(CellWrapper, { children }) }, cellKey));
|
|
17
18
|
export {
|
|
18
19
|
TableCell
|
|
19
20
|
};
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
export declare const CellWrapper: import('styled-components').StyledComponent<"div", any, {
|
|
1
|
+
export declare const CellWrapper: import('styled-components').StyledComponent<"div", any, {
|
|
2
|
+
$align?: "left" | "center" | "right";
|
|
3
|
+
}, never>;
|
|
2
4
|
export declare const Td: import('styled-components').StyledComponent<"td", any, {
|
|
3
5
|
$height?: number;
|
|
4
6
|
$width?: number;
|
|
7
|
+
$align?: "left" | "center" | "right";
|
|
5
8
|
isSorted?: boolean;
|
|
6
9
|
headerIndex?: number;
|
|
7
10
|
isPinned?: "left" | "right" | false;
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import styled from "styled-components";
|
|
2
2
|
import { commonCellStyles, commonPinnedStyles } from "../../../Table.styles.js";
|
|
3
|
+
const justifyMap = {
|
|
4
|
+
left: "flex-start",
|
|
5
|
+
center: "center",
|
|
6
|
+
right: "flex-end"
|
|
7
|
+
};
|
|
3
8
|
const CellWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
4
9
|
displayName: "TableCellstyles__CellWrapper",
|
|
5
10
|
componentId: "sc-1sq3dd7-0"
|
|
@@ -7,11 +12,11 @@ const CellWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
|
7
12
|
const Td = /* @__PURE__ */ styled.td.withConfig({
|
|
8
13
|
displayName: "TableCellstyles__Td",
|
|
9
14
|
componentId: "sc-1sq3dd7-1"
|
|
10
|
-
})(["", " ", "
|
|
15
|
+
})(["", " ", " text-align:", ";&&&&{", ";}", ";", ";", "{display:flex;align-items:center;justify-content:", ";width:100%;}"], commonCellStyles, commonPinnedStyles, (props) => props.$align ?? "left", (props) => props.isSorted && `background-color: ${props.theme.palette["blue-050"]}`, (props) => props.headerIndex !== void 0 ? `width: var(--col-${props.headerIndex}-width)` : props.$width && `width: ${props.$width}px`, (props) => props.$height ? `
|
|
11
16
|
padding: 0 24px;
|
|
12
17
|
height: ${props.$height}px` : `
|
|
13
18
|
padding: 16px 24px;
|
|
14
|
-
`, CellWrapper);
|
|
19
|
+
`, CellWrapper, (props) => props.$align ? justifyMap[props.$align] : "flex-start");
|
|
15
20
|
export {
|
|
16
21
|
CellWrapper,
|
|
17
22
|
Td
|
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { TableRowProps } from '../../../Table.types';
|
|
3
|
-
declare const
|
|
4
|
-
export declare const TableRow: typeof TableRowInner;
|
|
5
|
-
export {};
|
|
3
|
+
export declare const TableRow: <TData extends object>({ row, onRowClick, getRowTooltipProps, }: TableRowProps<TData>) => React.JSX.Element;
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { memo } from "react";
|
|
3
2
|
import Tooltip from "@synerise/ds-tooltip";
|
|
4
3
|
import { flexRender } from "@tanstack/react-table";
|
|
5
4
|
import { isSorted } from "../../../utils/sort.js";
|
|
6
5
|
import { TableCell } from "../TableCell/TableCell.js";
|
|
7
6
|
import { Tr } from "./TableRow.styles.js";
|
|
8
|
-
const
|
|
7
|
+
const TableRow = ({
|
|
9
8
|
row,
|
|
10
9
|
onRowClick,
|
|
11
10
|
getRowTooltipProps
|
|
12
11
|
}) => {
|
|
13
|
-
const rowContent = /* @__PURE__ */ jsx(Tr, { "data-row-depth": row.depth, "data-row-index": row.index, "data-index": row.index, role: "row", onClick: onRowClick ? (event) => {
|
|
12
|
+
const rowContent = /* @__PURE__ */ jsx(Tr, { "data-key": row.id, "data-row-depth": row.depth, "data-row-index": row.index, "data-index": row.index, role: "row", onClick: onRowClick ? (event) => {
|
|
14
13
|
event.stopPropagation();
|
|
15
14
|
onRowClick && onRowClick(row.original, event);
|
|
16
15
|
} : void 0, children: row.getVisibleCells().map((cell, columnIndex) => {
|
|
@@ -18,12 +17,11 @@ const TableRowInner = ({
|
|
|
18
17
|
const isColumnSorted = isSorted(cell.column);
|
|
19
18
|
const cellContent = flexRender(cell.column.columnDef.cell, cell.getContext());
|
|
20
19
|
const cellTooltipProps = cell.column.columnDef.meta?.getCellTooltipProps?.(row.original);
|
|
21
|
-
return /* @__PURE__ */ jsx(TableCell, { isSorted: isColumnSorted, headerIndex: columnIndex, cellKey: cellId, width: cell.column.getSize(), isPinned: cell.column.getIsPinned(), rightOffset: cell.column.getAfter("right"), leftOffset: cell.column.getStart("left"), style: cell.column.columnDef.meta?.style, "data-cell-id": cellId, "data-column-dataindex": cell.column.columnDef.meta?.dataIndex, "data-column-title": cell.column.columnDef.meta?.title, children: cellTooltipProps ? /* @__PURE__ */ jsx(Tooltip, { ...cellTooltipProps, children: /* @__PURE__ */ jsx("span", { children: cellContent }) }) : cellContent }, cellId);
|
|
20
|
+
return /* @__PURE__ */ jsx(TableCell, { isSorted: isColumnSorted, headerIndex: columnIndex, cellKey: cellId, width: cell.column.getSize(), isPinned: cell.column.getIsPinned(), rightOffset: cell.column.getAfter("right"), leftOffset: cell.column.getStart("left"), align: cell.column.columnDef.meta?.align, style: cell.column.columnDef.meta?.style, "data-cell-id": cellId, "data-column-dataindex": cell.column.columnDef.meta?.dataIndex, "data-column-title": cell.column.columnDef.meta?.title, children: cellTooltipProps ? /* @__PURE__ */ jsx(Tooltip, { ...cellTooltipProps, children: /* @__PURE__ */ jsx("span", { children: cellContent }) }) : cellContent }, cellId);
|
|
22
21
|
}) }, row.id);
|
|
23
22
|
const rowTooltipProps = getRowTooltipProps?.(row.original);
|
|
24
23
|
return rowTooltipProps ? /* @__PURE__ */ jsx(Tooltip, { ...rowTooltipProps, children: rowContent }) : rowContent;
|
|
25
24
|
};
|
|
26
|
-
const TableRow = memo(TableRowInner);
|
|
27
25
|
export {
|
|
28
26
|
TableRow
|
|
29
27
|
};
|
|
@@ -58,9 +58,10 @@ const TableRowVirtualInner = ({
|
|
|
58
58
|
return tableRow.getVisibleCells().map((cell, columnIndex) => {
|
|
59
59
|
const colId = cell.column.id;
|
|
60
60
|
const isColumnSorted = isSorted(cell.column);
|
|
61
|
-
const
|
|
61
|
+
const cellRenderer = isChild ? cell.column.columnDef.meta?.childCell ?? cell.column.columnDef.cell : cell.column.columnDef.cell;
|
|
62
|
+
const cellContent = flexRender(cellRenderer, cell.getContext());
|
|
62
63
|
const cellTooltipProps = cell.column.columnDef.meta?.getCellTooltipProps?.(tableRow.original);
|
|
63
|
-
return /* @__PURE__ */ jsx(TableCell, { isSorted: isColumnSorted, headerIndex: columnIndex, "data-column-key": colId, width: cell.column.getSize(), height: cellHeight, isPinned: cell.column.getIsPinned(), rightOffset: cell.column.getAfter("right"), leftOffset: cell.column.getStart("left"), style: cell.column.columnDef.meta?.style, "data-column-dataindex": cell.column.columnDef.meta?.dataIndex, "data-column-title": cell.column.columnDef.meta?.title, children: cellTooltipProps ? /* @__PURE__ */ jsx(Tooltip, { ...cellTooltipProps, children: /* @__PURE__ */ jsx("span", { children: cellContent }) }) : cellContent }, colId);
|
|
64
|
+
return /* @__PURE__ */ jsx(TableCell, { isSorted: isColumnSorted, headerIndex: columnIndex, "data-column-key": colId, width: cell.column.getSize(), height: cellHeight, isPinned: cell.column.getIsPinned(), rightOffset: cell.column.getAfter("right"), leftOffset: cell.column.getStart("left"), align: cell.column.columnDef.meta?.align, style: cell.column.columnDef.meta?.style, "data-column-dataindex": cell.column.columnDef.meta?.dataIndex, "data-column-title": cell.column.columnDef.meta?.title, children: cellTooltipProps ? /* @__PURE__ */ jsx(Tooltip, { ...cellTooltipProps, children: /* @__PURE__ */ jsx("span", { children: cellContent }) }) : cellContent }, colId);
|
|
64
65
|
});
|
|
65
66
|
}, [cellHeight, isChild]);
|
|
66
67
|
const rowTooltipProps = getRowTooltipProps?.(row.original);
|
|
@@ -20,7 +20,8 @@ const TableRowSelection = ({
|
|
|
20
20
|
} = selection || {};
|
|
21
21
|
const isGlobalAllSelected = globalSelectionOnChange !== void 0 && globalSelected;
|
|
22
22
|
const isSelected = row.getIsSelected();
|
|
23
|
-
const
|
|
23
|
+
const totalSelectedCount = Object.keys(table.getState().rowSelection).length;
|
|
24
|
+
const isDisabled = !row.getCanSelect() || isGlobalAllSelected || limit && totalSelectedCount >= limit && !isSelected;
|
|
24
25
|
const toggleSelection = row.getToggleSelectedHandler();
|
|
25
26
|
const handleChange = (newValue) => {
|
|
26
27
|
stickyContext && stickyContext.setStickyData((prevValue) => ({
|
|
@@ -17,7 +17,8 @@ const TableColumns = ({
|
|
|
17
17
|
const isSticky = header.column.getIsPinned();
|
|
18
18
|
const hasSorter = header.column.getCanSort();
|
|
19
19
|
const isColumnSorted = isSorted(header.column);
|
|
20
|
-
|
|
20
|
+
const align = header.column.columnDef.meta?.align;
|
|
21
|
+
return /* @__PURE__ */ jsx(Th, { headerIndex: columnIndex, colSpan: header.colSpan, style: header.column.columnDef.meta?.style, isPinned: header.column.getIsPinned(), rightOffset: header.column.getStart("left"), leftOffset: header.column.getAfter("right"), isSorted: isColumnSorted, hasSorter, $align: align, "data-sticky": isSticky ? "true" : void 0, role: "columnheader", children: /* @__PURE__ */ jsxs(HeaderWrapper, { $align: align, children: [
|
|
21
22
|
/* @__PURE__ */ jsx(Label, { disableColumnNamesLineBreak, children: header.isPlaceholder ? null : flexRender(header.column.columnDef.header, header.getContext()) }),
|
|
22
23
|
hasSorter && (header.column.columnDef.meta?.renderCustomSortButton?.(header.getContext()) || /* @__PURE__ */ jsx(TableColumnSorter, { texts, column: header.column }))
|
|
23
24
|
] }) }, id);
|
|
@@ -5,10 +5,13 @@ export declare const Th: import('styled-components').StyledComponent<"th", any,
|
|
|
5
5
|
isPinned?: "left" | "right" | false;
|
|
6
6
|
rightOffset?: number;
|
|
7
7
|
leftOffset?: number;
|
|
8
|
+
$align?: "left" | "center" | "right";
|
|
8
9
|
}, never>;
|
|
9
10
|
export declare const THead: import('styled-components').StyledComponent<"thead", any, {}, never>;
|
|
10
11
|
export declare const Tr: import('styled-components').StyledComponent<"tr", any, {}, never>;
|
|
11
|
-
export declare const HeaderWrapper: import('styled-components').StyledComponent<"div", any, {
|
|
12
|
+
export declare const HeaderWrapper: import('styled-components').StyledComponent<"div", any, {
|
|
13
|
+
$align?: "left" | "center" | "right";
|
|
14
|
+
}, never>;
|
|
12
15
|
export declare const Label: import('styled-components').StyledComponent<"div", any, {
|
|
13
16
|
disableColumnNamesLineBreak?: boolean;
|
|
14
17
|
}, never>;
|
|
@@ -4,7 +4,7 @@ import { ToggleButton } from "./TableColumnSorter/TableColumnSorter.styles.js";
|
|
|
4
4
|
const Th = /* @__PURE__ */ styled.th.withConfig({
|
|
5
5
|
displayName: "TableColumnsstyles__Th",
|
|
6
6
|
componentId: "sc-k8z5d0-0"
|
|
7
|
-
})(["", ";", ";height:64px;text-align:
|
|
7
|
+
})(["", ";", ";height:64px;text-align:", ";background-color:", ";border-bottom:solid 1px ", ";color:", ";", ";", " &{", "}"], commonCellStyles, commonPinnedStyles, (props) => props.$align ?? "left", (props) => props.theme.palette["white"], (props) => props.theme.palette["grey-300"], (props) => props.theme.palette["grey-700"], (props) => props.headerIndex !== void 0 && `width: var(--col-${props.headerIndex}-width)`, (props) => props.hasSorter && css(["", "{opacity:0;}&:hover{background-color:", ";border-bottom:solid 1px ", ";box-shadow:inset 0 -1px 0 ", ";", "{opacity:1;}}"], ToggleButton, props.theme.palette["grey-050"], props.theme.palette["grey-400"], props.theme.palette["grey-400"], ToggleButton), (props) => props.isSorted && css(["&{", "{opacity:1;}background-color:", ";border-bottom:solid 1px ", ";box-shadow:inset 0 -1px 0 ", ";}&:hover{background-color:", ";border-bottom:solid 1px ", ";box-shadow:inset 0 -1px 0 ", ";}"], ToggleButton, props.theme.palette["blue-050"], props.theme.palette["blue-400"], props.theme.palette["blue-400"], props.theme.palette["blue-100"], props.theme.palette["blue-600"], props.theme.palette["blue-600"]));
|
|
8
8
|
const THead = /* @__PURE__ */ styled.thead.withConfig({
|
|
9
9
|
displayName: "TableColumnsstyles__THead",
|
|
10
10
|
componentId: "sc-k8z5d0-1"
|
|
@@ -13,10 +13,15 @@ const Tr = /* @__PURE__ */ styled.tr.withConfig({
|
|
|
13
13
|
displayName: "TableColumnsstyles__Tr",
|
|
14
14
|
componentId: "sc-k8z5d0-2"
|
|
15
15
|
})(["", ""], commonRowStyles);
|
|
16
|
+
const justifyMap = {
|
|
17
|
+
left: "flex-start",
|
|
18
|
+
center: "center",
|
|
19
|
+
right: "flex-end"
|
|
20
|
+
};
|
|
16
21
|
const HeaderWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
17
22
|
displayName: "TableColumnsstyles__HeaderWrapper",
|
|
18
23
|
componentId: "sc-k8z5d0-3"
|
|
19
|
-
})(["display:flex;align-items:center;justify-content:
|
|
24
|
+
})(["display:flex;align-items:center;justify-content:", ";font-weight:500;"], (props) => props.$align ? justifyMap[props.$align] : "space-between");
|
|
20
25
|
const Label = /* @__PURE__ */ styled.div.withConfig({
|
|
21
26
|
displayName: "TableColumnsstyles__Label",
|
|
22
27
|
componentId: "sc-k8z5d0-4"
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { TableHeaderProps } from '../../Table.types';
|
|
3
|
-
export declare const TableHeader: <TData extends object, TValue>({ title, searchComponent, filterComponent, itemsMenu, isCounterLoading, headerButton, texts, renderSelectionTitle, renderCustomCounter, hideTitlePart, dataSourceTotalCount, isLoading, }: TableHeaderProps<TData, TValue>) => React.JSX.Element;
|
|
3
|
+
export declare const TableHeader: <TData extends object, TValue>({ title, searchComponent, filterComponent, itemsMenu, isCounterLoading, headerButton, texts, renderSelectionTitle, renderCustomCounter, hideTitlePart, dataSourceTotalCount, isLoading, searchQuery, setSearchQuery, handleSearchClear, hasBuiltInSearch, searchProps, }: TableHeaderProps<TData, TValue>) => React.JSX.Element;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useRef, useEffect, useMemo } from "react";
|
|
3
3
|
import { useDataFormat } from "@synerise/ds-core";
|
|
4
|
+
import { SearchInput } from "@synerise/ds-search";
|
|
4
5
|
import { BOTTOM_BORDER_WIDTH } from "../../Table.const.js";
|
|
5
6
|
import { TableSkeleton } from "../../Table.styles.js";
|
|
6
7
|
import { useSelectionContext } from "../../contexts/SelectionContext.js";
|
|
7
8
|
import { useStickyContext } from "../../contexts/StickyContext.js";
|
|
8
9
|
import { useTableContext } from "../../contexts/TableContext.js";
|
|
10
|
+
import { ItemsMenu } from "../ItemsMenu/ItemsMenu.js";
|
|
9
11
|
import { TableCounter } from "./TableCounter/TableCounter.js";
|
|
10
12
|
import { Left, TitleContainer, TitlePartEllipsis, TitleSeparator, TitlePart, Header, Right, RightSideWrapper } from "./TableHeader.styles.js";
|
|
11
13
|
import { TableHeaderSelection } from "./TableHeaderSelection/TableHeaderSelection.js";
|
|
@@ -23,7 +25,12 @@ const TableHeader = ({
|
|
|
23
25
|
renderCustomCounter,
|
|
24
26
|
hideTitlePart,
|
|
25
27
|
dataSourceTotalCount,
|
|
26
|
-
isLoading
|
|
28
|
+
isLoading,
|
|
29
|
+
searchQuery,
|
|
30
|
+
setSearchQuery,
|
|
31
|
+
handleSearchClear,
|
|
32
|
+
hasBuiltInSearch,
|
|
33
|
+
searchProps
|
|
27
34
|
}) => {
|
|
28
35
|
const {
|
|
29
36
|
formatValue
|
|
@@ -48,8 +55,9 @@ const TableHeader = ({
|
|
|
48
55
|
}));
|
|
49
56
|
}
|
|
50
57
|
}, []);
|
|
51
|
-
const selectedItemsCount = table.
|
|
52
|
-
const
|
|
58
|
+
const selectedItemsCount = Object.keys(table.getState().rowSelection).length;
|
|
59
|
+
const visibleRowCount = table.getRowCount();
|
|
60
|
+
const tableTotal = dataSourceTotalCount ?? visibleRowCount;
|
|
53
61
|
const displayedSelectedItems = isGlobalSelected ? tableTotal : selectedItemsCount;
|
|
54
62
|
const hasSelectedItems = useMemo(() => selectedItemsCount > 0 || isGlobalSelected, [isGlobalSelected, selectedItemsCount]);
|
|
55
63
|
const renderLeftSide = useMemo(() => {
|
|
@@ -68,7 +76,7 @@ const TableHeader = ({
|
|
|
68
76
|
return hasSelectedItems ? /* @__PURE__ */ jsxs(Left, { "data-testid": "ds-table-selection", children: [
|
|
69
77
|
selectionConfig && !hideSelectAll && /* @__PURE__ */ jsx(TableHeaderSelection, { texts }),
|
|
70
78
|
renderSelectionTitle ? /* @__PURE__ */ jsx(Fragment, { children: renderSelectionTitle(selectionConfig) }) : /* @__PURE__ */ jsx(TitleContainer, { children: /* @__PURE__ */ jsx(TableCounter, { selectedItemsCount: displayedSelectedItems, texts, isCounterLoading, tableTotal }) }),
|
|
71
|
-
itemsMenu
|
|
79
|
+
itemsMenu && /* @__PURE__ */ jsx(ItemsMenu, { children: itemsMenu })
|
|
72
80
|
] }) : /* @__PURE__ */ jsxs(Left, { "data-testid": "ds-table-title", children: [
|
|
73
81
|
selectionConfig && !isLoading && !hideSelectAll && /* @__PURE__ */ jsx(TableHeaderSelection, { texts }),
|
|
74
82
|
/* @__PURE__ */ jsxs(TitleContainer, { children: [
|
|
@@ -88,13 +96,13 @@ const TableHeader = ({
|
|
|
88
96
|
!isLoading && !hideTitlePart && /* @__PURE__ */ jsx(TitlePart, { children: /* @__PURE__ */ jsx(TableCounter, { texts, isCounterLoading, tableTotal, renderCustomCounter }) })
|
|
89
97
|
] })
|
|
90
98
|
] });
|
|
91
|
-
}, [selectionConfig, formatValue, texts, hasSelectedItems, renderSelectionTitle, isCounterLoading, selectedItemsCount, itemsMenu, isLoading, title, hideTitlePart, renderCustomCounter, tableTotal]);
|
|
99
|
+
}, [selectionConfig, formatValue, texts, hasSelectedItems, renderSelectionTitle, isCounterLoading, selectedItemsCount, itemsMenu, isLoading, title, hideTitlePart, renderCustomCounter, tableTotal, visibleRowCount, dataSourceTotalCount, displayedSelectedItems]);
|
|
92
100
|
return /* @__PURE__ */ jsxs(Header, { ref: headerRef, stickyData: stickyContext?.stickyData, "data-testid": "ds-table-header", isVirtual: !!rowVirtualizer, children: [
|
|
93
101
|
renderLeftSide,
|
|
94
102
|
/* @__PURE__ */ jsxs(Right, { children: [
|
|
95
103
|
headerButton,
|
|
96
104
|
filterComponent && /* @__PURE__ */ jsx(RightSideWrapper, { "data-testid": "ds-table-filter-wrapper", children: filterComponent }),
|
|
97
|
-
searchComponent
|
|
105
|
+
searchComponent ? /* @__PURE__ */ jsx(RightSideWrapper, { "data-testid": "ds-table-search-wrapper", children: searchComponent }) : hasBuiltInSearch && setSearchQuery && handleSearchClear ? /* @__PURE__ */ jsx(RightSideWrapper, { "data-testid": "ds-table-search-wrapper", children: /* @__PURE__ */ jsx(SearchInput, { placeholder: searchProps?.placeholder ?? "", clearTooltip: searchProps?.clearTooltip ?? "", onChange: setSearchQuery, value: searchQuery ?? "", onClear: handleSearchClear, closeOnClickOutside: true, ...searchProps }) }) : null
|
|
98
106
|
] })
|
|
99
107
|
] });
|
|
100
108
|
};
|
|
@@ -2,7 +2,6 @@ import { jsxs, jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { useMemo, useCallback } from "react";
|
|
3
3
|
import { DropdownMenu } from "@synerise/ds-dropdown";
|
|
4
4
|
import Icon, { OptionVerticalM } from "@synerise/ds-icon";
|
|
5
|
-
import Tooltip from "@synerise/ds-tooltip";
|
|
6
5
|
import { SELECTION_INVERT, SELECTION_ALL } from "../../../Table.const.js";
|
|
7
6
|
import { useSelectionContext } from "../../../contexts/SelectionContext.js";
|
|
8
7
|
import { useTableContext } from "../../../contexts/TableContext.js";
|
|
@@ -21,23 +20,44 @@ const TableHeaderSelection = ({
|
|
|
21
20
|
} = selectionConfig || {};
|
|
22
21
|
const hasGlobalSelection = globalSelectionOnChange !== void 0;
|
|
23
22
|
const isGlobalAllSelected = hasGlobalSelection && globalSelected;
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
const
|
|
23
|
+
const totalSelectedCount = Object.keys(table.getState().rowSelection).length;
|
|
24
|
+
const visibleRowCount = table.getRowModel().rows.length;
|
|
25
|
+
const visibleSelectedCount = table.getFilteredSelectedRowModel().rows.length;
|
|
26
|
+
const isAllVisibleSelected = visibleRowCount > 0 && visibleSelectedCount === visibleRowCount;
|
|
27
|
+
const isAnySelected = visibleSelectedCount > 0 && !isAllVisibleSelected;
|
|
28
|
+
const allRecordsCount = visibleRowCount;
|
|
29
|
+
const selectedRecordsCount = totalSelectedCount;
|
|
28
30
|
const selectableRecordsCount = table.getRowModel().rows.filter((row) => row.getCanSelect()).length;
|
|
29
31
|
const disabledBulkSelection = Boolean(allRecordsCount === 0 || selectableRecordsCount === 0 || hasSelectionLimit && selectedRecordsCount === 0);
|
|
30
32
|
const selectionTooltipTitle = useMemo(() => {
|
|
31
33
|
if (hasGlobalSelection) {
|
|
32
34
|
return isGlobalAllSelected ? texts.unselectGlobalAll : texts.selectGlobalAll;
|
|
33
35
|
}
|
|
34
|
-
return
|
|
35
|
-
}, [hasGlobalSelection,
|
|
36
|
+
return isAllVisibleSelected ? texts.unselectAll : texts.selectAllTooltip;
|
|
37
|
+
}, [hasGlobalSelection, isAllVisibleSelected, isGlobalAllSelected, texts.selectAllTooltip, texts.selectGlobalAll, texts.unselectAll, texts.unselectGlobalAll]);
|
|
36
38
|
const selectAll = useCallback(() => {
|
|
37
|
-
table.
|
|
39
|
+
table.setRowSelection((prev) => {
|
|
40
|
+
const next = {
|
|
41
|
+
...prev
|
|
42
|
+
};
|
|
43
|
+
table.getRowModel().rows.forEach((row) => {
|
|
44
|
+
if (row.getCanSelect()) {
|
|
45
|
+
next[row.id] = true;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
return next;
|
|
49
|
+
});
|
|
38
50
|
}, [table]);
|
|
39
51
|
const unselectAll = useCallback(() => {
|
|
40
|
-
table.
|
|
52
|
+
table.setRowSelection((prev) => {
|
|
53
|
+
const next = {
|
|
54
|
+
...prev
|
|
55
|
+
};
|
|
56
|
+
table.getRowModel().rows.forEach((row) => {
|
|
57
|
+
delete next[row.id];
|
|
58
|
+
});
|
|
59
|
+
return next;
|
|
60
|
+
});
|
|
41
61
|
}, [table]);
|
|
42
62
|
const selectGlobalAll = useCallback(() => {
|
|
43
63
|
unselectAll();
|
|
@@ -70,7 +90,7 @@ const TableHeaderSelection = ({
|
|
|
70
90
|
switch (selectionMenuElement) {
|
|
71
91
|
case SELECTION_ALL: {
|
|
72
92
|
const items = [];
|
|
73
|
-
if (!
|
|
93
|
+
if (!isAllVisibleSelected && !hasSelectionLimit) {
|
|
74
94
|
items.push({
|
|
75
95
|
onClick: selectAll,
|
|
76
96
|
text: texts.selectAll
|
|
@@ -100,17 +120,18 @@ const TableHeaderSelection = ({
|
|
|
100
120
|
}
|
|
101
121
|
});
|
|
102
122
|
return [...globalSelectionItem, ...menuItems || []];
|
|
103
|
-
}, [hasGlobalSelection, isGlobalAllSelected, unselectGlobalAll, texts.unselectGlobalAll, texts.selectGlobalAll, texts.selectAll, texts.unselectAll, texts.selectInvert, selectGlobalAll, selectionConfig?.selections,
|
|
123
|
+
}, [hasGlobalSelection, isGlobalAllSelected, unselectGlobalAll, texts.unselectGlobalAll, texts.selectGlobalAll, texts.selectAll, texts.unselectAll, texts.selectInvert, selectGlobalAll, selectionConfig?.selections, isAllVisibleSelected, hasSelectionLimit, isAnySelected, selectAll, unselectAll, selectInvert]);
|
|
104
124
|
const handleBatchSelectionChange = useCallback(() => {
|
|
105
|
-
const isSelected = hasGlobalSelection ? isGlobalAllSelected : table.getIsAllRowsSelected();
|
|
106
125
|
if (hasGlobalSelection) {
|
|
107
|
-
|
|
126
|
+
isGlobalAllSelected ? unselectGlobalAll() : selectGlobalAll();
|
|
108
127
|
} else {
|
|
109
|
-
|
|
128
|
+
isAllVisibleSelected ? unselectAll() : selectAll();
|
|
110
129
|
}
|
|
111
|
-
}, [hasGlobalSelection, isGlobalAllSelected, selectGlobalAll,
|
|
130
|
+
}, [hasGlobalSelection, isAllVisibleSelected, isGlobalAllSelected, selectAll, selectGlobalAll, unselectAll, unselectGlobalAll]);
|
|
112
131
|
return selectionConfig ? /* @__PURE__ */ jsxs(Selection, { "data-popup-container": true, children: [
|
|
113
|
-
!hasSelectionLimit && /* @__PURE__ */ jsx(
|
|
132
|
+
!hasSelectionLimit && /* @__PURE__ */ jsx(SelectionCheckbox, { isOrphan: !selectionConfig.selections, disabled: disabledBulkSelection, "data-testid": "ds-table-batch-selection-button", tooltipProps: {
|
|
133
|
+
title: selectionTooltipTitle
|
|
134
|
+
}, checked: hasGlobalSelection ? isGlobalAllSelected : isAllVisibleSelected, indeterminate: isAnySelected, onChange: handleBatchSelectionChange }),
|
|
114
135
|
selectionConfig.selections && /* @__PURE__ */ jsx(DropdownMenu, { disabled: disabledBulkSelection || dropdownDataSource?.length === 0, getPopupContainer: () => document.body, dataSource: dropdownDataSource || [], popoverProps: {
|
|
115
136
|
testId: "table-selection"
|
|
116
137
|
}, asChild: true, children: /* @__PURE__ */ jsx(DropdownButton, { isOrphan: !!hasSelectionLimit, disabled: disabledBulkSelection || dropdownDataSource?.length === 0, mode: "single-icon", type: "ghost", "data-testid": "ds-table-batch-selection-options", tooltipProps: {
|
|
@@ -4,7 +4,8 @@ import { useDataFormat } from "@synerise/ds-core";
|
|
|
4
4
|
import InlineAlert from "@synerise/ds-inline-alert";
|
|
5
5
|
import { TableSkeleton } from "../../../Table.styles.js";
|
|
6
6
|
import { useTableContext } from "../../../contexts/TableContext.js";
|
|
7
|
-
import {
|
|
7
|
+
import { ItemsMenu } from "../../ItemsMenu/ItemsMenu.js";
|
|
8
|
+
import { Alert, Title, TableLimit as TableLimit$1 } from "./TableLimit.styles.js";
|
|
8
9
|
function TableLimit({
|
|
9
10
|
texts,
|
|
10
11
|
itemsMenu,
|
|
@@ -21,7 +22,7 @@ function TableLimit({
|
|
|
21
22
|
const {
|
|
22
23
|
limit
|
|
23
24
|
} = selection;
|
|
24
|
-
const selectedRows = table.
|
|
25
|
+
const selectedRows = Object.keys(table.getState().rowSelection).length;
|
|
25
26
|
const total = table.getRowCount();
|
|
26
27
|
const limitReachedInfo = useMemo(() => limit <= selectedRows && /* @__PURE__ */ jsx(Alert, { children: /* @__PURE__ */ jsx(InlineAlert, { type: "warning", message: texts.selectionLimitWarning }) }), [texts, selectedRows, limit]);
|
|
27
28
|
const selected = useMemo(() => {
|
|
@@ -42,7 +43,7 @@ function TableLimit({
|
|
|
42
43
|
return /* @__PURE__ */ jsxs(TableLimit$1, { children: [
|
|
43
44
|
selected,
|
|
44
45
|
limitReachedInfo,
|
|
45
|
-
selectedRows > 0 && /* @__PURE__ */ jsx(ItemsMenu, { children: itemsMenu })
|
|
46
|
+
selectedRows > 0 && /* @__PURE__ */ jsx(ItemsMenu, { withLeftPadding: true, children: itemsMenu })
|
|
46
47
|
] });
|
|
47
48
|
}
|
|
48
49
|
export {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
export declare const TableLimit: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
2
2
|
export declare const Title: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
3
3
|
export declare const Alert: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
4
|
-
export declare const ItemsMenu: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
@@ -12,13 +12,8 @@ const Alert = /* @__PURE__ */ styled.div.withConfig({
|
|
|
12
12
|
displayName: "TableLimitstyles__Alert",
|
|
13
13
|
componentId: "sc-16p1ck3-2"
|
|
14
14
|
})(["position:relative;padding-left:16px;margin-left:16px;&::before{position:absolute;top:4px;left:0;content:'';display:flex;width:1px;height:16px;background:", ";}"], (props) => props.theme.palette["grey-200"]);
|
|
15
|
-
const ItemsMenu = /* @__PURE__ */ styled.div.withConfig({
|
|
16
|
-
displayName: "TableLimitstyles__ItemsMenu",
|
|
17
|
-
componentId: "sc-16p1ck3-3"
|
|
18
|
-
})(["padding-left:24px;"]);
|
|
19
15
|
export {
|
|
20
16
|
Alert,
|
|
21
|
-
ItemsMenu,
|
|
22
17
|
TableLimit,
|
|
23
18
|
Title
|
|
24
19
|
};
|