import { EditFilled } from '@ant-design/icons'; import { LibroContextKey } from '@difizen/libro-core'; import { useInject } from '@difizen/mana-app'; import { l10n } from '@difizen/mana-l10n'; import { Select, Tag } from 'antd'; import classNames from 'classnames'; import type { BaseSelectRef } from 'rc-select'; import type { FC } from 'react'; import { useEffect } from 'react'; import { useRef } from 'react'; import { useState } from 'react'; import './index.less'; interface ChatRecordInputProps { value: string | undefined; handleChange: (value: string | undefined) => void; onFocus?: () => void; classname?: string; records: string[]; } const ChatRecordInputCls = 'libro-chat-record-input'; export const ChatRecordInput: FC = ( props: ChatRecordInputProps, ) => { const { value, records, handleChange, onFocus } = props; const selectRef = useRef(null); const [selecting, setSelecting] = useState(false); const ref = useRef(null); const contextKey = useInject(LibroContextKey); useEffect(() => { if (selecting) { selectRef.current?.focus(); } }, [selecting]); const handleSelecting = (v: boolean) => { if (v) { contextKey.disableCommandMode(); } else { contextKey.enableCommandMode(); } setSelecting(v); }; const handleSelectChange = (arr: string | string[]) => { if (arr instanceof Array) { handleChange(arr[0]); } }; return (
Chat: {selecting ? (