@ackplus/react-tanstack-data-table 1.0.33 → 1.0.34

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ackplus/react-tanstack-data-table",
3
3
  "type": "commonjs",
4
- "version": "1.0.33",
4
+ "version": "1.0.34",
5
5
  "description": "A powerful React data table component built with MUI and TanStack Table",
6
6
  "keywords": [
7
7
  "react",
@@ -185,8 +185,15 @@ function DraggableHeader(props) {
185
185
  };
186
186
  const mergedContainerProps = (0, slot_helpers_1.mergeSlotProps)({
187
187
  ref: headerElementRef,
188
- sx: Object.assign({ display: 'flex', alignItems: 'center', justifyContent: justifyContent, gap: 1, cursor: getCursor(), userSelect: 'none', opacity: isDragging ? 0.5 : 1, backgroundColor: dragOver ? 'rgba(25, 118, 210, 0.08)' : 'transparent', borderLeft: dragOver ? '2px solid #1976d2' : 'none', padding: dragOver ? '0 0 0 -2px' : '0', width: '100%', height: '100%', '&:active': {
188
+ sx: Object.assign({ display: 'flex', alignItems: 'center', justifyContent: justifyContent, gap: 1, cursor: getCursor(), userSelect: 'none', opacity: isDragging ? 0.5 : 1, backgroundColor: dragOver ? 'rgba(25, 118, 210, 0.08)' : 'transparent', borderLeft: dragOver ? '2px solid #1976d2' : 'none', padding: dragOver ? '0 0 0 -2px' : '0', width: '100%', height: '100%', minWidth: '0', '&:active': {
189
189
  cursor: draggable ? 'grabbing' : 'pointer',
190
+ }, '.header-content': {
191
+ display: 'block',
192
+ flex: 1,
193
+ minWidth: 0,
194
+ overflow: 'hidden',
195
+ whiteSpace: 'nowrap',
196
+ textOverflow: 'ellipsis',
190
197
  } }, containerSx),
191
198
  draggable: draggable,
192
199
  onDragStart: handleDragStart,
@@ -200,9 +207,9 @@ function DraggableHeader(props) {
200
207
  if (!draggable && !enableSorting) {
201
208
  return (0, react_table_1.flexRender)(header.column.columnDef.header, header.getContext());
202
209
  }
203
- return ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({}, mergedContainerProps, { children: (0, jsx_runtime_1.jsxs)(material_1.Box, { component: "span", sx: {
210
+ return ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({}, mergedContainerProps, { children: (0, jsx_runtime_1.jsxs)(material_1.Box, { component: "span", className: 'header-wrapper', sx: {
204
211
  display: 'inline-flex',
205
212
  gap: 1,
206
- }, children: [(0, react_table_1.flexRender)(header.column.columnDef.header, header.getContext()), getSortIcon()] }) })));
213
+ }, children: [(0, jsx_runtime_1.jsx)(material_1.Box, { component: "span", className: 'header-content', children: (0, react_table_1.flexRender)(header.column.columnDef.header, header.getContext()) }), getSortIcon()] }) })));
207
214
  }
208
215
  exports.DraggableHeaderMemo = react_1.default.memo(DraggableHeader);
@@ -14,4 +14,3 @@ export interface TableHeaderProps extends TableHeadProps {
14
14
  [key: string]: any;
15
15
  }
16
16
  export declare function TableHeader<T>(props: TableHeaderProps): import("react/jsx-runtime").JSX.Element;
17
- export declare const TableHeaderMemo: typeof TableHeader;
@@ -1,10 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TableHeaderMemo = void 0;
4
3
  exports.TableHeader = TableHeader;
5
4
  const tslib_1 = require("tslib");
6
5
  const jsx_runtime_1 = require("react/jsx-runtime");
7
- const react_1 = tslib_1.__importStar(require("react"));
8
6
  const material_1 = require("@mui/material");
9
7
  const draggable_header_1 = require("./draggable-header");
10
8
  const data_table_context_1 = require("../../contexts/data-table-context");
@@ -24,21 +22,18 @@ function TableHeader(props) {
24
22
  sx: containerSx,
25
23
  }, headerSlotProps, otherProps);
26
24
  const mergedHeaderRowProps = (0, slot_helpers_1.mergeSlotProps)({}, headerRowSlotProps, headerRowProps || {});
27
- const renderHeaderCell = (0, react_1.useCallback)((header) => {
25
+ const renderHeaderCell = (header) => {
26
+ var _a;
28
27
  const isPinned = header.column.getIsPinned();
29
28
  const pinnedPosition = isPinned ? header.column.getStart('left') : undefined;
30
29
  const pinnedRightPosition = isPinned === 'right' ? header.column.getAfter('right') : undefined;
31
30
  const alignment = (0, utils_1.getColumnAlignment)(header.column.columnDef);
32
31
  const enableSorting = header.column.getCanSort();
33
- const minSize = header.column.columnDef.minSize;
34
- const maxSize = header.column.columnDef.maxSize;
35
- const columnSize = enableColumnResizing ? header.getSize() : (fitToScreen ? 'auto' : header.getSize());
32
+ const wrapText = (_a = header.column.columnDef.wrapText) !== null && _a !== void 0 ? _a : false;
36
33
  const mergedHeaderCellProps = (0, slot_helpers_1.mergeSlotProps)({
37
34
  align: alignment,
38
35
  sx: Object.assign({}, (0, utils_1.getPinnedColumnStyle)({
39
- width: columnSize,
40
- minWidth: minSize !== undefined ? minSize : undefined,
41
- maxWidth: maxSize !== undefined ? maxSize : undefined,
36
+ width: (fitToScreen && !enableColumnResizing) ? 'auto' : header.getSize(),
42
37
  isPinned,
43
38
  pinnedPosition,
44
39
  isLastLeftPinnedColumn: isPinned === 'left' && header.column.getIsLastColumn('left'),
@@ -46,6 +41,7 @@ function TableHeader(props) {
46
41
  pinnedRightPosition,
47
42
  zIndex: isPinned ? 10 : 1,
48
43
  disableStickyHeader: enableStickyHeader,
44
+ wrapText,
49
45
  })),
50
46
  }, headerCellSlotProps, headerCellProps || {});
51
47
  const mergedResizeHandleProps = (0, slot_helpers_1.mergeSlotProps)({
@@ -56,20 +52,6 @@ function TableHeader(props) {
56
52
  } }, resizeHandleSx),
57
53
  });
58
54
  return ((0, jsx_runtime_1.jsxs)(HeaderCellSlot, Object.assign({}, mergedHeaderCellProps, { children: [(0, jsx_runtime_1.jsx)(draggable_header_1.DraggableHeader, { header: header, enableSorting: enableSorting, draggable: !!(draggable && !isPinned), onColumnReorder: onColumnReorder, slots: slots, slotProps: slotProps, alignment: alignment }), enableColumnResizing && header.column.getCanResize() ? ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({}, mergedResizeHandleProps))) : null] }), header.id));
59
- }, [
60
- fitToScreen,
61
- enableColumnResizing,
62
- enableStickyHeader,
63
- headerCellSlotProps,
64
- headerCellProps,
65
- resizeHandleSx,
66
- theme,
67
- draggable,
68
- onColumnReorder,
69
- slots,
70
- slotProps,
71
- ]);
72
- const headerGroups = (0, react_1.useMemo)(() => table.getHeaderGroups(), [table]);
73
- return ((0, jsx_runtime_1.jsx)(HeaderSlot, Object.assign({}, mergedHeaderProps, { children: headerGroups.map(headerGroup => ((0, jsx_runtime_1.jsx)(HeaderRowSlot, Object.assign({}, mergedHeaderRowProps, { children: headerGroup.headers.map(renderHeaderCell) }), headerGroup.id))) })));
55
+ };
56
+ return ((0, jsx_runtime_1.jsx)(HeaderSlot, Object.assign({}, mergedHeaderProps, { children: table.getHeaderGroups().map(headerGroup => ((0, jsx_runtime_1.jsx)(HeaderRowSlot, Object.assign({}, mergedHeaderRowProps, { children: headerGroup.headers.map(renderHeaderCell) }), headerGroup.id))) })));
74
57
  }
