@equinor/fusion-react-ag-grid-person-cell
Version:
React component for displaying person details in AgGrid cell and PersonCard on cell hover
42 lines • 1.69 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import { PersonCell } from '@equinor/fusion-react-person';
import { personTooltip } from './personTooltip';
import { personSortComparator } from './personSort';
const renderPersonCell = (params) => {
const { heading, subHeading, azureId, upn, dataSource, showAvatar, value, size } = params;
const azureResult = azureId ? azureId(value) : undefined;
const upnResult = upn ? upn(value) : undefined;
const dataSourceResult = dataSource ? dataSource(value) : undefined;
return (_jsx(PersonCell, { size: size ?? 'small', azureId: azureResult, upn: upnResult, dataSource: dataSourceResult, heading: heading, subHeading: subHeading, showAvatar: showAvatar }));
};
export const agGridPersonCell = (col) => {
const { azureId, upn, dataSource, dataToSort, heading, subHeading, showAvatar, size } = col;
return {
cellRendererParams: {
azureId: azureId,
upn: upn,
dataSource: dataSource,
heading: heading,
subHeading: subHeading,
showAvatar: showAvatar,
size: size,
},
cellRenderer: renderPersonCell,
tooltipComponentParams: {
azureId: azureId,
upn: upn,
dataSource: dataSource,
},
tooltipComponent: personTooltip,
tooltipField: col.field,
comparator: dataToSort ? personSortComparator(dataToSort) : undefined,
cellClass: 'person-table-cell',
cellStyle: {
display: 'flex',
alignItems: 'center',
},
...col,
};
};
export default agGridPersonCell;
//# sourceMappingURL=agPersonCell.js.map