@serenity-is/sleekgrid
Version:
A modern Data Grid / Spreadsheet component
4 lines (3 loc) • 8.28 kB
JavaScript
var Slick=Slick||{};Slick._=(()=>{var p=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var F=(e,t)=>{for(var r in t)p(e,r,{get:t[r],enumerable:!0})},R=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of D(t))!S.call(e,o)&&o!==r&&p(e,o,{get:()=>t[o],enumerable:!(n=w(t,o))||n.enumerable});return e};var _=e=>R(p({},"__esModule",{value:!0}),e);var Z={};F(Z,{CellRange:()=>E,EditorLock:()=>m,EventData:()=>d,EventEmitter:()=>c,EventSubscriber:()=>f,GlobalEditorLock:()=>k,Group:()=>b,GroupTotals:()=>C,H:()=>A,NonDataRow:()=>s,addClass:()=>v,applyFormatterResultToCellNode:()=>U,basicRegexSanitizer:()=>G,columnDefaults:()=>M,convertCompatFormatter:()=>$,defaultColumnFormat:()=>K,disableSelection:()=>V,escapeHtml:()=>g,initializeColumns:()=>N,keyCode:()=>H,parsePx:()=>j,patchEvent:()=>P,preClickClassName:()=>L,removeClass:()=>h,spacerDiv:()=>W,titleize:()=>y});var s=class{constructor(){this.__nonDataRow=!0}},L="slick-edit-preclick";var M={nameIsHtml:!1,resizable:!0,sortable:!1,minWidth:30,rerenderOnResize:!1,defaultSortAsc:!0,focusable:!0,selectable:!0};function N(e,t){var l;for(var r={},n=0;n<e.length;n++){var o=e[n];if(t!=null)for(var a in t)o[a]===void 0&&(o[a]=t[a]);if(o.minWidth&&o.width<o.minWidth&&(o.width=o.minWidth),o.maxWidth&&o.width>o.maxWidth&&(o.width=o.maxWidth),o.id==null||r[o.id]){let u=o.id!=null&&o.id.length?o.id:o.field!=null?o.field:"col";for(var i=0;r[o.id=u+(i==0?"":"_"+i.toString())];)i++}r[o.id]=!0,o.name===void 0&&(o.name=y((l=o.field)!=null?l:o.id),delete o.nameIsHtml)}}function y(e){return e&&(e=(""+e).replace(/([A-Z]+)([A-Z][a-z])/,"$1_$2").replace(/([a-z\d])([A-Z])/,"$1_$2").replace(/[-\s]/,"_").toLowerCase(),e.replace(/\s/,"_").split("_").filter(t=>t.length).map(t=>t.charAt(0).toUpperCase()+t.substring(1).toLowerCase()).join(" "))}var m=class{isActive(t){return t?this.activeEditController===t:this.activeEditController!=null}activate(t){if(t!==this.activeEditController){if(this.activeEditController!=null)throw"SleekGrid.EditorLock.activate: an editController is still active, can't activate another editController";if(!t.commitCurrentEdit)throw"SleekGrid.EditorLock.activate: editController must implement .commitCurrentEdit()";if(!t.cancelCurrentEdit)throw"SleekGrid.EditorLock.activate: editController must implement .cancelCurrentEdit()";this.activeEditController=t}}deactivate(t){if(this.activeEditController!==t)throw"SleekGrid.EditorLock.deactivate: specified editController is not the currently active one";this.activeEditController=null}commitCurrentEdit(){return this.activeEditController?this.activeEditController.commitCurrentEdit():!0}cancelCurrentEdit(){return this.activeEditController?this.activeEditController.cancelCurrentEdit():!0}},k=new m;var d=class{constructor(){this._isPropagationStopped=!1;this._isImmediatePropagationStopped=!1}stopPropagation(){this._isPropagationStopped=!0}isPropagationStopped(){return this._isPropagationStopped}stopImmediatePropagation(){this._isImmediatePropagationStopped=!0}isImmediatePropagationStopped(){return this._isImmediatePropagationStopped}},c=class{constructor(){this._handlers=[]}subscribe(t){this._handlers.push(t)}unsubscribe(t){for(var r=this._handlers.length-1;r>=0;r--)this._handlers[r]===t&&this._handlers.splice(r,1)}notify(t,r,n){r=P(r)||new d,n=n||this;for(var o,a=0;a<this._handlers.length&&!(r.isPropagationStopped()||r.isImmediatePropagationStopped());a++)o=this._handlers[a].call(n,r,t);return o}clear(){this._handlers=[]}},f=class{constructor(){this._handlers=[]}subscribe(t,r){return this._handlers.push({event:t,handler:r}),t.subscribe(r),this}unsubscribe(t,r){for(var n=this._handlers.length;n--;)if(this._handlers[n].event===t&&this._handlers[n].handler===r)return this._handlers.splice(n,1),t.unsubscribe(r),this;return this}unsubscribeAll(){for(var t=this._handlers.length;t--;)this._handlers[t].event.unsubscribe(this._handlers[t].handler);return this._handlers=[],this}},H={BACKSPACE:8,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,PAGEDOWN:34,PAGEUP:33,RIGHT:39,TAB:9,UP:38};function x(){return!0}function I(){return!1}function P(e){if(e==null)return e;!e.isDefaultPrevented&&e.preventDefault&&(e.isDefaultPrevented=function(){return this.defaultPrevented});var t,r;return!e.isImmediatePropagationStopped&&(t=e.stopImmediatePropagation)&&(e.isImmediatePropagationStopped=I,e.stopImmediatePropagation=function(){this.isImmediatePropagationStopped=x,t.call(this)}),!e.isPropagationStopped&&(r=e.stopPropagation)&&(e.isPropagationStopped=I,e.stopPropagation=function(){this.isPropagationStopped=x,r.call(this)}),e}function v(e,t){if(!(t==null||!t.length))if(t.indexOf(" ")>=0){var r=t.split(" ").map(o=>o.trim()).filter(o=>o.length);for(var n of r)e.classList.add(n)}else e.classList.add(t)}var O={"<":"<",">":">",'"':""","'":"'","&":"&"};function z(e){return O[e]}function g(e){return!arguments.length&&this&&(e=this.value),e==null?"":(typeof e!="string"&&(e=""+e),e.replace(/[<>"'&]/g,z))}function G(e){return(e!=null?e:"").replace(/(\b)(on[a-z]+)(\s*)=|javascript:([^>]*)[^>]*|(<\s*)(\/*)script([<>]*).*(<\s*)(\/*)script(>*)|(<)(\/*)(script|script defer)(.*)(>|>">)/gi,"")}function V(e){e&&(e.setAttribute("unselectable","on"),e.style.userSelect="none",e.addEventListener("selectstart",()=>!1))}function h(e,t){if(!(t==null||!t.length))if(t.indexOf(" ")>=0){var r=t.split(" ").map(o=>o.trim()).filter(o=>o.length);for(var n of r)e.classList.remove(n)}else e.classList.remove(t)}function A(e,t,...r){var n=document.createElement(e),o,a,i;if(t){for(o in t)if(a=t[o],a!=null&&a!==!1){if(o==="ref"&&typeof a=="function"){a(n);continue}var l=o==="className"?"class":o;n.setAttribute(l,a===!0?"":a)}}return r&&r.length&&n.append(...r),n}function W(e){return A("div",{style:"display:block;height:1px;position:absolute;top:0;left:0;",width:e})}function j(e){var t=parseFloat(e);return isNaN(t)?0:t}function K(e){return g(e.value)}function $(e){return e==null?null:function(t){var r=e(t.row,t.cell,t.value,t.column,t.item,t.grid);return r!=null&&typeof r!="string"&&Object.prototype.toString.call(r)==="[object Object]"?(t.addClass=r.addClasses,t.tooltip=r.toolTip,r.text):r}}function U(e,t,r){var u,T;var n=r.dataset.fmtatt;if((n==null?void 0:n.length)>0){for(var o of n.split(","))r.removeAttribute(o);delete r.dataset.fmtatt}var a=r.dataset.fmtcls;a!=null&&a.length&&e.addClass!=a&&(h(r,a),(u=e.addClass)!=null&&u.length||delete r.dataset.fmtcls);var i=r.getAttribute("tooltip");if(i!=null&&e.tooltip!=i&&r.removeAttribute("tooltip"),e.tooltip!==void 0&&i!=e.tooltip&&r.setAttribute("tooltip",e.tooltip),t==null?r.innerHTML="":t instanceof Node?r.appendChild(t):r.innerHTML=""+t,e.addAttrs!=null){var l=Object.keys(e.addAttrs);if(l.length){for(var o of l)r.setAttribute(o,e.addAttrs[o]);r.dataset.fmtatt=l.join(",")}}(T=e.addClass)!=null&&T.length&&(v(r,e.addClass),r.dataset.fmtcls=e.addClass)}var b=class extends s{constructor(){super(...arguments);this.__group=!0;this.level=0;this.count=0;this.collapsed=!1;this.rows=[]}equals(r){return this.value===r.value&&this.count===r.count&&this.collapsed===r.collapsed&&this.title===r.title}},C=class extends s{constructor(){super(...arguments);this.__groupTotals=!0;this.initialized=!1}};var E=class{constructor(t,r,n,o){n===void 0&&o===void 0&&(n=t,o=r),this.fromRow=Math.min(t,n),this.fromCell=Math.min(r,o),this.toRow=Math.max(t,n),this.toCell=Math.max(r,o)}isSingleRow(){return this.fromRow==this.toRow}isSingleCell(){return this.fromRow==this.toRow&&this.fromCell==this.toCell}contains(t,r){return t>=this.fromRow&&t<=this.toRow&&r>=this.fromCell&&r<=this.toCell}toString(){return this.isSingleCell()?"("+this.fromRow+":"+this.fromCell+")":"("+this.fromRow+":"+this.fromCell+" - "+this.toRow+":"+this.toCell+")"}};return _(Z);})();
["Data", "Editors", "Formatters", "Plugins"].forEach(ns => Slick._[ns] && (Slick[ns] = Object.assign(Slick[ns] || {}, Slick._[ns])) && delete Slick._[ns]); Object.assign(Slick, Slick._); delete Slick._; Slick.Event = Slick.EventEmitter; Slick.EventHandler = Slick.EventSubscriber; Slick.Range = Slick.CellRange; typeof Map !== 'undefined' && (Slick.Map = Map);
//# sourceMappingURL=slick.core.min.js.map