Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DataGrid] Rename missed modules #1292

Merged
merged 2 commits into from
Mar 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as React from 'react';
import { DataGrid, FilterModel, GridToolbar } from '@material-ui/data-grid';
import { DataGrid, GridFilterModel, GridToolbar } from '@material-ui/data-grid';
import { useDemoData } from '@material-ui/x-grid-data-generator';

const riceFilterModel: FilterModel = {
const riceFilterModel: GridFilterModel = {
items: [{ columnField: 'commodity', operatorValue: 'contains', value: 'rice' }],
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import { makeStyles } from '@material-ui/core/styles';
import { Rating } from '@material-ui/lab';
import {
FilterInputValueProps,
GridFilterInputValueProps,
GridPreferencePanelsValue,
DataGrid,
GridFilterItem,
Expand All @@ -20,7 +20,7 @@ const useStyles = makeStyles({
},
});

function RatingInputValue(props: FilterInputValueProps) {
function RatingInputValue(props: GridFilterInputValueProps) {
const classes = useStyles();
const { item, applyValue } = props;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { makeStyles } from '@material-ui/core/styles';
import { Rating } from '@material-ui/lab';
import {
DataGrid,
FilterInputValueProps,
GridFilterInputValueProps,
getGridNumericColumnOperators,
GridPreferencePanelsValue,
} from '@material-ui/data-grid';
Expand All @@ -19,7 +19,7 @@ const useStyles = makeStyles({
},
});

function RatingInputValue(props: FilterInputValueProps) {
function RatingInputValue(props: GridFilterInputValueProps) {
const classes = useStyles();
const { item, applyValue } = props;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { FilterModel, GridLinkOperator, XGrid } from '@material-ui/x-grid';
import { GridFilterModel, GridLinkOperator, XGrid } from '@material-ui/x-grid';
import { useDemoData } from '@material-ui/x-grid-data-generator';
import * as React from 'react';

const filterModel: FilterModel = {
const filterModel: GridFilterModel = {
items: [
{ columnField: 'commodity', operatorValue: 'contains', value: 'rice' },
{ columnField: 'commodity', operatorValue: 'startsWith', value: 'soy' },
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/components/data-grid/filtering/filtering.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ The default operator that will be applied between filters is an And.
To change the default operator, you should set the 'linkOperator' property of the filterModel like below.

```ts
const filterModel: FilterModel = {
const filterModel: GridFilterModel = {
items: [
{ columnField: 'commodity', operatorValue: 'contains', value: 'rice' },
{ columnField: 'commodity', operatorValue: 'startsWith', value: 'Soy' },
Expand Down
10 changes: 8 additions & 2 deletions packages/grid/_modules_/grid/components/GridRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,20 @@ import { gridDensityRowHeightSelector } from '../hooks/features/density';
import { GridApiContext } from './GridApiContext';
import { useGridSelector } from '../hooks/features/core/useGridSelector';

export interface RowProps {
export interface GridRowProps {
id: GridRowId;
selected: boolean;
className: string;
rowIndex: number;
}

export const GridRow: React.FC<RowProps> = ({ selected, id, className, rowIndex, children }) => {
export const GridRow: React.FC<GridRowProps> = ({
selected,
id,
className,
rowIndex,
children,
}) => {
const ariaRowIndex = rowIndex + 2; // 1 for the header row and 1 as it's 1 based
const apiRef = React.useContext(GridApiContext);
const rowHeight = useGridSelector(apiRef, gridDensityRowHeightSelector);
Expand Down
2 changes: 1 addition & 1 deletion packages/grid/_modules_/grid/components/GridViewport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { visibleGridColumnsSelector } from '../hooks/features/columns/gridColumn
import { useGridSelector } from '../hooks/features/core/useGridSelector';
import { gridDensityRowHeightSelector } from '../hooks/features/density/densitySelector';
import { visibleSortedGridRowsSelector } from '../hooks/features/filter/gridFilterSelector';
import { gridKeyboardCellSelector } from '../hooks/features/keyboard/keyboardSelector';
import { gridKeyboardCellSelector } from '../hooks/features/keyboard/gridKeyboardSelector';
import { gridSelectionStateSelector } from '../hooks/features/selection/gridSelectionSelector';
import { renderStateSelector } from '../hooks/features/virtualization/renderingStateSelector';
import { optionsSelector } from '../hooks/utils/optionsSelector';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { GridIconSlotsComponent } from '../../models/gridIconSlotsComponent';
import { GridSortDirection } from '../../models/gridSortModel';
import { GridApiContext } from '../GridApiContext';

export interface ColumnHeaderSortIconProps {
export interface GridColumnHeaderSortIconProps {
direction: GridSortDirection;
index: number | undefined;
hide?: boolean;
Expand All @@ -18,7 +18,7 @@ function getIcon(icons: GridIconSlotsComponent, direction: GridSortDirection) {
}

export const GridColumnHeaderSortIcon = React.memo(function GridColumnHeaderSortIcon(
props: ColumnHeaderSortIconProps,
props: GridColumnHeaderSortIconProps,
) {
const { direction, index, hide } = props;
const apiRef = React.useContext(GridApiContext);
Expand Down
4 changes: 2 additions & 2 deletions packages/grid/_modules_/grid/components/menu/GridMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const useStyles = makeStyles(
{ name: 'MuiDataGridMenu' },
);

export interface MenuProps extends Omit<PopperProps, 'onKeyDown'> {
export interface GridMenuProps extends Omit<PopperProps, 'onKeyDown'> {
open: boolean;
target: React.ReactNode;
onClickAway: (event?: React.MouseEvent<Document, MouseEvent>) => void;
Expand All @@ -44,7 +44,7 @@ const transformOrigin = {
'bottom-end': 'top right',
};

export const GridMenu: React.FC<MenuProps> = ({
export const GridMenu: React.FC<GridMenuProps> = ({
open,
target,
onClickAway,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { ColumnMenuState } from '../../../hooks/features/columnMenu/columnMenuState';
import { GridColumnMenuState } from '../../../hooks/features/columnMenu/columnMenuState';
import { GridState } from '../../../hooks/features/core/gridState';
import { useGridSelector } from '../../../hooks/features/core/useGridSelector';
import { findHeaderElementFromField } from '../../../utils/domUtils';
Expand Down Expand Up @@ -36,7 +36,7 @@ export function GridColumnHeaderMenu({
}, [hideMenu]);

const updateColumnMenu = React.useCallback(
({ open, field }: ColumnMenuState) => {
({ open, field }: GridColumnMenuState) => {
if (field && open) {
immediateTimeout.current = setTimeout(() => clearTimeout(hideTimeout.current), 0);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { useGridSelector } from '../../../hooks/features/core/useGridSelector';
import { GridPreferencePanelsValue } from '../../../hooks/features/preferencesPanel/gridPreferencePanelsValue';
import { optionsSelector } from '../../../hooks/utils/optionsSelector';
import { GridApiContext } from '../../GridApiContext';
import { FilterItemProps } from './FilterItemProps';
import { GridFilterItemProps } from './GridFilterItemProps';

export const GridColumnsMenuItem: React.FC<FilterItemProps> = ({ onClick }) => {
export const GridColumnsMenuItem: React.FC<GridFilterItemProps> = ({ onClick }) => {
const apiRef = React.useContext(GridApiContext);
const options = useGridSelector(apiRef, optionsSelector);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import { GridColDef } from '../../../models/colDef/gridColDef';

export interface FilterItemProps {
export interface GridFilterItemProps {
column: GridColDef;
onClick: (event: React.MouseEvent<any>) => void;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import MenuItem from '@material-ui/core/MenuItem';
import { useGridSelector } from '../../../hooks/features/core/useGridSelector';
import { optionsSelector } from '../../../hooks/utils/optionsSelector';
import { GridApiContext } from '../../GridApiContext';
import { FilterItemProps } from './FilterItemProps';
import { GridFilterItemProps } from './GridFilterItemProps';

export const GridFilterMenuItem: React.FC<FilterItemProps> = ({ column, onClick }) => {
export const GridFilterMenuItem: React.FC<GridFilterItemProps> = ({ column, onClick }) => {
const apiRef = React.useContext(GridApiContext);
const options = useGridSelector(apiRef, optionsSelector);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as React from 'react';
import MenuItem from '@material-ui/core/MenuItem';
import { GridApiContext } from '../../GridApiContext';
import { FilterItemProps } from './FilterItemProps';
import { GridFilterItemProps } from './GridFilterItemProps';

export const HideGridColMenuItem: React.FC<FilterItemProps> = ({ column, onClick }) => {
export const HideGridColMenuItem: React.FC<GridFilterItemProps> = ({ column, onClick }) => {
const apiRef = React.useContext(GridApiContext);
const timeoutRef = React.useRef<any>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { useGridSelector } from '../../../hooks/features/core/useGridSelector';
import { gridSortModelSelector } from '../../../hooks/features/sorting/gridSortingSelector';
import { GridSortDirection } from '../../../models/gridSortModel';
import { GridApiContext } from '../../GridApiContext';
import { FilterItemProps } from './FilterItemProps';
import { GridFilterItemProps } from './GridFilterItemProps';

export const SortGridMenuItems: React.FC<FilterItemProps> = ({ column, onClick }) => {
export const SortGridMenuItems: React.FC<GridFilterItemProps> = ({ column, onClick }) => {
const apiRef = React.useContext(GridApiContext);
const sortModel = useGridSelector(apiRef, gridSortModelSelector);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export * from './GridColumnsMenuItem';
export * from './FilterItemProps';
export * from './GridFilterItemProps';
export * from './GridFilterMenuItem';
export * from './GridColumnHeaderMenu';
export * from './GridColumnMenu';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { GridFilterItem, GridLinkOperator } from '../../../models/gridFilterItem
import { GridFilterOperator } from '../../../models/gridFilterOperator';
import { GridApiContext } from '../../GridApiContext';
import { GridCloseIcon } from '../../icons/index';
import { TranslationKeys } from '../../../models/api/gridLocaleTextApi';
import { GridTranslationKeys } from '../../../models/api/gridLocaleTextApi';

export interface GridFilterFormProps {
item: GridFilterItem;
Expand Down Expand Up @@ -204,7 +204,7 @@ export function GridFilterForm(props: GridFilterFormProps) {
<option key={operator.value} value={operator.value}>
{operator.label ||
apiRef!.current.getLocaleText(
`filterOperator${capitalize(operator.value)}` as TranslationKeys,
`filterOperator${capitalize(operator.value)}` as GridTranslationKeys,
)}
</option>
))}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import * as React from 'react';
import TextField, { TextFieldProps } from '@material-ui/core/TextField';
import { GridLoadIcon } from '../../icons/index';
import { FilterInputValueProps } from './FilterInputValueProps';
import { GridFilterInputValueProps } from './GridFilterInputValueProps';

export const SUBMIT_FILTER_STROKE_TIME = 500;

export interface TypeFilterInputValueProps extends FilterInputValueProps {
export interface GridTypeFilterInputValueProps extends GridFilterInputValueProps {
type?: 'text' | 'number' | 'date' | 'datetime-local';
}

export function GridFilterInputValue(props: TypeFilterInputValueProps & TextFieldProps) {
export function GridFilterInputValue(props: GridTypeFilterInputValueProps & TextFieldProps) {
const { item, applyValue, type, apiRef, ...others } = props;
const filterTimeout = React.useRef<any>();
const [filterValueState, setFilterValueState] = React.useState(item.value || '');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { GridFilterItem } from '../../../models/gridFilterItem';

export interface FilterInputValueProps {
export interface GridFilterInputValueProps {
item: GridFilterItem;
applyValue: (value: GridFilterItem) => void;
// Is any because if typed as GridApiRef a dep cycle occurs. Same happens if ApiContext is used.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export * from './GridFilterForm';
export * from './GridFilterInputValue';
export * from './FilterInputValueProps';
export * from './GridFilterInputValueProps';
export * from './GridFilterPanel';
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export interface ColumnMenuState {
export interface GridColumnMenuState {
open: boolean;
field?: string;
id?: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { createSelector } from 'reselect';
import { GridState } from '../core/gridState';
import { ColumnReorderState } from './columnReorderState';
import { GridColumnReorderState } from './columnReorderState';

export const gridColumnReorderSelector = (state: GridState) => state.columnReorder;

export const gridColumnReorderDragColSelector = createSelector<
GridState,
ColumnReorderState,
GridColumnReorderState,
string
>(gridColumnReorderSelector, (columnReorder) => columnReorder.dragCol);
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export interface ColumnReorderState {
export interface GridColumnReorderState {
dragCol: string;
}

export function getInitialGridColumnReorderState(): ColumnReorderState {
export function getInitialGridColumnReorderState(): GridColumnReorderState {
return { dragCol: '' };
}
20 changes: 10 additions & 10 deletions packages/grid/_modules_/grid/hooks/features/core/gridState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ import {
} from '../../../models/gridContainerProps';
import { GridEditRowsModel } from '../../../models/gridEditRowModel';
import { DEFAULT_GRID_OPTIONS, GridOptions } from '../../../models/gridOptions';
import { ColumnMenuState } from '../columnMenu/columnMenuState';
import { GridColumnMenuState } from '../columnMenu/columnMenuState';
import {
ColumnReorderState,
GridColumnReorderState,
getInitialGridColumnReorderState,
} from '../columnReorder/columnReorderState';
import { GridGridDensity, getInitialGridDensityState } from '../density/densityState';
import { FilterModelState, getInitialGridFilterState } from '../filter/FilterModelState';
import { GridFilterModelState, getInitialGridFilterState } from '../filter/gridFilterModelState';
import {
getInitialVisibleGridRowsState,
VisibleGridRowsState,
} from '../filter/visibleGridRowsState';
import { KeyboardState } from '../keyboard/keyboardState';
import { GridKeyboardState } from '../keyboard/gridKeyboardState';
import {
GRID_INITIAL_PAGINATION_STATE,
PaginationState,
GridPaginationState,
} from '../pagination/gridPaginationReducer';
import { GridPreferencePanelState } from '../preferencesPanel/gridPreferencePanelState';
import { getInitialGridRowState, InternalGridRowsState } from '../rows/gridRowsState';
Expand All @@ -34,20 +34,20 @@ import {
export interface GridState {
rows: InternalGridRowsState;
editRows: GridEditRowsModel;
pagination: PaginationState;
pagination: GridPaginationState;
options: GridOptions;
isScrolling: boolean;
columns: GridInternalColumns;
columnReorder: ColumnReorderState;
columnMenu: ColumnMenuState;
columnReorder: GridColumnReorderState;
columnMenu: GridColumnMenuState;
rendering: InternalRenderingState;
containerSizes: GridContainerProps | null;
viewportSizes: GridViewportSizeState;
scrollBar: GridScrollBarState;
sorting: GridSortingState;
keyboard: KeyboardState;
keyboard: GridKeyboardState;
selection: GridSelectionState;
filter: FilterModelState;
filter: GridFilterModelState;
visibleRows: VisibleGridRowsState;
preferencePanel: GridPreferencePanelState;
density: GridGridDensity;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { GridFilterItem, GridLinkOperator } from '../../../models/gridFilterItem';

export interface FilterModelState {
export interface GridFilterModelState {
items: GridFilterItem[];
linkOperator?: GridLinkOperator;
}

export type FilterModel = FilterModelState;
export type GridFilterModel = GridFilterModelState;

export const getInitialGridFilterState: () => FilterModelState = () => ({
export const getInitialGridFilterState: () => GridFilterModelState = () => ({
items: [],
linkOperator: GridLinkOperator.And,
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { GridRowModel } from '../../../models/gridRows';
import { GridState } from '../core/gridState';
import { gridRowCountSelector } from '../rows/gridRowsSelector';
import { sortedGridRowsSelector } from '../sorting/gridSortingSelector';
import { FilterModelState } from './FilterModelState';
import { GridFilterModelState } from './gridFilterModelState';
import { VisibleGridRowsState } from './visibleGridRowsState';

export const visibleGridRowsStateSelector = (state: GridState) => state.visibleRows;
Expand Down Expand Up @@ -34,12 +34,12 @@ export const visibleGridRowCountSelector = createSelector<
return visibleRowsState.visibleRows.length;
});

export const filterGridStateSelector: (state: GridState) => FilterModelState = (state) =>
export const filterGridStateSelector: (state: GridState) => GridFilterModelState = (state) =>
state.filter;

export const activeGridFilterItemsSelector = createSelector<
GridState,
FilterModelState,
GridFilterModelState,
GridFilterItem[]
>(
filterGridStateSelector,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export * from './FilterModelState';
export * from './gridFilterModelState';
export * from './gridFilterSelector';
export * from './useGridFilter';
export * from './visibleGridRowsState';
Loading