All files / site/outputs index.ts

6.66% Statements 1/15
0% Branches 0/10
0% Functions 0/1
7.14% Lines 1/14

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50                                          2x                                                        
import type {SiteSpec} from '../../types'
import type Community from '../index'
import type {OutputDataTable} from './datatables'
import type {OutputInfo} from './info'
import type {OutputLegend} from './legend'
import type {OutputMap} from './map'
import type {OutputPlotly} from './plotly'
import type {OutputTable} from './table'
import type {OutputText} from './text'
 
type OutputTypes = 'info' | 'map' | 'plotly' | 'text' | 'datatable' | 'table' | 'legend'
export type SiteOutputs =
  | OutputInfo
  | OutputMap
  | OutputPlotly
  | OutputText
  | OutputDataTable
  | OutputTable
  | OutputLegend
export type RegisteredOutputs = {[index: string]: SiteOutputs}
 
export abstract class BaseOutput {
  type: OutputTypes
  input = false
  site: Community
  view: string
  e: HTMLElement
  tab?: HTMLElement
  id: string
  note: string
  color?: string
  x?: string
  y?: string
  spec: {[index: string]: any} = {}
  deferred = false
  constructor(e: HTMLElement, site: Community) {
    this.e = e
    this.tab = 'tabpanel' === e.parentElement.getAttribute('role') ? e.parentElement : void 0
    this.site = site
    this.view = e.dataset.view || site.defaults.dataview
    this.id = e.id || 'ui' + site.page.elementCount++
    this.note = e.getAttribute('aria-description') || ''
    this.type = e.dataset.autotype as OutputTypes
    Iif (this.type in site.spec) {
      const spec = site.spec[this.type as keyof SiteSpec] as SiteOutputs
      Iif (this.id in spec) this.spec = (spec as any)[this.id]
    }
  }
}