Core utilities and components for Apache Superset's frontend UI framework providing data visualization, formatting, and chart composition capabilities
npx @tessl/cli install tessl/npm-superset-ui--core@0.18.0The @superset-ui/core package provides foundational utilities, types, and components for the Apache Superset UI ecosystem. It serves as the core infrastructure layer that enables building extensible data visualization applications with robust plugin systems, formatting capabilities, and comprehensive type safety.
@superset-ui/corenpm install @superset-ui/coreimport {
Registry,
Plugin,
formatNumber,
SuperChart,
SupersetClient
} from '@superset-ui/core';const {
Registry,
Plugin,
formatNumber,
SuperChart,
SupersetClient
} = require('@superset-ui/core');import {
Registry,
getNumberFormatterRegistry,
formatNumber,
SupersetClient
} from '@superset-ui/core';
// Create a custom registry
const myRegistry = new Registry<string>();
myRegistry.registerValue('greeting', 'Hello World');
// Format numbers with built-in formatters
const formatted = formatNumber(',.2f', 1234.567); // "1,234.57"
// Configure API client
SupersetClient.configure({
host: 'http://localhost:8088',
});The @superset-ui/core package is organized into 18 core modules that provide different aspects of functionality:
Core registry infrastructure for managing extensible collections:
import { Registry, OverwritePolicy } from '@superset-ui/core';
class Registry<V, W = V | Promise<V>> {
constructor(config?: {
name?: string;
overwritePolicy?: OverwritePolicy;
setFirstItemAsDefault?: boolean;
});
registerValue(key: string, value: V): this;
registerLoader(key: string, loader: () => W): this;
get(key: string): V | W | undefined;
getAsPromise(key: string): Promise<V>;
has(key: string): boolean;
clear(): this;
keys(): string[];
values(): (V | W | undefined)[];
}
enum OverwritePolicy {
ALLOW = 'ALLOW',
PROHIBIT = 'PROHIBIT',
WARN = 'WARN'
}→ Learn more about Core Models & Utilities
Comprehensive number formatting with extensible formatters:
import { formatNumber, getNumberFormatter } from '@superset-ui/core';
// Format numbers using format strings
formatNumber(format: string, value: number): string;
formatNumber(',.2f', 1234.567); // "1,234.57"
formatNumber('.1%', 0.125); // "12.5%"
// Get formatter instances
getNumberFormatter(format: string): NumberFormatter;→ Learn more about Data Formatting
Plugin-based chart system with React integration:
import { SuperChart, ChartPlugin } from '@superset-ui/core';
interface SuperChartProps {
chartType: string;
width?: number;
height?: number;
formData?: QueryFormData;
queryData?: ChartDataResponseResult;
}
// Main chart component
const SuperChart: React.ComponentType<SuperChartProps>;
// Chart plugin base class
class ChartPlugin extends Plugin {
constructor(config: {
Chart: React.ComponentType<any>;
metadata: ChartMetadata;
transformProps?: TransformProps;
buildQuery?: BuildQueryFunction;
});
}→ Learn more about Plugin System
HTTP client for Superset API communication:
import { SupersetClient, callApi } from '@superset-ui/core';
// Configure global client
SupersetClient.configure(config: {
host?: string;
headers?: { [key: string]: string };
fetchRetryOptions?: FetchRetryOptions;
});
// Make API calls
callApi(config: {
url: string;
method?: 'GET' | 'POST' | 'PUT' | 'DELETE';
body?: BodyInit;
headers?: HeadersInit;
}): Promise<Response>;→ Learn more about Data Connection
Comprehensive theming with Emotion integration:
import {
useTheme,
ThemeProvider,
styled,
css,
SupersetTheme
} from '@superset-ui/core';
// Theme hook
useTheme(): SupersetTheme;
// Styled components
const StyledDiv = styled.div`
color: ${({ theme }) => theme.colors.primary.base};
`;
// Theme provider
<ThemeProvider theme={supersetTheme}>
{children}
</ThemeProvider>→ Learn more about UI & Styling
Translation and localization support:
import { t, tn } from '@superset-ui/core';
// Basic translation
t(text: string): string;
t('Hello World');
// Pluralized translation
tn(singular: string, plural: string, count: number): string;
tn('item', 'items', count);→ Learn more about Translation
Input validation and mathematical expression evaluation:
import {
validateNumber,
validateInteger,
evalExpression
} from '@superset-ui/core';
// Validation functions
validateNumber(value: unknown): string | false;
validateInteger(value: unknown): string | false;
// Math expressions
evalExpression(expression: string, value: number): number;
evalExpression('x > 10', 15); // 1 (true)→ Learn more about Validation & Math