diff --git a/docs/assets/css/frappe-datatable.css b/docs/assets/css/frappe-datatable.css deleted file mode 100644 index edffe35..0000000 --- a/docs/assets/css/frappe-datatable.css +++ /dev/null @@ -1,257 +0,0 @@ -.datatable *, .datatable *::after, .datatable *::before { - -webkit-box-sizing: border-box; - box-sizing: border-box; - } - -.datatable { - position: relative; - overflow: auto; -} - -.dt-header { - border-collapse: collapse; - border-bottom: 1px solid #d1d8dd; - - position: absolute; - top: 0; - left: 0; - background-color: #fff; -} - -.dt-body { - border-collapse: collapse; -} - -.dt-scrollable { - max-height: 40vw; - overflow: auto; - border-bottom: 1px solid #d1d8dd; -} - -.dt-scrollable--highlight-all { - background-color: #fffce7; - } - -.dt-scrollable__no-data { - text-align: center; - padding: 16px; - padding: 1rem; - border-left: 1px solid #d1d8dd; - border-right: 1px solid #d1d8dd; - } - -.dt-row--highlight { - background-color: #fffce7; - } - -.dt-row--unhighlight { - background-color: #fff; - } - -.dt-row--hide { - display: none; - } - -.dt-cell { - border: 1px solid #d1d8dd; - position: relative; - outline: none; - padding: 0; -} - -.dt-cell__content { - padding: 8px; - padding: 0.5rem; - border: 2px solid transparent; - height: 100%; - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; - text-overflow: ellipsis; - white-space: nowrap; - overflow: hidden; - } - -.dt-cell__edit { - display: none; - padding: 8px; - padding: 0.5rem; - background-color: #fff; - border: 2px solid rgb(255, 160, 10); - z-index: 1; - height: 100%; - } - -.dt-cell__resize-handle { - opacity: 0; - position: absolute; - right: -3px; - top: 0; - width: 5px; - height: 100%; - cursor: col-resize; - z-index: 1; - } - -.dt-cell--editing .dt-cell__content { - display: none; - } - -.dt-cell--editing .dt-cell__edit { - display: block; - } - -.dt-cell--focus .dt-cell__content { - border-color: rgb(82, 146, 247); - } - -.dt-cell--highlight { - background-color: #f5f7fa; - } - -.dt-cell--dragging { - background-color: #f5f7fa; - } - -.dt-cell--header .dt-cell__content { - padding-right: 16px; - padding-right: 1rem; - font-weight: bold; - } - -.dt-cell--header:hover .dt-dropdown__toggle { - opacity: 1; - } - -.dt-cell--tree-close .dt-tree-node__toggle:before { - content: '►'; - } - -.dt-dropdown { - position: absolute; - right: 10px; - display: -webkit-inline-box; - display: -ms-inline-flexbox; - display: inline-flex; - vertical-align: top; - text-align: left; - font-weight: normal; - cursor: pointer; -} - -.dt-dropdown__toggle { - opacity: 0; - } - -.dt-dropdown__list { - display: none; - - position: absolute; - min-width: 128px; - min-width: 8rem; - top: 100%; - right: 0; - z-index: 1; - background-color: #fff; - border-radius: 3px; - padding: 8px 0; - padding: 0.5rem 0; - -webkit-box-shadow: 0 2px 3px rgba(10, 10, 10, .1), 0 0 0 1px rgba(10, 10, 10, .1); - box-shadow: 0 2px 3px rgba(10, 10, 10, .1), 0 0 0 1px rgba(10, 10, 10, .1); - } - -.dt-dropdown__list-item { - padding: 8px 16px; - padding: 0.5rem 1rem; - } - -.dt-dropdown__list-item:hover { - background-color: #f5f7fa; - } - -.dt-dropdown--active .dt-dropdown__list { - display: block; - } - -.dt-tree-node { - display: inline-block; - position: relative; -} - -.dt-tree-node__toggle { - display: inline-block; - position: absolute; - font-size: 10px; - padding: 0 4px; - cursor: pointer; - } - -.dt-tree-node__toggle:before { - content: '▼'; - } - -.dt-toast { - position: absolute; - bottom: 16px; - bottom: 1rem; - left: 50%; - -webkit-transform: translateX(-50%); - transform: translateX(-50%); -} - -.dt-toast__message { - display: inline-block; - background-color: rgba(0, 0, 0, .8); - color: #dfe2e5; - border-radius: 3px; - padding: 8px 16px; - padding: 0.5rem 1rem; - } - -.dt-input { - outline: none; - width: 100%; - border: none; - overflow: visible; - font-family: inherit; - font-size: inherit; - line-height: inherit; - margin: 0; - padding: 0; -} - -.dt-freeze { - display: -webkit-box; - display: -ms-flexbox; - display: flex; - -webkit-box-pack: center; - -ms-flex-pack: center; - justify-content: center; - -ms-flex-line-pack: center; - align-content: center; - position: absolute; - left: 0; - right: 0; - top: 0; - bottom: 0; - background-color: #f5f7fa; - opacity: 0.5; - font-size: 2em; -} - -.dt-freeze__message { - position: absolute; - top: 50%; - -webkit-transform: translateY(-50%); - transform: translateY(-50%); - } - -.dt-paste-target { - position: fixed; - left: -999em; -} - -body.dt-resize { - cursor: col-resize; -} diff --git a/docs/assets/css/hljs-default.css b/docs/assets/css/hljs-default.css deleted file mode 100644 index f1bfade..0000000 --- a/docs/assets/css/hljs-default.css +++ /dev/null @@ -1,99 +0,0 @@ -/* - -Original highlight.js style (c) Ivan Sagalaev - -*/ - -.hljs { - display: block; - overflow-x: auto; - padding: 0.5em; - background: #F0F0F0; -} - - -/* Base color: saturation 0; */ - -.hljs, -.hljs-subst { - color: #444; -} - -.hljs-comment { - color: #888888; -} - -.hljs-keyword, -.hljs-attribute, -.hljs-selector-tag, -.hljs-meta-keyword, -.hljs-doctag, -.hljs-name { - font-weight: bold; -} - - -/* User color: hue: 0 */ - -.hljs-type, -.hljs-string, -.hljs-number, -.hljs-selector-id, -.hljs-selector-class, -.hljs-quote, -.hljs-template-tag, -.hljs-deletion { - color: #880000; -} - -.hljs-title, -.hljs-section { - color: #880000; - font-weight: bold; -} - -.hljs-regexp, -.hljs-symbol, -.hljs-variable, -.hljs-template-variable, -.hljs-link, -.hljs-selector-attr, -.hljs-selector-pseudo { - color: #BC6060; -} - - -/* Language color: hue: 90; */ - -.hljs-literal { - color: #78A960; -} - -.hljs-built_in, -.hljs-bullet, -.hljs-code, -.hljs-addition { - color: #397300; -} - - -/* Meta color: hue: 200 */ - -.hljs-meta { - color: #1f7199; -} - -.hljs-meta-string { - color: #4d99bf; -} - - -/* Misc effects */ - -.hljs-emphasis { - font-style: italic; -} - -.hljs-strong { - font-weight: bold; -} diff --git a/docs/assets/css/index.css b/docs/assets/css/index.css deleted file mode 100644 index 538990c..0000000 --- a/docs/assets/css/index.css +++ /dev/null @@ -1,159 +0,0 @@ -@import url('https://fonts.googleapis.com/css?family=Lato:400,700,900'); - -:root { - --border-color: #d1d8dd; - --border: 1px solid var(--border-color); - --text-color: #36414C; - --navbar-font-size: 1.25rem; - --light-bg: #f5f7fa; - --primary-color: #7575ff; - --primary-color-hover: #5b5be5; -} - -*, *::after, *::before { - box-sizing: border-box; - padding: 0; - margin: 0; -} - -html, body { - /* font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; */ - font-family: Lato, sans-serif; - font-size: 12px; - color: var(--text-color); -} - -body { - position: relative; -} - -code { - font-family: Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; -} - -h1 { - font-size: 2.5rem; - margin: 2rem 0 4rem 0; -} - -h3 { - font-size: 1.25rem; -} - -p { - font-size: 1.25rem; - margin: 1rem 0; -} - -.navbar { - position: sticky; - top: 0; - padding: 1.5rem; - background-color: white; - z-index: 1; - border-bottom: var(--border); -} - -.navbar .container { - display: flex; - justify-content: space-between; -} - -.navbar-links a { - color: var(--text-color); - text-decoration: none; - font-weight: bold; - font-size: var(--navbar-font-size); -} - -.container { - max-width: 720px; - margin: 0 auto; -} - -.logo { - max-width: 8rem; -} - -.footer-logo { - max-width: 3rem; - max-height: 3rem; - padding: 0.5rem; - background-color: #fff; - transform: translateY(-50%); -} - -.text-center { - text-align: center; -} - -.padding-1 { - padding: 0.5rem; -} - -.showcase { - display: flex; - flex-direction: column; - align-items: flex-start; - margin: 4rem 0; -} - -.showcase.align-center { - align-items: center; -} - -.features { - display: flex; - width: 100%; - font-size: 1.25rem; - margin-top: 1rem; - line-height: 2rem; -} - -.features ul { - padding-left: 2rem; - flex: 1; -} - -[class^="example-"] { - display: flex; - justify-content: center; - width: 100%; -} - -.code { - text-align: left; - width: 100%; - margin: 1rem 0; -} - -.hljs { - padding: 2rem; - border-left: 2px solid var(--border-color); - background-color: var(--light-bg); -} - -footer { - border-top: 1px solid #d1d8dd; -} - -.download-button { - color: #fff; - background-color: var(--primary-color); - border: 0px; - border-bottom: 3px solid rgba(0, 0, 0, 0.2); - font-size: 1.5rem; - padding: 1rem 2rem; - border-radius: 3px; -} - -.download-button:hover { - cursor: pointer; - background-color: var(--primary-color-hover); -} - -/* .data-table-header { - background: #f7fafc; - color: #8d99a6; -} */ - diff --git a/docs/assets/img/data-table-logo.svg b/docs/assets/img/data-table-logo.svg deleted file mode 100644 index 371a147..0000000 --- a/docs/assets/img/data-table-logo.svg +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/docs/assets/img/frappe-bird-grey.svg b/docs/assets/img/frappe-bird-grey.svg deleted file mode 100644 index 613bbde..0000000 --- a/docs/assets/img/frappe-bird-grey.svg +++ /dev/null @@ -1,46 +0,0 @@ - -image/svg+xml \ No newline at end of file diff --git a/docs/assets/js/Sortable.min.js b/docs/assets/js/Sortable.min.js deleted file mode 100644 index 938811f..0000000 --- a/docs/assets/js/Sortable.min.js +++ /dev/null @@ -1,2 +0,0 @@ -/*! Sortable 1.7.0 - MIT | git://github.com/rubaxa/Sortable.git */ -!function(a){"use strict";"function"==typeof define&&define.amd?define(a):"undefined"!=typeof module&&"undefined"!=typeof module.exports?module.exports=a():window.Sortable=a()}(function(){"use strict";function a(b,c){if(!b||!b.nodeType||1!==b.nodeType)throw"Sortable: `el` must be HTMLElement, and not "+{}.toString.call(b);this.el=b,this.options=c=t({},c),b[V]=this;var d={group:Math.random(),sort:!0,disabled:!1,store:null,handle:null,scroll:!0,scrollSensitivity:30,scrollSpeed:10,draggable:/[uo]l/i.test(b.nodeName)?"li":">*",ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:!0,animation:0,setData:function(a,b){a.setData("Text",b.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:"data-id",delay:0,forceFallback:!1,fallbackClass:"sortable-fallback",fallbackOnBody:!1,fallbackTolerance:0,fallbackOffset:{x:0,y:0},supportPointer:a.supportPointer!==!1};for(var e in d)!(e in c)&&(c[e]=d[e]);ka(c);for(var g in this)"_"===g.charAt(0)&&"function"==typeof this[g]&&(this[g]=this[g].bind(this));this.nativeDraggable=!c.forceFallback&&ca,f(b,"mousedown",this._onTapStart),f(b,"touchstart",this._onTapStart),c.supportPointer&&f(b,"pointerdown",this._onTapStart),this.nativeDraggable&&(f(b,"dragover",this),f(b,"dragenter",this)),ia.push(this._onDragOver),c.store&&this.sort(c.store.get(this))}function b(a,b){"clone"!==a.lastPullMode&&(b=!0),B&&B.state!==b&&(i(B,"display",b?"none":""),b||B.state&&(a.options.group.revertClone?(C.insertBefore(B,D),a._animate(y,B)):C.insertBefore(B,y)),B.state=b)}function c(a,b,c){if(a){c=c||X;do if(">*"===b&&a.parentNode===c||r(a,b))return a;while(a=d(a))}return null}function d(a){var b=a.host;return b&&b.nodeType?b:a.parentNode}function e(a){a.dataTransfer&&(a.dataTransfer.dropEffect="move"),a.preventDefault()}function f(a,b,c){a.addEventListener(b,c,aa)}function g(a,b,c){a.removeEventListener(b,c,aa)}function h(a,b,c){if(a)if(a.classList)a.classList[c?"add":"remove"](b);else{var d=(" "+a.className+" ").replace(T," ").replace(" "+b+" "," ");a.className=(d+(c?" "+b:"")).replace(T," ")}}function i(a,b,c){var d=a&&a.style;if(d){if(void 0===c)return X.defaultView&&X.defaultView.getComputedStyle?c=X.defaultView.getComputedStyle(a,""):a.currentStyle&&(c=a.currentStyle),void 0===b?c:c[b];b in d||(b="-webkit-"+b),d[b]=c+("string"==typeof c?"":"px")}}function j(a,b,c){if(a){var d=a.getElementsByTagName(b),e=0,f=d.length;if(c)for(;e5||b.clientX-(d.left+d.width)>5}function p(a){for(var b=a.tagName+a.className+a.src+a.href+a.textContent,c=b.length,d=0;c--;)d+=b.charCodeAt(c);return d.toString(36)}function q(a,b){var c=0;if(!a||!a.parentNode)return-1;for(;a&&(a=a.previousElementSibling);)"TEMPLATE"===a.nodeName.toUpperCase()||">*"!==b&&!r(a,b)||c++;return c}function r(a,b){if(a){b=b.split(".");var c=b.shift().toUpperCase(),d=new RegExp("\\s("+b.join("|")+")(?=\\s)","g");return!(""!==c&&a.nodeName.toUpperCase()!=c||b.length&&((" "+a.className+" ").match(d)||[]).length!=b.length)}return!1}function s(a,b){var c,d;return function(){void 0===c&&(c=arguments,d=this,Z(function(){1===c.length?a.call(d,c[0]):a.apply(d,c),c=void 0},b))}}function t(a,b){if(a&&b)for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c]);return a}function u(a){return _&&_.dom?_.dom(a).cloneNode(!0):$?$(a).clone(!0)[0]:a.cloneNode(!0)}function v(a){for(var b=a.getElementsByTagName("input"),c=b.length;c--;){var d=b[c];d.checked&&ha.push(d)}}function w(a){return Z(a,0)}function x(a){return clearTimeout(a)}if("undefined"==typeof window||!window.document)return function(){throw new Error("Sortable.js requires a window with a document")};var y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S={},T=/\s+/g,U=/left|right|inline/,V="Sortable"+(new Date).getTime(),W=window,X=W.document,Y=W.parseInt,Z=W.setTimeout,$=W.jQuery||W.Zepto,_=W.Polymer,aa=!1,ba=!1,ca="draggable"in X.createElement("div"),da=function(a){return!navigator.userAgent.match(/(?:Trident.*rv[ :]?11\.|msie)/i)&&(a=X.createElement("x"),a.style.cssText="pointer-events:auto","auto"===a.style.pointerEvents)}(),ea=!1,fa=Math.abs,ga=Math.min,ha=[],ia=[],ja=s(function(a,b,c){if(c&&b.scroll){var d,e,f,g,h,i,j=c[V],k=b.scrollSensitivity,l=b.scrollSpeed,m=a.clientX,n=a.clientY,o=window.innerWidth,p=window.innerHeight;if(G!==c&&(F=b.scroll,G=c,H=b.scrollFn,F===!0)){F=c;do if(F.offsetWidth-1:e==a)}}var c={},d=a.group;d&&"object"==typeof d||(d={name:d}),c.name=d.name,c.checkPull=b(d.pull,!0),c.checkPut=b(d.put),c.revertClone=d.revertClone,a.group=c};try{window.addEventListener("test",null,Object.defineProperty({},"passive",{get:function(){ba=!1,aa={capture:!1,passive:ba}}}))}catch(a){}return a.prototype={constructor:a,_onTapStart:function(a){var b,d=this,e=this.el,f=this.options,g=f.preventOnFilter,h=a.type,i=a.touches&&a.touches[0],j=(i||a).target,l=a.target.shadowRoot&&a.path&&a.path[0]||j,m=f.filter;if(v(e),!y&&!(/mousedown|pointerdown/.test(h)&&0!==a.button||f.disabled)&&!l.isContentEditable&&(j=c(j,f.draggable,e),j&&E!==j)){if(b=q(j,f.draggable),"function"==typeof m){if(m.call(this,a,j,this))return k(d,l,"filter",j,e,e,b),void(g&&a.preventDefault())}else if(m&&(m=m.split(",").some(function(a){if(a=c(l,a.trim(),e))return k(d,a,"filter",j,e,e,b),!0})))return void(g&&a.preventDefault());f.handle&&!c(l,f.handle,e)||this._prepareDragStart(a,i,j,b)}},_prepareDragStart:function(a,b,c,d){var e,g=this,i=g.el,l=g.options,n=i.ownerDocument;c&&!y&&c.parentNode===i&&(P=a,C=i,y=c,z=y.parentNode,D=y.nextSibling,E=c,N=l.group,L=d,this._lastX=(b||a).clientX,this._lastY=(b||a).clientY,y.style["will-change"]="all",e=function(){g._disableDelayedDrag(),y.draggable=g.nativeDraggable,h(y,l.chosenClass,!0),g._triggerDragStart(a,b),k(g,C,"choose",y,C,C,L)},l.ignore.split(",").forEach(function(a){j(y,a.trim(),m)}),f(n,"mouseup",g._onDrop),f(n,"touchend",g._onDrop),f(n,"touchcancel",g._onDrop),f(n,"selectstart",g),l.supportPointer&&f(n,"pointercancel",g._onDrop),l.delay?(f(n,"mouseup",g._disableDelayedDrag),f(n,"touchend",g._disableDelayedDrag),f(n,"touchcancel",g._disableDelayedDrag),f(n,"mousemove",g._disableDelayedDrag),f(n,"touchmove",g._disableDelayedDrag),l.supportPointer&&f(n,"pointermove",g._disableDelayedDrag),g._dragStartTimer=Z(e,l.delay)):e())},_disableDelayedDrag:function(){var a=this.el.ownerDocument;clearTimeout(this._dragStartTimer),g(a,"mouseup",this._disableDelayedDrag),g(a,"touchend",this._disableDelayedDrag),g(a,"touchcancel",this._disableDelayedDrag),g(a,"mousemove",this._disableDelayedDrag),g(a,"touchmove",this._disableDelayedDrag),g(a,"pointermove",this._disableDelayedDrag)},_triggerDragStart:function(a,b){b=b||("touch"==a.pointerType?a:null),b?(P={target:y,clientX:b.clientX,clientY:b.clientY},this._onDragStart(P,"touch")):this.nativeDraggable?(f(y,"dragend",this),f(C,"dragstart",this._onDragStart)):this._onDragStart(P,!0);try{X.selection?w(function(){X.selection.empty()}):window.getSelection().removeAllRanges()}catch(a){}},_dragStarted:function(){if(C&&y){var b=this.options;h(y,b.ghostClass,!0),h(y,b.dragClass,!1),a.active=this,k(this,C,"start",y,C,C,L)}else this._nulling()},_emulateDragOver:function(){if(Q){if(this._lastX===Q.clientX&&this._lastY===Q.clientY)return;this._lastX=Q.clientX,this._lastY=Q.clientY,da||i(A,"display","none");var a=X.elementFromPoint(Q.clientX,Q.clientY),b=a,c=ia.length;if(a&&a.shadowRoot&&(a=a.shadowRoot.elementFromPoint(Q.clientX,Q.clientY),b=a),b)do{if(b[V]){for(;c--;)ia[c]({clientX:Q.clientX,clientY:Q.clientY,target:a,rootEl:b});break}a=b}while(b=b.parentNode);da||i(A,"display","")}},_onTouchMove:function(b){if(P){var c=this.options,d=c.fallbackTolerance,e=c.fallbackOffset,f=b.touches?b.touches[0]:b,g=f.clientX-P.clientX+e.x,h=f.clientY-P.clientY+e.y,j=b.touches?"translate3d("+g+"px,"+h+"px,0)":"translate("+g+"px,"+h+"px)";if(!a.active){if(d&&ga(fa(f.clientX-this._lastX),fa(f.clientY-this._lastY))y.offsetWidth,x=e.offsetHeight>y.offsetHeight,E=(v?(d.clientX-g.left)/t:(d.clientY-g.top)/u)>.5,F=e.nextElementSibling,G=!1;if(v){var H=y.offsetTop,L=e.offsetTop;G=H===L?e.previousElementSibling===y&&!w||E&&w:e.previousElementSibling===y||y.previousElementSibling===e?(d.clientY-g.top)/u>.5:L>H}else r||(G=F!==y&&!x||E&&x);var M=l(C,j,y,f,e,g,d,G);M!==!1&&(1!==M&&M!==-1||(G=1===M),ea=!0,Z(n,30),b(p,q),y.contains(j)||(G&&!F?j.appendChild(y):e.parentNode.insertBefore(y,G?F:e)),z=y.parentNode,this._animate(f,y),this._animate(g,e))}}},_animate:function(a,b){var c=this.options.animation;if(c){var d=b.getBoundingClientRect();1===a.nodeType&&(a=a.getBoundingClientRect()),i(b,"transition","none"),i(b,"transform","translate3d("+(a.left-d.left)+"px,"+(a.top-d.top)+"px,0)"),b.offsetWidth,i(b,"transition","all "+c+"ms"),i(b,"transform","translate3d(0,0,0)"),clearTimeout(b.animated),b.animated=Z(function(){i(b,"transition",""),i(b,"transform",""),b.animated=!1},c)}},_offUpEvents:function(){var a=this.el.ownerDocument;g(X,"touchmove",this._onTouchMove),g(X,"pointermove",this._onTouchMove),g(a,"mouseup",this._onDrop),g(a,"touchend",this._onDrop),g(a,"pointerup",this._onDrop),g(a,"touchcancel",this._onDrop),g(a,"pointercancel",this._onDrop),g(a,"selectstart",this)},_onDrop:function(b){var c=this.el,d=this.options;clearInterval(this._loopId),clearInterval(S.pid),clearTimeout(this._dragStartTimer),x(this._cloneId),x(this._dragStartId),g(X,"mouseover",this),g(X,"mousemove",this._onTouchMove),this.nativeDraggable&&(g(X,"drop",this),g(c,"dragstart",this._onDragStart)),this._offUpEvents(),b&&(R&&(b.preventDefault(),!d.dropBubble&&b.stopPropagation()),A&&A.parentNode&&A.parentNode.removeChild(A),C!==z&&"clone"===a.active.lastPullMode||B&&B.parentNode&&B.parentNode.removeChild(B),y&&(this.nativeDraggable&&g(y,"dragend",this),m(y),y.style["will-change"]="",h(y,this.options.ghostClass,!1),h(y,this.options.chosenClass,!1),k(this,C,"unchoose",y,z,C,L),C!==z?(M=q(y,d.draggable),M>=0&&(k(null,z,"add",y,z,C,L,M),k(this,C,"remove",y,z,C,L,M),k(null,z,"sort",y,z,C,L,M),k(this,C,"sort",y,z,C,L,M))):y.nextSibling!==D&&(M=q(y,d.draggable),M>=0&&(k(this,C,"update",y,z,C,L,M),k(this,C,"sort",y,z,C,L,M))),a.active&&(null!=M&&M!==-1||(M=L),k(this,C,"end",y,z,C,L,M),this.save()))),this._nulling()},_nulling:function(){C=y=z=A=D=B=E=F=G=P=Q=R=M=I=J=O=N=a.active=null,ha.forEach(function(a){a.checked=!0}),ha.length=0},handleEvent:function(a){switch(a.type){case"drop":case"dragend":this._onDrop(a);break;case"dragover":case"dragenter":y&&(this._onDragOver(a),e(a));break;case"mouseover":this._onDrop(a);break;case"selectstart":a.preventDefault()}},toArray:function(){for(var a,b=[],d=this.el.children,e=0,f=d.length,g=this.options;e=l&&!c.tag&&(c.tag=b[0].match(/<([^>\s/]*)/)[1].toLowerCase()),1>=this.content_elem.children.length&&(a.data=this.html(b[0]+b[0]+b[0])),c.tag||(c.tag=this.content_elem.children[0].tagName.toLowerCase()), -this.getRowsHeight(b))},getRowsHeight:function(b){var a=this.options,c=a.item_height;a.cluster_height=0;if(b.length){b=this.content_elem.children;var d=b[Math.floor(b.length/2)];a.item_height=d.offsetHeight;"tr"==a.tag&&"collapse"!=m("borderCollapse",this.content_elem)&&(a.item_height+=parseInt(m("borderSpacing",this.content_elem),10)||0);"tr"!=a.tag&&(b=parseInt(m("marginTop",d),10)||0,d=parseInt(m("marginBottom",d),10)||0,a.item_height+=Math.max(b,d));a.block_height=a.item_height*a.rows_in_block; -a.rows_in_cluster=a.blocks_in_cluster*a.rows_in_block;a.cluster_height=a.blocks_in_cluster*a.block_height;return c!=a.item_height}},getClusterNum:function(){this.options.scroll_top=this.scroll_elem.scrollTop;return Math.floor(this.options.scroll_top/(this.options.cluster_height-this.options.block_height))||0},generateEmptyRow:function(){var b=this.options;if(!b.tag||!b.show_no_data_row)return[];var a=document.createElement(b.tag),c=document.createTextNode(b.no_data_text);a.className=b.no_data_class; -if("tr"==b.tag){var d=document.createElement("td");d.colSpan=100;d.appendChild(c)}a.appendChild(d||c);return[a.outerHTML]},generate:function(b,a){var c=this.options,d=b.length;if(de&&g++;f=l&&"tr"==this.options.tag){var c=document.createElement("div");for(c.innerHTML=""+b+"
";b=a.lastChild;)a.removeChild(b);for(c=this.getChildNodes(c.firstChild.firstChild);c.length;)a.appendChild(c.shift())}else a.innerHTML=b},getChildNodes:function(b){b=b.children;for(var a=[],c=0,d=b.length;c { - return typeof expr === 'string' ? - Array.from((con || document).querySelectorAll(expr)) : - expr || null; - }; - - $.create = (tag, o) => { - let element = document.createElement(tag); - - for (let i in o) { - let val = o[i]; - - if (i === 'inside') { - $(val).appendChild(element); - } else - if (i === 'around') { - let ref = $(val); - ref.parentNode.insertBefore(element, ref); - element.appendChild(ref); - } else - if (i === 'styles') { - if (typeof val === 'object') { - Object.keys(val).map(prop => { - element.style[prop] = val[prop]; - }); - } - } else - if (i in element) { - element[i] = val; - } else { - element.setAttribute(i, val); - } - } - - return element; - }; - - $.on = (element, event, selector, callback) => { - if (!callback) { - callback = selector; - $.bind(element, event, callback); - } else { - $.delegate(element, event, selector, callback); - } - }; - - $.off = (element, event, handler) => { - element.removeEventListener(event, handler); - }; - - $.bind = (element, event, callback) => { - event.split(/\s+/).forEach(function (event) { - element.addEventListener(event, callback); - }); - }; - - $.delegate = (element, event, selector, callback) => { - element.addEventListener(event, function (e) { - const delegatedTarget = e.target.closest(selector); - if (delegatedTarget) { - e.delegatedTarget = delegatedTarget; - callback.call(this, e, delegatedTarget); - } - }); - }; - - $.unbind = (element, o) => { - if (element) { - for (let event in o) { - let callback = o[event]; - - event.split(/\s+/).forEach(function (event) { - element.removeEventListener(event, callback); - }); - } - } - }; - - $.fire = (target, type, properties) => { - let evt = document.createEvent('HTMLEvents'); - - evt.initEvent(type, true, true); - - for (let j in properties) { - evt[j] = properties[j]; - } - - return target.dispatchEvent(evt); - }; - - $.data = (element, attrs) => { // eslint-disable-line - if (!attrs) { - return element.dataset; - } - - for (const attr in attrs) { - element.dataset[attr] = attrs[attr]; - } - }; - - $.style = (elements, styleMap) => { // eslint-disable-line - - if (typeof styleMap === 'string') { - return $.getStyle(elements, styleMap); - } - - if (!Array.isArray(elements)) { - elements = [elements]; - } - - elements.map(element => { - for (const prop in styleMap) { - element.style[prop] = styleMap[prop]; - } - }); - }; - - $.removeStyle = (elements, styleProps) => { - if (!Array.isArray(elements)) { - elements = [elements]; - } - - if (!Array.isArray(styleProps)) { - styleProps = [styleProps]; - } - - elements.map(element => { - for (const prop of styleProps) { - element.style[prop] = ''; - } - }); - }; - - $.getStyle = (element, prop) => { - let val = getComputedStyle(element)[prop]; - - if (['width', 'height'].includes(prop)) { - val = parseFloat(val); - } - - return val; - }; - - $.closest = (selector, element) => { - if (!element) return null; - - if (element.matches(selector)) { - return element; - } - - return $.closest(selector, element.parentNode); - }; - - $.inViewport = (el, parentEl) => { - const { - top, - left, - bottom, - right - } = el.getBoundingClientRect(); - const { - top: pTop, - left: pLeft, - bottom: pBottom, - right: pRight - } = parentEl.getBoundingClientRect(); - - return top >= pTop && left >= pLeft && bottom <= pBottom && right <= pRight; - }; - - $.scrollTop = function scrollTop(element, pixels) { - requestAnimationFrame(() => { - element.scrollTop = pixels; - }); - }; - - $.scrollbarWidth = function scrollbarWidth() { - // Create the measurement node - const scrollDiv = document.createElement('div'); - $.style(scrollDiv, { - width: '100px', - height: '100px', - overflow: 'scroll', - position: 'absolute', - top: '-9999px' - }); - document.body.appendChild(scrollDiv); - - // Get the scrollbar width - const scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth; - - // Delete the DIV - document.body.removeChild(scrollDiv); - - return scrollbarWidth; - }; - - /** - * Checks if `value` is the - * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) - * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an object, else `false`. - * @example - * - * _.isObject({}); - * // => true - * - * _.isObject([1, 2, 3]); - * // => true - * - * _.isObject(_.noop); - * // => true - * - * _.isObject(null); - * // => false - */ - function isObject(value) { - var type = typeof value; - return value != null && (type == 'object' || type == 'function'); - } - - var isObject_1 = isObject; - - var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; - - /** Detect free variable `global` from Node.js. */ - var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal; - - var _freeGlobal = freeGlobal; - - /** Detect free variable `self`. */ - var freeSelf = typeof self == 'object' && self && self.Object === Object && self; - - /** Used as a reference to the global object. */ - var root = _freeGlobal || freeSelf || Function('return this')(); - - var _root = root; - - /** - * Gets the timestamp of the number of milliseconds that have elapsed since - * the Unix epoch (1 January 1970 00:00:00 UTC). - * - * @static - * @memberOf _ - * @since 2.4.0 - * @category Date - * @returns {number} Returns the timestamp. - * @example - * - * _.defer(function(stamp) { - * console.log(_.now() - stamp); - * }, _.now()); - * // => Logs the number of milliseconds it took for the deferred invocation. - */ - var now = function() { - return _root.Date.now(); - }; - - var now_1 = now; - - /** Built-in value references. */ - var Symbol = _root.Symbol; - - var _Symbol = Symbol; - - /** Used for built-in method references. */ - var objectProto = Object.prototype; - - /** Used to check objects for own properties. */ - var hasOwnProperty = objectProto.hasOwnProperty; - - /** - * Used to resolve the - * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) - * of values. - */ - var nativeObjectToString = objectProto.toString; - - /** Built-in value references. */ - var symToStringTag = _Symbol ? _Symbol.toStringTag : undefined; - - /** - * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values. - * - * @private - * @param {*} value The value to query. - * @returns {string} Returns the raw `toStringTag`. - */ - function getRawTag(value) { - var isOwn = hasOwnProperty.call(value, symToStringTag), - tag = value[symToStringTag]; - - try { - value[symToStringTag] = undefined; - } catch (e) {} - - var result = nativeObjectToString.call(value); - { - if (isOwn) { - value[symToStringTag] = tag; - } else { - delete value[symToStringTag]; - } - } - return result; - } - - var _getRawTag = getRawTag; - - /** Used for built-in method references. */ - var objectProto$1 = Object.prototype; - - /** - * Used to resolve the - * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) - * of values. - */ - var nativeObjectToString$1 = objectProto$1.toString; - - /** - * Converts `value` to a string using `Object.prototype.toString`. - * - * @private - * @param {*} value The value to convert. - * @returns {string} Returns the converted string. - */ - function objectToString(value) { - return nativeObjectToString$1.call(value); - } - - var _objectToString = objectToString; - - /** `Object#toString` result references. */ - var nullTag = '[object Null]', - undefinedTag = '[object Undefined]'; - - /** Built-in value references. */ - var symToStringTag$1 = _Symbol ? _Symbol.toStringTag : undefined; - - /** - * The base implementation of `getTag` without fallbacks for buggy environments. - * - * @private - * @param {*} value The value to query. - * @returns {string} Returns the `toStringTag`. - */ - function baseGetTag(value) { - if (value == null) { - return value === undefined ? undefinedTag : nullTag; - } - return (symToStringTag$1 && symToStringTag$1 in Object(value)) - ? _getRawTag(value) - : _objectToString(value); - } - - var _baseGetTag = baseGetTag; - - /** - * Checks if `value` is object-like. A value is object-like if it's not `null` - * and has a `typeof` result of "object". - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is object-like, else `false`. - * @example - * - * _.isObjectLike({}); - * // => true - * - * _.isObjectLike([1, 2, 3]); - * // => true - * - * _.isObjectLike(_.noop); - * // => false - * - * _.isObjectLike(null); - * // => false - */ - function isObjectLike(value) { - return value != null && typeof value == 'object'; - } - - var isObjectLike_1 = isObjectLike; - - /** `Object#toString` result references. */ - var symbolTag = '[object Symbol]'; - - /** - * Checks if `value` is classified as a `Symbol` primitive or object. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a symbol, else `false`. - * @example - * - * _.isSymbol(Symbol.iterator); - * // => true - * - * _.isSymbol('abc'); - * // => false - */ - function isSymbol(value) { - return typeof value == 'symbol' || - (isObjectLike_1(value) && _baseGetTag(value) == symbolTag); - } - - var isSymbol_1 = isSymbol; - - /** Used as references for various `Number` constants. */ - var NAN = 0 / 0; - - /** Used to match leading and trailing whitespace. */ - var reTrim = /^\s+|\s+$/g; - - /** Used to detect bad signed hexadecimal string values. */ - var reIsBadHex = /^[-+]0x[0-9a-f]+$/i; - - /** Used to detect binary string values. */ - var reIsBinary = /^0b[01]+$/i; - - /** Used to detect octal string values. */ - var reIsOctal = /^0o[0-7]+$/i; - - /** Built-in method references without a dependency on `root`. */ - var freeParseInt = parseInt; - - /** - * Converts `value` to a number. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to process. - * @returns {number} Returns the number. - * @example - * - * _.toNumber(3.2); - * // => 3.2 - * - * _.toNumber(Number.MIN_VALUE); - * // => 5e-324 - * - * _.toNumber(Infinity); - * // => Infinity - * - * _.toNumber('3.2'); - * // => 3.2 - */ - function toNumber(value) { - if (typeof value == 'number') { - return value; - } - if (isSymbol_1(value)) { - return NAN; - } - if (isObject_1(value)) { - var other = typeof value.valueOf == 'function' ? value.valueOf() : value; - value = isObject_1(other) ? (other + '') : other; - } - if (typeof value != 'string') { - return value === 0 ? value : +value; - } - value = value.replace(reTrim, ''); - var isBinary = reIsBinary.test(value); - return (isBinary || reIsOctal.test(value)) - ? freeParseInt(value.slice(2), isBinary ? 2 : 8) - : (reIsBadHex.test(value) ? NAN : +value); - } - - var toNumber_1 = toNumber; - - /** Error message constants. */ - var FUNC_ERROR_TEXT = 'Expected a function'; - - /* Built-in method references for those with the same name as other `lodash` methods. */ - var nativeMax = Math.max, - nativeMin = Math.min; - - /** - * Creates a debounced function that delays invoking `func` until after `wait` - * milliseconds have elapsed since the last time the debounced function was - * invoked. The debounced function comes with a `cancel` method to cancel - * delayed `func` invocations and a `flush` method to immediately invoke them. - * Provide `options` to indicate whether `func` should be invoked on the - * leading and/or trailing edge of the `wait` timeout. The `func` is invoked - * with the last arguments provided to the debounced function. Subsequent - * calls to the debounced function return the result of the last `func` - * invocation. - * - * **Note:** If `leading` and `trailing` options are `true`, `func` is - * invoked on the trailing edge of the timeout only if the debounced function - * is invoked more than once during the `wait` timeout. - * - * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred - * until to the next tick, similar to `setTimeout` with a timeout of `0`. - * - * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/) - * for details over the differences between `_.debounce` and `_.throttle`. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Function - * @param {Function} func The function to debounce. - * @param {number} [wait=0] The number of milliseconds to delay. - * @param {Object} [options={}] The options object. - * @param {boolean} [options.leading=false] - * Specify invoking on the leading edge of the timeout. - * @param {number} [options.maxWait] - * The maximum time `func` is allowed to be delayed before it's invoked. - * @param {boolean} [options.trailing=true] - * Specify invoking on the trailing edge of the timeout. - * @returns {Function} Returns the new debounced function. - * @example - * - * // Avoid costly calculations while the window size is in flux. - * jQuery(window).on('resize', _.debounce(calculateLayout, 150)); - * - * // Invoke `sendMail` when clicked, debouncing subsequent calls. - * jQuery(element).on('click', _.debounce(sendMail, 300, { - * 'leading': true, - * 'trailing': false - * })); - * - * // Ensure `batchLog` is invoked once after 1 second of debounced calls. - * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 }); - * var source = new EventSource('/stream'); - * jQuery(source).on('message', debounced); - * - * // Cancel the trailing debounced invocation. - * jQuery(window).on('popstate', debounced.cancel); - */ - function debounce(func, wait, options) { - var lastArgs, - lastThis, - maxWait, - result, - timerId, - lastCallTime, - lastInvokeTime = 0, - leading = false, - maxing = false, - trailing = true; - - if (typeof func != 'function') { - throw new TypeError(FUNC_ERROR_TEXT); - } - wait = toNumber_1(wait) || 0; - if (isObject_1(options)) { - leading = !!options.leading; - maxing = 'maxWait' in options; - maxWait = maxing ? nativeMax(toNumber_1(options.maxWait) || 0, wait) : maxWait; - trailing = 'trailing' in options ? !!options.trailing : trailing; - } - - function invokeFunc(time) { - var args = lastArgs, - thisArg = lastThis; - - lastArgs = lastThis = undefined; - lastInvokeTime = time; - result = func.apply(thisArg, args); - return result; - } - - function leadingEdge(time) { - // Reset any `maxWait` timer. - lastInvokeTime = time; - // Start the timer for the trailing edge. - timerId = setTimeout(timerExpired, wait); - // Invoke the leading edge. - return leading ? invokeFunc(time) : result; - } - - function remainingWait(time) { - var timeSinceLastCall = time - lastCallTime, - timeSinceLastInvoke = time - lastInvokeTime, - timeWaiting = wait - timeSinceLastCall; - - return maxing - ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) - : timeWaiting; - } - - function shouldInvoke(time) { - var timeSinceLastCall = time - lastCallTime, - timeSinceLastInvoke = time - lastInvokeTime; - - // Either this is the first call, activity has stopped and we're at the - // trailing edge, the system time has gone backwards and we're treating - // it as the trailing edge, or we've hit the `maxWait` limit. - return (lastCallTime === undefined || (timeSinceLastCall >= wait) || - (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait)); - } - - function timerExpired() { - var time = now_1(); - if (shouldInvoke(time)) { - return trailingEdge(time); - } - // Restart the timer. - timerId = setTimeout(timerExpired, remainingWait(time)); - } - - function trailingEdge(time) { - timerId = undefined; - - // Only invoke if we have `lastArgs` which means `func` has been - // debounced at least once. - if (trailing && lastArgs) { - return invokeFunc(time); - } - lastArgs = lastThis = undefined; - return result; - } - - function cancel() { - if (timerId !== undefined) { - clearTimeout(timerId); - } - lastInvokeTime = 0; - lastArgs = lastCallTime = lastThis = timerId = undefined; - } - - function flush() { - return timerId === undefined ? result : trailingEdge(now_1()); - } - - function debounced() { - var time = now_1(), - isInvoking = shouldInvoke(time); - - lastArgs = arguments; - lastThis = this; - lastCallTime = time; - - if (isInvoking) { - if (timerId === undefined) { - return leadingEdge(lastCallTime); - } - if (maxing) { - // Handle invocations in a tight loop. - timerId = setTimeout(timerExpired, wait); - return invokeFunc(lastCallTime); - } - } - if (timerId === undefined) { - timerId = setTimeout(timerExpired, wait); - } - return result; - } - debounced.cancel = cancel; - debounced.flush = flush; - return debounced; - } - - var debounce_1 = debounce; - - /** Error message constants. */ - var FUNC_ERROR_TEXT$1 = 'Expected a function'; - - /** - * Creates a throttled function that only invokes `func` at most once per - * every `wait` milliseconds. The throttled function comes with a `cancel` - * method to cancel delayed `func` invocations and a `flush` method to - * immediately invoke them. Provide `options` to indicate whether `func` - * should be invoked on the leading and/or trailing edge of the `wait` - * timeout. The `func` is invoked with the last arguments provided to the - * throttled function. Subsequent calls to the throttled function return the - * result of the last `func` invocation. - * - * **Note:** If `leading` and `trailing` options are `true`, `func` is - * invoked on the trailing edge of the timeout only if the throttled function - * is invoked more than once during the `wait` timeout. - * - * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred - * until to the next tick, similar to `setTimeout` with a timeout of `0`. - * - * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/) - * for details over the differences between `_.throttle` and `_.debounce`. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Function - * @param {Function} func The function to throttle. - * @param {number} [wait=0] The number of milliseconds to throttle invocations to. - * @param {Object} [options={}] The options object. - * @param {boolean} [options.leading=true] - * Specify invoking on the leading edge of the timeout. - * @param {boolean} [options.trailing=true] - * Specify invoking on the trailing edge of the timeout. - * @returns {Function} Returns the new throttled function. - * @example - * - * // Avoid excessively updating the position while scrolling. - * jQuery(window).on('scroll', _.throttle(updatePosition, 100)); - * - * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes. - * var throttled = _.throttle(renewToken, 300000, { 'trailing': false }); - * jQuery(element).on('click', throttled); - * - * // Cancel the trailing throttled invocation. - * jQuery(window).on('popstate', throttled.cancel); - */ - function throttle(func, wait, options) { - var leading = true, - trailing = true; - - if (typeof func != 'function') { - throw new TypeError(FUNC_ERROR_TEXT$1); - } - if (isObject_1(options)) { - leading = 'leading' in options ? !!options.leading : leading; - trailing = 'trailing' in options ? !!options.trailing : trailing; - } - return debounce_1(func, wait, { - 'leading': leading, - 'maxWait': wait, - 'trailing': trailing - }); - } - - var throttle_1 = throttle; - - function camelCaseToDash(str) { - return str.replace(/([A-Z])/g, (g) => `-${g[0].toLowerCase()}`); - } - - function makeDataAttributeString(props) { - const keys = Object.keys(props); - - return keys - .map((key) => { - const _key = camelCaseToDash(key); - const val = props[key]; - - if (val === undefined) return ''; - return `data-${_key}="${val}" `; - }) - .join('') - .trim(); - } - - function copyTextToClipboard(text) { - // https://stackoverflow.com/a/30810322/5353542 - var textArea = document.createElement('textarea'); - - // - // *** This styling is an extra step which is likely not required. *** - // - // Why is it here? To ensure: - // 1. the element is able to have focus and selection. - // 2. if element was to flash render it has minimal visual impact. - // 3. less flakyness with selection and copying which **might** occur if - // the textarea element is not visible. - // - // The likelihood is the element won't even render, not even a flash, - // so some of these are just precautions. However in IE the element - // is visible whilst the popup box asking the user for permission for - // the web page to copy to the clipboard. - // - - // Place in top-left corner of screen regardless of scroll position. - textArea.style.position = 'fixed'; - textArea.style.top = 0; - textArea.style.left = 0; - - // Ensure it has a small width and height. Setting to 1px / 1em - // doesn't work as this gives a negative w/h on some browsers. - textArea.style.width = '2em'; - textArea.style.height = '2em'; - - // We don't need padding, reducing the size if it does flash render. - textArea.style.padding = 0; - - // Clean up any borders. - textArea.style.border = 'none'; - textArea.style.outline = 'none'; - textArea.style.boxShadow = 'none'; - - // Avoid flash of white box if rendered for any reason. - textArea.style.background = 'transparent'; - - textArea.value = text; - - document.body.appendChild(textArea); - - textArea.select(); - - try { - document.execCommand('copy'); - } catch (err) { - console.log('Oops, unable to copy'); - } - - document.body.removeChild(textArea); - } - - function isNumeric(val) { - return !isNaN(val); - } - - let throttle$1 = throttle_1; - - let debounce$1 = debounce_1; - - function nextTick(fn, context = null) { - return (...args) => { - return new Promise(resolve => { - const execute = () => { - const out = fn.apply(context, args); - resolve(out); - }; - setTimeout(execute); - }); - }; - } - function linkProperties(target, source, properties) { - const props = properties.reduce((acc, prop) => { - acc[prop] = { - get() { - return source[prop]; - } - }; - return acc; - }, {}); - Object.defineProperties(target, props); - } - function isSet(val) { - return val !== undefined || val !== null; - } - - function notSet(val) { - return !isSet(val); - } - - function isNumber(val) { - return !isNaN(val); - } - - function ensureArray(val) { - if (!Array.isArray(val)) { - return [val]; - } - return val; - } - - class DataManager { - constructor(options) { - this.options = options; - this.sortRows = nextTick(this.sortRows, this); - this.switchColumn = nextTick(this.switchColumn, this); - this.removeColumn = nextTick(this.removeColumn, this); - this.filterRows = nextTick(this.filterRows, this); - } - - init(data, columns) { - if (!data) { - data = this.options.data; - } - if (columns) { - this.options.columns = columns; - } - - this.data = data; - - this.rowCount = 0; - this.columns = []; - this.rows = []; - - this.prepareColumns(); - this.prepareRows(); - this.prepareTreeRows(); - this.prepareRowView(); - - this.prepareNumericColumns(); - } - - // computed property - get currentSort() { - const col = this.columns.find(col => col.sortOrder !== 'none'); - return col || { - colIndex: -1, - sortOrder: 'none' - }; - } - - prepareColumns() { - this.columns = []; - this.validateColumns(); - this.prepareDefaultColumns(); - this.prepareHeader(); - } - - prepareDefaultColumns() { - if (this.options.checkboxColumn && !this.hasColumnById('_checkbox')) { - const cell = { - id: '_checkbox', - content: this.getCheckboxHTML(), - editable: false, - resizable: false, - sortable: false, - focusable: false, - dropdown: false, - width: 32 - }; - this.columns.push(cell); - } - - if (this.options.serialNoColumn && !this.hasColumnById('_rowIndex')) { - let cell = { - id: '_rowIndex', - content: '', - align: 'center', - editable: false, - resizable: false, - focusable: false, - dropdown: false - }; - - this.columns.push(cell); - } - } - - prepareHeader() { - let columns = this.columns.concat(this.options.columns); - const baseCell = { - isHeader: 1, - editable: true, - sortable: true, - resizable: true, - focusable: true, - dropdown: true, - width: null, - format: (value) => { - if (value === null || value === undefined) { - return ''; - } - return value + ''; - } - }; - - this.columns = columns - .map((cell, i) => this.prepareCell(cell, i)) - .map(col => Object.assign({}, baseCell, col)) - .map(col => { - col.content = col.content || col.name || ''; - col.id = col.id || col.content; - return col; - }); - } - - prepareCell(content, i) { - const cell = { - content: '', - sortOrder: 'none', - colIndex: i, - column: this.columns[i] - }; - - if (content !== null && typeof content === 'object') { - // passed as column/header - Object.assign(cell, content); - } else { - cell.content = content; - } - - return cell; - } - - prepareNumericColumns() { - const row0 = this.getRow(0); - if (!row0) return; - this.columns = this.columns.map((column, i) => { - - const cellValue = row0[i].content; - if (!column.align && cellValue && isNumeric(cellValue)) { - column.align = 'right'; - } - - return column; - }); - } - - prepareRows() { - this.validateData(this.data); - - this.rows = this.data.map((d, i) => { - const index = this._getNextRowCount(); - - let row = []; - let meta = { - rowIndex: index - }; - - if (Array.isArray(d)) { - // row is an array - if (this.options.checkboxColumn) { - row.push(this.getCheckboxHTML()); - } - if (this.options.serialNoColumn) { - row.push((index + 1) + ''); - } - row = row.concat(d); - - while (row.length < this.columns.length) { - row.push(''); - } - - } else { - // row is an object - for (let col of this.columns) { - if (col.id === '_checkbox') { - row.push(this.getCheckboxHTML()); - } else if (col.id === '_rowIndex') { - row.push((index + 1) + ''); - } else { - row.push(d[col.id]); - } - } - - meta.indent = d.indent || 0; - } - - return this.prepareRow(row, meta); - }); - } - - prepareTreeRows() { - this.rows.forEach((row, i) => { - if (isNumber(row.meta.indent)) { - // if (i === 36) debugger; - const nextRow = this.getRow(i + 1); - row.meta.isLeaf = !nextRow || - notSet(nextRow.meta.indent) || - nextRow.meta.indent <= row.meta.indent; - } - }); - } - - prepareRowView() { - // This is order in which rows will be rendered in the table. - // When sorting happens, only this.rowViewOrder will change - // and not the original this.rows - this.rowViewOrder = this.rows.map(row => row.meta.rowIndex); - } - - prepareRow(row, meta) { - const baseRowCell = { - rowIndex: meta.rowIndex, - indent: meta.indent - }; - - row = row - .map((cell, i) => this.prepareCell(cell, i)) - .map(cell => Object.assign({}, baseRowCell, cell)); - - // monkey patched in array object - row.meta = meta; - return row; - } - - validateColumns() { - const columns = this.options.columns; - if (!Array.isArray(columns)) { - throw new DataError('`columns` must be an array'); - } - - columns.forEach((column, i) => { - if (typeof column !== 'string' && typeof column !== 'object') { - throw new DataError(`column "${i}" must be a string or an object`); - } - }); - } - - validateData(data) { - if (Array.isArray(data) && - (data.length === 0 || Array.isArray(data[0]) || typeof data[0] === 'object')) { - return true; - } - throw new DataError('`data` must be an array of arrays or objects'); - } - - appendRows(rows) { - this.validateData(rows); - - this.rows.push(...this.prepareRows(rows)); - } - - sortRows(colIndex, sortOrder = 'none') { - colIndex = +colIndex; - - // reset sortOrder and update for colIndex - this.getColumns() - .map(col => { - if (col.colIndex === colIndex) { - col.sortOrder = sortOrder; - } else { - col.sortOrder = 'none'; - } - }); - - this._sortRows(colIndex, sortOrder); - } - - _sortRows(colIndex, sortOrder) { - - if (this.currentSort.colIndex === colIndex) { - // reverse the array if only sortOrder changed - if ( - (this.currentSort.sortOrder === 'asc' && sortOrder === 'desc') || - (this.currentSort.sortOrder === 'desc' && sortOrder === 'asc') - ) { - this.reverseArray(this.rowViewOrder); - this.currentSort.sortOrder = sortOrder; - return; - } - } - - this.rowViewOrder.sort((a, b) => { - const aIndex = a; - const bIndex = b; - const aContent = this.getCell(colIndex, a).content; - const bContent = this.getCell(colIndex, b).content; - - if (sortOrder === 'none') { - return aIndex - bIndex; - } else if (sortOrder === 'asc') { - if (aContent < bContent) return -1; - if (aContent > bContent) return 1; - if (aContent === bContent) return 0; - } else if (sortOrder === 'desc') { - if (aContent < bContent) return 1; - if (aContent > bContent) return -1; - if (aContent === bContent) return 0; - } - return 0; - }); - - if (this.hasColumnById('_rowIndex')) { - // update row index - const srNoColIndex = this.getColumnIndexById('_rowIndex'); - this.rows.forEach((row, index) => { - const viewIndex = this.rowViewOrder.indexOf(index); - const cell = row[srNoColIndex]; - cell.content = (viewIndex + 1) + ''; - }); - } - } - - reverseArray(array) { - let left = null; - let right = null; - let length = array.length; - - for (left = 0, right = length - 1; left < right; left += 1, right -= 1) { - const temporary = array[left]; - - array[left] = array[right]; - array[right] = temporary; - } - } - - switchColumn(index1, index2) { - // update columns - const temp = this.columns[index1]; - this.columns[index1] = this.columns[index2]; - this.columns[index2] = temp; - - this.columns[index1].colIndex = index1; - this.columns[index2].colIndex = index2; - - // update rows - this.rows.forEach(row => { - const newCell1 = Object.assign({}, row[index1], { - colIndex: index2 - }); - const newCell2 = Object.assign({}, row[index2], { - colIndex: index1 - }); - - row[index2] = newCell1; - row[index1] = newCell2; - }); - } - - removeColumn(index) { - index = +index; - const filter = cell => cell.colIndex !== index; - const map = (cell, i) => Object.assign({}, cell, { - colIndex: i - }); - // update columns - this.columns = this.columns - .filter(filter) - .map(map); - - // update rows - this.rows.forEach(row => { - // remove cell - row.splice(index, 1); - // update colIndex - row.forEach((cell, i) => { - cell.colIndex = i; - }); - }); - } - - updateRow(row, rowIndex) { - if (row.length < this.columns.length) { - if (this.hasColumnById('_rowIndex')) { - const val = (rowIndex + 1) + ''; - - row = [val].concat(row); - } - - if (this.hasColumnById('_checkbox')) { - const val = ''; - - row = [val].concat(row); - } - } - - const _row = this.prepareRow(row, {rowIndex}); - const index = this.rows.findIndex(row => row[0].rowIndex === rowIndex); - this.rows[index] = _row; - - return _row; - } - - updateCell(colIndex, rowIndex, options) { - let cell; - if (typeof colIndex === 'object') { - // cell object was passed, - // must have colIndex, rowIndex - cell = colIndex; - colIndex = cell.colIndex; - rowIndex = cell.rowIndex; - // the object passed must be merged with original cell - options = cell; - } - cell = this.getCell(colIndex, rowIndex); - - // mutate object directly - for (let key in options) { - const newVal = options[key]; - if (newVal !== undefined) { - cell[key] = newVal; - } - } - - return cell; - } - - updateColumn(colIndex, keyValPairs) { - const column = this.getColumn(colIndex); - for (let key in keyValPairs) { - const newVal = keyValPairs[key]; - if (newVal !== undefined) { - column[key] = newVal; - } - } - return column; - } - - filterRows(keyword, colIndex) { - let rowsToHide = []; - let rowsToShow = []; - const cells = this.rows.map(row => row[colIndex]); - - cells.forEach(cell => { - const hay = String(cell.content || '').toLowerCase(); - const needle = (keyword || '').toLowerCase(); - - if (!needle || hay.includes(needle)) { - rowsToShow.push(cell.rowIndex); - } else { - rowsToHide.push(cell.rowIndex); - } - }); - - this._filteredRows = rowsToShow; - - return { - rowsToHide, - rowsToShow - }; - } - - getFilteredRowIndices() { - return this._filteredRows || this.rows.map(row => row.meta.rowIndex); - } - - getRowCount() { - return this.rowCount; - } - - _getNextRowCount() { - const val = this.rowCount; - - this.rowCount++; - return val; - } - - getRows(start, end) { - return this.rows.slice(start, end); - } - - getRowsForView(start, end) { - const rows = this.rowViewOrder.map(i => this.rows[i]); - return rows.slice(start, end); - } - - getColumns(skipStandardColumns) { - let columns = this.columns; - - if (skipStandardColumns) { - columns = columns.slice(this.getStandardColumnCount()); - } - - return columns; - } - - getStandardColumnCount() { - if (this.options.checkboxColumn && this.options.serialNoColumn) { - return 2; - } - - if (this.options.checkboxColumn || this.options.serialNoColumn) { - return 1; - } - - return 0; - } - - getColumnCount(skipStandardColumns) { - let val = this.columns.length; - - if (skipStandardColumns) { - val = val - this.getStandardColumnCount(); - } - - return val; - } - - getColumn(colIndex) { - colIndex = +colIndex; - - if (colIndex < 0) { - // negative indexes - colIndex = this.columns.length + colIndex; - } - - return this.columns.find(col => col.colIndex === colIndex); - } - - getColumnById(id) { - return this.columns.find(col => col.id === id); - } - - getRow(rowIndex) { - rowIndex = +rowIndex; - return this.rows[rowIndex]; - } - - getCell(colIndex, rowIndex) { - rowIndex = +rowIndex; - colIndex = +colIndex; - return this.getRow(rowIndex)[colIndex]; - } - - getChildren(parentRowIndex) { - parentRowIndex = +parentRowIndex; - const parentIndent = this.getRow(parentRowIndex).meta.indent; - const out = []; - - for (let i = parentRowIndex + 1; i < this.rowCount; i++) { - const row = this.getRow(i); - if (isNaN(row.meta.indent)) continue; - - if (row.meta.indent > parentIndent) { - out.push(i); - } - - if (row.meta.indent === parentIndent) { - break; - } - } - - return out; - } - - getImmediateChildren(parentRowIndex) { - parentRowIndex = +parentRowIndex; - const parentIndent = this.getRow(parentRowIndex).meta.indent; - const out = []; - const childIndent = parentIndent + 1; - - for (let i = parentRowIndex + 1; i < this.rowCount; i++) { - const row = this.getRow(i); - if (isNaN(row.meta.indent) || row.meta.indent > childIndent) continue; - - if (row.meta.indent === childIndent) { - out.push(i); - } - - if (row.meta.indent === parentIndent) { - break; - } - } - - return out; - } - - get() { - return { - columns: this.columns, - rows: this.rows - }; - } - - /** - * Returns the original data which was passed - * based on rowIndex - * @param {Number} rowIndex - * @returns Array|Object - * @memberof DataManager - */ - getData(rowIndex) { - return this.data[rowIndex]; - } - - hasColumn(name) { - return Boolean(this.columns.find(col => col.content === name)); - } - - hasColumnById(id) { - return Boolean(this.columns.find(col => col.id === id)); - } - - getColumnIndex(name) { - return this.columns.findIndex(col => col.content === name); - } - - getColumnIndexById(id) { - return this.columns.findIndex(col => col.id === id); - } - - getCheckboxHTML() { - return ''; - } - } - - // Custom Errors - class DataError extends TypeError {} - - class CellManager { - constructor(instance) { - this.instance = instance; - linkProperties(this, this.instance, [ - 'wrapper', - 'options', - 'style', - 'bodyScrollable', - 'columnmanager', - 'rowmanager', - 'datamanager', - 'keyboard' - ]); - - this.bindEvents(); - } - - bindEvents() { - this.bindFocusCell(); - this.bindEditCell(); - this.bindKeyboardSelection(); - this.bindCopyCellContents(); - this.bindMouseEvents(); - this.bindTreeEvents(); - } - - bindFocusCell() { - this.bindKeyboardNav(); - } - - bindEditCell() { - this.$editingCell = null; - - $.on(this.bodyScrollable, 'dblclick', '.dt-cell', (e, cell) => { - this.activateEditing(cell); - }); - - this.keyboard.on('enter', () => { - if (this.$focusedCell && !this.$editingCell) { - // enter keypress on focused cell - this.activateEditing(this.$focusedCell); - } else if (this.$editingCell) { - // enter keypress on editing cell - this.submitEditing(); - this.deactivateEditing(); - } - }); - } - - bindKeyboardNav() { - const focusCell = (direction) => { - if (!this.$focusedCell || this.$editingCell) { - return false; - } - - let $cell = this.$focusedCell; - - if (direction === 'left' || direction === 'shift+tab') { - $cell = this.getLeftCell$($cell); - } else if (direction === 'right' || direction === 'tab') { - $cell = this.getRightCell$($cell); - } else if (direction === 'up') { - $cell = this.getAboveCell$($cell); - } else if (direction === 'down') { - $cell = this.getBelowCell$($cell); - } - - this.focusCell($cell); - return true; - }; - - const focusLastCell = (direction) => { - if (!this.$focusedCell || this.$editingCell) { - return false; - } - - let $cell = this.$focusedCell; - const { - rowIndex, - colIndex - } = $.data($cell); - - if (direction === 'left') { - $cell = this.getLeftMostCell$(rowIndex); - } else if (direction === 'right') { - $cell = this.getRightMostCell$(rowIndex); - } else if (direction === 'up') { - $cell = this.getTopMostCell$(colIndex); - } else if (direction === 'down') { - $cell = this.getBottomMostCell$(colIndex); - } - - this.focusCell($cell); - return true; - }; - - ['left', 'right', 'up', 'down', 'tab', 'shift+tab'] - .map(direction => this.keyboard.on(direction, () => focusCell(direction))); - - ['left', 'right', 'up', 'down'] - .map(direction => this.keyboard.on(`ctrl+${direction}`, () => focusLastCell(direction))); - - this.keyboard.on('esc', () => { - this.deactivateEditing(); - }); - - if (this.options.inlineFilters) { - this.keyboard.on('ctrl+f', (e) => { - const $cell = $.closest('.dt-cell', e.target); - const { colIndex } = $.data($cell); - - this.activateFilter(colIndex); - return true; - }); - } - } - - bindKeyboardSelection() { - const getNextSelectionCursor = (direction) => { - let $selectionCursor = this.getSelectionCursor(); - - if (direction === 'left') { - $selectionCursor = this.getLeftCell$($selectionCursor); - } else if (direction === 'right') { - $selectionCursor = this.getRightCell$($selectionCursor); - } else if (direction === 'up') { - $selectionCursor = this.getAboveCell$($selectionCursor); - } else if (direction === 'down') { - $selectionCursor = this.getBelowCell$($selectionCursor); - } - - return $selectionCursor; - }; - - ['left', 'right', 'up', 'down'] - .map(direction => - this.keyboard.on(`shift+${direction}`, () => this.selectArea(getNextSelectionCursor(direction)))); - } - - bindCopyCellContents() { - this.keyboard.on('ctrl+c', () => { - const noOfCellsCopied = this.copyCellContents(this.$focusedCell, this.$selectionCursor); - const message = `${noOfCellsCopied} cell${noOfCellsCopied > 1 ? 's' : ''} copied`; - if (noOfCellsCopied) { - this.instance.showToastMessage(message, 2); - } - }); - - if (this.options.pasteFromClipboard) { - this.keyboard.on('ctrl+v', (e) => { - // hack - // https://stackoverflow.com/a/2177059/5353542 - this.instance.pasteTarget.focus(); - - setTimeout(() => { - const data = this.instance.pasteTarget.value; - this.instance.pasteTarget.value = ''; - this.pasteContentInCell(data); - }, 10); - - return false; - }); - } - } - - bindMouseEvents() { - let mouseDown = null; - - $.on(this.bodyScrollable, 'mousedown', '.dt-cell', (e) => { - mouseDown = true; - this.focusCell($(e.delegatedTarget)); - }); - - $.on(this.bodyScrollable, 'mouseup', () => { - mouseDown = false; - }); - - const selectArea = (e) => { - if (!mouseDown) return; - this.selectArea($(e.delegatedTarget)); - }; - - $.on(this.bodyScrollable, 'mousemove', '.dt-cell', throttle$1(selectArea, 50)); - } - - bindTreeEvents() { - $.on(this.bodyScrollable, 'click', '.dt-tree-node__toggle', (e, $toggle) => { - const $cell = $.closest('.dt-cell', $toggle); - const { rowIndex } = $.data($cell); - - if ($cell.classList.contains('dt-cell--tree-close')) { - this.rowmanager.openSingleNode(rowIndex); - } else { - this.rowmanager.closeSingleNode(rowIndex); - } - }); - } - - focusCell($cell, { - skipClearSelection = 0 - } = {}) { - if (!$cell) return; - - // don't focus if already editing cell - if ($cell === this.$editingCell) return; - - const { - colIndex, - isHeader - } = $.data($cell); - if (isHeader) { - return; - } - - const column = this.columnmanager.getColumn(colIndex); - if (column.focusable === false) { - return; - } - - this.scrollToCell($cell); - - this.deactivateEditing(); - if (!skipClearSelection) { - this.clearSelection(); - } - - if (this.$focusedCell) { - this.$focusedCell.classList.remove('dt-cell--focus'); - } - - this.$focusedCell = $cell; - $cell.classList.add('dt-cell--focus'); - - // so that keyboard nav works - $cell.focus(); - - this.highlightRowColumnHeader($cell); - } - - highlightRowColumnHeader($cell) { - const { - colIndex, - rowIndex - } = $.data($cell); - - const srNoColIndex = this.datamanager.getColumnIndexById('_rowIndex'); - const colHeaderSelector = `.dt-cell--header-${colIndex}`; - const rowHeaderSelector = `.dt-cell--${srNoColIndex}-${rowIndex}`; - - if (this.lastHeaders) { - this.lastHeaders.forEach(header => header.classList.remove('dt-cell--highlight')); - } - - const colHeader = $(colHeaderSelector, this.wrapper); - const rowHeader = $(rowHeaderSelector, this.wrapper); - - this.lastHeaders = [colHeader, rowHeader]; - this.lastHeaders.forEach(header => header.classList.add('dt-cell--highlight')); - } - - selectAreaOnClusterChanged() { - if (!(this.$focusedCell && this.$selectionCursor)) return; - const { - colIndex, - rowIndex - } = $.data(this.$selectionCursor); - const $cell = this.getCell$(colIndex, rowIndex); - - if (!$cell || $cell === this.$selectionCursor) return; - - // selectArea needs $focusedCell - const fCell = $.data(this.$focusedCell); - this.$focusedCell = this.getCell$(fCell.colIndex, fCell.rowIndex); - - this.selectArea($cell); - } - - focusCellOnClusterChanged() { - if (!this.$focusedCell) return; - - const { - colIndex, - rowIndex - } = $.data(this.$focusedCell); - const $cell = this.getCell$(colIndex, rowIndex); - - if (!$cell) return; - // this function is called after selectAreaOnClusterChanged, - // focusCell calls clearSelection which resets the area selection - // so a flag to skip it - this.focusCell($cell, { - skipClearSelection: 1 - }); - } - - selectArea($selectionCursor) { - if (!this.$focusedCell) return; - - if (this._selectArea(this.$focusedCell, $selectionCursor)) { - // valid selection - this.$selectionCursor = $selectionCursor; - } - } - - _selectArea($cell1, $cell2) { - if ($cell1 === $cell2) return false; - - const cells = this.getCellsInRange($cell1, $cell2); - if (!cells) return false; - - this.clearSelection(); - this._selectedCells = cells.map(index => this.getCell$(...index)); - requestAnimationFrame(() => { - this._selectedCells.map($cell => $cell.classList.add('dt-cell--highlight')); - }); - return true; - } - - getCellsInRange($cell1, $cell2) { - let colIndex1, rowIndex1, colIndex2, rowIndex2; - - if (typeof $cell1 === 'number') { - [colIndex1, rowIndex1, colIndex2, rowIndex2] = arguments; - } else - if (typeof $cell1 === 'object') { - if (!($cell1 && $cell2)) { - return false; - } - - const cell1 = $.data($cell1); - const cell2 = $.data($cell2); - - colIndex1 = +cell1.colIndex; - rowIndex1 = +cell1.rowIndex; - colIndex2 = +cell2.colIndex; - rowIndex2 = +cell2.rowIndex; - } - - if (rowIndex1 > rowIndex2) { - [rowIndex1, rowIndex2] = [rowIndex2, rowIndex1]; - } - - if (colIndex1 > colIndex2) { - [colIndex1, colIndex2] = [colIndex2, colIndex1]; - } - - if (this.isStandardCell(colIndex1) || this.isStandardCell(colIndex2)) { - return false; - } - - const cells = []; - let colIndex = colIndex1; - let rowIndex = rowIndex1; - const rowIndices = []; - - while (rowIndex <= rowIndex2) { - rowIndices.push(rowIndex); - rowIndex += 1; - } - - rowIndices.map((rowIndex) => { - while (colIndex <= colIndex2) { - cells.push([colIndex, rowIndex]); - colIndex++; - } - colIndex = colIndex1; - }); - - return cells; - } - - clearSelection() { - (this._selectedCells || []) - .forEach($cell => $cell.classList.remove('dt-cell--highlight')); - - this._selectedCells = []; - this.$selectionCursor = null; - } - - getSelectionCursor() { - return this.$selectionCursor || this.$focusedCell; - } - - activateEditing($cell) { - this.focusCell($cell); - const { - rowIndex, - colIndex - } = $.data($cell); - - const col = this.columnmanager.getColumn(colIndex); - if (col && (col.editable === false || col.focusable === false)) { - return; - } - - const cell = this.getCell(colIndex, rowIndex); - if (cell && cell.editable === false) { - return; - } - - if (this.$editingCell) { - const { - _rowIndex, - _colIndex - } = $.data(this.$editingCell); - - if (rowIndex === _rowIndex && colIndex === _colIndex) { - // editing the same cell - return; - } - } - - this.$editingCell = $cell; - $cell.classList.add('dt-cell--editing'); - - const $editCell = $('.dt-cell__edit', $cell); - $editCell.innerHTML = ''; - - const editor = this.getEditor(colIndex, rowIndex, cell.content, $editCell); - - if (editor) { - this.currentCellEditor = editor; - // initialize editing input with cell value - editor.initValue(cell.content, rowIndex, col); - } - } - - deactivateEditing() { - // keep focus on the cell so that keyboard navigation works - if (this.$focusedCell) this.$focusedCell.focus(); - - if (!this.$editingCell) return; - this.$editingCell.classList.remove('dt-cell--editing'); - this.$editingCell = null; - } - - getEditor(colIndex, rowIndex, value, parent) { - const column = this.datamanager.getColumn(colIndex); - const row = this.datamanager.getRow(rowIndex); - const data = this.datamanager.getData(rowIndex); - let editor = this.options.getEditor ? - this.options.getEditor(colIndex, rowIndex, value, parent, column, row, data) : - this.getDefaultEditor(parent); - - if (editor === false) { - // explicitly returned false - return false; - } - if (editor === undefined) { - // didn't return editor, fallback to default - editor = this.getDefaultEditor(parent); - } - - return editor; - } - - getDefaultEditor(parent) { - const $input = $.create('input', { - class: 'dt-input', - type: 'text', - inside: parent - }); - - return { - initValue(value) { - $input.focus(); - $input.value = value; - }, - getValue() { - return $input.value; - }, - setValue(value) { - $input.value = value; - } - }; - } - - submitEditing() { - if (!this.$editingCell) return; - const $cell = this.$editingCell; - const { - rowIndex, - colIndex - } = $.data($cell); - const col = this.datamanager.getColumn(colIndex); - - if ($cell) { - const editor = this.currentCellEditor; - - if (editor) { - const value = editor.getValue(); - const done = editor.setValue(value, rowIndex, col); - const oldValue = this.getCell(colIndex, rowIndex).content; - - // update cell immediately - this.updateCell(colIndex, rowIndex, value); - $cell.focus(); - - if (done && done.then) { - // revert to oldValue if promise fails - done.catch((e) => { - console.log(e); - this.updateCell(colIndex, rowIndex, oldValue); - }); - } - } - } - - this.currentCellEditor = null; - } - - copyCellContents($cell1, $cell2) { - if (!$cell2 && $cell1) { - // copy only focusedCell - const { - colIndex, - rowIndex - } = $.data($cell1); - const cell = this.getCell(colIndex, rowIndex); - copyTextToClipboard(cell.content); - return 1; - } - const cells = this.getCellsInRange($cell1, $cell2); - - if (!cells) return 0; - - const rows = cells - // get cell objects - .map(index => this.getCell(...index)) - // convert to array of rows - .reduce((acc, curr) => { - const rowIndex = curr.rowIndex; - - acc[rowIndex] = acc[rowIndex] || []; - acc[rowIndex].push(curr.content); - - return acc; - }, []); - - const values = rows - // join values by tab - .map(row => row.join('\t')) - // join rows by newline - .join('\n'); - - copyTextToClipboard(values); - - // return no of cells copied - return rows.reduce((total, row) => total + row.length, 0); - } - - pasteContentInCell(data) { - if (!this.$focusedCell) return; - - const matrix = data - .split('\n') - .map(row => row.split('\t')) - .filter(row => row.length && row.every(it => it)); - - let { colIndex, rowIndex } = $.data(this.$focusedCell); - - let focusedCell = { - colIndex: +colIndex, - rowIndex: +rowIndex - }; - - matrix.forEach((row, i) => { - let rowIndex = i + focusedCell.rowIndex; - row.forEach((cell, j) => { - let colIndex = j + focusedCell.colIndex; - this.updateCell(colIndex, rowIndex, cell); - }); - }); - } - - activateFilter(colIndex) { - this.columnmanager.toggleFilter(); - this.columnmanager.focusFilter(colIndex); - - if (!this.columnmanager.isFilterShown) { - // put focus back on cell - this.$focusedCell.focus(); - } - } - - updateCell(colIndex, rowIndex, value) { - const cell = this.datamanager.updateCell(colIndex, rowIndex, { - content: value - }); - this.refreshCell(cell); - } - - refreshCell(cell) { - const $cell = $(this.selector(cell.colIndex, cell.rowIndex), this.bodyScrollable); - $cell.innerHTML = this.getCellContent(cell); - } - - toggleTreeButton(rowIndex, flag) { - const colIndex = this.columnmanager.getFirstColumnIndex(); - const $cell = this.getCell$(colIndex, rowIndex); - if ($cell) { - $cell.classList[flag ? 'remove' : 'add']('dt-cell--tree-close'); - } - } - - isStandardCell(colIndex) { - // Standard cells are in Sr. No and Checkbox column - return colIndex < this.columnmanager.getFirstColumnIndex(); - } - - getCell$(colIndex, rowIndex) { - return $(this.selector(colIndex, rowIndex), this.bodyScrollable); - } - - getAboveCell$($cell) { - const { - colIndex - } = $.data($cell); - - let $aboveRow = $cell.parentElement.previousElementSibling; - while ($aboveRow && $aboveRow.classList.contains('dt-row--hide')) { - $aboveRow = $aboveRow.previousElementSibling; - } - - if (!$aboveRow) return $cell; - return $(`.dt-cell--col-${colIndex}`, $aboveRow); - } - - getBelowCell$($cell) { - const { - colIndex - } = $.data($cell); - - let $belowRow = $cell.parentElement.nextElementSibling; - while ($belowRow && $belowRow.classList.contains('dt-row--hide')) { - $belowRow = $belowRow.nextElementSibling; - } - - if (!$belowRow) return $cell; - return $(`.dt-cell--col-${colIndex}`, $belowRow); - } - - getLeftCell$($cell) { - return $cell.previousElementSibling; - } - - getRightCell$($cell) { - return $cell.nextElementSibling; - } - - getLeftMostCell$(rowIndex) { - return this.getCell$(this.columnmanager.getFirstColumnIndex(), rowIndex); - } - - getRightMostCell$(rowIndex) { - return this.getCell$(this.columnmanager.getLastColumnIndex(), rowIndex); - } - - getTopMostCell$(colIndex) { - return this.getCell$(colIndex, this.rowmanager.getFirstRowIndex()); - } - - getBottomMostCell$(colIndex) { - return this.getCell$(colIndex, this.rowmanager.getLastRowIndex()); - } - - getCell(colIndex, rowIndex) { - return this.instance.datamanager.getCell(colIndex, rowIndex); - } - - getRowHeight() { - return $.style($('.dt-row', this.bodyScrollable), 'height'); - } - - scrollToCell($cell) { - if ($.inViewport($cell, this.bodyScrollable)) return false; - - const { - rowIndex - } = $.data($cell); - this.rowmanager.scrollToRow(rowIndex); - return false; - } - - getRowCountPerPage() { - return Math.ceil(this.instance.getViewportHeight() / this.getRowHeight()); - } - - getCellHTML(cell) { - const { - rowIndex, - colIndex, - isHeader, - isFilter - } = cell; - const dataAttr = makeDataAttributeString({ - rowIndex, - colIndex, - isHeader, - isFilter - }); - - const isBodyCell = !(isHeader || isFilter); - - const className = [ - 'dt-cell', - 'dt-cell--col-' + colIndex, - isBodyCell ? `dt-cell--${colIndex}-${rowIndex}` : '', - isBodyCell ? 'dt-cell--row-' + rowIndex : '', - isHeader ? 'dt-cell--header' : '', - isHeader ? `dt-cell--header-${colIndex}` : '', - isFilter ? 'dt-cell--filter' : '' - ].join(' '); - - return ` - - ${this.getCellContent(cell)} - - `; - } - - getCellContent(cell) { - const { - isHeader, - isFilter, - colIndex - } = cell; - - const editable = !isHeader && cell.editable !== false; - const editCellHTML = editable ? this.getEditCellHTML(colIndex) : ''; - - const sortable = isHeader && cell.sortable !== false; - const sortIndicator = sortable ? '' : ''; - - const resizable = isHeader && cell.resizable !== false; - const resizeColumn = resizable ? '' : ''; - - const hasDropdown = isHeader && cell.dropdown !== false; - const dropdown = hasDropdown ? this.columnmanager.getDropdownHTML() : ''; - - const customFormatter = cell.format || (cell.column && cell.column.format) || null; - - let contentHTML; - if (isHeader || isFilter || !customFormatter) { - contentHTML = cell.content; - } else { - const row = this.datamanager.getRow(cell.rowIndex); - const data = this.datamanager.getData(cell.rowIndex); - contentHTML = customFormatter(cell.content, row, cell.column, data); - } - - if (this.options.treeView && !(isHeader || isFilter) && cell.indent !== undefined) { - const nextRow = this.datamanager.getRow(cell.rowIndex + 1); - const addToggle = nextRow && nextRow.meta.indent > cell.indent; - - // Add toggle and indent in the first column - const firstColumnIndex = this.datamanager.getColumnIndexById('_rowIndex') + 1; - if (firstColumnIndex === cell.colIndex) { - const padding = ((cell.indent || 0) + 1) * 1.5; - const toggleHTML = addToggle ? - `` : ''; - contentHTML = ` - ${toggleHTML}${contentHTML}`; - } - } - - const className = [ - 'dt-cell__content', - isHeader ? `dt-cell__content--header-${colIndex}` : `dt-cell__content--col-${colIndex}` - ].join(' '); - - return ` -
- ${contentHTML} - ${sortIndicator} - ${resizeColumn} - ${dropdown} -
- ${editCellHTML} - `; - } - - getEditCellHTML(colIndex) { - return `
`; - } - - selector(colIndex, rowIndex) { - return `.dt-cell--${colIndex}-${rowIndex}`; - } - } - - class ColumnManager { - constructor(instance) { - this.instance = instance; - - linkProperties(this, this.instance, [ - 'options', - 'fireEvent', - 'header', - 'datamanager', - 'style', - 'wrapper', - 'rowmanager', - 'bodyScrollable' - ]); - - this.bindEvents(); - } - - renderHeader() { - this.header.innerHTML = ''; - this.refreshHeader(); - } - - refreshHeader() { - const columns = this.datamanager.getColumns(); - const $cols = $.each('.dt-cell--header', this.header); - - const refreshHTML = - // first init - !$('.dt-cell', this.header) || - // deleted column - columns.length < $cols.length; - - if (refreshHTML) { - // refresh html - $('thead', this.header).innerHTML = this.getHeaderHTML(columns); - - this.$filterRow = $('.dt-row[data-is-filter]', this.header); - if (this.$filterRow) { - $.style(this.$filterRow, { display: 'none' }); - } - } else { - // update data-attributes - $cols.map(($col, i) => { - const column = columns[i]; - // column sorted or order changed - // update colIndex of each header cell - $.data($col, { - colIndex: column.colIndex - }); - - // refresh sort indicator - const sortIndicator = $('.sort-indicator', $col); - if (sortIndicator) { - sortIndicator.innerHTML = this.options.sortIndicator[column.sortOrder]; - } - }); - } - // reset columnMap - this.$columnMap = []; - } - - getHeaderHTML(columns) { - let html = this.rowmanager.getRowHTML(columns, { - isHeader: 1 - }); - if (this.options.inlineFilters) { - html += this.rowmanager.getRowHTML(columns, { - isFilter: 1 - }); - } - return html; - } - - bindEvents() { - this.bindDropdown(); - this.bindResizeColumn(); - this.bindMoveColumn(); - this.bindFilter(); - } - - bindDropdown() { - let $activeDropdown; - let activeClass = 'dt-dropdown--active'; - let toggleClass = '.dt-dropdown__toggle'; - - $.on(this.header, 'click', toggleClass, (e, $button) => { - const $dropdown = $.closest('.dt-dropdown', $button); - - if (!$dropdown.classList.contains(activeClass)) { - deactivateDropdown(); - $dropdown.classList.add(activeClass); - $activeDropdown = $dropdown; - } else { - deactivateDropdown(); - } - }); - - $.on(document.body, 'click', (e) => { - if (e.target.matches(toggleClass)) return; - deactivateDropdown(); - }); - - const dropdownItems = this.options.headerDropdown; - - $.on(this.header, 'click', '.dt-dropdown__list-item', (e, $item) => { - const $col = $.closest('.dt-cell', $item); - const { - index - } = $.data($item); - const { - colIndex - } = $.data($col); - let callback = dropdownItems[index].action; - - callback && callback.call(this.instance, this.getColumn(colIndex)); - }); - - function deactivateDropdown(e) { - $activeDropdown && $activeDropdown.classList.remove(activeClass); - $activeDropdown = null; - } - } - - bindResizeColumn() { - let isDragging = false; - let $resizingCell, startWidth, startX; - - $.on(this.header, 'mousedown', '.dt-cell .dt-cell__resize-handle', (e, $handle) => { - document.body.classList.add('dt-resize'); - const $cell = $handle.parentNode.parentNode; - $resizingCell = $cell; - const { - colIndex - } = $.data($resizingCell); - const col = this.getColumn(colIndex); - - if (col && col.resizable === false) { - return; - } - - isDragging = true; - startWidth = $.style($('.dt-cell__content', $resizingCell), 'width'); - startX = e.pageX; - }); - - $.on(document.body, 'mouseup', (e) => { - document.body.classList.remove('dt-resize'); - if (!$resizingCell) return; - isDragging = false; - - const { - colIndex - } = $.data($resizingCell); - this.setColumnWidth(colIndex); - this.style.setBodyStyle(); - $resizingCell = null; - }); - - $.on(document.body, 'mousemove', (e) => { - if (!isDragging) return; - const finalWidth = startWidth + (e.pageX - startX); - const { - colIndex - } = $.data($resizingCell); - - if (this.getColumnMinWidth(colIndex) > finalWidth) { - // don't resize past minWidth - return; - } - this.datamanager.updateColumn(colIndex, { - width: finalWidth - }); - this.setColumnHeaderWidth(colIndex); - }); - } - - bindMoveColumn() { - let initialized; - - const initialize = () => { - if (initialized) { - $.off(document.body, 'mousemove', initialize); - return; - } - const ready = $('.dt-cell', this.header); - if (!ready) return; - - const $parent = $('.dt-row', this.header); - - this.sortable = Sortable.create($parent, { - onEnd: (e) => { - const { - oldIndex, - newIndex - } = e; - const $draggedCell = e.item; - const { - colIndex - } = $.data($draggedCell); - if (+colIndex === newIndex) return; - - this.switchColumn(oldIndex, newIndex); - }, - preventOnFilter: false, - filter: '.dt-cell__resize-handle, .dt-dropdown', - chosenClass: 'dt-cell--dragging', - animation: 150 - }); - }; - - $.on(document.body, 'mousemove', initialize); - } - - sortColumn(colIndex, nextSortOrder) { - this.instance.freeze(); - this.sortRows(colIndex, nextSortOrder) - .then(() => { - this.refreshHeader(); - return this.rowmanager.refreshRows(); - }) - .then(() => this.instance.unfreeze()) - .then(() => { - this.fireEvent('onSortColumn', this.getColumn(colIndex)); - }); - } - - removeColumn(colIndex) { - const removedCol = this.getColumn(colIndex); - this.instance.freeze(); - this.datamanager.removeColumn(colIndex) - .then(() => { - this.refreshHeader(); - return this.rowmanager.refreshRows(); - }) - .then(() => this.instance.unfreeze()) - .then(() => { - this.fireEvent('onRemoveColumn', removedCol); - }); - } - - switchColumn(oldIndex, newIndex) { - this.instance.freeze(); - this.datamanager.switchColumn(oldIndex, newIndex) - .then(() => { - this.refreshHeader(); - return this.rowmanager.refreshRows(); - }) - .then(() => { - this.setColumnWidth(oldIndex); - this.setColumnWidth(newIndex); - this.instance.unfreeze(); - }) - .then(() => { - this.fireEvent('onSwitchColumn', - this.getColumn(oldIndex), this.getColumn(newIndex) - ); - }); - } - - toggleFilter(flag) { - let showFilter; - if (flag === undefined) { - showFilter = !this.isFilterShown; - } else { - showFilter = flag; - } - - if (showFilter) { - $.style(this.$filterRow, { display: '' }); - } else { - $.style(this.$filterRow, { display: 'none' }); - } - - this.isFilterShown = showFilter; - this.style.setBodyStyle(); - } - - focusFilter(colIndex) { - if (!this.isFilterShown) return; - - const $filterInput = $(`[data-col-index="${colIndex}"] .dt-filter`, this.$filterRow); - $filterInput.focus(); - } - - bindFilter() { - if (!this.options.inlineFilters) return; - const handler = e => { - const $filterCell = $.closest('.dt-cell', e.target); - const { - colIndex - } = $.data($filterCell); - const keyword = e.target.value; - - this.datamanager.filterRows(keyword, colIndex) - .then(({ - rowsToHide, - rowsToShow - }) => { - this.rowmanager.hideRows(rowsToHide); - this.rowmanager.showRows(rowsToShow); - }); - }; - $.on(this.header, 'keydown', '.dt-filter', debounce$1(handler, 300)); - } - - sortRows(colIndex, sortOrder) { - return this.datamanager.sortRows(colIndex, sortOrder); - } - - getColumn(colIndex) { - return this.datamanager.getColumn(colIndex); - } - - getColumns() { - return this.datamanager.getColumns(); - } - - setColumnWidth(colIndex, width) { - colIndex = +colIndex; - this._columnWidthMap = this._columnWidthMap || []; - - let columnWidth = width || this.getColumn(colIndex).width; - - let index = this._columnWidthMap[colIndex]; - const selector = [ - `.dt-cell__content--col-${colIndex}`, - `.dt-cell__edit--col-${colIndex}` - ].join(', '); - - const styles = { - width: columnWidth + 'px' - }; - - index = this.style.setStyle(selector, styles, index); - - if (index !== undefined) { - this._columnWidthMap[colIndex] = index; - } - } - - setColumnHeaderWidth(colIndex) { - colIndex = +colIndex; - this.$columnMap = this.$columnMap || []; - const selector = `.dt-cell__content--header-${colIndex}`; - const { - width - } = this.getColumn(colIndex); - - let $column = this.$columnMap[colIndex]; - if (!$column) { - $column = this.header.querySelector(selector); - this.$columnMap[colIndex] = $column; - } - - $column.style.width = width + 'px'; - } - - getColumnMinWidth(colIndex) { - colIndex = +colIndex; - return this.getColumn(colIndex).minWidth || 24; - } - - getFirstColumnIndex() { - return this.datamanager.getColumnIndexById('_rowIndex') + 1; - } - - getHeaderCell$(colIndex) { - return $(`.dt-cell--header-${colIndex}`, this.header); - } - - getLastColumnIndex() { - return this.datamanager.getColumnCount() - 1; - } - - getDropdownHTML() { - const { dropdownButton, headerDropdown: dropdownItems } = this.options; - - return ` -
-
${dropdownButton}
-
- ${dropdownItems.map((d, i) => ` -
${d.label}
- `).join('')} -
-
- `; - } - } - - class RowManager { - constructor(instance) { - this.instance = instance; - linkProperties(this, this.instance, [ - 'options', - 'fireEvent', - 'wrapper', - 'bodyScrollable', - 'bodyRenderer' - ]); - - this.bindEvents(); - this.refreshRows = nextTick(this.refreshRows, this); - } - - get datamanager() { - return this.instance.datamanager; - } - - get cellmanager() { - return this.instance.cellmanager; - } - - bindEvents() { - this.bindCheckbox(); - } - - bindCheckbox() { - if (!this.options.checkboxColumn) return; - - // map of checked rows - this.checkMap = []; - - $.on(this.wrapper, 'click', '.dt-cell[data-col-index="0"] [type="checkbox"]', (e, $checkbox) => { - const $cell = $checkbox.closest('.dt-cell'); - const { - rowIndex, - isHeader - } = $.data($cell); - const checked = $checkbox.checked; - - if (isHeader) { - this.checkAll(checked); - } else { - this.checkRow(rowIndex, checked); - } - }); - } - - refreshRows() { - this.instance.renderBody(); - this.instance.setDimensions(); - } - - refreshRow(row, rowIndex) { - const _row = this.datamanager.updateRow(row, rowIndex); - - _row.forEach(cell => { - this.cellmanager.refreshCell(cell); - }); - } - - getCheckedRows() { - if (!this.checkMap) { - return []; - } - - let out = []; - for (let rowIndex in this.checkMap) { - const checked = this.checkMap[rowIndex]; - if (checked === 1) { - out.push(rowIndex); - } - } - - return out; - } - - highlightCheckedRows() { - this.getCheckedRows() - .map(rowIndex => this.checkRow(rowIndex, true)); - } - - checkRow(rowIndex, toggle) { - const value = toggle ? 1 : 0; - const selector = rowIndex => - `.dt-cell[data-row-index="${rowIndex}"][data-col-index="0"] [type="checkbox"]`; - // update internal map - this.checkMap[rowIndex] = value; - // set checkbox value explicitly - $.each(selector(rowIndex), this.bodyScrollable) - .map(input => { - input.checked = toggle; - }); - // highlight row - this.highlightRow(rowIndex, toggle); - this.showCheckStatus(); - this.fireEvent('onCheckRow', this.datamanager.getRow(rowIndex)); - } - - checkAll(toggle) { - const value = toggle ? 1 : 0; - - // update internal map - if (toggle) { - this.checkMap = Array.from(Array(this.getTotalRows())).map(c => value); - } else { - this.checkMap = []; - } - // set checkbox value - $.each('.dt-cell[data-col-index="0"] [type="checkbox"]', this.bodyScrollable) - .map(input => { - input.checked = toggle; - }); - // highlight all - this.highlightAll(toggle); - this.showCheckStatus(); - } - - showCheckStatus() { - if (!this.options.checkedRowStatus) return; - const checkedRows = this.getCheckedRows(); - const count = checkedRows.length; - if (count > 0) { - this.bodyRenderer.showToastMessage(`${count} row${count > 1 ? 's' : ''} selected`); - } else { - this.bodyRenderer.clearToastMessage(); - } - } - - highlightRow(rowIndex, toggle = true) { - const $row = this.getRow$(rowIndex); - if (!$row) return; - - if (!toggle && this.bodyScrollable.classList.contains('dt-scrollable--highlight-all')) { - $row.classList.add('dt-row--unhighlight'); - return; - } - - if (toggle && $row.classList.contains('dt-row--unhighlight')) { - $row.classList.remove('dt-row--unhighlight'); - } - - this._highlightedRows = this._highlightedRows || {}; - - if (toggle) { - $row.classList.add('dt-row--highlight'); - this._highlightedRows[rowIndex] = $row; - } else { - $row.classList.remove('dt-row--highlight'); - delete this._highlightedRows[rowIndex]; - } - } - - highlightAll(toggle = true) { - if (toggle) { - this.bodyScrollable.classList.add('dt-scrollable--highlight-all'); - } else { - this.bodyScrollable.classList.remove('dt-scrollable--highlight-all'); - for (const rowIndex in this._highlightedRows) { - const $row = this._highlightedRows[rowIndex]; - $row.classList.remove('dt-row--highlight'); - } - this._highlightedRows = {}; - } - } - - hideRows(rowIndices) { - rowIndices = ensureArray(rowIndices); - rowIndices.map(rowIndex => { - const $tr = this.getRow$(rowIndex); - $tr.classList.add('dt-row--hide'); - }); - } - - showRows(rowIndices) { - rowIndices = ensureArray(rowIndices); - rowIndices.map(rowIndex => { - const $tr = this.getRow$(rowIndex); - $tr.classList.remove('dt-row--hide'); - }); - } - - openSingleNode(rowIndex) { - const rowsToShow = this.datamanager.getImmediateChildren(rowIndex); - this.showRows(rowsToShow); - this.cellmanager.toggleTreeButton(rowIndex, true); - } - - closeSingleNode(rowIndex) { - const children = this.datamanager.getImmediateChildren(rowIndex); - children.forEach(childIndex => { - const row = this.datamanager.getRow(childIndex); - if (row.meta.isLeaf) { - // close - this.hideRows(childIndex); - this.cellmanager.toggleTreeButton(childIndex, false); - } else { - this.closeSingleNode(childIndex); - this.hideRows(childIndex); - } - }); - this.cellmanager.toggleTreeButton(rowIndex, false); - } - - getRow$(rowIndex) { - return $(this.selector(rowIndex), this.bodyScrollable); - } - - getTotalRows() { - return this.datamanager.getRowCount(); - } - - getFirstRowIndex() { - return 0; - } - - getLastRowIndex() { - return this.datamanager.getRowCount() - 1; - } - - scrollToRow(rowIndex) { - rowIndex = +rowIndex; - this._lastScrollTo = this._lastScrollTo || 0; - const $row = this.getRow$(rowIndex); - if ($.inViewport($row, this.bodyScrollable)) return; - - const { - height - } = $row.getBoundingClientRect(); - const { - top, - bottom - } = this.bodyScrollable.getBoundingClientRect(); - const rowsInView = Math.floor((bottom - top) / height); - - let offset = 0; - if (rowIndex > this._lastScrollTo) { - offset = height * ((rowIndex + 1) - rowsInView); - } else { - offset = height * ((rowIndex + 1) - 1); - } - - this._lastScrollTo = rowIndex; - $.scrollTop(this.bodyScrollable, offset); - } - - getRowHTML(row, props) { - const dataAttr = makeDataAttributeString(props); - - if (props.isFilter) { - row = row.map(cell => (Object.assign({}, cell, { - content: this.getFilterInput({ - colIndex: cell.colIndex - }), - isFilter: 1, - isHeader: undefined, - editable: false - }))); - } - - return ` - - ${row.map(cell => this.cellmanager.getCellHTML(cell)).join('')} - - `; - } - - getFilterInput(props) { - const dataAttr = makeDataAttributeString(props); - return ``; - } - - selector(rowIndex) { - return `.dt-row[data-row-index="${rowIndex}"]`; - } - } - - class BodyRenderer { - constructor(instance) { - this.instance = instance; - this.options = instance.options; - this.datamanager = instance.datamanager; - this.rowmanager = instance.rowmanager; - this.cellmanager = instance.cellmanager; - this.bodyScrollable = instance.bodyScrollable; - this.log = instance.log; - this.appendRemainingData = nextTick(this.appendRemainingData, this); - } - - render() { - if (this.options.clusterize) { - this.renderBodyWithClusterize(); - } else { - this.renderBodyHTML(); - } - } - - renderBodyHTML() { - const rows = this.datamanager.getRowsForView(); - - this.bodyScrollable.innerHTML = this.getBodyHTML(rows); - this.instance.setDimensions(); - this.restoreState(); - } - - renderBodyWithClusterize() { - // first page - const rows = this.datamanager.getRowsForView(0, 20); - let initialData = this.getDataForClusterize(rows); - - if (initialData.length === 0) { - initialData = [this.getNoDataHTML()]; - } - - if (!this.clusterize) { - // empty body - this.bodyScrollable.innerHTML = this.getBodyHTML([]); - - // first 20 rows will appended - // rest of them in nextTick - this.clusterize = new Clusterize({ - rows: initialData, - scrollElem: this.bodyScrollable, - contentElem: $('tbody', this.bodyScrollable), - callbacks: { - clusterChanged: () => this.restoreState() - }, - /* eslint-disable */ - show_no_data_row: false, - /* eslint-enable */ - }); - - // setDimensions requires atleast 1 row to exist in dom - this.instance.setDimensions(); - } else { - this.clusterize.update(initialData); - } - - this.appendRemainingData(); - } - - restoreState() { - this.rowmanager.highlightCheckedRows(); - this.cellmanager.selectAreaOnClusterChanged(); - this.cellmanager.focusCellOnClusterChanged(); - } - - appendRemainingData() { - const rows = this.datamanager.getRowsForView(20); - const data = this.getDataForClusterize(rows); - this.clusterize.append(data); - } - - showToastMessage(message, hideAfter) { - this.instance.toastMessage.innerHTML = this.getToastMessageHTML(message); - - if (hideAfter) { - setTimeout(() => { - this.clearToastMessage(); - }, hideAfter * 1000); - } - } - - clearToastMessage() { - this.instance.toastMessage.innerHTML = ''; - } - - getDataForClusterize(rows) { - return rows.map(row => this.rowmanager.getRowHTML(row, row.meta)); - } - - getBodyHTML(rows) { - return ` - - - ${rows.map(row => this.rowmanager.getRowHTML(row, row.meta)).join('')} - -
- `; - } - - getNoDataHTML() { - return `
${this.options.noDataMessage}
`; - } - - getToastMessageHTML(message) { - return `${message}`; - } - } - - class Style { - constructor(instance) { - this.instance = instance; - - linkProperties(this, this.instance, [ - 'options', 'datamanager', 'columnmanager', - 'header', 'bodyScrollable', 'datatableWrapper', - 'getColumn' - ]); - - this.scopeClass = 'dt-instance-' + instance.constructor.instances; - instance.datatableWrapper.classList.add(this.scopeClass); - - const styleEl = document.createElement('style'); - instance.wrapper.insertBefore(styleEl, instance.datatableWrapper); - this.styleEl = styleEl; - - this.bindResizeWindow(); - } - - get stylesheet() { - return this.styleEl.sheet; - } - - bindResizeWindow() { - if (this.options.layout === 'fluid') { - $.on(window, 'resize', throttle$1(() => { - this.distributeRemainingWidth(); - this.refreshColumnWidth(); - this.compensateScrollbarWidth(); - this.setBodyStyle(); - }, 300)); - } - } - - destroy() { - this.styleEl.remove(); - } - - setStyle(selector, styleMap, index = -1) { - const styles = Object.keys(styleMap) - .map(prop => { - if (!prop.includes('-')) { - prop = camelCaseToDash(prop); - } - return `${prop}:${styleMap[prop]};`; - }) - .join(''); - let prefixedSelector = selector - .split(',') - .map(r => `.${this.scopeClass} ${r}`) - .join(','); - - let ruleString = `${prefixedSelector} { ${styles} }`; - - if (!this.stylesheet) return; - - let _index = this.stylesheet.cssRules.length; - if (index !== -1) { - this.stylesheet.deleteRule(index); - _index = index; - } - - this.stylesheet.insertRule(ruleString, _index); - return _index; // eslint-disable-line - } - - setDimensions() { - this.setHeaderStyle(); - - this.setupMinWidth(); - this.setupNaturalColumnWidth(); - this.setupColumnWidth(); - this.distributeRemainingWidth(); - this.setColumnStyle(); - this.compensateScrollbarWidth(); - - this.setDefaultCellHeight(); - this.setBodyStyle(); - } - - setHeaderStyle() { - if (this.options.layout === 'fluid') { - // setting width as 0 will ensure that the - // header doesn't take the available space - $.style(this.header, { - width: 0 - }); - } - - $.style(this.header, { - margin: 0 - }); - } - - setupMinWidth() { - $.each('.dt-cell[data-is-header]', this.header).map(col => { - const { colIndex } = $.data(col); - const column = this.getColumn(colIndex); - - if (!column.minWidth) { - const width = $.style($('.dt-cell__content', col), 'width'); - // only set this once - column.minWidth = width; - } - }); - } - - setupNaturalColumnWidth() { - if (!$('.dt-row')) return; - - // set initial width as naturally calculated by table's first row - $.each('.dt-row[data-row-index="0"] .dt-cell', this.bodyScrollable).map($cell => { - const { - colIndex - } = $.data($cell); - const column = this.datamanager.getColumn(colIndex); - - let naturalWidth = $.style($('.dt-cell__content', $cell), 'width'); - - if (column.id === '_rowIndex') { - naturalWidth = this.getRowIndexColumnWidth(naturalWidth); - column.width = naturalWidth; - } - - column.naturalWidth = naturalWidth; - }); - } - - setupColumnWidth() { - if (this.options.layout === 'ratio') { - let totalWidth = $.style(this.datatableWrapper, 'width'); - - if (this.options.serialNoColumn) { - const rowIndexColumn = this.datamanager.getColumnById('_rowIndex'); - totalWidth = totalWidth - rowIndexColumn.width - 1; - } - - if (this.options.checkboxColumn) { - const rowIndexColumn = this.datamanager.getColumnById('_checkbox'); - totalWidth = totalWidth - rowIndexColumn.width - 1; - } - - const totalParts = this.datamanager.getColumns() - .map(column => { - if (column.id === '_rowIndex' || column.id === '_checkbox') { - return 0; - } - if (!column.width) { - column.width = 1; - } - column.ratioWidth = parseInt(column.width, 10); - return column.ratioWidth; - }) - .reduce((a, c) => a + c); - - const onePart = totalWidth / totalParts; - - this.datamanager.getColumns() - .map(column => { - if (column.id === '_rowIndex' || column.id === '_checkbox') return; - column.width = Math.floor(onePart * column.ratioWidth) - 1; - }); - } else { - this.datamanager.getColumns() - .map(column => { - if (!column.width) { - column.width = column.naturalWidth; - } - if (column.width < column.minWidth) { - column.width = column.minWidth; - } - }); - } - } - - compensateScrollbarWidth() { - requestAnimationFrame(() => { - const scrollbarWidth = $.scrollbarWidth(); - const lastCol = this.datamanager.getColumn(-1); - const width = lastCol.width - scrollbarWidth; - this.columnmanager.setColumnWidth(lastCol.colIndex, width); - }); - } - - distributeRemainingWidth() { - if (this.options.layout !== 'fluid') return; - - const wrapperWidth = $.style(this.instance.datatableWrapper, 'width'); - const headerWidth = $.style(this.header, 'width'); - const resizableColumns = this.datamanager.getColumns().filter(col => col.resizable); - const deltaWidth = (wrapperWidth - headerWidth) / resizableColumns.length; - - resizableColumns.map(col => { - const width = $.style(this.getColumnHeaderElement(col.colIndex), 'width'); - let finalWidth = Math.floor(width + deltaWidth) - 2; - - this.datamanager.updateColumn(col.colIndex, { - width: finalWidth - }); - }); - } - - setDefaultCellHeight() { - if (this.options.dynamicRowHeight) return; - if (this.__cellHeightSet) return; - const $firstCell = $('.dt-cell[data-is-header]', this.instance.header); - if (!$firstCell) return; - - const height = this.options.cellHeight || $.style($firstCell, 'height'); - if (height) { - this.setCellHeight(height); - this.__cellHeightSet = true; - } - } - - setCellHeight(height) { - this.setStyle('.dt-cell__content, .dt-cell__edit', { - height: height + 'px' - }); - } - - setColumnStyle() { - // align columns - this.datamanager.getColumns() - .map(column => { - // alignment - if (['left', 'center', 'right'].includes(column.align)) { - this.setStyle(`.dt-cell--col-${column.colIndex}`, { - 'text-align': column.align - }); - } - // width - this.columnmanager.setColumnHeaderWidth(column.colIndex); - this.columnmanager.setColumnWidth(column.colIndex); - }); - this.setBodyStyle(); - } - - refreshColumnWidth() { - this.datamanager.getColumns() - .map(column => { - this.columnmanager.setColumnHeaderWidth(column.colIndex); - this.columnmanager.setColumnWidth(column.colIndex); - }); - } - - setBodyStyle() { - requestAnimationFrame(() => { - const width = $.style(this.header, 'width'); - - $.style(this.bodyScrollable, { - width: width + 'px' - }); - - const $body = $('.dt-body', this.bodyScrollable); - - if ($body) { - $.style($body, { - height: '0px' - }); - } - - $.style(this.bodyScrollable, { - marginTop: $.style(this.header, 'height') + 'px' - }); - - $.style($('table', this.bodyScrollable), { - margin: 0, - width: '100%' - }); - }); - } - - getColumnHeaderElement(colIndex) { - colIndex = +colIndex; - if (colIndex < 0) return null; - return $(`.dt-cell[data-col-index="${colIndex}"]`, this.header); - } - - getRowIndexColumnWidth(baseWidth) { - this._rowIndexColumnWidthMap = this._rowIndexColumnWidthMap || {}; - const rowCount = this.datamanager.getRowCount(); - const digits = (rowCount + '').length; - - if (!this._rowIndexColumnWidthMap[digits]) { - // add 8px for each unit - this._rowIndexColumnWidthMap[digits] = baseWidth + ((digits - 1) * 8); - } - - return this._rowIndexColumnWidthMap[digits]; - } - } - - const KEYCODES = { - 13: 'enter', - 91: 'meta', - 16: 'shift', - 17: 'ctrl', - 18: 'alt', - 37: 'left', - 38: 'up', - 39: 'right', - 40: 'down', - 9: 'tab', - 27: 'esc', - 67: 'c', - 70: 'f', - 86: 'v' - }; - - class Keyboard { - constructor(element) { - this.listeners = {}; - $.on(element, 'keydown', this.handler.bind(this)); - } - - handler(e) { - let key = KEYCODES[e.keyCode]; - - if (e.shiftKey && key !== 'shift') { - key = 'shift+' + key; - } - - if ((e.ctrlKey && key !== 'ctrl') || (e.metaKey && key !== 'meta')) { - key = 'ctrl+' + key; - } - - const listeners = this.listeners[key]; - - if (listeners && listeners.length > 0) { - for (let listener of listeners) { - const preventBubbling = listener(e); - if (preventBubbling === undefined || preventBubbling === true) { - e.preventDefault(); - } - } - } - } - - on(key, listener) { - const keys = key.split(',').map(k => k.trim()); - - keys.map(key => { - this.listeners[key] = this.listeners[key] || []; - this.listeners[key].push(listener); - }); - } - } - - var DEFAULT_OPTIONS = { - columns: [], - data: [], - dropdownButton: '▼', - headerDropdown: [ - { - label: 'Sort Ascending', - action: function (column) { - this.sortColumn(column.colIndex, 'asc'); - } - }, - { - label: 'Sort Descending', - action: function (column) { - this.sortColumn(column.colIndex, 'desc'); - } - }, - { - label: 'Reset sorting', - action: function (column) { - this.sortColumn(column.colIndex, 'none'); - } - }, - { - label: 'Remove column', - action: function (column) { - this.removeColumn(column.colIndex); - } - } - ], - events: { - onRemoveColumn(column) {}, - onSwitchColumn(column1, column2) {}, - onSortColumn(column) {}, - onCheckRow(row) {} - }, - sortIndicator: { - asc: '↑', - desc: '↓', - none: '' - }, - freezeMessage: '', - getEditor: null, - serialNoColumn: true, - checkboxColumn: false, - clusterize: true, - logs: false, - layout: 'fixed', // fixed, fluid, ratio - noDataMessage: 'No Data', - cellHeight: null, - inlineFilters: false, - treeView: false, - checkedRowStatus: true, - dynamicRowHeight: false, - pasteFromClipboard: false - }; - - class DataTable { - constructor(wrapper, options) { - DataTable.instances++; - - if (typeof wrapper === 'string') { - // css selector - wrapper = document.querySelector(wrapper); - } - this.wrapper = wrapper; - if (!(this.wrapper instanceof HTMLElement)) { - throw new Error('Invalid argument given for `wrapper`'); - } - - this.buildOptions(options); - this.prepare(); - - this.style = new Style(this); - this.keyboard = new Keyboard(this.wrapper); - this.datamanager = new DataManager(this.options); - this.rowmanager = new RowManager(this); - this.columnmanager = new ColumnManager(this); - this.cellmanager = new CellManager(this); - this.bodyRenderer = new BodyRenderer(this); - - if (this.options.data) { - this.refresh(); - } - } - - buildOptions(options) { - this.options = this.options || {}; - - this.options = Object.assign( - {}, DEFAULT_OPTIONS, - this.options || {}, options - ); - - options.headerDropdown = options.headerDropdown || []; - this.options.headerDropdown = [ - ...DEFAULT_OPTIONS.headerDropdown, - ...options.headerDropdown - ]; - - // custom user events - this.events = Object.assign( - {}, DEFAULT_OPTIONS.events, - this.options.events || {}, - options.events || {} - ); - this.fireEvent = this.fireEvent.bind(this); - } - - prepare() { - this.prepareDom(); - this.unfreeze(); - } - - prepareDom() { - this.wrapper.innerHTML = ` -
- -
-
-
-
- - ${this.options.freezeMessage} - -
-
- -
- `; - - this.datatableWrapper = $('.datatable', this.wrapper); - this.header = $('.dt-header', this.wrapper); - this.bodyScrollable = $('.dt-scrollable', this.wrapper); - this.freezeContainer = $('.dt-freeze', this.wrapper); - this.toastMessage = $('.dt-toast', this.wrapper); - this.pasteTarget = $('.dt-paste-target', this.wrapper); - } - - refresh(data, columns) { - this.datamanager.init(data, columns); - this.render(); - this.setDimensions(); - } - - destroy() { - this.wrapper.innerHTML = ''; - this.style.destroy(); - } - - appendRows(rows) { - this.datamanager.appendRows(rows); - this.rowmanager.refreshRows(); - } - - refreshRow(row, rowIndex) { - this.rowmanager.refreshRow(row, rowIndex); - } - - render() { - this.renderHeader(); - this.renderBody(); - } - - renderHeader() { - this.columnmanager.renderHeader(); - } - - renderBody() { - this.bodyRenderer.render(); - } - - setDimensions() { - this.style.setDimensions(); - } - - showToastMessage(message, hideAfter) { - this.bodyRenderer.showToastMessage(message, hideAfter); - } - - clearToastMessage() { - this.bodyRenderer.clearToastMessage(); - } - - getColumn(colIndex) { - return this.datamanager.getColumn(colIndex); - } - - getColumns() { - return this.datamanager.getColumns(); - } - - getRows() { - return this.datamanager.getRows(); - } - - getCell(colIndex, rowIndex) { - return this.datamanager.getCell(colIndex, rowIndex); - } - - getColumnHeaderElement(colIndex) { - return this.columnmanager.getColumnHeaderElement(colIndex); - } - - getViewportHeight() { - if (!this.viewportHeight) { - this.viewportHeight = $.style(this.bodyScrollable, 'height'); - } - - return this.viewportHeight; - } - - sortColumn(colIndex, sortOrder) { - this.columnmanager.sortColumn(colIndex, sortOrder); - } - - removeColumn(colIndex) { - this.columnmanager.removeColumn(colIndex); - } - - scrollToLastColumn() { - this.datatableWrapper.scrollLeft = 9999; - } - - freeze() { - $.style(this.freezeContainer, { - display: '' - }); - } - - unfreeze() { - $.style(this.freezeContainer, { - display: 'none' - }); - } - - updateOptions(options) { - this.buildOptions(options); - } - - fireEvent(eventName, ...args) { - this.events[eventName].apply(this, args); - } - - log() { - if (this.options.logs) { - console.log.apply(console, arguments); - } - } - } - - DataTable.instances = 0; - - var name = "frappe-datatable"; - var version = "0.0.5"; - var description = "A modern datatable library for the web"; - var main = "dist/frappe-datatable.cjs.js"; - var scripts = {"start":"yarn run dev","build":"rollup -c","production":"rollup -c --production","build:docs":"rollup -c --docs","dev":"rollup -c -w","test":"mocha --compilers js:babel-core/register --colors ./test/*.spec.js"}; - var devDependencies = {"chai":"3.5.0","deepmerge":"^2.0.1","eslint-config-airbnb":"^16.1.0","eslint-config-airbnb-base":"^12.1.0","eslint-plugin-import":"^2.11.0","mocha":"3.3.0","postcss-cssnext":"^3.1.0","postcss-nested":"^3.0.0","rollup-plugin-commonjs":"^8.3.0","rollup-plugin-eslint":"^4.0.0","rollup-plugin-json":"^2.3.0","rollup-plugin-node-resolve":"^3.0.3","rollup-plugin-postcss":"^1.2.8","rollup-plugin-uglify-es":"^0.0.1"}; - var repository = {"type":"git","url":"https://github.com/frappe/datatable.git"}; - var keywords = ["datatable","data","grid","table"]; - var author = "Faris Ansari"; - var license = "MIT"; - var bugs = {"url":"https://github.com/frappe/datatable/issues"}; - var homepage = "https://frappe.github.io/datatable"; - var dependencies = {"clusterize.js":"^0.18.0","lodash":"^4.17.5","sortablejs":"^1.7.0"}; - var packageJson = { - name: name, - version: version, - description: description, - main: main, - scripts: scripts, - devDependencies: devDependencies, - repository: repository, - keywords: keywords, - author: author, - license: license, - bugs: bugs, - homepage: homepage, - dependencies: dependencies - }; - - DataTable.__version__ = packageJson.version; - - return DataTable; - -}(Sortable,Clusterize)); diff --git a/docs/assets/js/highlight.pack.js b/docs/assets/js/highlight.pack.js deleted file mode 100644 index c020b11..0000000 --- a/docs/assets/js/highlight.pack.js +++ /dev/null @@ -1,2 +0,0 @@ -/*! highlight.js v9.12.0 | BSD3 License | git.io/hljslicense */ -!function(e){var n="object"==typeof window&&window||"object"==typeof self&&self;"undefined"!=typeof exports?e(exports):n&&(n.hljs=e({}),"function"==typeof define&&define.amd&&define([],function(){return n.hljs}))}(function(e){function n(e){return e.replace(/&/g,"&").replace(//g,">")}function t(e){return e.nodeName.toLowerCase()}function r(e,n){var t=e&&e.exec(n);return t&&0===t.index}function a(e){return k.test(e)}function i(e){var n,t,r,i,o=e.className+" ";if(o+=e.parentNode?e.parentNode.className:"",t=B.exec(o))return w(t[1])?t[1]:"no-highlight";for(o=o.split(/\s+/),n=0,r=o.length;r>n;n++)if(i=o[n],a(i)||w(i))return i}function o(e){var n,t={},r=Array.prototype.slice.call(arguments,1);for(n in e)t[n]=e[n];return r.forEach(function(e){for(n in e)t[n]=e[n]}),t}function u(e){var n=[];return function r(e,a){for(var i=e.firstChild;i;i=i.nextSibling)3===i.nodeType?a+=i.nodeValue.length:1===i.nodeType&&(n.push({event:"start",offset:a,node:i}),a=r(i,a),t(i).match(/br|hr|img|input/)||n.push({event:"stop",offset:a,node:i}));return a}(e,0),n}function c(e,r,a){function i(){return e.length&&r.length?e[0].offset!==r[0].offset?e[0].offset"}function u(e){s+=""}function c(e){("start"===e.event?o:u)(e.node)}for(var l=0,s="",f=[];e.length||r.length;){var g=i();if(s+=n(a.substring(l,g[0].offset)),l=g[0].offset,g===e){f.reverse().forEach(u);do c(g.splice(0,1)[0]),g=i();while(g===e&&g.length&&g[0].offset===l);f.reverse().forEach(o)}else"start"===g[0].event?f.push(g[0].node):f.pop(),c(g.splice(0,1)[0])}return s+n(a.substr(l))}function l(e){return e.v&&!e.cached_variants&&(e.cached_variants=e.v.map(function(n){return o(e,{v:null},n)})),e.cached_variants||e.eW&&[o(e)]||[e]}function s(e){function n(e){return e&&e.source||e}function t(t,r){return new RegExp(n(t),"m"+(e.cI?"i":"")+(r?"g":""))}function r(a,i){if(!a.compiled){if(a.compiled=!0,a.k=a.k||a.bK,a.k){var o={},u=function(n,t){e.cI&&(t=t.toLowerCase()),t.split(" ").forEach(function(e){var t=e.split("|");o[t[0]]=[n,t[1]?Number(t[1]):1]})};"string"==typeof a.k?u("keyword",a.k):x(a.k).forEach(function(e){u(e,a.k[e])}),a.k=o}a.lR=t(a.l||/\w+/,!0),i&&(a.bK&&(a.b="\\b("+a.bK.split(" ").join("|")+")\\b"),a.b||(a.b=/\B|\b/),a.bR=t(a.b),a.e||a.eW||(a.e=/\B|\b/),a.e&&(a.eR=t(a.e)),a.tE=n(a.e)||"",a.eW&&i.tE&&(a.tE+=(a.e?"|":"")+i.tE)),a.i&&(a.iR=t(a.i)),null==a.r&&(a.r=1),a.c||(a.c=[]),a.c=Array.prototype.concat.apply([],a.c.map(function(e){return l("self"===e?a:e)})),a.c.forEach(function(e){r(e,a)}),a.starts&&r(a.starts,i);var c=a.c.map(function(e){return e.bK?"\\.?("+e.b+")\\.?":e.b}).concat([a.tE,a.i]).map(n).filter(Boolean);a.t=c.length?t(c.join("|"),!0):{exec:function(){return null}}}}r(e)}function f(e,t,a,i){function o(e,n){var t,a;for(t=0,a=n.c.length;a>t;t++)if(r(n.c[t].bR,e))return n.c[t]}function u(e,n){if(r(e.eR,n)){for(;e.endsParent&&e.parent;)e=e.parent;return e}return e.eW?u(e.parent,n):void 0}function c(e,n){return!a&&r(n.iR,e)}function l(e,n){var t=N.cI?n[0].toLowerCase():n[0];return e.k.hasOwnProperty(t)&&e.k[t]}function p(e,n,t,r){var a=r?"":I.classPrefix,i='',i+n+o}function h(){var e,t,r,a;if(!E.k)return n(k);for(a="",t=0,E.lR.lastIndex=0,r=E.lR.exec(k);r;)a+=n(k.substring(t,r.index)),e=l(E,r),e?(B+=e[1],a+=p(e[0],n(r[0]))):a+=n(r[0]),t=E.lR.lastIndex,r=E.lR.exec(k);return a+n(k.substr(t))}function d(){var e="string"==typeof E.sL;if(e&&!y[E.sL])return n(k);var t=e?f(E.sL,k,!0,x[E.sL]):g(k,E.sL.length?E.sL:void 0);return E.r>0&&(B+=t.r),e&&(x[E.sL]=t.top),p(t.language,t.value,!1,!0)}function b(){L+=null!=E.sL?d():h(),k=""}function v(e){L+=e.cN?p(e.cN,"",!0):"",E=Object.create(e,{parent:{value:E}})}function m(e,n){if(k+=e,null==n)return b(),0;var t=o(n,E);if(t)return t.skip?k+=n:(t.eB&&(k+=n),b(),t.rB||t.eB||(k=n)),v(t,n),t.rB?0:n.length;var r=u(E,n);if(r){var a=E;a.skip?k+=n:(a.rE||a.eE||(k+=n),b(),a.eE&&(k=n));do E.cN&&(L+=C),E.skip||(B+=E.r),E=E.parent;while(E!==r.parent);return r.starts&&v(r.starts,""),a.rE?0:n.length}if(c(n,E))throw new Error('Illegal lexeme "'+n+'" for mode "'+(E.cN||"")+'"');return k+=n,n.length||1}var N=w(e);if(!N)throw new Error('Unknown language: "'+e+'"');s(N);var R,E=i||N,x={},L="";for(R=E;R!==N;R=R.parent)R.cN&&(L=p(R.cN,"",!0)+L);var k="",B=0;try{for(var M,j,O=0;;){if(E.t.lastIndex=O,M=E.t.exec(t),!M)break;j=m(t.substring(O,M.index),M[0]),O=M.index+j}for(m(t.substr(O)),R=E;R.parent;R=R.parent)R.cN&&(L+=C);return{r:B,value:L,language:e,top:E}}catch(T){if(T.message&&-1!==T.message.indexOf("Illegal"))return{r:0,value:n(t)};throw T}}function g(e,t){t=t||I.languages||x(y);var r={r:0,value:n(e)},a=r;return t.filter(w).forEach(function(n){var t=f(n,e,!1);t.language=n,t.r>a.r&&(a=t),t.r>r.r&&(a=r,r=t)}),a.language&&(r.second_best=a),r}function p(e){return I.tabReplace||I.useBR?e.replace(M,function(e,n){return I.useBR&&"\n"===e?"
":I.tabReplace?n.replace(/\t/g,I.tabReplace):""}):e}function h(e,n,t){var r=n?L[n]:t,a=[e.trim()];return e.match(/\bhljs\b/)||a.push("hljs"),-1===e.indexOf(r)&&a.push(r),a.join(" ").trim()}function d(e){var n,t,r,o,l,s=i(e);a(s)||(I.useBR?(n=document.createElementNS("http://www.w3.org/1999/xhtml","div"),n.innerHTML=e.innerHTML.replace(/\n/g,"").replace(//g,"\n")):n=e,l=n.textContent,r=s?f(s,l,!0):g(l),t=u(n),t.length&&(o=document.createElementNS("http://www.w3.org/1999/xhtml","div"),o.innerHTML=r.value,r.value=c(t,u(o),l)),r.value=p(r.value),e.innerHTML=r.value,e.className=h(e.className,s,r.language),e.result={language:r.language,re:r.r},r.second_best&&(e.second_best={language:r.second_best.language,re:r.second_best.r}))}function b(e){I=o(I,e)}function v(){if(!v.called){v.called=!0;var e=document.querySelectorAll("pre code");E.forEach.call(e,d)}}function m(){addEventListener("DOMContentLoaded",v,!1),addEventListener("load",v,!1)}function N(n,t){var r=y[n]=t(e);r.aliases&&r.aliases.forEach(function(e){L[e]=n})}function R(){return x(y)}function w(e){return e=(e||"").toLowerCase(),y[e]||y[L[e]]}var E=[],x=Object.keys,y={},L={},k=/^(no-?highlight|plain|text)$/i,B=/\blang(?:uage)?-([\w-]+)\b/i,M=/((^(<[^>]+>|\t|)+|(?:\n)))/gm,C="
",I={classPrefix:"hljs-",tabReplace:null,useBR:!1,languages:void 0};return e.highlight=f,e.highlightAuto=g,e.fixMarkup=p,e.highlightBlock=d,e.configure=b,e.initHighlighting=v,e.initHighlightingOnLoad=m,e.registerLanguage=N,e.listLanguages=R,e.getLanguage=w,e.inherit=o,e.IR="[a-zA-Z]\\w*",e.UIR="[a-zA-Z_]\\w*",e.NR="\\b\\d+(\\.\\d+)?",e.CNR="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",e.BNR="\\b(0b[01]+)",e.RSR="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",e.BE={b:"\\\\[\\s\\S]",r:0},e.ASM={cN:"string",b:"'",e:"'",i:"\\n",c:[e.BE]},e.QSM={cN:"string",b:'"',e:'"',i:"\\n",c:[e.BE]},e.PWM={b:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},e.C=function(n,t,r){var a=e.inherit({cN:"comment",b:n,e:t,c:[]},r||{});return a.c.push(e.PWM),a.c.push({cN:"doctag",b:"(?:TODO|FIXME|NOTE|BUG|XXX):",r:0}),a},e.CLCM=e.C("//","$"),e.CBCM=e.C("/\\*","\\*/"),e.HCM=e.C("#","$"),e.NM={cN:"number",b:e.NR,r:0},e.CNM={cN:"number",b:e.CNR,r:0},e.BNM={cN:"number",b:e.BNR,r:0},e.CSSNM={cN:"number",b:e.NR+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",r:0},e.RM={cN:"regexp",b:/\//,e:/\/[gimuy]*/,i:/\n/,c:[e.BE,{b:/\[/,e:/\]/,r:0,c:[e.BE]}]},e.TM={cN:"title",b:e.IR,r:0},e.UTM={cN:"title",b:e.UIR,r:0},e.METHOD_GUARD={b:"\\.\\s*"+e.UIR,r:0},e});hljs.registerLanguage("javascript",function(e){var r="[A-Za-z$_][0-9A-Za-z$_]*",t={keyword:"in of if for while finally var new function do return void else break catch instanceof with throw case default try this switch continue typeof delete let yield const export super debugger as async await static import from as",literal:"true false null undefined NaN Infinity",built_in:"eval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Error EvalError InternalError RangeError ReferenceError StopIteration SyntaxError TypeError URIError Number Math Date String RegExp Array Float32Array Float64Array Int16Array Int32Array Int8Array Uint16Array Uint32Array Uint8Array Uint8ClampedArray ArrayBuffer DataView JSON Intl arguments require module console window document Symbol Set Map WeakSet WeakMap Proxy Reflect Promise"},a={cN:"number",v:[{b:"\\b(0[bB][01]+)"},{b:"\\b(0[oO][0-7]+)"},{b:e.CNR}],r:0},n={cN:"subst",b:"\\$\\{",e:"\\}",k:t,c:[]},c={cN:"string",b:"`",e:"`",c:[e.BE,n]};n.c=[e.ASM,e.QSM,c,a,e.RM];var s=n.c.concat([e.CBCM,e.CLCM]);return{aliases:["js","jsx"],k:t,c:[{cN:"meta",r:10,b:/^\s*['"]use (strict|asm)['"]/},{cN:"meta",b:/^#!/,e:/$/},e.ASM,e.QSM,c,e.CLCM,e.CBCM,a,{b:/[{,]\s*/,r:0,c:[{b:r+"\\s*:",rB:!0,r:0,c:[{cN:"attr",b:r,r:0}]}]},{b:"("+e.RSR+"|\\b(case|return|throw)\\b)\\s*",k:"return throw case",c:[e.CLCM,e.CBCM,e.RM,{cN:"function",b:"(\\(.*?\\)|"+r+")\\s*=>",rB:!0,e:"\\s*=>",c:[{cN:"params",v:[{b:r},{b:/\(\s*\)/},{b:/\(/,e:/\)/,eB:!0,eE:!0,k:t,c:s}]}]},{b://,sL:"xml",c:[{b:/<\w+\s*\/>/,skip:!0},{b:/<\w+/,e:/(\/\w+|\w+\/)>/,skip:!0,c:[{b:/<\w+\s*\/>/,skip:!0},"self"]}]}],r:0},{cN:"function",bK:"function",e:/\{/,eE:!0,c:[e.inherit(e.TM,{b:r}),{cN:"params",b:/\(/,e:/\)/,eB:!0,eE:!0,c:s}],i:/\[|%/},{b:/\$[(.]/},e.METHOD_GUARD,{cN:"class",bK:"class",e:/[{;=]/,eE:!0,i:/[:"\[\]]/,c:[{bK:"extends"},e.UTM]},{bK:"constructor",e:/\{/,eE:!0}],i:/#(?!!)/}});hljs.registerLanguage("xml",function(s){var e="[A-Za-z0-9\\._:-]+",t={eW:!0,i:/`]+/}]}]}]};return{aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist"],cI:!0,c:[{cN:"meta",b:"",r:10,c:[{b:"\\[",e:"\\]"}]},s.C("",{r:10}),{b:"<\\!\\[CDATA\\[",e:"\\]\\]>",r:10},{b:/<\?(php)?/,e:/\?>/,sL:"php",c:[{b:"/\\*",e:"\\*/",skip:!0}]},{cN:"tag",b:"|$)",e:">",k:{name:"style"},c:[t],starts:{e:"",rE:!0,sL:["css","xml"]}},{cN:"tag",b:"|$)",e:">",k:{name:"script"},c:[t],starts:{e:"",rE:!0,sL:["actionscript","javascript","handlebars","xml"]}},{cN:"meta",v:[{b:/<\?xml/,e:/\?>/,r:10},{b:/<\?\w+/,e:/\?>/}]},{cN:"tag",b:"",c:[{cN:"name",b:/[^\/><\s]+/,r:0},t]}]}}); \ No newline at end of file diff --git a/docs/assets/js/index.js b/docs/assets/js/index.js deleted file mode 100644 index a3a6eb3..0000000 --- a/docs/assets/js/index.js +++ /dev/null @@ -1,718 +0,0 @@ -/* global DataTable */ -/* eslint-disable no-unused-vars */ - -const { - columns, - data -} = getSampleData(); - -// Hero -let datatable1 = new DataTable('.example-1', { - columns, - data, - checkboxColumn: true -}); - -// // Formatted Cells -// let datatable2 = new DataTable('.example-2', { -// columns: ['Name', 'Position', 'Office', 'Extn.', 'Start Date', -// { content: 'Salary', format: val => '$' + val, align: 'right' }], -// data -// }); - -// // Inline Filters -// let datatable3 = new DataTable('.example-3', { -// columns, -// data, -// enableInlineFilters: true -// }); -// datatable3.showToastMessage('Click on a cell and press Ctrl/Cmd + F'); - -// // Keyboard -// let datatable4 = new DataTable('.example-4', { -// columns, -// data -// }); -// datatable4.showToastMessage('Double click to edit'); - -// // Tree Structured Rows -// let datatable5 = new DataTable('.example-5', getTreeData()); -// datatable5.showToastMessage('Expand/Collapse tree nodes'); - -function getSampleData(multiplier) { - let columns = ['Name', 'Position', 'Office', {name: 'Extn.', width: 120}, 'Start Date', 'Salary']; - let data = [ - ['Tiger Nixon', 'System Architect', 'Edinburgh', 5421, '2011/04/25', '320,800'], - ['Garrett Winters', 'Accountant', 'Tokyo', 8422, '2011/07/25', '170,750'], - ['Ashton Cox', 'Junior Technical Author', 'San Francisco', 1562, '2009/01/12', '86,000'], - ['Cedric Kelly', 'Senior Javascript Developer', 'Edinburgh', 6224, '2012/03/29', '433,060'], - ['Airi Satou', 'Accountant', 'Tokyo', 5407, '2008/11/28', '162,700'], - ['Brielle Williamson', 'Integration Specialist', 'New York', 4804, '2012/12/02', '372,000'], - ['Herrod Chandler', 'Sales Assistant', 'San Francisco', 9608, '2012/08/06', '137,500'], - ['Rhona Davidson', 'Integration Specialist', 'Tokyo', 6200, '2010/10/14', '327,900'], - ['Colleen Hurst', 'Javascript Developer', 'San Francisco', 2360, '2009/09/15', '205,500'], - ['Sonya Frost', 'Software Engineer', 'Edinburgh', 1667, '2008/12/13', '103,600'], - ['Jena Gaines', 'Office Manager', 'London', 3814, '2008/12/19', '90,560'], - ['Quinn Flynn', 'Support Lead', 'Edinburgh', 9497, '2013/03/03', '342,000'], - ['Charde Marshall', 'Regional Director', 'San Francisco', 6741, '2008/10/16', '470,600'], - ['Haley Kennedy', 'Senior Marketing Designer', 'London', 3597, '2012/12/18', '313,500'], - ['Tatyana Fitzpatrick', 'Regional Director', 'London', 1965, '2010/03/17', '385,750'], - ['Michael Silva', 'Marketing Designer', 'London', 1581, '2012/11/27', '198,500'], - ['Paul Byrd', 'Chief Financial Officer (CFO)', 'New York', 3059, '2010/06/09', '725,000'], - ['Gloria Little', 'Systems Administrator', 'New York', 1721, '2009/04/10', '237,500'], - ['Bradley Greer', 'Software Engineer', 'London', 2558, '2012/10/13', '132,000'], - ['Dai Rios', 'Personnel Lead', 'Edinburgh', 2290, '2012/09/26', '217,500'], - ['Jenette Caldwell', 'Development Lead', 'New York', 1937, '2011/09/03', '345,000'], - ['Yuri Berry', 'Chief Marketing Officer (CMO)', 'New York', 6154, '2009/06/25', '675,000'], - ['Caesar Vance', 'Pre-Sales Support', 'New York', 8330, '2011/12/12', '106,450'], - ['Doris Wilder', 'Sales Assistant', 'Sidney', 3023, '2010/09/20', '85,600'], - ['Angelica Ramos', 'Chief Executive Officer (CEO)', 'London', 5797, '2009/10/09', '1,200,000'], - ['Gavin Joyce', 'Developer', 'Edinburgh', 8822, '2010/12/22', '92,575'], - ['Jennifer Chang', 'Regional Director', 'Singapore', 9239, '2010/11/14', '357,650'], - ['Brenden Wagner', 'Software Engineer', 'San Francisco', 1314, '2011/06/07', '206,850'], - ['Fiona Green', 'Chief Operating Officer (COO)', 'San Francisco', 2947, '2010/03/11', '850,000'], - ['Shou Itou', 'Regional Marketing', 'Tokyo', 8899, '2011/08/14', '163,000'], - ['Michelle House', 'Integration Specialist', 'Sidney', 2769, '2011/06/02', '95,400'], - ['Suki Burks', 'Developer', 'London', 6832, '2009/10/22', '114,500'], - ['Prescott Bartlett', 'Technical Author', 'London', 3606, '2011/05/07', '145,000'], - ['Gavin Cortez', 'Team Leader', 'San Francisco', 2860, '2008/10/26', '235,500'], - ['Martena Mccray', 'Post-Sales support', 'Edinburgh', 8240, '2011/03/09', '324,050'], - ['Unity Butler', 'Marketing Designer', 'San Francisco', 5384, '2009/12/09', '85,675'], - ['Howard Hatfield', 'Office Manager', 'San Francisco', 7031, '2008/12/16', '164,500'], - ['Hope Fuentes', 'Secretary', 'San Francisco', 6318, '2010/02/12', '109,850'], - ['Vivian Harrell', 'Financial Controller', 'San Francisco', 9422, '2009/02/14', '452,500'], - ['Timothy Mooney', 'Office Manager', 'London', 7580, '2008/12/11', '136,200'], - ['Jackson Bradshaw', 'Director', 'New York', 1042, '2008/09/26', '645,750'], - ['Olivia Liang', 'Support Engineer', 'Singapore', 2120, '2011/02/03', '234,500'], - ['Bruno Nash', 'Software Engineer', 'London', 6222, '2011/05/03', '163,500'], - ['Sakura Yamamoto', 'Support Engineer', 'Tokyo', 9383, '2009/08/19', '139,575'], - ['Thor Walton', 'Developer', 'New York', 8327, '2013/08/11', '98,540'], - ['Finn Camacho', 'Support Engineer', 'San Francisco', 2927, '2009/07/07', '87,500'], - ['Serge Baldwin', 'Data Coordinator', 'Singapore', 8352, '2012/04/09', '138,575'], - ['Zenaida Frank', 'Software Engineer', 'New York', 7439, '2010/01/04', '125,250'], - ['Zorita Serrano', 'Software Engineer', 'San Francisco', 4389, '2012/06/01', '115,000'], - ['Jennifer Acosta', 'Junior Javascript Developer', 'Edinburgh', 3431, '2013/02/01', '75,650'], - ['Cara Stevens', 'Sales Assistant', 'New York', 3990, '2011/12/06', '145,600'], - ['Hermione Butler', 'Regional Director', 'London', 1016, '2011/03/21', '356,250'], - ['Lael Greer', 'Systems Administrator', 'London', 6733, '2009/02/27', '103,500'], - ['Jonas Alexander', 'Developer', 'San Francisco', 8196, '2010/07/14', '86,500'], - ['Shad Decker', 'Regional Director', 'Edinburgh', 6373, '2008/11/13', '183,000'], - ['Michael Bruce', 'Javascript Developer', 'Singapore', 5384, '2011/06/27', '183,000'], - ['Donna Snider', 'Customer Support', 'New York', 4226, '2011/01/25', '112,000'] - ]; - - if (multiplier) { - Array.from(new Array(multiplier - 1)).forEach(d => { - data = data.concat(data); - }); - } - - return { - columns, - data - }; -} - -function getTreeData() { - return { - columns: [{ - 'id': 'account', - 'content': 'Account' - }, { - 'id': 'opening_debit', - 'content': 'Opening (Dr)' - }, { - 'id': 'opening_credit', - 'content': 'Opening (Cr)' - }, - // { - // 'id': 'debit', - // 'content': 'Debit' - // }, - // { - // 'id': 'credit', - // 'content': 'Credit' - // }, - { - 'id': 'closing_debit', - 'content': 'Closing (Dr)' - }, { - 'id': 'closing_credit', - 'content': 'Closing (Cr)' - }, { - 'id': 'currency', - 'content': 'Currency', - 'hidden': 1 - }], - data: [{ - 'account_name': 'Application of Funds (Assets)', - 'account': 'Application of Funds (Assets)', - 'parent_account': null, - 'indent': 0, - 'from_date': '2018-04-01', - 'to_date': '2019-03-31', - 'currency': 'INR', - 'opening_debit': 12023729.54, - 'opening_credit': 0.0, - 'debit': 0.0, - 'credit': 0.0, - 'closing_debit': 12023729.54, - 'closing_credit': 0.0, - 'has_value': true - }, { - 'account_name': 'Current Assets', - 'account': 'Current Assets', - 'parent_account': 'Application of Funds (Assets)', - 'indent': 1, - 'from_date': '2018-04-01', - 'to_date': '2019-03-31', - 'currency': 'INR', - 'opening_debit': 13960649.54, - 'opening_credit': 0.0, - 'debit': 0.0, - 'credit': 0.0, - 'closing_debit': 13960649.54, - 'closing_credit': 0.0, - 'has_value': true - }, { - 'account_name': 'Accounts Receivable', - 'account': 'Accounts Receivable', - 'parent_account': 'Current Assets', - 'indent': 2, - 'from_date': '2018-04-01', - 'to_date': '2019-03-31', - 'currency': 'INR', - 'opening_debit': 742790.474, - 'opening_credit': 0.0, - 'debit': 0.0, - 'credit': 0.0, - 'closing_debit': 742790.474, - 'closing_credit': 0.0, - 'has_value': true - }, { - 'account_name': 'Debtors', - 'account': 'Debtors', - 'parent_account': 'Accounts Receivable', - 'indent': 3, - 'from_date': '2018-04-01', - 'to_date': '2019-03-31', - 'currency': 'INR', - 'opening_debit': 742790.474, - 'opening_credit': 0.0, - 'debit': 0.0, - 'credit': 0.0, - 'closing_debit': 742790.474, - 'closing_credit': 0.0, - 'has_value': true - }, { - 'account_name': 'Bank Accounts', - 'account': 'Bank Accounts', - 'parent_account': 'Current Assets', - 'indent': 2, - 'from_date': '2018-04-01', - 'to_date': '2019-03-31', - 'currency': 'INR', - 'opening_debit': 280676.822, - 'opening_credit': 0.0, - 'debit': 0.0, - 'credit': 0.0, - 'closing_debit': 280676.822, - 'closing_credit': 0.0, - 'has_value': true - }, { - 'account_name': 'Corporation Bank', - 'account': 'Corporation Bank', - 'parent_account': 'Bank Accounts', - 'indent': 3, - 'from_date': '2018-04-01', - 'to_date': '2019-03-31', - 'currency': 'INR', - 'opening_debit': 290676.822, - 'opening_credit': 0.0, - 'debit': 0.0, - 'credit': 0.0, - 'closing_debit': 290676.822, - 'closing_credit': 0.0, - 'has_value': true - }, { - 'account_name': 'HDFC Bank', - 'account': 'HDFC Bank', - 'parent_account': 'Bank Accounts', - 'indent': 3, - 'from_date': '2018-04-01', - 'to_date': '2019-03-31', - 'currency': 'INR', - 'opening_debit': 0.0, - 'opening_credit': 10000.0, - 'debit': 0.0, - 'credit': 0.0, - 'closing_debit': 0.0, - 'closing_credit': 10000.0, - 'has_value': true - }, { - 'account_name': 'Cash In Hand', - 'account': 'Cash In Hand', - 'parent_account': 'Current Assets', - 'indent': 2, - 'from_date': '2018-04-01', - 'to_date': '2019-03-31', - 'currency': 'INR', - 'opening_debit': 229904.494, - 'opening_credit': 0.0, - 'debit': 0.0, - 'credit': 0.0, - 'closing_debit': 229904.494, - 'closing_credit': 0.0, - 'has_value': true - }, { - 'account_name': 'Cash', - 'account': 'Cash', - 'parent_account': 'Cash In Hand', - 'indent': 3, - 'from_date': '2018-04-01', - 'to_date': '2019-03-31', - 'currency': 'INR', - 'opening_debit': 229904.494, - 'opening_credit': 0.0, - 'debit': 0.0, - 'credit': 0.0, - 'closing_debit': 229904.494, - 'closing_credit': 0.0, - 'has_value': true - }, { - 'account_name': 'Stock Assets', - 'account': 'Stock Assets', - 'parent_account': 'Current Assets', - 'indent': 2, - 'from_date': '2018-04-01', - 'to_date': '2019-03-31', - 'currency': 'INR', - 'opening_debit': 12707277.75, - 'opening_credit': 0.0, - 'debit': 0.0, - 'credit': 0.0, - 'closing_debit': 12707277.75, - 'closing_credit': 0.0, - 'has_value': true - }, { - 'account_name': 'All Warehouses', - 'account': 'All Warehouses', - 'parent_account': 'Stock Assets', - 'indent': 3, - 'from_date': '2018-04-01', - 'to_date': '2019-03-31', - 'currency': 'INR', - 'opening_debit': 12707277.75, - 'opening_credit': 0.0, - 'debit': 0.0, - 'credit': 0.0, - 'closing_debit': 12707277.75, - 'closing_credit': 0.0, - 'has_value': true - }, { - 'account_name': 'Finished Goods', - 'account': 'Finished Goods', - 'parent_account': 'All Warehouses', - 'indent': 4, - 'from_date': '2018-04-01', - 'to_date': '2019-03-31', - 'currency': 'INR', - 'opening_debit': 87320.3, - 'opening_credit': 0.0, - 'debit': 0.0, - 'credit': 0.0, - 'closing_debit': 87320.3, - 'closing_credit': 0.0, - 'has_value': true - }, { - 'account_name': 'Retail Stores', - 'account': 'Retail Stores', - 'parent_account': 'All Warehouses', - 'indent': 4, - 'from_date': '2018-04-01', - 'to_date': '2019-03-31', - 'currency': 'INR', - 'opening_debit': 4540590.0, - 'opening_credit': 0.0, - 'debit': 0.0, - 'credit': 0.0, - 'closing_debit': 4540590.0, - 'closing_credit': 0.0, - 'has_value': true - }, { - 'account_name': 'Bandra Store', - 'account': 'Bandra Store', - 'parent_account': 'Retail Stores', - 'indent': 5, - 'from_date': '2018-04-01', - 'to_date': '2019-03-31', - 'currency': 'INR', - 'opening_debit': 3246800.0, - 'opening_credit': 0.0, - 'debit': 0.0, - 'credit': 0.0, - 'closing_debit': 3246800.0, - 'closing_credit': 0.0, - 'has_value': true - }, { - 'account_name': 'Central Warehouse', - 'account': 'Central Warehouse', - 'parent_account': 'Retail Stores', - 'indent': 5, - 'from_date': '2018-04-01', - 'to_date': '2019-03-31', - 'currency': 'INR', - 'opening_debit': 1236790.0, - 'opening_credit': 0.0, - 'debit': 0.0, - 'credit': 0.0, - 'closing_debit': 1236790.0, - 'closing_credit': 0.0, - 'has_value': true - }, { - 'account_name': 'Lower Parel Store', - 'account': 'Lower Parel Store', - 'parent_account': 'Retail Stores', - 'indent': 5, - 'from_date': '2018-04-01', - 'to_date': '2019-03-31', - 'currency': 'INR', - 'opening_debit': 57000.0, - 'opening_credit': 0.0, - 'debit': 0.0, - 'credit': 0.0, - 'closing_debit': 57000.0, - 'closing_credit': 0.0, - 'has_value': true - }, { - 'account_name': 'Stores', - 'account': 'Stores', - 'parent_account': 'All Warehouses', - 'indent': 4, - 'from_date': '2018-04-01', - 'to_date': '2019-03-31', - 'currency': 'INR', - 'opening_debit': 8016525.27, - 'opening_credit': 0.0, - 'debit': 0.0, - 'credit': 0.0, - 'closing_debit': 8016525.27, - 'closing_credit': 0.0, - 'has_value': true - }, { - 'account_name': 'Work In Progress', - 'account': 'Work In Progress', - 'parent_account': 'All Warehouses', - 'indent': 4, - 'from_date': '2018-04-01', - 'to_date': '2019-03-31', - 'currency': 'INR', - 'opening_debit': 62842.18, - 'opening_credit': 0.0, - 'debit': 0.0, - 'credit': 0.0, - 'closing_debit': 62842.18, - 'closing_credit': 0.0, - 'has_value': true - }, { - 'account_name': 'Fixed Assets', - 'account': 'Fixed Assets', - 'parent_account': 'Application of Funds (Assets)', - 'indent': 1, - 'from_date': '2018-04-01', - 'to_date': '2019-03-31', - 'currency': 'INR', - 'opening_debit': 0.0, - 'opening_credit': 19920.0, - 'debit': 0.0, - 'credit': 0.0, - 'closing_debit': 0.0, - 'closing_credit': 19920.0, - 'has_value': true - }, { - 'account_name': 'Electronic Equipments', - 'account': 'Electronic Equipments', - 'parent_account': 'Fixed Assets', - 'indent': 2, - 'from_date': '2018-04-01', - 'to_date': '2019-03-31', - 'currency': 'INR', - 'opening_debit': 80.0, - 'opening_credit': 0.0, - 'debit': 0.0, - 'credit': 0.0, - 'closing_debit': 80.0, - 'closing_credit': 0.0, - 'has_value': true - }, { - 'account_name': 'Furnitures and Fixtures', - 'account': 'Furnitures and Fixtures', - 'parent_account': 'Fixed Assets', - 'indent': 2, - 'from_date': '2018-04-01', - 'to_date': '2019-03-31', - 'currency': 'INR', - 'opening_debit': 0.0, - 'opening_credit': 20000.0, - 'debit': 0.0, - 'credit': 0.0, - 'closing_debit': 0.0, - 'closing_credit': 20000.0, - 'has_value': true - }, { - 'account_name': 'Temporary Accounts', - 'account': 'Temporary Accounts', - 'parent_account': 'Application of Funds (Assets)', - 'indent': 1, - 'from_date': '2018-04-01', - 'to_date': '2019-03-31', - 'currency': 'INR', - 'opening_debit': 0.0, - 'opening_credit': 1917000.0, - 'debit': 0.0, - 'credit': 0.0, - 'closing_debit': 0.0, - 'closing_credit': 1917000.0, - 'has_value': true - }, { - 'account_name': 'Temporary Opening', - 'account': 'Temporary Opening', - 'parent_account': 'Temporary Accounts', - 'indent': 2, - 'from_date': '2018-04-01', - 'to_date': '2019-03-31', - 'currency': 'INR', - 'opening_debit': 0.0, - 'opening_credit': 1917000.0, - 'debit': 0.0, - 'credit': 0.0, - 'closing_debit': 0.0, - 'closing_credit': 1917000.0, - 'has_value': true - }, { - 'account_name': 'Source of Funds (Liabilities)', - 'account': 'Source of Funds (Liabilities)', - 'parent_account': null, - 'indent': 0, - 'from_date': '2018-04-01', - 'to_date': '2019-03-31', - 'currency': 'INR', - 'opening_debit': 0.0, - 'opening_credit': 2371628.002, - 'debit': 0.0, - 'credit': 0.0, - 'closing_debit': 0.0, - 'closing_credit': 2371628.002, - 'has_value': true - }, { - 'account_name': 'Current Liabilities', - 'account': 'Current Liabilities', - 'parent_account': 'Source of Funds (Liabilities)', - 'indent': 1, - 'from_date': '2018-04-01', - 'to_date': '2019-03-31', - 'currency': 'INR', - 'opening_debit': 0.0, - 'opening_credit': 2371628.002, - 'debit': 0.0, - 'credit': 0.0, - 'closing_debit': 0.0, - 'closing_credit': 2371628.002, - 'has_value': true - }, { - 'account_name': 'Accounts Payable', - 'account': 'Accounts Payable', - 'parent_account': 'Current Liabilities', - 'indent': 2, - 'from_date': '2018-04-01', - 'to_date': '2019-03-31', - 'currency': 'INR', - 'opening_debit': 0.0, - 'opening_credit': 368311.85, - 'debit': 0.0, - 'credit': 0.0, - 'closing_debit': 0.0, - 'closing_credit': 368311.85, - 'has_value': true - }, { - 'account_name': 'Creditors', - 'account': 'Creditors', - 'parent_account': 'Accounts Payable', - 'indent': 3, - 'from_date': '2018-04-01', - 'to_date': '2019-03-31', - 'currency': 'INR', - 'opening_debit': 0.0, - 'opening_credit': 194871.85, - 'debit': 0.0, - 'credit': 0.0, - 'closing_debit': 0.0, - 'closing_credit': 194871.85, - 'has_value': true - }, { - 'account_name': 'Salary Payable', - 'account': 'Salary Payable', - 'parent_account': 'Accounts Payable', - 'indent': 3, - 'from_date': '2018-04-01', - 'to_date': '2019-03-31', - 'currency': 'INR', - 'opening_debit': 0.0, - 'opening_credit': 173440.0, - 'debit': 0.0, - 'credit': 0.0, - 'closing_debit': 0.0, - 'closing_credit': 173440.0, - 'has_value': true - }, { - 'account_name': 'Duties and Taxes', - 'account': 'Duties and Taxes', - 'parent_account': 'Current Liabilities', - 'indent': 2, - 'from_date': '2018-04-01', - 'to_date': '2019-03-31', - 'currency': 'INR', - 'opening_debit': 0.0, - 'opening_credit': 150146.822, - 'debit': 0.0, - 'credit': 0.0, - 'closing_debit': 0.0, - 'closing_credit': 150146.822, - 'has_value': true - }, { - 'account_name': 'CGST', - 'account': 'CGST', - 'parent_account': 'Duties and Taxes', - 'indent': 3, - 'from_date': '2018-04-01', - 'to_date': '2019-03-31', - 'currency': 'INR', - 'opening_debit': 0.0, - 'opening_credit': 51479.591, - 'debit': 0.0, - 'credit': 0.0, - 'closing_debit': 0.0, - 'closing_credit': 51479.591, - 'has_value': true - }, { - 'account_name': 'IGST', - 'account': 'IGST', - 'parent_account': 'Duties and Taxes', - 'indent': 3, - 'from_date': '2018-04-01', - 'to_date': '2019-03-31', - 'currency': 'INR', - 'opening_debit': 1944.0, - 'opening_credit': 0.0, - 'debit': 0.0, - 'credit': 0.0, - 'closing_debit': 1944.0, - 'closing_credit': 0.0, - 'has_value': true - }, { - 'account_name': 'SGST', - 'account': 'SGST', - 'parent_account': 'Duties and Taxes', - 'indent': 3, - 'from_date': '2018-04-01', - 'to_date': '2019-03-31', - 'currency': 'INR', - 'opening_debit': 0.0, - 'opening_credit': 97711.231, - 'debit': 0.0, - 'credit': 0.0, - 'closing_debit': 0.0, - 'closing_credit': 97711.231, - 'has_value': true - }, { - 'account_name': 'UGST', - 'account': 'UGST', - 'parent_account': 'Duties and Taxes', - 'indent': 3, - 'from_date': '2018-04-01', - 'to_date': '2019-03-31', - 'currency': 'INR', - 'opening_debit': 0.0, - 'opening_credit': 2900.0, - 'debit': 0.0, - 'credit': 0.0, - 'closing_debit': 0.0, - 'closing_credit': 2900.0, - 'has_value': true - }, { - 'account_name': 'Stock Liabilities', - 'account': 'Stock Liabilities', - 'parent_account': 'Current Liabilities', - 'indent': 2, - 'from_date': '2018-04-01', - 'to_date': '2019-03-31', - 'currency': 'INR', - 'opening_debit': 0.0, - 'opening_credit': 1853169.33, - 'debit': 0.0, - 'credit': 0.0, - 'closing_debit': 0.0, - 'closing_credit': 1853169.33, - 'has_value': true - }, { - 'account_name': 'Stock Received But Not Billed', - 'account': 'Stock Received But Not Billed', - 'parent_account': 'Stock Liabilities', - 'indent': 3, - 'from_date': '2018-04-01', - 'to_date': '2019-03-31', - 'currency': 'INR', - 'opening_debit': 0.0, - 'opening_credit': 1853169.33, - 'debit': 0.0, - 'credit': 0.0, - 'closing_debit': 0.0, - 'closing_credit': 1853169.33, - 'has_value': true - }, { - 'account_name': 'Equity', - 'account': 'Equity', - 'parent_account': null, - 'indent': 0, - 'from_date': '2018-04-01', - 'to_date': '2019-03-31', - 'currency': 'INR', - 'opening_debit': 0.0, - 'opening_credit': 10000.0, - 'debit': 0.0, - 'credit': 0.0, - 'closing_debit': 0.0, - 'closing_credit': 10000.0, - 'has_value': true - }, { - 'account_name': 'Capital Stock', - 'account': 'Capital Stock', - 'parent_account': 'Equity', - 'indent': 1, - 'from_date': '2018-04-01', - 'to_date': '2019-03-31', - 'currency': 'INR', - 'opening_debit': 0.0, - 'opening_credit': 10000.0, - 'debit': 0.0, - 'credit': 0.0, - 'closing_debit': 0.0, - 'closing_credit': 10000.0, - 'has_value': true - }, {}, { - 'account': 'Total', - 'account_name': 'Total', - 'warn_if_negative': true, - 'opening_debit': 32260956.43, - 'opening_credit': 22618854.891999997, - 'debit': 0.0, - 'credit': 0.0, - 'closing_debit': 32260956.43, - 'closing_credit': 22618854.891999997, - 'parent_account': null, - 'indent': 0, - 'has_value': true, - 'currency': 'INR' - }] - }; -} diff --git a/docs/index.html b/docs/index.html deleted file mode 100644 index 7f75756..0000000 --- a/docs/index.html +++ /dev/null @@ -1,172 +0,0 @@ - - - - - - - Frappe DataTable - A simple, modern datatable library for the web - - - - - - -
- -
- -

