import { LitElementWw } from '@webwriter/lit' import { CSSResult, TemplateResult, html } from 'lit' import { customElement, property } from 'lit/decorators.js' import { globalStyles } from '@/global_styles' import type { DataSet } from '@/types/data_set' import type { FeatureDesc } from '@/types/feature_desc' import type { LabelDesc } from '@/types/label_desc' import SlTooltip from "@shoelace-style/shoelace/dist/components/tooltip/tooltip.component.js" import SlTag from "@shoelace-style/shoelace/dist/components/tag/tag.component.js" export class CDataInfo extends LitElementWw { static scopedElements = { "sl-tooltip": SlTooltip, "sl-tag": SlTag } @property() accessor type: 'feature' | 'label' @property() accessor dataDesc: FeatureDesc | LabelDesc @property() accessor dataSet: DataSet // STYLES - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - static styles: CSSResult = globalStyles // RENDER - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - getTooltipContent(): TemplateResult<1> { switch (this.type) { case 'feature': return html`

${this.dataDesc.description}

` case 'label': switch (this.dataSet.type) { case 'regression': return html`

${this.dataDesc.description}

Type: regression

` case 'classification': return html`

${this.dataDesc.description}

Type: classification

${'classes' in this.dataDesc ? html` ${this.dataDesc.classes.map( (clazz) => html`

${clazz.id.toString()}: ${clazz.description}

` )} ` : html``} ` default: console.error(`Data set has no type!`) return html`` } default: console.error(`No or wrong type argument was passed to c-data-info`) return html`` } } render(): TemplateResult<1> { return html`
${this.getTooltipContent()}
${this.dataDesc.key}
` } }