synapse-react-client
Version:
[](https://badge.fury.io/js/synapse-react-client) [](https://github.com/prettier/prettie
42 lines • 2.36 kB
TypeScript
import { QueryBundleRequest, QueryResultBundle, Row } from '@sage-bionetworks/synapse-types';
import { SustainabilityScorecardProps } from './SustainabilityScorecard';
export declare const SUSTAINABILITY_ICON_COLORS: {
check: string;
close: string;
};
export type MetricsConfig = {
/** Name of the metric column in the table */
key: string;
/** Display label for the metric */
label: string;
/** Shown as a tooltip in SustainabilityScorecard and as summary text in SustainabilityScorecardSummary */
text?: string;
};
export type SustainabilityScorecardBaseProps = {
queryRequest: QueryBundleRequest;
metricsConfig: MetricsConfig[];
/** Name of the URL search parameter used to filter the data. */
searchParamKey: string;
/** The name of the column in the table to apply the filter to. */
filterColumn: string;
scoreDescriptorColumnName: string;
};
/**
* Maps each metric key to its value in the row
* Returns an array of metric values in the same order as `metricsConfig`
*/
export declare const getMetricValues: (row: Row | undefined, queryResultBundle: QueryResultBundle | undefined, metricsConfig: MetricsConfig[]) => string[];
export declare const getSelectedColumns: (metricsConfig: MetricsConfig[], scoreDescriptorColumnName: string) => string[];
/**
* Creates an array of metric config objects from a QueryResultBundle.
* @param bundle - The Synapse QueryResultBundle containing metric config data (key, label, summaryText, tooltipText)
* @param textColumn - The name of the column to use for the `text` field ('summaryText' for the SustainabilityScorecardSummary component and 'tooltipText' for the SustainabilityScorecard component)
*/
export declare function getMetricConfig(bundle: QueryResultBundle | undefined, textColumn: 'summaryText' | 'tooltipText'): MetricsConfig[];
/**
* Custom hook that returns the provided SustainabilityScorecardProps only if the query returns data.
* Helps conditionally render `SustainabilityScorecard` component
* @param props - The props containing the queryRequest, metricsConfig, searchParamKey, filterColumn, and scoreDescriptorColumnName.
*/
export declare function useSustainabilityScorecardIfHasData(props: SustainabilityScorecardProps): SustainabilityScorecardProps | undefined;
//# sourceMappingURL=SustainabilityScorecardUtils.d.ts.map