import { LitElementWw } from '@webwriter/lit' import { CSSResult, TemplateResult, html, css } from 'lit' import { customElement } from 'lit/decorators.js' import { consume } from '@lit/context' import { globalStyles } from '@/global_styles' import type { DataSet } from '@/types/data_set' import type { FeatureDesc } from '@/types/feature_desc' import { dataSetContext } from '@/contexts/data_set_context' import { DataSetUtils } from '@/utils/data_set_utils' import { CCard } from '../reusables/c-card' import { CDataInfo } from '../reusables/c-data-info' import SlDetails from '@shoelace-style/shoelace/dist/components/details/details.component.js' import { msg } from '@lit/localize' export class DataSetInfoCard extends LitElementWw { static scopedElements = { 'c-card': CCard, 'c-data-info': CDataInfo, 'sl-details': SlDetails, } @consume({ context: dataSetContext, subscribe: true }) accessor dataSet: DataSet // METHODS - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - handleSelectDataDesc(featureDesc: FeatureDesc): void { this.dispatchEvent( new CustomEvent('select-data-desc', { detail: featureDesc.key, }), ) } // STYLES - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - static styles: CSSResult[] = [ globalStyles, css` .clickable:hover { cursor: pointer; } `, ] // RENDER - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - render(): TemplateResult<1> { return html`
${this.dataSet.name}

${this.dataSet.description}

${msg('Features')}

${this.dataSet.featureDescs.map( (featureDesc) => html` `, )}

${msg('Label')}

${DataSetUtils.getData(this.dataSet).map( (dataItem) => html`

${dataItem.features.map((feature) => html`${feature} `)} → ${dataItem.label}

`, )}
` } }