import type { IForEachAble } from '../internal' ; import Column from './Column' ; import { IArrayColumn , isArrayColumn } from './IArrayColumn' ; import type { IValueColumnDesc , IColumnDesc , IDataRow , ITypedDump } from './interfaces' ; export interface ICategoricalDesc { categories : ( string | Partial < ICategory > ) [ ] ; } export declare type ICategoricalColumnDesc = IValueColumnDesc < string > & ICategoricalDesc ; export interface ICategoricalColorMappingFunction { apply ( v ) : string ; toJSON ( ) : ITypedDump | null ; clone ( ) : ICategoricalColorMappingFunction ; eq ( other ) : boolean ; } export interface ICategoricalColorMappingFunctionConstructor { new ( dump ) : ICategoricalColorMappingFunction ; } export interface ICategoricalLikeColumn extends Column { readonly categories : ICategory [ ] ; getColorMapping ( ) : ICategoricalColorMappingFunction ; setColorMapping ( mapping ) : void ; iterCategory ( row ) : IForEachAble < ICategory | null > ; getCategories ( row ) : ( ICategory | null ) [ ] ; } export function isCategoricalLikeColumn ( col ) { return ( typeof ( col as ICategoricalLikeColumn ) . categories !== 'undefined' && typeof ( col as ICategoricalLikeColumn ) . iterCategory === 'function' ) ; } export interface ISetColumn extends IArrayColumn < boolean > , ICategoricalLikeColumn { getSet ( row ) : Set < ICategory > ; } export function isSetColumn ( col ) { return isCategoricalLikeColumn ( col ) && typeof ( col as ISetColumn ) . getSet === 'function' ; } export interface ICategoricalColumn extends ISetColumn { getCategory ( row ) : ICategory | null ; } export interface ICategory { readonly name : string ; /**
     * optional label of this category (the one to render)
     */ readonly label : string ; default readonly color : string ; value : number ; } param col returns { boolean } export function isCategoricalColumn ( col ) ; export function isCategoricalColumn ( col ) ; export function isCategoricalColumn ( col ) { return ( ( col instanceof Column && typeof ( col as ICategoricalColumn ) . getCategory === 'function' ) || ( ! ( col instanceof Column ) && ( col as IColumnDesc ) . type . match ( /(categorical|ordinal|hierarchy)/ ) != null ) ) ; } export declare type ICategoricalsColumn = ICategoricalLikeColumn & IArrayColumn < string | null > ; export function isCategoricalsColumn ( col ) { return isCategoricalLikeColumn ( col ) && isArrayColumn ( col ) && ! isSetColumn ( col ) ; } export interface ICategoricalFilter { filter : string [ ] | string | RegExp ; filterMissing : boolean ; } export interface ISetCategoricalFilter extends ICategoricalFilter { mode ? : 'every' | 'some' ; } export function isCategory ( v ) { return ( typeof v . name === 'string' && typeof v . label === 'string' && typeof v . color === 'string' && typeof v . value === 'number' ) ; }