import { FC } from 'react'; import type { Dispatch, SetStateAction } from 'react'; import type { IPagePopulatedToShowRevision } from '@growi/core'; import { useTranslation } from 'next-i18next'; import { ValidationTarget } from '~/client/util/input-validator'; import ClosableTextInput from '../Common/ClosableTextInput'; import { usePagePathSubmitHandler } from './page-header-utils'; type StateHandler = { isRenameInputShown: boolean setRenameInputShown: Dispatch> } type Props = { currentPagePath: string currentPage: IPagePopulatedToShowRevision stateHandler: StateHandler inputValue: string CustomComponent: () => JSX.Element handleInputChange?: (string) => void } export const TextInputForPageTitleAndPath: FC = (props) => { const { currentPagePath, currentPage, stateHandler, inputValue, CustomComponent, handleInputChange, } = props; const { t } = useTranslation(); const { isRenameInputShown, setRenameInputShown } = stateHandler; const pagePathSubmitHandler = usePagePathSubmitHandler(currentPage, currentPagePath, setRenameInputShown); return ( <> {isRenameInputShown ? (
{ setRenameInputShown(false) }} onPressEnter={pagePathSubmitHandler} validationTarget={ValidationTarget.PAGE} handleInputChange={handleInputChange} />
) : ( )} ); };