diff --git a/docs/pages/base-ui/api/use-autocomplete.json b/docs/pages/base-ui/api/use-autocomplete.json index bde54693aa8ba3..2e844c577d7da4 100644 --- a/docs/pages/base-ui/api/use-autocomplete.json +++ b/docs/pages/base-ui/api/use-autocomplete.json @@ -1,7 +1,7 @@ { "parameters": { "options": { - "type": { "name": "ReadonlyArray<T>", "description": "ReadonlyArray<T>" }, + "type": { "name": "ReadonlyArray<Value>", "description": "ReadonlyArray<Value>" }, "required": true }, "autoComplete": { "type": { "name": "boolean", "description": "boolean" }, "default": "false" }, @@ -28,8 +28,8 @@ "componentName": { "type": { "name": "string", "description": "string" } }, "defaultValue": { "type": { - "name": "AutocompleteValue<T, Multiple, DisableClearable, FreeSolo>", - "description": "AutocompleteValue<T, Multiple, DisableClearable, FreeSolo>" + "name": "AutocompleteValue<Value, Multiple, DisableClearable, FreeSolo>", + "description": "AutocompleteValue<Value, Multiple, DisableClearable, FreeSolo>" }, "default": "props.multiple ? [] : null" }, @@ -52,8 +52,8 @@ }, "filterOptions": { "type": { - "name": "(options: T[], state: FilterOptionsState<T>) => T[]", - "description": "(options: T[], state: FilterOptionsState<T>) => T[]" + "name": "(options: Value[], state: FilterOptionsState<Value>) => Value[]", + "description": "(options: Value[], state: FilterOptionsState<Value>) => Value[]" }, "default": "createFilterOptions()" }, @@ -63,17 +63,23 @@ }, "freeSolo": { "type": { "name": "FreeSolo", "description": "FreeSolo" }, "default": "false" }, "getOptionDisabled": { - "type": { "name": "(option: T) => boolean", "description": "(option: T) => boolean" } + "type": { + "name": "(option: Value) => boolean", + "description": "(option: Value) => boolean" + } }, "getOptionLabel": { "type": { - "name": "(option: T | AutocompleteFreeSoloValueMapping<FreeSolo>) => string", - "description": "(option: T | AutocompleteFreeSoloValueMapping<FreeSolo>) => string" + "name": "(option: Value | AutocompleteFreeSoloValueMapping<FreeSolo>) => string", + "description": "(option: Value | AutocompleteFreeSoloValueMapping<FreeSolo>) => string" }, "default": "(option) => option.label ?? option" }, "groupBy": { - "type": { "name": "(option: T) => string", "description": "(option: T) => string" } + "type": { + "name": "(option: Value) => string", + "description": "(option: Value) => string" + } }, "handleHomeEndKeys": { "type": { "name": "boolean", "description": "boolean" }, @@ -87,15 +93,15 @@ "inputValue": { "type": { "name": "string", "description": "string" } }, "isOptionEqualToValue": { "type": { - "name": "(option: T, value: T) => boolean", - "description": "(option: T, value: T) => boolean" + "name": "(option: Value, value: Value) => boolean", + "description": "(option: Value, value: Value) => boolean" } }, "multiple": { "type": { "name": "Multiple", "description": "Multiple" }, "default": "false" }, "onChange": { "type": { - "name": "(event: React.SyntheticEvent, value: AutocompleteValue<T, Multiple, DisableClearable, FreeSolo>, reason: AutocompleteChangeReason, details?: AutocompleteChangeDetails<T>) => void", - "description": "(event: React.SyntheticEvent, value: AutocompleteValue<T, Multiple, DisableClearable, FreeSolo>, reason: AutocompleteChangeReason, details?: AutocompleteChangeDetails<T>) => void" + "name": "(event: React.SyntheticEvent, value: AutocompleteValue<Value, Multiple, DisableClearable, FreeSolo>, reason: AutocompleteChangeReason, details?: AutocompleteChangeDetails<Value>) => void", + "description": "(event: React.SyntheticEvent, value: AutocompleteValue<Value, Multiple, DisableClearable, FreeSolo>, reason: AutocompleteChangeReason, details?: AutocompleteChangeDetails<Value>) => void" } }, "onClose": { @@ -106,8 +112,8 @@ }, "onHighlightChange": { "type": { - "name": "(event: React.SyntheticEvent, option: T | null, reason: AutocompleteHighlightChangeReason) => void", - "description": "(event: React.SyntheticEvent, option: T | null, reason: AutocompleteHighlightChangeReason) => void" + "name": "(event: React.SyntheticEvent, option: Value | null, reason: AutocompleteHighlightChangeReason) => void", + "description": "(event: React.SyntheticEvent, option: Value | null, reason: AutocompleteHighlightChangeReason) => void" } }, "onInputChange": { @@ -141,8 +147,8 @@ }, "value": { "type": { - "name": "AutocompleteValue<T, Multiple, DisableClearable, FreeSolo>", - "description": "AutocompleteValue<T, Multiple, DisableClearable, FreeSolo>" + "name": "AutocompleteValue<Value, Multiple, DisableClearable, FreeSolo>", + "description": "AutocompleteValue<Value, Multiple, DisableClearable, FreeSolo>" } } }, @@ -185,8 +191,8 @@ }, "getOptionProps": { "type": { - "name": "(renderedOption: UseAutocompleteRenderedOption<T>) => React.HTMLAttributes<HTMLLIElement>", - "description": "(renderedOption: UseAutocompleteRenderedOption<T>) => React.HTMLAttributes<HTMLLIElement>" + "name": "(renderedOption: UseAutocompleteRenderedOption<Value>) => React.HTMLAttributes<HTMLLIElement>", + "description": "(renderedOption: UseAutocompleteRenderedOption<Value>) => React.HTMLAttributes<HTMLLIElement>" }, "required": true }, @@ -210,8 +216,8 @@ }, "groupedOptions": { "type": { - "name": "T[] | Array<AutocompleteGroupedOption<T>>", - "description": "T[] | Array<AutocompleteGroupedOption<T>>" + "name": "Value[] | Array<AutocompleteGroupedOption<Value>>", + "description": "Value[] | Array<AutocompleteGroupedOption<Value>>" }, "required": true }, @@ -224,8 +230,8 @@ }, "value": { "type": { - "name": "AutocompleteValue<T, Multiple, DisableClearable, FreeSolo>", - "description": "AutocompleteValue<T, Multiple, DisableClearable, FreeSolo>" + "name": "AutocompleteValue<Value, Multiple, DisableClearable, FreeSolo>", + "description": "AutocompleteValue<Value, Multiple, DisableClearable, FreeSolo>" }, "required": true } diff --git a/docs/pages/joy-ui/api/autocomplete.json b/docs/pages/joy-ui/api/autocomplete.json index 83ff79191c11ab..b04e59237babbc 100644 --- a/docs/pages/joy-ui/api/autocomplete.json +++ b/docs/pages/joy-ui/api/autocomplete.json @@ -28,7 +28,7 @@ "type": { "name": "func" }, "default": "createFilterOptions()", "signature": { - "type": "function(options: Array, state: object) => Array", + "type": "function(options: Array, state: object) => Array", "describedArgs": ["options", "state"] } }, @@ -47,23 +47,23 @@ }, "getOptionDisabled": { "type": { "name": "func" }, - "signature": { "type": "function(option: T) => boolean", "describedArgs": ["option"] } + "signature": { "type": "function(option: Value) => boolean", "describedArgs": ["option"] } }, "getOptionLabel": { "type": { "name": "func" }, "default": "(option) => option.label ?? option", - "signature": { "type": "function(option: T) => string", "describedArgs": [] } + "signature": { "type": "function(option: Value) => string", "describedArgs": [] } }, "groupBy": { "type": { "name": "func" }, - "signature": { "type": "function(options: T) => string", "describedArgs": ["options"] } + "signature": { "type": "function(options: Value) => string", "describedArgs": ["options"] } }, "id": { "type": { "name": "string" } }, "inputValue": { "type": { "name": "string" } }, "isOptionEqualToValue": { "type": { "name": "func" }, "signature": { - "type": "function(option: T, value: T) => boolean", + "type": "function(option: Value, value: Value) => boolean", "describedArgs": ["option", "value"] } }, @@ -76,7 +76,7 @@ "onChange": { "type": { "name": "func" }, "signature": { - "type": "function(event: React.SyntheticEvent, value: T | Array, reason: string, details?: string) => void", + "type": "function(event: React.SyntheticEvent, value: Value | Array, reason: string, details?: string) => void", "describedArgs": ["event", "value", "reason"] } }, @@ -90,7 +90,7 @@ "onHighlightChange": { "type": { "name": "func" }, "signature": { - "type": "function(event: React.SyntheticEvent, option: T, reason: string) => void", + "type": "function(event: React.SyntheticEvent, option: Value, reason: string) => void", "describedArgs": ["event", "option", "reason"] } }, diff --git a/docs/pages/material-ui/api/autocomplete.json b/docs/pages/material-ui/api/autocomplete.json index c1bf7b8d58a943..c3235218da5ee8 100644 --- a/docs/pages/material-ui/api/autocomplete.json +++ b/docs/pages/material-ui/api/autocomplete.json @@ -44,7 +44,7 @@ "type": { "name": "func" }, "default": "createFilterOptions()", "signature": { - "type": "function(options: Array, state: object) => Array", + "type": "function(options: Array, state: object) => Array", "describedArgs": ["options", "state"] } }, @@ -62,16 +62,16 @@ }, "getOptionDisabled": { "type": { "name": "func" }, - "signature": { "type": "function(option: T) => boolean", "describedArgs": ["option"] } + "signature": { "type": "function(option: Value) => boolean", "describedArgs": ["option"] } }, "getOptionLabel": { "type": { "name": "func" }, "default": "(option) => option.label ?? option", - "signature": { "type": "function(option: T) => string", "describedArgs": [] } + "signature": { "type": "function(option: Value) => string", "describedArgs": [] } }, "groupBy": { "type": { "name": "func" }, - "signature": { "type": "function(options: T) => string", "describedArgs": ["options"] } + "signature": { "type": "function(options: Value) => string", "describedArgs": ["options"] } }, "handleHomeEndKeys": { "type": { "name": "bool" }, "default": "!props.freeSolo" }, "id": { "type": { "name": "string" } }, @@ -80,7 +80,7 @@ "isOptionEqualToValue": { "type": { "name": "func" }, "signature": { - "type": "function(option: T, value: T) => boolean", + "type": "function(option: Value, value: Value) => boolean", "describedArgs": ["option", "value"] } }, @@ -94,7 +94,7 @@ "onChange": { "type": { "name": "func" }, "signature": { - "type": "function(event: React.SyntheticEvent, value: T | Array, reason: string, details?: string) => void", + "type": "function(event: React.SyntheticEvent, value: Value | Array, reason: string, details?: string) => void", "describedArgs": ["event", "value", "reason"] } }, @@ -108,7 +108,7 @@ "onHighlightChange": { "type": { "name": "func" }, "signature": { - "type": "function(event: React.SyntheticEvent, option: T, reason: string) => void", + "type": "function(event: React.SyntheticEvent, option: Value, reason: string) => void", "describedArgs": ["event", "option", "reason"] } }, diff --git a/docs/translations/api-docs/use-autocomplete/use-autocomplete.json b/docs/translations/api-docs/use-autocomplete/use-autocomplete.json index b07aae431e8b72..09862263d70940 100644 --- a/docs/translations/api-docs/use-autocomplete/use-autocomplete.json +++ b/docs/translations/api-docs/use-autocomplete/use-autocomplete.json @@ -111,7 +111,7 @@ "getRootProps": { "description": "Resolver for the root slot's props." }, "getTagProps": { "description": "A tag props getter." }, "groupedOptions": { - "description": "The options to render. It's either T[] or AutocompleteGroupedOption<T>[] if the groupBy prop is provided." + "description": "The options to render. It's either Value[] or AutocompleteGroupedOption<Value>[] if the groupBy prop is provided." }, "id": { "description": "Id for the Autocomplete." }, "inputValue": { "description": "The input value." }, diff --git a/packages/mui-base/src/Badge/Badge.types.ts b/packages/mui-base/src/Badge/Badge.types.ts index 8bf9d3756ed9e7..3784e2e3892692 100644 --- a/packages/mui-base/src/Badge/Badge.types.ts +++ b/packages/mui-base/src/Badge/Badge.types.ts @@ -78,12 +78,14 @@ export interface BadgeTypeMap< /** * Utility to create component types that inherit props from Badge. */ -export interface ExtendBadgeTypeMap { - props: M['props'] & BadgeTypeMap['props']; - defaultComponent: M['defaultComponent']; +export interface ExtendBadgeTypeMap { + props: TypeMap['props'] & BadgeTypeMap['props']; + defaultComponent: TypeMap['defaultComponent']; } -export type ExtendBadge = OverridableComponent>; +export type ExtendBadge = OverridableComponent< + ExtendBadgeTypeMap +>; export type BadgeProps< RootComponentType extends React.ElementType = BadgeTypeMap['defaultComponent'], diff --git a/packages/mui-base/src/Modal/Modal.types.ts b/packages/mui-base/src/Modal/Modal.types.ts index b5f9f78f2739d4..cb258ae8a60df9 100644 --- a/packages/mui-base/src/Modal/Modal.types.ts +++ b/packages/mui-base/src/Modal/Modal.types.ts @@ -141,12 +141,14 @@ export interface ModalTypeMap< /** * Utility to create component types that inherit props from Modal. */ -export interface ExtendModalTypeMap { - props: M['props'] & ModalTypeMap['props']; - defaultComponent: M['defaultComponent']; +export interface ExtendModalTypeMap { + props: TypeMap['props'] & ModalTypeMap['props']; + defaultComponent: TypeMap['defaultComponent']; } -export type ExtendModal = OverridableComponent>; +export type ExtendModal = OverridableComponent< + ExtendModalTypeMap +>; export type ModalProps< RootComponentType extends React.ElementType = ModalTypeMap['defaultComponent'], diff --git a/packages/mui-base/src/Slider/Slider.types.ts b/packages/mui-base/src/Slider/Slider.types.ts index 8c3280d3e8f21d..48eb79e0f117ee 100644 --- a/packages/mui-base/src/Slider/Slider.types.ts +++ b/packages/mui-base/src/Slider/Slider.types.ts @@ -172,13 +172,13 @@ export interface SliderTypeMap< /** * Utility to create component types that inherit props from Slider. */ -export interface ExtendSliderTypeMap { - props: M['props'] & Omit; - defaultComponent: M['defaultComponent']; +export interface ExtendSliderTypeMap { + props: TypeMap['props'] & Omit; + defaultComponent: TypeMap['defaultComponent']; } -export type ExtendSlider = OverridableComponent< - ExtendSliderTypeMap +export type ExtendSlider = OverridableComponent< + ExtendSliderTypeMap >; export type SliderProps< diff --git a/packages/mui-base/src/useAutocomplete/useAutocomplete.d.ts b/packages/mui-base/src/useAutocomplete/useAutocomplete.d.ts index 0b74f14638392f..85cf78249a3752 100644 --- a/packages/mui-base/src/useAutocomplete/useAutocomplete.d.ts +++ b/packages/mui-base/src/useAutocomplete/useAutocomplete.d.ts @@ -1,40 +1,40 @@ import * as React from 'react'; -export interface CreateFilterOptionsConfig { +export interface CreateFilterOptionsConfig { ignoreAccents?: boolean; ignoreCase?: boolean; limit?: number; matchFrom?: 'any' | 'start'; - stringify?: (option: T) => string; + stringify?: (option: Value) => string; trim?: boolean; } -export interface FilterOptionsState { +export interface FilterOptionsState { inputValue: string; - getOptionLabel: (option: T) => string; + getOptionLabel: (option: Value) => string; } -export interface AutocompleteGroupedOption { +export interface AutocompleteGroupedOption { key: number; index: number; group: string; - options: T[]; + options: Value[]; } -export function createFilterOptions( - config?: CreateFilterOptionsConfig, -): (options: T[], state: FilterOptionsState) => T[]; +export function createFilterOptions( + config?: CreateFilterOptionsConfig, +): (options: Value[], state: FilterOptionsState) => Value[]; export type AutocompleteFreeSoloValueMapping = FreeSolo extends true ? string : never; -export type AutocompleteValue = Multiple extends true - ? Array> +export type AutocompleteValue = Multiple extends true + ? Array> : DisableClearable extends true - ? NonNullable> - : T | null | AutocompleteFreeSoloValueMapping; + ? NonNullable> + : Value | null | AutocompleteFreeSoloValueMapping; export interface UseAutocompleteProps< - T, + Value, Multiple extends boolean | undefined, DisableClearable extends boolean | undefined, FreeSolo extends boolean | undefined, @@ -103,7 +103,7 @@ export interface UseAutocompleteProps< * The default value. Use when the component is not controlled. * @default props.multiple ? [] : null */ - defaultValue?: AutocompleteValue; + defaultValue?: AutocompleteValue; /** * If `true`, the input can't be cleared. * @default false @@ -133,11 +133,11 @@ export interface UseAutocompleteProps< * A function that determines the filtered options to be rendered on search. * * @default createFilterOptions() - * @param {T[]} options The options to render. + * @param {Value[]} options The options to render. * @param {object} state The state of the component. - * @returns {T[]} + * @returns {Value[]} */ - filterOptions?: (options: T[], state: FilterOptionsState) => T[]; + filterOptions?: (options: Value[], state: FilterOptionsState) => Value[]; /** * If `true`, hide the selected options from the list box. * @default false @@ -151,29 +151,29 @@ export interface UseAutocompleteProps< /** * Used to determine the disabled state for a given option. * - * @param {T} option The option to test. + * @param {Value} option The option to test. * @returns {boolean} */ - getOptionDisabled?: (option: T) => boolean; + getOptionDisabled?: (option: Value) => boolean; /** * Used to determine the string value for a given option. * It's used to fill the input (and the list box options if `renderOption` is not provided). * * If used in free solo mode, it must accept both the type of the options and a string. * - * @param {T} option + * @param {Value} option * @returns {string} * @default (option) => option.label ?? option */ - getOptionLabel?: (option: T | AutocompleteFreeSoloValueMapping) => string; + getOptionLabel?: (option: Value | AutocompleteFreeSoloValueMapping) => string; /** * If provided, the options will be grouped under the returned string. * The groupBy value is also used as the text for group headings when `renderGroup` is not provided. * - * @param {T} options The options to group. + * @param {Value} options The options to group. * @returns {string} */ - groupBy?: (option: T) => string; + groupBy?: (option: Value) => string; /** * If `true`, the component handles the "Home" and "End" keys when the popup is open. @@ -200,11 +200,11 @@ export interface UseAutocompleteProps< * Uses strict equality by default. * ⚠️ Both arguments need to be handled, an option can only match with one value. * - * @param {T} option The option to test. - * @param {T} value The value to test against. + * @param {Value} option The option to test. + * @param {Value} value The value to test against. * @returns {boolean} */ - isOptionEqualToValue?: (option: T, value: T) => boolean; + isOptionEqualToValue?: (option: Value, value: Value) => boolean; /** * If `true`, `value` must be an array and the menu will support multiple selections. * @default false @@ -214,15 +214,15 @@ export interface UseAutocompleteProps< * Callback fired when the value changes. * * @param {React.SyntheticEvent} event The event source of the callback. - * @param {T|T[]} value The new value of the component. + * @param {Value|Value[]} value The new value of the component. * @param {string} reason One of "createOption", "selectOption", "removeOption", "blur" or "clear". * @param {string} [details] */ onChange?: ( event: React.SyntheticEvent, - value: AutocompleteValue, + value: AutocompleteValue, reason: AutocompleteChangeReason, - details?: AutocompleteChangeDetails, + details?: AutocompleteChangeDetails, ) => void; /** * Callback fired when the popup requests to be closed. @@ -236,12 +236,12 @@ export interface UseAutocompleteProps< * Callback fired when the highlight option changes. * * @param {React.SyntheticEvent} event The event source of the callback. - * @param {T} option The highlighted option. + * @param {Value} option The highlighted option. * @param {string} reason Can be: `"keyboard"`, `"auto"`, `"mouse"`, `"touch"`. */ onHighlightChange?: ( event: React.SyntheticEvent, - option: T | null, + option: Value | null, reason: AutocompleteHighlightChangeReason, ) => void; /** @@ -275,7 +275,7 @@ export interface UseAutocompleteProps< /** * Array of options. */ - options: ReadonlyArray; + options: ReadonlyArray; /** * If `true`, the component becomes readonly. It is also supported for multiple tags where the tag cannot be deleted. * @default false @@ -293,15 +293,15 @@ export interface UseAutocompleteProps< * The value must have reference equality with the option in order to be selected. * You can customize the equality behavior with the `isOptionEqualToValue` prop. */ - value?: AutocompleteValue; + value?: AutocompleteValue; } export interface UseAutocompleteParameters< - T, + Value, Multiple extends boolean | undefined, DisableClearable extends boolean | undefined, FreeSolo extends boolean | undefined, -> extends UseAutocompleteProps {} +> extends UseAutocompleteProps {} export type AutocompleteHighlightChangeReason = 'keyboard' | 'mouse' | 'auto' | 'touch'; @@ -311,8 +311,8 @@ export type AutocompleteChangeReason = | 'removeOption' | 'clear' | 'blur'; -export interface AutocompleteChangeDetails { - option: T; +export interface AutocompleteChangeDetails { + option: Value; } export type AutocompleteCloseReason = | 'createOption' @@ -340,21 +340,21 @@ export type AutocompleteGetTagProps = ({ index }: { index: number }) => { * - [useAutocomplete API](https://mui.com/base-ui/react-autocomplete/hooks-api/#use-autocomplete) */ export default function useAutocomplete< - T, + Value, Multiple extends boolean | undefined = false, DisableClearable extends boolean | undefined = false, FreeSolo extends boolean | undefined = false, >( - props: UseAutocompleteProps, -): UseAutocompleteReturnValue; + props: UseAutocompleteProps, +): UseAutocompleteReturnValue; -export interface UseAutocompleteRenderedOption { - option: T; +export interface UseAutocompleteRenderedOption { + option: Value; index: number; } export interface UseAutocompleteReturnValue< - T, + Value, Multiple extends boolean | undefined = false, DisableClearable extends boolean | undefined = false, FreeSolo extends boolean | undefined = false, @@ -400,7 +400,7 @@ export interface UseAutocompleteReturnValue< * @returns props that should be spread on the li element */ getOptionProps: ( - renderedOption: UseAutocompleteRenderedOption, + renderedOption: UseAutocompleteRenderedOption, ) => React.HTMLAttributes; /** * Id for the Autocomplete. @@ -413,7 +413,7 @@ export interface UseAutocompleteReturnValue< /** * The value of the autocomplete. */ - value: AutocompleteValue; + value: AutocompleteValue; /** * If `true`, the component input has some values. */ @@ -444,7 +444,7 @@ export interface UseAutocompleteReturnValue< */ focusedTag: number; /** - * The options to render. It's either `T[]` or `AutocompleteGroupedOption[]` if the groupBy prop is provided. + * The options to render. It's either `Value[]` or `AutocompleteGroupedOption[]` if the groupBy prop is provided. */ - groupedOptions: T[] | Array>; + groupedOptions: Value[] | Array>; } diff --git a/packages/mui-base/src/utils/areArraysEqual.ts b/packages/mui-base/src/utils/areArraysEqual.ts index 7dd92a8226db69..3093738261c852 100644 --- a/packages/mui-base/src/utils/areArraysEqual.ts +++ b/packages/mui-base/src/utils/areArraysEqual.ts @@ -1,9 +1,9 @@ -type ItemComparer = (a: T, b: T) => boolean; +type ItemComparer = (a: Item, b: Item) => boolean; -export default function areArraysEqual( - array1: T[], - array2: T[], - itemComparer: ItemComparer = (a, b) => a === b, +export default function areArraysEqual( + array1: Item[], + array2: Item[], + itemComparer: ItemComparer = (a, b) => a === b, ) { return ( array1.length === array2.length && diff --git a/packages/mui-base/src/utils/mergeSlotProps.ts b/packages/mui-base/src/utils/mergeSlotProps.ts index eda0e336a8e52d..648be9693aac62 100644 --- a/packages/mui-base/src/utils/mergeSlotProps.ts +++ b/packages/mui-base/src/utils/mergeSlotProps.ts @@ -5,7 +5,7 @@ import { EventHandlers } from './types'; import extractEventHandlers from './extractEventHandlers'; import omitEventHandlers from './omitEventHandlers'; -export type WithCommonProps = T & { +export type WithCommonProps = OtherProps & { className?: string; style?: React.CSSProperties; ref?: React.Ref; diff --git a/packages/mui-base/src/utils/omitEventHandlers.ts b/packages/mui-base/src/utils/omitEventHandlers.ts index 49982fcd1ddaf2..001282b71b0d86 100644 --- a/packages/mui-base/src/utils/omitEventHandlers.ts +++ b/packages/mui-base/src/utils/omitEventHandlers.ts @@ -5,14 +5,14 @@ * @param object Object to remove event handlers from. * @returns Object with event handlers removed. */ -export default function omitEventHandlers>( - object: T | undefined, +export default function omitEventHandlers>( + object: Props | undefined, ) { if (object === undefined) { return {}; } - const result = {} as Partial; + const result = {} as Partial; Object.keys(object) .filter((prop) => !(prop.match(/^on[A-Z]/) && typeof object[prop] === 'function')) diff --git a/packages/mui-base/src/utils/types.ts b/packages/mui-base/src/utils/types.ts index 78027f2b3964bc..4d2a96ce8f99e1 100644 --- a/packages/mui-base/src/utils/types.ts +++ b/packages/mui-base/src/utils/types.ts @@ -2,8 +2,11 @@ import * as React from 'react'; export type EventHandlers = Record>; -export type WithOptionalOwnerState = Omit & - Partial>; +export type WithOptionalOwnerState = Omit< + Props, + 'ownerState' +> & + Partial>; export type SlotComponentProps = | (Partial> & TOverrides) diff --git a/packages/mui-base/src/utils/useLatest.ts b/packages/mui-base/src/utils/useLatest.ts index 06f930cc5befb8..6a08aa789e2be7 100644 --- a/packages/mui-base/src/utils/useLatest.ts +++ b/packages/mui-base/src/utils/useLatest.ts @@ -14,8 +14,8 @@ import * as React from 'react'; * * - [useLatest API](https://mui.com/base-ui/api/use-latest/) */ -export default function useLatest(value: T, deps?: React.DependencyList) { - const ref = React.useRef(value); +export default function useLatest(value: Value, deps?: React.DependencyList) { + const ref = React.useRef(value); React.useEffect(() => { ref.current = value; diff --git a/packages/mui-joy/src/Autocomplete/Autocomplete.tsx b/packages/mui-joy/src/Autocomplete/Autocomplete.tsx index 39795afd4052c3..21c905f0108d1d 100644 --- a/packages/mui-joy/src/Autocomplete/Autocomplete.tsx +++ b/packages/mui-joy/src/Autocomplete/Autocomplete.tsx @@ -851,9 +851,9 @@ Autocomplete.propTypes /* remove-proptypes */ = { * A function that determines the filtered options to be rendered on search. * * @default createFilterOptions() - * @param {T[]} options The options to render. + * @param {Value[]} options The options to render. * @param {object} state The state of the component. - * @returns {T[]} + * @returns {Value[]} */ filterOptions: PropTypes.func, /** @@ -877,7 +877,7 @@ Autocomplete.propTypes /* remove-proptypes */ = { /** * Used to determine the disabled state for a given option. * - * @param {T} option The option to test. + * @param {Value} option The option to test. * @returns {boolean} */ getOptionDisabled: PropTypes.func, @@ -887,7 +887,7 @@ Autocomplete.propTypes /* remove-proptypes */ = { * * If used in free solo mode, it must accept both the type of the options and a string. * - * @param {T} option + * @param {Value} option * @returns {string} * @default (option) => option.label ?? option */ @@ -896,7 +896,7 @@ Autocomplete.propTypes /* remove-proptypes */ = { * If provided, the options will be grouped under the returned string. * The groupBy value is also used as the text for group headings when `renderGroup` is not provided. * - * @param {T} options The options to group. + * @param {Value} options The options to group. * @returns {string} */ groupBy: PropTypes.func, @@ -914,8 +914,8 @@ Autocomplete.propTypes /* remove-proptypes */ = { * Uses strict equality by default. * ⚠️ Both arguments need to be handled, an option can only match with one value. * - * @param {T} option The option to test. - * @param {T} value The value to test against. + * @param {Value} option The option to test. + * @param {Value} value The value to test against. * @returns {boolean} */ isOptionEqualToValue: PropTypes.func, @@ -958,7 +958,7 @@ Autocomplete.propTypes /* remove-proptypes */ = { * Callback fired when the value changes. * * @param {React.SyntheticEvent} event The event source of the callback. - * @param {T|T[]} value The new value of the component. + * @param {Value|Value[]} value The new value of the component. * @param {string} reason One of "createOption", "selectOption", "removeOption", "blur" or "clear". * @param {string} [details] */ @@ -975,7 +975,7 @@ Autocomplete.propTypes /* remove-proptypes */ = { * Callback fired when the highlight option changes. * * @param {React.SyntheticEvent} event The event source of the callback. - * @param {T} option The highlighted option. + * @param {Value} option The highlighted option. * @param {string} reason Can be: `"keyboard"`, `"auto"`, `"mouse"`, `"touch"`. */ onHighlightChange: PropTypes.func, diff --git a/packages/mui-material/src/Autocomplete/Autocomplete.js b/packages/mui-material/src/Autocomplete/Autocomplete.js index e92d7bccc3b0a4..a2e39002f3302b 100644 --- a/packages/mui-material/src/Autocomplete/Autocomplete.js +++ b/packages/mui-material/src/Autocomplete/Autocomplete.js @@ -847,9 +847,9 @@ Autocomplete.propTypes /* remove-proptypes */ = { * A function that determines the filtered options to be rendered on search. * * @default createFilterOptions() - * @param {T[]} options The options to render. + * @param {Value[]} options The options to render. * @param {object} state The state of the component. - * @returns {T[]} + * @returns {Value[]} */ filterOptions: PropTypes.func, /** @@ -883,7 +883,7 @@ Autocomplete.propTypes /* remove-proptypes */ = { /** * Used to determine the disabled state for a given option. * - * @param {T} option The option to test. + * @param {Value} option The option to test. * @returns {boolean} */ getOptionDisabled: PropTypes.func, @@ -893,7 +893,7 @@ Autocomplete.propTypes /* remove-proptypes */ = { * * If used in free solo mode, it must accept both the type of the options and a string. * - * @param {T} option + * @param {Value} option * @returns {string} * @default (option) => option.label ?? option */ @@ -902,7 +902,7 @@ Autocomplete.propTypes /* remove-proptypes */ = { * If provided, the options will be grouped under the returned string. * The groupBy value is also used as the text for group headings when `renderGroup` is not provided. * - * @param {T} options The options to group. + * @param {Value} options The options to group. * @returns {string} */ groupBy: PropTypes.func, @@ -931,8 +931,8 @@ Autocomplete.propTypes /* remove-proptypes */ = { * Uses strict equality by default. * ⚠️ Both arguments need to be handled, an option can only match with one value. * - * @param {T} option The option to test. - * @param {T} value The value to test against. + * @param {Value} option The option to test. + * @param {Value} value The value to test against. * @returns {boolean} */ isOptionEqualToValue: PropTypes.func, @@ -980,7 +980,7 @@ Autocomplete.propTypes /* remove-proptypes */ = { * Callback fired when the value changes. * * @param {React.SyntheticEvent} event The event source of the callback. - * @param {T|T[]} value The new value of the component. + * @param {Value|Value[]} value The new value of the component. * @param {string} reason One of "createOption", "selectOption", "removeOption", "blur" or "clear". * @param {string} [details] */ @@ -997,7 +997,7 @@ Autocomplete.propTypes /* remove-proptypes */ = { * Callback fired when the highlight option changes. * * @param {React.SyntheticEvent} event The event source of the callback. - * @param {T} option The highlighted option. + * @param {Value} option The highlighted option. * @param {string} reason Can be: `"keyboard"`, `"auto"`, `"mouse"`, `"touch"`. */ onHighlightChange: PropTypes.func,