import Vue from 'vue'; interface Watchable { watch(callback: () => void): WatchHandle; } interface WatchHandle { remove(): void; } /** * Builds a component that forwards configured properties to its child. This allows the user to * instantiate a simple Vue component with dynamic data, for example from the OSGI System. * * The general flow is as follows: * - Create a Builder for a Vue Component by calling `Builder.for(childComponent)`. * - Add properties by calling the appropriate methods of the builder. Note that methods return * an instance to the builder itself so it can be used in a fluent way (see example below). * Property names that have already been specified at an earlier time will overwrite the previous entries. * - Call `builder.build()` to obtain the final component. That component wraps the original child * and forwards all configured properties as `props` to that child. When mutable properties are * used, the child will be re-rendered whenever one of these properties change. * * Example: * ``` * import MyComponent from "./Somewhere.vue"; * * // In your code, e.g. in activate(): * const Component = ComponentBuilder.for(MyComponent) * .staticProperty("title", i18n.title) // Provide title in correct language, at runtime * .mutableProperty("user", mutableModel) // Provide user from mutableModel (instance of apprt-core/Mutable) * .build(); // Finalize construction * * // Use the new component somewhere, e.g. mount it in the DOM * ``` */ declare class ComponentBuilder { #private; private constructor(); /** * Creates a new builder. Components created using this builder will wrap the given childComponent, which * must be a Vue Component. */ static for(childComponent: any): ComponentBuilder; /** * Add a new static property with the given name and value to the builder. * * @param name The name of the new property * @param value The static value of the new property * @returns this */ staticProperty(name: string, value: any): ComponentBuilder; /** * Adds all entries in `props` as static properties. * * @param props A mapping from properties name to values. * @returns this */ staticProperties(props: any): ComponentBuilder; /** * Adds a new mutable property with the given name. The value of that property will be * retrieved from the provided mutable instance. `mutable` will also be watched, and the * current value will be provided to the child component. * * @param name The name of the property (both in `mutable` and in the built component). * @param mutable The mutable model (instance of `apprt-core/Mutable`). * @returns this */ mutableProperty(name: string, mutable: any): ComponentBuilder; /** * Adds multiple properties (specified in `names`) from the given mutable model. * * @param mutable An instance of `apprt-core/Mutable`. * @param names A sequence of property names. * @returns this */ mutableProperties(mutable: any, ...names: string[]): ComponentBuilder; /** * Adds all properties present on the mutable object. * * @param mutable An instance of `apprt-core/Mutable`. */ allMutableProperties(mutable: any): ComponentBuilder; /** * Registers a watchable object. The component will rerender itself * whenever the watchable triggers an event. */ watchable(source: Watchable): ComponentBuilder; /** * Provides a static value under the given name to all descendant components (i.e. childComponent * and all its children and so on). Note: Vue does not support reactive components in this instance. * * @param name The name of the provided value, as a string or a symbol. * @param value The static value that will be provided to all descendants. * @returns this */ provideValue(name: string | symbol, value: any): ComponentBuilder; /** * Provides multiple (key, value) pairs to all descendant components. * * @param values An object containing symbols or string keys associated with static values. * @returns this */ provideValues(values: Record): ComponentBuilder; /** * Constructs a new Vue component that forwards all configured properties to its child component. * * @returns A vue component. */ build(): typeof Vue; } export { ComponentBuilder, WatchHandle, Watchable };