75
- exports.TableHeaderMemo = react_1.default.memo(TableHeader);
@@ -8,6 +8,8 @@ export interface DataTableRowProps<T> extends TableRowProps {
8
8
  isOdd?: boolean;
9
9
  renderSubComponent?: (row: Row<T>) => ReactNode;
10
10
  disableStickyHeader?: boolean;
11
+ onRowClick?: (event: React.MouseEvent<HTMLTableRowElement>, row: Row<T>) => void;
12
+ selectOnRowClick?: boolean;
11
13
  cellProps?: TableCellProps;
12
14
  expandedRowProps?: TableRowProps;
13
15
  expandedCellProps?: TableCellProps;
@@ -7,36 +7,56 @@ const material_1 = require("@mui/material");
7
7
  const react_table_1 = require("@tanstack/react-table");
8
8
  const utils_1 = require("../../utils");
9
9
  const slot_helpers_1 = require("../../utils/slot-helpers");
10
+ const data_table_context_1 = require("../../contexts/data-table-context");
10
11
  function DataTableRow(props) {
11
- const { row, enableHover = true, enableStripes = false, isOdd = false, renderSubComponent, disableStickyHeader = false, cellProps, expandedRowProps, expandedCellProps, containerSx, expandedContainerSx, slots, slotProps } = props, otherProps = tslib_1.__rest(props, ["row", "enableHover", "enableStripes", "isOdd", "renderSubComponent", "disableStickyHeader", "cellProps", "expandedRowProps", "expandedCellProps", "containerSx", "expandedContainerSx", "slots", "slotProps"]);
12
+ var _a;
13
+ const { row, enableHover = true, enableStripes = false, isOdd = false, renderSubComponent, disableStickyHeader = false, onRowClick, selectOnRowClick = false, cellProps, expandedRowProps, expandedCellProps, containerSx, expandedContainerSx, slots, slotProps } = props, otherProps = tslib_1.__rest(props, ["row", "enableHover", "enableStripes", "isOdd", "renderSubComponent", "disableStickyHeader", "onRowClick", "selectOnRowClick", "cellProps", "expandedRowProps", "expandedCellProps", "containerSx", "expandedContainerSx", "slots", "slotProps"]);
14
+ const { table } = (0, data_table_context_1.useDataTableContext)();
12
15
  const cellSlotProps = (0, slot_helpers_1.extractSlotProps)(slotProps, 'cell');
13
16
  const expandedRowSlotProps = (0, slot_helpers_1.extractSlotProps)(slotProps, 'expandedRow');
14
17
  const rowSlotProps = (0, slot_helpers_1.extractSlotProps)(slotProps, 'row');
15
18
  const CellSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'cell', material_1.TableCell);
16
19
  const ExpandedRowSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'expandedRow', material_1.TableRow);
