import type { UmbContextToken } from '../token/index.js'; import type { UmbContextMinimal } from '../types.js'; export interface UmbProvideOptions { context: string | UmbContextToken; } /** * A property decorator that creates an UmbContextProviderController to provide * a context value to child elements via the Umbraco Context API. * * This decorator supports both modern "standard" decorators (Stage 3 TC39 proposal) and * legacy TypeScript experimental decorators for backward compatibility. * * The provider is created once during initialization with the property's initial value. * To update the provided value dynamically, keep a state inside the provided context instance * and update that state as needed. The context instance itself should remain the same. * You can use any of the Umb{*}State classes. * @param {UmbProvideOptions} options Configuration object containing the context token * @example * ```ts * import {provideContext} from '../index.js'; * import {UMB_WORKSPACE_CONTEXT} from './workspace.context-token.js'; * * class MyWorkspaceElement extends UmbLitElement { * // Standard decorators - requires 'accessor' keyword * @provideContext({context: UMB_WORKSPACE_CONTEXT}) * accessor workspaceContext = new UmbWorkspaceContext(this); * * // Legacy decorators - works without 'accessor' * @provideContext({context: UMB_WORKSPACE_CONTEXT}) * workspaceContext = new UmbWorkspaceContext(this); * } * ``` * @example * ```ts * // For dynamic updates, store the state inside the context instance * class MyContext extends UmbControllerBase { * someProperty = new UmbStringState('initial value'); * } * * class MyElement extends UmbLitElement { * @provideContext({context: MY_CONTEXT}) * private _myContext = new MyContext(this); * * updateValue(newValue: string) { * this._myContext.someProperty.setValue(newValue); * } * } * ``` * @returns {ProvideDecorator} A property decorator function */ export declare function provideContext(options: UmbProvideOptions): ProvideDecorator; /** * Generates a public interface type that removes private and protected fields. * This allows accepting otherwise compatible versions of the type (e.g. from * multiple copies of the same package in `node_modules`). */ type Interface = { [K in keyof T]: T[K]; }; declare class ReactiveElement { static addInitializer?: (initializer: (instance: any) => void) => void; } declare class ReactiveController { hostConnected?: () => void; } /** * A type representing the base class of which the decorator should work * requiring either addInitializer (UmbLitElement) or hostConnected (UmbController). */ type ReactiveEntity = ReactiveElement | ReactiveController; type ProvideDecorator = { >(protoOrDescriptor: Proto, name?: K): FieldMustMatchContextType; , V extends ContextType>(value: ClassAccessorDecoratorTarget, context: ClassAccessorDecoratorContext): void; }; type DecoratorReturn = void | any; type FieldMustMatchContextType = Obj extends Record ? [ ProvidingType ] extends [ContextType] ? DecoratorReturn : { message: 'providing field not assignable to context'; context: ContextType; provided: ProvidingType; } : Obj extends Partial> ? [ Providing | undefined ] extends [ContextType] ? DecoratorReturn : { message: 'providing field not assignable to context'; context: ContextType; consuming: Providing | undefined; } : DecoratorReturn; export {};