UNPKG

@public-ui/components

Version:

Contains all web components that belong to KoliBri - The accessible HTML-Standard.

4 lines 3.46 kB
/*! * KoliBri - The accessible HTML-Standard */ import{r as e,h as t,H as i,g as s}from"./index-1ed13705.js";import{i as a}from"./index-ebe5a881.js";import{f as l,e as n,w as o}from"./component-names-7924d82a.js";import{n as c}from"./dev.utils-cb61837d.js";import{c as h}from"./clsx-09a06a12.js";import{v as d}from"./label-bf9966d0.js";import{v as r}from"./open-385de2c9.js";import{v as f}from"./href-d9ccbbdf.js";const _=(e,t,i)=>{a(e,"_active",t,i)},b=class{constructor(t){e(this,t),this.groupId=`tree-group-${c()}`,this.level=void 0,this.state={_active:!1,_hasChildren:!1,_href:"",_label:"",_open:!1},this._active=void 0,this._label=void 0,this._open=void 0,this._href=void 0}render(){const{_href:e,_active:a,_hasChildren:s,_open:o,_label:c}=this.state;return t(i,{key:"1358f3b8f8c7ae14535f30e3c2ff1ef8ab6904b1",onSlotchange:this.handleSlotchange.bind(this)},t("li",{key:"d6271238a133cac44eb78bf8ed0b94a951135432",class:"kol-tree-item",style:{"--level":`${this.level}`}},t(l,{key:"329b9adc28bacf6742544123bc02fe82f2ceb9b5",class:h("kol-tree-item__link",{"kol-tree-item__link--first-level":0===this.level,"kol-tree-item__link--active":a}),_href:e,_label:"",_role:"treeitem",_tabIndex:a?0:-1,_ariaExpanded:s?o:void 0,_ariaOwns:s?this.groupId:void 0,ref:e=>this.linkElement=e},t("span",{key:"0292f071a8abfe0f9332ef4a8561149d38f804e2",class:"kol-tree-item__link-inner",slot:"expert"},s?t("span",{class:"kol-tree-item__toggle-button",onClick:e=>o?void this.handleCollapseClick(e):void this.handleExpandClick(e)},t(n,{class:"kol-tree-item__toggle-button-icon",_icons:"codicon codicon-"+(o?"chevron-down":"chevron-right"),_label:""})):t("span",{class:"kol-tree-item__toggle-button-placeholder"}),t("span",{key:"ed810a798a4e2ba38f848ce0c6fdfc3893c3c86d",class:"kol-tree-item__text"},c))),t("ul",{key:"0e8ea268f1c26f79e55d45bfeda91d230bc4789d",class:"kol-tree-item__children",hidden:!s||!o,role:"group",id:this.groupId},t("slot",{key:"a6509011c3fa851be4c6cace3aadf2b6d6bbfc7b"}))))}validateActive(e){_(this,e||!1)}validateLabel(e){d(this,e)}validateOpen(e){r(this,e)}validateHref(e){f(this,e)}componentWillLoad(){this.validateActive(this._active),this.validateLabel(this._label),this.validateOpen(this._open),this.validateHref(this._href),this.checkForChildren(),this.determineTreeItemDepth()}determineTreeItemDepth(){let e=0,t=this.host.parentNode.host.parentNode;for(;null!==t&&t.tagName.toLowerCase()!==o&&t!==document.body;)t=t.parentElement,e+=1;this.level=e}handleSlotchange(){this.checkForChildren()}checkForChildren(){var e,t;this.state=Object.assign(Object.assign({},this.state),{_hasChildren:Boolean(null===(t=null===(e=this.host.querySelector("slot"))||void 0===e?void 0:e.assignedElements)||void 0===t?void 0:t.call(e).length)})}async focusLink(){await this.linkElement.kolFocus()}async handleExpandClick(e){e.preventDefault(),await this.linkElement.kolFocus(),await this.expand()}async expand(){this.state._hasChildren&&(this.state=Object.assign(Object.assign({},this.state),{_open:!0}))}async handleCollapseClick(e){e.preventDefault(),this.linkElement.focus(),await this.collapse()}async collapse(){this.state._hasChildren&&(this.state=Object.assign(Object.assign({},this.state),{_open:!1}))}async isOpen(){var e;return null!==(e=this.state._open)&&void 0!==e&&e}get host(){return s(this)}static get watchers(){return{_active:["validateActive"],_label:["validateLabel"],_open:["validateOpen"],_href:["validateHref"]}}};export{b as kol_tree_item_wc};