Skip to content

Commit

Permalink
[core] Fix missing context display names
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Feb 18, 2024
1 parent f0caa3d commit 7d11e16
Show file tree
Hide file tree
Showing 26 changed files with 110 additions and 5 deletions.
4 changes: 4 additions & 0 deletions packages/mui-base/src/Unstable_Popup/PopupContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ export interface PopupContextValue {
}

export const PopupContext = React.createContext<PopupContextValue | null>(null);

if (process.env.NODE_ENV !== 'production') {
PopupContext.displayName = 'PopupContext';
}
4 changes: 3 additions & 1 deletion packages/mui-base/src/useCompound/useCompoundParent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ export const CompoundComponentContext = React.createContext<CompoundComponentCon
any
> | null>(null);

CompoundComponentContext.displayName = 'CompoundComponentContext';
if (process.env.NODE_ENV !== 'production') {
CompoundComponentContext.displayName = 'CompoundComponentContext';
}

export interface UseCompoundParentReturnValue<Key, Subitem extends { ref: React.RefObject<Node> }> {
/**
Expand Down
4 changes: 4 additions & 0 deletions packages/mui-base/src/useDropdown/DropdownContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@ export interface DropdownContextValue {

const DropdownContext = React.createContext<DropdownContextValue | null>(null);

if (process.env.NODE_ENV !== 'production') {
DropdownContext.displayName = 'DropdownContext';
}

export { DropdownContext };
1 change: 1 addition & 0 deletions packages/mui-base/src/useList/ListContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export interface ListContextValue<ItemValue> {
}

export const ListContext = React.createContext<ListContextValue<any> | null>(null);

if (process.env.NODE_ENV !== 'production') {
ListContext.displayName = 'ListContext';
}
4 changes: 4 additions & 0 deletions packages/mui-base/src/useTransition/TransitionContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,7 @@ export type TransitionContextValue = {
};

export const TransitionContext = React.createContext<TransitionContextValue | null>(null);

if (process.env.NODE_ENV !== 'production') {
TransitionContext.displayName = 'TransitionContext';
}
4 changes: 4 additions & 0 deletions packages/mui-base/src/utils/ClassNameConfigurator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ const defaultContextValue: ClassNameConfiguration = {
const ClassNameConfiguratorContext =
React.createContext<ClassNameConfiguration>(defaultContextValue);

if (process.env.NODE_ENV !== 'production') {
ClassNameConfiguratorContext.displayName = 'ClassNameConfiguratorContext';
}

export interface ClassNameConfiguratorProps extends Partial<ClassNameConfiguration> {
children?: React.ReactNode;
}
Expand Down
4 changes: 4 additions & 0 deletions packages/mui-joy/src/AvatarGroup/AvatarGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ import useSlot from '../utils/useSlot';

export const AvatarGroupContext = React.createContext<AvatarGroupOwnerState | undefined>(undefined);

if (process.env.NODE_ENV !== 'production') {
AvatarGroupContext.displayName = 'AvatarGroupContext';
}

const useUtilityClasses = () => {
const slots = {
root: ['root'],
Expand Down
4 changes: 4 additions & 0 deletions packages/mui-joy/src/Chip/ChipContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@ const ChipColorContext = React.createContext<Pick<ChipProps, 'disabled' | 'varia
color: undefined,
});

if (process.env.NODE_ENV !== 'production') {
ChipColorContext.displayName = 'ChipColorContext';
}

export default ChipColorContext;
4 changes: 4 additions & 0 deletions packages/mui-joy/src/FormControl/FormControlContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,8 @@ export type FormControlContextValue =

const FormControlContext = React.createContext<FormControlContextValue>(undefined);

if (process.env.NODE_ENV !== 'production') {
FormControlContext.displayName = 'FormControlContext';
}

export default FormControlContext;
4 changes: 4 additions & 0 deletions packages/mui-joy/src/List/ComponentListContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@ import * as React from 'react';

const ComponentListContext = React.createContext<string | undefined>(undefined);

if (process.env.NODE_ENV !== 'production') {
ComponentListContext.displayName = 'ComponentListContext';
}

export default ComponentListContext;
4 changes: 4 additions & 0 deletions packages/mui-joy/src/List/GroupListContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@ import * as React from 'react';

const GroupListContext = React.createContext<undefined | 'menu' | 'select'>(undefined);

if (process.env.NODE_ENV !== 'production') {
GroupListContext.displayName = 'GroupListContext';
}

export default GroupListContext;
4 changes: 4 additions & 0 deletions packages/mui-joy/src/List/NestedListContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@ import * as React from 'react';

const NestedListContext = React.createContext<boolean | string>(false);

if (process.env.NODE_ENV !== 'production') {
NestedListContext.displayName = 'NestedListContext';
}

export default NestedListContext;
4 changes: 4 additions & 0 deletions packages/mui-joy/src/List/RowListContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@ import * as React from 'react';

const RowListContext = React.createContext(false);

if (process.env.NODE_ENV !== 'production') {
RowListContext.displayName = 'RowListContext';
}

export default RowListContext;
4 changes: 4 additions & 0 deletions packages/mui-joy/src/List/WrapListContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@ import * as React from 'react';

const WrapListContext = React.createContext(false);

if (process.env.NODE_ENV !== 'production') {
WrapListContext.displayName = 'WrapListContext';
}

export default WrapListContext;
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ const ListItemButtonOrientationContext = React.createContext<'horizontal' | 'ver
'horizontal',
);

if (process.env.NODE_ENV !== 'production') {
ListItemButtonOrientationContext.displayName = 'ListItemButtonOrientationContext';
}

export default ListItemButtonOrientationContext;
4 changes: 4 additions & 0 deletions packages/mui-joy/src/ListSubheader/ListSubheaderContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ const ListSubheaderDispatch = React.createContext<
undefined | React.Dispatch<React.SetStateAction<string>>
>(undefined);

if (process.env.NODE_ENV !== 'production') {
ListSubheaderDispatch.displayName = 'ListSubheaderDispatch';
}

export default ListSubheaderDispatch;
4 changes: 4 additions & 0 deletions packages/mui-joy/src/Modal/CloseModalContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@ import { ModalProps } from './ModalProps';

const CloseModalContext = React.createContext<undefined | ModalProps['onClose']>(undefined);

if (process.env.NODE_ENV !== 'production') {
CloseModalContext.displayName = 'CloseModalContext';
}

export default CloseModalContext;
4 changes: 4 additions & 0 deletions packages/mui-joy/src/ModalDialog/ModalDialogSizeContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@ import { ModalDialogProps } from './ModalDialogProps';

const ModalDialogSizeContext = React.createContext<undefined | ModalDialogProps['size']>(undefined);

if (process.env.NODE_ENV !== 'production') {
ModalDialogSizeContext.displayName = 'ModalDialogSizeContext';
}

export default ModalDialogSizeContext;
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ const ModalDialogVariantColorContext = React.createContext<
| (Pick<ModalDialogProps, 'variant' | 'color'> & { labelledBy?: string; describedBy?: string })
>(undefined);

if (process.env.NODE_ENV !== 'production') {
ModalDialogVariantColorContext.displayName = 'ModalDialogVariantColorContext';
}

export default ModalDialogVariantColorContext;
4 changes: 4 additions & 0 deletions packages/mui-joy/src/Tabs/SizeTabsContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@ import { TabsProps } from './TabsProps';

const SizeTabsContext = React.createContext<Exclude<TabsProps['size'], undefined>>('md');

if (process.env.NODE_ENV !== 'production') {
SizeTabsContext.displayName = 'SizeTabsContext';
}

export default SizeTabsContext;
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@ const ToggleButtonGroupContext = React.createContext<ToggleButtonGroupContextTyp
undefined,
);

if (process.env.NODE_ENV !== 'production') {
ToggleButtonGroupContext.displayName = 'ToggleButtonGroupContext';
}

export default ToggleButtonGroupContext;
8 changes: 8 additions & 0 deletions packages/mui-joy/src/Typography/Typography.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ import { TypographySystem } from '../styles/types';
*/
export const TypographyNestedContext = React.createContext(false);

if (process.env.NODE_ENV !== 'production') {
TypographyNestedContext.displayName = 'TypographyNestedContext';
}

/**
* @internal
* Typography's level will be inherit within this context unless an explicit `level` prop is provided.
Expand All @@ -30,6 +34,10 @@ export const TypographyNestedContext = React.createContext(false);
*/
export const TypographyInheritContext = React.createContext(false);

if (process.env.NODE_ENV !== 'production') {
TypographyInheritContext.displayName = 'TypographyInheritContext';
}

const useUtilityClasses = (ownerState: TypographyOwnerState) => {
const { gutterBottom, noWrap, level, color, variant } = ownerState;

Expand Down
4 changes: 4 additions & 0 deletions packages/mui-joy/src/styles/variantColorInheritance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import { ColorPaletteProp, VariantProp } from '@mui/joy/styles/types';

const VariantColorContext = React.createContext<string | undefined>(undefined);

if (process.env.NODE_ENV !== 'production') {
VariantColorContext.displayName = 'VariantColorContext';
}

/**
* @internal For internal usage only.
*
Expand Down
4 changes: 4 additions & 0 deletions packages/mui-material-next/src/Tabs/TabsListContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@ import * as React from 'react';

const TabsListContext = React.createContext(null);

if (process.env.NODE_ENV !== 'production') {
TabsListContext.displayName = 'TabsListContext';
}

export default TabsListContext;
14 changes: 10 additions & 4 deletions packages/mui-system/src/Unstable_Grid/createGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ export default function createGrid(
componentName = 'MuiGrid',
} = options;

const OverflowContext = React.createContext<boolean | undefined>(undefined);
const GridOverflowContext = React.createContext<boolean | undefined>(undefined);

if (process.env.NODE_ENV !== 'production') {
GridOverflowContext.displayName = 'GridOverflowContext';
}

const useUtilityClasses = (ownerState: GridOwnerState, theme: typeof defaultTheme) => {
const { container, direction, spacing, wrap, gridSize } = ownerState;
Expand Down Expand Up @@ -91,7 +95,7 @@ export default function createGrid(
const theme = useTheme();
const themeProps = useThemeProps<typeof inProps & { component?: React.ElementType }>(inProps);
const props = extendSxProp(themeProps) as Omit<typeof themeProps, 'color'> & GridOwnerState; // `color` type conflicts with html color attribute.
const overflow = React.useContext(OverflowContext);
const overflow = React.useContext(GridOverflowContext);
const {
className,
children,
Expand Down Expand Up @@ -171,11 +175,13 @@ export default function createGrid(
);

if (disableEqualOverflow !== undefined && disableEqualOverflow !== (overflow ?? false)) {
// There are 2 possibilities that should wrap with the OverflowContext to communicate with the nested grids:
// There are 2 possibilities that should wrap with the GridOverflowContext to communicate with the nested grids:
// 1. It is the root grid with `disableEqualOverflow`.
// 2. It is a nested grid with different `disableEqualOverflow` from the context.
result = (
<OverflowContext.Provider value={disableEqualOverflow}>{result}</OverflowContext.Provider>
<GridOverflowContext.Provider value={disableEqualOverflow}>
{result}
</GridOverflowContext.Provider>
);
}

Expand Down
4 changes: 4 additions & 0 deletions packages/mui-system/src/cssVars/createCssVarsProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ export default function createCssVarsProvider(options) {
}
const ColorSchemeContext = React.createContext(undefined);

if (process.env.NODE_ENV !== 'production') {
ColorSchemeContext.displayName = 'ColorSchemeContext';
}

const useColorScheme = () => {
const value = React.useContext(ColorSchemeContext);
if (!value) {
Expand Down

0 comments on commit 7d11e16

Please sign in to comment.