import { ChildrenManager, RefsManager, ServicesManager, EventsManager, OptionsManager } from './managers/index.js'; export type BaseEl = HTMLElement & { __base__?: Map; }; export type BaseConstructor = { new (...args: any[]): T; prototype: Base; } & Pick; export type BaseAsyncConstructor = (instance: Base) => Promise | { default: BaseConstructor; }>; export type BaseOptions = { [name: string]: unknown; }; export type BaseRefs = { [name: string]: HTMLElement | HTMLElement[]; }; export type BaseChildren = { [nameOrSelector: string]: Base[] | Promise[]; }; export type BaseConfigComponents = { [nameOrSelector: string]: BaseConstructor | BaseAsyncConstructor; }; export type BaseConfig = { name: string; debug?: boolean; log?: boolean; refs?: string[]; emits?: string[]; components?: BaseConfigComponents; options?: import('./managers/OptionsManager').OptionsSchema; }; export type BaseProps = { $el?: HTMLElement; $options?: BaseOptions; $refs?: BaseRefs; $children?: BaseChildren; $parent?: Base; }; export type Managers = { ChildrenManager: typeof ChildrenManager; EventsManager: typeof EventsManager; OptionsManager: typeof OptionsManager; RefsManager: typeof RefsManager; ServicesManager: typeof ServicesManager; }; /** * Base class. * * @link https://js-toolkit.studiometa.dev/api/ */ export declare class Base { /** * Declare the `this.constructor` type * @link https://github.com/microsoft/TypeScript/issues/3841#issuecomment-2381594311 */ ['constructor']: BaseConstructor; /** * This is a Base instance. */ static readonly $isBase: true; /** * Config. * @link https://js-toolkit.studiometa.dev/api/configuration.html */ static config: BaseConfig; /** * The instance id. * @link https://js-toolkit.studiometa.dev/api/instance-properties.html#id */ $id: string; /** * The root element. * @link https://js-toolkit.studiometa.dev/api/instance-properties.html#el */ $el: T['$el'] & BaseEl; /** * The state of the component. * @link https://js-toolkit.studiometa.dev/api/instance-properties.html#isMounted */ $isMounted: boolean; /** * Is the component currently mounting itself and its children? * @private */ __isMounting: boolean; /** * Store the event handlers. * @private */ __eventHandlers: Map>; /** * Get the root instance of the app. * @deprecated Use `$closest(name)` instead. Will be removed in v4. * @link https://js-toolkit.studiometa.dev/api/instance-properties.html#root */ get $root(): Base; /** * The parent instance if the current instance is registered as a child component in a parent component. * @deprecated Use `$closest(name)` instead. Will be removed in v4. * @link https://js-toolkit.studiometa.dev/api/instance-properties.html#parent */ get $parent(): T['$parent'] & Base | null; /** * Internal parent resolution without deprecation warning. * @internal */ get __parent(): T['$parent'] & Base | null; /** * Merge configuration with the parents' configurations. * @private */ get __config(): BaseConfig; /** * The normalized config of the component. * @link https://js-toolkit.studiometa.dev/api/instance-properties.html#config */ get $config(): BaseConfig; __services: ServicesManager; /** * Services. * @link https://js-toolkit.studiometa.dev/api/instance-properties.html#services */ get $services(): ServicesManager; __refs: RefsManager; /** * Refs. * @link https://js-toolkit.studiometa.dev/api/instance-properties.html#refs */ get $refs(): T['$refs'] & BaseRefs; __options: OptionsManager; /** * Options. * @link https://js-toolkit.studiometa.dev/api/instance-properties.html#options */ get $options(): T['$options'] & BaseOptions; __children: ChildrenManager; /** * Children. * @deprecated Use `$query(name)` instead. Will be removed in v4. * @link https://js-toolkit.studiometa.dev/api/instance-properties.html#children */ get $children(): T['$children'] & BaseChildren; /** * Get all descendant component instances matching the given query. * Sugar for `queryComponentAll(query, { from: this.$el })`. * @link https://js-toolkit.studiometa.dev/api/instance-methods.html#query-query */ $query(query: string): U[]; /** * Get the closest ancestor component instance matching the given query. * Sugar for `closestComponent(query, { from: this.$el })`. * @link https://js-toolkit.studiometa.dev/api/instance-methods.html#closest-query */ $closest(query: string): U | undefined; __events: EventsManager; /** * Small helper to log stuff. * @link https://js-toolkit.studiometa.dev/api/instance-methods.html#log-content */ get $log(): (...args: unknown[]) => void; /** * Small helper to make warning easier. * @link https://js-toolkit.studiometa.dev/api/instance-methods.html#warn-content */ get $warn(): (...args: unknown[]) => void; /** * Small helper to debug information. * @internal */ get __debug(): (...args: unknown[]) => void; /** * Get manager constructors. * @internal */ get __managers(): Managers; /** * Call an instance method and emit corresponding events. * @internal */ __callMethod(method: string, ...args: unknown[]): unknown; /** * Test if the given event has been bound to the instance. * * @param {string} event The event's name. * @return {boolean} Wether the given event has been bound or not. * @internal */ __hasEvent(event: string): boolean; /** * Class constructor where all the magic takes place. * * @param {HTMLElement} element The component's root element dd. * @link https://js-toolkit.studiometa.dev/api/instantiation.html */ constructor(element: HTMLElement); /** * Trigger the `mounted` callback. * @link https://js-toolkit.studiometa.dev/api/instance-methods.html#mount */ $mount(): Promise; /** * Update the instance children. * @link https://js-toolkit.studiometa.dev/api/instance-methods.html#update */ $update(): Promise; /** * Trigger the `destroyed` callback. * @link https://js-toolkit.studiometa.dev/api/instance-methods.html#destroy */ $destroy(): Promise; /** * Terminate a child instance when it is not needed anymore. * @link https://js-toolkit.studiometa.dev/api/instance-methods.html#terminate */ $terminate(): Promise; /** * Add an emitted event. * * @param {string} event The event name. * @return {void} * @internal */ __addEmits(event: string): void; /** * Remove an emitted event. * * @param {string} event The event name. * @return {void} * @internal */ __removeEmits(event: string): void; /** * Bind a listener function to an event. * * @param {string} event * Name of the event. * @param {EventListenerOrEventListenerObject} listener * Function to be called. * @param {boolean|AddEventListenerOptions} [options] * Options for the `removeEventListener` method. * @return {() => void} * A function to unbind the listener. * @link https://js-toolkit.studiometa.dev/api/instance-methods.html#on-event-callback-options */ $on(event: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): () => void; /** * Unbind a listener function from an event. * * @param {string} event * Name of the event. * @param {EventListenerOrEventListenerObject} listener * Function to be removed. * @param {boolean|EventListenerOptions} [options] * Options for the `removeEventListener` method. * @return {void} * @link https://js-toolkit.studiometa.dev/api/instance-methods.html#off-event-callback-options */ $off(event: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; /** * Emits an event. * * @param {string} event Name of the event. * @param {any[]} args The arguments to apply to the functions bound to this event. * @return {void} * @link https://js-toolkit.studiometa.dev/api/instance-methods.html#emit-event-args */ $emit(event: string | Event, ...args: unknown[]): void; /** * Register and mount all instances of the component. * @link https://js-toolkit.studiometa.dev/api/static-methods.html#register-nameorselector-string */ static $register = typeof Base>(this: U, nameOrSelector?: string): Promise>[]; }