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

[base] Improve some types #33270

Merged
merged 1 commit into from Jun 23, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -36,8 +36,12 @@ const FormControlUnstyledTest = () => (
);

function Root(props: FormControlUnstyledRootSlotProps) {
const { ownerState, ...other } = props;
return <div data-filled={ownerState.filled} {...other} />;
const { ownerState, children, ...other } = props;
return (
<div data-filled={ownerState.filled} {...other}>
{children as React.ReactNode}
</div>
);
}

const StyledFormControl = <FormControlUnstyled components={{ Root }} />;
2 changes: 1 addition & 1 deletion packages/mui-base/src/InputUnstyled/useInput.ts
Expand Up @@ -61,7 +61,7 @@ export default function useInput(parameters: UseInputParameters) {

const { current: isControlled } = React.useRef(value != null);

const handleInputRefWarning = React.useCallback((instance) => {
const handleInputRefWarning = React.useCallback((instance: HTMLElement) => {
if (process.env.NODE_ENV !== 'production') {
if (instance && instance.nodeName !== 'INPUT' && !instance.focus) {
console.error(
Expand Down
4 changes: 2 additions & 2 deletions packages/mui-base/src/MenuUnstyled/useMenu.ts
Expand Up @@ -51,15 +51,15 @@ export default function useMenu(parameters: UseMenuParameters = {}) {
const listboxRef = React.useRef<HTMLElement | null>(null);
const handleRef = useForkRef(listboxRef, listboxRefProp);

const registerItem = React.useCallback((id, metadata) => {
const registerItem = React.useCallback((id: string, metadata: MenuItemMetadata) => {
setMenuItems((previousState) => {
const newState = { ...previousState };
newState[id] = metadata;
return newState;
});
}, []);

const unregisterItem = React.useCallback((id) => {
const unregisterItem = React.useCallback((id: string) => {
setMenuItems((previousState) => {
const newState = { ...previousState };
delete newState[id];
Expand Down
Expand Up @@ -77,7 +77,7 @@ export type MultiSelectUnstyledListboxSlotProps<TValue> = Simplify<

export type MultiSelectUnstyledPopperSlotProps<TValue> = {
anchorEl: PopperUnstyledProps['anchorEl'];
children?: React.ReactNode;
children?: PopperUnstyledProps['children'];
className: string | undefined;
disablePortal: PopperUnstyledProps['disablePortal'];
open: boolean;
Expand Down
Expand Up @@ -106,7 +106,7 @@ export type SelectUnstyledListboxSlotProps<TValue> = Simplify<

export type SelectUnstyledPopperSlotProps<TValue> = {
anchorEl: PopperUnstyledProps['anchorEl'];
children?: React.ReactNode;
children?: PopperUnstyledProps['children'];
className: string | undefined;
disablePortal: PopperUnstyledProps['disablePortal'];
open: boolean;
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-base/src/TabsUnstyled/TabsUnstyled.types.ts
Expand Up @@ -50,7 +50,7 @@ export interface TabsUnstyledOwnProps {
/**
* Callback invoked when new value is being set.
*/
onChange?: (event: React.SyntheticEvent, value: number | string) => void;
onChange?: (event: React.SyntheticEvent, value: number | string | boolean) => void;
/**
* If `true` the selected tab changes on focus. Otherwise it only
* changes on activation.
Expand Down
4 changes: 2 additions & 2 deletions packages/mui-base/src/TabsUnstyled/useTabs.ts
Expand Up @@ -24,7 +24,7 @@ export interface UseTabsParameters {
/**
* Callback invoked when new value is being set.
*/
onChange?: (event: React.SyntheticEvent, value: number | string) => void;
onChange?: (event: React.SyntheticEvent, value: number | string | boolean) => void;
/**
* If `true` the selected tab changes on focus. Otherwise it only
* changes on activation.
Expand Down Expand Up @@ -52,7 +52,7 @@ const useTabs = (parameters: UseTabsParameters) => {
const idPrefix = useId();

const onSelected = React.useCallback(
(e, newValue) => {
(e: React.SyntheticEvent, newValue: string | number | false) => {
setValue(newValue);
if (onChange) {
onChange(e, newValue);
Expand Down