@public-ui/components
Version:
Contains all web components that belong to KoliBri - The accessible HTML-Standard.
5 lines • 26.7 kB
JavaScript
/*!
* KoliBri - The accessible HTML-Standard
*/
import{r as t,h as e,F as i,g as n}from"./index-BQlHOxik.js";import{a as l}from"./tslib.es6-QNbPBOk5.js";import{b as s,c as o,t as r}from"./component-names-Dy77vq43.js";import{t as a}from"./i18n-Br16IAnY.js";import{I as c}from"./component-DzaT2WlJ.js";import{T as d}from"./component-Dh0cPCxF.js";import{P as h,o as u,p as f,b,L as v,s as _}from"./common-Cx_AGO_M.js";import{c as p,v as k,a as y,b as m,f as g,d as S}from"./table-selection-DmmUo33G.js";import{v as j}from"./label-Fyi30H9j.js";import{v as w}from"./variant-class-name-BCcQYpIV.js";import{C}from"./keyboard-DNd73LVa.js";import{c as A}from"./clsx-COFh-Vc8.js";import{n as x}from"./dev.utils-02Sl9bQo.js";import{d as $,K as O}from"./events-VVvk1win.js";import{M as D,e as F,U as H,f as T,b as L,d as M,S as E,h as B}from"./_Uint8Array-kJHDjtoP.js";import{S as K,a as W,i as z}from"./isArray-CcrBs4JM.js";import"./i18n-B2d_exHc.js";import"./bem-registry-CWvl2xho.js";import"./component-DvjvBJeK.js";var P="__lodash_hash_undefined__";function R(t){this.__data__.set(t,P);return this}function V(t){return this.__data__.has(t)}function I(t){var e=-1,i=t==null?0:t.length;this.__data__=new D;while(++e<i){this.add(t[e])}}I.prototype.add=I.prototype.push=R;I.prototype.has=V;function N(t,e){var i=-1,n=t==null?0:t.length;while(++i<n){if(e(t[i],i,t)){return true}}return false}function U(t,e){return t.has(e)}var J=1,Q=2;function q(t,e,i,n,l,s){var o=i&J,r=t.length,a=e.length;if(r!=a&&!(o&&a>r)){return false}var c=s.get(t);var d=s.get(e);if(c&&d){return c==e&&d==t}var h=-1,u=true,f=i&Q?new I:undefined;s.set(t,e);s.set(e,t);while(++h<r){var b=t[h],v=e[h];if(n){var _=o?n(v,b,h,e,t,s):n(b,v,h,t,e,s)}if(_!==undefined){if(_){continue}u=false;break}if(f){if(!N(e,(function(t,e){if(!U(f,e)&&(b===t||l(b,t,i,n,s))){return f.push(e)}}))){u=false;break}}else if(!(b===v||l(b,v,i,n,s))){u=false;break}}s["delete"](t);s["delete"](e);return u}function G(t){var e=-1,i=Array(t.size);t.forEach((function(t,n){i[++e]=[n,t]}));return i}function Y(t){var e=-1,i=Array(t.size);t.forEach((function(t){i[++e]=t}));return i}var X=1,Z=2;var tt="[object Boolean]",et="[object Date]",it="[object Error]",nt="[object Map]",lt="[object Number]",st="[object RegExp]",ot="[object Set]",rt="[object String]",at="[object Symbol]";var ct="[object ArrayBuffer]",dt="[object DataView]";var ht=K?K.prototype:undefined,ut=ht?ht.valueOf:undefined;function ft(t,e,i,n,l,s,o){switch(i){case dt:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset){return false}t=t.buffer;e=e.buffer;case ct:if(t.byteLength!=e.byteLength||!s(new H(t),new H(e))){return false}return true;case tt:case et:case lt:return F(+t,+e);case it:return t.name==e.name&&t.message==e.message;case st:case rt:return t==e+"";case nt:var r=G;case ot:var a=n&X;r||(r=Y);if(t.size!=e.size&&!a){return false}var c=o.get(t);if(c){return c==e}n|=Z;o.set(t,e);var d=q(r(t),r(e),n,l,s,o);o["delete"](t);return d;case at:if(ut){return ut.call(t)==ut.call(e)}}return false}var bt=1;var vt=Object.prototype;var _t=vt.hasOwnProperty;function pt(t,e,i,n,l,s){var o=i&bt,r=T(t),a=r.length,c=T(e),d=c.length;if(a!=d&&!o){return false}var h=a;while(h--){var u=r[h];if(!(o?u in e:_t.call(e,u))){return false}}var f=s.get(t);var b=s.get(e);if(f&&b){return f==e&&b==t}var v=true;s.set(t,e);s.set(e,t);var _=o;while(++h<a){u=r[h];var p=t[u],k=e[u];if(n){var y=o?n(k,p,u,e,t,s):n(p,k,u,t,e,s)}if(!(y===undefined?p===k||l(p,k,i,n,s):y)){v=false;break}_||(_=u=="constructor")}if(v&&!_){var m=t.constructor,g=e.constructor;if(m!=g&&("constructor"in t&&"constructor"in e)&&!(typeof m=="function"&&m instanceof m&&typeof g=="function"&&g instanceof g)){v=false}}s["delete"](t);s["delete"](e);return v}var kt=1;var yt="[object Arguments]",mt="[object Array]",gt="[object Object]";var St=Object.prototype;var jt=St.hasOwnProperty;function wt(t,e,i,n,l,s){var o=W(t),r=W(e),a=o?mt:L(t),c=r?mt:L(e);a=a==yt?gt:a;c=c==yt?gt:c;var d=a==gt,h=c==gt,u=a==c;if(u&&M(t)){if(!M(e)){return false}o=true;d=false}if(u&&!d){s||(s=new E);return o||B(t)?q(t,e,i,n,l,s):ft(t,e,a,i,n,l,s)}if(!(i&kt)){var f=d&&jt.call(t,"__wrapped__"),b=h&&jt.call(e,"__wrapped__");if(f||b){var v=f?t.value():t,_=b?e.value():e;s||(s=new E);return l(v,_,i,n,s)}}if(!u){return false}s||(s=new E);return pt(t,e,i,n,l,s)}function Ct(t,e,i,n,l){if(t===e){return true}if(t==null||e==null||!z(t)&&!z(e)){return t!==t&&e!==e}return wt(t,e,i,n,Ct,l)}function At(t,e){return Ct(t,e)}const xt=t=>Array.isArray(t)&&t.every((t=>Array.isArray(t)));const $t=(t,e)=>{h(e,(()=>{u(e,(()=>{try{e=f(e)}catch(t){}b(t,"_headerCells",(t=>{if(typeof t!=="object"||t===null)return false;const e=t.horizontal;const i=t.vertical;if(e!==undefined&&!xt(e)||i!==undefined&&!xt(i)){return false}const n=[];for(const t of e!==null&&e!==void 0?e:[]){n.push(...t)}for(const t of i!==null&&i!==void 0?i:[]){n.push(...t)}return n.every((t=>t.width===undefined||typeof t.width==="number"))}),new Set(["TableHeaderCellsPropType"]),e)}))}))};const Ot=150;const Dt=class{constructor(i){t(this,i);this.translateNoEntries=a("kol-no-entries");this.state={_data:[],_headerCells:{horizontal:[],vertical:[]},_label:"",_hasSettingsMenu:false};this.horizontal=true;this.cellsToRenderTimeouts=new Map;this.dataToKeyMap=new Map;this.checkboxRefs=[];this.translateSort=a("kol-sort");this.translateSortOrder=a("kol-table-sort-order");this.maxCols=0;this.fixedOffsets=[];this.settingsChangedCounter=0;this.tableDivElementHasScrollbar=false;this.stickyColsDisabled=false;this.renderTableRow=(t,i,n,l=false)=>{var s,o;let r=String(i);if(this.horizontal&&((s=t[0])===null||s===void 0?void 0:s.data)){r=(o=this.getDataKey(t[0].data))!==null&&o!==void 0?o:r}return e("tr",{class:A("kol-table__row",{"kol-table__row--body":!l,"kol-table__row--footer":l}),key:`row-${r}`},this.renderSelectionCell(t,i),t.map(((t,e)=>this.renderTableCell(t,i,e,n))))};this.renderTableCell=(t,i,n,l)=>{if(t.visible===false){return""}let s=`${i}-${n}-${t.label}`;if(t.data){const e=this.getDataKey(t.data);s=e?`${e}-${this.horizontal?n:i}`:s}if(t.headerCell){return this.renderHeadingCell(t,i,n,l)}else{const i=typeof t.render!=="function"&&t.label===this.translateNoEntries;const l=this.getActionColumnHeader(n);const o=Boolean(l&&t.data);const r=this.isFixedCol(n);const a=r==="left"?this.getOffsetString(t.colIndex,true):undefined;const c=r==="right"?this.getOffsetString(t.colIndex):undefined;const d=typeof t.render==="function";return e("td",{key:`cell-${s}-${this.settingsChangedCounter}`,class:A("kol-table__cell kol-table__cell--body",t.textAlign&&`kol-table__cell--align-${t.textAlign}`,o&&"kol-table__cell--actions",r&&`kol-table__cell--sticky-${r}`),"aria-atomic":i?"false":undefined,"aria-live":i?"polite":undefined,"aria-relevant":i?"text":undefined,colSpan:t.colSpan,rowSpan:t.rowSpan,style:{textAlign:t.textAlign,left:a,right:c},ref:d?e=>{this.cellRender(t,e)}:undefined},o&&l&&t.data?this.renderActionItems(l,t.data,s):!d?t.label:"")}};this.renderActionItems=(t,i,n)=>{const r=t.actions(i);return e("div",{class:"kol-table__cell-actions"},r.map(((t,i)=>{if(t.type==="button"){const o=l(t,[]);return e(s,Object.assign({key:`action-${n}-${i}`},o,{_variant:o._variant}))}else if(t.type==="link"){const s=l(t,[]);return e(o,Object.assign({key:`action-${n}-${i}`},s))}return null})))}}onExternalLabelElementsChange(t){this.syncTableLabel(t)}validateAriaLabelledby(){}syncTableLabel(t){if(!this.tableRef)return;if("ariaLabelledByElements"in this.tableRef){if(t===null||t===void 0?void 0:t.length){this.tableRef.ariaLabelledByElements=t}v.debug([this.tableRef,!!(t===null||t===void 0?void 0:t.length),t,this.tableRef.ariaLabelledByElements])}}validateHasSettingsMenu(t){p(this,t)}validateData(t){k(this,t,{beforePatch:t=>{this.updateDataToKeyMap(t)}})}validateDataFoot(t){y(this,t)}validateFixedCols(t){m(this,t);this.checkAndUpdateStickyState()}validateHeaderCells(t){$t(this,t);if(!At(this.previousHeaderCells,this.state._headerCells)){this.initializeHeaderCellSettings()}this.previousHeaderCells=this.state._headerCells}validateLabel(t){j(this,t,{required:true})}validateOn(t){g(this,t)}validateSelection(t){S(this,t);this.checkAndUpdateStickyState()}validateVariantClassName(t){w(this,t)}handleKeyDown(t){var e;if(t.key==="ArrowUp"||t.key==="ArrowDown"){const i=(e=this.tableDivElement)===null||e===void 0?void 0:e.querySelector(":focus");let n=this.checkboxRefs.indexOf(i);if(n>-1){t.preventDefault();if(t.key==="ArrowDown"){n=(n+1)%this.checkboxRefs.length;this.checkboxRefs[n].focus()}else if(t.key==="ArrowUp"){t.preventDefault();n=(n+this.checkboxRefs.length-1)%this.checkboxRefs.length;this.checkboxRefs[n].focus()}}}}componentDidRender(){this.checkDivElementScrollbar()}componentDidLoad(){if(this.tableDivElement&&ResizeObserver){this.tableDivElementResizeObserver=new ResizeObserver(this.handleResize.bind(this));this.tableDivElementResizeObserver.observe(this.tableDivElement)}this.checkAndUpdateStickyState()}handleSettingsChange(t){var e;const i=Object.assign(Object.assign({},this.state._headerCells),{horizontal:t.detail});_(this,"_headerCells",i);this.settingsChangedCounter++;if(typeof((e=this.state._on)===null||e===void 0?void 0:e[C.onChangeHeaderCells])==="function"){this.state._on[C.onChangeHeaderCells](t,i)}}disconnectedCallback(){var t;(t=this.tableDivElementResizeObserver)===null||t===void 0?void 0:t.disconnect();clearTimeout(this.resizeDebounceTimeout)}handleResize(){this.checkDivElementScrollbar();clearTimeout(this.resizeDebounceTimeout);this.resizeDebounceTimeout=setTimeout((()=>{this.checkAndUpdateStickyState()}),Ot)}checkDivElementScrollbar(){if(this.tableDivElement){this.tableDivElementHasScrollbar=this.tableDivElement.scrollWidth>this.tableDivElement.clientWidth}}calculateFixedColsWidth(){var t,e,i,n,l,s;if(!this._fixedCols)return 0;const o=this.getPrimaryHeaders(this.state._headerCells);let r=0;for(let i=0;i<this._fixedCols[0]&&i<o.length;i++){r+=(e=(t=o[i])===null||t===void 0?void 0:t.width)!==null&&e!==void 0?e:0}const a=this.maxCols-this._fixedCols[1];for(let t=a;t<this.maxCols&&t<o.length;t++){r+=(n=(i=o[t])===null||i===void 0?void 0:i.width)!==null&&n!==void 0?n:0}if(this.state._selection){const t=(l=this.tableDivElement)===null||l===void 0?void 0:l.querySelector(".kol-table__cell--selection");r+=(s=t===null||t===void 0?void 0:t.offsetWidth)!==null&&s!==void 0?s:0}return r}checkAndUpdateStickyState(){if(!this.tableDivElement||!this._fixedCols){this.stickyColsDisabled=false;return}const t=this.tableDivElement.clientWidth;const e=this.calculateFixedColsWidth();this.stickyColsDisabled=e>0&&e>=t}updateDataToKeyMap(t){t.forEach((t=>{if(!this.dataToKeyMap.has(t)){this.dataToKeyMap.set(t,x())}}));this.dataToKeyMap.forEach(((e,i)=>{if(!t.includes(i)){this.dataToKeyMap.delete(i)}}))}getDataKey(t){return this.dataToKeyMap.get(t)}getActionColumnHeader(t){const e=this.horizontal?this.state._headerCells.horizontal:this.state._headerCells.vertical;if(!e||e.length===0)return undefined;const i=this.getPrimaryHeaders(this.state._headerCells);const n=i[t];if(n&&n.type==="action"){return n}return undefined}cellRender(t,e){if(e){clearTimeout(this.cellsToRenderTimeouts.get(e));this.cellsToRenderTimeouts.set(e,setTimeout((()=>{if(typeof t.render==="function"){const i=t.render(e,t,t.data,this.state._data);if(typeof i==="string"){e.textContent=i}}})))}}getNumberOfCols(t,e){let i=0;t.forEach((t=>{let e=0;if(Array.isArray(t)){t.forEach((t=>{var i;e+=(i=t.colSpan)!==null&&i!==void 0?i:1}))}if(i<e){i=e}}));if(i===0){i=e.length}return i}getNumberOfRows(t,e){var i;let n=0;t.forEach((t=>{let e=0;if(Array.isArray(t)){t.forEach((t=>{var i;e+=(i=t.rowSpan)!==null&&i!==void 0?i:1}))}if(n<e){n=e}}));if(n===0){n=e.length}else{n-=((i=this.state._dataFoot)===null||i===void 0?void 0:i.length)||0}return n}getThePrimaryHeadersWithKeyOrRenderFunction(t){const e=[];t.forEach((t=>{t.forEach((t=>{if(typeof t.key==="string"||typeof t.render==="function"){e.push(t)}}))}));return e}getPrimaryHeaders(t){var e,i;let n=this.getThePrimaryHeadersWithKeyOrRenderFunction((e=t.horizontal)!==null&&e!==void 0?e:[]);this.horizontal=true;if(n.length===0){n=this.getThePrimaryHeadersWithKeyOrRenderFunction((i=t.vertical)!==null&&i!==void 0?i:[]);if(n.length>0){this.horizontal=false}}return n}createDataField(t,e,i){var n,l,s,o,r,a,c,d;e.horizontal=Array.isArray(e===null||e===void 0?void 0:e.horizontal)?e.horizontal:[];e.vertical=Array.isArray(e===null||e===void 0?void 0:e.vertical)?e.vertical:[];this.maxCols=this.getNumberOfCols(e.horizontal,t);const h=this.getPrimaryHeaders(e);let u=this.getNumberOfRows(e.vertical,t);let f=0;if(i){f=u;u+=((n=this.state._dataFoot)===null||n===void 0?void 0:n.length)||0}const b=[];const v=[];const _=[];e.vertical.forEach(((t,e)=>{v[e]=0;_[e]=[]}));const p=h;for(let n=f;n<u;n++){const d=[];e.vertical.forEach(((t,e)=>{let i=0;_[e].forEach((t=>i+=t));if(i<=n){const l=t[n-i+v[e]];if(typeof l==="object"){d.push(Object.assign(Object.assign({},l),{headerCell:true,data:{}}));let t=1;if(typeof l.rowSpan==="number"&&l.rowSpan>1){t=l.rowSpan}_[e].push(t);if(typeof l.colSpan==="number"&&l.colSpan>1){for(let i=1;i<l.colSpan;i++){_[e+i].push(t)}}v[e]++}}}));for(let e=0;e<this.maxCols;e++){let h=this.isFixedCol(e);if(h==="left"){if(this.getFixedOffset(e)===undefined){let t=(l=this.fixedOffsets[e-1])!==null&&l!==void 0?l:0;t+=(o=(s=p[e-1])===null||s===void 0?void 0:s.width)!==null&&o!==void 0?o:0;this.fixedOffsets[e]=t}}if(h==="right"){if(this.getFixedOffset(e)===undefined){let t=(r=this.fixedOffsets[e+1])!==null&&r!==void 0?r:0;t+=(c=(a=p[e+1])===null||a===void 0?void 0:a.width)!==null&&c!==void 0?c:0;this.fixedOffsets[e]=t}}if(this.horizontal===true){const l=i&&this.state._dataFoot?this.state._dataFoot[n-f]:t[n];if(typeof p[e]==="object"&&p[e]!==null&&typeof l==="object"&&l!==null&&(typeof p[e].key==="string"||typeof p[e].render==="function")){const t=p[e].key;const i=l[t];d.push(Object.assign(Object.assign({},p[e]),{colIndex:e,colSpan:undefined,rowSpan:undefined,data:l,label:i}))}}else{if(typeof p[n]==="object"&&p[n]!==null&&typeof t[e]==="object"&&t[e]!==null&&(typeof p[n].key==="string"||typeof p[n].render==="function")){const i=p[n].key;const l=t[e][i];d.push(Object.assign(Object.assign({},p[n]),{colIndex:e,colSpan:undefined,rowSpan:undefined,data:t[e],label:l}))}}}b.push(d)}if(t.length===0){let t=this.getVisibleColSpan((d=e.horizontal)===null||d===void 0?void 0:d[0]);let i=0;if(Array.isArray(e.vertical)&&e.vertical.length>0){t-=e.vertical.length;e.vertical[0].forEach((t=>{i+=t.rowSpan||1}))}const n={colSpan:t,label:this.translateNoEntries,render:undefined,rowSpan:Math.max(i,1)};if(b.length===0){b.push([n])}else{b[0].push(n)}}return b}getVisibleColSpan(t){var e;return(e=t===null||t===void 0?void 0:t.reduce(((t,e)=>{if("visible"in e&&e.visible===false){return t}return t+(e.colSpan||1)}),0))!==null&&e!==void 0?e:0}isFixedCol(t){if(!this._fixedCols||t===undefined||this.stickyColsDisabled){return undefined}if(t<this._fixedCols[0]){return"left"}if(t>=this.maxCols-this._fixedCols[1]){return"right"}}getFixedOffset(t){if(!this.tableDivElement||t===undefined){return undefined}if(this.fixedOffsets[t]!==undefined){return this.fixedOffsets[t]}return undefined}getOffsetString(t,e){if(e&&this._selection){return"calc( var(--kol-table-selection-col-width) + "+this.getFixedOffset(t)+"px)"}return this.getFixedOffset(t)+"px"}handleSelectionChangeCallbackAndEvent(t,e){var i;if(typeof((i=this.state._on)===null||i===void 0?void 0:i[C.onSelectionChange])==="function"){this.state._on[C.onSelectionChange](t,e)}if(this.host){$(this.host,O.selectionChange,e)}}initializeHeaderCellSettings(){if(this.state._headerCells&&this.state._headerCells.horizontal&&this.state._headerCells.horizontal.length>0){const t=Object.assign(Object.assign({},this.state._headerCells),{horizontal:this.state._headerCells.horizontal.map((t=>t.map((t=>Object.assign(Object.assign({},t),{visible:typeof t.visible==="boolean"?t.visible:true,hidable:typeof t.hidable==="boolean"?t.hidable:true})))))});_(this,"_headerCells",t)}}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);this.validateVariantClassName(this._variant)}renderSelectionCell(t,i){var n;const l=this.state._selection;if(!l)return"";const s=this.getSelectionKeyPropertyName();const o=(n=t[0])===null||n===void 0?void 0:n.data;if(!o)return"";const r=o[s];const a=l.multiple||l.multiple===undefined;const h=(()=>{const t=l===null||l===void 0?void 0:l.selectedKeys;const e=t===undefined?[]:Array.isArray(t)?t:[t];return e.some((t=>String(t)===String(r)))})();const u=(()=>{const t=l===null||l===void 0?void 0:l.disabledKeys;const e=t===undefined?[]:Array.isArray(t)?t:[t];return e.some((t=>String(t)===String(r)))})();const f=l.label(o);const b={name:"selection",checked:h,disabled:u,id:String(r),["aria-label"]:f};return e("td",{key:`tbody-${i}-selection`,class:"kol-table__cell kol-table__cell--selection"},e("div",{class:A("kol-table__selection",{"kol-table__selection--checked":h})},a?e("label",{class:A("kol-table__selection-label",{"kol-table__selection-label--disabled":u})},e(c,{class:"kol-table__selection-icon",icons:`kolicon ${h?"kolicon-check":""}`,label:""}),e("input",Object.assign({class:A("kol-table__selection-input kol-table__selection-input--checkbox"),ref:t=>t&&this.checkboxRefs.push(t)},b,{type:"checkbox",onInput:t=>{const e=(()=>{const t=l===null||l===void 0?void 0:l.selectedKeys;return t===undefined?[]:Array.isArray(t)?t:[t]})();const i=!h?[...e,r]:e.filter((t=>String(t)!==String(r)));this.handleSelectionChangeCallbackAndEvent(t,i!==null&&i!==void 0?i:[])}}))):e("label",{class:"kol-table__selection-label"},e("input",Object.assign({class:A("kol-table__selection-input kol-table__selection-input--radio")},b,{type:"radio",onInput:t=>{this.handleSelectionChangeCallbackAndEvent(t,[r])}}))),e("div",{class:"kol-table__selection-input-tooltip"},e(d,{label:f,badgeText:"",id:`${r}-label`,refFloating:()=>{}}))))}getSelectionKeyPropertyName(){var t,e;return(e=(t=this.state._selection)===null||t===void 0?void 0:t.keyPropertyName)!==null&&e!==void 0?e:"id"}getDataWithSelectionEnabled(){const t=this.getSelectionKeyPropertyName();return this.state._data.filter((e=>{var i;const n=(i=this.state._selection)===null||i===void 0?void 0:i.disabledKeys;const l=n===undefined?[]:Array.isArray(n)?n:[n];return!l.some((i=>String(i)===String(e[t])))}))}getSelectedKeysWithoutDisabledKeys(){const t=(()=>{var t;const e=(t=this.state._selection)===null||t===void 0?void 0:t.selectedKeys;return e===undefined?[]:Array.isArray(e)?e:[e]})();const e=(()=>{var t;const e=(t=this.state._selection)===null||t===void 0?void 0:t.disabledKeys;return e===undefined?[]:Array.isArray(e)?e:[e]})();return t.filter((t=>!e.some((e=>String(e)===String(t)))))}getSelectedKeysWithDisabledKeysOnly(){const t=(()=>{var t;const e=(t=this.state._selection)===null||t===void 0?void 0:t.selectedKeys;return e===undefined?[]:Array.isArray(e)?e:[e]})();const e=(()=>{var t;const e=(t=this.state._selection)===null||t===void 0?void 0:t.disabledKeys;return e===undefined?[]:Array.isArray(e)?e:[e]})();return t.filter((t=>e.some((e=>String(e)===String(t)))))}getRevertedSelection(t){var e;const i=this.getSelectionKeyPropertyName();const n=(e=this.getSelectedKeysWithDisabledKeysOnly())!==null&&e!==void 0?e:[];if(t){n.push(...this.getDataWithSelectionEnabled().map((t=>t===null||t===void 0?void 0:t[i])))}return n}getTableMinWidth(){var t,e;const i=(t=this.state._headerCells.horizontal)!==null&&t!==void 0?t:[];const n=[];i.forEach((t=>{t.forEach((t=>{if(t.visible!==false&&t.width!==undefined&&t.width>0){n.push(t.width)}}))}));const l=(e=this.state._headerCells.vertical)!==null&&e!==void 0?e:[];const s=[];l.forEach((t=>{t.forEach((t=>{if(t.width!==undefined&&t.width>0){s.push(t.width)}}))}));const o=[...s,...n];if(o.length===0){return"0px"}if(o.length===1){return`${o[0]}px`}return`calc(${o.map((t=>`${t}px`)).join(" + ")})`}renderHeadingSelectionCell(){var t,i;const n=this.state._selection;if(!n){return e("td",{class:"kol-table__cell kol-table__cell--header",key:`thead-0`})}if(n.multiple===false){return e("td",{key:`thead-0-selection`,class:"kol-table__cell kol-table__cell--header kol-table__cell--selection"})}const l=(i=(t=this.getSelectedKeysWithoutDisabledKeys())===null||t===void 0?void 0:t.length)!==null&&i!==void 0?i:0;const s=this.getDataWithSelectionEnabled().length;const o=l===s;const r=l!==0&&!o;let h="kol-table-selection-indeterminate";if(o&&!r){h="kol-table-selection-none"}if(l===0){h="kol-table-selection-all"}const u=a(h);return e("th",{key:`thead-0-selection`,class:"kol-table__cell kol-table__cell--header kol-table__cell--selection"},e("div",{class:A("kol-table__selection",{"kol-table__selection--indeterminate":r,"kol-table__selection--checked":o})},e("label",{class:"kol-table__selection-label"},e(c,{class:"kol-table__selection-icon",icons:`kolicon ${r?"kolicon-minus":o?"kolicon-check":""}`,label:""}),e("input",{class:A("kol-table__selection-input kol-table__selection-input--checkbox"),"data-testid":"selection-checkbox-all",ref:t=>t&&this.checkboxRefs.push(t),name:"selection",checked:o&&!r,indeterminate:r,"aria-label":u,type:"checkbox",onInput:t=>{this.handleSelectionChangeCallbackAndEvent(t,this.getRevertedSelection(!o))}})),e("div",{class:"kol-table__selection-input-tooltip"},e(d,{label:u,badgeText:"",id:`${h}-label`,refFloating:()=>{}}))))}renderHeaderTdCell(){const t=this.state._headerCells.horizontal;const n=this.state._headerCells.vertical;if(!Array.isArray(t)||t.length===0||!Array.isArray(n)||n.length===0){return e(i,null)}const l=n.reduce(((t,e)=>{var i;const n=e===null||e===void 0?void 0:e[0];return t+((i=n===null||n===void 0?void 0:n.width)!==null&&i!==void 0?i:0)}),0);return e("td",{"aria-hidden":"true",colSpan:n.length,rowSpan:t.length,style:l>0?{width:`${l}px`}:undefined})}formatSortOrderDescription(t){return this.translateSortOrder.replace("{{order}}",`${t}`)}getSortAriaDescription(t){if(typeof t==="number"&&t>0){return`${this.translateSort} – ${this.formatSortOrderDescription(t)}`}return this.translateSort}renderHeadingCell(t,i,n,l){if(t.visible===false){return""}const o=(t===null||t===void 0?void 0:t.sortable)!==false;const r=typeof t.sortDirection==="string";const a=o&&r;let c="none";let d="kolicon-sort-neutral";if(a&&t.sortDirection){switch(t.sortDirection){case"ASC":d="kolicon-sort-asc";c="ascending";break;case"DESC":d="kolicon-sort-desc";c="descending";break;default:c="none"}}const h=l?"row":typeof t.colSpan==="number"&&t.colSpan>1?"colgroup":"col";const u=typeof t.sortOrder==="number"&&t.sortOrder>0?t.sortOrder:undefined;const f=this.getSortAriaDescription(u);const b=t.width!==undefined?`${t.width}px`:undefined;const v=this.isFixedCol(n);const _=v==="left"?this.getOffsetString(n,true):undefined;const p=v==="right"?this.getOffsetString(n):undefined;return e("th",{key:`${i}-${n}-${t.label}`,class:A("kol-table__cell kol-table__cell--header",`kol-table__cell--${c}`,t.textAlign&&`kol-table__cell--align-${t.textAlign}`,v&&`kol-table__cell--sticky-${v}`),scope:h,colSpan:t.colSpan,rowSpan:t.rowSpan,style:{width:b,left:_,right:p},"aria-sort":c,"data-sort":a&&t.sortDirection?`sort-${t.sortDirection}`:undefined},a&&t.sortDirection?e("span",{class:"kol-table__sort"},e(s,{class:"kol-table__sort-button",_icons:{right:d},_label:t.label,_ariaDescription:f,_on:{onClick:e=>{var i;if(typeof((i=this.state._on)===null||i===void 0?void 0:i.onSort)==="function"&&t.key&&t.sortDirection){this.state._on.onSort(e,{key:t.key,currentSortDirection:t.sortDirection})}if(this.host){$(this.host,O.sort,{key:t.key,currentSortDirection:t.sortDirection})}}}}),u&&e("span",{"aria-hidden":"true",class:"kol-table__sort-order"},u)):t.label)}renderSpacer(t,i){var n;const l=((n=this.state._headerCells.vertical)===null||n===void 0?void 0:n.length)||0;const s=this.getVisibleColSpan(i===null||i===void 0?void 0:i[0]);const o=this.state._selection?1:0;return e("tr",{"aria-hidden":"true",class:A("kol-table__spacer",`kol-table__spacer--${t}`)},e("td",{class:A(`kol-table__spacer-line kol-table__spacer-line--${t}`),colSpan:l+s+o}))}renderFoot(){if(!this.state._dataFoot||this.state._dataFoot.length===0){return null}const t=this.createDataField(this.state._dataFoot,this.state._headerCells,true);return e("tfoot",{class:"kol-table__footer"},[this.renderSpacer("foot",t),t.map(((t,e)=>this.renderTableRow(t,e,true,true)))])}render(){var t;const i=this.createDataField(this.state._data,this.state._headerCells);this.checkboxRefs=[];const n=this.state._headerCells.horizontal;const l=!((t=this.externalLabelElements)===null||t===void 0?void 0:t.length);return e("div",{key:"b3078fc5b1fddaf8b1a125452e5a0ba65f64cce1",class:A("kol-table",{[`kol-table--${this.state._variant}`]:this.state._variant!==undefined})},this.state._hasSettingsMenu&&e(r,{key:"cba65b7abb0aa685c0115c74238414e1acf65d20",_horizontalHeaderCells:n!==null&&n!==void 0?n:[]}),e("div",{key:"d8390e0d8ef806a913c5b433c1e528c3729c63a2",ref:t=>this.tableDivElement=t,class:"kol-table__scroll-container",tabindex:this.tableDivElementHasScrollbar?l?"-1":"0":undefined},e("table",{key:"24880450759191739622f8dc03f25ec52c188248",ref:t=>{this.tableRef=t;this.syncTableLabel(this.externalLabelElements)},"aria-labelledby":l?"caption":undefined,class:"kol-table__table",style:{minWidth:this.getTableMinWidth()}},l&&e("caption",{key:"9a80f320bcb382b953176564e1209e24a14ebe91",class:"kol-table__focus-element kol-table__caption",id:"caption",tabindex:this.tableDivElementHasScrollbar?"0":undefined},this.state._label),Array.isArray(n)&&e("thead",{key:"9125286ae3e47630e42fd04d970f687ca8c4c056",class:"kol-table__head"},[n.map(((t,i)=>e("tr",{class:"kol-table__head-row",key:`thead-${i}`},this.state._selection&&this.renderHeadingSelectionCell(),i===0&&this.renderHeaderTdCell(),Array.isArray(t)&&t.map(((t,e)=>this.renderHeadingCell(t,i,e,false)))))),this.renderSpacer("head",n)]),e("tbody",{key:"18458ad8f7712d2acffbec2ae79da9b5991174b7",class:"kol-table__body"},i.map(((t,e)=>this.renderTableRow(t,e,true)))),this.renderFoot())))}get host(){return n(this)}static get watchers(){return{externalLabelElements:["onExternalLabelElementsChange"],_ariaLabelledby:["validateAriaLabelledby"],_hasSettingsMenu:["validateHasSettingsMenu"],_data:["validateData"],_dataFoot:["validateDataFoot"],_fixedCols:["validateFixedCols"],_headerCells:["validateHeaderCells"],_label:["validateLabel"],_on:["validateOn"],_selection:["validateSelection"],_variant:["validateVariantClassName"]}}};export{Dt as kol_table_stateless_wc};
//# sourceMappingURL=kol-table-stateless-wc.entry.js.map