@gravity-ui/graph
Version:
Modern graph editor component
71 lines (70 loc) • 2.23 kB
TypeScript
import type { TGraphColors, TGraphConstants } from "../../graphConfig";
import type { TComponentState } from "../../lib/Component";
import type { LayerProps } from "../../services/Layer";
import { RecursivePartial } from "../../utils/types/helpers";
/**
* Describes a change to a CSS variable
*/
export interface CSSVariableChange {
/** The CSS variable name (e.g., '--graph-block-background') */
name: string;
/** The new value of the CSS variable */
value: string;
/** The previous value of the CSS variable (if any) */
oldValue?: string;
}
/**
* Props for CSSVariablesLayer
*/
export interface CSSVariablesLayerProps extends LayerProps {
/** CSS class name to apply to the container div */
containerClass: string;
/** Optional callback for CSS variable changes */
onChange?: (changes: CSSVariableChange[]) => void;
/** Whether to enable debug logging */
debug?: boolean;
}
/**
* State for CSSVariablesLayer
*/
export interface CSSVariablesLayerState extends TComponentState {
/** Whether the layer is actively observing changes */
isObserving: boolean;
colors: RecursivePartial<TGraphColors>;
constants: RecursivePartial<TGraphConstants>;
}
/**
* Supported value types for CSS variables
*/
export declare enum CSSVariableType {
COLOR = "color",
FLOAT = "float",
INT = "int",
STRING = "string",
BOOLEAN = "boolean"
}
/**
* Type converter functions for CSS variable values
*/
export declare const CSS_VALUE_CONVERTERS: {
readonly color: (value: string) => string;
readonly float: (value: string) => number;
readonly int: (value: string) => number;
readonly string: (value: string) => string;
readonly boolean: (value: string) => boolean;
};
/**
* Mapping configuration for CSS variables to graph properties
*/
export interface CSSVariableMapping {
/** CSS variable name */
cssVariable: string;
/** Path in TGraphColors or TGraphConstants (e.g., 'block.background') */
graphPath: string;
/** Type converter for the CSS variable value */
typeConverter: CSSVariableType;
}
/**
* Collection of all supported CSS variable mappings
*/
export type CSSVariableMappings = CSSVariableMapping[];