Sha256: 0ed87de68a4057d360d0b643157dc8602339eea22449b1f5a96049dd3a102e94

Contents?: true

Size: 1.86 KB

Versions: 645

Compression:

Stored size: 1.86 KB

Contents

// eslint-disable-next-line
// @ts-nocheck
import ElementObserver from './element_observer'

export default class PbEnhancedElement {
  static _elements: Map<Element, PbEnhancedElement>
  static _observer: ElementObserver
  element: Element

  constructor(element?: Element) {
    this.element = element
  }

  static get elements(): Map<Element, PbEnhancedElement> {
    return this._elements = (this._elements || new Map)
  }

  static get observer(): ElementObserver {
    return this._observer = (this._observer || new ElementObserver(this))
  }

  static get selector(): string {
    // eslint-disable-next-line no-console
    console.warn('Define a static property for selector or redefine the matches function in a subclass.', this)
    return null
  }

  static matches(node: Element): Array<Element> {
    if (!this.selector) return []

    const matches = []
    if (node.nodeType === Node.ELEMENT_NODE && node.matches(this.selector)) matches.push(node)
    matches.push(...node.querySelectorAll(this.selector))

    return (matches)
  }

  static addMatch(element: Element): void {
    if (element._pbEnhanced || this.elements.has(element)) return

    const enhansedElement = new this(element)
    enhansedElement.connect()
    this.elements.set(element, enhansedElement)
    element._pbEnhanced = enhansedElement
  }

  static removeMatch(element: Element): void {
    if (!this.elements.has(element)) return

    const enhansedElement = this.elements.get(element)
    enhansedElement.disconnect()
    this.elements.delete(element)
  }

  static start(): void {
    this.observer.start()
  }

  static stop(): void {
    this.mutationObserver.stop()
  }

  connect(): void {
    // eslint-disable-next-line no-console
    console.warn('Redefine the connect function in a subclass.', this)
  }

  // eslint-disable-next-line @typescript-eslint/no-empty-function
  disconnect(): void {}
}

Version data entries

645 entries across 645 versions & 1 rubygems

Version Path
playbook_ui-13.21.0.pre.alpha.PBNTR224letuserresetrowexpansion2441 app/pb_kits/playbook/pb_enhanced_element/index.ts
playbook_ui-13.21.0.pre.alpha.PBNTR225advancedtablefeedback2438 app/pb_kits/playbook/pb_enhanced_element/index.ts
playbook_ui-13.21.0.pre.alpha.PBNTR238DatePickerYearBug2436 app/pb_kits/playbook/pb_enhanced_element/index.ts
playbook_ui-13.21.0.pre.alpha.pbntr220improveexpansionspeed2431 app/pb_kits/playbook/pb_enhanced_element/index.ts
playbook_ui-13.21.0.pre.alpha.pbntr220improveexpansionspeed2415 app/pb_kits/playbook/pb_enhanced_element/index.ts
playbook_ui-13.20.0.pre.alpha.play1247htmloptions2404 app/pb_kits/playbook/pb_enhanced_element/index.ts
playbook_ui-13.20.0.pre.alpha.play1247htmloptions2403 app/pb_kits/playbook/pb_enhanced_element/index.ts
playbook_ui-13.20.0.pre.alpha.PLAY12572402 app/pb_kits/playbook/pb_enhanced_element/index.ts
playbook_ui-13.21.0 app/pb_kits/playbook/pb_enhanced_element/index.ts
playbook_ui-13.20.0.pre.alpha.PBNTR225advancedtablefeedback2375 app/pb_kits/playbook/pb_enhanced_element/index.ts
playbook_ui-13.19.0.pre.alpha.PBNTR200addadvancedtablekitdarkmodestyles2346 app/pb_kits/playbook/pb_enhanced_element/index.ts
playbook_ui-13.19.0.pre.alpha.play1174fixconfimationtoastmobilebug2345 app/pb_kits/playbook/pb_enhanced_element/index.ts
playbook_ui-13.19.0.pre.alpha.play1174fixconfimationtoastmobilebug2342 app/pb_kits/playbook/pb_enhanced_element/index.ts
playbook_ui-13.19.0.pre.alpha.play1186collapsiblenaviconcolorbug2321 app/pb_kits/playbook/pb_enhanced_element/index.ts
playbook_ui-13.19.0.pre.alpha.PBNTR211tablekitsubcomponentsreact2318 app/pb_kits/playbook/pb_enhanced_element/index.ts
playbook_ui-13.19.0.pre.alpha.play1174fixconfimationtoastmobilebug2306 app/pb_kits/playbook/pb_enhanced_element/index.ts
playbook_ui-13.19.0.pre.alpha.play1174fixconfimationtoastmobilebug2305 app/pb_kits/playbook/pb_enhanced_element/index.ts
playbook_ui-13.20.0 app/pb_kits/playbook/pb_enhanced_element/index.ts
playbook_ui-13.19.0.pre.alpha.play1141iconkitusinglibrary2264 app/pb_kits/playbook/pb_enhanced_element/index.ts
playbook_ui-13.19.0.pre.alpha.PBNTR207tabledivsupport2261 app/pb_kits/playbook/pb_enhanced_element/index.ts