UNPKG

@scania/tegel

Version:
51 lines (50 loc) 1.72 kB
import { h, Host } from "@stencil/core"; import getPreviousNestedChildOfSiblingsMatching from "../../../utils/getPreviousNestedChildOfSiblingsMatching"; import isHeadingElement from "../../../utils/isHeadingElement"; /** * @slot <default> - <b>Unnamed slot.</b> For a grid item element. */ export class TdsHeaderLauncherGrid { constructor() { this.headingElement = undefined; } componentWillLoad() { const listRoot = this.host; const headingEl = getPreviousNestedChildOfSiblingsMatching(listRoot, (el) => { const e = el; return isHeadingElement(e); }); if (headingEl) { this.headingElement = headingEl; } else { console.warn('Heading element for list not found'); } } render() { var _a; const listAttributes = { 'class': 'tds-header-launcher-grid', 'role': 'list', 'aria-labelledby': (_a = this.headingElement) === null || _a === void 0 ? void 0 : _a.id, }; return (h(Host, { key: '3f2f7a655fef2f9d996851065a54b1f86929c989' }, h("div", Object.assign({ key: '2a111751b897f09bedeaa332fb7c9c0ef46ba5cd' }, listAttributes), h("slot", { key: '9e172d88f775c2f7508fb55b7de5cec49e7c9160' })))); } static get is() { return "tds-header-launcher-grid"; } static get originalStyleUrls() { return { "$": ["header-launcher-grid.scss"] }; } static get styleUrls() { return { "$": ["header-launcher-grid.css"] }; } static get states() { return { "headingElement": {} }; } static get elementRef() { return "host"; } }