material-react-table 1.6.3 → 1.6.5

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.
@@ -0,0 +1,2 @@
1
+ import type { MRT_Localization } from '../MaterialReactTable';
2
+ export declare const MRT_Localization_UK: MRT_Localization;
@@ -106,6 +106,8 @@ export declare const getLeadingDisplayColumnIds: <TData extends Record<string, a
106
106
  export declare const getTrailingDisplayColumnIds: <TData extends Record<string, any> = {}>(props: MaterialReactTableProps<TData>) => (string | false | undefined)[];
107
107
  export declare const getDefaultColumnOrderIds: <TData extends Record<string, any> = {}>(props: MaterialReactTableProps<TData>) => string[];
108
108
  export declare const getDefaultColumnFilterFn: <TData extends Record<string, any> = {}>(columnDef: MRT_ColumnDef<TData>) => MRT_FilterOption;
109
+ export declare const getIsFirstColumn: (column: MRT_Column, table: MRT_TableInstance) => boolean;
110
+ export declare const getIsLastColumn: (column: MRT_Column, table: MRT_TableInstance) => boolean;
109
111
  export declare const getIsLastLeftPinnedColumn: (table: MRT_TableInstance, column: MRT_Column) => boolean;
110
112
  export declare const getIsFirstRightPinnedColumn: (column: MRT_Column) => boolean;
111
113
  export declare const getTotalRight: (table: MRT_TableInstance, column: MRT_Column) => number;
@@ -217,6 +217,13 @@ const getDefaultColumnFilterFn = (columnDef) => {
217
217
  return 'equals';
218
218
  return 'fuzzy';
219
219
  };