17
20
  const TableRowSlot = (0, slot_helpers_1.getSlotComponent)(slots, 'row', material_1.TableRow);
21
+ const handleRowClick = (event) => {
22
+ const target = event.target;
23
+ const isCheckboxClick = target.closest('input[type="checkbox"]') !== null;
24
+ const isButtonClick = target.closest('button') !== null;
25
+ const isLinkClick = target.closest('a') !== null;
26
+ if (selectOnRowClick && !isCheckboxClick && !isButtonClick && !isLinkClick && (table === null || table === void 0 ? void 0 : table.toggleRowSelected)) {
27
+ table.toggleRowSelected(row.id);
28
+ }
29
+ if (onRowClick) {
30
+ onRowClick(event, row);
31
+ }
32
+ };
18
33
  const mergedRowProps = (0, slot_helpers_1.mergeSlotProps)({
19
34
  hover: enableHover,
20
- sx: (theme) => (Object.assign(Object.assign(Object.assign({ '--row-bg': enableStripes && isOdd
35
+ selected: !!((_a = table === null || table === void 0 ? void 0 : table.getIsRowSelected) === null || _a === void 0 ? void 0 : _a.call(table, row.id)),
36
+ onClick: (onRowClick || selectOnRowClick) ? handleRowClick : undefined,
37
+ sx: (theme) => (Object.assign(Object.assign(Object.assign(Object.assign({ '--row-bg': enableStripes && isOdd
21
38
  ? theme.palette.action.hover
22
39
  : theme.palette.background.paper, backgroundColor: 'var(--row-bg)' }, (enableHover && {
23
40
  '&:hover': { '--row-bg': theme.palette.action.hover },
24
41
  })), { [`&.${material_1.tableRowClasses.selected}`]: {
25
- '--row-bg': (0, material_1.alpha)(theme.palette.primary.dark, 0.08),
42
+ '--row-bg': theme.palette.action.selected,
26
43
  backgroundColor: 'var(--row-bg)',
27
- } }), containerSx)),
44
+ } }), ((onRowClick || selectOnRowClick) && {
45
+ cursor: 'pointer',
46
+ })), containerSx)),
28
47
  }, rowSlotProps, otherProps);
