UNPKG

@synergy-design-system/components

Version:
62 lines (61 loc) 2.12 kB
import type { ECConfig } from '../types.js'; /** * A single partial config contribution that can participate in a merge. */ type ConfigLayer = Partial<ECConfig> | undefined; /** * Merges multiple config layers into a single ECConfig. * * Nested plain objects are deep-merged recursively. Arrays are always * replaced by the rightmost (latest) value that provides them. Undefined * or null layers are silently ignored, allowing conditional config layers * to be passed without pre-filtering. * * This is the primary low-level helper used inside ConfigModifier functions * and builder operations. When no layers are provided, returns an empty object. * * @param layers Variable number of config layers to merge, applied left-to-right. * @returns The fully merged chart configuration. * * @example * ```ts * // Basic merge * const myModifier: ConfigModifier = (config) => * mergeConfigs(config, { xAxis: { name: 'Days' } }); * * // With conditional layers * const config = mergeConfigs( * baseConfig, * shouldAddTitle ? { title: { text: 'My Chart' } } : undefined, * { yAxis: { name: 'Values' } } * ); * ``` */ export declare const mergeConfigs: (...layers: ConfigLayer[]) => ECConfig; /** * The signature of a function that modifies a chart configuration. * * @example * ```ts * const myModifier: ConfigModifier = (config) => * mergeConfigs(config, { xAxis: { name: 'Days' } }); * ``` */ export type ConfigModifier = (config: ECConfig) => ECConfig; /** * Composes multiple modifiers into a single `ConfigModifier`. * Modifiers are applied left-to-right, so later Modifiers override earlier ones. * * Each modifier is evaluated against the accumulated, merged config so composed * patch-style modifiers can depend on updates from earlier ones. * * @param modifiers The modifiers to apply in sequence. * @returns A single `ConfigModifier` representing the full composition. * * @example * ```ts * const combined = compose(axesShowSplitLines(), axesHideYLabels()); * ``` */ export declare const compose: (...modifiers: ConfigModifier[]) => ConfigModifier; export {};