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

[internals] Move utils needed for tree view virtualization to shared package #14202

Merged
merged 2 commits into from
Aug 14, 2024
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
Expand Up @@ -6,6 +6,7 @@ import {
unstable_composeClasses as composeClasses,
unstable_capitalize as capitalize,
} from '@mui/utils';
import { fastMemo } from '@mui/x-internals/fastMemo';
import {
GridFilterItem,
GridFilterOperator,
Expand All @@ -19,7 +20,6 @@ import {
GridPinnedColumnPosition,
} from '@mui/x-data-grid';
import {
fastMemo,
GridStateColDef,
useGridPrivateApiContext,
gridHeaderFilteringEditFieldSelector,
Expand Down
2 changes: 1 addition & 1 deletion packages/x-data-grid/src/components/GridColumnHeaders.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import PropTypes from 'prop-types';
import { fastMemo } from '../utils/fastMemo';
import { fastMemo } from '@mui/x-internals/fastMemo';
import {
useGridColumnHeaders,
UseGridColumnHeadersProps,
Expand Down
2 changes: 1 addition & 1 deletion packages/x-data-grid/src/components/GridHeaders.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { fastMemo } from '../utils/fastMemo';
import { fastMemo } from '@mui/x-internals/fastMemo';
import { useGridPrivateApiContext } from '../hooks/utils/useGridPrivateApiContext';
import { useGridSelector } from '../hooks/utils/useGridSelector';
import { useGridRootProps } from '../hooks/utils/useGridRootProps';
Expand Down
2 changes: 1 addition & 1 deletion packages/x-data-grid/src/components/GridRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import PropTypes from 'prop-types';
import clsx from 'clsx';
import { unstable_useForkRef as useForkRef } from '@mui/utils';
import { fastMemo } from '../utils/fastMemo';
import { fastMemo } from '@mui/x-internals/fastMemo';
import { GridRowEventLookup } from '../models/events';
import { GridRowId, GridRowModel } from '../models/gridRows';
import { GridEditModes, GridRowModes, GridCellModes } from '../models/gridEditRowModel';
Expand Down
2 changes: 1 addition & 1 deletion packages/x-data-grid/src/components/GridScrollArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
unstable_useEventCallback as useEventCallback,
} from '@mui/utils';
import { styled } from '@mui/system';
import { fastMemo } from '@mui/x-internals/fastMemo';
import { DataGridProcessedProps } from '../models/props/DataGridProps';
import { useGridRootProps } from '../hooks/utils/useGridRootProps';
import { getDataGridUtilityClass, gridClasses } from '../constants';
Expand All @@ -18,7 +19,6 @@ import { GridScrollParams } from '../models/params/gridScrollParams';
import { GridEventListener } from '../models/events';
import { useTimeout } from '../hooks/utils/useTimeout';
import { getTotalHeaderHeight } from '../hooks/features/columns/gridColumnsUtils';
import { fastMemo } from '../utils/fastMemo';

const CLIFF = 1;
const SLOP = 1.5;
Expand Down
2 changes: 1 addition & 1 deletion packages/x-data-grid/src/components/cell/GridCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {
unstable_ownerDocument as ownerDocument,
unstable_capitalize as capitalize,
} from '@mui/utils';
import { fastMemo } from '@mui/x-internals/fastMemo';
import type { GridApiCommunity } from '../../internals';
import { fastMemo } from '../../utils/fastMemo';
import { doesSupportPreventScroll } from '../../utils/doesSupportPreventScroll';
import { getDataGridUtilityClass, gridClasses } from '../../constants/gridClasses';
import {
Expand Down
4 changes: 2 additions & 2 deletions packages/x-data-grid/src/components/cell/GridSkeletonCell.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import * as React from 'react';
import PropTypes from 'prop-types';
import clsx from 'clsx';
import Skeleton from '@mui/material/Skeleton';
import {
unstable_composeClasses as composeClasses,
unstable_capitalize as capitalize,
} from '@mui/utils';
import clsx from 'clsx';
import { fastMemo } from '../../utils/fastMemo';
import { fastMemo } from '@mui/x-internals/fastMemo';
import { createRandomNumberGenerator } from '../../utils/utils';
import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
import { getDataGridUtilityClass } from '../../constants/gridClasses';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import PropTypes from 'prop-types';
import clsx from 'clsx';
import { unstable_composeClasses as composeClasses, unstable_useId as useId } from '@mui/utils';
import { fastMemo } from '../../utils/fastMemo';
import { fastMemo } from '@mui/x-internals/fastMemo';
import { GridStateColDef } from '../../models/colDef/gridColDef';
import { GridSortDirection } from '../../models/gridSortModel';
import { useGridPrivateApiContext } from '../../hooks/utils/useGridPrivateApiContext';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { styled } from '@mui/system';
import { fastMemo } from '../../utils/fastMemo';
import { fastMemo } from '@mui/x-internals/fastMemo';
import { useGridSelector } from '../../hooks/utils/useGridSelector';
import { useGridApiContext } from '../../hooks/utils/useGridApiContext';
import { gridDimensionsSelector } from '../../hooks/features/dimensions';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
unstable_useEventCallback as useEventCallback,
unstable_ownerWindow as ownerWindow,
} from '@mui/utils';
import { throttle } from '@mui/x-internals/throttle';
import { GridEventListener } from '../../../models/events';
import { ElementSize } from '../../../models';
import { GridPrivateApiCommunity } from '../../../models/api/gridApiCommunity';
Expand All @@ -13,7 +14,6 @@ import {
useGridApiOptionHandler,
} from '../../utils/useGridApiEventHandler';
import { useGridApiMethod } from '../../utils/useGridApiMethod';
import { throttle } from '../../../utils/throttle';
import { useGridLogger } from '../../utils/useGridLogger';
import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
import { GridDimensions, GridDimensionsApi, GridDimensionsPrivateApi } from './gridDimensionsApi';
Expand Down
2 changes: 1 addition & 1 deletion packages/x-data-grid/src/hooks/utils/useGridSelector.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import * as React from 'react';
import { fastObjectShallowCompare } from '@mui/x-internals/fastObjectShallowCompare';
import type { GridApiCommon } from '../../models/api/gridApiCommon';
import { OutputSelector } from '../../utils/createSelector';
import { useLazyRef } from './useLazyRef';
import { useOnMount } from './useOnMount';
import { warnOnce } from '../../internals/utils/warning';
import { fastObjectShallowCompare } from '../../utils/fastObjectShallowCompare';

function isOutputSelector<Api extends GridApiCommon, T>(
selector: any,
Expand Down
1 change: 0 additions & 1 deletion packages/x-data-grid/src/internals/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ export {
} from '../utils/domUtils';
export { isNavigationKey, isPasteShortcut } from '../utils/keyboardUtils';
export * from '../utils/utils';
export * from '../utils/fastMemo';
export { exportAs } from '../utils/exportAs';
export * from '../utils/getPublicApiRef';
export * from '../utils/cellBorderUtils';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { fastObjectShallowCompare } from './fastObjectShallowCompare';
import { fastObjectShallowCompare } from '../fastObjectShallowCompare';

export function fastMemo<T>(component: T): T {
return React.memo(component as any, fastObjectShallowCompare) as unknown as T;
Expand Down
1 change: 1 addition & 0 deletions packages/x-internals/src/fastMemo/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { fastMemo } from './fastMemo';
1 change: 1 addition & 0 deletions packages/x-internals/src/fastObjectShallowCompare/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { fastObjectShallowCompare } from './fastObjectShallowCompare';
1 change: 1 addition & 0 deletions packages/x-internals/src/throttle/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { throttle } from './throttle';