sparc - v1.0.1
    Preparing search index...

    Abstract base class for rendering structured HTML elements with unique IDs, BEM-based class names, event management, and child support.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    _children?: HTMDNode
    _containerSelector: string

    should be ...but for the sake of simplicity, when undefined ill assign an empty string Pardon me for the incoherence and read the HTMDElementInterface docs on the same property

    _isOpen: boolean
    _onCloseHandler: () => void
    _onOpenHandler: () => void
    _variant: DialogVariants
    backdrop: boolean
    closeOnFocusLoss: boolean
    isHTMD: true

    Discriminator to identify classes that implement this interface

    isHTMDComponent

    selectableItems: boolean

    Accessors

    • get class(): string

      Returns string

    • set class(classList: string): void

      A string containing all css classes attached to the element. Note that classes added via other methods will not be present here. Internally FormControls use modifierClasses, but external tools can also be used to add remove classes to the DOM. This is NOT the intended use.

      Setter method ensures that element classes are not removed

      Parameters

      • classList: string

      Returns void

      MyElement.class ="special-class"
      console.log(MyElement.class) //`${SPARC_PREFIX}__${this.name} special-class`
    • get containerSelector(): string

      A css selector to specify where the element should be rendered When nesting elements, the parent should be responsible for assigning the containerSelector on its children

      Returns string

    • set containerSelector(selector: string): void

      A css selector to specify where the element should be rendered When nesting elements, the parent should be responsible for assigning the containerSelector on its children

      Parameters

      • selector: string

      Returns void

    • get id(): string

      By default an UUID is used. Can be overridden. This id can be used to identify both the object, and the DOM representation.

      Returns string

    • get instance(): null | JQuery<HTMLElement>

      Returns the jQuery DOM instance, if it is present in the DOM.

      Returns null | JQuery<HTMLElement>

    • get name(): string

      Returns the lowercase class name responsible for creating this object. This property is used to define the element's main class too

      Returns string

    • get selector(): string

      Returns the element's CSS selector.

      Returns string

      `${this._containerSelector} #${this.id}.${this.topClassBEM}`;
      

    Methods

    • Handles child rendering, removing existing nodes from the DOM, and rendering them inside this element.

      Parameters

      • children: undefined | HTMDNode = ...
      • Optionaloptions: { childContainerSelector?: string }

      Returns void

      const childContainerSelector = undefined // this.children -> rendered directly on this.instance
      const childContainerSelector = ".child-wrapper" // this.children -> rendered on this.instance.find(".child-wrapper")
    • Removes specified event handlers, or all if none are specified.

      Type Parameters

      • K extends keyof HTMLElementEventMap

      Parameters

      • OptionaleventsList: K | K[]

        An array of event types to clear (or a single type).

      Returns void

    • Registers an event handler for a given event type on this element. Replaces any previously assigned handler for the same event.

      Type Parameters

      • K extends keyof HTMLElementEventMap

      Parameters

      • eventName: K

        The DOM event type to listen for (e.g., 'click').

      • Optionalcallback: (ev: HTMLElementEventMap[K]) => void

        The event handler function.

      Returns void