UNPKG

@adaptabletools/adaptable

Version:

Powerful AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements

39 lines (38 loc) 1.57 kB
import { StaticThemes } from '../../themes'; import { logDeprecation } from '../logDeprecation'; const LEGACY_SYSTEM_THEME_PROPS = ['Description', 'CSSVariables', 'Variant']; export function isLegacySystemThemeObject(theme) { if (typeof theme === 'string') { return false; } return LEGACY_SYSTEM_THEME_PROPS.some((prop) => prop in theme && theme[prop] !== undefined); } export function resolveSystemThemeDescription(name) { return StaticThemes.find((staticTheme) => staticTheme.Name === name)?.Description ?? name; } export function systemThemeEntryToAdaptableTheme(theme, logger) { if (typeof theme === 'string') { return { Name: theme, Description: resolveSystemThemeDescription(theme), }; } if (isLegacySystemThemeObject(theme)) { if (logger) { logDeprecation(logger, 'ThemeState', 'SystemThemes', undefined, 'Passing a full AdaptableTheme object in SystemThemes is deprecated. Use a theme name string or SystemThemeOptions (Name with AgThemeMode / AgGridClassName only).'); } return { Name: theme.Name, Description: theme.Description ?? resolveSystemThemeDescription(theme.Name), AgThemeMode: theme.AgThemeMode, AgGridClassName: theme.AgGridClassName, }; } const options = theme; return { Name: options.Name, Description: resolveSystemThemeDescription(options.Name), AgThemeMode: options.AgThemeMode, AgGridClassName: options.AgGridClassName, }; }