UNPKG

@public-ui/components

Version:

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

4 lines 28.1 kB
/*! * KoliBri - The accessible HTML-Standard */ import{r as t,h as e,F as n,g as i}from"./index-1ed13705.js";import{c as r}from"./clsx-09a06a12.js";import{e as o,a,b as l,v as s}from"./component-names-7924d82a.js";import{t as c}from"./i18n-260f0fe9.js";import{M as u,o as d,k as f,w as h,l as v}from"./index-ebe5a881.js";import{C as b}from"./keyboard-2483c6de.js";import{n as _}from"./dev.utils-cb61837d.js";import{d as p,K as y}from"./events-bad0a075.js";import{v as j,a as k,e as m,b as w,d as g}from"./table-settings-c12356ed.js";import{b as S,r as A,a as O,f as $,i as x,S as C}from"./isArray-7a60fa7f.js";import{i as D}from"./isObject-ffcbbb76.js";import{v as M}from"./label-bf9966d0.js";import"./i18n-45224cc3.js";const W=(e,t)=>{u(t,(()=>{d(t,(()=>{try{t=f(t)}catch(e){}h(e,"_headerCells",(e=>"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))))&&!0),new Set(["TableHeaderCellsPropType"]),t)}))}))};var F="[object AsyncFunction]",P="[object Function]",T="[object GeneratorFunction]",E="[object Proxy]";function K(e){if(!D(e))return!1;var t=S(e);return t==P||t==T||t==F||t==E}var R=A["__core-js_shared__"];const H=R;var I=function(){var e=/[^.]+$/.exec(H&&H.keys&&H.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function N(e){return!!I&&I in e}var z=Function.prototype,B=z.toString;function U(e){if(null!=e){try{return B.call(e)}catch(e){}try{return e+""}catch(e){}}return""}var L=/[\\^$.*+?()[\]{}|]/g,V=/^\[object .+?Constructor\]$/,q=Function.prototype,G=Object.prototype,J=q.toString,Q=G.hasOwnProperty,X=RegExp("^"+J.call(Q).replace(L,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Y(e){return!(!D(e)||N(e))&&(K(e)?X:V).test(U(e))}function Z(e,t){return null==e?void 0:e[t]}function tt(e,t){var n=Z(e,t);return Y(n)?n:void 0}var et=tt(A,"WeakMap");const nt=et;var it=9007199254740991,rt=/^(?:0|[1-9]\d*)$/;function ot(e,t){var n=typeof e;return!!(t=null==t?it:t)&&("number"==n||"symbol"!=n&&rt.test(e))&&e>-1&&e%1==0&&e<t}function at(e,t){return e===t||e!=e&&t!=t}var lt=9007199254740991;function st(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=lt}function ct(e){return null!=e&&st(e.length)&&!K(e)}var ut=Object.prototype;function dt(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||ut)}function ft(e,t){for(var n=-1,i=Array(e);++n<e;)i[n]=t(n);return i}var ht="[object Arguments]";function vt(e){return O(e)&&S(e)==ht}var bt=Object.prototype,_t=bt.hasOwnProperty,pt=bt.propertyIsEnumerable,yt=vt(function(){return arguments}())?vt:function(e){return O(e)&&_t.call(e,"callee")&&!pt.call(e,"callee")};const jt=yt;function kt(){return!1}var mt="object"==typeof exports&&exports&&!exports.nodeType&&exports,wt=mt&&"object"==typeof module&&module&&!module.nodeType&&module,gt=wt&&wt.exports===mt,St=gt?A.Buffer:void 0,At=St?St.isBuffer:void 0,Ot=At||kt;const $t=Ot;var xt="[object Arguments]",Ct="[object Array]",Dt="[object Boolean]",Mt="[object Date]",Wt="[object Error]",Ft="[object Function]",Pt="[object Map]",Tt="[object Number]",Et="[object Object]",Kt="[object RegExp]",Rt="[object Set]",Ht="[object String]",It="[object WeakMap]",Nt="[object ArrayBuffer]",zt="[object DataView]",Bt="[object Float32Array]",Ut="[object Float64Array]",Lt="[object Int8Array]",Vt="[object Int16Array]",qt="[object Int32Array]",Gt="[object Uint8Array]",Jt="[object Uint8ClampedArray]",Qt="[object Uint16Array]",Xt="[object Uint32Array]",Yt={};function Zt(e){return O(e)&&st(e.length)&&!!Yt[S(e)]}function te(e){return function(t){return e(t)}}Yt[Bt]=Yt[Ut]=Yt[Lt]=Yt[Vt]=Yt[qt]=Yt[Gt]=Yt[Jt]=Yt[Qt]=Yt[Xt]=!0,Yt[xt]=Yt[Ct]=Yt[Nt]=Yt[Dt]=Yt[zt]=Yt[Mt]=Yt[Wt]=Yt[Ft]=Yt[Pt]=Yt[Tt]=Yt[Et]=Yt[Kt]=Yt[Rt]=Yt[Ht]=Yt[It]=!1;var ee="object"==typeof exports&&exports&&!exports.nodeType&&exports,ne=ee&&"object"==typeof module&&module&&!module.nodeType&&module,ie=ne&&ne.exports===ee,re=ie&&$.process,oe=function(){try{var e=ne&&ne.require&&ne.require("util").types;return e||re&&re.binding&&re.binding("util")}catch(e){}}();const ae=oe;var le=oe&&oe.isTypedArray,se=le?te(le):Zt;const ce=se;var ue=Object.prototype,de=ue.hasOwnProperty;function fe(e,t){var n=x(e),i=!n&&jt(e),a=!n&&!i&&$t(e),r=!n&&!i&&!a&&ce(e),o=n||i||a||r,l=o?ft(e.length,String):[],s=l.length;for(var c in e)!t&&!de.call(e,c)||o&&("length"==c||a&&("offset"==c||"parent"==c)||r&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||ot(c,s))||l.push(c);return l}function he(e,t){return function(n){return e(t(n))}}var ve=he(Object.keys,Object);const be=ve;var _e=Object.prototype,pe=_e.hasOwnProperty;function ye(e){if(!dt(e))return be(e);var t=[];for(var n in Object(e))pe.call(e,n)&&"constructor"!=n&&t.push(n);return t}function je(e){return ct(e)?fe(e):ye(e)}var ke=tt(Object,"create");const me=ke;function we(){this.__data__=me?me(null):{},this.size=0}function ge(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var Se="__lodash_hash_undefined__",Ae=Object.prototype,Oe=Ae.hasOwnProperty;function $e(e){var t=this.__data__;if(me){var n=t[e];return n===Se?void 0:n}return Oe.call(t,e)?t[e]:void 0}var xe=Object.prototype,Ce=xe.hasOwnProperty;function De(e){var t=this.__data__;return me?void 0!==t[e]:Ce.call(t,e)}var Me="__lodash_hash_undefined__";function We(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=me&&void 0===t?Me:t,this}function Fe(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var i=e[t];this.set(i[0],i[1])}}function Pe(){this.__data__=[],this.size=0}function Te(e,t){for(var n=e.length;n--;)if(at(e[n][0],t))return n;return-1}Fe.prototype.clear=we,Fe.prototype.delete=ge,Fe.prototype.get=$e,Fe.prototype.has=De,Fe.prototype.set=We;var Ee=Array.prototype,Ke=Ee.splice;function Re(e){var t=this.__data__,n=Te(t,e);return!(n<0)&&(n==t.length-1?t.pop():Ke.call(t,n,1),--this.size,!0)}function He(e){var t=this.__data__,n=Te(t,e);return n<0?void 0:t[n][1]}function Ie(e){return Te(this.__data__,e)>-1}function Ne(e,t){var n=this.__data__,i=Te(n,e);return i<0?(++this.size,n.push([e,t])):n[i][1]=t,this}function ze(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var i=e[t];this.set(i[0],i[1])}}ze.prototype.clear=Pe,ze.prototype.delete=Re,ze.prototype.get=He,ze.prototype.has=Ie,ze.prototype.set=Ne;var Be=tt(A,"Map");const Ue=Be;function Le(){this.size=0,this.__data__={hash:new Fe,map:new(Ue||ze),string:new Fe}}function Ve(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}function qe(e,t){var n=e.__data__;return Ve(t)?n["string"==typeof t?"string":"hash"]:n.map}function Ge(e){var t=qe(this,e).delete(e);return this.size-=t?1:0,t}function Je(e){return qe(this,e).get(e)}function Qe(e){return qe(this,e).has(e)}function Xe(e,t){var n=qe(this,e),i=n.size;return n.set(e,t),this.size+=n.size==i?0:1,this}function Ye(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var i=e[t];this.set(i[0],i[1])}}function Ze(e,t){for(var n=-1,i=t.length,a=e.length;++n<i;)e[a+n]=t[n];return e}function tn(){this.__data__=new ze,this.size=0}function en(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}function nn(e){return this.__data__.get(e)}function rn(e){return this.__data__.has(e)}Ye.prototype.clear=Le,Ye.prototype.delete=Ge,Ye.prototype.get=Je,Ye.prototype.has=Qe,Ye.prototype.set=Xe;var on=200;function an(e,t){var n=this.__data__;if(n instanceof ze){var i=n.__data__;if(!Ue||i.length<on-1)return i.push([e,t]),this.size=++n.size,this;n=this.__data__=new Ye(i)}return n.set(e,t),this.size=n.size,this}function ln(e){var t=this.__data__=new ze(e);this.size=t.size}function sn(e,t){for(var n=-1,i=null==e?0:e.length,a=0,r=[];++n<i;){var o=e[n];t(o,n,e)&&(r[a++]=o)}return r}function cn(){return[]}ln.prototype.clear=tn,ln.prototype.delete=en,ln.prototype.get=nn,ln.prototype.has=rn,ln.prototype.set=an;var un=Object.prototype,dn=un.propertyIsEnumerable,fn=Object.getOwnPropertySymbols,hn=fn?function(e){return null==e?[]:(e=Object(e),sn(fn(e),(function(t){return dn.call(e,t)})))}:cn;const vn=hn;function bn(e,t,n){var i=t(e);return x(e)?i:Ze(i,n(e))}function _n(e){return bn(e,je,vn)}var pn=tt(A,"DataView");const yn=pn;var jn=tt(A,"Promise");const kn=jn;var mn=tt(A,"Set");const wn=mn;var gn="[object Map]",Sn="[object Object]",An="[object Promise]",On="[object Set]",$n="[object WeakMap]",xn="[object DataView]",Cn=U(yn),Dn=U(Ue),Mn=U(kn),Wn=U(wn),Fn=U(nt),Pn=S;(yn&&Pn(new yn(new ArrayBuffer(1)))!=xn||Ue&&Pn(new Ue)!=gn||kn&&Pn(kn.resolve())!=An||wn&&Pn(new wn)!=On||nt&&Pn(new nt)!=$n)&&(Pn=function(e){var t=S(e),n=t==Sn?e.constructor:void 0,i=n?U(n):"";if(i)switch(i){case Cn:return xn;case Dn:return gn;case Mn:return An;case Wn:return On;case Fn:return $n}return t});const Tn=Pn;var En=A.Uint8Array;const Kn=En;var Rn="__lodash_hash_undefined__";function Hn(e){return this.__data__.set(e,Rn),this}function In(e){return this.__data__.has(e)}function Nn(e){var t=-1,n=null==e?0:e.length;for(this.__data__=new Ye;++t<n;)this.add(e[t])}function zn(e,t){for(var n=-1,i=null==e?0:e.length;++n<i;)if(t(e[n],n,e))return!0;return!1}function Bn(e,t){return e.has(t)}Nn.prototype.add=Nn.prototype.push=Hn,Nn.prototype.has=In;var Un=1,Ln=2;function Vn(e,t,n,i,a,r){var o=n&Un,l=e.length,s=t.length;if(l!=s&&!(o&&s>l))return!1;var c=r.get(e),d=r.get(t);if(c&&d)return c==t&&d==e;var h=-1,u=!0,b=n&Ln?new Nn:void 0;for(r.set(e,t),r.set(t,e);++h<l;){var v=e[h],_=t[h];if(i)var f=o?i(_,v,h,t,e,r):i(v,_,h,e,t,r);if(void 0!==f){if(f)continue;u=!1;break}if(b){if(!zn(t,(function(e,t){if(!Bn(b,t)&&(v===e||a(v,e,n,i,r)))return b.push(t)}))){u=!1;break}}else if(v!==_&&!a(v,_,n,i,r)){u=!1;break}}return r.delete(e),r.delete(t),u}function qn(e){var t=-1,n=Array(e.size);return e.forEach((function(e,i){n[++t]=[i,e]})),n}function Gn(e){var t=-1,n=Array(e.size);return e.forEach((function(e){n[++t]=e})),n}var Jn=1,Qn=2,Xn="[object Boolean]",Yn="[object Date]",Zn="[object Error]",ti="[object Map]",ei="[object Number]",ni="[object RegExp]",ii="[object Set]",ri="[object String]",oi="[object Symbol]",ai="[object ArrayBuffer]",li="[object DataView]",si=C?C.prototype:void 0,ci=si?si.valueOf:void 0;function ui(e,t,n,i,a,r,o){switch(n){case li:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case ai:return!(e.byteLength!=t.byteLength||!r(new Kn(e),new Kn(t)));case Xn:case Yn:case ei:return at(+e,+t);case Zn:return e.name==t.name&&e.message==t.message;case ni:case ri:return e==t+"";case ti:var l=qn;case ii:var s=i&Jn;if(l||(l=Gn),e.size!=t.size&&!s)return!1;var c=o.get(e);if(c)return c==t;i|=Qn,o.set(e,t);var d=Vn(l(e),l(t),i,a,r,o);return o.delete(e),d;case oi:if(ci)return ci.call(e)==ci.call(t)}return!1}var di=1,fi=Object.prototype,hi=fi.hasOwnProperty;function vi(e,t,n,i,a,r){var o=n&di,l=_n(e),s=l.length;if(s!=_n(t).length&&!o)return!1;for(var c=s;c--;){var d=l[c];if(!(o?d in t:hi.call(t,d)))return!1}var h=r.get(e),u=r.get(t);if(h&&u)return h==t&&u==e;var b=!0;r.set(e,t),r.set(t,e);for(var v=o;++c<s;){var _=e[d=l[c]],f=t[d];if(i)var p=o?i(f,_,d,t,e,r):i(_,f,d,e,t,r);if(!(void 0===p?_===f||a(_,f,n,i,r):p)){b=!1;break}v||(v="constructor"==d)}if(b&&!v){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 r.delete(e),r.delete(t),b}var bi=1,_i="[object Arguments]",pi="[object Array]",yi="[object Object]",ji=Object.prototype,ki=ji.hasOwnProperty;function mi(e,t,n,i,a,r){var o=x(e),l=x(t),s=o?pi:Tn(e),c=l?pi:Tn(t),d=(s=s==_i?yi:s)==yi,h=(c=c==_i?yi:c)==yi,u=s==c;if(u&&$t(e)){if(!$t(t))return!1;o=!0,d=!1}if(u&&!d)return r||(r=new ln),o||ce(e)?Vn(e,t,n,i,a,r):ui(e,t,s,n,i,a,r);if(!(n&bi)){var b=d&&ki.call(e,"__wrapped__"),v=h&&ki.call(t,"__wrapped__");if(b||v){var _=b?e.value():e,f=v?t.value():t;return r||(r=new ln),a(_,f,n,i,r)}}return!!u&&(r||(r=new ln),vi(e,t,n,i,a,r))}function wi(e,t,n,i,a){return e===t||(null==e||null==t||!O(e)&&!O(t)?e!=e&&t!=t:mi(e,t,n,i,wi,a))}function gi(e,t){return wi(e,t)}const Si=/^\d+(\.\d+)?([a-z]+|%)?$/,Ai=(e,t,n)=>{h(e,"_minWidth",(e=>"string"==typeof e&&Si.test(e)),new Set(["String","/^\\d+(\\.\\d+)?([a-z]+|%)?$/"]),t,n)},Oi=class{constructor(n){t(this,n),this.horizontal=!0,this.cellsToRenderTimeouts=new Map,this.dataToKeyMap=new Map,this.checkboxRefs=[],this.renderTableRow=(t,n,i,a=!1)=>{var o,l;let s=String(n);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:r("kol-table__row",{"kol-table__row--body":!a,"kol-table__row--footer":a}),key:`row-${s}`},this.renderSelectionCell(t,n),t.map(((e,t)=>this.renderTableCell(e,n,t,i))))},this.renderTableCell=(t,n,i,a)=>{const o=this.getColumnSettings(t);if(o&&!o.visible)return"";let l=`${n}-${i}-${t.label}`;if(t.data){const e=this.getDataKey(t.data);l=e?`${e}-${this.horizontal?i:n}`:l}return t.headerCell?this.renderHeadingCell(t,n,i,a):e("td",{key:`cell-${l}`,class:r("kol-table__cell kol-table__cell--body",{[`kol-table__cell--align-${t.textAlign}`]:t.textAlign}),colSpan:t.colSpan,rowSpan:t.rowSpan,style:{textAlign:t.textAlign,width:(null==o?void 0:o.width)?`${o.width}ch`:t.width},ref:"function"==typeof t.render?e=>{this.cellRender(t,e)}:void 0},"function"!=typeof t.render?t.label:"")},this.state={_data:[],_headerCells:{horizontal:[],vertical:[]},_label:"",_minWidth:"auto"},this.tableDivElementHasScrollbar=!1,this.previousHeaderCells=void 0,this._data=void 0,this._dataFoot=void 0,this._headerCells=void 0,this._label=void 0,this._minWidth=void 0,this._on=void 0,this._selection=void 0,this._tableSettings=void 0}validateData(e){j(this,e,{beforePatch:e=>{this.updateDataToKeyMap(e)}})}validateDataFoot(e){k(this,e)}validateHeaderCells(e){W(this,e),gi(this.previousHeaderCells,this.state._headerCells)||this.initializeTableSettings(),this.previousHeaderCells=this.state._headerCells}validateLabel(e){M(this,e,{required:!0})}validateMinWidth(e){Ai(this,e)}validateOn(e){m(this,e)}validateSelection(e){w(this,e)}validateTableSettings(e){g(this,e)}handleKeyDown(e){var t;if("ArrowUp"===e.key||"ArrowDown"===e.key){const n=null===(t=this.tableDivElement)||void 0===t?void 0:t.querySelector(":focus");let i=this.checkboxRefs.indexOf(n);i>-1&&(e.preventDefault(),"ArrowDown"===e.key?(i=(i+1)%this.checkboxRefs.length,this.checkboxRefs[i].focus()):"ArrowUp"===e.key&&(e.preventDefault(),i=(i+this.checkboxRefs.length-1)%this.checkboxRefs.length,this.checkboxRefs[i].focus()))}}componentDidRender(){this.checkDivElementScrollbar()}componentDidLoad(){this.tableDivElement&&ResizeObserver&&(this.tableDivElementResizeObserver=new ResizeObserver(this.checkDivElementScrollbar.bind(this)),this.tableDivElementResizeObserver.observe(this.tableDivElement))}handleSettingsChange(e){v(this,"_tableSettings",e.detail)}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,_())})),this.dataToKeyMap.forEach(((t,n)=>{e.includes(n)||this.dataToKeyMap.delete(n)}))}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 n=e.render(t,e,e.data,this.state._data);"string"==typeof n&&(t.textContent=n)}}))))}getNumberOfCols(e,t){let n=0;return e.forEach((e=>{let t=0;Array.isArray(e)&&e.forEach((e=>{var n;return t+=null!==(n=e.colSpan)&&void 0!==n?n:1})),n<t&&(n=t)})),0===n&&(n=t.length),n}getNumberOfRows(e,t){var n;let i=0;return e.forEach((e=>{let t=0;Array.isArray(e)&&e.forEach((e=>{var n;return t+=null!==(n=e.rowSpan)&&void 0!==n?n:1})),i<t&&(i=t)})),0===i?i=t.length:i-=(null===(n=this.state._dataFoot)||void 0===n?void 0:n.length)||0,i}getThePrimaryHeadersWithKeysIfExists(e){const t=[];return e.forEach((e=>{e.forEach((e=>{"string"==typeof e.key&&t.push(e)}))})),t}getPrimaryHeaders(e){var t,n;let i=this.getThePrimaryHeadersWithKeysIfExists(null!==(t=e.horizontal)&&void 0!==t?t:[]);return this.horizontal=!0,0===i.length&&(i=this.getThePrimaryHeadersWithKeysIfExists(null!==(n=e.vertical)&&void 0!==n?n:[]),i.length>0&&(this.horizontal=!1)),i}getColumnPositionMap(){var e;const t=new Map;return null===(e=this.state._tableSettings)||void 0===e||e.columns.forEach((e=>{t.set(e.key,e.position)})),t}sortByColumnPosition(e){const t=this.getColumnPositionMap();return[...e].sort(((e,n)=>{var i,a,r,o;return(null!==(a=t.get(null!==(i=e.key)&&void 0!==i?i:""))&&void 0!==a?a:Number.MAX_SAFE_INTEGER)-(null!==(o=t.get(null!==(r=n.key)&&void 0!==r?r:""))&&void 0!==o?o:Number.MAX_SAFE_INTEGER)}))}createDataField(e,t,n){var i;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),r=this.getNumberOfCols(t.horizontal,e);let o=this.getNumberOfRows(t.vertical,e),l=0;n&&(l=o,o+=(null===(i=this.state._dataFoot)||void 0===i?void 0:i.length)||0);const s=[],d=[],h=[];t.vertical.forEach(((e,t)=>{d[t]=0,h[t]=[]}));const u=this.sortByColumnPosition(a);for(let i=l;i<o;i++){const a=[];t.vertical.forEach(((e,t)=>{let n=0;if(h[t].forEach((e=>n+=e)),n<=i){const r=e[i-n+d[t]];if("object"==typeof r){a.push(Object.assign(Object.assign({},r),{headerCell:!0,data:{}}));let e=1;if("number"==typeof r.rowSpan&&r.rowSpan>1&&(e=r.rowSpan),h[t].push(e),"number"==typeof r.colSpan&&r.colSpan>1)for(let n=1;n<r.colSpan;n++)h[t+n].push(e);d[t]++}}}));for(let t=0;t<r;t++)if(!0===this.horizontal){const r=n&&this.state._dataFoot?this.state._dataFoot[i-l]:e[i];"object"==typeof u[t]&&null!==u[t]&&"string"==typeof u[t].key&&"object"==typeof r&&null!==r&&a.push(Object.assign(Object.assign({},u[t]),{colSpan:void 0,data:r,label:r[u[t].key],rowSpan:void 0}))}else"object"==typeof u[i]&&null!==u[i]&&"string"==typeof u[i].key&&"object"==typeof e[t]&&null!==e[t]&&a.push(Object.assign(Object.assign({},u[i]),{colSpan:void 0,data:e[t],label:e[t][u[i].key],rowSpan:void 0}));s.push(a)}if(0===e.length){let e=0,n=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=>{n+=e.rowSpan||1})));const i={colSpan:e,label:c("kol-no-entries"),render:void 0,rowSpan:Math.max(n,1)};0===s.length?s.push([i]):s[0].push(i)}return s}handleSelectionChangeCallbackAndEvent(e,t){var n;"function"==typeof(null===(n=this.state._on)||void 0===n?void 0:n[b.onSelectionChange])&&this.state._on[b.onSelectionChange](e,t),this.host&&p(this.host,y.selectionChange,t)}initializeTableSettings(){if(this._tableSettings)return;const e=this.getPrimaryHeaders(this.state._headerCells);this.state._tableSettings||(this.state._tableSettings={columns:[]}),this.state._tableSettings.columns=e.filter((e=>e.key)).map(((e,t)=>{var n;return{key:null!==(n=e.key)&&void 0!==n?n:_(),label:e.label,position:t,visible:!0}}))}componentWillLoad(){this.validateData(this._data),this.validateDataFoot(this._dataFoot),this.validateHeaderCells(this._headerCells),this.validateLabel(this._label),this.validateMinWidth(this._minWidth),this.validateOn(this._on),this.validateSelection(this._selection),this.validateTableSettings(this._tableSettings)}renderSelectionCell(t,n){var i,l,s;const c=this.state._selection;if(!c)return"";const d=this.getSelectionKeyPropertyName(),h=null===(i=t[0])||void 0===i?void 0:i.data;if(!h)return"";const u=h[d],b=c.multiple||void 0===c.multiple,v=null===(l=null==c?void 0:c.selectedKeys)||void 0===l?void 0:l.includes(u),_=null===(s=null==c?void 0:c.disabledKeys)||void 0===s?void 0:s.includes(u),f=c.label(h),p={name:"selection",checked:v,disabled:_,id:u,"aria-label":f};return e("td",{key:`tbody-${n}-selection`,class:"kol-table__cell kol-table__cell--selection"},e("div",{class:r("kol-table__selection",{"kol-table__selection--checked":v})},b?e("label",{class:r("kol-table__selection-label",{"kol-table__selection-label--disabled":_})},e(o,{class:"kol-table__selection-icon",_icons:"codicon "+(v?"codicon-check":""),_label:""}),e("input",Object.assign({class:r("kol-table__selection-input kol-table__selection-input--checkbox"),ref:e=>e&&this.checkboxRefs.push(e)},p,{type:"checkbox",onInput:e=>{var t,n;const i=v?null===(n=null==c?void 0:c.selectedKeys)||void 0===n?void 0:n.filter((e=>e!==u)):[...null!==(t=null==c?void 0:c.selectedKeys)&&void 0!==t?t:[],u];this.handleSelectionChangeCallbackAndEvent(e,null!=i?i:[])}}))):e("label",{class:"kol-table__selection-label"},e("input",Object.assign({class:r("kol-table__selection-input kol-table__selection-input--radio")},p,{type:"radio",onInput:e=>{this.handleSelectionChangeCallbackAndEvent(e,u)}}))),e(a,{"aria-hidden":"true",class:"kol-table__selection-input-tooltip",_align:"right",_id:`${u}-label`,_label:f})))}getColumnSettings(e){var t;return null===(t=this.state._tableSettings)||void 0===t?void 0:t.columns.find((t=>t.key===e.key))}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 n,i;return!(null===(i=null===(n=this.state._selection)||void 0===n?void 0:n.disabledKeys)||void 0===i?void 0:i.includes(t[e]))}))}getSelectedKeysWithoutDisabledKeys(){var e,t;return null===(t=null===(e=this.state._selection)||void 0===e?void 0:e.selectedKeys)||void 0===t?void 0:t.filter((e=>{var t,n;return!(null===(n=null===(t=this.state._selection)||void 0===t?void 0:t.disabledKeys)||void 0===n?void 0:n.includes(e))}))}getSelectedKeysWithDisabledKeysOnly(){var e,t;return null===(t=null===(e=this.state._selection)||void 0===e?void 0:e.selectedKeys)||void 0===t?void 0:t.filter((e=>{var t,n;return null===(n=null===(t=this.state._selection)||void 0===t?void 0:t.disabledKeys)||void 0===n?void 0:n.includes(e)}))}getRevertedSelection(e){var t;const n=this.getSelectionKeyPropertyName(),i=null!==(t=this.getSelectedKeysWithDisabledKeysOnly())&&void 0!==t?t:[];return e&&i.push(...this.getDataWithSelectionEnabled().map((e=>null==e?void 0:e[n]))),i}getTableMinWidth(){var e,t;const n=null!==(t=null===(e=this.state._tableSettings)||void 0===e?void 0:e.columns.filter((e=>e.visible)).reduce(((e,t)=>{var n;return e+(null!==(n=t.width)&&void 0!==n?n:0)}),0))&&void 0!==t?t:0;return"auto"===this.state._minWidth?`${n}ch`:`max(${this.state._minWidth}, ${n}ch)`}renderHeadingSelectionCell(){var t,n;const i=this.state._selection;if(!i||!i.multiple&&void 0!==i.multiple)return e("th",{class:"kol-table__cell kol-table__cell--header",key:"thead-0"});const l=null!==(n=null===(t=this.getSelectedKeysWithoutDisabledKeys())||void 0===t?void 0:t.length)&&void 0!==n?n:0,s=l===this.getDataWithSelectionEnabled().length,d=0!==l&&!s;let h="kol-table-selection-indeterminate";s&&!d&&(h="kol-table-selection-none"),0===l&&(h="kol-table-selection-all");const u=c(h);return e("th",{key:"thead-0-selection",class:"kol-table__cell kol-table__cell--header"},e("div",{class:r("kol-table__selection",{"kol-table__selection--indeterminate":d,"kol-table__selection--checked":s})},e("label",{class:"kol-table__selection-label"},e(o,{class:"kol-table__selection-icon",_icons:"codicon "+(d?"codicon-remove":s?"codicon-check":""),_label:""}),e("input",{class:r("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&&!d,indeterminate:d,"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:`${h}-label`,_label:u})))}renderHeaderTdCell(){return e(n,null,Array.isArray(this.state._headerCells.horizontal)&&this.state._headerCells.horizontal.length>0&&Array.isArray(this.state._headerCells.vertical)&&this.state._headerCells.vertical.length>0&&Array.isArray(this.state._headerCells.horizontal)&&e("td",{"aria-hidden":"true",colSpan:this.state._headerCells.vertical.length,rowSpan:this.state._headerCells.horizontal.length}))}renderHeadingCell(t,n,i,a){const o=this.getColumnSettings(t);if(o&&!o.visible)return"";let s,c="codicon codicon-fold";if(t.sortDirection)switch(t.sortDirection){case"ASC":c="codicon codicon-chevron-up",s="ascending";break;case"DESC":c="codicon codicon-chevron-down",s="descending"}const d=a?"row":"number"==typeof t.colSpan&&t.colSpan>1?"colgroup":"col";return e("th",{key:`${n}-${i}-${t.label}`,class:r("kol-table__cell kol-table__cell--header",{[`kol-table__cell--align-${t.textAlign}`]:t.textAlign,[`kol-table__cell--${s}`]:s}),scope:d,colSpan:t.colSpan,rowSpan:t.rowSpan,style:{width:(null==o?void 0:o.width)?`${o.width}ch`:t.width},"aria-sort":s,"data-sort":`sort-${t.sortDirection}`},t.sortDirection?e(l,{class:"kol-table__sort-button",exportparts:"icon",_icons:{right:c},_label:t.label,_on:{onClick:e=>{var n;"function"==typeof(null===(n=this.state._on)||void 0===n?void 0:n.onSort)&&t.key&&t.sortDirection&&this.state._on.onSort(e,{key:t.key,currentSortDirection:t.sortDirection}),this.host&&p(this.host,y.sort,{key:t.key,currentSortDirection:t.sortDirection})}}}):t.label)}renderSpacer(t,n){var i,a;const o=(null===(i=this.state._headerCells.vertical)||void 0===i?void 0:i.length)||0,l=null===(a=null==n?void 0:n[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:r("kol-table__spacer",`kol-table__spacer--${t}`)},e("td",{class:r(`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(){var t;const n=this.createDataField(this.state._data,this.state._headerCells);this.checkboxRefs=[];const i=null===(t=this.state._headerCells.horizontal)||void 0===t?void 0:t.map((e=>this.sortByColumnPosition(e)));return e("div",{key:"41ef1f9232f94305a6492420a311cf543b582a22",class:"kol-table"},e(s,{key:"3e0def33d6cf806d72c305d0e350b7ee4b2d3899",_tableSettings:this.state._tableSettings}),e("div",{key:"cc55a031f7bae8733cc5877763b68f9b1717b3e2",ref:e=>this.tableDivElement=e,class:"kol-table__scroll-container",tabindex:this.tableDivElementHasScrollbar?"-1":void 0},e("table",{key:"c96b4770ff54fb28a6d6eea1a9f021132e04652c",class:"kol-table__table",style:{minWidth:this.getTableMinWidth()}},e("div",{key:"96095fade8aa2347d2db8e4a42a735e07a683f05",class:"kol-table__focus-element",tabindex:this.tableDivElementHasScrollbar?"0":void 0,"aria-describedby":"caption"}," "),e("caption",{key:"fbf77baecd9f1f569c97df6596e598926f4fc420",class:"kol-table__caption",id:"caption"},this.state._label),Array.isArray(i)&&e("thead",{key:"aeab10b5b582c3134e5e0e7a483fbd441e00edc1",class:"kol-table__head"},[i.map(((t,n)=>e("tr",{class:"kol-table__head-row",key:`thead-${n}`},this.state._selection&&this.renderHeadingSelectionCell(),0===n&&this.renderHeaderTdCell(),Array.isArray(t)&&t.map(((e,t)=>this.renderHeadingCell(e,n,t,!1)))))),this.renderSpacer("head",i)]),e("tbody",{key:"536ad9c3574792ce18cf2694a4251cd781587aea",class:"kol-table__body"},n.map(((e,t)=>this.renderTableRow(e,t,!0)))),this.renderFoot())))}get host(){return i(this)}static get watchers(){return{_data:["validateData"],_dataFoot:["validateDataFoot"],_headerCells:["validateHeaderCells"],_label:["validateLabel"],_minWidth:["validateMinWidth"],_on:["validateOn"],_selection:["validateSelection"],_tableSettings:["validateTableSettings"]}}};export{Oi as kol_table_stateless_wc};