@public-ui/components
Version:
Contains all web components that belong to KoliBri - The accessible HTML-Standard.
4 lines • 34.4 kB
JavaScript
/*!
* KoliBri - The accessible HTML-Standard
*/
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const index$1=require("./index-03ef29aa.js"),clsx=require("./clsx-dd4d6dd1.js"),componentNames=require("./component-names-82c4d68d.js"),i18n=require("./i18n-b9d16ebc.js"),index=require("./index-8b802221.js"),keyboard=require("./keyboard-19a7833a.js"),dev_utils=require("./dev.utils-f6da9b54.js"),events=require("./events-40771c95.js"),tableSettings=require("./table-settings-ab716c5d.js"),isArray=require("./isArray-e114fe6e.js"),isObject=require("./isObject-6090b636.js"),label=require("./label-21c38949.js");require("./i18n-8c288a27.js");const validateTableHeaderCells=(e,t)=>{index.emptyStringByArrayHandler(t,(()=>{index.objectObjectHandler(t,(()=>{try{t=index.parseJson(t)}catch(e){}index.watchValidator(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 asyncTag="[object AsyncFunction]",funcTag$1="[object Function]",genTag="[object GeneratorFunction]",proxyTag="[object Proxy]";function isFunction(e){if(!isObject.isObject(e))return!1;var t=isArray.baseGetTag(e);return t==funcTag$1||t==genTag||t==asyncTag||t==proxyTag}var coreJsData=isArray.root["__core-js_shared__"];const coreJsData$1=coreJsData;var maskSrcKey=function(){var e=/[^.]+$/.exec(coreJsData$1&&coreJsData$1.keys&&coreJsData$1.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function isMasked(e){return!!maskSrcKey&&maskSrcKey in e}var funcProto$1=Function.prototype,funcToString$1=funcProto$1.toString;function toSource(e){if(null!=e){try{return funcToString$1.call(e)}catch(e){}try{return e+""}catch(e){}}return""}var reRegExpChar=/[\\^$.*+?()[\]{}|]/g,reIsHostCtor=/^\[object .+?Constructor\]$/,funcProto=Function.prototype,objectProto$9=Object.prototype,funcToString=funcProto.toString,hasOwnProperty$7=objectProto$9.hasOwnProperty,reIsNative=RegExp("^"+funcToString.call(hasOwnProperty$7).replace(reRegExpChar,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function baseIsNative(e){return!(!isObject.isObject(e)||isMasked(e))&&(isFunction(e)?reIsNative:reIsHostCtor).test(toSource(e))}function getValue(e,t){return null==e?void 0:e[t]}function getNative(e,t){var a=getValue(e,t);return baseIsNative(a)?a:void 0}var WeakMap=getNative(isArray.root,"WeakMap");const WeakMap$1=WeakMap;var MAX_SAFE_INTEGER$1=9007199254740991,reIsUint=/^(?:0|[1-9]\d*)$/;function isIndex(e,t){var a=typeof e;return!!(t=null==t?MAX_SAFE_INTEGER$1:t)&&("number"==a||"symbol"!=a&&reIsUint.test(e))&&e>-1&&e%1==0&&e<t}function eq(e,t){return e===t||e!=e&&t!=t}var MAX_SAFE_INTEGER=9007199254740991;function isLength(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=MAX_SAFE_INTEGER}function isArrayLike(e){return null!=e&&isLength(e.length)&&!isFunction(e)}var objectProto$8=Object.prototype;function isPrototype(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||objectProto$8)}function baseTimes(e,t){for(var a=-1,r=Array(e);++a<e;)r[a]=t(a);return r}var argsTag$2="[object Arguments]";function baseIsArguments(e){return isArray.isObjectLike(e)&&isArray.baseGetTag(e)==argsTag$2}var objectProto$7=Object.prototype,hasOwnProperty$6=objectProto$7.hasOwnProperty,propertyIsEnumerable$1=objectProto$7.propertyIsEnumerable,isArguments=baseIsArguments(function(){return arguments}())?baseIsArguments:function(e){return isArray.isObjectLike(e)&&hasOwnProperty$6.call(e,"callee")&&!propertyIsEnumerable$1.call(e,"callee")};const isArguments$1=isArguments;function stubFalse(){return!1}var freeExports$1="object"==typeof exports&&exports&&!exports.nodeType&&exports,freeModule$1=freeExports$1&&"object"==typeof module&&module&&!module.nodeType&&module,moduleExports$1=freeModule$1&&freeModule$1.exports===freeExports$1,Buffer=moduleExports$1?isArray.root.Buffer:void 0,nativeIsBuffer=Buffer?Buffer.isBuffer:void 0,isBuffer=nativeIsBuffer||stubFalse;const isBuffer$1=isBuffer;var argsTag$1="[object Arguments]",arrayTag$1="[object Array]",boolTag$1="[object Boolean]",dateTag$1="[object Date]",errorTag$1="[object Error]",funcTag="[object Function]",mapTag$2="[object Map]",numberTag$1="[object Number]",objectTag$2="[object Object]",regexpTag$1="[object RegExp]",setTag$2="[object Set]",stringTag$1="[object String]",weakMapTag$1="[object WeakMap]",arrayBufferTag$1="[object ArrayBuffer]",dataViewTag$2="[object DataView]",float32Tag="[object Float32Array]",float64Tag="[object Float64Array]",int8Tag="[object Int8Array]",int16Tag="[object Int16Array]",int32Tag="[object Int32Array]",uint8Tag="[object Uint8Array]",uint8ClampedTag="[object Uint8ClampedArray]",uint16Tag="[object Uint16Array]",uint32Tag="[object Uint32Array]",typedArrayTags={};function baseIsTypedArray(e){return isArray.isObjectLike(e)&&isLength(e.length)&&!!typedArrayTags[isArray.baseGetTag(e)]}function baseUnary(e){return function(t){return e(t)}}typedArrayTags[float32Tag]=typedArrayTags[float64Tag]=typedArrayTags[int8Tag]=typedArrayTags[int16Tag]=typedArrayTags[int32Tag]=typedArrayTags[uint8Tag]=typedArrayTags[uint8ClampedTag]=typedArrayTags[uint16Tag]=typedArrayTags[uint32Tag]=!0,typedArrayTags[argsTag$1]=typedArrayTags[arrayTag$1]=typedArrayTags[arrayBufferTag$1]=typedArrayTags[boolTag$1]=typedArrayTags[dataViewTag$2]=typedArrayTags[dateTag$1]=typedArrayTags[errorTag$1]=typedArrayTags[funcTag]=typedArrayTags[mapTag$2]=typedArrayTags[numberTag$1]=typedArrayTags[objectTag$2]=typedArrayTags[regexpTag$1]=typedArrayTags[setTag$2]=typedArrayTags[stringTag$1]=typedArrayTags[weakMapTag$1]=!1;var freeExports="object"==typeof exports&&exports&&!exports.nodeType&&exports,freeModule=freeExports&&"object"==typeof module&&module&&!module.nodeType&&module,moduleExports=freeModule&&freeModule.exports===freeExports,freeProcess=moduleExports&&isArray.freeGlobal.process,nodeUtil=function(){try{var e=freeModule&&freeModule.require&&freeModule.require("util").types;return e||freeProcess&&freeProcess.binding&&freeProcess.binding("util")}catch(e){}}();const nodeUtil$1=nodeUtil;var nodeIsTypedArray=nodeUtil&&nodeUtil.isTypedArray,isTypedArray=nodeIsTypedArray?baseUnary(nodeIsTypedArray):baseIsTypedArray;const isTypedArray$1=isTypedArray;var objectProto$6=Object.prototype,hasOwnProperty$5=objectProto$6.hasOwnProperty;function arrayLikeKeys(e,t){var a=isArray.isArray(e),r=!a&&isArguments$1(e),o=!a&&!r&&isBuffer$1(e),i=!a&&!r&&!o&&isTypedArray$1(e),s=a||r||o||i,n=s?baseTimes(e.length,String):[],l=n.length;for(var c in e)!t&&!hasOwnProperty$5.call(e,c)||s&&("length"==c||o&&("offset"==c||"parent"==c)||i&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||isIndex(c,l))||n.push(c);return n}function overArg(e,t){return function(a){return e(t(a))}}var nativeKeys=overArg(Object.keys,Object);const nativeKeys$1=nativeKeys;var objectProto$5=Object.prototype,hasOwnProperty$4=objectProto$5.hasOwnProperty;function baseKeys(e){if(!isPrototype(e))return nativeKeys$1(e);var t=[];for(var a in Object(e))hasOwnProperty$4.call(e,a)&&"constructor"!=a&&t.push(a);return t}function keys(e){return isArrayLike(e)?arrayLikeKeys(e):baseKeys(e)}var nativeCreate=getNative(Object,"create");const nativeCreate$1=nativeCreate;function hashClear(){this.__data__=nativeCreate$1?nativeCreate$1(null):{},this.size=0}function hashDelete(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var HASH_UNDEFINED$2="__lodash_hash_undefined__",objectProto$4=Object.prototype,hasOwnProperty$3=objectProto$4.hasOwnProperty;function hashGet(e){var t=this.__data__;if(nativeCreate$1){var a=t[e];return a===HASH_UNDEFINED$2?void 0:a}return hasOwnProperty$3.call(t,e)?t[e]:void 0}var objectProto$3=Object.prototype,hasOwnProperty$2=objectProto$3.hasOwnProperty;function hashHas(e){var t=this.__data__;return nativeCreate$1?void 0!==t[e]:hasOwnProperty$2.call(t,e)}var HASH_UNDEFINED$1="__lodash_hash_undefined__";function hashSet(e,t){var a=this.__data__;return this.size+=this.has(e)?0:1,a[e]=nativeCreate$1&&void 0===t?HASH_UNDEFINED$1:t,this}function Hash(e){var t=-1,a=null==e?0:e.length;for(this.clear();++t<a;){var r=e[t];this.set(r[0],r[1])}}function listCacheClear(){this.__data__=[],this.size=0}function assocIndexOf(e,t){for(var a=e.length;a--;)if(eq(e[a][0],t))return a;return-1}Hash.prototype.clear=hashClear,Hash.prototype.delete=hashDelete,Hash.prototype.get=hashGet,Hash.prototype.has=hashHas,Hash.prototype.set=hashSet;var arrayProto=Array.prototype,splice=arrayProto.splice;function listCacheDelete(e){var t=this.__data__,a=assocIndexOf(t,e);return!(a<0)&&(a==t.length-1?t.pop():splice.call(t,a,1),--this.size,!0)}function listCacheGet(e){var t=this.__data__,a=assocIndexOf(t,e);return a<0?void 0:t[a][1]}function listCacheHas(e){return assocIndexOf(this.__data__,e)>-1}function listCacheSet(e,t){var a=this.__data__,r=assocIndexOf(a,e);return r<0?(++this.size,a.push([e,t])):a[r][1]=t,this}function ListCache(e){var t=-1,a=null==e?0:e.length;for(this.clear();++t<a;){var r=e[t];this.set(r[0],r[1])}}ListCache.prototype.clear=listCacheClear,ListCache.prototype.delete=listCacheDelete,ListCache.prototype.get=listCacheGet,ListCache.prototype.has=listCacheHas,ListCache.prototype.set=listCacheSet;var Map$1=getNative(isArray.root,"Map");const Map$2=Map$1;function mapCacheClear(){this.size=0,this.__data__={hash:new Hash,map:new(Map$2||ListCache),string:new Hash}}function isKeyable(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}function getMapData(e,t){var a=e.__data__;return isKeyable(t)?a["string"==typeof t?"string":"hash"]:a.map}function mapCacheDelete(e){var t=getMapData(this,e).delete(e);return this.size-=t?1:0,t}function mapCacheGet(e){return getMapData(this,e).get(e)}function mapCacheHas(e){return getMapData(this,e).has(e)}function mapCacheSet(e,t){var a=getMapData(this,e),r=a.size;return a.set(e,t),this.size+=a.size==r?0:1,this}function MapCache(e){var t=-1,a=null==e?0:e.length;for(this.clear();++t<a;){var r=e[t];this.set(r[0],r[1])}}function arrayPush(e,t){for(var a=-1,r=t.length,o=e.length;++a<r;)e[o+a]=t[a];return e}function stackClear(){this.__data__=new ListCache,this.size=0}function stackDelete(e){var t=this.__data__,a=t.delete(e);return this.size=t.size,a}function stackGet(e){return this.__data__.get(e)}function stackHas(e){return this.__data__.has(e)}MapCache.prototype.clear=mapCacheClear,MapCache.prototype.delete=mapCacheDelete,MapCache.prototype.get=mapCacheGet,MapCache.prototype.has=mapCacheHas,MapCache.prototype.set=mapCacheSet;var LARGE_ARRAY_SIZE=200;function stackSet(e,t){var a=this.__data__;if(a instanceof ListCache){var r=a.__data__;if(!Map$2||r.length<LARGE_ARRAY_SIZE-1)return r.push([e,t]),this.size=++a.size,this;a=this.__data__=new MapCache(r)}return a.set(e,t),this.size=a.size,this}function Stack(e){var t=this.__data__=new ListCache(e);this.size=t.size}function arrayFilter(e,t){for(var a=-1,r=null==e?0:e.length,o=0,i=[];++a<r;){var s=e[a];t(s,a,e)&&(i[o++]=s)}return i}function stubArray(){return[]}Stack.prototype.clear=stackClear,Stack.prototype.delete=stackDelete,Stack.prototype.get=stackGet,Stack.prototype.has=stackHas,Stack.prototype.set=stackSet;var objectProto$2=Object.prototype,propertyIsEnumerable=objectProto$2.propertyIsEnumerable,nativeGetSymbols=Object.getOwnPropertySymbols,getSymbols=nativeGetSymbols?function(e){return null==e?[]:(e=Object(e),arrayFilter(nativeGetSymbols(e),(function(t){return propertyIsEnumerable.call(e,t)})))}:stubArray;const getSymbols$1=getSymbols;function baseGetAllKeys(e,t,a){var r=t(e);return isArray.isArray(e)?r:arrayPush(r,a(e))}function getAllKeys(e){return baseGetAllKeys(e,keys,getSymbols$1)}var DataView=getNative(isArray.root,"DataView");const DataView$1=DataView;var Promise$1=getNative(isArray.root,"Promise");const Promise$2=Promise$1;var Set$1=getNative(isArray.root,"Set");const Set$2=Set$1;var mapTag$1="[object Map]",objectTag$1="[object Object]",promiseTag="[object Promise]",setTag$1="[object Set]",weakMapTag="[object WeakMap]",dataViewTag$1="[object DataView]",dataViewCtorString=toSource(DataView$1),mapCtorString=toSource(Map$2),promiseCtorString=toSource(Promise$2),setCtorString=toSource(Set$2),weakMapCtorString=toSource(WeakMap$1),getTag=isArray.baseGetTag;(DataView$1&&getTag(new DataView$1(new ArrayBuffer(1)))!=dataViewTag$1||Map$2&&getTag(new Map$2)!=mapTag$1||Promise$2&&getTag(Promise$2.resolve())!=promiseTag||Set$2&&getTag(new Set$2)!=setTag$1||WeakMap$1&&getTag(new WeakMap$1)!=weakMapTag)&&(getTag=function(e){var t=isArray.baseGetTag(e),a=t==objectTag$1?e.constructor:void 0,r=a?toSource(a):"";if(r)switch(r){case dataViewCtorString:return dataViewTag$1;case mapCtorString:return mapTag$1;case promiseCtorString:return promiseTag;case setCtorString:return setTag$1;case weakMapCtorString:return weakMapTag}return t});const getTag$1=getTag;var Uint8Array=isArray.root.Uint8Array;const Uint8Array$1=Uint8Array;var HASH_UNDEFINED="__lodash_hash_undefined__";function setCacheAdd(e){return this.__data__.set(e,HASH_UNDEFINED),this}function setCacheHas(e){return this.__data__.has(e)}function SetCache(e){var t=-1,a=null==e?0:e.length;for(this.__data__=new MapCache;++t<a;)this.add(e[t])}function arraySome(e,t){for(var a=-1,r=null==e?0:e.length;++a<r;)if(t(e[a],a,e))return!0;return!1}function cacheHas(e,t){return e.has(t)}SetCache.prototype.add=SetCache.prototype.push=setCacheAdd,SetCache.prototype.has=setCacheHas;var COMPARE_PARTIAL_FLAG$3=1,COMPARE_UNORDERED_FLAG$1=2;function equalArrays(e,t,a,r,o,i){var s=a&COMPARE_PARTIAL_FLAG$3,n=e.length,l=t.length;if(n!=l&&!(s&&l>n))return!1;var c=i.get(e),d=i.get(t);if(c&&d)return c==t&&d==e;var h=-1,u=!0,b=a&COMPARE_UNORDERED_FLAG$1?new SetCache:void 0;for(i.set(e,t),i.set(t,e);++h<n;){var y=e[h],p=t[h];if(r)var g=s?r(p,y,h,t,e,i):r(y,p,h,e,t,i);if(void 0!==g){if(g)continue;u=!1;break}if(b){if(!arraySome(t,(function(e,t){if(!cacheHas(b,t)&&(y===e||o(y,e,a,r,i)))return b.push(t)}))){u=!1;break}}else if(y!==p&&!o(y,p,a,r,i)){u=!1;break}}return i.delete(e),i.delete(t),u}function mapToArray(e){var t=-1,a=Array(e.size);return e.forEach((function(e,r){a[++t]=[r,e]})),a}function setToArray(e){var t=-1,a=Array(e.size);return e.forEach((function(e){a[++t]=e})),a}var COMPARE_PARTIAL_FLAG$2=1,COMPARE_UNORDERED_FLAG=2,boolTag="[object Boolean]",dateTag="[object Date]",errorTag="[object Error]",mapTag="[object Map]",numberTag="[object Number]",regexpTag="[object RegExp]",setTag="[object Set]",stringTag="[object String]",symbolTag="[object Symbol]",arrayBufferTag="[object ArrayBuffer]",dataViewTag="[object DataView]",symbolProto=isArray.Symbol?isArray.Symbol.prototype:void 0,symbolValueOf=symbolProto?symbolProto.valueOf:void 0;function equalByTag(e,t,a,r,o,i,s){switch(a){case dataViewTag:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case arrayBufferTag:return!(e.byteLength!=t.byteLength||!i(new Uint8Array$1(e),new Uint8Array$1(t)));case boolTag:case dateTag:case numberTag:return eq(+e,+t);case errorTag:return e.name==t.name&&e.message==t.message;case regexpTag:case stringTag:return e==t+"";case mapTag:var n=mapToArray;case setTag:var l=r&COMPARE_PARTIAL_FLAG$2;if(n||(n=setToArray),e.size!=t.size&&!l)return!1;var c=s.get(e);if(c)return c==t;r|=COMPARE_UNORDERED_FLAG,s.set(e,t);var d=equalArrays(n(e),n(t),r,o,i,s);return s.delete(e),d;case symbolTag:if(symbolValueOf)return symbolValueOf.call(e)==symbolValueOf.call(t)}return!1}var COMPARE_PARTIAL_FLAG$1=1,objectProto$1=Object.prototype,hasOwnProperty$1=objectProto$1.hasOwnProperty;function equalObjects(e,t,a,r,o,i){var s=a&COMPARE_PARTIAL_FLAG$1,n=getAllKeys(e),l=n.length;if(l!=getAllKeys(t).length&&!s)return!1;for(var c=l;c--;){var d=n[c];if(!(s?d in t:hasOwnProperty$1.call(t,d)))return!1}var h=i.get(e),u=i.get(t);if(h&&u)return h==t&&u==e;var b=!0;i.set(e,t),i.set(t,e);for(var y=s;++c<l;){var p=e[d=n[c]],g=t[d];if(r)var v=s?r(g,p,d,t,e,i):r(p,g,d,e,t,i);if(!(void 0===v?p===g||o(p,g,a,r,i):v)){b=!1;break}y||(y="constructor"==d)}if(b&&!y){var _=e.constructor,f=t.constructor;_==f||!("constructor"in e)||!("constructor"in t)||"function"==typeof _&&_ instanceof _&&"function"==typeof f&&f instanceof f||(b=!1)}return i.delete(e),i.delete(t),b}var COMPARE_PARTIAL_FLAG=1,argsTag="[object Arguments]",arrayTag="[object Array]",objectTag="[object Object]",objectProto=Object.prototype,hasOwnProperty=objectProto.hasOwnProperty;function baseIsEqualDeep(e,t,a,r,o,i){var s=isArray.isArray(e),n=isArray.isArray(t),l=s?arrayTag:getTag$1(e),c=n?arrayTag:getTag$1(t),d=(l=l==argsTag?objectTag:l)==objectTag,h=(c=c==argsTag?objectTag:c)==objectTag,u=l==c;if(u&&isBuffer$1(e)){if(!isBuffer$1(t))return!1;s=!0,d=!1}if(u&&!d)return i||(i=new Stack),s||isTypedArray$1(e)?equalArrays(e,t,a,r,o,i):equalByTag(e,t,l,a,r,o,i);if(!(a&COMPARE_PARTIAL_FLAG)){var b=d&&hasOwnProperty.call(e,"__wrapped__"),y=h&&hasOwnProperty.call(t,"__wrapped__");if(b||y){var p=b?e.value():e,g=y?t.value():t;return i||(i=new Stack),o(p,g,a,r,i)}}return!!u&&(i||(i=new Stack),equalObjects(e,t,a,r,o,i))}function baseIsEqual(e,t,a,r,o){return e===t||(null==e||null==t||!isArray.isObjectLike(e)&&!isArray.isObjectLike(t)?e!=e&&t!=t:baseIsEqualDeep(e,t,a,r,baseIsEqual,o))}function isEqual(e,t){return baseIsEqual(e,t)}const HEADER_CELL_WIDTH_VALIDATOR=/^\d+(\.\d+)?([a-z]+|%)?$/,validateMinWidth=(e,t,a)=>{index.watchValidator(e,"_minWidth",(e=>"string"==typeof e&&HEADER_CELL_WIDTH_VALIDATOR.test(e)),new Set(["String","/^\\d+(\\.\\d+)?([a-z]+|%)?$/"]),t,a)},KolTableStateless=class{constructor(e){index$1.registerInstance(this,e),this.horizontal=!0,this.cellsToRenderTimeouts=new Map,this.dataToKeyMap=new Map,this.checkboxRefs=[],this.renderTableRow=(e,t,a,r=!1)=>{var o,i;let s=String(t);return this.horizontal&&(null===(o=e[0])||void 0===o?void 0:o.data)&&(s=null!==(i=this.getDataKey(e[0].data))&&void 0!==i?i:s),index$1.h("tr",{class:clsx.clsx("kol-table__row",{"kol-table__row--body":!r,"kol-table__row--footer":r}),key:`row-${s}`},this.renderSelectionCell(e,t),e.map(((e,r)=>this.renderTableCell(e,t,r,a))))},this.renderTableCell=(e,t,a,r)=>{const o=this.getColumnSettings(e);if(o&&!o.visible)return"";let i=`${t}-${a}-${e.label}`;if(e.data){const r=this.getDataKey(e.data);i=r?`${r}-${this.horizontal?a:t}`:i}return e.headerCell?this.renderHeadingCell(e,t,a,r):index$1.h("td",{key:`cell-${i}`,class:clsx.clsx("kol-table__cell kol-table__cell--body",{[`kol-table__cell--align-${e.textAlign}`]:e.textAlign}),colSpan:e.colSpan,rowSpan:e.rowSpan,style:{textAlign:e.textAlign,width:(null==o?void 0:o.width)?`${o.width}ch`:e.width},ref:"function"==typeof e.render?t=>{this.cellRender(e,t)}:void 0},"function"!=typeof e.render?e.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){tableSettings.validateTableData(this,e,{beforePatch:e=>{this.updateDataToKeyMap(e)}})}validateDataFoot(e){tableSettings.validateTableDataFoot(this,e)}validateHeaderCells(e){validateTableHeaderCells(this,e),isEqual(this.previousHeaderCells,this.state._headerCells)||this.initializeTableSettings(),this.previousHeaderCells=this.state._headerCells}validateLabel(e){label.validateLabel(this,e,{required:!0})}validateMinWidth(e){validateMinWidth(this,e)}validateOn(e){tableSettings.validateTableCallbacks(this,e)}validateSelection(e){tableSettings.validateTableSelection(this,e)}validateTableSettings(e){tableSettings.validateTableSettings(this,e)}handleKeyDown(e){var t;if("ArrowUp"===e.key||"ArrowDown"===e.key){const a=null===(t=this.tableDivElement)||void 0===t?void 0:t.querySelector(":focus");let r=this.checkboxRefs.indexOf(a);r>-1&&(e.preventDefault(),"ArrowDown"===e.key?(r=(r+1)%this.checkboxRefs.length,this.checkboxRefs[r].focus()):"ArrowUp"===e.key&&(e.preventDefault(),r=(r+this.checkboxRefs.length-1)%this.checkboxRefs.length,this.checkboxRefs[r].focus()))}}componentDidRender(){this.checkDivElementScrollbar()}componentDidLoad(){this.tableDivElement&&ResizeObserver&&(this.tableDivElementResizeObserver=new ResizeObserver(this.checkDivElementScrollbar.bind(this)),this.tableDivElementResizeObserver.observe(this.tableDivElement))}handleSettingsChange(e){index.setState(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,dev_utils.nonce())})),this.dataToKeyMap.forEach(((t,a)=>{e.includes(a)||this.dataToKeyMap.delete(a)}))}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 a=e.render(t,e,e.data,this.state._data);"string"==typeof a&&(t.textContent=a)}}))))}getNumberOfCols(e,t){let a=0;return e.forEach((e=>{let t=0;Array.isArray(e)&&e.forEach((e=>{var a;return t+=null!==(a=e.colSpan)&&void 0!==a?a:1})),a<t&&(a=t)})),0===a&&(a=t.length),a}getNumberOfRows(e,t){var a;let r=0;return e.forEach((e=>{let t=0;Array.isArray(e)&&e.forEach((e=>{var a;return t+=null!==(a=e.rowSpan)&&void 0!==a?a:1})),r<t&&(r=t)})),0===r?r=t.length:r-=(null===(a=this.state._dataFoot)||void 0===a?void 0:a.length)||0,r}getThePrimaryHeadersWithKeysIfExists(e){const t=[];return e.forEach((e=>{e.forEach((e=>{"string"==typeof e.key&&t.push(e)}))})),t}getPrimaryHeaders(e){var t,a;let r=this.getThePrimaryHeadersWithKeysIfExists(null!==(t=e.horizontal)&&void 0!==t?t:[]);return this.horizontal=!0,0===r.length&&(r=this.getThePrimaryHeadersWithKeysIfExists(null!==(a=e.vertical)&&void 0!==a?a:[]),r.length>0&&(this.horizontal=!1)),r}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,a)=>{var r,o,i,s;return(null!==(o=t.get(null!==(r=e.key)&&void 0!==r?r:""))&&void 0!==o?o:Number.MAX_SAFE_INTEGER)-(null!==(s=t.get(null!==(i=a.key)&&void 0!==i?i:""))&&void 0!==s?s:Number.MAX_SAFE_INTEGER)}))}createDataField(e,t,a){var r;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 o=this.getPrimaryHeaders(t),i=this.getNumberOfCols(t.horizontal,e);let s=this.getNumberOfRows(t.vertical,e),n=0;a&&(n=s,s+=(null===(r=this.state._dataFoot)||void 0===r?void 0:r.length)||0);const l=[],c=[],d=[];t.vertical.forEach(((e,t)=>{c[t]=0,d[t]=[]}));const h=this.sortByColumnPosition(o);for(let r=n;r<s;r++){const o=[];t.vertical.forEach(((e,t)=>{let a=0;if(d[t].forEach((e=>a+=e)),a<=r){const i=e[r-a+c[t]];if("object"==typeof i){o.push(Object.assign(Object.assign({},i),{headerCell:!0,data:{}}));let e=1;if("number"==typeof i.rowSpan&&i.rowSpan>1&&(e=i.rowSpan),d[t].push(e),"number"==typeof i.colSpan&&i.colSpan>1)for(let a=1;a<i.colSpan;a++)d[t+a].push(e);c[t]++}}}));for(let t=0;t<i;t++)if(!0===this.horizontal){const i=a&&this.state._dataFoot?this.state._dataFoot[r-n]:e[r];"object"==typeof h[t]&&null!==h[t]&&"string"==typeof h[t].key&&"object"==typeof i&&null!==i&&o.push(Object.assign(Object.assign({},h[t]),{colSpan:void 0,data:i,label:i[h[t].key],rowSpan:void 0}))}else"object"==typeof h[r]&&null!==h[r]&&"string"==typeof h[r].key&&"object"==typeof e[t]&&null!==e[t]&&o.push(Object.assign(Object.assign({},h[r]),{colSpan:void 0,data:e[t],label:e[t][h[r].key],rowSpan:void 0}));l.push(o)}if(0===e.length){let e=0,a=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=>{a+=e.rowSpan||1})));const r={colSpan:e,label:i18n.translate("kol-no-entries"),render:void 0,rowSpan:Math.max(a,1)};0===l.length?l.push([r]):l[0].push(r)}return l}handleSelectionChangeCallbackAndEvent(e,t){var a;"function"==typeof(null===(a=this.state._on)||void 0===a?void 0:a[keyboard.Callback.onSelectionChange])&&this.state._on[keyboard.Callback.onSelectionChange](e,t),this.host&&events.dispatchDomEvent(this.host,events.KolEvent.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 a;return{key:null!==(a=e.key)&&void 0!==a?a:dev_utils.nonce(),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(e,t){var a,r,o;const i=this.state._selection;if(!i)return"";const s=this.getSelectionKeyPropertyName(),n=null===(a=e[0])||void 0===a?void 0:a.data;if(!n)return"";const l=n[s],c=i.multiple||void 0===i.multiple,d=null===(r=null==i?void 0:i.selectedKeys)||void 0===r?void 0:r.includes(l),h=null===(o=null==i?void 0:i.disabledKeys)||void 0===o?void 0:o.includes(l),u=i.label(n),b={name:"selection",checked:d,disabled:h,id:l,"aria-label":u};return index$1.h("td",{key:`tbody-${t}-selection`,class:"kol-table__cell kol-table__cell--selection"},index$1.h("div",{class:clsx.clsx("kol-table__selection",{"kol-table__selection--checked":d})},c?index$1.h("label",{class:clsx.clsx("kol-table__selection-label",{"kol-table__selection-label--disabled":h})},index$1.h(componentNames.KolIconTag,{class:"kol-table__selection-icon",_icons:"codicon "+(d?"codicon-check":""),_label:""}),index$1.h("input",Object.assign({class:clsx.clsx("kol-table__selection-input kol-table__selection-input--checkbox"),ref:e=>e&&this.checkboxRefs.push(e)},b,{type:"checkbox",onInput:e=>{var t,a;const r=d?null===(a=null==i?void 0:i.selectedKeys)||void 0===a?void 0:a.filter((e=>e!==l)):[...null!==(t=null==i?void 0:i.selectedKeys)&&void 0!==t?t:[],l];this.handleSelectionChangeCallbackAndEvent(e,null!=r?r:[])}}))):index$1.h("label",{class:"kol-table__selection-label"},index$1.h("input",Object.assign({class:clsx.clsx("kol-table__selection-input kol-table__selection-input--radio")},b,{type:"radio",onInput:e=>{this.handleSelectionChangeCallbackAndEvent(e,l)}}))),index$1.h(componentNames.KolTooltipWcTag,{"aria-hidden":"true",class:"kol-table__selection-input-tooltip",_align:"right",_id:`${l}-label`,_label:u})))}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 a,r;return!(null===(r=null===(a=this.state._selection)||void 0===a?void 0:a.disabledKeys)||void 0===r?void 0:r.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,a;return!(null===(a=null===(t=this.state._selection)||void 0===t?void 0:t.disabledKeys)||void 0===a?void 0:a.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,a;return null===(a=null===(t=this.state._selection)||void 0===t?void 0:t.disabledKeys)||void 0===a?void 0:a.includes(e)}))}getRevertedSelection(e){var t;const a=this.getSelectionKeyPropertyName(),r=null!==(t=this.getSelectedKeysWithDisabledKeysOnly())&&void 0!==t?t:[];return e&&r.push(...this.getDataWithSelectionEnabled().map((e=>null==e?void 0:e[a]))),r}getTableMinWidth(){var e,t;const a=null!==(t=null===(e=this.state._tableSettings)||void 0===e?void 0:e.columns.filter((e=>e.visible)).reduce(((e,t)=>{var a;return e+(null!==(a=t.width)&&void 0!==a?a:0)}),0))&&void 0!==t?t:0;return"auto"===this.state._minWidth?`${a}ch`:`max(${this.state._minWidth}, ${a}ch)`}renderHeadingSelectionCell(){var e,t;const a=this.state._selection;if(!a||!a.multiple&&void 0!==a.multiple)return index$1.h("th",{class:"kol-table__cell kol-table__cell--header",key:"thead-0"});const r=null!==(t=null===(e=this.getSelectedKeysWithoutDisabledKeys())||void 0===e?void 0:e.length)&&void 0!==t?t:0,o=r===this.getDataWithSelectionEnabled().length,i=0!==r&&!o;let s="kol-table-selection-indeterminate";o&&!i&&(s="kol-table-selection-none"),0===r&&(s="kol-table-selection-all");const n=i18n.translate(s);return index$1.h("th",{key:"thead-0-selection",class:"kol-table__cell kol-table__cell--header"},index$1.h("div",{class:clsx.clsx("kol-table__selection",{"kol-table__selection--indeterminate":i,"kol-table__selection--checked":o})},index$1.h("label",{class:"kol-table__selection-label"},index$1.h(componentNames.KolIconTag,{class:"kol-table__selection-icon",_icons:"codicon "+(i?"codicon-remove":o?"codicon-check":""),_label:""}),index$1.h("input",{class:clsx.clsx("kol-table__selection-input kol-table__selection-input--checkbox"),"data-testid":"selection-checkbox-all",ref:e=>e&&this.checkboxRefs.push(e),name:"selection",checked:o&&!i,indeterminate:i,"aria-label":n,type:"checkbox",onInput:e=>{this.handleSelectionChangeCallbackAndEvent(e,this.getRevertedSelection(!o))}})),index$1.h(componentNames.KolTooltipWcTag,{"aria-hidden":"true",class:"kol-table__selection-input-tooltip",_align:"right",_id:`${s}-label`,_label:n})))}renderHeaderTdCell(){return index$1.h(index$1.Fragment,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)&&index$1.h("td",{"aria-hidden":"true",colSpan:this.state._headerCells.vertical.length,rowSpan:this.state._headerCells.horizontal.length}))}renderHeadingCell(e,t,a,r){const o=this.getColumnSettings(e);if(o&&!o.visible)return"";let i,s="codicon codicon-fold";if(e.sortDirection)switch(e.sortDirection){case"ASC":s="codicon codicon-chevron-up",i="ascending";break;case"DESC":s="codicon codicon-chevron-down",i="descending"}const n=r?"row":"number"==typeof e.colSpan&&e.colSpan>1?"colgroup":"col";return index$1.h("th",{key:`${t}-${a}-${e.label}`,class:clsx.clsx("kol-table__cell kol-table__cell--header",{[`kol-table__cell--align-${e.textAlign}`]:e.textAlign,[`kol-table__cell--${i}`]:i}),scope:n,colSpan:e.colSpan,rowSpan:e.rowSpan,style:{width:(null==o?void 0:o.width)?`${o.width}ch`:e.width},"aria-sort":i,"data-sort":`sort-${e.sortDirection}`},e.sortDirection?index$1.h(componentNames.KolButtonWcTag,{class:"kol-table__sort-button",exportparts:"icon",_icons:{right:s},_label:e.label,_on:{onClick:t=>{var a;"function"==typeof(null===(a=this.state._on)||void 0===a?void 0:a.onSort)&&e.key&&e.sortDirection&&this.state._on.onSort(t,{key:e.key,currentSortDirection:e.sortDirection}),this.host&&events.dispatchDomEvent(this.host,events.KolEvent.sort,{key:e.key,currentSortDirection:e.sortDirection})}}}):e.label)}renderSpacer(e,t){var a,r;const o=(null===(a=this.state._headerCells.vertical)||void 0===a?void 0:a.length)||0,i=null===(r=null==t?void 0:t[0])||void 0===r?void 0:r.reduce(((e,t)=>e+(t.colSpan||1)),0),s=this.state._selection?1:0;return index$1.h("tr",{"aria-hidden":"true",class:clsx.clsx("kol-table__spacer",`kol-table__spacer--${e}`)},index$1.h("td",{class:clsx.clsx(`kol-table__spacer-line kol-table__spacer-line--${e}`),colSpan:o+i+s}))}renderFoot(){if(!this.state._dataFoot||0===this.state._dataFoot.length)return null;const e=this.createDataField(this.state._dataFoot,this.state._headerCells,!0);return index$1.h("tfoot",{class:"kol-table__footer"},[this.renderSpacer("foot",e),e.map(((e,t)=>this.renderTableRow(e,t,!0,!0)))])}render(){var e;const t=this.createDataField(this.state._data,this.state._headerCells);this.checkboxRefs=[];const a=null===(e=this.state._headerCells.horizontal)||void 0===e?void 0:e.map((e=>this.sortByColumnPosition(e)));return index$1.h("div",{key:"41ef1f9232f94305a6492420a311cf543b582a22",class:"kol-table"},index$1.h(componentNames.KolTableSettingsWcTag,{key:"3e0def33d6cf806d72c305d0e350b7ee4b2d3899",_tableSettings:this.state._tableSettings}),index$1.h("div",{key:"cc55a031f7bae8733cc5877763b68f9b1717b3e2",ref:e=>this.tableDivElement=e,class:"kol-table__scroll-container",tabindex:this.tableDivElementHasScrollbar?"-1":void 0},index$1.h("table",{key:"c96b4770ff54fb28a6d6eea1a9f021132e04652c",class:"kol-table__table",style:{minWidth:this.getTableMinWidth()}},index$1.h("div",{key:"96095fade8aa2347d2db8e4a42a735e07a683f05",class:"kol-table__focus-element",tabindex:this.tableDivElementHasScrollbar?"0":void 0,"aria-describedby":"caption"}," "),index$1.h("caption",{key:"fbf77baecd9f1f569c97df6596e598926f4fc420",class:"kol-table__caption",id:"caption"},this.state._label),Array.isArray(a)&&index$1.h("thead",{key:"aeab10b5b582c3134e5e0e7a483fbd441e00edc1",class:"kol-table__head"},[a.map(((e,t)=>index$1.h("tr",{class:"kol-table__head-row",key:`thead-${t}`},this.state._selection&&this.renderHeadingSelectionCell(),0===t&&this.renderHeaderTdCell(),Array.isArray(e)&&e.map(((e,a)=>this.renderHeadingCell(e,t,a,!1)))))),this.renderSpacer("head",a)]),index$1.h("tbody",{key:"536ad9c3574792ce18cf2694a4251cd781587aea",class:"kol-table__body"},t.map(((e,t)=>this.renderTableRow(e,t,!0)))),this.renderFoot())))}get host(){return index$1.getElement(this)}static get watchers(){return{_data:["validateData"],_dataFoot:["validateDataFoot"],_headerCells:["validateHeaderCells"],_label:["validateLabel"],_minWidth:["validateMinWidth"],_on:["validateOn"],_selection:["validateSelection"],_tableSettings:["validateTableSettings"]}}};exports.kol_table_stateless_wc=KolTableStateless;