import type { OrArray } from '@jsmanifest/typefest'; import type { ComponentObject, StyleObject } from 'noodl-types'; import * as t from './types'; type Hooks = Record; declare class Component { #private; type: C['type']; static isComponent(component: unknown): component is t.NuiComponent.Instance; [Symbol.iterator](): { next(): { done: boolean; value: [] | [keyof ComponentObject, any]; }; }; constructor(component: C, opts?: { id?: string; }); get blueprint(): ComponentObject; get children(): t.NuiComponent.Instance[]; get defaultChildren(): t.NuiComponent.Instance[]; get contentType(): any; get hooks(): Hooks; get id(): string; get length(): number; get parent(): t.NuiComponent.Instance | null; get eventListeners(): {}; /** * Returns the value of the component property using key, or * Returns the value of the property of the component's style object * using styleKey if key === 'style' * @param { string } key - Component property or "style" if using styleKey for style lookups */ get props(): ComponentObject & { id: string; }; /** Returns the most recent styles at the time of this call */ get style(): StyleObject; set style(style: StyleObject); addEventListeners({ event, callback, }: { event: string; callback: Function; }): void; removeAllEventListeners(): void; /** * Returns the value of the component property using key, or * Returns the value of the property of the component's style object * using styleKey if key === 'style' * @param { string } key - Component property or "style" if using styleKey for style lookups */ get(key: K | K[], styleKey?: keyof StyleObject): ComponentObject[K] | Record | undefined; /** * Sets a property's value on the component, or sets a property's value on * the style object if the key is "style", value is the styleKey and * styleChanges is the value to update on the style object's styleKey * @param { string } key - Key of component or "style" to update the style object using value * @param { any? } value - Value to update key, or styleKey to update the style object if key === 'style' * @param { any? } styleChanges - Value to set on a style object if key === 'style' */ set(key: K, value?: any, styleChanges?: any): this; set(key: O, value?: any, styleChanges?: any): this; /** * Returns true if the key exists on the blueprint * NOTE: This method is for keys that have explicitly been set via * this.set * @param { string } key - Component property or "style" if using styleKey for style lookups */ has(key: K): boolean; /** * Removes a component property, or removes a style property from the style object * using styleKey if key === 'style' * @param { string } key - Component property, or "style" if removing a style property using styleKey */ remove(key: string, styleKey?: keyof StyleObject): this; /** * Returns a stringified JSON object of the current component * @param { number | undefined } spaces - Spaces to indent in the JSON string */ toString({ spaces }?: { spaces?: number; }): any; setParent(parent: t.NuiComponent.Instance | null): this; /** * Returns a child at the index. Returns null if nothing was found. * If an index is not passed in it will default to returning the * first child or null otherwise * @param { number } index */ child(index?: number): t.NuiComponent.Instance; /** * Creates and appends the new child instance to the childrens list * @param { IComponentType } props */ createChild(child: C): C; /** * Removes a child from its children. You can pass in either the instance * directly, the index leading to the child, the component's id, or leave the args empty to * remove the first child by default * @param { t.NuiComponent.Instance | string | number | undefined } child - Child component, id, index, or no arg (to remove the first child by default) */ removeChild(index: number): t.NuiComponent.Instance | undefined; removeChild(id: string): t.NuiComponent.Instance | undefined; removeChild(child: t.NuiComponent.Instance): t.NuiComponent.Instance | undefined; removeChild(): t.NuiComponent.Instance | undefined; removeAllDefaultChild(): never[]; copyFromChildrenToDefault(): void; on(eventName: Evt, cb: t.NuiComponent.Hook[Evt], id?: string): this; off(eventName: Evt, cb: t.NuiComponent.Hook[Evt]): this; emit(eventName: Evt, ...args: Parameters>): Promise[] | undefined>; clear(filter?: OrArray<'children' | 'hooks'>): this; /** * Explicitly setting style to null resets it back to an empty object * @param { string | function | object } props * @param { any | undefined } value */ edit(fn: (props: ComponentObject) => ComponentObject | undefined | void): void; edit(prop: Record, opts?: t.NuiComponent.EditResolutionOptions): void; edit(prop: string, value: any): void; /** Returns the JS representation of the currently resolved component */ toJSON(): any; } export default Component;