diff --git a/packages/ra-ui-materialui/src/layout/Title.js b/packages/ra-ui-materialui/src/layout/Title.tsx similarity index 68% rename from packages/ra-ui-materialui/src/layout/Title.js rename to packages/ra-ui-materialui/src/layout/Title.tsx index ae56c310e90..7af44f612c1 100644 --- a/packages/ra-ui-materialui/src/layout/Title.js +++ b/packages/ra-ui-materialui/src/layout/Title.tsx @@ -1,10 +1,13 @@ -import * as React from 'react'; +import React from 'react'; import { cloneElement } from 'react'; import { createPortal } from 'react-dom'; import PropTypes from 'prop-types'; -import { useTranslate, warning } from 'ra-core'; +import { Record, useTranslate, warning } from 'ra-core'; -const Title = ({ className, defaultTitle, locale, record, title, ...rest }) => { +const Title = ( + props: TitleProps +): React.ReactElement> => { + const { className, defaultTitle, locale, record, title, ...rest } = props; const translate = useTranslate(); const container = typeof document !== 'undefined' @@ -27,6 +30,16 @@ const Title = ({ className, defaultTitle, locale, record, title, ...rest }) => { return createPortal(titleElement, container); }; +export declare type TitleProp = string | React.ReactElement; + +export declare type TitleProps = { + defaultTitle?: string; + className?: string; + locale?: string; + record?: R; + title?: TitleProp; +} & T; + export const TitlePropType = PropTypes.oneOfType([ PropTypes.string, PropTypes.element,