UNPKG

@public-ui/components

Version:

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

4 lines 28.5 kB
/*! * KoliBri - The accessible HTML-Standard */ import{r as t,h as e,F as n,g as r}from"./index-DyUiyxj3.js";import{c as i}from"./clsx-eK3rPvPS.js";import{e as o,a,d as l,x as s}from"./component-names-B_kYyA8u.js";import{t as c}from"./i18n-CvQhdUrE.js";import{O as u,o as f,p as d,w as h,s as v}from"./common-BXXICkFX.js";import{b,v as _,a as p,e as y,c as k}from"./table-selection-C4VgH6EI.js";import{v as j}from"./label-Dkj9sxQK.js";import{C as m}from"./keyboard-DNd73LVa.js";import{n as g}from"./dev.utils-EtfHgKpk.js";import{d as w,K as S}from"./events-DHTi_wtD.js";import{i as A,c as O,r as $,a as D,f as x,b as C,S as M}from"./isObject-DvSELytj.js";import"./i18n-B0tfVPMa.js";const F=(e,t)=>{u(t,()=>{f(t,()=>{try{t=d(t)}catch(e){}h(e,"_headerCells",e=>{var t,r;return"object"==typeof e&&null!==e&&(void 0===e.horizontal||Array.isArray(e.horizontal)&&void 0===e.horizontal.find(e=>!Array.isArray(e)))&&(void 0===e.vertical||Array.isArray(e.vertical)&&void 0===e.vertical.find(e=>!Array.isArray(e)))&&[...null!==(t=e.horizontal)&&void 0!==t?t:[],...null!==(r=e.vertical)&&void 0!==r?r:[]].flat().every(e=>void 0===e.width||"number"==typeof e.width)&&!0},new Set(["TableHeaderCellsPropType"]),t)})})};var H="[object AsyncFunction]",E="[object Function]",K="[object GeneratorFunction]",P="[object Proxy]";function R(e){if(!A(e))return!1;var t=O(e);return t==E||t==K||t==H||t==P}var W=$["__core-js_shared__"],T=function(){var e=/[^.]+$/.exec(W&&W.keys&&W.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function B(e){return!!T&&T in e}var I=Function.prototype,U=I.toString;function z(e){if(null!=e){try{return U.call(e)}catch(e){}try{return e+""}catch(e){}}return""}var L=/[\\^$.*+?()[\]{}|]/g,V=/^\[object .+?Constructor\]$/,N=Function.prototype,X=Object.prototype,Q=N.toString,q=X.hasOwnProperty,G=RegExp("^"+Q.call(q).replace(L,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Y(e){return!(!A(e)||B(e))&&(R(e)?G:V).test(z(e))}function J(e,t){return null==e?void 0:e[t]}function Z(e,t){var r=J(e,t);return Y(r)?r:void 0}var tt=Z($,"WeakMap"),et=9007199254740991,nt=/^(?:0|[1-9]\d*)$/;function rt(e,t){var r=typeof e;return!!(t=null==t?et:t)&&("number"==r||"symbol"!=r&&nt.test(e))&&e>-1&&e%1==0&&e<t}function it(e,t){return e===t||e!=e&&t!=t}var ot=9007199254740991;function at(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=ot}function lt(e){return null!=e&&at(e.length)&&!R(e)}var st=Object.prototype;function ct(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||st)}function ut(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}var ft="[object Arguments]";function dt(e){return D(e)&&O(e)==ft}var ht=Object.prototype,vt=ht.hasOwnProperty,bt=ht.propertyIsEnumerable,_t=dt(function(){return arguments}())?dt:function(e){return D(e)&&vt.call(e,"callee")&&!bt.call(e,"callee")};function pt(){return!1}var yt="object"==typeof exports&&exports&&!exports.nodeType&&exports,kt=yt&&"object"==typeof module&&module&&!module.nodeType&&module,jt=kt&&kt.exports===yt,mt=jt?$.Buffer:void 0,gt=mt?mt.isBuffer:void 0,wt=gt||pt,St="[object Arguments]",At="[object Array]",Ot="[object Boolean]",$t="[object Date]",Dt="[object Error]",xt="[object Function]",Ct="[object Map]",Mt="[object Number]",Ft="[object Object]",Ht="[object RegExp]",Et="[object Set]",Kt="[object String]",Pt="[object WeakMap]",Rt="[object ArrayBuffer]",Wt="[object DataView]",Tt="[object Float32Array]",Bt="[object Float64Array]",It="[object Int8Array]",Ut="[object Int16Array]",zt="[object Int32Array]",Lt="[object Uint8Array]",Vt="[object Uint8ClampedArray]",Nt="[object Uint16Array]",Xt="[object Uint32Array]",Qt={};function qt(e){return D(e)&&at(e.length)&&!!Qt[O(e)]}function Gt(e){return function(t){return e(t)}}Qt[Tt]=Qt[Bt]=Qt[It]=Qt[Ut]=Qt[zt]=Qt[Lt]=Qt[Vt]=Qt[Nt]=Qt[Xt]=!0,Qt[St]=Qt[At]=Qt[Rt]=Qt[Ot]=Qt[Wt]=Qt[$t]=Qt[Dt]=Qt[xt]=Qt[Ct]=Qt[Mt]=Qt[Ft]=Qt[Ht]=Qt[Et]=Qt[Kt]=Qt[Pt]=!1;var Yt="object"==typeof exports&&exports&&!exports.nodeType&&exports,Jt=Yt&&"object"==typeof module&&module&&!module.nodeType&&module,Zt=Jt&&Jt.exports===Yt,te=Zt&&x.process,ee=function(){try{var e=Jt&&Jt.require&&Jt.require("util").types;return e||te&&te.binding&&te.binding("util")}catch(e){}}(),ne=ee&&ee.isTypedArray,re=ne?Gt(ne):qt,ie=Object.prototype,oe=ie.hasOwnProperty;function ae(e,t){var r=C(e),n=!r&&_t(e),a=!r&&!n&&wt(e),o=!r&&!n&&!a&&re(e),i=r||n||a||o,l=i?ut(e.length,String):[],s=l.length;for(var c in e)!oe.call(e,c)||i&&("length"==c||a&&("offset"==c||"parent"==c)||o&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||rt(c,s))||l.push(c);return l}function le(e,t){return function(r){return e(t(r))}}var se=le(Object.keys,Object),ce=Object.prototype,ue=ce.hasOwnProperty;function fe(e){if(!ct(e))return se(e);var t=[];for(var r in Object(e))ue.call(e,r)&&"constructor"!=r&&t.push(r);return t}function de(e){return lt(e)?ae(e):fe(e)}var he=Z(Object,"create");function ve(){this.__data__=he?he(null):{},this.size=0}function be(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var _e="__lodash_hash_undefined__",pe=Object.prototype,ye=pe.hasOwnProperty;function ke(e){var t=this.__data__;if(he){var r=t[e];return r===_e?void 0:r}return ye.call(t,e)?t[e]:void 0}var je=Object.prototype,me=je.hasOwnProperty;function ge(e){var t=this.__data__;return he?void 0!==t[e]:me.call(t,e)}var we="__lodash_hash_undefined__";function Se(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=he&&void 0===t?we:t,this}function Ae(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function Oe(){this.__data__=[],this.size=0}function $e(e,t){for(var r=e.length;r--;)if(it(e[r][0],t))return r;return-1}Ae.prototype.clear=ve,Ae.prototype.delete=be,Ae.prototype.get=ke,Ae.prototype.has=ge,Ae.prototype.set=Se;var De=Array.prototype,xe=De.splice;function Ce(e){var t=this.__data__,r=$e(t,e);return!(r<0)&&(r==t.length-1?t.pop():xe.call(t,r,1),--this.size,!0)}function Me(e){var t=this.__data__,r=$e(t,e);return r<0?void 0:t[r][1]}function Fe(e){return $e(this.__data__,e)>-1}function He(e,t){var r=this.__data__,n=$e(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this}function Ee(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}Ee.prototype.clear=Oe,Ee.prototype.delete=Ce,Ee.prototype.get=Me,Ee.prototype.has=Fe,Ee.prototype.set=He;var Ke=Z($,"Map");function Pe(){this.size=0,this.__data__={hash:new Ae,map:new(Ke||Ee),string:new Ae}}function Re(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}function We(e,t){var r=e.__data__;return Re(t)?r["string"==typeof t?"string":"hash"]:r.map}function Te(e){var t=We(this,e).delete(e);return this.size-=t?1:0,t}function Be(e){return We(this,e).get(e)}function Ie(e){return We(this,e).has(e)}function Ue(e,t){var r=We(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this}function ze(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function Le(e,t){for(var r=-1,n=t.length,a=e.length;++r<n;)e[a+r]=t[r];return e}function Ve(){this.__data__=new Ee,this.size=0}function Ne(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r}function Xe(e){return this.__data__.get(e)}function Qe(e){return this.__data__.has(e)}ze.prototype.clear=Pe,ze.prototype.delete=Te,ze.prototype.get=Be,ze.prototype.has=Ie,ze.prototype.set=Ue;var qe=200;function Ge(e,t){var r=this.__data__;if(r instanceof Ee){var n=r.__data__;if(!Ke||n.length<qe-1)return n.push([e,t]),this.size=++r.size,this;r=this.__data__=new ze(n)}return r.set(e,t),this.size=r.size,this}function Ye(e){var t=this.__data__=new Ee(e);this.size=t.size}function Je(e,t){for(var r=-1,n=null==e?0:e.length,a=0,o=[];++r<n;){var i=e[r];t(i,r,e)&&(o[a++]=i)}return o}function Ze(){return[]}Ye.prototype.clear=Ve,Ye.prototype.delete=Ne,Ye.prototype.get=Xe,Ye.prototype.has=Qe,Ye.prototype.set=Ge;var tn=Object.prototype,en=tn.propertyIsEnumerable,nn=Object.getOwnPropertySymbols,rn=nn?function(e){return null==e?[]:(e=Object(e),Je(nn(e),function(t){return en.call(e,t)}))}:Ze;function on(e,t,r){var n=t(e);return C(e)?n:Le(n,r(e))}function an(e){return on(e,de,rn)}var ln=Z($,"DataView"),sn=Z($,"Promise"),cn=Z($,"Set"),un="[object Map]",fn="[object Object]",dn="[object Promise]",hn="[object Set]",vn="[object WeakMap]",bn="[object DataView]",_n=z(ln),pn=z(Ke),yn=z(sn),kn=z(cn),jn=z(tt),mn=O;(ln&&mn(new ln(new ArrayBuffer(1)))!=bn||Ke&&mn(new Ke)!=un||sn&&mn(sn.resolve())!=dn||cn&&mn(new cn)!=hn||tt&&mn(new tt)!=vn)&&(mn=function(e){var t=O(e),r=t==fn?e.constructor:void 0,n=r?z(r):"";if(n)switch(n){case _n:return bn;case pn:return un;case yn:return dn;case kn:return hn;case jn:return vn}return t});var gn=$.Uint8Array,wn="__lodash_hash_undefined__";function Sn(e){return this.__data__.set(e,wn),this}function An(e){return this.__data__.has(e)}function On(e){var t=-1,r=null==e?0:e.length;for(this.__data__=new ze;++t<r;)this.add(e[t])}function $n(e,t){for(var r=-1,n=null==e?0:e.length;++r<n;)if(t(e[r],r,e))return!0;return!1}function Dn(e,t){return e.has(t)}On.prototype.add=On.prototype.push=Sn,On.prototype.has=An;var xn=1,Cn=2;function Mn(e,t,r,n,a,o){var i=r&xn,l=e.length,s=t.length;if(l!=s&&!(i&&s>l))return!1;var c=o.get(e),h=o.get(t);if(c&&h)return c==t&&h==e;var d=-1,u=!0,b=r&Cn?new On:void 0;for(o.set(e,t),o.set(t,e);++d<l;){var p=e[d],f=t[d];if(n)var _=i?n(f,p,d,t,e,o):n(p,f,d,e,t,o);if(void 0!==_){if(_)continue;u=!1;break}if(b){if(!$n(t,function(e,t){if(!Dn(b,t)&&(p===e||a(p,e,r,n,o)))return b.push(t)})){u=!1;break}}else if(p!==f&&!a(p,f,r,n,o)){u=!1;break}}return o.delete(e),o.delete(t),u}function Fn(e){var t=-1,r=Array(e.size);return e.forEach(function(e,n){r[++t]=[n,e]}),r}function Hn(e){var t=-1,r=Array(e.size);return e.forEach(function(e){r[++t]=e}),r}var En=1,Kn=2,Pn="[object Boolean]",Rn="[object Date]",Wn="[object Error]",Tn="[object Map]",Bn="[object Number]",In="[object RegExp]",Un="[object Set]",zn="[object String]",Ln="[object Symbol]",Vn="[object ArrayBuffer]",Nn="[object DataView]",Xn=M?M.prototype:void 0,Qn=Xn?Xn.valueOf:void 0;function qn(e,t,r,n,a,o,i){switch(r){case Nn:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case Vn:return!(e.byteLength!=t.byteLength||!o(new gn(e),new gn(t)));case Pn:case Rn:case Bn:return it(+e,+t);case Wn:return e.name==t.name&&e.message==t.message;case In:case zn:return e==t+"";case Tn:var l=Fn;case Un:var s=n&En;if(l||(l=Hn),e.size!=t.size&&!s)return!1;var c=i.get(e);if(c)return c==t;n|=Kn,i.set(e,t);var h=Mn(l(e),l(t),n,a,o,i);return i.delete(e),h;case Ln:if(Qn)return Qn.call(e)==Qn.call(t)}return!1}var Gn=1,Yn=Object.prototype,Jn=Yn.hasOwnProperty;function Zn(e,t,r,n,a,o){var i=r&Gn,l=an(e),s=l.length;if(s!=an(t).length&&!i)return!1;for(var c=s;c--;){var h=l[c];if(!(i?h in t:Jn.call(t,h)))return!1}var d=o.get(e),u=o.get(t);if(d&&u)return d==t&&u==e;var b=!0;o.set(e,t),o.set(t,e);for(var p=i;++c<s;){var f=e[h=l[c]],_=t[h];if(n)var v=i?n(_,f,h,t,e,o):n(f,_,h,e,t,o);if(!(void 0===v?f===_||a(f,_,r,n,o):v)){b=!1;break}p||(p="constructor"==h)}if(b&&!p){var y=e.constructor,g=t.constructor;y==g||!("constructor"in e)||!("constructor"in t)||"function"==typeof y&&y instanceof y&&"function"==typeof g&&g instanceof g||(b=!1)}return o.delete(e),o.delete(t),b}var tr=1,er="[object Arguments]",nr="[object Array]",rr="[object Object]",ir=Object.prototype,or=ir.hasOwnProperty;function ar(e,t,r,n,a,o){var i=C(e),l=C(t),s=i?nr:mn(e),c=l?nr:mn(t),h=(s=s==er?rr:s)==rr,d=(c=c==er?rr:c)==rr,u=s==c;if(u&&wt(e)){if(!wt(t))return!1;i=!0,h=!1}if(u&&!h)return o||(o=new Ye),i||re(e)?Mn(e,t,r,n,a,o):qn(e,t,s,r,n,a,o);if(!(r&tr)){var b=h&&or.call(e,"__wrapped__"),p=d&&or.call(t,"__wrapped__");if(b||p){var f=b?e.value():e,_=p?t.value():t;return o||(o=new Ye),a(f,_,r,n,o)}}return!!u&&(o||(o=new Ye),Zn(e,t,r,n,a,o))}function lr(e,t,r,n,a){return e===t||(null==e||null==t||!D(e)&&!D(t)?e!=e&&t!=t:ar(e,t,r,n,lr,a))}function sr(e,t){return lr(e,t)}const cr=class{constructor(r){t(this,r),this.translateNoEntries=c("kol-no-entries"),this.state={_data:[],_headerCells:{horizontal:[],vertical:[]},_label:"",_hasSettingsMenu:!1},this.horizontal=!0,this.cellsToRenderTimeouts=new Map,this.dataToKeyMap=new Map,this.checkboxRefs=[],this.translateSort=c("kol-sort"),this.translateSortOrder=c("kol-table-sort-order"),this.tableDivElementHasScrollbar=!1,this.renderTableRow=(t,r,n,a=!1)=>{var o,l;let s=String(r);return this.horizontal&&(null===(o=t[0])||void 0===o?void 0:o.data)&&(s=null!==(l=this.getDataKey(t[0].data))&&void 0!==l?l:s),e("tr",{class:i("kol-table__row",{"kol-table__row--body":!a,"kol-table__row--footer":a}),key:`row-${s}`},this.renderSelectionCell(t,r),t.map((e,t)=>this.renderTableCell(e,r,t,n)))},this.renderTableCell=(t,r,n,a)=>{if(!1===t.visible)return"";let o=`${r}-${n}-${t.label}`;if(t.data){const e=this.getDataKey(t.data);o=e?`${e}-${this.horizontal?n:r}`:o}if(t.headerCell)return this.renderHeadingCell(t,r,n,a);{const r="function"!=typeof t.render&&t.label===this.translateNoEntries;return e("td",{key:`cell-${o}`,class:i("kol-table__cell kol-table__cell--body",{[`kol-table__cell--align-${t.textAlign}`]:t.textAlign}),"aria-atomic":r?"false":void 0,"aria-live":r?"polite":void 0,"aria-relevant":r?"text":void 0,colSpan:t.colSpan,rowSpan:t.rowSpan,style:{textAlign:t.textAlign},ref:"function"==typeof t.render?e=>{this.cellRender(t,e)}:void 0},"function"!=typeof t.render?t.label:"")}}}validateHasSettingsMenu(e){b(this,e)}validateData(e){_(this,e,{beforePatch:e=>{this.updateDataToKeyMap(e)}})}validateDataFoot(e){p(this,e)}validateHeaderCells(e){F(this,e),sr(this.previousHeaderCells,this.state._headerCells)||this.initializeHeaderCellSettings(),this.previousHeaderCells=this.state._headerCells}validateLabel(e){j(this,e,{required:!0})}validateOn(e){y(this,e)}validateSelection(e){k(this,e)}handleKeyDown(e){var t;if("ArrowUp"===e.key||"ArrowDown"===e.key){const r=null===(t=this.tableDivElement)||void 0===t?void 0:t.querySelector(":focus");let n=this.checkboxRefs.indexOf(r);n>-1&&(e.preventDefault(),"ArrowDown"===e.key?(n=(n+1)%this.checkboxRefs.length,this.checkboxRefs[n].focus()):"ArrowUp"===e.key&&(e.preventDefault(),n=(n+this.checkboxRefs.length-1)%this.checkboxRefs.length,this.checkboxRefs[n].focus()))}}componentDidRender(){this.checkDivElementScrollbar()}componentDidLoad(){this.tableDivElement&&ResizeObserver&&(this.tableDivElementResizeObserver=new ResizeObserver(this.checkDivElementScrollbar.bind(this)),this.tableDivElementResizeObserver.observe(this.tableDivElement))}handleSettingsChange(e){var t;const r=Object.assign(Object.assign({},this.state._headerCells),{horizontal:e.detail});v(this,"_headerCells",r),"function"==typeof(null===(t=this.state._on)||void 0===t?void 0:t[m.onChangeHeaderCells])&&this.state._on[m.onChangeHeaderCells](e,r)}disconnectedCallback(){var e;null===(e=this.tableDivElementResizeObserver)||void 0===e||e.disconnect()}checkDivElementScrollbar(){this.tableDivElement&&(this.tableDivElementHasScrollbar=this.tableDivElement.scrollWidth>this.tableDivElement.clientWidth)}updateDataToKeyMap(e){e.forEach(e=>{this.dataToKeyMap.has(e)||this.dataToKeyMap.set(e,g())}),this.dataToKeyMap.forEach((t,r)=>{e.includes(r)||this.dataToKeyMap.delete(r)})}getDataKey(e){return this.dataToKeyMap.get(e)}cellRender(e,t){t&&(clearTimeout(this.cellsToRenderTimeouts.get(t)),this.cellsToRenderTimeouts.set(t,setTimeout(()=>{if("function"==typeof e.render){const r=e.render(t,e,e.data,this.state._data);"string"==typeof r&&(t.textContent=r)}})))}getNumberOfCols(e,t){let r=0;return e.forEach(e=>{let t=0;Array.isArray(e)&&e.forEach(e=>{var r;return t+=null!==(r=e.colSpan)&&void 0!==r?r:1}),r<t&&(r=t)}),0===r&&(r=t.length),r}getNumberOfRows(e,t){var r;let n=0;return e.forEach(e=>{let t=0;Array.isArray(e)&&e.forEach(e=>{var r;return t+=null!==(r=e.rowSpan)&&void 0!==r?r:1}),n<t&&(n=t)}),0===n?n=t.length:n-=(null===(r=this.state._dataFoot)||void 0===r?void 0:r.length)||0,n}getThePrimaryHeadersWithKeyOrRenderFunction(e){const t=[];return e.forEach(e=>{e.forEach(e=>{"string"!=typeof e.key&&"function"!=typeof e.render||t.push(e)})}),t}getPrimaryHeaders(e){var t,r;let n=this.getThePrimaryHeadersWithKeyOrRenderFunction(null!==(t=e.horizontal)&&void 0!==t?t:[]);return this.horizontal=!0,0===n.length&&(n=this.getThePrimaryHeadersWithKeyOrRenderFunction(null!==(r=e.vertical)&&void 0!==r?r:[]),n.length>0&&(this.horizontal=!1)),n}createDataField(e,t,r){var n;t.horizontal=Array.isArray(null==t?void 0:t.horizontal)?t.horizontal:[],t.vertical=Array.isArray(null==t?void 0:t.vertical)?t.vertical:[];const a=this.getPrimaryHeaders(t),o=this.getNumberOfCols(t.horizontal,e);let i=this.getNumberOfRows(t.vertical,e),l=0;r&&(l=i,i+=(null===(n=this.state._dataFoot)||void 0===n?void 0:n.length)||0);const s=[],c=[],h=[];t.vertical.forEach((e,t)=>{c[t]=0,h[t]=[]});const d=a;for(let n=l;n<i;n++){const a=[];t.vertical.forEach((e,t)=>{let r=0;if(h[t].forEach(e=>r+=e),r<=n){const o=e[n-r+c[t]];if("object"==typeof o){a.push(Object.assign(Object.assign({},o),{headerCell:!0,data:{}}));let e=1;if("number"==typeof o.rowSpan&&o.rowSpan>1&&(e=o.rowSpan),h[t].push(e),"number"==typeof o.colSpan&&o.colSpan>1)for(let r=1;r<o.colSpan;r++)h[t+r].push(e);c[t]++}}});for(let t=0;t<o;t++)if(!0===this.horizontal){const o=r&&this.state._dataFoot?this.state._dataFoot[n-l]:e[n];"object"!=typeof d[t]||null===d[t]||"object"!=typeof o||null===o||"string"!=typeof d[t].key&&"function"!=typeof d[t].render||a.push(Object.assign(Object.assign({},d[t]),{colSpan:void 0,rowSpan:void 0,data:o,label:o[d[t].key]}))}else"object"!=typeof d[n]||null===d[n]||"object"!=typeof e[t]||null===e[t]||"string"!=typeof d[n].key&&"function"!=typeof d[n].render||a.push(Object.assign(Object.assign({},d[n]),{colSpan:void 0,rowSpan:void 0,data:e[t],label:e[t][d[n].key]}));s.push(a)}if(0===e.length){let e=0,r=0;Array.isArray(t.horizontal)&&t.horizontal.length>0&&t.horizontal[0].forEach(t=>{e+=t.colSpan||1}),Array.isArray(t.vertical)&&t.vertical.length>0&&(e-=t.vertical.length,t.vertical[0].forEach(e=>{r+=e.rowSpan||1}));const n={colSpan:e,label:this.translateNoEntries,render:void 0,rowSpan:Math.max(r,1)};0===s.length?s.push([n]):s[0].push(n)}return s}handleSelectionChangeCallbackAndEvent(e,t){var r;"function"==typeof(null===(r=this.state._on)||void 0===r?void 0:r[m.onSelectionChange])&&this.state._on[m.onSelectionChange](e,t),this.host&&w(this.host,S.selectionChange,t)}initializeHeaderCellSettings(){if(this.state._headerCells&&this.state._headerCells.horizontal&&this.state._headerCells.horizontal.length>0){const e=Object.assign(Object.assign({},this.state._headerCells),{horizontal:this.state._headerCells.horizontal.map(e=>e.map(e=>Object.assign(Object.assign({},e),{visible:"boolean"!=typeof e.visible||e.visible,hidable:"boolean"!=typeof e.hidable||e.hidable})))});v(this,"_headerCells",e)}}componentWillLoad(){this.validateData(this._data),this.validateDataFoot(this._dataFoot),this.validateHeaderCells(this._headerCells),this.validateLabel(this._label),this.validateOn(this._on),this.validateSelection(this._selection),this.validateHasSettingsMenu(this._hasSettingsMenu)}renderSelectionCell(t,r){var n;const l=this.state._selection;if(!l)return"";const s=this.getSelectionKeyPropertyName(),c=null===(n=t[0])||void 0===n?void 0:n.data;if(!c)return"";const h=c[s],d=l.multiple||void 0===l.multiple,u=(()=>{const e=null==l?void 0:l.selectedKeys;return(void 0===e?[]:Array.isArray(e)?e:[e]).some(e=>String(e)===String(h))})(),b=(()=>{const e=null==l?void 0:l.disabledKeys;return(void 0===e?[]:Array.isArray(e)?e:[e]).some(e=>String(e)===String(h))})(),p=l.label(c),f={name:"selection",checked:u,disabled:b,id:String(h),"aria-label":p};return e("td",{key:`tbody-${r}-selection`,class:"kol-table__cell kol-table__cell--selection"},e("div",{class:i("kol-table__selection",{"kol-table__selection--checked":u})},d?e("label",{class:i("kol-table__selection-label",{"kol-table__selection-label--disabled":b})},e(o,{class:"kol-table__selection-icon",_icons:"kolicon "+(u?"kolicon-check":""),_label:""}),e("input",Object.assign({class:i("kol-table__selection-input kol-table__selection-input--checkbox"),ref:e=>e&&this.checkboxRefs.push(e)},f,{type:"checkbox",onInput:e=>{const t=(()=>{const e=null==l?void 0:l.selectedKeys;return void 0===e?[]:Array.isArray(e)?e:[e]})(),r=u?t.filter(e=>String(e)!==String(h)):[...t,h];this.handleSelectionChangeCallbackAndEvent(e,null!=r?r:[])}}))):e("label",{class:"kol-table__selection-label"},e("input",Object.assign({class:i("kol-table__selection-input kol-table__selection-input--radio")},f,{type:"radio",onInput:e=>{this.handleSelectionChangeCallbackAndEvent(e,[h])}}))),e(a,{"aria-hidden":"true",class:"kol-table__selection-input-tooltip",_align:"right",_id:`${h}-label`,_label:p})))}getSelectionKeyPropertyName(){var e,t;return null!==(t=null===(e=this.state._selection)||void 0===e?void 0:e.keyPropertyName)&&void 0!==t?t:"id"}getDataWithSelectionEnabled(){const e=this.getSelectionKeyPropertyName();return this.state._data.filter(t=>{var r;const n=null===(r=this.state._selection)||void 0===r?void 0:r.disabledKeys;return!(void 0===n?[]:Array.isArray(n)?n:[n]).some(r=>String(r)===String(t[e]))})}getSelectedKeysWithoutDisabledKeys(){const e=(()=>{var e;const t=null===(e=this.state._selection)||void 0===e?void 0:e.selectedKeys;return void 0===t?[]:Array.isArray(t)?t:[t]})(),t=(()=>{var e;const t=null===(e=this.state._selection)||void 0===e?void 0:e.disabledKeys;return void 0===t?[]:Array.isArray(t)?t:[t]})();return e.filter(e=>!t.some(t=>String(t)===String(e)))}getSelectedKeysWithDisabledKeysOnly(){const e=(()=>{var e;const t=null===(e=this.state._selection)||void 0===e?void 0:e.selectedKeys;return void 0===t?[]:Array.isArray(t)?t:[t]})(),t=(()=>{var e;const t=null===(e=this.state._selection)||void 0===e?void 0:e.disabledKeys;return void 0===t?[]:Array.isArray(t)?t:[t]})();return e.filter(e=>t.some(t=>String(t)===String(e)))}getRevertedSelection(e){var t;const r=this.getSelectionKeyPropertyName(),n=null!==(t=this.getSelectedKeysWithDisabledKeysOnly())&&void 0!==t?t:[];return e&&n.push(...this.getDataWithSelectionEnabled().map(e=>null==e?void 0:e[r])),n}getTableMinWidth(){var e,t;const r=null!==(e=this.state._headerCells.horizontal)&&void 0!==e?e:[],n=[];r.forEach(e=>{e.forEach(e=>{!1!==e.visible&&void 0!==e.width&&e.width>0&&n.push(e.width)})});const a=null!==(t=this.state._headerCells.vertical)&&void 0!==t?t:[],o=[];a.forEach(e=>{e.forEach(e=>{void 0!==e.width&&e.width>0&&o.push(e.width)})});const i=[...o,...n];return 0===i.length?"0px":1===i.length?`${i[0]}px`:`calc(${i.map(e=>`${e}px`).join(" + ")})`}renderHeadingSelectionCell(){var t,r;const n=this.state._selection;if(!n)return e("td",{class:"kol-table__cell kol-table__cell--header",key:"thead-0"});if(!1===n.multiple)return e("td",{key:"thead-0-selection",class:"kol-table__cell kol-table__cell--header kol-table__cell--selection"});const l=null!==(r=null===(t=this.getSelectedKeysWithoutDisabledKeys())||void 0===t?void 0:t.length)&&void 0!==r?r:0,s=l===this.getDataWithSelectionEnabled().length,h=0!==l&&!s;let d="kol-table-selection-indeterminate";s&&!h&&(d="kol-table-selection-none"),0===l&&(d="kol-table-selection-all");const u=c(d);return e("th",{key:"thead-0-selection",class:"kol-table__cell kol-table__cell--header kol-table__cell--selection"},e("div",{class:i("kol-table__selection",{"kol-table__selection--indeterminate":h,"kol-table__selection--checked":s})},e("label",{class:"kol-table__selection-label"},e(o,{class:"kol-table__selection-icon",_icons:"kolicon "+(h?"kolicon-minus":s?"kolicon-check":""),_label:""}),e("input",{class:i("kol-table__selection-input kol-table__selection-input--checkbox"),"data-testid":"selection-checkbox-all",ref:e=>e&&this.checkboxRefs.push(e),name:"selection",checked:s&&!h,indeterminate:h,"aria-label":u,type:"checkbox",onInput:e=>{this.handleSelectionChangeCallbackAndEvent(e,this.getRevertedSelection(!s))}})),e(a,{"aria-hidden":"true",class:"kol-table__selection-input-tooltip",_align:"right",_id:`${d}-label`,_label:u})))}renderHeaderTdCell(){const t=this.state._headerCells.horizontal,r=this.state._headerCells.vertical;if(!Array.isArray(t)||0===t.length||!Array.isArray(r)||0===r.length)return e(n,null);const a=r.reduce((e,t)=>{var r;const n=null==t?void 0:t[0];return e+(null!==(r=null==n?void 0:n.width)&&void 0!==r?r:0)},0);return e("td",{"aria-hidden":"true",colSpan:r.length,rowSpan:t.length,style:a>0?{width:`${a}px`}:void 0})}formatSortOrderDescription(e){return this.translateSortOrder.replace("{{order}}",`${e}`)}getSortAriaDescription(e){return"number"==typeof e&&e>0?`${this.translateSort} – ${this.formatSortOrderDescription(e)}`:this.translateSort}renderHeadingCell(t,r,n,a){if(!1===t.visible)return"";const o=!1!==(null==t?void 0:t.sortable),s="string"==typeof t.sortDirection,c=o&&s;let h="none",d="kolicon-sort-neutral";if(c&&t.sortDirection)switch(t.sortDirection){case"ASC":d="kolicon-sort-asc",h="ascending";break;case"DESC":d="kolicon-sort-desc",h="descending";break;default:h="none"}const u=a?"row":"number"==typeof t.colSpan&&t.colSpan>1?"colgroup":"col",b="number"==typeof t.sortOrder&&t.sortOrder>0?t.sortOrder:void 0,p=this.getSortAriaDescription(b);return e("th",{key:`${r}-${n}-${t.label}`,class:i("kol-table__cell kol-table__cell--header",{[`kol-table__cell--align-${t.textAlign}`]:t.textAlign,[`kol-table__cell--${h}`]:h}),scope:u,colSpan:t.colSpan,rowSpan:t.rowSpan,style:void 0!==t.width?{width:`${t.width}px`}:void 0,"aria-sort":h,"data-sort":c&&t.sortDirection?`sort-${t.sortDirection}`:void 0},c&&t.sortDirection?e("span",{class:"kol-table__sort"},e(l,{class:"kol-table__sort-button",exportparts:"icon",_icons:{right:d},_label:t.label,_ariaDescription:p,_on:{onClick:e=>{var r;"function"==typeof(null===(r=this.state._on)||void 0===r?void 0:r.onSort)&&t.key&&t.sortDirection&&this.state._on.onSort(e,{key:t.key,currentSortDirection:t.sortDirection}),this.host&&w(this.host,S.sort,{key:t.key,currentSortDirection:t.sortDirection})}}}),b&&e("span",{"aria-hidden":"true",class:"kol-table__sort-order"},b)):t.label)}renderSpacer(t,r){var n,a;const o=(null===(n=this.state._headerCells.vertical)||void 0===n?void 0:n.length)||0,l=null===(a=null==r?void 0:r[0])||void 0===a?void 0:a.reduce((e,t)=>e+(t.colSpan||1),0),s=this.state._selection?1:0;return e("tr",{"aria-hidden":"true",class:i("kol-table__spacer",`kol-table__spacer--${t}`)},e("td",{class:i(`kol-table__spacer-line kol-table__spacer-line--${t}`),colSpan:o+l+s}))}renderFoot(){if(!this.state._dataFoot||0===this.state._dataFoot.length)return null;const t=this.createDataField(this.state._dataFoot,this.state._headerCells,!0);return e("tfoot",{class:"kol-table__footer"},[this.renderSpacer("foot",t),t.map((e,t)=>this.renderTableRow(e,t,!0,!0))])}render(){const t=this.createDataField(this.state._data,this.state._headerCells);this.checkboxRefs=[];const r=this.state._headerCells.horizontal;return e("div",{key:"3afe5c237067ccac3023d7fd53883e9057de27e0",class:"kol-table"},this.state._hasSettingsMenu&&e(s,{key:"9b41896802e14e25f0234e3dd714972d9e6c77db",_horizontalHeaderCells:null!=r?r:[]}),e("div",{key:"d004c445641a06efe649a6de3c51a15a2502c0df",ref:e=>this.tableDivElement=e,class:"kol-table__scroll-container",tabindex:this.tableDivElementHasScrollbar?"-1":void 0},e("table",{key:"5119cd5e99cb529baf922b66fc0e3d917886ee07",class:"kol-table__table",style:{minWidth:this.getTableMinWidth()}},e("caption",{key:"961a09c0d6e5faff72e65ef9a3aeaa9df0f0ed41",class:"kol-table__focus-element kol-table__caption",id:"caption",tabindex:this.tableDivElementHasScrollbar?"0":void 0},this.state._label),Array.isArray(r)&&e("thead",{key:"12bb291debe3b8532f7ffa862a3e9698903598f5",class:"kol-table__head"},[r.map((t,r)=>e("tr",{class:"kol-table__head-row",key:`thead-${r}`},this.state._selection&&this.renderHeadingSelectionCell(),0===r&&this.renderHeaderTdCell(),Array.isArray(t)&&t.map((e,t)=>this.renderHeadingCell(e,r,t,!1)))),this.renderSpacer("head",r)]),e("tbody",{key:"bba0270d6ca03234ebe2b12b101c589439bda99d",class:"kol-table__body"},t.map((e,t)=>this.renderTableRow(e,t,!0))),this.renderFoot())))}get host(){return r(this)}static get watchers(){return{_hasSettingsMenu:["validateHasSettingsMenu"],_data:["validateData"],_dataFoot:["validateDataFoot"],_headerCells:["validateHeaderCells"],_label:["validateLabel"],_on:["validateOn"],_selection:["validateSelection"]}}};export{cr as kol_table_stateless_wc};