import {Component, ContextType} from 'react' import {safeInvoke} from '@befe/brick-utils' import {ComponentLocale, LocaleTextReplacement} from '../i18n' import {ThemeConfigWithDefaults} from '../theme' import {ConfigContext, getDefaultValueUsingContextTheme, getValueFromContextTheme} from './config-context' export class ConfiguredComponent< Props = Record, State = Record > extends Component { static contextType = ConfigContext context!: ContextType componentLocale?: ComponentLocale getLocaleText(key: string, ...args: LocaleTextReplacement[]): string { return this.componentLocale && safeInvoke(this.context.getLocaleText, this.componentLocale, key, ...args) || '' } getThemeValue(themePropName: TN) { return getValueFromContextTheme(this.context, themePropName) } getDefaultValueUsingTheme( propName: N, themePropName: TN ) { return getDefaultValueUsingContextTheme(this, propName, themePropName) } }