import React, { useMemo } from 'react'; import type { IInteractive } from '../../typings'; import EditName from '../EditName'; import FieldSelect from '../FieldSelect'; import useDataset from '../../hooks/useDataset'; import { Collapse, Popconfirm, Switch, Form } from 'antd'; import { useRef } from 'react'; import styles from './index.less'; const { Panel } = Collapse; interface IProps { interactive: IInteractive; dragIcon: JSX.Element; onChange: (newInteractive: Partial) => void; onEditName: (newName: string, interactive: IInteractive) => void; onDelete: (interactive: IInteractive) => void; } const InteractiveItem = ({ interactive, onChange, onEditName, onDelete, dragIcon, }: IProps) => { const { getTargetDataset } = useDataset(); const dropdownRef = useRef(null); const { getDatasetMarkStyle } = useDataset(); const fields = useMemo( () => getTargetDataset(interactive.datasetId)?.fields ?? [], [getTargetDataset, interactive.datasetId], ); const header = (
e.stopPropagation()} > {dragIcon} onEditName(newName, interactive)} />
onChange({ id: interactive.id, enable: newEnable, }) } /> onDelete(interactive)} >
); const content = (
onChange({ ...interactive, fields: Array.isArray(newFields) ? newFields : [], }) } />
); return ( {content} ); }; export default InteractiveItem;