import { ReactiveController, ReactiveControllerHost } from 'lit'; import { Logger } from '../logger'; export declare type ConsumeContextOptions = { /** * A unique identifier used to pair a context provider and consumer. */ id: symbol; /** * Provide a name for debugging. */ name?: string | symbol; /** * Whether context updates should also request an update on the controller host to trigger * a re-render. */ shouldRequestUpdate?: boolean; /** * Called when the consumer has connected to a provider. */ onConnect?(): void; /** * Called when the consumed value is updated. */ onUpdate?(newValue: T): void; /** * Called when the host controller has disconnected from the DOM or from a connected provider. */ onDisconnect?(): void; /** * Used to transform the consumed value as it's updated. */ transform?: (newValue: T) => T; }; export declare class ContextConsumerController implements ReactiveController { protected readonly _host: ReactiveControllerHost; readonly initialValue: T; protected readonly _options: ConsumeContextOptions; protected _value: T; protected _ref?: Element; protected _hasConnectedToProvider: boolean; protected readonly _logger: Logger; /** * Custom `DisposalBin` so there's no infinite dep cycle: * * Logger -> ContextConsumer -> DisposalBin -> Logger -> ... */ protected readonly _stopDisposal: { _bin: (() => void)[]; add(cb: () => void): void; empty(): void; }; protected readonly consumerId: symbol; get id(): symbol; get name(): string | symbol | undefined; get value(): T; /** * Whether the consumer is currently connected to a provider. */ get isConnected(): boolean; constructor(_host: ReactiveControllerHost, initialValue: T, _options: ConsumeContextOptions); hostConnected(): void; hostDisconnected(): void; /** * Set a reference to a DOM element that this controller will use to connect to a provider * by dispatching a connect event from it. The reference element's position in the DOM will * dictate which provider it connects to, since it'll connect to the first parent provider * that provides the current context. */ setRef(newRef?: Element): void; /** * Start consuming context. */ start(): void; /** * Stop consuming context. */ stop(): void; /** * Stop current connection to provider and attempts to reconnect. */ reconnect(): void; protected _handleContextConnect(): void; protected _handleContextUpdate(newValue: T): void; protected _handleContextDisconnect(callback: () => void): void; protected _transformValue(value: T): T; }