Skip to content

Commit

Permalink
[DataGrid] Don't export the internal utils (#2233)
Browse files Browse the repository at this point in the history
* Export clean utils

* Fix

* Fix

* Remove exports

* Fix

* Regen docs examples

* Fix story
  • Loading branch information
flaviendelangle authored Jul 30, 2021
1 parent f35cee0 commit 363a7a1
Show file tree
Hide file tree
Showing 44 changed files with 102 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Typography from '@material-ui/core/Typography';
import Paper from '@material-ui/core/Paper';
import Popper from '@material-ui/core/Popper';
import { makeStyles } from '@material-ui/styles';
import { DataGrid, isOverflown } from '@material-ui/data-grid';
import { DataGrid } from '@material-ui/data-grid';

const useStyles = makeStyles(() => ({
root: {
Expand All @@ -22,6 +22,13 @@ const useStyles = makeStyles(() => ({
},
}));

function isOverflown(element) {
return (
element.scrollHeight > element.clientHeight ||
element.scrollWidth > element.clientWidth
);
}

const GridCellExpand = React.memo(function GridCellExpand(props) {
const { width, value } = props;
const wrapper = React.useRef(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@ import Typography from '@material-ui/core/Typography';
import Paper from '@material-ui/core/Paper';
import Popper from '@material-ui/core/Popper';
import { createStyles, makeStyles } from '@material-ui/styles';
import {
DataGrid,
GridColDef,
GridCellParams,
isOverflown,
} from '@material-ui/data-grid';
import { DataGrid, GridColDef, GridCellParams } from '@material-ui/data-grid';

interface GridCellExpandProps {
value: string;
Expand All @@ -33,6 +28,13 @@ const useStyles = makeStyles(() =>
}),
);

function isOverflown(element: Element): boolean {
return (
element.scrollHeight > element.clientHeight ||
element.scrollWidth > element.clientWidth
);
}

const GridCellExpand = React.memo(function GridCellExpand(
props: GridCellExpandProps,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@
import * as React from 'react';
import { createMuiTheme } from '@material-ui/core/styles';
import { makeStyles } from '@material-ui/styles';
import { DataGrid, getThemePaletteMode } from '@material-ui/data-grid';
import { DataGrid } from '@material-ui/data-grid';
import {
randomCreatedDate,
randomTraderName,
randomUpdatedDate,
} from '@material-ui/x-grid-data-generator';

function getThemePaletteMode(palette) {
return palette.type || palette.mode;
}

const defaultTheme = createMuiTheme();
const useStyles = makeStyles(
(theme) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@
import * as React from 'react';
import { createMuiTheme, Theme } from '@material-ui/core/styles';
import { makeStyles } from '@material-ui/styles';
import {
DataGrid,
getThemePaletteMode,
GridColumns,
GridRowsProp,
} from '@material-ui/data-grid';
import { DataGrid, GridColumns, GridRowsProp } from '@material-ui/data-grid';
import {
randomCreatedDate,
randomTraderName,
randomUpdatedDate,
} from '@material-ui/x-grid-data-generator';

function getThemePaletteMode(palette: any): string {
return palette.type || palette.mode;
}

const defaultTheme = createMuiTheme();
const useStyles = makeStyles(
(theme: Theme) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@
import * as React from 'react';
import { createMuiTheme } from '@material-ui/core/styles';
import { makeStyles } from '@material-ui/styles';
import { DataGrid, getThemePaletteMode } from '@material-ui/data-grid';
import { DataGrid } from '@material-ui/data-grid';
import {
randomCreatedDate,
randomEmail,
randomTraderName,
randomUpdatedDate,
} from '@material-ui/x-grid-data-generator';

function getThemePaletteMode(palette) {
return palette.type || palette.mode;
}

const defaultTheme = createMuiTheme();
const useStyles = makeStyles(
(theme) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { createMuiTheme, Theme } from '@material-ui/core/styles';
import { makeStyles } from '@material-ui/styles';
import {
DataGrid,
getThemePaletteMode,
GridColumns,
GridEditRowsModel,
GridRowsProp,
Expand All @@ -16,6 +15,10 @@ import {
randomUpdatedDate,
} from '@material-ui/x-grid-data-generator';

function getThemePaletteMode(palette: any): string {
return palette.type || palette.mode;
}

const defaultTheme = createMuiTheme();
const useStyles = makeStyles(
(theme: Theme) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
import * as React from 'react';
import { createMuiTheme } from '@material-ui/core/styles';
import { makeStyles } from '@material-ui/styles';
import { useGridApiRef, getThemePaletteMode, XGrid } from '@material-ui/x-grid';
import { useGridApiRef, XGrid } from '@material-ui/x-grid';

function getThemePaletteMode(palette) {
return palette.type || palette.mode;
}

const defaultTheme = createMuiTheme();
const useStyles = makeStyles(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ import {
GridEditCellPropsParams,
GridRowsProp,
useGridApiRef,
getThemePaletteMode,
XGrid,
} from '@material-ui/x-grid';

function getThemePaletteMode(palette: any): string {
return palette.type || palette.mode;
}

const defaultTheme = createMuiTheme();
const useStyles = makeStyles(
(theme: Theme) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import IconButton from '@material-ui/core/IconButton';
import TextField from '@material-ui/core/TextField';
import {
DataGrid,
escapeRegExp,
GridToolbarDensitySelector,
GridToolbarFilterButton,
} from '@material-ui/data-grid';
Expand All @@ -14,6 +13,10 @@ import SearchIcon from '@material-ui/icons/Search';
import { createMuiTheme } from '@material-ui/core/styles';
import { makeStyles } from '@material-ui/styles';

function escapeRegExp(value) {
return value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
}

const defaultTheme = createMuiTheme();
const useStyles = makeStyles(
(theme) => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import IconButton from '@material-ui/core/IconButton';
import TextField from '@material-ui/core/TextField';
import {
DataGrid,
escapeRegExp,
GridToolbarDensitySelector,
GridToolbarFilterButton,
} from '@material-ui/data-grid';
Expand All @@ -13,6 +12,10 @@ import SearchIcon from '@material-ui/icons/Search';
import { createMuiTheme, Theme } from '@material-ui/core/styles';
import { createStyles, makeStyles } from '@material-ui/styles';

function escapeRegExp(value: string): string {
return value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
}

const defaultTheme = createMuiTheme();
const useStyles = makeStyles(
(theme: Theme) =>
Expand Down
6 changes: 5 additions & 1 deletion docs/src/pages/components/data-grid/style/StylingRowsGrid.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import * as React from 'react';
import { DataGrid, getThemePaletteMode } from '@material-ui/data-grid';
import { DataGrid } from '@material-ui/data-grid';
import { useDemoData } from '@material-ui/x-grid-data-generator';
import { createMuiTheme, darken, lighten } from '@material-ui/core/styles';
import { makeStyles } from '@material-ui/styles';

function getThemePaletteMode(palette) {
return palette.type || palette.mode;
}

const defaultTheme = createMuiTheme();
const useStyles = makeStyles(
(theme) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import * as React from 'react';
import { DataGrid, getThemePaletteMode } from '@material-ui/data-grid';
import { DataGrid } from '@material-ui/data-grid';
import { useDemoData } from '@material-ui/x-grid-data-generator';
import { createMuiTheme, darken, lighten, Theme } from '@material-ui/core/styles';
import { makeStyles } from '@material-ui/styles';

function getThemePaletteMode(palette: any): string {
return palette.type || palette.mode;
}

const defaultTheme = createMuiTheme();
const useStyles = makeStyles(
(theme: Theme) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/grid/_modules_/grid/components/GridPagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useGridSelector } from '../hooks/features/core/useGridSelector';
import { gridPaginationSelector } from '../hooks/features/pagination/gridPaginationSelector';
import { optionsSelector } from '../hooks/utils/optionsSelector';
import { useGridApiContext } from '../hooks/root/useGridApiContext';
import { getMuiVersion, createTheme } from '../utils';
import { createTheme, getMuiVersion } from '../utils/utils';
import { GridRootPropsContext } from '../context/GridRootPropsContext';

const defaultTheme = createTheme();
Expand Down
2 changes: 1 addition & 1 deletion packages/grid/_modules_/grid/components/GridRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
GRID_ROW_OVER,
} from '../constants/eventsConstants';
import { GridRowId } from '../models';
import { isFunction } from '../utils';
import { isFunction } from '../utils/utils';
import { gridDensityRowHeightSelector } from '../hooks/features/density';
import { useGridApiContext } from '../hooks/root/useGridApiContext';
import { useGridSelector } from '../hooks/features/core/useGridSelector';
Expand Down
4 changes: 2 additions & 2 deletions packages/grid/_modules_/grid/components/cell/GridRowCells.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import {
GridCellParams,
GridRowId,
GridEditRowProps,
} from '../../models/index';
} from '../../models';
import { GridCell, GridCellProps } from './GridCell';
import { useGridApiContext } from '../../hooks/root/useGridApiContext';
import { isFunction } from '../../utils/index';
import { isFunction } from '../../utils/utils';
import { GRID_CSS_CLASS_PREFIX } from '../../constants/cssClassesConstants';

interface RowCellsProps {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import clsx from 'clsx';
import Tooltip from '@material-ui/core/Tooltip';
import { isOverflown } from '../../utils/index';
import { isOverflown } from '../../utils/domUtils';

const ColumnHeaderInnerTitle = React.forwardRef<
HTMLDivElement,
Expand Down
3 changes: 2 additions & 1 deletion packages/grid/_modules_/grid/components/panel/GridPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import ClickAwayListener from '@material-ui/core/ClickAwayListener';
import Paper from '@material-ui/core/Paper';
import Popper, { PopperProps } from '@material-ui/core/Popper';
import { useGridApiContext } from '../../hooks/root/useGridApiContext';
import { isEscapeKey, getMuiVersion, createTheme } from '../../utils';
import { getMuiVersion, createTheme } from '../../utils/utils';
import { isEscapeKey } from '../../utils/keyboardUtils';
import {
InternalStandardProps as StandardProps,
generateUtilityClasses,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import clsx from 'clsx';
import TrapFocus from '@material-ui/core/Unstable_TrapFocus';
import { makeStyles } from '@material-ui/styles';
import { getMuiVersion } from '../../utils';
import { getMuiVersion } from '../../utils/utils';

const useStyles = makeStyles(
() => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { gridSelectionStateSelector } from '../selection';
import { GridCsvExportApi } from '../../../models/api/gridCsvExportApi';
import { GridExportCsvOptions } from '../../../models/gridExport';
import { useLogger } from '../../utils/useLogger';
import { exportAs } from '../../../utils';
import { exportAs } from '../../../utils/exportAs';
import { buildCSV } from './serializers/csvSerializer';
import { GridColDef } from '../../../models';

Expand Down
1 change: 0 additions & 1 deletion packages/grid/_modules_/grid/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ export * from './constants';
export * from './hooks';
export * from './locales';
export * from './models';
export * from './utils';
export * from './GridComponentProps';
export * from './GridComponent';
export * from './useGridComponent';
Expand Down
2 changes: 1 addition & 1 deletion packages/grid/_modules_/grid/locales/bgBG.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { bgBG as bgBGCore } from '@material-ui/core/locale';
import { GridLocaleText } from '../models/api/gridLocaleTextApi';
import { getGridLocalization, Localization } from '../utils';
import { getGridLocalization, Localization } from '../utils/getGridLocalization';

const bgBGGrid: Partial<GridLocaleText> = {
// Root
Expand Down
2 changes: 1 addition & 1 deletion packages/grid/_modules_/grid/locales/csCZ.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { csCZ as csCZCore } from '@material-ui/core/locale';
import { GridLocaleText } from '../models/api/gridLocaleTextApi';
import { getGridLocalization, Localization } from '../utils';
import { getGridLocalization, Localization } from '../utils/getGridLocalization';

const csCZKGrid: Partial<GridLocaleText> = {
// Root
Expand Down
2 changes: 1 addition & 1 deletion packages/grid/_modules_/grid/locales/deDE.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { deDE as deDECore } from '@material-ui/core/locale';
import { GridLocaleText } from '../models/api/gridLocaleTextApi';
import { getGridLocalization, Localization } from '../utils';
import { getGridLocalization, Localization } from '../utils/getGridLocalization';

const deDEGrid: Partial<GridLocaleText> = {
// Root
Expand Down
2 changes: 1 addition & 1 deletion packages/grid/_modules_/grid/locales/elGR.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GridLocaleText } from '../models/api/gridLocaleTextApi';
import { getGridLocalization, Localization } from '../utils';
import { getGridLocalization, Localization } from '../utils/getGridLocalization';

const elGRGrid: Partial<GridLocaleText> = {
// Root
Expand Down
2 changes: 1 addition & 1 deletion packages/grid/_modules_/grid/locales/enUS.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { enUS as enUSCore } from '@material-ui/core/locale';
import { getGridLocalization, Localization } from '../utils';
import { getGridLocalization, Localization } from '../utils/getGridLocalization';
import { GRID_DEFAULT_LOCALE_TEXT } from '../constants/localeTextConstants';

export const enUS: Localization = getGridLocalization(GRID_DEFAULT_LOCALE_TEXT, enUSCore);
2 changes: 1 addition & 1 deletion packages/grid/_modules_/grid/locales/esES.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { esES as esESCore } from '@material-ui/core/locale';
import { GridLocaleText } from '../models/api/gridLocaleTextApi';
import { getGridLocalization, Localization } from '../utils';
import { getGridLocalization, Localization } from '../utils/getGridLocalization';

const esESGrid: Partial<GridLocaleText> = {
// Root
Expand Down
2 changes: 1 addition & 1 deletion packages/grid/_modules_/grid/locales/frFR.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { frFR as frFRCore } from '@material-ui/core/locale';
import { GridLocaleText } from '../models/api/gridLocaleTextApi';
import { getGridLocalization, Localization } from '../utils';
import { getGridLocalization, Localization } from '../utils/getGridLocalization';

const frFRGrid: Partial<GridLocaleText> = {
// Root
Expand Down
2 changes: 1 addition & 1 deletion packages/grid/_modules_/grid/locales/itIT.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { itIT as itITCore } from '@material-ui/core/locale';
import { GridLocaleText } from '../models/api/gridLocaleTextApi';
import { getGridLocalization, Localization } from '../utils';
import { getGridLocalization, Localization } from '../utils/getGridLocalization';

const itITGrid: Partial<GridLocaleText> = {
// Root
Expand Down
2 changes: 1 addition & 1 deletion packages/grid/_modules_/grid/locales/jaJP.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { jaJP as jaJPCore } from '@material-ui/core/locale';
import { GridLocaleText } from '../models/api/gridLocaleTextApi';
import { getGridLocalization, Localization } from '../utils';
import { getGridLocalization, Localization } from '../utils/getGridLocalization';

const jaJPGrid: Partial<GridLocaleText> = {
// Root
Expand Down
2 changes: 1 addition & 1 deletion packages/grid/_modules_/grid/locales/nlNL.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { nlNL as nlNLCore } from '@material-ui/core/locale';
import { GridLocaleText } from '../models/api/gridLocaleTextApi';
import { getGridLocalization, Localization } from '../utils';
import { getGridLocalization, Localization } from '../utils/getGridLocalization';

const nlNLGrid: Partial<GridLocaleText> = {
// Root
Expand Down
2 changes: 1 addition & 1 deletion packages/grid/_modules_/grid/locales/plPL.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { plPL as plPLCore } from '@material-ui/core/locale';
import { GridLocaleText } from '../models/api/gridLocaleTextApi';
import { getGridLocalization, Localization } from '../utils';
import { getGridLocalization, Localization } from '../utils/getGridLocalization';

export const plPLGrid: Partial<GridLocaleText> = {
// Root
Expand Down
2 changes: 1 addition & 1 deletion packages/grid/_modules_/grid/locales/ptBR.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ptBR as ptBRCore } from '@material-ui/core/locale';
import { GridLocaleText } from '../models/api/gridLocaleTextApi';
import { getGridLocalization, Localization } from '../utils';
import { getGridLocalization, Localization } from '../utils/getGridLocalization';

const ptBRGrid: Partial<GridLocaleText> = {
// Root
Expand Down
Loading

0 comments on commit 363a7a1

Please sign in to comment.