29
48
  const mergedExpandedRowProps = (0, slot_helpers_1.mergeSlotProps)({
30
49
  sx: expandedContainerSx,
31
50
  }, expandedRowSlotProps, expandedRowProps || {});
32
51
  return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(TableRowSlot, Object.assign({}, mergedRowProps, { children: row.getVisibleCells().map(cell => {
33
- var _a;
52
+ var _a, _b;
34
53
  const isPinned = cell.column.getIsPinned();
35
54
  const pinnedPosition = isPinned ? cell.column.getStart('left') : undefined;
36
55
  const pinnedRightPosition = isPinned === 'right' ? cell.column.getAfter('right') : undefined;
37
56
  const alignment = (0, utils_1.getColumnAlignment)(cell.column.columnDef);
38
57
  const minSize = (_a = cell.column.columnDef) === null || _a === void 0 ? void 0 : _a.minSize;
39
58
  const maxSize = cell.column.columnDef.maxSize;
59
+ const wrapText = (_b = cell.column.columnDef.wrapText) !== null && _b !== void 0 ? _b : false;
40
60
  const mergedCellProps = (0, slot_helpers_1.mergeSlotProps)({
41
61
  align: alignment,
42
62
  sx: Object.assign({}, (0, utils_1.getPinnedColumnStyle)({
@@ -50,6 +70,7 @@ function DataTableRow(props) {
50
70
  disableStickyHeader,
51
71
  isLastLeftPinnedColumn: isPinned === 'left' && cell.column.getIsLastColumn('left'),
52
72
  isFirstRightPinnedColumn: isPinned === 'right' && cell.column.getIsFirstColumn('right'),
73
+ wrapText,
53
74
  })),
54
75
  }, cellSlotProps, cellProps || {});
55
76
  return ((0, jsx_runtime_1.jsx)(CellSlot, Object.assign({}, mergedCellProps, { children: (0, react_table_1.flexRender)(cell.column.columnDef.cell, cell.getContext()) }), cell.id));
@@ -41,7 +41,7 @@ const DEFAULT_INITIAL_STATE = {
41
41
  pendingLogic: 'AND',
42
42
  },
43
43
  };
44
- exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, columns, data = [], totalRow = 0, idKey = 'id', extraFilter = null, footerFilter = null, dataMode = 'client', initialLoadData = true, onFetchData, onDataStateChange, enableRowSelection = false, enableMultiRowSelection = true, selectMode = 'page', isRowSelectable, onSelectionChange, enableBulkActions = false, bulkActions, enableColumnResizing = false, columnResizeMode = 'onChange', onColumnSizingChange, enableColumnDragging = false, onColumnDragEnd, enableColumnPinning = false, onColumnPinningChange, onColumnVisibilityChange, enableColumnVisibility = true, enableExpanding = false, getRowCanExpand, renderSubComponent, enablePagination = false, paginationMode = 'client', enableGlobalFilter = true, enableColumnFilter = false, filterMode = 'client', enableSorting = true, sortingMode = 'client', onSortingChange, exportFilename = 'export', onExportProgress, onExportComplete, onExportError, onServerExport, onExportCancel, enableHover = true, enableStripes = false, tableProps = {}, fitToScreen = true, tableSize: initialTableSize = 'medium', enableStickyHeaderOrFooter = false, maxHeight = '400px', enableVirtualization = false, estimateRowHeight = 52, enableTableSizeControl = true, enableExport = false, enableReset = true, loading = false, emptyMessage = 'No data available', skeletonRows = 5, onColumnFiltersChange, onPaginationChange, onGlobalFilterChange, slots = {}, slotProps = {}, logging, }, ref) {
44
+ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, columns, data = [], totalRow = 0, idKey = 'id', extraFilter = null, footerFilter = null, dataMode = 'client', initialLoadData = true, onFetchData, onDataStateChange, enableRowSelection = false, enableMultiRowSelection = true, selectMode = 'page', isRowSelectable, onSelectionChange, onRowClick, selectOnRowClick = false, enableBulkActions = false, bulkActions, enableColumnResizing = false, columnResizeMode = 'onChange', onColumnSizingChange, enableColumnDragging = false, onColumnDragEnd, enableColumnPinning = false, onColumnPinningChange, onColumnVisibilityChange, enableColumnVisibility = true, enableExpanding = false, getRowCanExpand, renderSubComponent, enablePagination = false, paginationMode = 'client', enableGlobalFilter = true, enableColumnFilter = false, filterMode = 'client', enableSorting = true, sortingMode = 'client', onSortingChange, exportFilename = 'export', onExportProgress, onExportComplete, onExportError, onServerExport, onExportCancel, enableHover = true, enableStripes = false, tableProps = {}, fitToScreen = true, tableSize: initialTableSize = 'medium', enableStickyHeaderOrFooter = false, maxHeight = '400px', enableVirtualization = false, estimateRowHeight = 52, enableTableSizeControl = true, enableExport = false, enableReset = true, loading = false, emptyMessage = 'No data available', skeletonRows = 5, onColumnFiltersChange, onPaginationChange, onGlobalFilterChange, slots = {}, slotProps = {}, logging, }, ref) {
45
45
  var _a;
46
46
  const isServerMode = dataMode === 'server';
47
47
  const isServerPagination = paginationMode === 'server' || isServerMode;
@@ -1206,7 +1206,7 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
1206
1206
  const row = rows[virtualRow.index];
1207
1207
  if (!row)
1208
1208
  return null;
1209
- return ((0, jsx_runtime_1.jsx)(rows_1.DataTableRow, { row: row, enableHover: enableHover, enableStripes: enableStripes, isOdd: virtualRow.index % 2 === 1, renderSubComponent: renderSubComponent, disableStickyHeader: enableStickyHeaderOrFooter, slots: slots, slotProps: slotProps }, row.id));
1209
+ return ((0, jsx_runtime_1.jsx)(rows_1.DataTableRow, { row: row, enableHover: enableHover, enableStripes: enableStripes, isOdd: virtualRow.index % 2 === 1, renderSubComponent: renderSubComponent, disableStickyHeader: enableStickyHeaderOrFooter, onRowClick: onRowClick, selectOnRowClick: selectOnRowClick, slots: slots, slotProps: slotProps }, row.id));
1210
1210
  }), virtualItems.length > 0 && ((0, jsx_runtime_1.jsx)("tr", { children: (0, jsx_runtime_1.jsx)("td", { colSpan: table.getAllColumns().length, style: {
1211
1211
  height: `${rowVirtualizer.getTotalSize() -
1212
1212
  ((_d = (_c = virtualItems[virtualItems.length - 1]) === null || _c === void 0 ? void 0 : _c.end) !== null && _d !== void 0 ? _d : 0)}px`,
@@ -1214,7 +1214,7 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
1214
1214
  border: 0,
1215
1215
  } }) }))] }));