220
+ const getIsFirstColumn = (column, table) => {
221
+ return table.getVisibleLeafColumns()[0].id === column.id;
222
+ };
223
+ const getIsLastColumn = (column, table) => {
224
+ const columns = table.getVisibleLeafColumns();
225
+ return columns[columns.length - 1].id === column.id;
226
+ };
220
227
  const getIsLastLeftPinnedColumn = (table, column) => {
221
228
  return (column.getIsPinned() === 'left' &&
222
229
  table.getLeftLeafHeaders().length - 1 === column.getPinnedIndex());
@@ -2203,7 +2210,7 @@ const MRT_TableBodyCell = ({ cell, enableHover, measureElement, numRows, rowInde
2203
2210
  var _a, _b;
2204
2211
  const theme = useTheme();
2205
2212
  const { getState, options: { editingMode, enableClickToCopy, enableColumnOrdering, enableEditing, enableGrouping, enableRowNumbers, layoutMode, muiTableBodyCellProps, muiTableBodyCellSkeletonProps, rowNumberMode, }, refs: { editInputRefs }, setEditingCell, setHoveredColumn, } = table;
2206
- const { draggingColumn, editingCell, editingRow, hoveredColumn, density, isLoading, showSkeletons, } = getState();
2213
+ const { draggingColumn, draggingRow, editingCell, editingRow, hoveredColumn, hoveredRow, density, isLoading, showSkeletons, } = getState();
2207
2214
  const { column, row } = cell;
2208
2215
  const { columnDef } = column;
2209
2216
  const { columnDefType } = columnDef;
@@ -2224,18 +2231,38 @@ const MRT_TableBodyCell = ({ cell, enableHover, measureElement, numRows, rowInde
2224
2231
  : Math.round(Math.random() * (column.getSize() - column.getSize() / 3) +
2225
2232
  column.getSize() / 3)
2226
2233
  : 100), []);
2227
- const draggingBorder = useMemo(() => (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id
2228
- ? `1px dashed ${theme.palette.text.secondary}`
2229
- : (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === column.id
2230
- ? `2px dashed ${theme.palette.primary.main}`
2231
- : undefined, [draggingColumn, hoveredColumn]);
2232
- const draggingBorders = useMemo(() => draggingBorder
2233
- ? {
2234
- borderLeft: draggingBorder,
2235
- borderRight: draggingBorder,
2236
- borderBottom: rowIndex === numRows - 1 ? draggingBorder : undefined,
2237
- }
2238
- : undefined, [draggingBorder, numRows]);
2234
+ const draggingBorders = useMemo(() => {
2235
+ const isDraggingColumn = (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id;
2236
+ const isHoveredColumn = (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === column.id;
2237
+ const isDraggingRow = (draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id) === row.id;
2238
+ const isHoveredRow = (hoveredRow === null || hoveredRow === void 0 ? void 0 : hoveredRow.id) === row.id;
2239
+ const isFirstColumn = getIsFirstColumn(column, table);
2240
+ const isLastColumn = getIsLastColumn(column, table);
2241
+ const isLastRow = rowIndex === numRows - 1;
2242
+ const borderStyle = isDraggingColumn || isDraggingRow
2243
+ ? `1px dashed ${theme.palette.text.secondary} !important`
2244
+ : isHoveredColumn || isHoveredRow
2245
+ ? `2px dashed ${theme.palette.primary.main} !important`
2246
+ : undefined;
2247
+ return borderStyle
2248
+ ? {
2249
+ borderLeft: isDraggingColumn ||
2250
+ isHoveredColumn ||
2251
+ ((isDraggingRow || isHoveredRow) && isFirstColumn)
2252
+ ? borderStyle
2253
+ : undefined,
2254
+ borderRight: isDraggingColumn ||
2255
+ isHoveredColumn ||
2256
+ ((isDraggingRow || isHoveredRow) && isLastColumn)
2257
+ ? borderStyle
2258
+ : undefined,
2259
+ borderBottom: isDraggingRow || isHoveredRow || isLastRow
2260
+ ? borderStyle
2261
+ : undefined,
2262
+ borderTop: isDraggingRow || isHoveredRow ? borderStyle : undefined,
2263
+ }
2264
+ : undefined;
2265
+ }, [draggingColumn, draggingRow, hoveredColumn, hoveredRow, rowIndex]);
2239
2266
  const isEditable = (enableEditing || columnDef.enableEditing) &&
2240
2267
  columnDef.enableEditing !== false;
2241
2268
  const isEditing = isEditable &&
@@ -2355,7 +2382,6 @@ const MRT_TableDetailPanel = ({ parentRowRef, row, table, virtualRow, }) => {
2355
2382
  };
2356
2383
 
2357
2384
  const MRT_TableBodyRow = ({ columnVirtualizer, measureElement, numRows, row, rowIndex, table, virtualColumns, virtualPaddingLeft, virtualPaddingRight, virtualRow, }) => {
2358
- const theme = useTheme();
2359
2385
  const { getIsSomeColumnsPinned, getState, options: { enableRowOrdering, layoutMode, memoMode, muiTableBodyRowProps, renderDetailPanel, }, setHoveredRow, } = table;
2360
2386
  const { draggingColumn, draggingRow, editingCell, editingRow, hoveredRow } = getState();
2361
2387
  const tableRowProps = muiTableBodyRowProps instanceof Function
@@ -2367,23 +2393,13 @@ const MRT_TableBodyRow = ({ columnVirtualizer, measureElement, numRows, row, row
2367
2393
  }
2368
2394
  };
2369
2395
  const rowRef = useRef(null);
2370
- const draggingBorder = useMemo(() => (draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id) === row.id
2371
- ? `1px dashed ${theme.palette.text.secondary}`
2372
- : (hoveredRow === null || hoveredRow === void 0 ? void 0 : hoveredRow.id) === row.id
2373
- ? `2px dashed ${theme.palette.primary.main}`
2374
- : undefined, [draggingRow, hoveredRow]);
2375
- const draggingBorders = draggingBorder
2376
- ? {
2377
- border: draggingBorder,
2378
- }
2379
- : undefined;
2380
2396
  return (React.createElement(React.Fragment, null,
2381
2397
  React.createElement(TableRow, Object.assign({ "data-index": virtualRow === null || virtualRow === void 0 ? void 0 : virtualRow.index, hover: true, onDragEnter: handleDragEnter, selected: row.getIsSelected(), ref: (node) => {
2382
2398
  if (node) {
2383
2399
  rowRef.current = node;
2384
2400
  measureElement === null || measureElement === void 0 ? void 0 : measureElement(node);
2385
2401
  }
2386
- } }, tableRowProps, { sx: (theme) => (Object.assign(Object.assign({ backgroundColor: lighten(theme.palette.background.default, 0.06), display: layoutMode === 'grid' ? 'flex' : 'table-row', opacity: (draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id) === row.id || (hoveredRow === null || hoveredRow === void 0 ? void 0 : hoveredRow.id) === row.id ? 0.5 : 1, position: virtualRow ? 'absolute' : undefined, top: virtualRow ? 0 : undefined, transform: virtualRow
2402
+ } }, tableRowProps, { sx: (theme) => (Object.assign({ backgroundColor: lighten(theme.palette.background.default, 0.06), display: layoutMode === 'grid' ? 'flex' : 'table-row', opacity: (draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id) === row.id || (hoveredRow === null || hoveredRow === void 0 ? void 0 : hoveredRow.id) === row.id ? 0.5 : 1, position: virtualRow ? 'absolute' : undefined, top: virtualRow ? 0 : undefined, transform: virtualRow
2387
2403
  ? `translateY(${virtualRow === null || virtualRow === void 0 ? void 0 : virtualRow.start}px)`
2388
2404
  : undefined, transition: virtualRow ? 'none' : 'all 150ms ease-in-out', width: '100%', '&:hover td': {
2389
2405
  backgroundColor: (tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.hover) !== false && getIsSomeColumnsPinned()
@@ -2393,7 +2409,7 @@ const MRT_TableBodyRow = ({ columnVirtualizer, measureElement, numRows, row, row
2393
2409
  : undefined,
2394
2410
  } }, ((tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx) instanceof Function
2395
2411
  ? tableRowProps.sx(theme)
2396
- : tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx)), draggingBorders)) }),
2412
+ : tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx))) }),
2397
2413
  virtualPaddingLeft ? (React.createElement("td", { style: { display: 'flex', width: virtualPaddingLeft } })) : null,
2398
2414
  (virtualColumns !== null && virtualColumns !== void 0 ? virtualColumns : row.getVisibleCells()).map((cellOrVirtualCell) => {
2399
2415
  const cell = columnVirtualizer