/********************************************************************************** * Copyright (c) 2025 EclipseSource and others. * * This program and the accompanying materials are made available under the * terms of the MIT License as outlined in the LICENSE file. **********************************************************************************/ import React, { useCallback } from 'react'; import { CDTTreeItem, CDTTreeItemResource, CDTTreeTableStringColumn, EditableCDTTreeTableStringColumn } from '../../../common'; import EditableStringCell from './EditableStringCell'; import LabelCell from './LabelCell'; interface StringCellProps { column: CDTTreeTableStringColumn; record: CDTTreeItem; editing?: boolean; autoFocus?: boolean; onSubmit?: (record: CDTTreeItem, newValue: string) => void; onCancel?: (record: CDTTreeItem) => void; onEdit?: (record: CDTTreeItem, edit: boolean) => void; } const StringCell = ({ column, record, editing = false, autoFocus = false, onSubmit, onCancel, onEdit }: StringCellProps) => { const handleSubmit = useCallback((newValue: string) => onSubmit?.(record, newValue), [record, onSubmit]); const handleCancel = useCallback(() => onCancel?.(record), [record, onCancel]); const handleEdit = useCallback((edit: boolean) => onEdit?.(record, edit), [record, onEdit]); return column.edit && onSubmit ? ( ) : ( ); }; export default StringCell;