upsetjs import { isSet , isSetCombination , isGenerateSetCombinationOptions , isSetLike , isUpSetQuery } from '@upsetjs/model' ; import type { UpSetStyleClassNames , UpSetFontSizes , UpSetMultiStyle , UpSetExportOptions , UpSetThemes , VennDiagramMultiStyle , VennDiagramFontSizes , UpSetLayoutProps , UpSetBaseDataProps , UpSetDataProps , UpSetSelectionProps , KarnaughMapMultiStyle , UpSetBaseStyleProps , UpSetStyleProps , KarnaughMapFontSizes , } from './interfaces' ; import { FONT_SIZES_KEYS , MULTI_STYLE_KEYS , EXPORT_OPTION_KEYS } from './defaults' ; export function widthRatios ( value ? ) { return value == null || ( Array . isArray ( value ) && value . length >= 2 && value . every ( ( v ) => typeof v === 'number' ) ) ; } export function heightRatios ( value ? ) { return value == null || ( Array . isArray ( value ) && value . length >= 1 && value . every ( ( v ) => typeof v === 'number' ) ) ; } export function setLabelAlignment ( value ? ) { return value == null || value === 'left' || value === 'center' || value === 'right' ; } export function sets ( value ) { return Array . isArray ( value ) && value . every ( isSet ) ; } export function combinations ( value ? ) { return ( value == null || ( Array . isArray ( value ) && value . every ( isSetCombination ) ) || isGenerateSetCombinationOptions ( value ) ) ; } export function selection ( value ? ) { return value == null || Array . isArray ( value ) || isSetLike ( value ) ; } export function onHover ( value ? ) { return value == null || typeof value === 'function' ; } export function onClick ( value ? ) { return value == null || typeof value === 'function' ; } export function onContextMenu ( value ? ) { return value == null || typeof value === 'function' ; } export function onMouseMove ( value ? ) { return value == null || typeof value === 'function' ; } export function queries ( value ? ) { return ! value || ( Array . isArray ( value ) && value . every ( isUpSetQuery ) ) ; } export function stringOrFalse ( value ? ) { return value == null || typeof value === 'string' || value === false ; } export function theme ( value ? ) { return value == null || value === 'light' || value === 'dark' || value === 'vega' ; } export function classNames ( value ? ) { return ( value == null || ( Object . keys ( value ) as ( keyof ( UpSetStyleClassNames | VennDiagramMultiStyle < string > ) ) [ ] ) . every ( ( k ) => MULTI_STYLE_KEYS . includes ( k ) && typeof value [ k ] === 'string' ) ) ; } export function fontSizes ( value ? ) { return ( value == null || ( Object . keys ( value ) as ( keyof ( UpSetFontSizes | VennDiagramFontSizes ) ) [ ] ) . every ( ( k ) => FONT_SIZES_KEYS . includes ( k ) && typeof value [ k ] === 'string' ) ) ; } export function numericScale ( value ? ) { return value == null || value === 'linear' || value === 'log' || typeof value === 'function' ; } export function bandScale ( value ? ) { return value == null || value === 'band' || typeof value === 'function' ; } export function axisOffset ( value ? ) { return value == null || value === 'auto' || typeof value === 'number' ; } export function style ( value ? ) { return value == null || typeof value === 'object' ; } export function styles ( value ? ) { return ( value == null || Object . keys ( value ) . every ( ( k ) => MULTI_STYLE_KEYS . includes ( k as keyof ( UpSetMultiStyle < any > | VennDiagramMultiStyle < any > ) ) ) ) ; } export function exportButtons ( value ? ) { return ( value == null || typeof value === 'boolean' || ( Object . keys ( value ) as ( keyof UpSetExportOptions ) [ ] ) . every ( ( k ) => EXPORT_OPTION_KEYS . includes ( k ) && typeof value [ k ] === 'boolean' ) ) ; }