import { Tag, Tooltip, Typography } from 'antd'; import { useTranslation } from 'react-i18next'; import { REMARK_VARIABLES, REMARK_VAR_GROUPS, wrapToken } from '@/lib/remark/remarkVariables'; import type { RemarkVar } from '@/lib/remark/remarkVariables'; import { activateOnKey } from '@/utils/a11y'; interface RemarkVarPickerProps { /** Called with the bare token (e.g. "EMAIL") when a chip is clicked. */ onPick: (token: string) => void; variables?: RemarkVar[]; } /** * RemarkVarPicker is the grouped, tooltipped chip list of {{VAR}} tokens used by * the global remark-template field. */ export default function RemarkVarPicker({ onPick, variables = REMARK_VARIABLES }: RemarkVarPickerProps) { const { t } = useTranslation(); return (
{t('pages.hosts.remarkVars.intro')} {REMARK_VAR_GROUPS.filter((group) => variables.some((v) => v.group === group)).map((group) => (
{t(`pages.hosts.remarkVars.groups.${group}`)}
{variables.filter((v) => v.group === group).map((v) => ( onPick(v.token)} onKeyDown={activateOnKey(() => onPick(v.token))} style={{ cursor: 'pointer', margin: 0, fontFamily: 'monospace' }} > {wrapToken(v.token)} ))}
))}
); }