Skip to content

Commit

Permalink
[core] Move warning methods to @mui/x-internals (#14528)
Browse files Browse the repository at this point in the history
Co-authored-by: Lukas <llukas.tyla@gmail.com>
  • Loading branch information
k-rajat19 and LukasTy authored Sep 9, 2024
1 parent 39464cf commit dd98382
Show file tree
Hide file tree
Showing 29 changed files with 25 additions and 101 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import * as React from 'react';
import composeClasses from '@mui/utils/composeClasses';
import { warnOnce } from '@mui/x-internals/warning';
import { useDrawingArea, useXScale } from '../hooks';
import { CommonChartsReferenceLineProps, ReferenceLineRoot } from './common';
import { ChartsText } from '../ChartsText';
import {
ChartsReferenceLineClasses,
getReferenceLineUtilityClass,
} from './chartsReferenceLineClasses';
import { warnOnce } from '../internals/warning';

export type ChartsXReferenceLineProps<
TValue extends string | number | Date = string | number | Date,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import * as React from 'react';
import composeClasses from '@mui/utils/composeClasses';
import { warnOnce } from '@mui/x-internals/warning';
import { useDrawingArea, useYScale } from '../hooks';
import { CommonChartsReferenceLineProps, ReferenceLineRoot } from './common';
import { ChartsText } from '../ChartsText';
import {
ChartsReferenceLineClasses,
getReferenceLineUtilityClass,
} from './chartsReferenceLineClasses';
import { warnOnce } from '../internals/warning';

export type ChartsYReferenceLineProps<
TValue extends string | number | Date = string | number | Date,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
gridExpandedSortedRowIdsSelector,
} from '@mui/x-data-grid';
import {
warnOnce,
getRowIdFromRowModel,
getActiveElement,
GridPipeProcessor,
Expand All @@ -23,6 +22,7 @@ import {
isPasteShortcut,
useGridLogger,
} from '@mui/x-data-grid/internals';
import { warnOnce } from '@mui/x-internals/warning';
import { GRID_DETAIL_PANEL_TOGGLE_FIELD, GRID_REORDER_COL_DEF } from '@mui/x-data-grid-pro';
import { unstable_debounce as debounce } from '@mui/utils';
import { GridApiPremium, GridPrivateApiPremium } from '../../../models/gridApiPremium';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import {
GridValidRowModel,
} from '@mui/x-data-grid-pro';
import {
warnOnce,
GridStateColDef,
GridSingleSelectColDef,
isObject,
GridColumnGroupLookup,
isSingleSelectColDef,
gridHasColSpanSelector,
} from '@mui/x-data-grid/internals';
import { warnOnce } from '@mui/x-internals/warning';
import { ColumnsStylesInterface, GridExcelExportOptions } from '../gridExcelExportInterface';
import { GridPrivateApiPremium } from '../../../../models/gridApiPremium';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
unstable_useEventCallback as useEventCallback,
unstable_useEnhancedEffect as useEnhancedEffect,
} from '@mui/utils';
import { warnOnce } from '@mui/x-internals/warning';
import {
useGridApiEventHandler,
useGridApiOptionHandler,
Expand Down Expand Up @@ -30,7 +31,6 @@ import { useGridApiMethod } from '../../utils/useGridApiMethod';
import { gridEditRowsStateSelector } from './gridEditingSelectors';
import { GridRowId } from '../../../models/gridRows';
import { isPrintableKey, isPasteShortcut } from '../../../utils/keyboardUtils';
import { warnOnce } from '../../../internals/utils/warning';
import { gridRowsDataRowIdToIdLookupSelector } from '../rows/gridRowsSelector';
import { deepClone } from '../../../utils/utils';
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
unstable_useEventCallback as useEventCallback,
unstable_useEnhancedEffect as useEnhancedEffect,
} from '@mui/utils';
import { warnOnce } from '@mui/x-internals/warning';
import {
useGridApiEventHandler,
useGridApiOptionHandler,
Expand Down Expand Up @@ -36,7 +37,6 @@ import {
gridVisibleColumnFieldsSelector,
} from '../columns/gridColumnsSelector';
import { GridCellParams } from '../../../models/params/gridCellParams';
import { warnOnce } from '../../../internals/utils/warning';
import { gridRowsDataRowIdToIdLookupSelector } from '../rows/gridRowsSelector';
import { deepClone } from '../../../utils/utils';
import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { warnOnce } from '@mui/x-internals/warning';
import type { GridColumnGroup, GridCsvExportOptions, GridRowId } from '../../../../models';
import { GRID_CHECKBOX_SELECTION_COL_DEF } from '../../../../colDef';
import type { GridCellParams } from '../../../../models/params/gridCellParams';
import type { GridStateColDef } from '../../../../models/colDef/gridColDef';
import type { GridApiCommunity } from '../../../../models/api/gridApiCommunity';
import { warnOnce } from '../../../../internals/utils/warning';

function sanitizeCellValue(value: unknown, csvOptions: CSVOptions): string {
if (value === null || value === undefined) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as React from 'react';
import { warnOnce } from '@mui/x-internals/warning';
import {
GridColDef,
GridFilterItem,
Expand All @@ -14,7 +15,6 @@ import {
GridFilterItemResult,
GridQuickFilterValueResult,
} from './gridFilterState';
import { warnOnce } from '../../../internals/utils/warning';
import { getPublicApiRef } from '../../../utils/getPublicApiRef';
import {
gridColumnFieldsSelector,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as React from 'react';
import { warnOnce } from '@mui/x-internals/warning';
import { GridSortingModelApplier } from './gridSortingState';
import type { GridRowId, GridTreeNode } from '../../../models';
import { GridApiCommunity } from '../../../models/api/gridApiCommunity';
Expand All @@ -10,7 +11,6 @@ import {
GridSortModel,
GridSortCellParams,
} from '../../../models/gridSortModel';
import { warnOnce } from '../../../internals/utils/warning';

type GridSortingFieldComparator = {
getSortCellParams: (id: GridRowId) => GridSortCellParams;
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 { warnOnce } from '@mui/x-internals/warning';
import type { GridApiCommon } from '../../models/api/gridApiCommon';
import { OutputSelector, OutputSelectorV8 } from '../../utils/createSelector';
import { useLazyRef } from './useLazyRef';
import { useOnMount } from './useOnMount';
import { warnOnce } from '../../internals/utils/warning';
import type { GridCoreApi } from '../../models/api/gridCoreApi';

function isOutputSelector<Api extends GridApiCommon, T>(
Expand Down
1 change: 0 additions & 1 deletion packages/x-data-grid/src/internals/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export * from './computeSlots';
export * from './useProps';
export * from './propValidation';
export * from './warning';
2 changes: 1 addition & 1 deletion packages/x-data-grid/src/internals/utils/propValidation.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { warnOnce } from './warning';
import { warnOnce } from '@mui/x-internals/warning';
import { isNumber } from '../../utils/utils';
import { DataGridProcessedProps } from '../../models/props/DataGridProps';
import { GridSignature } from '../../hooks/utils/useGridApiEventHandler';
Expand Down
25 changes: 0 additions & 25 deletions packages/x-data-grid/src/internals/utils/warning.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/x-data-grid/src/utils/createSelector.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import { lruMemoize, createSelectorCreator, Selector, SelectorResultArray } from 'reselect';
import { warnOnce } from '@mui/x-internals/warning';
import type { GridCoreApi } from '../models/api/gridCoreApi';
import { warnOnce } from '../internals/utils/warning';

type CacheKey = { id: number };

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import {
PickerSelectionState,
useNow,
DEFAULT_DESKTOP_MODE_MEDIA_QUERY,
warnOnce,
useControlledValueWithTimezone,
useViews,
} from '@mui/x-date-pickers/internals';
import { warnOnce } from '@mui/x-internals/warning';
import { PickerValidDate } from '@mui/x-date-pickers/models';
import { getReleaseInfo } from '../internals/utils/releaseInfo';
import {
Expand Down
2 changes: 1 addition & 1 deletion packages/x-date-pickers/src/AdapterDayjs/AdapterDayjs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import customParseFormatPlugin from 'dayjs/plugin/customParseFormat';
import localizedFormatPlugin from 'dayjs/plugin/localizedFormat';
import isBetweenPlugin from 'dayjs/plugin/isBetween';
import advancedFormatPlugin from 'dayjs/plugin/advancedFormat';
import { warnOnce } from '@mui/x-internals/warning';
import {
FieldFormatTokenMap,
MuiPickersAdapter,
Expand All @@ -13,7 +14,6 @@ import {
PickersTimezone,
DateBuilderReturnType,
} from '../models';
import { warnOnce } from '../internals/utils/warning';

defaultDayjs.extend(localizedFormatPlugin);
defaultDayjs.extend(weekOfYearPlugin);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { warnOnce } from '@mui/x-internals/warning';
import { UsePickerParams, UsePickerProps, UsePickerResponse } from './usePicker.types';
import { usePickerValue } from './usePickerValue';
import { usePickerViews } from './usePickerViews';
import { usePickerLayoutProps } from './usePickerLayoutProps';
import { InferError } from '../useValidation';
import { warnOnce } from '../../utils/warning';
import { FieldSection, PickerValidDate } from '../../../models';
import { DateOrTimeViewWithMeridiem } from '../../models';

Expand Down
1 change: 0 additions & 1 deletion packages/x-date-pickers/src/internals/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ export { validateDate } from './utils/validation/validateDate';
export { validateDateTime } from './utils/validation/validateDateTime';
export { validateTime } from './utils/validation/validateTime';
export { applyDefaultViewProps } from './utils/views';
export { warnOnce } from './utils/warning';

export { DayCalendar } from '../DateCalendar/DayCalendar';
export type {
Expand Down
25 changes: 0 additions & 25 deletions packages/x-date-pickers/src/internals/utils/warning.ts

This file was deleted.

1 change: 1 addition & 0 deletions packages/x-internals/src/warning/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { warnOnce, clearWarningsCache } from './warning';
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const warnedOnceCache = new Set();

// TODO move to @mui/x-internals
// TODO eventually move to @base_ui/internals. Base UI, etc. too need this helper.
// TODO move to @base_ui/internals. Base UI, etc. need this helper.
export function warnOnce(message: string | string[], gravity: 'warning' | 'error' = 'warning') {
if (process.env.NODE_ENV === 'production') {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import composeClasses from '@mui/utils/composeClasses';
import { useLicenseVerifier, Watermark } from '@mui/x-license';
import useSlotProps from '@mui/utils/useSlotProps';
import { TreeItem, TreeItemProps } from '@mui/x-tree-view/TreeItem';
import { useTreeView, TreeViewProvider, warnOnce } from '@mui/x-tree-view/internals';
import { useTreeView, TreeViewProvider } from '@mui/x-tree-view/internals';
import { warnOnce } from '@mui/x-internals/warning';
import { styled, createUseThemeProps } from '../internals/zero-styled';
import { getRichTreeViewProUtilityClass } from './richTreeViewProClasses';
import { RichTreeViewProProps } from './RichTreeViewPro.types';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from 'react';
import { warnOnce, TreeViewPlugin } from '@mui/x-tree-view/internals';
import { TreeViewPlugin } from '@mui/x-tree-view/internals';
import { warnOnce } from '@mui/x-internals/warning';
import { TreeViewItemsReorderingAction } from '@mui/x-tree-view/models';
import {
TreeViewItemItemReorderingValidActions,
Expand Down
2 changes: 1 addition & 1 deletion packages/x-tree-view/src/RichTreeView/RichTreeView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import * as React from 'react';
import PropTypes from 'prop-types';
import composeClasses from '@mui/utils/composeClasses';
import useSlotProps from '@mui/utils/useSlotProps';
import { warnOnce } from '@mui/x-internals/warning';
import { getRichTreeViewUtilityClass } from './richTreeViewClasses';
import { RichTreeViewProps } from './RichTreeView.types';
import { styled, createUseThemeProps } from '../internals/zero-styled';
import { useTreeView } from '../internals/useTreeView';
import { TreeViewProvider } from '../internals/TreeViewProvider';
import { RICH_TREE_VIEW_PLUGINS, RichTreeViewPluginSignatures } from './RichTreeView.plugins';
import { TreeItem, TreeItemProps } from '../TreeItem';
import { warnOnce } from '../internals/utils/warning';

const useThemeProps = createUseThemeProps('MuiRichTreeView');

Expand Down
2 changes: 1 addition & 1 deletion packages/x-tree-view/src/SimpleTreeView/SimpleTreeView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import * as React from 'react';
import PropTypes from 'prop-types';
import composeClasses from '@mui/utils/composeClasses';
import useSlotProps from '@mui/utils/useSlotProps';
import { warnOnce } from '@mui/x-internals/warning';
import { styled, createUseThemeProps } from '../internals/zero-styled';
import { getSimpleTreeViewUtilityClass } from './simpleTreeViewClasses';
import { SimpleTreeViewProps } from './SimpleTreeView.types';
import { useTreeView } from '../internals/useTreeView';
import { TreeViewProvider } from '../internals/TreeViewProvider';
import { SIMPLE_TREE_VIEW_PLUGINS, SimpleTreeViewPluginSignatures } from './SimpleTreeView.plugins';
import { warnOnce } from '../internals/utils/warning';

const useThemeProps = createUseThemeProps('MuiSimpleTreeView');

Expand Down
1 change: 0 additions & 1 deletion packages/x-tree-view/src/internals/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,3 @@ export type {
} from './plugins/useTreeViewJSXItems';

export { isTargetInDescendants } from './utils/tree';
export { warnOnce } from './utils/warning';
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { warnOnce } from '../../utils/warning';
import { warnOnce } from '@mui/x-internals/warning';
import { TreeViewPlugin } from '../../models';
import { TreeViewItemId } from '../../../models';
import { UseTreeViewLabelSignature } from './useTreeViewLabel.types';
Expand Down
25 changes: 0 additions & 25 deletions packages/x-tree-view/src/internals/utils/warning.ts

This file was deleted.

2 changes: 1 addition & 1 deletion test/utils/mochaHooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { unstable_resetCleanupTracking as unstable_resetCleanupTrackingDataGrid
import { unstable_resetCleanupTracking as unstable_resetCleanupTrackingDataGridPro } from '@mui/x-data-grid-pro';
import { unstable_resetCleanupTracking as unstable_resetCleanupTrackingTreeView } from '@mui/x-tree-view';
import { unstable_cleanupDOM as unstable_cleanupDOMCharts } from '@mui/x-charts/internals';
import { clearWarningsCache } from '@mui/x-data-grid/internals';
import { clearWarningsCache } from '@mui/x-internals/warning';
import { generateTestLicenseKey, setupTestLicenseKey } from './testLicense';

export function createXMochaHooks(coreMochaHooks = {}) {
Expand Down

1 comment on commit dd98382

@mdkausar001
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi MUI Team,

I'm an experienced software engineer with 5 years of experience in software development. I’m very interested in contributing to the MUI project and would like to explore opportunities to join the team as a maintainer. I have a strong background in front-end development, including working with React and component libraries, which I believe aligns well with MUI's goals and needs.

Please let me know if there are specific areas where I can contribute or any steps I need to take to get started. I look forward to the opportunity to collaborate with the team and support the continued development of MUI.

Thank you!

Mohammad Sharib Kausar
Email : mohammadkausardev@gmail.com

Please sign in to comment.