UNPKG

synapse-react-client

Version:

[![npm version](https://badge.fury.io/js/synapse-react-client.svg)](https://badge.fury.io/js/synapse-react-client) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettie

134 lines 6.31 kB
import { CommonCardProps } from '@/components/CardContainer/CardConfiguration'; import { ColumnModel, SelectColumn } from '@sage-bionetworks/synapse-types'; import React from 'react'; import { HeaderCardVariant } from '../HeaderCard'; import { ShareThisPageProps } from '../ShareThisPage/ShareThisPage'; import { SustainabilityScorecardProps } from '../SustainabilityScorecard/SustainabilityScorecard'; import { PortalDOIConfiguration } from './PortalDOI/PortalDOIConfiguration'; type RowSynapseEntityConfig = { /** Use the table rowId to resolve the Synapse entity ID. */ id: { source: 'rowId'; }; /** Use the table rowVersionNumber to resolve the Synapse entity version (if available). */ version?: { source: 'rowVersionNumber'; }; }; type ColumnSynapseEntityConfig = { /** Use a column value to resolve the Synapse entity ID. */ id: { source: 'column'; columnName: string; }; /** Use a column value to resolve the Synapse entity version. */ version?: { source: 'column'; columnName: string; }; }; export type SynapseEntityConfig = RowSynapseEntityConfig | ColumnSynapseEntityConfig; /** * Maps a table query result to a GenericCard. */ export type TableToGenericCardMapping = { /** The 'type' of resource a card refers to. Renders a label on the card with this string value. * Can be hidden by setting it to '' (empty string) */ type: string; /** The column name whose data contains the title of the card */ title: string; /** The column name whose data contains the subtitle of the card */ subTitle?: string; /** The column name whose data contains the description of the card */ description?: string; /** If true, a 'Cite As' button will be displayed for those cards with a DOI in the 'doi' column */ includeCitation?: boolean; /** If true, a 'Share this page' button will be displayed */ includeShareButton?: boolean; /** * Configuration for displaying the SustainabilityScorecard component */ sustainabilityScorecard?: SustainabilityScorecardProps; /** The initial citation format to use in the 'Cite As' UI */ defaultCitationFormat?: 'bibtex' | 'apa' | 'ieee' | 'nature' | 'science'; /** Static text displayed in the 'Cite As' UI */ citationBoilerplateText?: string; /** The column name whose data contains the value used to map to the icon */ icon?: string; /** The column name whose data contains an image file handle to be displayed on the card */ imageFileHandleColumnName?: string; /** Static boolean value used if the image displayed using `imageFileHandleColumnName` requires extra padding */ thumbnailRequiresPadding?: boolean; /** Array of column names to be used for labels in the Card Footer */ secondaryLabels?: string[]; /** Can be used to add a custom secondary label */ customSecondaryLabelConfig?: { /** The displayed label key */ key: string; /** The value to display */ value: React.ReactNode; /** Callback to determine visibility of the label * @param schema the mapping of columnName to data index * @param data the row data */ isVisible: (schema: Record<string, number>, data: string[]) => boolean; }; /** Column name of the link value if the title should be linked */ link?: string; /** Column name of the STRING_LIST column that includes icon names that represent icons that should be displayed on the card */ dataTypeIconNames?: string; /** * Ordered list of column names to display to the right of the title area. * Each renders as "Display Name: Value" on its own line. Rows with empty values are skipped. * The display name is derived from getColumnDisplayName (respects column aliases and unCamelCase). * * Can also be a function that receives the schema and row data and returns the list of column * names to display, allowing the displayed details to vary based on the row's actual values. */ titleAreaDetails?: string[] | ((schema: Record<string, number>, data: string[]) => string[]); /** Configuration for resolving the Synapse entity ID/version represented by each card row. * The ID and version sources must both reference either row-based values or column-based values. */ synapseEntityConfig?: SynapseEntityConfig; /** The column name whose data contains a synId that can be used to show a button to add the corresponding entity to the download cart. */ downloadCartSynId?: string; /** Configuration to display a DOI, as well as the ability to create one for users with such permission */ portalDoiConfiguration?: PortalDOIConfiguration; }; export type TableRowGenericCardProps = { /** The schema that maps a table result to the GenericCard UI */ genericCardSchema: TableToGenericCardMapping; /** The table's SelectColumns */ selectColumns?: SelectColumn[]; /** The table's ColumnModels */ columnModels?: ColumnModel[]; /** If true, the 'type' column will be used as the icon string to choose the icon */ useTypeColumnForIcon?: boolean; /** If true, render the card as a HeaderCard */ isHeader?: boolean; /** If isHeader is true, use this variant of HeaderCard */ headerCardVariant?: HeaderCardVariant; isAlignToLeftNav?: boolean; /** Mapping of column name to row data index */ schema: Record<string, number>; /** The row data */ data: string[]; /** The ID of the table row */ rowId?: number; /** The versionNumber of the table row */ versionNumber?: number; /** Optional props for the ShareThisPage component */ sharePageLinkButtonProps?: ShareThisPageProps; /** Optional function that receives schema and data and returns a ReactNode to be rendered next to the card type */ CardTypeAdornment?: React.ComponentType<{ schema: Record<string, number>; data: string[]; }>; } & CommonCardProps; /** * Maps a table row to a GenericCard. */ export declare function TableRowGenericCard(props: TableRowGenericCardProps): import("react/jsx-runtime").JSX.Element; export default TableRowGenericCard; //# sourceMappingURL=TableRowGenericCard.d.ts.map