import React from 'react'; import { DevidedPagePath } from '@growi/core/dist/models'; import { useTranslation } from 'next-i18next'; import { useCurrentPagePath } from '~/stores/page'; import type { GetItemProps } from '../interfaces/downshift'; import { SearchMenuItem } from './SearchMenuItem'; type Props = { activeIndex: number | null searchKeyword: string getItemProps: GetItemProps } export const SearchMethodMenuItem = (props: Props): JSX.Element => { const { activeIndex, searchKeyword, getItemProps, } = props; const { t } = useTranslation('commons'); const { data: currentPagePath } = useCurrentPagePath(); const dPagePath = (new DevidedPagePath(currentPagePath ?? '', true, true)); const currentPageName = ` ${(!(dPagePath.isRoot || dPagePath.isFormerRoot) ? '...' : '')}/${(dPagePath.isRoot ? '' : `${dPagePath.latter}/`)} `; const shouldShowMenuItem = searchKeyword.trim().length > 0; return (
{currentPageName}
{searchKeyword}
{t('search_method_menu_item.only_children_of_this_tree')}