1216
1216
  }
1217
- return rows.map((row, index) => ((0, jsx_runtime_1.jsx)(rows_1.DataTableRow, { row: row, enableHover: enableHover, enableStripes: enableStripes, isOdd: index % 2 === 1, renderSubComponent: renderSubComponent, disableStickyHeader: enableStickyHeaderOrFooter, slots: slots, slotProps: slotProps }, row.id)));
1217
+ return rows.map((row, index) => ((0, jsx_runtime_1.jsx)(rows_1.DataTableRow, { row: row, enableHover: enableHover, enableStripes: enableStripes, isOdd: index % 2 === 1, renderSubComponent: renderSubComponent, disableStickyHeader: enableStickyHeaderOrFooter, onRowClick: onRowClick, selectOnRowClick: selectOnRowClick, slots: slots, slotProps: slotProps }, row.id)));
1218
1218
  }, [
1219
1219
  tableLoading,
1220
1220
  rows,
@@ -1230,6 +1230,8 @@ exports.DataTable = (0, react_1.forwardRef)(function DataTable({ initialState, c
1230
1230
  enableStripes,
1231
1231
  renderSubComponent,
1232
1232
  enableStickyHeaderOrFooter,
1233
+ onRowClick,
1234
+ selectOnRowClick,
1233
1235
  slots,
1234
1236
  ]);
1235
1237
  const handleCancelExport = (0, react_1.useCallback)(() => {
@@ -53,6 +53,8 @@ export interface DataTableProps<T> {
53
53
  id: string;
54
54
  }) => boolean;
55
55
  onSelectionChange?: (selection: SelectionState) => void;
56
+ onRowClick?: (event: React.MouseEvent<HTMLTableRowElement>, row: Row<T>) => void;
57
+ selectOnRowClick?: boolean;
56
58
  enableBulkActions?: boolean;
57
59
  bulkActions?: (selectionState: SelectionState) => ReactNode;
58
60
  enableColumnResizing?: boolean;
@@ -56,7 +56,8 @@ function ColumnPinningControl(props = {}) {
56
56
  return column.id;
57
57
  };
58
58
  const handleUnpinAll = (0, react_1.useCallback)(() => {
59
- table.setColumnPinning(table.initialState.columnPinning || {});
59
+ var _a;
60
+ table === null || table === void 0 ? void 0 : table.setColumnPinning(((_a = table === null || table === void 0 ? void 0 : table.initialState) === null || _a === void 0 ? void 0 : _a.columnPinning) || {});
60
61
  }, [table]);
61
62
  const userPinnedLeft = (((_a = columnPinning.left) === null || _a === void 0 ? void 0 : _a.filter((id) => allColumns.some((column) => column.id === id))) || []);
62
63
  const userPinnedRight = (((_b = columnPinning.right) === null || _b === void 0 ? void 0 : _b.filter((id) => allColumns.some((column) => column.id === id))) || []);
@@ -12,6 +12,7 @@ declare module '@tanstack/table-core' {
12
12
  align?: 'left' | 'center' | 'right';
13
13
  filterable?: boolean;
14
14
  hideInExport?: boolean;
15
+ wrapText?: boolean;
15
16
  editComponent?: React.ComponentType<{
16
17
  value: any;
17
18
  onChange: (value: any) => void;
@@ -71,6 +71,7 @@ export interface PinnedColumnStyleOptions {
71
71
  disableStickyHeader?: boolean;
72
72
  isLastLeftPinnedColumn?: boolean;
73
73
  isFirstRightPinnedColumn?: boolean;
74
+ wrapText?: boolean;
74
75
  }
75
76
  export interface SimpleExportOptions {
76
77
  filename?: string;
@@ -1,17 +1,56 @@
1
1
  import type { DataTableColumn, PinnedColumnStyleOptions } from '../types';
2
2
  export declare function getPinnedColumnStyle(options: PinnedColumnStyleOptions): {
3
- backgroundColor: string;
4
- backgroundClip: string;
3
+ backgroundColor: (theme: any) => any;
4
+ backgroundImage: (theme: any) => string;
5
5
  boxShadow: string;
6
- willChange: string;
7
- transform: string;
8
6
  left?: number;
9
7
  right?: number;
10
8
  zIndex?: number;
11
- overflow: string;
12
- whiteSpace: string;
13
- textOverflow: string;
14
- maxWidth?: string | number;
9
+ whiteSpace: "normal";
10
+ wordBreak: "break-word";
11
+ overflow: "visible";
12
+ textOverflow?: undefined;
13
+ maxWidth: string | number;
14
+ minWidth: number;
15
+ width: string | number;
16
+ } | {
17
+ backgroundColor: (theme: any) => string;
18
+ boxShadow: string;
19
+ left?: number;
20
+ right?: number;
21
+ zIndex?: number;
22
+ whiteSpace: "normal";
23
+ wordBreak: "break-word";
24
+ overflow: "visible";
25
+ textOverflow?: undefined;
26
+ maxWidth: string | number;
27
+ minWidth: number;
28
+ width: string | number;
29
+ } | {
30
+ backgroundColor: (theme: any) => any;
31
+ backgroundImage: (theme: any) => string;
32
+ boxShadow: string;
33
+ left?: number;
34
+ right?: number;
35
+ zIndex?: number;
36
+ overflow: "hidden";
37
+ whiteSpace: "nowrap";
38
+ textOverflow: "ellipsis";
39
+ wordBreak?: undefined;
40
+ maxWidth: string | number;
41
+ minWidth: number;
42
+ width: string | number;
43
+ } | {
44
+ backgroundColor: (theme: any) => string;
45
+ boxShadow: string;
46
+ left?: number;
47
+ right?: number;
48
+ zIndex?: number;
49
+ overflow: "hidden";
50
+ whiteSpace: "nowrap";
51
+ textOverflow: "ellipsis";
52
+ wordBreak?: undefined;
53
+ maxWidth: string | number;
15
54
  minWidth: number;
16
55
  width: string | number;
17
56
  };
@@ -3,19 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.tableRowStyles = exports.tableCellStyles = void 0;
4
4
  exports.getPinnedColumnStyle = getPinnedColumnStyle;
5
5
  exports.getColumnAlignment = getColumnAlignment;
6
- const getBoxShadow = (isPinned, isLastLeftPinnedColumn, isFirstRightPinnedColumn) => {
7
- if (isPinned === 'left' && isLastLeftPinnedColumn) {
8
- return '1px 0 3px rgba(0, 0, 0, 0.12)';
9
- }
10
- if (isPinned === 'right' && isFirstRightPinnedColumn) {
11
- return '-1px 0 3px rgba(0, 0, 0, 0.12)';
12
- }
13
- return 'none';
14
- };
15
6
  function getPinnedColumnStyle(options) {
16
- const { width = 'auto', minWidth, maxWidth, isPinned, pinnedPosition, pinnedRightPosition, isLastLeftPinnedColumn, isFirstRightPinnedColumn, zIndex = 1, disableStickyHeader = false, } = options;
7
+ const { width = 'auto', minWidth, maxWidth, isPinned, pinnedPosition, pinnedRightPosition, isLastLeftPinnedColumn, isFirstRightPinnedColumn, zIndex = 1, disableStickyHeader = false, wrapText = false, } = options;
17
8
  const needsPinnedPositioning = isPinned;
18
- const shouldBeSticky = !!isPinned;
9
+ const shouldBeSticky = isPinned;
19
10
  let positionStyle = {};
20
11
  if (shouldBeSticky) {
21
12
  positionStyle = { position: 'sticky' };
@@ -23,15 +14,31 @@ function getPinnedColumnStyle(options) {
23
14
  else if (!disableStickyHeader) {
24
15
  positionStyle = { position: 'relative' };
25
16
  }
26
- return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ width }, (minWidth !== undefined && { minWidth })), (maxWidth !== undefined ? { maxWidth } : width !== 'auto' ? { maxWidth: width } : {})), { overflow: 'hidden', whiteSpace: 'nowrap', textOverflow: 'ellipsis' }), positionStyle), (needsPinnedPositioning ? {
17
+ const textWrappingStyles = wrapText
18
+ ? {
19
+ whiteSpace: 'normal',
20
+ wordBreak: 'break-word',
21
+ overflow: 'visible',
22
+ }
23
+ : {
24
+ overflow: 'hidden',
25
+ whiteSpace: 'nowrap',
26
+ textOverflow: 'ellipsis',
27
+ };
28
+ return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ width }, (minWidth !== undefined && { minWidth })), (maxWidth !== undefined ? { maxWidth } : { maxWidth: width })), textWrappingStyles), positionStyle), (needsPinnedPositioning ? {
27
29
  left: isPinned === 'left' ? pinnedPosition : undefined,
28
30
  right: isPinned === 'right' ? pinnedRightPosition : undefined,
29
31
  zIndex,
30
- } : {})), { backgroundColor: isPinned ? 'background.paper' : 'var(--row-bg, var(--mui-palette-background-paper))', backgroundClip: 'padding-box', boxShadow: isPinned === 'left' && isLastLeftPinnedColumn
32
+ } : {})), { boxShadow: isPinned === 'left' && isLastLeftPinnedColumn
31
33
  ? 'inset -1px 0 0 var(--palette-TableCell-border), 6px 0 6px -4px rgba(0,0,0,.18)'
32
34
  : isPinned === 'right' && isFirstRightPinnedColumn
33
35
  ? 'inset 1px 0 0 var(--palette-TableCell-border), -6px 0 6px -4px rgba(0,0,0,.18)'
34
- : undefined, willChange: 'transform', transform: 'translateZ(0)' });
36
+ : undefined }), (isPinned ? {
37
+ backgroundColor: (theme) => theme.palette.background.paper,
38
+ backgroundImage: (theme) => `linear-gradient(var(--row-bg, ${theme.palette.background.paper}), var(--row-bg, ${theme.palette.background.paper}))`,
39
+ } : {
40
+ backgroundColor: (theme) => `var(--row-bg, ${theme.palette.background.paper})`,
41
+ }));
35
42
  }
36
43
  exports.tableCellStyles = {
37
44
  sticky: {