UNPKG

synapse-react-client

Version:

[![Build Status](https://travis-ci.com/Sage-Bionetworks/Synapse-React-Client.svg?branch=main)](https://travis-ci.com/Sage-Bionetworks/Synapse-React-Client) [![npm version](https://badge.fury.io/js/synapse-react-client.svg)](https://badge.fury.io/js/synaps

146 lines (145 loc) 4.58 kB
import * as React from 'react'; import { KeyValue, SQLOperator } from '../utils/functions/sqlFunctions'; import { QueryBundleRequest, QueryResultBundle } from '../utils/synapseTypes/'; import { GenericCardSchema, IconOptions } from './GenericCard'; import { IconSvgOptions } from './IconSvg'; /** * TODO: SWC-5612 - Replace token prop with SynapseContext.accessToken * * This wasn't done because Enzyme's shallow renderer is not currently * compatible with the `contextType` field in the React 16+ context API. * * This can be fixed by rewriting tests to not rely on the shallow renderer. * * See here: https://github.com/enzymejs/enzyme/issues/1553 */ /** * Used when a column value should link to an external URL defined by a value in another column. * Currently only works in SynapseTable (not cards!) */ export interface ColumnSpecifiedLink { isMarkdown: false; matchColumnName: string; linkColumnName: string; } export interface CardLink { baseURL: string; URLColumnName: string; matchColumnName: string; isMarkdown: false; wrapValueWithParens?: boolean; } export declare type MarkdownLink = { isMarkdown: true; matchColumnName: string; }; export declare type CTACardLink = { text: string; link: string; }; export declare type DescriptionConfig = { isMarkdown?: boolean; showFullDescriptionByDefault?: boolean; }; export declare type LabelLinkConfig = (MarkdownLink | CardLink | ColumnSpecifiedLink)[]; export declare type ColumnIconConfigs = { columns: { [index: string]: { [index: string]: IconSvgOptions; }; }; }; export declare type CommonCardProps = { genericCardSchema?: GenericCardSchema; secondaryLabelLimit?: number; titleLinkConfig?: CardLink; ctaLinkConfig?: CTACardLink; labelLinkConfig?: LabelLinkConfig; descriptionConfig?: DescriptionConfig; rgbIndex?: number; columnIconOptions?: ColumnIconConfigs; }; export declare type CardConfiguration = { type: string; hasInternalLink?: boolean; iconOptions?: IconOptions; } & CommonCardProps; export declare type CardContainerLogicProps = { token?: string; limit?: number; title?: string; unitDescription?: string; sqlOperator?: SQLOperator; searchParams?: KeyValue; facet?: string; facetAliases?: Record<string, string>; rgbIndex?: number; isHeader?: boolean; isAlignToLeftNav?: boolean; sql: string; } & CardConfiguration; declare type State = { data: QueryResultBundle | undefined; isLoading: boolean; queryRequest: QueryBundleRequest; totalResultsNoFacet: number; hasMoreData: boolean; }; /** * Class wraps around CardContainer and serves as a standalone logic container for rendering cards. * This same logic exists in QueryWrapper, but the two serve two distinct purposes, making this component * sufficiently distinct. * * @class CardContainerLogic * @extends {React.Component} */ export default class CardContainerLogic extends React.Component<CardContainerLogicProps, State> { static defaultState: { data: undefined; isLoading: boolean; queryRequest: QueryBundleRequest; totalResultsNoFacet: number; hasMoreData: boolean; }; constructor(props: CardContainerLogicProps); /** * Compute default query request * * @memberof QueryWrapper */ componentDidMount(): void; /** * @memberof QueryWrapper * */ componentDidUpdate(prevProps: CardContainerLogicProps): void; /** * Pass down a deep clone (so no side affects on the child's part) of the * last query request made * * @returns * @memberof QueryWrapper */ getLastQueryRequest(): QueryBundleRequest; /** * Grab the next page of data, pulling in 25 more rows. * * @param {*} queryRequest Query request as specified by * https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/table/Query.html * @memberof QueryWrapper */ getNextPageOfData(queryRequest: QueryBundleRequest): Promise<void>; /** * Execute the initial query passed into the component * * @param {*} queryRequest Query request as specified by * https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/table/Query.html * @memberof QueryWrapper */ executeInitialQueryRequest(): void; /** * Render the children without any formatting */ render(): JSX.Element; } export {};