Skip to content

Commit

Permalink
Fix MuiPopper styleOverrides missing type issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Irtiza751 committed Oct 1, 2023
1 parent ed315c5 commit dd487db
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
17 changes: 17 additions & 0 deletions packages/mui-material/src/Popper/popperClasses.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { unstable_generateUtilityClasses as generateUtilityClasses } from '@mui/utils';
import generateUtilityClass from '../generateUtilityClass';

export interface PopperClasses {
/** Styles applied to the root element. */
root: string;
}

export type PopperClassKey = keyof PopperClasses;

export function getPopperUtilityClass(slot: string): string {
return generateUtilityClass('MuiPopper', slot);
}

const popperClasses: PopperClasses = generateUtilityClasses('MuiPopper', ['root']);

export default popperClasses;
2 changes: 2 additions & 0 deletions packages/mui-material/src/styles/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,8 @@ export interface Components<Theme = unknown> {
};
MuiPopper?: {
defaultProps?: ComponentsProps['MuiPopper'];
styleOverrides?: ComponentsOverrides<Theme>['MuiPopper'];
variants?: ComponentsVariants['MuiPopper'];
};
MuiPopover?: {
defaultProps?: ComponentsProps['MuiPopover'];
Expand Down
14 changes: 8 additions & 6 deletions packages/mui-material/src/styles/overrides.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ import { ToolbarClassKey } from '../Toolbar';
import { TooltipClassKey } from '../Tooltip';
import { TouchRippleClassKey } from '../ButtonBase/TouchRipple';
import { TypographyClassKey } from '../Typography';
import { PopperClassKey } from '@mui/base';

export type OverridesStyleRules<
ClassKey extends string = string,
Expand All @@ -123,12 +124,12 @@ export type OverridesStyleRules<
ClassKey,
| CSSInterpolation
| ((
// Record<string, unknown> is for other props that the slot receive internally
// Documenting all ownerStates could be a huge work, let's wait until we have a real needs from developers.
props: (ComponentName extends keyof ComponentsPropsList
? { ownerState: ComponentsPropsList[ComponentName] & Record<string, unknown> }
: {}) & { theme: Theme } & Record<string, unknown>,
) => CSSInterpolation)
// Record<string, unknown> is for other props that the slot receive internally
// Documenting all ownerStates could be a huge work, let's wait until we have a real needs from developers.
props: (ComponentName extends keyof ComponentsPropsList
? { ownerState: ComponentsPropsList[ComponentName] & Record<string, unknown> }
: {}) & { theme: Theme } & Record<string, unknown>,
) => CSSInterpolation)
>;

export type ComponentsOverrides<Theme = unknown> = {
Expand Down Expand Up @@ -214,6 +215,7 @@ export interface ComponentNameToClassKey {
MuiPagination: PaginationClassKey;
MuiPaginationItem: PaginationItemClassKey;
MuiPaper: PaperClassKey;
MuiPopper: PopperClassKey;
MuiPopover: PopoverClassKey;
MuiRadio: RadioClassKey;
MuiRating: RatingClassKey;
Expand Down

0 comments on commit dd487db

Please sign in to comment.