Skip to content

Commit

Permalink
Make ref optional in @mui/base
Browse files Browse the repository at this point in the history
  • Loading branch information
Janpot committed Sep 17, 2024
1 parent a5548f5 commit e564fc7
Show file tree
Hide file tree
Showing 19 changed files with 18 additions and 19 deletions.
2 changes: 1 addition & 1 deletion packages/mui-base/src/Badge/Badge.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export type BadgeRootSlotProps = {
children?: React.ReactNode;
className?: string;
ownerState: BadgeOwnerState;
ref: React.Ref<HTMLSpanElement>;
ref?: React.Ref<HTMLSpanElement>;
};

export type BadgeBadgeSlotProps = {
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-base/src/Input/Input.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ export type InputInputSlotProps = Simplify<
ownerState: InputOwnerState;
placeholder: string | undefined;
readOnly: boolean | undefined;
ref: React.Ref<HTMLInputElement>;
ref?: React.Ref<HTMLInputElement>;
type: React.HTMLInputTypeAttribute | undefined;
}
>;
2 changes: 1 addition & 1 deletion packages/mui-base/src/MenuItem/MenuItem.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export type MenuItemRootSlotProps = Simplify<
UseMenuItemRootSlotProps & {
children?: React.ReactNode;
className: string;
ref: React.Ref<HTMLElement>;
ref?: React.Ref<HTMLElement>;
ownerState: MenuItemOwnerState;
}
>;
2 changes: 1 addition & 1 deletion packages/mui-base/src/Option/Option.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export type OptionRootSlotProps<OptionValue> = Simplify<
UseOptionRootSlotProps & {
children?: React.ReactNode;
className: string;
ref: React.Ref<HTMLElement>;
ref?: React.Ref<HTMLElement>;
ownerState: OptionOwnerState<OptionValue>;
}
>;
2 changes: 1 addition & 1 deletion packages/mui-base/src/OptionGroup/OptionGroup.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export type OptionGroupRootSlotProps = {
children?: React.ReactNode;
className?: string;
ownerState: OptionGroupOwnerState;
ref: React.Ref<HTMLLIElement>;
ref?: React.Ref<HTMLLIElement>;
};

