import { IDesignSystem, INode, Event, EventType, EventCallback, IProperty, IListenerSubscription } from "../interfaces"; declare class NodeState { isEnabled: { [key: string]: boolean; }; } /** * The Node class is the base class for all atoms, molecules, and organisms. * * It is used to create a tree of the following form: * ``` * DesignSystem -> Atoms -> -> * -> Molecules -> -> * -> Organisms -> -> * -> Layers -> * -> Code -> * ``` * * It is also used to form a dependency graph between nodes of the tree. * * Each node may depend on other nodes and inversely may be depended on by other nodes. * A node is considered "initialized" only when all children are initialized. * A Prop (a leaf node) is considered "initialized" if it is either not a required property * or it is required but has a value. * A node is considered "enabled" only when all dependency nodes are "initialized". * Listeners are notified when it transitions the enabled status of a node changes. * * @category Utilities */ export declare class Node implements INode { /** The name of the node, which is unique relative to it's siblings */ readonly name: string; /** The unique key for the node. It is unique from all other nodes in the ThemeBuilder */ readonly key: string; protected readonly parent?: Node; protected readonly children: Node[]; private readonly dependencies; private readonly dependents; private readonly listeners; private readonly props; protected readonly dsNodes: { [key: string]: Node; }; constructor(name: string, parent?: INode); /** Get the design system */ getDesignSystem(): IDesignSystem; /** Add a dependency to another node in the tree */ addDependency(node: INode): void; /** * Determine if this node is enabled. A node is enabled if all other nodes on which this node depends have been initialized. * @returns True if enabled, or false otherwise. */ isEnabled(): boolean; /** * Determine if this node is initialized. * * If this node is a property, it is initialized if it is not required to have a value, or if it is required and has either a default or non-default value. * * @returns True if initialized, or false otherwise. */ isInitialized(): boolean; /** * Return the keys of all properties which are required and not initialized. * @returns Returns the keys of all properties which are required and not initialized. */ getUninitializedRequiredProperties(): string[]; private _getUninitializedRequiredProperties; /** * Set a listener on this node * @param name The name of the listener. * @param callback The callback to call when an event occurs. * @param eventTypes The types of events to wait for. If none are specified, listen for all events. * @returns The ListenerSubscription which should be canceled to stop listening. */ setListener(name: string, callback: EventCallback, eventTypes?: EventType[]): ListenerSubscription; /** * Remove a listener by name. * @param name The name of the listener to remove */ removeListener(name: string): void; /** * Remove all listeners on this node. */ removeAllListeners(): void; notifyListeners(event: Event): void; /** * Store persistently the state of the design system. */ store(): Promise; addProperty(prop: IProperty): void; getNodeState(): NodeState; compareNodeState(state: NodeState): void; getParent(): Node | undefined; private addToNodeState; protected _addProperties(props: IProperty[]): void; serialize(): any; deserialize(obj: any): void; toJSON(): Object; } /** * A ListenerSubscription returned by Node.setListener. * @category Utilities */ export declare class ListenerSubscription implements IListenerSubscription { private name; private node; constructor(name: string, node: Node); /** Cancel this listener subscription */ cancel(): void; } export {};