import type { ClipTypes, IBoxDimensionsByEdge, IBoxSize, RenderableContent } from '@adam-sv/arc'; import type { CSSProperties } from 'react'; import type { IChartState } from './logic/index'; import { ICoords } from '@adam-sv/arc'; export type { IChartState }; export type ChartSide = 'left' | 'top' | 'right' | 'bottom'; export type ChartComponent = ChartSide | 'content' | 'container'; export type _ScrollableSide = `${ChartSide}-floatingScroll`; export type ScrollableChartComponent = ChartComponent | _ScrollableSide | 'content'; export interface IChartConfiguration { axisSettings?: { sizes?: Partial>; minimumSizes?: Partial>; maximumSizes?: Partial>; preventResize?: boolean | Set; }; contentSizing: IChartContentSizeProps; scrollControls?: { left: number; top: number; onScrollUpdate?: (scrollLeft: number, scrollTop: number) => unknown; }; zoomSettings?: { value?: number; min?: number; max?: number; onZoomUpdate?: (zoom: number) => unknown; axes?: 'x' | 'y' | 'xy'; }; } export interface IChartBaseProps { children?: RenderableContent; chartState: IChartState; className?: string; id?: string; style?: CSSProperties; } export interface IChartComponentProps { children?: RenderableContent; className?: string; id?: string; style?: CSSProperties; showScrollBars?: boolean; onContextMenu?: (ev: React.MouseEvent, coordinateSpacePosition: ICoords) => unknown; onDrop?: (ev: React.DragEvent, coordinateSpacePosition: ICoords, data: string, chartState: IChartState) => unknown; } export interface IChartSideProps extends IChartComponentProps { /** * Label to display on chart side */ label?: RenderableContent; /** * Clip path options for the two sides of your chart side. * If side is 'top' then clipTypes can be {left: ClipType, right: clipType} * Other ClipTypes are ignored ('top' and 'bottom' don't make sense for 'top' side) */ clipTypes?: ClipTypes; /** * Shows or hides the corner mask border line * For now this line is only diagonal. If you have clip paths other than diagonal * it might make sense to turn this off */ showCornerMaskBorder?: boolean; } export interface IChartContentSizePropsBase { mode: 'responsive' | 'fits-width' | 'fits-height'; minContentHeight?: number; maxContentHeight?: number; } export interface IChartResponsiveSizing extends IChartContentSizePropsBase { mode: 'responsive'; coordinateSpace: IBoxSize; matchSizeAtDefaultZoomTo?: 'width' | 'height' | 'pixelSpace'; /** * WARNING: use of padding is exposed to ChartBase consumer as part of chartSize */ padding?: IBoxDimensionsByEdge; fillMaxSpace?: boolean; } export interface IChartFitsOneDimensionSizing extends IChartContentSizePropsBase { /** * Options are 'fits-width' or 'fits-height' * fits-width => the chart can be arbitrarily wide * fits-height => the chart can be arbitrarily tall * the other dimension is "controlled" */ mode: 'fits-width' | 'fits-height'; controlledDimensionSize: number; } export type IChartContentSizeProps = IChartResponsiveSizing | IChartFitsOneDimensionSizing;