Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface IComponent

Hierarchy

Implements

Implemented by

Index

Properties

attributes

attributes: AttributeManipulator<this>

childCount

childCount: number

The number of child UiElements in this element.

classes

classes: ClassManipulator<this>

consumed

consumed: number

data

data: DataManipulator<this>

dataset

dataset: DOMStringMap

The dataset of the internal element.

element

element: HTMLElement

The element that this UiElement instance wraps.

Readonly event

event: IEventEmitter<this, IComponentEvents> = new EventEmitter<this, E>(this)

have

have: number

listen

listen: Element["addEventListener"]

required

required: number

selectable

selectable: false | SelectableLayer

The selectable layer of this element, or false if it is not selectable.

style

style: StyleManipulator<this>

type

Methods

append

  • Append every element of a list of elements.

    Parameters

    • Rest ...elements: ArrayOfIterablesOr<HTMLElement | IComponent | undefined | false>

      A varargs list of elements or iterables of elements. undefined is skipped

    Returns this

appendTo

  • Append this element to another element, by selector, element, or UiElement.

    The element is only added to a UiElement wrapper if given that wrapper and not its internal element.

    Parameters

    Returns this

contains

  • contains(what: string | HTMLElement | IComponent): boolean
  • Returns whether this UiElement contains the given element.

    Parameters

    Returns boolean

dump

  • dump(): this
  • dump(filter: (element: HTMLElement, component?: Component) => boolean): this
  • Remove all children

    Returns this

  • Remove all children that are not filtered out with the given filter function

    Parameters

    • filter: (element: HTMLElement, component?: Component) => boolean

      A function that will return true if the child should be kept

        • (element: HTMLElement, component?: Component): boolean
        • Parameters

          • element: HTMLElement
          • Optional component: Component

          Returns boolean

    Returns this

findDescendants

  • findDescendants(selector: string): NodeListOf<Element>
  • An alias for element.querySelectorAll(selector)

    Parameters

    • selector: string

    Returns NodeListOf<Element>

getBox

  • getBox(): ClientRect | DOMRect
  • An alias for element.getBoundingClientRect()

    Returns ClientRect | DOMRect

getChildren

  • Returns a new array of the children

    Returns Stream<IComponent>

getNthChild

  • getNthChild(nth?: undefined | number): IComponent
  • Returns the nth child, defaulting to the first child

    Parameters

    • Optional nth: undefined | number

    Returns IComponent

getOffset

  • getOffset(): { left: number; top: number }
  • Returns an object containing element.offsetTop and element.offsetLeft

    Returns { left: number; top: number }

    • left: number
    • top: number

hide

  • hide(): this
  • Hides the element. If a tooltip is shown for this element, hides that as well.

    Returns this

isVisible

  • isVisible(): boolean
  • Returns whether the element is visible.

    Returns boolean

remove

  • remove(): void
  • Remove this element.

    This will remove all child UiElements, remove itself from its parent UiElement, and then remove itself from the DOM.

    Returns void

repaint

  • repaint(): void
  • Triggers a repaint on this element.

    Returns void

schedule

  • schedule(cb?: undefined | ((this: this, button: this, ...args: any[]) => any), ...args: any[]): this
  • schedule(ms: number, cb?: undefined | ((this: this, button: this, ...args: any[]) => any), ...args: any[]): this
  • schedule(ms: number, debounce: number, cb?: undefined | ((this: this, button: this, ...args: any[]) => any), ...args: any[]): this
  • Runs the given callback with the given arguments. this and the first argument are this element.

    Parameters

    • Optional cb: undefined | ((this: this, button: this, ...args: any[]) => any)

      The callback to run.

    • Rest ...args: any[]

      The arguments with which to call the callback.

    Returns this

  • Runs the given callback with the given arguments, after the specified amount of time. this and the first argument are this element.

    Parameters

    • ms: number

      The amount of time to wait before running the callback, in milliseconds.

    • Optional cb: undefined | ((this: this, button: this, ...args: any[]) => any)

      The callback to run.

    • Rest ...args: any[]

      The arguments with which to call the callback.

    Returns this

  • Runs the given callback with the given arguments, after the specified amount of time. this and the first argument are this element.

    Parameters

    • ms: number

      The amount of time to wait before running the callback, in milliseconds.

    • debounce: number

      The span of time to debounce in. (If this callback was scheduled again in this time, skip this earlier call)

    • Optional cb: undefined | ((this: this, button: this, ...args: any[]) => any)

      The callback to run.

    • Rest ...args: any[]

      The arguments with which to call the callback.

    Returns this

scrollTo

  • scrollTo(child: IComponent, ms?: undefined | number): void
  • Scrolls this element so the given child is at the top of the viewport.

    Parameters

    • child: IComponent

      The child to scroll to

    • Optional ms: undefined | number

      The time to take, defaulting to 1000 (1 second)

    Returns void

setContents

  • setContents(html: string, escape?: undefined | false | true): this
  • Sets the contents of this element using innerHTML.

    Parameters

    • html: string

      The content, an HTML string. Script tags will not be executed, as per the normal functionality of innerHTML

    • Optional escape: undefined | false | true

      Only the text within the HTML will be appended, not the tags.

    Returns this

setContextMenu

  • setContextMenu(): void
  • setContextMenu(generator: () => IComponent): void
  • Remove the context menu from this element

    Returns void

  • Set the context menu for this element

    Parameters

    Returns void

setId

  • setId(id: string): this
  • Sets the ID of this component's element.

    Parameters

    • id: string

    Returns this

setTooltip

  • Sets the tooltip options for this element. Setting the tooltip to undefined, or not providing the argument removes the tooltip options.

    Parameters

    Returns this

show

  • show(): this
  • Shows the element.

    Returns this

store

  • store(): void
  • Moves this element to a hidden element, in order to retain any information the element had. This allows the element to be re-appended later without re-adding event handlers, CSS, or any other data.

    Returns void

toggle

  • toggle(visible: boolean): this
  • Toggles the visibility of this element. Internally uses show and hide.

    Parameters

    • visible: boolean

      The new visiblity of this element.

    Returns this

Generated using TypeDoc