import type { Entity, Dirty } from "./Entity"; import type { State } from "./States"; import { EventDispatcher, Events } from "./EventDispatcher"; import { IDisposer } from "./Disposer"; /** * A state of a [[Template]], passed on to every object that uses the template. */ export declare class TemplateState { _settings: Partial; private _name; private _template; constructor(name: string, template: Template, settings: Partial); _dispose(): void; /** * Returns the state's value of setting `key`, or `fallback` if it has none. * * @param key Setting key * @param fallback Value to return if the state has no value * @return Value */ get(key: Key): this["_settings"][Key]; get(key: Key, fallback: F): NonNullable | F; /** * Sets the value setting `key` takes in this state, for every object that * uses the template. * * @param key Setting key * @param value Setting value */ set(key: Key, value: E["_settings"][Key]): void; /** * Removes setting `key` from the state. * * @param key Setting key */ remove(key: Key): void; /** * Sets several of the state's settings at once. * * @param settings Settings */ setAll(settings: this["_settings"]): void; _apply(other: State, seen: Dirty): void; } /** * The states of a [[Template]], by name. */ export declare class TemplateStates { private _template; private _states; constructor(template: Template); _dispose(): void; /** * Returns the state called `name`, or `undefined` if there is none. * * @param name State name * @return State */ lookup(name: string): TemplateState | undefined; /** * Creates the state called `name` with `settings`, or adds `settings` to * it if it already exists. * * @param name State name * @param settings Settings * @return State */ create(name: string, settings: Partial): TemplateState; /** * Removes the state called `name`. * * @param name State name */ remove(name: string): void; _apply(entity: E, state: ApplyState): void; } /** * Adapters of a [[Template]], added to every object that uses the template. */ export declare class TemplateAdapters { private _callbacks; /** * Adds a function that modifies the value of setting `key` each time it is * read, on the objects that use the template. * * @param key Setting key * @param callback Takes the value and returns the modified one * @return Disposer that removes the adapter */ add(key: Key, callback: (value: E["_settings"][Key], target: E, key: Key) => E["_settings"][Key]): IDisposer; /** * Removes all adapters for setting `key` from the template. * * @param key Setting key */ remove(key: Key): void; _apply(entity: E): IDisposer; } export interface ApplyState { settings: Dirty; privateSettings: Dirty; states: { [name: string]: Dirty; }; } /** * Settings, states, adapters and events shared by many objects, such as all * columns of a series. A setting on the template reaches every object that * uses it, unless the object has its own value. */ export declare class Template implements IDisposer { private _disposed; _settings: Partial; _privateSettings: E["_privateSettings"]; _computedSettings: Dirty; _settingEvents: { [K in keyof this["_settings"]]?: Array<((value: V) => void)>; }; _privateSettingEvents: { [K in keyof this["_settings"]]?: Array<((value: V) => void)>; }; _entities: Array; /** * States passed on to the objects that use the template. */ readonly states: TemplateStates; /** * Adapters added to the objects that use the template. */ readonly adapters: TemplateAdapters; /** * Event listeners added to the objects that use the template. */ readonly events: EventDispatcher>; /** * A function called once for each object that uses the template, when the * template is first applied to it. */ setup: ((entity: O) => void) | undefined; /** * Creates a template with `settings`. * * @see {@link https://www.amcharts.com/docs/v5/getting-started/#New_element_syntax} for more info * @param settings Settings * @return Template */ static new(settings: E["_settings"]): Template; protected _dispose(): void; /** * Returns `true` if the template has been disposed. * * @return Disposed */ isDisposed(): boolean; /** * Disposes the template, along with any disposable objects in its settings. */ dispose(): void; private _checkDisposed; /** * The objects that use the template. */ get entities(): Array; constructor(settings: E["_settings"], isReal: boolean); /** * Returns the template's value of setting `key`, or `fallback` if it has * none. * * @param key Setting key * @param fallback Value to return if the setting is not set * @return Value */ get(key: Key): this["_settings"][Key]; get(key: Key, fallback: F): NonNullable | F; /** * Sets setting `key` on the template only, without passing it on to the * objects that use it. * * @param key Setting key * @param value Setting value */ setRaw(key: Key, value: this["_settings"][Key]): void; /** * Sets setting `key` on the template, and on every object that uses it and * has no value of its own. * * @param key Setting key * @param value Setting value */ set(key: Key, value: this["_settings"][Key]): void; /** * Same as `set()`, but for a value the library works out itself rather than * one that was asked for, so that it can be left out when serializing. * * @ignore */ _setC(key: Key, value: this["_settings"][Key]): void; /** * Sets multiple computed settings at once. * * @ignore */ _setCAll(settings: this["_settings"]): void; /** * Flags already-set settings as computed, without writing anything. * * @ignore */ _markC>(this: T, ...keys: Array): T; /** * Removes setting `key` from the template. The objects that use it go back * to a value from a theme or other template, if there is one. * * @param key Setting key */ remove(key: Key): void; /** * Removes all settings from the template, as `remove()` does for each one. */ removeAll(): void; /** * Returns the template's value of private setting `key`, or `fallback` if * it has none. * * @param key Private setting key * @param fallback Value to return if the setting is not set * @return Value */ getPrivate(key: Key, fallback: F): NonNullable | F; getPrivate(key: Key): this["_privateSettings"][Key]; /** * Sets private setting `key` on the template only, without passing it on * to the objects that use it. Returns `value`. * * @param key Private setting key * @param value Setting value * @return Setting value */ setPrivateRaw(key: Key, value: Value): Value; /** * Sets private setting `key` on the template, and on every object that uses * it and has no value of its own. Returns `value`. * * @param key Private setting key * @param value Setting value * @return Setting value */ setPrivate(key: Key, value: Value): Value; /** * Removes private setting `key` from the template. * * @param key Private setting key */ removePrivate(key: Key): void; /** * Sets several settings at once, as `set()` does for each one. * * @param value Settings */ setAll(value: this["_settings"]): void; /** * Calls `callback` each time setting `key` changes on an object that uses * the template. * * @param key Setting key * @param callback Callback * @return Disposer for event */ on(key: Key, callback: (value: this["_settings"][Key], target?: E, key?: Key) => void): IDisposer; /** * Calls `callback` each time private setting `key` changes on an object * that uses the template. * * @param key Private setting key * @param callback Callback * @return Disposer for event */ onPrivate(key: Key, callback: (value: this["_privateSettings"][Key], target?: E, key?: Key) => void): IDisposer; _apply(entity: E, state: ApplyState): IDisposer; _setObjectTemplate(entity: E): void; _removeObjectTemplate(entity: E): void; _stateChanged(name: string): void; } //# sourceMappingURL=Template.d.ts.map