gregnb / mui-datatables

Datatables for React using Material-UI
MIT License
2.71k stars 935 forks source link

Add support for DefinitelyTyped when using MUI5 and TS #1846

Open arvebratt opened 2 years ago

arvebratt commented 2 years ago

Expected Behavior

The latest version of DefinitelyTyped/mui-datatables uses

This is an issue if you want to use MUI5, mui-datatables and DefinitelyTyped together since @material-ui/core and @mui/material can not be dependencies in the same project.

Current Behavior

In DefinitelyTyped/mui-datatables package.json { "private": true, "dependencies": { "@material-ui/core": "^4.11.3", -> @mui/material "@material-ui/types": "5.1.0" -> @mui/types } }

Your Environment

Tech Version
Material-UI 5.2
MUI-datatables 4.0.0
React 17.2
TypeScript 4.3.2
mRamzii commented 2 years ago

+1 Facing the same issue, types have MaterialUi 4.x as peer dependency

TristanHoladay commented 2 years ago

Running into the same problem.

LuisAlejandro commented 2 years ago

I also have the same problem. What needs to be done? submit an issue to DefinitelyTyped?

AlonMiz commented 2 years ago

what would it take to migrate this lib to Typescript... then we don't need to chaise DefinitelyTyped on each change.

mRamzii commented 2 years ago

As temporary workarounds : I have managed to workaround this by styling MUI's native Table (MuiTable, MuiTableBody etc..) instead, seems like MuiDataTable inherits style classes from it, with some adjustments managed to get the style I wanted.

You could also ignore the typing on the createTheme()

AlonMiz commented 2 years ago

here's a snippet for making the custom components work

import { ComponentsOverrides } from '@mui/material';

declare module '@mui/material/styles' {
  interface ComponentNameToClassKey {
    MUIDataTableHeadCell:
      | 'root'
      | 'contentWrapper'
      | 'data'
      | 'dragCursor'
      | 'fixedHeader'
      | 'hintIconAlone'
      | 'hintIconWithSortIcon'
      | 'mypopper'
      | 'sortAction'
      | 'sortActive'
      | 'sortLabelRoot'
      | 'toolButton'
      | 'tooltip';
    MUIDataTable:
      | 'root'
      | 'caption'
      | 'liveAnnounce'
      | 'paper'
      | 'responsiveScroll'
      | 'tableRoot'
      | 'responsiveBase'; // not sure it's there

    MUIDataTableToolbar:
      | 'root'
      | 'actions'
      | 'filterCloseIcon'
      | 'filterPaper'
      | 'fullWidthActions'
      | 'fullWidthLeft'
      | 'fullWidthRoot'
      | 'fullWidthTitleText'
      | 'icon'
      | 'iconActive'
      | 'left'
      | 'searchIcon'
      | 'titleRoot'
      | 'titleText';
  }

  interface Components<Theme = unknown> {
    MUIDataTableHeadCell?: {
      styleOverrides?: ComponentsOverrides<Theme>['MUIDataTableHeadCell'];
    };
    MUIDataTable?: {
      styleOverrides?: ComponentsOverrides<Theme>['MUIDataTable'];
    };
    MUIDataTableToolbar?: {
      styleOverrides?: ComponentsOverrides<Theme>['MUIDataTableToolbar'];
    };
  }
}