A simple, modern and interactive
datatable for the web

-
-
- -
-

Installation

-
-
# Install using yarn
-$ yarn add frappe-datatable
-
-# or npm
-$ npm install frappe-datatable
-
- -
-

Usage

-
-
import DataTable from 'frappe-datatable';
-
-// or add
-// <script src="frappe-datatable.js" ></script>
-// in your html
-
-let datatable = new DataTable({
-    columns: ['Name', 'Position', ...],
-    data: [
-        ['Tiger Nixon', 'System Architect', ...],
-        ['Garrett Winters', 'Accountant', ...],
-        ...
-    ]
-});
-
-
-

Cell Features

-
-
    -
  • Custom Formatters
  • -
  • Inline Editing
  • -
  • Mouse Selection
  • -
-
    -
  • Copy Cells
  • -
  • Keyboard Navigation
  • -
  • Custom Cell Editor
  • -
-
-
- -
-

Column Features

-
-
    -
  • Reorder Columns
  • -
  • Sort by Column
  • -
  • Remove / Hide Column
  • -
-
    -
  • Custom Actions
  • -
  • Resize Column
  • -
  • Flexible Layout
  • -
-
-
- -
-

Row Features

- -
-
    -
  • Row Selection
  • -
  • Tree Structured Rows
  • -
  • Inline Filters
  • -
-
    -
  • Large Number of Rows
  • -
  • Dynamic Row Height
  • -
-
-
- -
-

List of configurable options

-
-
{
-    columns: [],
-    data: [],
-    dropdownButton: '▼',
-    headerDropdown: [
-        {
-            label: 'Custom Action',
-            action: console.log
-        }
-    ],
-    events: {
-        onRemoveColumn(column) {
-
-        },
-        onSwitchColumn(column1, column2) {
-
-        },
-        onSortColumn(column) {
-
-        }
-    },
-    sortIndicator: {
-        asc: '↑',
-        desc: '↓',
-        none: ''
-    },
-    freezeMessage: '',
-    getEditor: () => {
-
-    },
-    addSerialNoColumn: true,
-    addCheckboxColumn: false,
-    enableClusterize: true,
-    enableLogs: false,
-    layout: 'fixed', // fixed, fluid
-    noDataMessage: 'No Data',
-    cellHeight: null,
-    enableInlineFilters: false
-}
-
-
-
-

- -

-

- View on GitHub -

-

- MIT License -

-
-
-
- -
Made with ❤️ by Frappe
-
- - - - - - - -