active-table
Version:
Framework agnostic table component for editable data experience
1 lines • 362 kB
JavaScript
class GenericElementUtils{static hideElements(...t){t.forEach((t=>t.style.display="none"))}static getStyleWidth(t,e){return Number.parseFloat(t.style[e])||0}static doesElementExistInDom(t){return!!t.parentElement}static isFirstChildInParent(t){var e;return(null==(e=t.parentElement)?void 0:e.firstChild)===t}}GenericElementUtils.NOT_SELECTABLE_CLASS="not-selectable";class SVGIconUtils{static createSVGElement(t){return(new DOMParser).parseFromString(t,"image/svg+xml").documentElement}}SVGIconUtils.WHITE_FILTER="brightness(0) saturate(100%) invert(100%) sepia(1%) saturate(3877%)\n hue-rotate(184deg) brightness(103%) contrast(100%)",SVGIconUtils.LIGHT_GREY_FILTER="brightness(0) saturate(100%) invert(68%) sepia(0%) saturate(317%)\n hue-rotate(84deg) brightness(92%) contrast(93%)",SVGIconUtils.HEADER_FILTER="brightness(0) saturate(100%) invert(34%) sepia(0%) saturate(1075%)\n hue-rotate(211deg) brightness(96%) contrast(90%)",SVGIconUtils.DROPDOWN_ITEM_FILTER="brightness(0) saturate(100%) invert(7%) sepia(23%) saturate(258%)\n hue-rotate(63deg) brightness(99%) contrast(97%)";class StaticDropdown{}StaticDropdown.DROPDOWN_CLASS="static-dropdown",StaticDropdown.ITEM_CLASS="static-dropdown-item",StaticDropdown.ACTIVE_ITEM_CLASS="active-static-dropdown-item";const _DropdownItemHighlightUtils=class t{static fadeCurrentlyHighlighted(t){const e=t.dropdownItem;e&&(e.classList.contains(StaticDropdown.ACTIVE_ITEM_CLASS)&&e.classList.remove(StaticDropdown.ACTIVE_ITEM_CLASS),e.style.backgroundColor="",delete t.dropdownItem)}static highlightNew(e,n){t.fadeCurrentlyHighlighted(e),n.focus(),e.dropdownItem=n,n.classList.contains(StaticDropdown.ITEM_CLASS)?n.classList.add(StaticDropdown.ACTIVE_ITEM_CLASS):n.classList.contains(DropdownItem.DROPDOWN_INPUT_CLASS)||(n.style.backgroundColor=t.HOVER_BACKGROUND_COLOR)}};_DropdownItemHighlightUtils.HOVER_BACKGROUND_COLOR="#eaeaea";let DropdownItemHighlightUtils=_DropdownItemHighlightUtils;class DropdownItemEvents{static addItemEvents(t,e){e.addEventListener("mouseenter",DropdownItemHighlightUtils.highlightNew.bind(this,t,e)),e.addEventListener("mouseleave",DropdownItemHighlightUtils.fadeCurrentlyHighlighted.bind(this,t))}}const _DropdownItem=class t{static toggleItem(e,n){e.style.display=n?t.DISPLAY:t.HIDDEN}static isDisplayed(e){return e.style.display===t.DISPLAY}static createDropdownItemBaseElement(e){const n=document.createElement(e);return n.classList.add(t.DROPDOWN_ITEM_IDENTIFIER),n}static createItem(e){const n=t.createDropdownItemBaseElement("div");return e&&(n.tabIndex=e.children.length),n.classList.add(t.DROPDOWN_ITEM_CLASS,GenericElementUtils.NOT_SELECTABLE_CLASS),n}static addInputItem(e,n){const o=t.createItem(n);o.classList.add(t.DROPDOWN_INPUT_ITEM_CLASS);const s=t.createDropdownItemBaseElement("input");s.classList.add(t.DROPDOWN_INPUT_CLASS),o.appendChild(s),n.appendChild(o),DropdownItemEvents.addItemEvents(e._activeOverlayElements,s)}static insertIcon(e,n){const{svgString:o,containerStyles:s}=n,l=document.createElement("div");l.classList.add(t.DROPDOWN_ITEM_ICON_CONTAINER_CLASS),Object.assign(l.style,null==s?void 0:s.dropdown);const i=SVGIconUtils.createSVGElement(o);i.style.filter=SVGIconUtils.DROPDOWN_ITEM_FILTER,l.appendChild(i),e.insertBefore(l,e.children[0])}static addPlaneButtonItem(e,n,o){const s=t.createItem(e),l=t.createDropdownItemBaseElement("div");return l.innerText=n||t.DROPDOWN_ITEM_EMPTY_PLACEHOLDER_TEXT,""===n.trim()&&l.classList.add(t.DROPDOWN_ITEM_EMPTY_CLASS),s.append(l),e&&(void 0!==o&&e.children[o]?e.insertBefore(s,e.children[o]):e.appendChild(s)),s}static createButtonItemNoEvents(e,n,...o){const s=t.addPlaneButtonItem(e,n.text);return n.iconSettings&&t.insertIcon(s,n.iconSettings),o.length>0&&s.classList.add(...o),s}static addTitle(e,n){const o=t.createDropdownItemBaseElement("div");o.classList.add(t.DROPDOWN_ITEM_CLASS,t.DROPDOWN_TITLE_ITEM_CLASS),o.innerText=n,e.appendChild(o)}static addDivider(e){const n=t.createDropdownItemBaseElement("div");n.classList.add(t.DROPDOWN_ITEM_DIVIDER_CLASS),e.appendChild(n)}static addButtonItem(e,n,o,...s){const l=t.createButtonItemNoEvents(n,o,...s);return DropdownItemEvents.addItemEvents(e._activeOverlayElements,l),l}static addNewButtonItems(e,n,o){return o.map((o=>t.addButtonItem(e,n,o)))}static addButtonItemElements(t,e,n){n.forEach((n=>{n.tabIndex=e.children.length,e.appendChild(n),DropdownItemEvents.addItemEvents(t._activeOverlayElements,n)}))}static removeItems(t){Array.from(t.children).forEach((t=>t.remove()))}static doesElementContainItemClass(e){return e.classList.contains(t.DROPDOWN_ITEM_IDENTIFIER)}static doesElementContainInputClass(e){return e.classList.contains(t.DROPDOWN_INPUT_CLASS)}static getInputElement(e){return e.getElementsByClassName(t.DROPDOWN_INPUT_ITEM_CLASS)[0]}static toggleUsability(e,n){const o=e.children[0];n?(e.classList.remove(t.DISABLED_ITEM_CLASS),o.style.filter=""):(e.classList.add(t.DISABLED_ITEM_CLASS),o.style.filter=SVGIconUtils.LIGHT_GREY_FILTER)}};_DropdownItem.DROPDOWN_ITEM_CLASS="dropdown-item",_DropdownItem.DISABLED_ITEM_CLASS="dropdown-disabled-item",_DropdownItem.ACTIVE_ITEM_CLASS="active-dropdown-item",_DropdownItem.DROPDOWN_INPUT_CLASS="dropdown-input",_DropdownItem.DROPDOWN_ITEM_ICON_CONTAINER_CLASS="dropdown-item-icon-container",_DropdownItem.DROPDOWN_INPUT_ITEM_CLASS="dropdown-input-item",_DropdownItem.DROPDOWN_TITLE_ITEM_CLASS="dropdown-title-item",_DropdownItem.DROPDOWN_ITEM_DIVIDER_CLASS="dropdown-item-divider",_DropdownItem.DROPDOWN_ITEM_EMPTY_CLASS="dropdown-item-empty",_DropdownItem.DROPDOWN_ITEM_EMPTY_PLACEHOLDER_TEXT="...",_DropdownItem.DROPDOWN_ITEM_IDENTIFIER="dropdown-item-identifier",_DropdownItem.HIDDEN="none",_DropdownItem.DISPLAY="";let DropdownItem=_DropdownItem;class OuterDropdownItem{static unsetHoverColors(t){t.forEach((t=>t.style.backgroundColor=""))}static unsetActiveItem(t){const e=t.getElementsByClassName(DropdownItem.ACTIVE_ITEM_CLASS)[0];null==e||e.classList.remove(DropdownItem.ACTIVE_ITEM_CLASS)}static setActive(t,e){const n=t.find((t=>t.innerText===e));null==n||n.classList.add(DropdownItem.ACTIVE_ITEM_CLASS)}static setActiveByIndex(t,e){t[e].classList.add(DropdownItem.ACTIVE_ITEM_CLASS)}}class ElementStyle{static setStyle(t,e,n){t.style[e]=n}static moveStyles(t,e,...n){n.forEach((n=>{t.style[n]&&ElementStyle.setStyle(e,n,t.style[n])}))}static unsetStyle(t,e){const n=Object.keys(e).reduce(((t,e)=>(t[e]="",t)),{});Object.assign(t.style,n)}static unsetAllCSSStates(t,e){e.click&&ElementStyle.unsetStyle(t,e.click),e.hover&&ElementStyle.unsetStyle(t,e.hover),e.default&&ElementStyle.unsetStyle(t,e.default)}static generateStatefulCSS(t,e,n){const o=t.default||{},s=Object.assign(JSON.parse(JSON.stringify({...o,...e})),null==t?void 0:t.hover);return{default:o,hover:s,click:Object.assign(JSON.parse(JSON.stringify({...s,...n})),null==t?void 0:t.click)}}}const _ToggleableElement=class t{static set(e,n){e.classList.add(t.ACTIVE_BUTTON_CLASS),Object.assign(e.style,n)}static unset(e,n){e.classList.remove(t.ACTIVE_BUTTON_CLASS),ElementStyle.unsetStyle(e,n)}static toggleActive(e,n){const o=!!e.classList.contains(t.ACTIVE_BUTTON_CLASS);return o?(t.unset(e,n),e.dispatchEvent(new MouseEvent("mouseenter"))):t.set(e,n),o}static unsetActive(e,n){e.classList.contains(t.ACTIVE_BUTTON_CLASS)&&(t.unset(e,n),e.dispatchEvent(new MouseEvent("mouseleave")))}static setActive(e,n){e.classList.contains(t.ACTIVE_BUTTON_CLASS)||t.set(e,n)}};_ToggleableElement.ACTIVE_BUTTON_CLASS="toggleable-button-active",_ToggleableElement.AUTO_STYLING_CLASS="toggleable-button-auto-styling";let ToggleableElement=_ToggleableElement;const _Dropdown=class t{static createBase(){const e=document.createElement("div");return e.classList.add(t.DROPDOWN_CLASS),e.style.width=`${t.DROPDOWN_WIDTH}px`,e.style.paddingTop=t.DROPDOWN_VERTICAL_PX,e.style.paddingBottom=t.DROPDOWN_VERTICAL_PX,t.hide(e),e}static isDisplayed(e){return(null==e?void 0:e.style.display)===t.CSS_DISPLAY_VISIBLE}static display(...e){e.forEach((e=>{e.style.display=t.CSS_DISPLAY_VISIBLE}))}static hide(...t){GenericElementUtils.hideElements(...t)}static isPartOfDropdownElement(e){return e.classList.contains(t.DROPDOWN_CLASS)||DropdownItem.doesElementContainItemClass(e)}};_Dropdown.DROPDOWN_CLASS="active-table-dropdown",_Dropdown.CSS_DISPLAY_VISIBLE="grid",_Dropdown.DROPDOWN_WIDTH=176,_Dropdown.DROPDOWN_VERTICAL_PX="4px";let Dropdown=_Dropdown;const _OuterDropdownButtonEvents=class t{static mouseClickButton(e,n,o){const{element:s}=n;s.classList.contains(t.DO_NOT_DISPLAY_DROPDOWN_CLASS)?s.classList.remove(t.DO_NOT_DISPLAY_DROPDOWN_CLASS):o(e,n)}static mouseDownButton(e){const{element:n,button:o,activeButtonStyle:s}=e;Dropdown.isDisplayed(n)&&(n.classList.add(t.DO_NOT_DISPLAY_DROPDOWN_CLASS),ToggleableElement.unsetActive(o,s))}static getDisplayFunc(t){return t.startsWith("top")?OuterDropdownElement.display:OuterDropdownElement.displayReactToBottomVisibility}static set(e,n,o,s,l){const i=l||t.getDisplayFunc(o);n.addEventListener("mousedown",t.mouseDownButton.bind(this,s)),n.addEventListener("click",t.mouseClickButton.bind(this,e,s,i))}};_OuterDropdownButtonEvents.DO_NOT_DISPLAY_DROPDOWN_CLASS="do-not-display-class";let OuterDropdownButtonEvents=_OuterDropdownButtonEvents;const VH="vh",VW="vw";class LITElementTypeConverters{static convertToBoolean(t){return"string"==typeof t?"true"===t:!!t}static convertToFunction(value){if("function"==typeof value)return value;if("string"==typeof value){const evaluatedExpression=eval(value);if("function"==typeof evaluatedExpression)return evaluatedExpression}return()=>{}}}class ObjectUtils{static createTwoWayObject(t){return Object.keys(t).forEach((e=>{t[t[e]]=e})),t}static convertStringToFunction(t,e){"string"==typeof t[e]&&(t[e]=LITElementTypeConverters.convertToFunction(t[e]))}static areValuesFullyDefined(...t){return-1===t.findIndex((t=>null==t))}static removeProperties(t,...e){e.forEach((e=>{delete t[e]}))}}class RegexUtils{static extractIntegerStrs(t){return t.match(/\d+/g)}static extractFloatStrs(t){return t.match(/-?\d+(\.\d+)?$/g)}}class StringDimensionUtils{static processDimension(t,e){return t<e?e:t}static processPercentageDimension(t,e,n,o){e>100&&(e=100);const s=(n?t.getBoundingClientRect().width:t.offsetHeight)*(e/100);return{number:StringDimensionUtils.processDimension(s,o),isPercentage:!0}}static generateNumberDimensionFromClientString(t,e,n,o,s=0){const l=e[n],i="string"==typeof l;let r=i?Number(RegexUtils.extractIntegerStrs(l)[0]):l;if(i){if(l.includes("%"))return StringDimensionUtils.processPercentageDimension(t,r,o,s);l.includes(VH)?r=window.innerHeight*(r/100):l.includes(VW)&&(r=window.innerWidth*(r/100))}return{number:StringDimensionUtils.processDimension(r,s),isPercentage:!1}}static removeAllDimensions(t){if(t)return ObjectUtils.removeProperties(t,"width","minWidth","maxWidth","height","minHeight","maxHeight"),t}}class PageButtonStyle{static unsetAllCSSStates(t,e,n){ElementStyle.unsetAllCSSStates(t,e[n])}static unsetAll(t,e,n){t.classList.contains(e.activeButtonClass)?PageButtonStyle.unsetAllCSSStates(t,e,"activeButton"):t.classList.contains(PageButtonElement.DISABLED_PAGINATION_BUTTON_CLASS)?ElementStyle.unsetStyle(t,e.disabledButtons):PageButtonStyle.unsetAllCSSStates(t,e,n?"actionButtons":"buttons")}static setDefault(t,e,n){PageButtonStyle.unsetAll(t,e,n),n?Object.assign(t.style,e.actionButtons.default):Object.assign(t.style,e.buttons.default)}static setActive(t,e,n){n&&(PageButtonStyle.unsetAllCSSStates(n,e,"activeButton"),Object.assign(n.style,e.buttons.default)),t.classList.contains(PageButtonElement.DISABLED_PAGINATION_BUTTON_CLASS)?ElementStyle.unsetStyle(t,e.disabledButtons):PageButtonStyle.unsetAllCSSStates(t,e,"buttons"),Object.assign(t.style,e.activeButton.default)}static setDisabled(t,e,n){PageButtonStyle.setDefault(t,e,n),Object.assign(t.style,e.disabledButtons)}static mouseDown(t,e,n){t.classList.contains(e.activeButtonClass)?Object.assign(t.style,e.activeButton.click):n?Object.assign(t.style,e.actionButtons.click):Object.assign(t.style,e.buttons.click),PaginationVisibleButtonsUtils.overrideOnMouseEvent(t,e)}static mouseEnter(t,e,n){t.classList.contains(PageButtonElement.DISABLED_PAGINATION_BUTTON_CLASS)||(t.classList.contains(e.activeButtonClass)?(PageButtonStyle.unsetAllCSSStates(t,e,"activeButton"),Object.assign(t.style,e.activeButton.default),Object.assign(t.style,e.activeButton.hover)):(PageButtonStyle.setDefault(t,e,n),n?Object.assign(t.style,e.actionButtons.hover):Object.assign(t.style,e.buttons.hover)),PaginationVisibleButtonsUtils.overrideOnMouseEvent(t,e))}static mouseLeave(t,e,n){t.classList.contains(PageButtonElement.DISABLED_PAGINATION_BUTTON_CLASS)||(t.classList.contains(e.activeButtonClass)?(PageButtonStyle.unsetAll(t,e,!1),Object.assign(t.style,e.activeButton.default)):PageButtonStyle.setDefault(t,e,n),PaginationVisibleButtonsUtils.overrideOnMouseEvent(t,e))}}const _FilterInputElement=class t{static setPlaceholder(e,n,o){if(n&&""!==n){const s=o||t.DEFAULT_PLACEHOLDER_TEMPLATE;e.placeholder=s.replace(t.TEMPLATE_VARIABLE,n)}else e.placeholder=t.DEFAULT_PLACEHOLDER}static createElement(e,n,o){const s=document.createElement("input");s.classList.add(t.INPUT_CLASS);const l=(null==o?void 0:o.placeholderColor)||"#656565";return s.style.setProperty("--active-table-filter-placeholder-color",l),Object.assign(s.style,null==o?void 0:o.input),t.setPlaceholder(s,e,n),s}static create(e,n,o){const s=FilterInternalUtils.generateDefaultHeaderName(o,e.defaultColumnHeaderName),l=t.createElement(s,e.placeholderTemplate,n.styles);return e.inputElement=l,l}};_FilterInputElement.INPUT_CLASS="filter-rows-input",_FilterInputElement.TEMPLATE_VARIABLE="{headerName}",_FilterInputElement.DEFAULT_PLACEHOLDER="Filter",_FilterInputElement.DEFAULT_PLACEHOLDER_TEMPLATE=`Filter ${_FilterInputElement.TEMPLATE_VARIABLE}...`;let FilterInputElement=_FilterInputElement;class FilterInputEvents{static unsetEvents(t){t&&t.forEach((t=>t.inputElement.oninput=()=>{}))}static updateSameInputValues(t,e){t.forEach((t=>{t.elements===e.elements&&(t.inputElement.value=e.inputElement.value)}))}static getFilterData(t){return t.map((t=>({filterText:t.isCaseSensitive?t.inputElement.value:t.inputElement.value.toLocaleLowerCase(),colCells:t.elements.slice(1),isCaseSensitive:t.isCaseSensitive})))}static splitChunksAndExecute(t,e){const n=t.filter((t=>""!==t.filterText));0===n.length&&n.push(t[0]);const o=Math.ceil(n[0].colCells.length/FilterInternalUtils.CHUNK_SIZE);for(let t=0;t<o;t+=1){const o=t*FilterInternalUtils.CHUNK_SIZE;e(n.map((t=>({...t,chunk:t.colCells.slice(o,o+FilterInternalUtils.CHUNK_SIZE)}))))}}static setEvents(t,e,n){if(!e.elements)return;const o=FilterInternalUtils.getFilterFunc(t),s=n.filter((t=>t!==e));e.inputElement.oninput=()=>{FilterInputEvents.updateSameInputValues(s,e),FilterInputEvents.splitChunksAndExecute(FilterInputEvents.getFilterData(n),o)}}}const ARROW_DOWN_SVG_STRING='<?xml version="1.0" encoding="UTF-8"?>\n<svg viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">\n\t<g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">\n\t\t<g transform="translate(-288.000000, 0.000000)">\n\t\t\t<g transform="translate(288.000000, 0.000000)">\n\t\t\t\t<path d="M24,0 L24,24 L0,24 L0,0 L24,0 Z M12.5934901,23.257841 L12.5819402,23.2595131 L12.5108777,23.2950439 L12.4918791,23.2987469 L12.4918791,23.2987469 L12.4767152,23.2950439 L12.4056548,23.2595131 C12.3958229,23.2563662 12.3870493,23.2590235 12.3821421,23.2649074 L12.3780323,23.275831 L12.360941,23.7031097 L12.3658947,23.7234994 L12.3769048,23.7357139 L12.4804777,23.8096931 L12.4953491,23.8136134 L12.4953491,23.8136134 L12.5071152,23.8096931 L12.6106902,23.7357139 L12.6232938,23.7196733 L12.6232938,23.7196733 L12.6266527,23.7031097 L12.609561,23.275831 C12.6075724,23.2657013 12.6010112,23.2592993 12.5934901,23.257841 L12.5934901,23.257841 Z M12.8583906,23.1452862 L12.8445485,23.1473072 L12.6598443,23.2396597 L12.6498822,23.2499052 L12.6498822,23.2499052 L12.6471943,23.2611114 L12.6650943,23.6906389 L12.6699349,23.7034178 L12.6699349,23.7034178 L12.678386,23.7104931 L12.8793402,23.8032389 C12.8914285,23.8068999 12.9022333,23.8029875 12.9078286,23.7952264 L12.9118235,23.7811639 L12.8776777,23.1665331 C12.8752882,23.1545897 12.8674102,23.1470016 12.8583906,23.1452862 L12.8583906,23.1452862 Z M12.1430473,23.1473072 C12.1332178,23.1423925 12.1221763,23.1452606 12.1156365,23.1525954 L12.1099173,23.1665331 L12.0757714,23.7811639 C12.0751323,23.7926639 12.0828099,23.8018602 12.0926481,23.8045676 L12.108256,23.8032389 L12.3092106,23.7104931 L12.3186497,23.7024347 L12.3186497,23.7024347 L12.3225043,23.6906389 L12.340401,23.2611114 L12.337245,23.2485176 L12.337245,23.2485176 L12.3277531,23.2396597 L12.1430473,23.1473072 Z" fill-rule="nonzero"></path>\n\t\t\t\t<path d="M12.7071,15.7072 C12.3166,16.0977 11.6834,16.0977 11.2929,15.7072 L5.63604,10.0503 C5.24551,9.65982 5.24551,9.02666 5.63604,8.63613 C6.02656,8.24561 6.65973,8.24561 7.05025,8.63613 L12,13.5859 L16.9497,8.63613 C17.3403,8.24561 17.9734,8.24561 18.364,8.63613 C18.7545,9.02666 18.7545,9.65982 18.364,10.0503 L12.7071,15.7072 Z" fill="#09244B"></path>\n\t\t\t</g>\n\t\t</g>\n\t</g>\n</svg>',_FilterButtonElement=class t{static create(e={}){const n=document.createElement("div");n.classList.add("filter-rows-dropdown-button",ToggleableElement.AUTO_STYLING_CLASS),FilterElements.applyStatefulStyles(n,t.HOVER_STYLE,e);const o=SVGIconUtils.createSVGElement(ARROW_DOWN_SVG_STRING);return n.appendChild(o),n}};_FilterButtonElement.ACTIVE_STYLE={filter:"brightness(0) saturate(100%) invert(14%) sepia(59%) saturate(2970%) hue-rotate(219deg) brightness(98%) contrast(126%)"},_FilterButtonElement.HOVER_STYLE={filter:"brightness(0) saturate(100%) invert(31%) sepia(1%) saturate(75%) hue-rotate(327deg) brightness(100%) contrast(99%)"};let FilterButtonElement=_FilterButtonElement;class OuterDropdownItemEvents{static itemMouseDownCommon(t,e,n){const{_activeOverlayElements:{outerContainerDropdown:o}}=this,s=n.target.innerText;if(!o)return;null==t||t(this,s,n);const l=Array.from(o.element.children);null==e||e(this._activeOverlayElements,l),o.element.classList.contains(StaticDropdown.DROPDOWN_CLASS)||(OuterDropdownItem.unsetActiveItem(o.element),OuterDropdownItem.setActive(l,s),DropdownItemHighlightUtils.fadeCurrentlyHighlighted(this._activeOverlayElements))}}class FilterDropdownItemEvents{static resetInput(t,e,n,o){const s=o.target,l=-1===s.tabIndex?s.parentElement.tabIndex:s.tabIndex,i=e._columnsDetails[l].elements;i!==t.elements&&(t.elements=i,FilterInternalUtils.resetInput(e,t),FilterInternalUtils.unsetFilter(t.inputElement))}static setEvents(t,e,n,o){const s=FilterDropdownItemEvents.resetInput.bind(this,n),l=FilterDropdownElement.hide.bind(this,o);e.onmousedown=OuterDropdownItemEvents.itemMouseDownCommon.bind(t,s,l)}}class FilterDropdownItem{static setActive(t,e,n){const o=t._columnsDetails.findIndex((t=>t.elements===n.elements));OuterDropdownItem.setActiveByIndex(Array.from(e.children),o)}static addItems(t,e,n){var o;const s=null==(o=t.data[0])?void 0:o.map((t=>String(t)));null==s||s.forEach((o=>{const s={text:o},l=DropdownItem.addButtonItem(t,e.element,s);FilterDropdownItemEvents.setEvents(t,l,n,e.activeButtonStyle)}))}static populate(t,e,n){e.element.replaceChildren(),FilterDropdownItem.addItems(t,e,n),FilterDropdownItem.setActive(t,e.element,n)}}class FilterDropdownElement{static hide(t,e){OuterDropdownElement.hide(e,t)}static display(t,e,n,o){n.data[0]&&(FilterDropdownItem.populate(n,o,e),t(n,o))}static create(t,e,n,o,s){const l=FilterButtonElement.create(s);e.appendChild(l);const i=(null==s?void 0:s.active)||{},r={...FilterButtonElement.ACTIVE_STYLE,...i},a=FilterDropdownElement.hide.bind(this,r,t._activeOverlayElements),c=OuterDropdownButtonEvents.getDisplayFunc(n),d=FilterDropdownElement.display.bind(this,c,o),{element:u}=OuterDropdownElement.create(t,l,n,r,["filter-rows-dropdown"],a,d);return u}}class StatefulCSSEvents{static apply(t,e,n){ElementStyle.unsetAllCSSStates(n,t),Object.assign(n.style,e)}static mouseUp(t,e,n){e&&n.classList.contains(e)||(StatefulCSSEvents.apply(t,t.default,n),Object.assign(n.style,t.hover))}static mouseDown(t,e,n){e&&n.classList.contains(e)||Object.assign(n.style,t.click)}static mouseLeave(t,e,n){e&&n.classList.contains(e)||StatefulCSSEvents.apply(t,t.default,n)}static mouseEnter(t,e,n){e&&n.classList.contains(e)||Object.assign(n.style,t.hover)}static getEvents(t,e,n,o){const s=o||t;return{mouseenter:StatefulCSSEvents.mouseEnter.bind(this,e,n,s),mouseleave:StatefulCSSEvents.mouseLeave.bind(this,e,n,s),mousedown:StatefulCSSEvents.mouseDown.bind(this,e,n,s),mouseup:StatefulCSSEvents.mouseUp.bind(this,e,n,s)}}static setEvents(t,e,n,o){const s=StatefulCSSEvents.getEvents(t,e,n,o);return t.addEventListener("mouseenter",s.mouseenter),t.addEventListener("mouseleave",s.mouseleave),t.addEventListener("mousedown",s.mousedown),t.addEventListener("mouseup",s.mouseup),s}}class FilterInputCaseEvents{static clickButton(t,e,n){const o=n||{},s=ToggleableElement.toggleActive(t,{color:"#000000",...o});e.isCaseSensitive=!s,FilterInternalUtils.resetInput(this,e),e.inputElement.dispatchEvent(new Event("input"))}static setEvents(t,e,n,o){e.onclick=FilterInputCaseEvents.clickButton.bind(t,e,n,o)}}class FilterInputCaseElement{static createButton(t={}){const e=document.createElement("div");return e.classList.add("filter-rows-case-button"),e.textContent="Aa",FilterElements.applyStatefulStyles(e,{color:"#626262"},t),e}static create(t,e,n,o){const s=FilterInputCaseElement.createButton(null==o?void 0:o.caseIcon);e.appendChild(s),setTimeout((()=>{var e;return FilterInputCaseEvents.setEvents(t,s,n,null==(e=null==o?void 0:o.caseIcon)?void 0:e.active)}))}}const _FilterElements=class t{static createContainerElement(t){const e=document.createElement("div");return e.classList.add("filter-rows-container"),e.style.order=String(t||0),e}static createComponent(e,n,o){var s;const l=o.position||t.DEFAULT_INPUT_POSITION,i=t.createContainerElement(o.order),r=FilterInternalUtils.addConfig(e,o);if(!1!==o.dropdown){const t=FilterDropdownElement.create(e,i,l,r,null==(s=o.styles)?void 0:s.dropdownIcon);setTimeout((()=>i.appendChild(t)))}!1!==o.caseButton&&FilterInputCaseElement.create(e,i,r,o.styles);const a=FilterInputElement.create(r,o,e.data);i.appendChild(a),OuterContainerElements.addToContainer(l,n,i)}static create(e,n){"boolean"==typeof e.filter?t.createComponent(e,n,{}):Array.isArray(e.filter)?e.filter.forEach((o=>{t.createComponent(e,n,o)})):e.filter&&t.createComponent(e,n,e.filter),setTimeout((()=>FilterInternalUtils.resetAllInputs(e)))}static applyStatefulStyles(t,e,n={}){const o=ElementStyle.generateStatefulCSS(n,e,{color:"#484848"});Object.assign(t.style,o.default),setTimeout((()=>StatefulCSSEvents.setEvents(t,o,ToggleableElement.ACTIVE_BUTTON_CLASS)))}};_FilterElements.DEFAULT_INPUT_POSITION="top-right";let FilterElements=_FilterElements;const CALENDAR_ICON_SVG_STRING='<?xml version="1.0" encoding="UTF-8"?>\n<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="10px" viewBox="0 0 10 10" version="1.1">\n <g id="surface1">\n <path style=" stroke:none;fill-rule:nonzero;fill:rgb(0%,0%,0%);fill-opacity:1;" d="M 1.070312 9.285156 L 8.929688 9.285156 L 8.929688 3.570312 L 1.070312 3.570312 Z M 3.214844 2.5 L 3.214844 0.894531 C 3.214844 0.839844 3.199219 0.796875 3.164062 0.765625 C 3.128906 0.730469 3.085938 0.714844 3.035156 0.714844 L 2.679688 0.714844 C 2.625 0.714844 2.582031 0.730469 2.550781 0.765625 C 2.515625 0.796875 2.5 0.839844 2.5 0.894531 L 2.5 2.5 C 2.5 2.550781 2.515625 2.59375 2.550781 2.628906 C 2.582031 2.660156 2.625 2.679688 2.679688 2.679688 L 3.035156 2.679688 C 3.085938 2.679688 3.128906 2.660156 3.164062 2.628906 C 3.199219 2.59375 3.214844 2.550781 3.214844 2.5 Z M 7.5 2.5 L 7.5 0.894531 C 7.5 0.839844 7.484375 0.796875 7.449219 0.765625 C 7.417969 0.730469 7.375 0.714844 7.320312 0.714844 L 6.964844 0.714844 C 6.914062 0.714844 6.871094 0.730469 6.835938 0.765625 C 6.800781 0.796875 6.785156 0.839844 6.785156 0.894531 L 6.785156 2.5 C 6.785156 2.550781 6.800781 2.59375 6.835938 2.628906 C 6.871094 2.660156 6.914062 2.679688 6.964844 2.679688 L 7.320312 2.679688 C 7.375 2.679688 7.417969 2.660156 7.449219 2.628906 C 7.484375 2.59375 7.5 2.550781 7.5 2.5 Z M 9.644531 2.144531 L 9.644531 9.285156 C 9.644531 9.480469 9.570312 9.648438 9.429688 9.789062 C 9.289062 9.929688 9.121094 10 8.929688 10 L 1.070312 10 C 0.878906 10 0.710938 9.929688 0.570312 9.789062 C 0.429688 9.648438 0.355469 9.480469 0.355469 9.285156 L 0.355469 2.144531 C 0.355469 1.949219 0.429688 1.78125 0.570312 1.640625 C 0.710938 1.5 0.878906 1.429688 1.070312 1.429688 L 1.785156 1.429688 L 1.785156 0.894531 C 1.785156 0.648438 1.875 0.4375 2.046875 0.261719 C 2.222656 0.0859375 2.433594 0 2.679688 0 L 3.035156 0 C 3.28125 0 3.492188 0.0859375 3.667969 0.261719 C 3.839844 0.4375 3.929688 0.648438 3.929688 0.894531 L 3.929688 1.429688 L 6.070312 1.429688 L 6.070312 0.894531 C 6.070312 0.648438 6.160156 0.4375 6.332031 0.261719 C 6.507812 0.0859375 6.71875 0 6.964844 0 L 7.320312 0 C 7.566406 0 7.777344 0.0859375 7.953125 0.261719 C 8.125 0.4375 8.214844 0.648438 8.214844 0.894531 L 8.214844 1.429688 L 8.929688 1.429688 C 9.121094 1.429688 9.289062 1.5 9.429688 1.640625 C 9.570312 1.78125 9.644531 1.949219 9.644531 2.144531 Z M 9.644531 2.144531 "/>\n </g>\n</svg>',_DateCellCalendarIconElement=class t{static createContainer(){const e=document.createElement("div");return e.classList.add(t.CALENDAR_ICON_CONTAINER_CLASS),e}static createSVGElement(){const t=SVGIconUtils.createSVGElement(CALENDAR_ICON_SVG_STRING);return t.style.pointerEvents="none",t.style.height="25px",t}static createSVG(){const e=t.createSVGElement(),n=t.createContainer();return n.appendChild(e),n}static get(){return t.CALENDAR_ICON_ELEMENT.cloneNode(!0)}};_DateCellCalendarIconElement.CALENDAR_ICON_CONTAINER_CLASS="calender-icon-container",_DateCellCalendarIconElement.CALENDAR_ICON_ELEMENT=_DateCellCalendarIconElement.createSVG();let DateCellCalendarIconElement=_DateCellCalendarIconElement;class ColumnDetailsUtils{static getColumnsByWidth(t){var e;const n=[],o=[];for(let s=0;s<t.length;s+=1){const l=t[s];void 0!==(null==(e=l.settings.widths)?void 0:e.staticWidth)?o.push(l):n.push(l)}return{dynamicWidth:n,staticWidth:o}}static aggregateItems(t){return t.labelDetails?Object.keys(t.itemsDetails).map((e=>({name:e,backgroundColor:t.itemsDetails[e].backgroundColor}))):Object.keys(t.itemsDetails).map((t=>({name:t})))}static getDetails(t){const e={width:t.elements[0].offsetWidth,typeName:t.activeType.name};return t.activeType.cellDropdownProps&&(e.cellDropdownItems=ColumnDetailsUtils.aggregateItems(t.cellDropdown)),e}static getAllColumnsDetails(t){return t.map((t=>ColumnDetailsUtils.getDetails(t)))}}class FireEvents{static onCellUpdate(t,e,n,o,s){const l={text:String(e),rowIndex:n,columnIndex:o,updateType:s};t.onCellUpdate(l),t.dispatchEvent(new CustomEvent("cell-update",{detail:l}))}static onDataUpdate(t){const e=JSON.parse(JSON.stringify(t.data));t.onDataUpdate(e),t.dispatchEvent(new CustomEvent("data-update",{detail:e}))}static onColumnsUpdate(t){const e=ColumnDetailsUtils.getAllColumnsDetails(t._columnsDetails);t.onColumnsUpdate(e),t.dispatchEvent(new CustomEvent("columns-update",{detail:e}))}static onRender(t){t.onRender(),t.dispatchEvent(new CustomEvent("render"))}}class StaticTable{static isTableAtMaxWidth(t,e){return void 0!==e.maxWidth&&e.maxWidth<=t.offsetWidth+2}static isStaticTableWidth(t,e){return void 0!==e.width||StaticTable.isTableAtMaxWidth(t,e)}}class StaticTableWidthUtils{static togglePreserveNarrowColumns(t,e,n){n||(e.style.display=t?"block":"")}static toggleWidthUsingMaxWidth(t,e){const{_tableElementRef:n,_tableDimensions:{maxWidth:o,preserveNarrowColumns:s}}=t;n&&void 0!==o&&(n.style.width=e?`${o}px`:"",StaticTableWidthUtils.togglePreserveNarrowColumns(e,n,s))}static setTableWidth(t){const{_tableDimensions:{preserveNarrowColumns:e,width:n},_tableElementRef:o}=t;o&&void 0!==n&&(o.style.width=`${n}px`,StaticTableWidthUtils.togglePreserveNarrowColumns(!0,o,e))}static changeTableWidthForNonDynamicColumns(t,e,n,o,s){0===t.length||e.dynamicWidth.length>0?n.offsetWidth!==o&&(n.style.width=`${o}px`):n.style.width=`${s}px`}static resetDynamicWidthColumns(t,e){t.forEach((t=>{t.elements[0].style.width=`${e.newColumnWidth}px`}))}static setNewColumnWidth(t,e,n){if(e>0){const o=t-n.staticWidth;n.newColumnWidth=o/e}}static resetColumnSizes(t,e,n){const o=ColumnDetailsUtils.getColumnsByWidth(t);return StaticTableWidthUtils.setNewColumnWidth(e,o.dynamicWidth.length,n),StaticTableWidthUtils.resetDynamicWidthColumns(o.dynamicWidth,n),o}static changeWidthsBasedOnColumnInsertRemove(t,e){const{_tableElementRef:n,_tableDimensions:o,_columnsDetails:s}=t;if(!n)return;const{width:l,maxWidth:i,staticWidth:r}=o;if(void 0!==l){const t=StaticTableWidthUtils.resetColumnSizes(s,l,o);StaticTableWidthUtils.changeTableWidthForNonDynamicColumns(s,t,n,l,r)}else e&&StaticTable.isTableAtMaxWidth(n,o)&&StaticTableWidthUtils.resetColumnSizes(s,i,o);setTimeout((()=>FireEvents.onColumnsUpdate(t)))}}class ConvertCellTypeUtils{static preprocessCell(t){t.style.cursor=""}}class CellStructureUtils{static setColumn(t,e,n,o){const{elements:s}=t._columnsDetails[e];s.slice(1).forEach(((s,l)=>{const i=l+1;n(t,s,e,i),t._columnsDetails[e].settings.isCellTextEditable&&o(t,s,i,e)}))}}class FocusedCellUtils{static createEmpty(){return{}}static setHeaderCell(t,e,n){t.element=e,t.rowIndex=0,t.columnIndex=n}static setIndexCell(t,e,n){t.element=e,t.rowIndex=n,delete t.columnIndex}static set(t,e,n,o){t.element=e,t.rowIndex=n,t.columnIndex=o}static incrementColumnIndex(t,e){void 0!==t.columnIndex&&e<=t.columnIndex&&(t.columnIndex+=1)}static purge(t){delete t.columnIndex,delete t.element,delete t.rowIndex}}var KEYBOARD_KEY=(t=>(t.ESCAPE="Escape",t.ENTER="Enter",t.TAB="Tab",t.ARROW_UP="ArrowUp",t.ARROW_DOWN="ArrowDown",t.ARROW_RIGHT="ArrowRight",t.ARROW_LEFT="ArrowLeft",t))(KEYBOARD_KEY||{});const _Browser=class{static createDateInput(){const t=document.createElement("input");return t.type="date",t}static createColorInput(){const t=document.createElement("input");return t.type="color",t}};_Browser.IS_FIREFOX=navigator.userAgent.toLowerCase().indexOf("firefox")>-1,_Browser.IS_SAFARI=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),_Browser.IS_CHROMIUM=window.chrome,_Browser.IS_INPUT_DATE_SUPPORTED="date"===_Browser.createDateInput().type&&"showPicker"in HTMLInputElement.prototype,_Browser.IS_COLOR_PICKER_SUPPORTED="color"===_Browser.createColorInput().type&&"showPicker"in HTMLInputElement.prototype;let Browser=_Browser;class ColumnSettingsStyleUtils{static applySettingsStyleOnCell(t,e,n){var o;Object.assign(e.style,t.cellStyle||{},n&&(null==(o=t.headerStyles)?void 0:o.default)||{})}static setNewHeaderStyle(t,e){var n;const{settings:o,elements:s}=e,l=o.cellStyle||(null==(n=o.headerStyles)?void 0:n.default);l&&ColumnSettingsStyleUtils.applySettingsStyleOnCell(o,s[0],!0);const i=l?o:void 0;e.headerStateColors=ColumnDetails.createHeaderStateColors(t._defaultColumnsSettings,i,t._defaultCellHoverColors),ColumnSettingsBorderUtils.overwriteSideBorderIfSiblingsHaveSettings(e,[s[0]])}static unsetHeaderSettingStyle(t,e){Object.keys(e).forEach((e=>{ElementStyle.setStyle(t,e,"")}))}static resetHeaderStyleToDefault(t,e,n){var o;null!=(o=e.headerStyles)&&o.default&&ColumnSettingsStyleUtils.unsetHeaderSettingStyle(t[0],e.headerStyles.default),e.cellStyle&&ElementStyle.unsetStyle(t[0],e.cellStyle);const{cellStyle:s,headerStyles:l}=n;CellElement.setDefaultCellStyle(t[0],s,null==l?void 0:l.default)}static changeHeaderStyleFunc(t,e){var n,o,s;const l=this._columnsDetails[t],{elements:i,settings:{isHeaderTextEditable:r}}=l;ColumnSettingsStyleUtils.resetHeaderStyleToDefault(i,e,this._defaultColumnsSettings),ColumnSettingsStyleUtils.setNewHeaderStyle(this,l);const a=null==(s=null==(o=null==(n=this._defaultColumnsSettings.columnDropdown)?void 0:n.displaySettings)?void 0:o.openMethod)?void 0:s.cellClick,c=!a&&r;CellElement.prepContentEditable(CellElement.getTextElement(i[0]),!!c,a)}static changeStyleFunc(t,e,n){ProcessedDataTextStyle.resetDataCellsStyle(t,e,ColumnSettingsStyleUtils.changeHeaderStyleFunc.bind(t,e,n),n.cellStyle)}static doStylesHaveVisibleDimension(t,e){for(let n=0;n<e.length;n+=1){const o=t[e[n]];if(o){const t=RegexUtils.extractIntegerStrs(String(o));if(t.length>0&&Number(t[0])>0)return!0}}return!1}static doesSettingHaveSideBorderStyle(t){var e;const n=t.cellStyle||(null==(e=t.headerStyles)?void 0:e.default);return!!n&&ColumnSettingsStyleUtils.doStylesHaveVisibleDimension(n,["border","borderLeft","borderLeftWidth","borderRight","borderRightWidth"])}}class ResetColumnStyles{static applyDefaultStyles(t,e){const{cellStyle:n,headerStyles:o}=e;CellElement.setDefaultCellStyle(t[0],n,null==o?void 0:o.default),t.slice(1).forEach((t=>{CellElement.setDefaultCellStyle(t,n)}))}static unsetLastAppliedStyle(t,e){Object.keys(t.lastAppliedStyle).forEach((t=>{ElementStyle.setStyle(e,t,"")}))}static setDefaultStyle(t,e,n,o,s){ResetColumnStyles.unsetLastAppliedStyle(e,n),s&&ElementStyle.unsetStyle(n,s),CellElement.setDefaultCellStyle(n,o.cellStyle),ColumnSettingsStyleUtils.applySettingsStyleOnCell(t.settings,n,!1)}}const _ProcessedDataTextStyle=class t{static setCustomStyle(t,e,n,o,s,l,i){if(t){ResetColumnStyles.setDefaultStyle(n,s,l,i);const r=t(String(e),o);Object.assign(l.style,r),s.lastAppliedStyle=r,ColumnSettingsBorderUtils.overwriteSideBorderIfSiblingsHaveSettings(n,[l])}}static setFailedValidationStyle(e,n,o){const{textValidation:s}=e.activeType,l=s.failedStyle||t.DEFAULT_FAILED_VALIDATION_STYLE;Object.assign(o.style,l),n.lastAppliedStyle=l}static setStyle(e,n,o,s,l,i){let r=!1;return e?null!=s&&s.changeStyleFunc||(ResetColumnStyles.setDefaultStyle(n,o,l,i),o.lastAppliedStyle={},r=!0):(null!=s&&s.changeStyleFunc&&ResetColumnStyles.setDefaultStyle(n,o,l,i),t.setFailedValidationStyle(n,o,l),r=!0),r&&ColumnSettingsBorderUtils.overwriteSideBorderIfSiblingsHaveSettings(n,[l]),r}static setCellStyle(e,n,o,s=!1){const l=e._columnsDetails[o],i=l.elements[n],r=l.processedStyle[n],a=CellElement.getText(i),{textValidation:{func:c},customTextProcessing:d}=l.activeType;let u=!1;if(c){const n=c(a);(s||r.isValid!==n)&&(u=t.setStyle(n,l,r,d,i,e._defaultColumnsSettings),r.isValid=n)}!u&&null!=d&&d.changeStyleFunc&&t.setCustomStyle(d.changeStyleFunc,a,l,n,r,i,e._defaultColumnsSettings)}static setStyleOnColumn(e,n){const o=e._columnsDetails[n];o.elements.slice(1).forEach(((s,l)=>{const i=l+1;t.setCellStyle(e,i,n,!0),ColumnSettingsBorderUtils.overwriteSideBorderIfSiblingsHaveSettings(o,[s])}))}static unsetStyleOnColumn(t,e,n){const o=t._columnsDetails[e];o.elements.slice(1).forEach(((e,s)=>{const l=s+1,i=o.processedStyle[l];ResetColumnStyles.setDefaultStyle(o,i,e,t._defaultColumnsSettings,n)}))}static resetDataCellsStyle(e,n,o,s){t.unsetStyleOnColumn(e,n,s),o(),t.setStyleOnColumn(e,n)}static reapplyCellsStyle(t,e){const n=t._columnsDetails[e],{textValidation:{func:o},customTextProcessing:s}=n.activeType;(o||null!=s&&s.changeStyleFunc)&&n.elements.slice(1).forEach(((t,e)=>{const o=e+1;Object.assign(t.style,n.processedStyle[o].lastAppliedStyle)}))}static getDefaultProcessedTextStyle(){return{isValid:!0,lastAppliedStyle:{}}}};_ProcessedDataTextStyle.DEFAULT_FAILED_VALIDATION_STYLE={color:"grey"};let ProcessedDataTextStyle=_ProcessedDataTextStyle;class NumberOfIdenticalCells{static get(t,e){return e.map((t=>t.elements.length>0?CellElement.getText(t.elements[0]):"")).filter((e=>e===t)).length}}const EMPTY_STRING="";class DataUtils{static createEmptyStringDataArray(t){return new Array(t).fill(EMPTY_STRING)}static isTextEmpty(t,e){return t!==EMPTY_STRING&&("string"==typeof e?e.trim():e)===EMPTY_STRING}static shouldBeSetToDefault(t,e,n,o,s){const{allowDuplicateHeaders:l,_columnsDetails:i}=t;return DataUtils.isTextEmpty(n,e)||0===o&&!l&&NumberOfIdenticalCells.get(e,i)>1||o>0&&!(void 0===s.func||s.func(String(e)))}static processCellText(t,e,n,o){let s="string"==typeof o?o.trim():o;const l=t._columnsDetails[n];if(!l)return s;const{activeType:{textValidation:i,customTextProcessing:r},settings:{defaultText:a}}=l;return e>0&&(null!=r&&r.changeTextFunc&&(s=r.changeTextFunc(String(s),e)),!i.setTextToDefaultOnFail&&s!==EMPTY_STRING)?s:DataUtils.shouldBeSetToDefault(t,s,a,e,i)?a:s}}var CELL_UPDATE_TYPE=(t=>(t.UPDATE="Update",t.ADD="Add",t.REMOVED="Removed",t))(CELL_UPDATE_TYPE||{});class CellEvents{static executeUpdateOperation(t,e){return void 0===(null==e?void 0:e[t])||!0===e[t]}static updateCell(t,e,n,o,s){return CellEvents.executeUpdateOperation("processText",s)&&(e=DataUtils.processCellText(t,n,o,e)),CellEvents.executeUpdateOperation("updateData",s)&&(t.data[n][o]=e),null!=s&&s.element&&CellElement.setNewText(t,s.element,e,!1,!1),CellEvents.executeUpdateOperation("updateTableEvent",s)&&t.onDataUpdate(t.data),n>0&&ProcessedDataTextStyle.setCellStyle(t,n,o),CellEvents.executeUpdateOperation("updateCellEvent",s)&&FireEvents.onCellUpdate(t,e,n,o,CELL_UPDATE_TYPE.UPDATE),e}static setCellToDefaultIfNeeded(t,e,n,o,s=!0){const l=CellElement.getText(o),i=DataUtils.processCellText(t,e,n,l);return i!==l&&(CellEvents.updateCell(t,i,e,n,{element:o,processText:!1,updateTableEvent:s}),!0)}static removeTextIfDefault(t,e,n,o){const{isDefaultTextRemovable:s,defaultText:l}=t._columnsDetails[n].settings;s&&l!==EMPTY_STRING&&l===CellElement.getText(o)&&CellEvents.updateCell(t,EMPTY_STRING,e,n,{element:o,processText:!1})}}class CheckboxEvents{static focusCheckbox(t,e,n){Browser.IS_SAFARI||FocusedCellUtils.set(this._focusedElements.cell,t,e,n)}static blurCheckbox(){Browser.IS_SAFARI||FocusedCellUtils.purge(this._focusedElements.cell)}static changeValueCheckbox(t,e,n){const o=n.target;CellEvents.updateCell(this,String(o.checked),t,e,{processText:!1})}static keyDownCheckbox(t){t.key===KEYBOARD_KEY.ENTER&&t.target.click()}static setEvents(t,e,n,o){e.onkeydown=CheckboxEvents.keyDownCheckbox,e.onchange=CheckboxEvents.changeValueCheckbox.bind(t,n,o),e.onfocus=CheckboxEvents.focusCheckbox.bind(t,e,n,o),e.onblur=CheckboxEvents.blurCheckbox.bind(t)}}class CheckboxCellEvents{static mouseDownCell(t){const e=t.target;e.classList.contains(CellElement.CELL_CLASS)&&e.children[0].click()}static focusCell(t){t.target.children[0].focus()}static setEvents(t,e,n,o){if(!t._columnsDetails[o].settings.isCellTextEditable)return;e.onblur=()=>{},e.onfocus=CheckboxCellEvents.focusCell,e.onmouseenter=()=>{},e.onmouseleave=()=>{},e.oninput=()=>{},e.onmousedown=CheckboxCellEvents.mouseDownCell.bind(t);const s=CheckboxCellElement.getCheckboxElement(e);CheckboxEvents.setEvents(t,s,n,o)}}class CheckboxElement{static createCheckbox(t){const e=document.createElement("input");return e.type="checkbox",e.style.cursor=t?"pointer":"auto",e.style.pointerEvents=t?"":"none",e}static setCellTextAsCheckbox(t,e){const n=CheckboxElement.createCheckbox(e);t.replaceChildren(n)}}class CheckboxCellElement{static isCheckbox(t){return"checkbox"===(null==t?void 0:t.type)}static isCheckboxCell(t){return CheckboxCellElement.isCheckbox(t.children[0])}static getCheckboxElement(t){return CheckboxCellElement.isCheckboxCell(t)?t.children[0]:CheckboxCellElement.isCheckbox(t)?t:void 0}static getValue(t){const e=CheckboxCellElement.getCheckboxElement(t);if(e)return String(e.checked)}static setValue(t,e){const n=CheckboxCellElement.getCheckboxElement(t);return!!n&&(n.checked="true"===e,!0)}static setCellTextAsAnElement(t,e,n,o){const{settings:{isCellTextEditable:s}}=t._columnsDetails[o],l=CellElement.getText(e);CheckboxElement.setCellTextAsCheckbox(e,s),e.contentEditable="false",e.style.cursor=s?"pointer":"default",CellEvents.updateCell(t,l,n,o,{element:e})}static setCellCheckboxStructure(t,e,n,o){ConvertCellTypeUtils.preprocessCell(e),CheckboxCellElement.setCellTextAsAnElement(t,e,o,n)}static setColumnCheckboxStructure(t,e){CellStructureUtils.setColumn(t,e,CheckboxCellElement.setCellCheckboxStructure,CheckboxCellEvents.setEvents)}}class CaretPosition{static setSelectionToEndOfText(t,e){const n=CellElement.getTextElement(t),o=document.createRange();o.setStart(n.childNodes[0],CellElement.getText(n).length||0),o.collapse(!0),e.removeAllRanges(),e.addRange(o)}static getSelection(t){var e;const n=t.shadowRoot;return n.getSelection?n.getSelection():(null==(e=window.document.activeElement)?void 0:e.shadowRoot)===n?window.document.getSelection():null}static setToEndOfText(t,e){if(CheckboxCellElement.isCheckboxCell(e))return;let n=CaretPosition.getSelection(t);Browser.IS_SAFARI&&!n&&(e.focus(),n=CaretPosition.getSelection(t)),n&&CaretPosition.setSelectionToEndOfText(e,n)}}class ArrayUtils{static transpose(t){if(0===t.length)return t;const e=[],n=Math.max(t.length,t[0].length);t:for(let o=0;o<n;o+=1){const s=[];for(let e=0;e<n&&void 0!==t[e];e+=1){if(void 0===t[e][o])break t;s.push(t[e][o])}e.push(s)}return e}static shuffle(t){return t.sort((()=>Math.random()-.5))}static swap(t,e,n){const o=t[e];t[e]=t[n],t[n]=o}}const _LabelColorUtils=class t{static generateNewPasteleColor(){return`hsl(${Math.floor(360*Math.random())}, 95%, 90%)`}static setNewLatestPasteleColor(){t.LATEST_PASTELE_COLOR=t.generateNewPasteleColor()}static getLatestPasteleColor(){return t.LATEST_PASTELE_COLOR}static getLatestPasteleColorAndSetNew(){const e=t.getLatestPasteleColor();return t.setNewLatestPasteleColor(),e}static generateDefaultColors(){return ArrayUtils.shuffle(["hsl(154deg 96% 90%)","hsl(50deg 96% 90%)","hsl(171deg 96% 90%)","hsl(76deg 96% 90%)","hsl(315deg 96% 90%)","hsl(251deg 96% 90%)","hsl(209deg 84% 92%)","hsl(0deg 100% 81%)","hsl(29deg 100% 79%)","hsl(31deg 73% 75%)","hsl(137deg 80% 80%)","hsl(60deg 100% 82%)","hsl(219deg 100% 84%)","hsl(93deg 62% 74%)","hsl(54deg 93% 84%)","hsl(146deg 100% 90%)","hsl(334deg 100% 87%)","hsl(19deg 95% 84%)","hsl(203deg 95% 84%)","hsl(76deg 100% 78%)","hsl(0deg 100% 86%)","hsl(42deg 82% 82%)","hsl(97deg 100% 87%)"])}static generateGlobalItemColors(){return{newColors:t.generateDefaultColors(),existingColors:{}}}};_LabelColorUtils.LATEST_PASTELE_COLOR=_LabelColorUtils.generateNewPasteleColor();let LabelColorUtils=_LabelColorUtils;class ScrollbarUtils{static isVerticalPresent(t){return t.scrollHeight>t.clientHeight}static isHorizontalPresent(t){return t.scrollWidth>t.clientWidth}}const _CellDropdownHorizontalScrollFix=class t{static setPropertiesIfHorizontalScrollPresent(e){const{element:n,scrollbarPresence:o,customDropdownStyle:s}=e;ScrollbarUtils.isHorizontalPresent(n)&&ScrollbarUtils.isVerticalPresent(n)?(o.horizontal=!0,n.style.paddingBottom=t.NEW_BOTTOM_PADDING_IF_PRESENT):(o.horizontal=!1,n.style.paddingBottom=(null==s?void 0:s.paddingBottom)||Dropdown.DROPDOWN_VERTICAL_PX)}static scrollDownFurther(e){e.scrollTop+=t.SCROLL_FURTHER_BOTTOM_PX}};_CellDropdownHorizontalScrollFix.NEW_BOTTOM_PADDING_IF_PRESENT="8px",_CellDropdownHorizontalScrollFix.SCROLL_FURTHER_BOTTOM_PX=14;let CellDropdownHorizontalScrollFix=_CellDropdownHorizontalScrollFix;const _RGBAToHex=class t{static extractIndividualNumbers(e){return e.match(t.REGEX)}static convert(e){return`#${t.extractIndividualNumbers(e).slice(1).map(((t,e)=>(3===e?Math.round(255*parseFloat(t)):parseFloat(t)).toString(16).padStart(2,"0").replace("NaN",""))).join("")}`}};_RGBAToHex.REGEX=/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+\.{0,1}\d*))?\)$/;let RGBAToHex=_RGBAToHex;const _OptionColorButton=class t{static extractRelativeParentElements(t){var e;const n=t.parentElement;return{containerElement:n,textElement:null==(e=n.previousSibling)?void 0:e.previousSibling,dropdownItemElement:n.parentElement}}static changeVisibility(t,e,n){const o=t.children[2];if(o.style.display=n?"block":"none",n){const t=o.children[0],s=Browser.IS_SAFARI?9:5;t.style.left=`${n.offsetWidth-e+s}px`;o.children[1].style.left=n.offsetWidth-e+"px"}}static createIcon(){const e=document.createElement("div");return e.innerText=t.COLOR_ICON_TEXT,e.classList.add(t.COLOR_BUTTON_ICON_CLASS),e}static createButton(){const e=document.createElement("div");e.classList.add(OptionButton.BUTTON_CLASS,t.COLOR_BUTTON_CLASS);const n=t.createIcon();return e.appendChild(n),e}static createInput(){const e=document.createElement("input");return e.type="color",e.style.top=Browser.IS_SAFARI?"0px":"14px",e.classList.add(t.COLOR_INPUT_CLASS),e}static createContainer(){const t=document.createElement("div");return t.classList.add(OptionButton.BUTTON_CONTAINER_CLASS),t}static create(e,n){const o=t.createContainer(),s=t.createInput();o.appendChild(s);const l=t.createButton();return o.appendChild(l),OptionColorButtonEvents.setEvents(o,s,e,n),o}};_OptionColorButton.COLOR_INPUT_CLASS="color-input",_OptionColorButton.COLOR_BUTTON_CLASS="option-color-button",_OptionColorButton.COLOR_BUTTON_ICON_CLASS="cell-dropdown-option-color-button-icon",_OptionColorButton.COLOR_ICON_TEXT="c";let OptionColorButton=_OptionColorButton;class OptionColorButtonEvents{static updateCellElements(t,e){const{itemText:n,backgroundColor:o}=e;t.elements.slice(1).forEach((t=>{const e=t.children[0];e.innerText===n&&(e.style.backgroundColor=o)}))}static updateIfUpdatable(t,e,n){const{itemText:o,backgroundColor:s}=n,l=t.cellDropdown.itemsDetails[o];l&&(!l.isCustomBackgroundColor||e===t.activeType.name)&&(l.backgroundColor=s,OptionColorButtonEvents.updateCellElements(t,n))}static updateElements(t,e,n){t.forEach((t=>{t.cellDropdown.labelDetails&&OptionColorButtonEvents.updateIfUpdatable(t,e,n)}))}static updateColorStates(t,e){var n,o,s;const{itemText:l,backgroundColor:i}=e;null==(o=null==(n=t.activeType.cellDropdownProps)?void 0:n.options)||o.forEach((t=>{t.text===l&&(t.backgroundColor=i)}));const r=null==(s=t.cellDropdown.labelDetails)?void 0:s.globalItemColors.existingColors;null!=r&&r[l]&&(r[l]=i)}static updateColumnLabelColors(t,e){const{cellDropdown:{labelDetails:n},activeType:o}=e;!n||!n.colorPickerNewValue||(OptionColorButtonEvents.updateColorStates(e,n.colorPickerNewValue),OptionColorButtonEvents.updateElements(t,o.name,n.colorPickerNewValue),delete n.colorPickerNewValue,setTimeout((()=>e.fireColumnsUpdate())))}static windowEventClosePicker(t,e){if(e.cellDropdown){const n=e.cell.columnIndex;OptionButton.hideAfterColorPickerContainerClose(t,t[n])}}static inputEvent(t,e){if(!Dropdown.isDisplayed(t.element))return;const n=e.target,{containerElement:o,textElement:s,dropdownItemElement:l}=OptionColorButton.extractRelativeParentElements(n),i=s.textContent,r=n.value;l.style.backgroundColor=r;const a=t.itemsDetails[i];a.backgroundColor!==r&&(a.backgroundColor=r,t.labelDetails.colorPickerNewValue={backgroundColor:r,itemText:i},setTimeout((()=>{var e;(e=t.labelDetails).colorPickerContainer??(e.colorPickerContainer=o)})))}static mouseDownContainer(t,e,n){const{cellDropdown:{labelDetails:o}}=e;if(!o)return;if(o.colorPickerContainer)return delete o.colorPickerContainer,void OptionColorButtonEvents.updateColumnLabelColors(t,e);const s=n.target,{containerElement:l,dropdownItemElement:i}=OptionColorButton.extractRelativeParentElements(s),r=s.previousSibling;r.value=RGBAToHex.convert(getComputedStyle(i).backgroundColor),r.showPicker(),setTimeout((()=>o.colorPickerContainer=l))}static setEvents(t,e,n,o){t.onmousedown=OptionColorButtonEvents.mouseDownContainer.bind(this,n,o),e.oninput=OptionColorButtonEvents.inputEvent.bind(this,o.cellDropdown)}}class FocusNextRowCell{static focus(t,e,n,o){o.preventDefault();const s=n[e+1];s&&(s.focus(),CaretPosition.setToEndOfText(t,s))}static focusOrBlurSelect(t,e){const n=t[e+1];if(n)return n.dispatchEvent(new Event("mousedown")),n.scrollIntoView({block:"nearest"}),n;t[e].children[0].blur()}}const ARROW_DOWN_ICON_SVG_STRING='<?xml version="1.0" standalone="no"?>\n<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">\n<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="12" height="12">\n <g style="pointer-events: none" transform="matrix(0.6315789 0 0 0.6315789 0 0)">\n <g transform="matrix(0.027142858 0 0 0.027142858 0 0)">\n <path d="M0 87.5L350 507.5L700 87.5L0 87.5z" stroke="none" fill="#3e3e3e" fill-rule="nonzero" />\n </g>\n </g>\n</svg>\n',_ArrowDownIconElement=class t{static toggle(t,e){if(!t)return;const n=t.children[1];n.style.display=e?"block":"none";const o=n.children[0];!e&&o.style.filter&&(o.style.filter="")}static setActive(t){t.children[1].children[0].style.filter="brightness(0) saturate(100%) invert(24%) sepia(73%) saturate(631%)\n hue-rotate(171deg) brightness(98%) contrast(98%)"}static createContainer(){const e=document.createElement("div");return e.classList.add(t.ARROW_ICON_CONTAINER_CLASS),e.style.display="none",e}static createSVGElement(){const e=SVGIconUtils.createSVGElement(ARROW_DOWN_ICON_SVG_STRING);return e.classList.add(t.ARROW_ICON_CLASS),e}static createSVG(){const e=t.createSVGElement(),n=t.createContainer();return n.appendChild(e),n}static get(){return t.ARROW_ICON_ELEMENT.cloneNode(!0)}};_ArrowDownIconElement.ARROW_ICON_CLASS="arrow-down-icon",_ArrowDownIconElement.ARROW_ICON_CONTAINER_CLASS="arrow-down-icon-container",_ArrowDownIconElement.ARROW_ICON_ELEMENT=_ArrowDownIconElement.createSVG();let ArrowDownIconElement=_ArrowDownIconElement;class TableBorderDimensionsUtils{static generateDefault(){return{leftWidth:0,rightWidth:0,topWidth:0,bottomWidth:0}}static getWidth(t,e){return""===t.style[e]?1:Number.parseFloat(t.style[e])||0}static generateUsingElement(t){return{leftWidth:TableBorderDimensionsUtils.getWidth(t,"borderLeftWidth"),rightWidth:TableBorderDimensionsUtils.getWidth(t,"borderRightWidth"),topWidth:TableBorderDimensionsUtils.getWidth(t,"borderTopWidth"),bottomWidth:TableBorderDimensionsUtils.getWidth(t,"borderBottomWidth")}}}const _UpdateIndexColumnWidth=class t{static wrapColumnTextAndGetDefaultWidth(t){const{_tableBodyElementRef:e,data:n,_tableDimensions:o}=t;return ExtractElements.textRowsArrFromTBody(e,n).forEach((t=>{t.children[0