import styled from '@emotion/styled'; import type { Info1D } from '@zakodium/nmr-types'; import type { WorkspacePanelPreferences } from '@zakodium/nmrium-core'; import { FaLink } from 'react-icons/fa'; import { withDialog } from '../../elements/DialogManager.js'; import { EmptyText } from '../../elements/EmptyText.js'; import type { TanStackTableContextMenuProps } from '../../elements/tanstack_table/index.ts'; import useTableSortBy from '../../hooks/useTableSortBy.js'; import { EditRangeModal } from '../../modal/editRange/EditRangeModal.js'; import { extractChemicalElement } from '../../utility/extractChemicalElement.js'; import { NoDataForFid } from '../extra/placeholder/NoDataForFid.js'; import type { RangesTableDataRow } from './RangesPanel.js'; import RangesTableRow from './RangesTableRow.js'; import type { RangeData } from './hooks/useMapRanges.js'; import useMapRanges from './hooks/useMapRanges.js'; const Table = styled.table` border: 1px solid #dedede; border-spacing: 0; font-size: 12px; width: 100%; .react-contextmenu-wrapper { display: contents; } th { position: sticky; top: 0; background-color: white; z-index: 1; } th, td { border-bottom: 1px solid #dedede; border-right: 1px solid #dedede; margin: 0; padding: 0.1rem 0.4rem; text-align: center; white-space: nowrap; :last-child { border-right: 0; } button { background-color: transparent; border: none; } } tr { :last-child { td { border-bottom: 0; } } } `; interface RangesTableProps extends TanStackTableContextMenuProps { preferences: WorkspacePanelPreferences['ranges']; tableData: RangesTableDataRow[]; activeTab: string; info: Info1D; } const EditRangeDialog = withDialog(EditRangeModal, { force: true }); export default function RangesTable(props: RangesTableProps) { const { tableData, contextMenu = [], onContextMenuSelect, activeTab, preferences, info, } = props; const { tablePreferences } = preferences; const element = extractChemicalElement(activeTab); const { items: sortedData, isSortedDesc, onSort } = useTableSortBy(tableData); const data = useMapRanges(sortedData); if (info?.isFid) { return ; } if (!tableData || tableData.length === 0) { return ; } const showActions = tablePreferences.showDeleteAction || tablePreferences.showEditAction || tablePreferences.showZoomAction; return ( <> {tablePreferences.showSerialNumber && } {tablePreferences.showAssignmentLabel && ( )} {tablePreferences.from.show && ( )} {tablePreferences.to.show && ( )} {tablePreferences.deltaPPM.show && ( )} {tablePreferences.deltaHz.show && } {tablePreferences.relative.show && ( )} {tablePreferences.absolute.show && } {tablePreferences.showMultiplicity && } {tablePreferences.coupling.show && } {tablePreferences.showAssignment && ( )} {tablePreferences.showKind && } {showActions && } {data.map((range) => { return ( ); })}
#Assignment From {isSortedDesc('from').content} To {isSortedDesc('to').content} δ (ppm) {isSortedDesc('from').content} δ (Hz) Rel. {element} {isSortedDesc('integration').content} AbsoluteMult.J (Hz) Kind{''}
); }