import { MessageDescriptor } from 'react-intl'; import { TimeseriesChartProps, ChartVariant } from './timeseries-props.js'; import { TimeseriesPerVariant } from './timeseries.js'; import { ChartMessage } from '../../core/types/chart-message.js'; import { ValueRepresentation } from '../../core/types/scales.js'; export type TimeseriesChartPropsWithVariant = Omit & { variant: ChartVariant; }; export type TimeseriesPropValidation = { messages: ChartMessage[]; sanitizedValue: { valueRepresentation: ValueRepresentation; data: TimeseriesPerVariant; }; }; export type ChartI18nableMessage = { /** Severity level of the emitted message */ severityLevel: 'warning' | 'error'; /** message descriptor used to translate to human-readable message */ descriptor: MessageDescriptor; }; export type ValidationResult = { /** name of the TimeseriesChartProps to sanitize */ field: keyof TimeseriesChartProps; /** a message able to be translated with intl hook */ message?: ChartI18nableMessage; /** default or sanitized value */ sanitizedValue?: T; }; export type ValidationFunction = (valueRepresentation: ValueRepresentation, timeseriesPerVariant: TimeseriesPerVariant, options?: unknown) => ValidationResult; export type ValidationResponse = { message: ChartI18nableMessage | ChartI18nableMessage[]; sanitizedValue: T; }; export type ValidationMap = Record>;