export type OptionGroupLabelSlotProps = {
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-base/src/Snackbar/Snackbar.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export type SnackbarRootSlotProps = {
ownerState: SnackbarOwnerState;
className?: string;
children?: React.ReactNode;
ref: React.Ref<any>;
ref?: React.Ref<any>;
};

export interface SnackbarClickAwayListenerSlotProps extends ClickAwayListenerProps {
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-base/src/Tab/Tab.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export type TabOwnerState = Simplify<
export type TabRootSlotProps = Simplify<
UseTabRootSlotProps & {
className?: string;
ref: React.Ref<any>;
ref?: React.Ref<any>;
ownerState: TabOwnerState;
}
>;
2 changes: 1 addition & 1 deletion packages/mui-base/src/useButton/useButton.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export interface UseButtonRootSlotOwnProps {
onKeyUp: MuiCancellableEventHandler<React.KeyboardEvent>;
onMouseDown: React.MouseEventHandler;
onMouseLeave: React.MouseEventHandler;
ref: React.RefCallback<Element> | null;
ref?: React.RefCallback<Element> | null;
}

export type UseButtonRootSlotProps<ExternalProps = {}> = ExternalProps & UseButtonRootSlotOwnProps;
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-base/src/useList/useList.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ interface UseListRootSlotOwnProps {
onBlur: MuiCancellableEventHandler<React.FocusEvent<HTMLElement>>;
onKeyDown: MuiCancellableEventHandler<React.KeyboardEvent<HTMLElement>>;
tabIndex: number;
ref: React.RefCallback<Element> | null;
ref?: React.RefCallback<Element> | null;
}

export type UseListRootSlotProps<ExternalProps = {}> = ExternalProps & UseListRootSlotOwnProps;
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-base/src/useMenu/useMenu.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ interface UseMenuListboxSlotEventHandlers {
export type UseMenuListboxSlotProps<ExternalProps = {}> = UseListRootSlotProps<
Omit<ExternalProps, keyof UseMenuListboxSlotEventHandlers> & UseMenuListboxSlotEventHandlers
> & {
ref: React.RefCallback<Element> | null;
ref?: React.RefCallback<Element> | null;
role: React.AriaRole;
};

Expand Down
2 changes: 1 addition & 1 deletion packages/mui-base/src/useMenuItem/useMenuItem.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { MuiCancellableEventHandler } from '../utils/MuiCancellableEvent';
interface UseMenuItemRootSlotOwnProps {
id: string | undefined;
role: 'menuitem';
ref: React.RefCallback<Element> | null;
ref?: React.RefCallback<Element> | null;
}

export interface MenuItemMetadata {
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-base/src/useSelect/useSelect.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export type UseSelectButtonSlotProps<TOther = {}> = UseButtonRootSlotProps<
'aria-expanded': React.AriaAttributes['aria-expanded'];
'aria-controls': React.AriaAttributes['aria-controls'];
role: React.HTMLAttributes<Element>['role'];
ref: React.RefCallback<Element> | null;
ref?: React.RefCallback<Element> | null;
};

interface UseSelectHiddenInputSlotEventHandlers {
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-base/src/useSlider/useSlider.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export interface Mark {

export type UseSliderRootSlotOwnProps = {
onMouseDown: React.MouseEventHandler;
ref: React.RefCallback<Element> | null;
ref?: React.RefCallback<Element> | null;
};

export type UseSliderRootSlotProps<ExternalProps = {}> = Omit<
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-base/src/useSwitch/useSwitch.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ interface UseSwitchInputSlotOwnProps {
onChange: React.ChangeEventHandler<HTMLInputElement>;
onFocus: React.FocusEventHandler;
readOnly?: boolean;
ref: React.RefCallback<HTMLInputElement> | null;
ref?: React.RefCallback<HTMLInputElement> | null;
required?: boolean;
type: React.HTMLInputTypeAttribute;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-base/src/useTab/useTab.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export type UseTabRootSlotProps<ExternalProps = {}> = UseButtonRootSlotProps<Ext
'aria-controls': React.AriaAttributes['aria-controls'];
'aria-selected': React.AriaAttributes['aria-selected'];
id: string | undefined;
ref: React.RefCallback<Element> | null;
ref?: React.RefCallback<Element> | null;
role: React.AriaRole;
};

Expand Down
2 changes: 1 addition & 1 deletion packages/mui-base/src/useTabsList/useTabsList.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export type UseTabsListRootSlotProps<ExternalProps = {}> = ExternalProps & {
'aria-labelledby'?: React.AriaAttributes['aria-labelledby'];
'aria-orientation'?: React.AriaAttributes['aria-orientation'];
role: React.AriaRole;
ref: React.RefCallback<Element> | null;
ref?: React.RefCallback<Element> | null;
onKeyDown?: React.KeyboardEventHandler<HTMLElement>;
};

Expand Down
1 change: 0 additions & 1 deletion packages/mui-lab/src/Timeline/Timeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ const Timeline = React.forwardRef<HTMLUListElement, TimelineProps>(function Time
<TimelineRoot
className={clsx(classes.root, className)}
ownerState={ownerState}
// @ts-expect-error TypeScript bug, need to keep unknown for DX
ref={ref}
{...other}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ describe('elementAcceptingRef', () => {
it('accepts lazy', async () => {
const Component = React.lazy(() =>
Promise.resolve({
default: React.forwardRef((props, ref) => <div {...props} ref={ref} />),
default: React.forwardRef<HTMLDivElement>((props, ref) => <div {...props} ref={ref} />),
}),
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ describe('elementTypeAcceptingRef', () => {
it('accepts lazy', async () => {
const Component = React.lazy(() =>
Promise.resolve({
default: React.forwardRef((props, ref) => <div ref={ref} {...props} />),
default: React.forwardRef<HTMLDivElement>((props, ref) => <div ref={ref} {...props} />),
}),
);

Expand Down

0 comments on commit e564fc7

Please sign in to comment.