column-resizer
Advanced tools
Comparing version 1.3.6 to 1.4.0
@@ -10,3 +10,3 @@ { | ||
"extends": "eslint:recommended", | ||
"parser": "babel-eslint", | ||
"parser": "@babel/eslint-parser", | ||
"parserOptions": { | ||
@@ -13,0 +13,0 @@ "sourceType": "module" |
@@ -0,1 +1,8 @@ | ||
<a name="v1.4.0"></a> | ||
# [v1.4.0] Initial commit (2023-1-17) | ||
## Bug fixes | ||
## Enhancement | ||
* Security update [9d8282e](https://github.com/jglynn43/column-resizer/commit/54a6f9951a19b826c51cde8c37aafd73e663eb15) (2023-1-17) | ||
<a name="v1.3.6"></a> | ||
@@ -2,0 +9,0 @@ # [v1.3.6](https://github.com/MonsantoCo/column-resizer/compare/v1.3.5...v1.3.6) (2020-12-04) |
@@ -1,2 +0,2 @@ | ||
!function webpackUniversalModuleDefinition(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.ColumnResizer=t():e.ColumnResizer=t()}(this,(function(){return(()=>{"use strict";var e={67:(e,t,r)=>{r.r(t),r.d(t,{default:()=>a});var i=r(887),o=r.n(i);function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var n,l=(n=0,function(){return n++}),a=function ColumnResizer(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};_classCallCheck(this,ColumnResizer),_defineProperty(this,"ID","id"),_defineProperty(this,"PX","px"),_defineProperty(this,"RESIZABLE","grip-resizable"),_defineProperty(this,"FLEX","grip-flex"),_defineProperty(this,"legacyIE",navigator.userAgent.indexOf("Trident/4.0")>0),_defineProperty(this,"reset",(function(e){return t.init(e)})),_defineProperty(this,"onResize",(function(){var e=t.tb;if(e.classList.remove(t.RESIZABLE),e.opt.fixed){e.tableWidth=Number(window.getComputedStyle(e).width.replace(/px/,"")).valueOf();for(var r=0,i=0;i<e.columnCnt;i++)r+=e.columns[i].w;for(var o=0;o<e.columnCnt;o++)e.columns[o].style.width=Math.round(1e3*e.columns[o].w/r)/10+"%",e.columns[o].locked=!0}else t.applyBounds(),"flex"===e.opt.resizeMode&&e.opt.serialize&&t.serializeStore();e.classList.add(t.RESIZABLE),t.syncGrips()})),_defineProperty(this,"onGripMouseDown",(function(e){var r=e.target.parentNode.data,i=t.tb,o=i.grips[r.i],n=e.touches;if(o.ox=n?n[0].pageX:e.pageX,o.l=o.offsetLeft,o.x=o.l,t.createStyle(document.querySelector("head"),"*{cursor:"+i.opt.dragCursor+"!important}"),document.addEventListener("touchmove",t.onGripDrag),document.addEventListener("mousemove",t.onGripDrag),document.addEventListener("touchend",t.onGripDragOver),document.addEventListener("mouseup",t.onGripDragOver),o.classList.add(i.opt.draggingClass),t.grip=o,i.columns[r.i].locked)for(var l,a=0;a<i.columnCnt;a++)(l=i.columns[a]).locked=!1,l.w=Number(window.getComputedStyle(l).width.replace(/px/,"")).valueOf();e.preventDefault()})),_defineProperty(this,"onGripDrag",(function(e){var r=t.grip;if(r){var i=r.t,o=e.touches,n=(o?o[0].pageX:e.pageX)-r.ox+r.l,l=i.opt.minWidth,a=r.i,s=1.5*i.cellSpace+l+i.borderSpace,d=a===i.columnCnt-1,p=a?i.grips[a-1].offsetLeft+i.cellSpace+l:s,u=i.opt.fixed?a===i.columnCnt-1?i.tableWidth-s:i.grips[a+1].offsetLeft-i.cellSpace-l:1/0;if(n=Math.max(p,Math.min(u,n)),r.x=n,r.style.left=n+t.PX,d&&(r.w=i.columns[a].w+n-r.l),i.opt.liveDrag){d?(i.columns[a].style.width=r.w+t.PX,!i.opt.fixed&&i.opt.overflow?i.style.minWidth=i.tableWidth+n-r.l+t.PX:i.tableWidth=Number(window.getComputedStyle(i).width.replace(/px/,"")).valueOf()):t.syncCols(i,a,!1,i.opt),t.syncGrips();var c=i.opt.onDrag;c&&c(e)}e.preventDefault()}})),_defineProperty(this,"onGripDragOver",(function(e){var r=t.grip;document.removeEventListener("touchend",t.onGripDragOver),document.removeEventListener("mouseup",t.onGripDragOver),document.removeEventListener("touchmove",t.onGripDrag),document.removeEventListener("mousemove",t.onGripDrag);var i=document.querySelector("head").lastChild;if(i.parentNode.removeChild(i),r){if(r.classList.remove(r.t.opt.draggingClass),r.x-r.l!=0){var o=r.t,n=o.opt.onResize,l=r.i;if(l===o.columnCnt-1){var a=o.columns[l];a.style.width=r.w+t.PX,a.w=r.w}else t.syncCols(o,l,!0,o.opt);o.opt.fixed||t.applyBounds(),t.syncGrips(),n&&n(e),o.opt.serialize&&t.serializeStore()}t.grip=null}})),_defineProperty(this,"init",(function(e){if(e.disable)return t.destroy();var r=t.tb,i=r.getAttribute(t.ID)||t.RESIZABLE+l();if(!r.matches("table")||r.extended&&!e.partialRefresh)return null;var o=document.querySelector("head");if(t.createStyle(o," .grip-resizable{table-layout:fixed;} .grip-resizable > tbody > tr > td, .grip-resizable > tbody > tr > th{overflow:hidden} .grip-padding > tbody > tr > td, .grip-padding > tbody > tr > th{padding-left:0!important; padding-right:0!important;} .grip-container{ height:0px; position:relative;} .grip-handle{margin-left:-5px; position:absolute; z-index:5; } .grip-handle .grip-resizable{position:absolute;background-color:red;filter:alpha(opacity=1);opacity:0;width:10px;height:100%;cursor: col-resize;top:0px} .grip-lastgrip{position:absolute; width:1px; } .grip-drag{ border-left:1px dotted black;\t} .grip-flex{width:auto!important;} .grip-handle.grip-disabledgrip .grip-resizable{cursor:default; display:none;}"),e.hoverCursor&&"col-resize"!==e.hoverCursor){var n=".grip-handle .grip-resizable:hover{cursor:"+e.hoverCursor+"!important}";t.createStyle(o,n)}r.setAttribute(t.ID,i);var a=r.opt;r.opt=t.extendOptions(e);var s=t.getTableHeaders(r);if(t.extendTable(s),e.remoteTable&&e.remoteTable.matches("table")){var d=t.getTableHeaders(r.opt.remoteTable);s.length===d.length?t.extendRemoteTable(r.opt.remoteTable,d,r):console.warn("column count for remote table did not match")}return a})),_defineProperty(this,"applyBounds",(function(){var e=t.tb,r=e.columns.map((function(e){return window.getComputedStyle(e).width}));e.style.width=window.getComputedStyle(e).width,e.tableWidth=Number(e.style.width.replace(/px/,"")).valueOf(),e.classList.remove(t.FLEX),e.columns.forEach((function(e,t){e.style.width=r[t],e.w=Number(r[t].replace(/px/,"")).valueOf()})),e.classList.add(t.FLEX)})),_defineProperty(this,"serializeStore",(function(){var e=t.store,r=t.tb;e[r.getAttribute(t.ID)]="";for(var i=0,o=0;o<r.columns.length;o++){var n=window.getComputedStyle(r.columns[o]).width.replace(/px/,"");e[r.getAttribute(t.ID)]+=n+";",i+=Number(n).valueOf()}e[r.getAttribute(t.ID)]+=i.toString(),r.opt.fixed||(e[r.getAttribute(t.ID)]+=";"+window.getComputedStyle(r).width.replace(/px/,""))})),_defineProperty(this,"syncGrips",(function(){var e=t.tb;e.gripContainer.style.width=e.tableWidth+t.PX;for(var r=0;r<e.columnCnt;r++){var i=e.columns[r],o=i.getBoundingClientRect(),n=e.getBoundingClientRect();e.grips[r].style.left=o.left-n.left+i.offsetWidth+e.cellSpace/2+t.PX,e.grips[r].style.height=(e.opt.headerOnly?e.columns[0].offsetHeight:e.offsetHeight)+t.PX}})),_defineProperty(this,"destroy",(function(){var e=t.tb,r=e.getAttribute(t.ID);return r?(t.store[r]="",e.classList.remove(t.RESIZABLE),e.classList.remove(t.FLEX),e.remote&&(e.remote.classList.remove(t.RESIZABLE),e.remote.classList.remove(t.FLEX)),e.gripContainer&&e.gripContainer.parentNode&&e.gripContainer.parentNode.removeChild(e.gripContainer),delete e.extended,e.opt):null})),_defineProperty(this,"createStyle",(function(e,t){var r=o()(t).toString(),i=e.querySelectorAll("style");if(!Array.from(i).filter((function(e){return e.gripid===r})).length){var n=document.createElement("style");n.type="text/css",n.gripid=r,n.styleSheet?n.styleSheet.cssText=t:n.appendChild(document.createTextNode(t)),e.appendChild(n)}})),_defineProperty(this,"extendOptions",(function(e){var t=Object.assign({},ColumnResizer.DEFAULTS,e);switch(t.fixed=!0,t.overflow=!1,t.resizeMode){case"flex":t.fixed=!1;break;case"overflow":t.fixed=!1,t.overflow=!0}return t})),_defineProperty(this,"getTableHeaders",(function(e){var r="#"+e.id,i=Array.from(e.querySelectorAll(r+">thead>tr:nth-of-type(1)>th"));return(i=i.concat(Array.from(e.querySelectorAll(r+">thead>tr:nth-of-type(1)>td")))).length||(i=(i=(i=(i=Array.from(e.querySelectorAll(r+">tbody>tr:nth-of-type(1)>th"))).concat(Array.from(e.querySelectorAll(r+">tr:nth-of-type(1)>th")))).concat(Array.from(e.querySelectorAll(r+">tbody>tr:nth-of-type(1)>td")))).concat(Array.from(e.querySelectorAll(r+">tr:nth-of-type(1)>td")))),t.filterInvisible(i,!1)})),_defineProperty(this,"filterInvisible",(function(e,t){return e.filter((function(e){var r=t?-1:e.offsetWidth,i=t?-1:e.offsetHeight;return!(0===r&&0===i||e.style&&e.style.display&&"none"===window.getComputedStyle(e).display||!1)}))})),_defineProperty(this,"extendTable",(function(e){var r=t.tb;r.opt.removePadding&&r.classList.add("grip-padding"),r.classList.add(t.RESIZABLE),r.insertAdjacentHTML("beforebegin",'<div class="grip-container"/>'),r.grips=[],r.columns=[],r.tableWidth=Number(window.getComputedStyle(r).width.replace(/px/,"")).valueOf(),r.gripContainer=r.previousElementSibling,r.opt.marginLeft&&(r.gripContainer.style.marginLeft=r.opt.marginLeft),r.opt.marginRight&&(r.gripContainer.style.marginRight=r.opt.marginRight),r.cellSpace=parseInt(t.legacyIE?r.cellSpacing||r.currentStyle.borderSpacing:window.getComputedStyle(r).borderSpacing.split(" ")[0].replace(/px/,""))||2,r.borderSpace=parseInt(t.legacyIE?r.border||r.currentStyle.borderLeftWidth:window.getComputedStyle(r).borderLeftWidth.replace(/px/,""))||1,r.extended=!0,t.createGrips(e)})),_defineProperty(this,"extendRemoteTable",(function(e,r,i){i.opt.removePadding&&e.classList.add("grip-padding"),e.classList.add(t.RESIZABLE),e.getAttribute(t.ID)||e.setAttribute(t.ID,i.getAttribute(t.ID)+"remote"),e.columns=[],r.forEach((function(o,n){var l=r[n];l.w=i.columns[n].w,l.style.width=l.w+t.PX,l.removeAttribute("width"),e.columns.push(l)})),e.tableWidth=i.tableWidth,e.cellSpace=i.cellSpace,e.borderSpace=i.borderSpace;var o=Array.from(e.querySelectorAll("col"));e.columnGrp=t.filterInvisible(o,!0),e.columnGrp.forEach((function(e,t){e.removeAttribute("width"),e.style.width=i.columnGrp[t].style.width})),i.remote=e})),_defineProperty(this,"createGrips",(function(e){var r=t.tb;r.columnGrp=t.filterInvisible(Array.from(r.querySelectorAll("col")),!0),r.columnGrp.forEach((function(e){e.removeAttribute("width")})),r.columnCnt=e.length;var i=!1;t.store[r.getAttribute(t.ID)]&&(t.deserializeStore(e),i=!0),r.opt.widths||(r.opt.widths=[]),e.forEach((function(o,n){var l=e[n],a=-1!==r.opt.disabledColumns.indexOf(n);t.createDiv(r.gripContainer,"grip-handle");var s=r.gripContainer.lastChild;!a&&r.opt.gripInnerHtml&&(s.innerHTML=r.opt.gripInnerHtml),t.createDiv(s,t.RESIZABLE),n===r.columnCnt-1&&(s.classList.add("grip-lastgrip"),r.opt.fixed&&(s.innerHTML="")),s.addEventListener("touchstart",t.onGripMouseDown,{capture:!0,passive:!0}),s.addEventListener("mousedown",t.onGripMouseDown,!0),a?s.classList.add("grip-disabledgrip"):(s.classList.remove("grip-disabledgrip"),s.addEventListener("touchstart",t.onGripMouseDown,{capture:!0,passive:!0}),s.addEventListener("mousedown",t.onGripMouseDown,!0)),s.t=r,s.i=n,r.opt.widths[n]?l.w=r.opt.widths[n]:l.w=i?Number(l.style.width.replace(/px/,"")).valueOf():Number(window.getComputedStyle(l).width.replace(/px/,"")).valueOf(),l.style.width=l.w+t.PX,l.removeAttribute("width"),s.data={i:n,t:r.getAttribute(t.ID),last:n===r.columnCnt-1},r.grips.push(s),r.columns.push(l)}));var o=Array.from(r.querySelectorAll("td"));o.concat(Array.from(r.querySelectorAll("th"))),(o=(o=o.filter((function(t){for(var r=0;r<e.length;r++)if(e[r]===t)return!1;return!0}))).filter((function(e){return!(e.querySelectorAll("table th").length||e.querySelectorAll("table td").length)}))).forEach((function(e){e.removeAttribute("width")})),r.opt.fixed||(r.removeAttribute("width"),r.classList.add(t.FLEX)),t.syncGrips()})),_defineProperty(this,"deserializeStore",(function(e){var r=t.tb;if(r.columnGrp.forEach((function(e){e.removeAttribute("width")})),r.opt.flush)t.store[r.getAttribute(t.ID)]="";else{var i=t.store[r.getAttribute(t.ID)].split(";"),o=i[r.columnCnt+1];!r.opt.fixed&&o&&(r.style.width=o+t.PX,r.opt.overflow&&(r.style.minWidth=o+t.PX,r.tableWidth=Number(o).valueOf()));for(var n=0;n<r.columnCnt;n++)e[n].style.width=i[n]+t.PX,r.columnGrp[n]&&(r.columnGrp[n].style.width=100*Number(i[n]).valueOf()/Number(i[r.columnCnt]).valueOf()+"%")}})),_defineProperty(this,"createDiv",(function(e,t,r){var i=document.createElement("div");i.classList.add(t),r&&(i.innerHTML=r),e.appendChild(i)})),_defineProperty(this,"syncCols",(function(e,r,i,o){var n=e.remote,l=t.grip.x-t.grip.l,a=e.columns[r],s=e.columns[r+1];if(a&&s){var d=a.w+l,p=s.w-l,u=d+t.PX;if(a.style.width=u,e.columnGrp[r]&&e.columnGrp[r].style.width&&(e.columnGrp[r].style.width=u),n&&(n.columns[r].style.width=u,n.columnGrp[r]&&n.columnGrp[r].style.width&&(n.columnGrp[r].style.width=u)),o.fixed){var c=p+t.PX;s.style.width=c,e.columnGrp[r+1]&&e.columnGrp[r+1].style.width&&(e.columnGrp[r+1].style.width=c),n&&(n.columns[r+1].style.width=c,n.columnGrp[r+1]&&n.columnGrp[r+1].style.width&&(n.columnGrp[r+1].style.width=c))}else o.overflow&&(e.style.minWidth=e.tableWidth+l+t.PX);i&&(a.w=d,s.w=o.fixed?p:s.w,n&&(n.columns[r].w=d,n.columns[r+1].w=o.fixed?p:s.w))}}));try{this.store=sessionStorage}catch(e){this.store={}}this.grip=null,this.tb=e,window.addEventListener("resize",this.onResize),Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector),this.init(r)};a.DEFAULTS={resizeMode:"fit",draggingClass:"grip-drag",gripInnerHtml:"",liveDrag:!1,minWidth:15,headerOnly:!1,hoverCursor:"col-resize",dragCursor:"col-resize",flush:!1,marginLeft:null,marginRight:null,remoteTable:null,disable:!1,partialRefresh:!1,disabledColumns:[],removePadding:!0,widths:[],serialize:!0,onDrag:null,onResize:null}},887:e=>{e.exports=function hash(e){for(var t=5381,r=e.length;r;)t=33*t^e.charCodeAt(--r);return t>>>0}}},t={};function __webpack_require__(r){if(t[r])return t[r].exports;var i=t[r]={exports:{}};return e[r](i,i.exports,__webpack_require__),i.exports}return __webpack_require__.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return __webpack_require__.d(t,{a:t}),t},__webpack_require__.d=(e,t)=>{for(var r in t)__webpack_require__.o(t,r)&&!__webpack_require__.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},__webpack_require__(67)})()})); | ||
!function webpackUniversalModuleDefinition(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.ColumnResizer=t():e.ColumnResizer=t()}(this,(()=>(()=>{"use strict";var e={887:e=>{e.exports=function hash(e){for(var t=5381,r=e.length;r;)t=33*t^e.charCodeAt(--r);return t>>>0}}},t={};function __webpack_require__(r){var i=t[r];if(void 0!==i)return i.exports;var o=t[r]={exports:{}};return e[r](o,o.exports,__webpack_require__),o.exports}__webpack_require__.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return __webpack_require__.d(t,{a:t}),t},__webpack_require__.d=(e,t)=>{for(var r in t)__webpack_require__.o(t,r)&&!__webpack_require__.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{__webpack_require__.r(r),__webpack_require__.d(r,{default:()=>n});var e=__webpack_require__(887),t=__webpack_require__.n(e);function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,_toPropertyKey(i.key),i)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperty(e,t,r){return(t=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _toPropertyKey(e){var t=function _toPrimitive(e,t){if("object"!==_typeof(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!==_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===_typeof(t)?t:String(t)}var i,o=(i=0,function(){return i++}),n=_createClass((function ColumnResizer(e){var r=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};_classCallCheck(this,ColumnResizer),_defineProperty(this,"ID","id"),_defineProperty(this,"PX","px"),_defineProperty(this,"RESIZABLE","grip-resizable"),_defineProperty(this,"FLEX","grip-flex"),_defineProperty(this,"legacyIE",navigator.userAgent.indexOf("Trident/4.0")>0),_defineProperty(this,"reset",(function(e){return r.init(e)})),_defineProperty(this,"onResize",(function(){var e=r.tb;if(e.classList.remove(r.RESIZABLE),e.opt.fixed){e.tableWidth=Number(window.getComputedStyle(e).width.replace(/px/,"")).valueOf();for(var t=0,i=0;i<e.columnCnt;i++)t+=e.columns[i].w;for(var o=0;o<e.columnCnt;o++)e.columns[o].style.width=Math.round(1e3*e.columns[o].w/t)/10+"%",e.columns[o].locked=!0,e.opt.currentWidths[o]=Number(window.getComputedStyle(e.columns[o]).width.replace(/px/,"")).valueOf()}else r.applyBounds(),"flex"===e.opt.resizeMode&&e.opt.serialize&&r.serializeStore();e.classList.add(r.RESIZABLE),r.syncGrips()})),_defineProperty(this,"onGripMouseDown",(function(e){var t=e.target.parentNode.data,i=r.tb,o=i.grips[t.i],n=e.touches;if(o.ox=n?n[0].pageX:e.pageX,o.l=o.offsetLeft,o.x=o.l,r.createStyle(document.querySelector("head"),"*{cursor:"+i.opt.dragCursor+"!important}"),document.addEventListener("touchmove",r.onGripDrag),document.addEventListener("mousemove",r.onGripDrag),document.addEventListener("touchend",r.onGripDragOver),document.addEventListener("mouseup",r.onGripDragOver),o.classList.add(i.opt.draggingClass),r.grip=o,i.columns[t.i].locked)for(var l,a=0;a<i.columnCnt;a++)(l=i.columns[a]).locked=!1,l.w=Number(window.getComputedStyle(l).width.replace(/px/,"")).valueOf();e.preventDefault()})),_defineProperty(this,"onGripDrag",(function(e){var t=r.grip;if(t){var i=t.t,o=e.touches,n=(o?o[0].pageX:e.pageX)-t.ox+t.l,l=i.opt.minWidth,a=t.i,s=1.5*i.cellSpace+l+i.borderSpace,d=a===i.columnCnt-1,p=a?i.grips[a-1].offsetLeft+i.cellSpace+l:s,u=i.opt.fixed?a===i.columnCnt-1?i.tableWidth-s:i.grips[a+1].offsetLeft-i.cellSpace-l:1/0;if(n=Math.max(p,Math.min(u,n)),t.x=n,t.style.left=n+r.PX,d&&(t.w=i.columns[a].w+n-t.l),i.opt.liveDrag){d?(i.columns[a].style.width=t.w+r.PX,!i.opt.fixed&&i.opt.overflow?i.style.minWidth=i.tableWidth+n-t.l+r.PX:i.tableWidth=Number(window.getComputedStyle(i).width.replace(/px/,"")).valueOf()):r.syncCols(i,a,!1,i.opt),r.syncGrips();var c=i.opt.onDrag;c&&c(e)}e.preventDefault()}})),_defineProperty(this,"onGripDragOver",(function(e){var t=r.grip;document.removeEventListener("touchend",r.onGripDragOver),document.removeEventListener("mouseup",r.onGripDragOver),document.removeEventListener("touchmove",r.onGripDrag),document.removeEventListener("mousemove",r.onGripDrag);var i=document.querySelector("head").lastChild;if(i.parentNode.removeChild(i),t){if(t.classList.remove(t.t.opt.draggingClass),t.x-t.l!=0){var o=t.t,n=o.opt.onResize,l=t.i;if(l===o.columnCnt-1){var a=o.columns[l];a.style.width=t.w+r.PX,a.w=t.w}else r.syncCols(o,l,!0,o.opt);o.opt.fixed||r.applyBounds(),r.syncGrips(),n&&n(e),o.opt.serialize&&r.serializeStore()}r.grip=null}})),_defineProperty(this,"init",(function(e){if(e.disable)return r.destroy();var t=r.tb,i=t.getAttribute(r.ID)||r.RESIZABLE+o();if(!t.matches("table")||t.extended&&!e.partialRefresh)return null;var n=document.querySelector("head");if(r.createStyle(n," .grip-resizable{table-layout:fixed;} .grip-resizable > tbody > tr > td, .grip-resizable > tbody > tr > th{overflow:hidden} .grip-padding > tbody > tr > td, .grip-padding > tbody > tr > th{padding-left:0!important; padding-right:0!important;} .grip-container{ height:0px; position:relative;} .grip-handle{margin-left:-5px; position:absolute; z-index:5; } .grip-handle .grip-resizable{position:absolute;background-color:red;filter:alpha(opacity=1);opacity:0;width:10px;height:100%;cursor: col-resize;top:0px} .grip-lastgrip{position:absolute; width:1px; } .grip-drag{ border-left:1px dotted black;\t} .grip-flex{width:auto!important;} .grip-handle.grip-disabledgrip .grip-resizable{cursor:default; display:none;}"),e.hoverCursor&&"col-resize"!==e.hoverCursor){var l=".grip-handle .grip-resizable:hover{cursor:"+e.hoverCursor+"!important}";r.createStyle(n,l)}t.setAttribute(r.ID,i);var a=t.opt;t.opt=r.extendOptions(e);var s=r.getTableHeaders(t);if(r.extendTable(s),e.remoteTable&&e.remoteTable.matches("table")){var d=r.getTableHeaders(t.opt.remoteTable);s.length===d.length?r.extendRemoteTable(t.opt.remoteTable,d,t):console.warn("column count for remote table did not match")}return a})),_defineProperty(this,"applyBounds",(function(){var e=r.tb,t=e.columns.map((function(e){return window.getComputedStyle(e).width}));e.style.width=window.getComputedStyle(e).width,e.tableWidth=Number(e.style.width.replace(/px/,"")).valueOf(),e.classList.remove(r.FLEX),e.columns.forEach((function(r,i){r.style.width=t[i];var o=Number(t[i].replace(/px/,"")).valueOf();r.w=o,e.opt.currentWidths[i]=o})),e.classList.add(r.FLEX)})),_defineProperty(this,"serializeStore",(function(){var e=r.store,t=r.tb;e[t.getAttribute(r.ID)]="";for(var i=0,o=0;o<t.columns.length;o++){var n=window.getComputedStyle(t.columns[o]).width.replace(/px/,"");e[t.getAttribute(r.ID)]+=n+";",i+=Number(n).valueOf()}e[t.getAttribute(r.ID)]+=i.toString(),t.opt.fixed||(e[t.getAttribute(r.ID)]+=";"+window.getComputedStyle(t).width.replace(/px/,""))})),_defineProperty(this,"syncGrips",(function(){var e=r.tb;e.gripContainer.style.width=e.tableWidth+r.PX;for(var t=0;t<e.columnCnt;t++){var i=e.columns[t],o=i.getBoundingClientRect(),n=e.getBoundingClientRect();e.grips[t].style.left=o.left-n.left+i.offsetWidth+e.cellSpace/2+r.PX,e.grips[t].style.height=(e.opt.headerOnly?e.columns[0].offsetHeight:e.offsetHeight)+r.PX}})),_defineProperty(this,"destroy",(function(){var e=r.tb,t=e.getAttribute(r.ID);return t?(r.store[t]="",e.classList.remove(r.RESIZABLE),e.classList.remove(r.FLEX),e.remote&&(e.remote.classList.remove(r.RESIZABLE),e.remote.classList.remove(r.FLEX)),e.gripContainer&&e.gripContainer.parentNode&&e.gripContainer.parentNode.removeChild(e.gripContainer),delete e.extended,e.opt):null})),_defineProperty(this,"createStyle",(function(e,r){var i=t()(r).toString(),o=e.querySelectorAll("style"),n=Array.from(o).filter((function(e){return e.gripid===i}));if(!n.length){var l=document.createElement("style");l.type="text/css",l.gripid=i,l.styleSheet?l.styleSheet.cssText=r:l.appendChild(document.createTextNode(r)),e.appendChild(l)}})),_defineProperty(this,"extendOptions",(function(e){var t=Object.assign({},ColumnResizer.DEFAULTS,e);switch(t.fixed=!0,t.overflow=!1,t.resizeMode){case"flex":t.fixed=!1;break;case"overflow":t.fixed=!1,t.overflow=!0}return t})),_defineProperty(this,"getTableHeaders",(function(e){var t="#"+e.id,i=Array.from(e.querySelectorAll(t+">thead>tr:nth-of-type(1)>th"));return(i=i.concat(Array.from(e.querySelectorAll(t+">thead>tr:nth-of-type(1)>td")))).length||(i=(i=(i=(i=Array.from(e.querySelectorAll(t+">tbody>tr:nth-of-type(1)>th"))).concat(Array.from(e.querySelectorAll(t+">tr:nth-of-type(1)>th")))).concat(Array.from(e.querySelectorAll(t+">tbody>tr:nth-of-type(1)>td")))).concat(Array.from(e.querySelectorAll(t+">tr:nth-of-type(1)>td")))),r.filterInvisible(i,!1)})),_defineProperty(this,"filterInvisible",(function(e,t){return e.filter((function(e){var r=t?-1:e.offsetWidth,i=t?-1:e.offsetHeight;return!(0===r&&0===i||e.style&&e.style.display&&"none"===window.getComputedStyle(e).display||!1)}))})),_defineProperty(this,"extendTable",(function(e){var t=r.tb;t.opt.removePadding&&t.classList.add("grip-padding"),t.classList.add(r.RESIZABLE),t.insertAdjacentHTML("beforebegin",'<div class="grip-container"/>'),t.grips=[],t.columns=[],t.tableWidth=Number(window.getComputedStyle(t).width.replace(/px/,"")).valueOf(),t.gripContainer=t.previousElementSibling,t.opt.marginLeft&&(t.gripContainer.style.marginLeft=t.opt.marginLeft),t.opt.marginRight&&(t.gripContainer.style.marginRight=t.opt.marginRight),t.cellSpace=parseInt(r.legacyIE?t.cellSpacing||t.currentStyle.borderSpacing:window.getComputedStyle(t).borderSpacing.split(" ")[0].replace(/px/,""))||2,t.borderSpace=parseInt(r.legacyIE?t.border||t.currentStyle.borderLeftWidth:window.getComputedStyle(t).borderLeftWidth.replace(/px/,""))||1,t.extended=!0,r.createGrips(e)})),_defineProperty(this,"extendRemoteTable",(function(e,t,i){i.opt.removePadding&&e.classList.add("grip-padding"),e.classList.add(r.RESIZABLE),e.getAttribute(r.ID)||e.setAttribute(r.ID,i.getAttribute(r.ID)+"remote"),e.columns=[],t.forEach((function(o,n){var l=t[n];l.w=i.columns[n].w,l.style.width=l.w+r.PX,l.removeAttribute("width"),e.columns.push(l)})),e.tableWidth=i.tableWidth,e.cellSpace=i.cellSpace,e.borderSpace=i.borderSpace;var o=Array.from(e.querySelectorAll("col"));e.columnGrp=r.filterInvisible(o,!0),e.columnGrp.forEach((function(e,t){e.removeAttribute("width"),e.style.width=i.columnGrp[t].style.width})),i.remote=e})),_defineProperty(this,"createGrips",(function(e){var t=r.tb;t.columnGrp=r.filterInvisible(Array.from(t.querySelectorAll("col")),!0),t.columnGrp.forEach((function(e){e.removeAttribute("width")})),t.columnCnt=e.length;var i=!1;r.store[t.getAttribute(r.ID)]&&(r.deserializeStore(e),i=!0),e.forEach((function(o,n){var l=e[n],a=-1!==t.opt.disabledColumns.indexOf(n);r.createDiv(t.gripContainer,"grip-handle");var s=t.gripContainer.lastChild;!a&&t.opt.gripInnerHtml&&(s.innerHTML=t.opt.gripInnerHtml),r.createDiv(s,r.RESIZABLE),n===t.columnCnt-1&&(s.classList.add("grip-lastgrip"),t.opt.fixed&&(s.innerHTML="")),s.addEventListener("touchstart",r.onGripMouseDown,{capture:!0,passive:!0}),s.addEventListener("mousedown",r.onGripMouseDown,!0),a?s.classList.add("grip-disabledgrip"):(s.classList.remove("grip-disabledgrip"),s.addEventListener("touchstart",r.onGripMouseDown,{capture:!0,passive:!0}),s.addEventListener("mousedown",r.onGripMouseDown,!0)),s.t=t,s.i=n,t.opt.widths[n]?l.w=t.opt.widths[n]:l.w=i?Number(l.style.width.replace(/px/,"")).valueOf():Number(window.getComputedStyle(l).width.replace(/px/,"")).valueOf(),t.opt.currentWidths[n]=l.w,l.style.width=l.w+r.PX,l.removeAttribute("width"),s.data={i:n,t:t.getAttribute(r.ID),last:n===t.columnCnt-1},t.grips.push(s),t.columns.push(l)}));var o=Array.from(t.querySelectorAll("td"));o.concat(Array.from(t.querySelectorAll("th"))),(o=(o=o.filter((function(t){for(var r=0;r<e.length;r++)if(e[r]===t)return!1;return!0}))).filter((function(e){return!(e.querySelectorAll("table th").length||e.querySelectorAll("table td").length)}))).forEach((function(e){e.removeAttribute("width")})),t.opt.fixed||(t.removeAttribute("width"),t.classList.add(r.FLEX)),r.syncGrips()})),_defineProperty(this,"deserializeStore",(function(e){var t=r.tb;if(t.columnGrp.forEach((function(e){e.removeAttribute("width")})),t.opt.flush)r.store[t.getAttribute(r.ID)]="";else{var i=r.store[t.getAttribute(r.ID)].split(";"),o=i[t.columnCnt+1];!t.opt.fixed&&o&&(t.style.width=o+r.PX,t.opt.overflow&&(t.style.minWidth=o+r.PX,t.tableWidth=Number(o).valueOf()));for(var n=0;n<t.columnCnt;n++)e[n].style.width=i[n]+r.PX,t.columnGrp[n]&&(t.columnGrp[n].style.width=100*Number(i[n]).valueOf()/Number(i[t.columnCnt]).valueOf()+"%")}})),_defineProperty(this,"createDiv",(function(e,t,r){var i=document.createElement("div");i.classList.add(t),r&&(i.innerHTML=r),e.appendChild(i)})),_defineProperty(this,"syncCols",(function(e,t,i,o){var n=e.remote,l=r.grip.x-r.grip.l,a=e.columns[t],s=e.columns[t+1];if(a&&s){var d=a.w+l,p=s.w-l,u=d+r.PX;if(a.style.width=u,e.columnGrp[t]&&e.columnGrp[t].style.width&&(e.columnGrp[t].style.width=u),n&&(n.columns[t].style.width=u,n.columnGrp[t]&&n.columnGrp[t].style.width&&(n.columnGrp[t].style.width=u)),o.fixed){var c=p+r.PX;s.style.width=c,e.columnGrp[t+1]&&e.columnGrp[t+1].style.width&&(e.columnGrp[t+1].style.width=c),n&&(n.columns[t+1].style.width=c,n.columnGrp[t+1]&&n.columnGrp[t+1].style.width&&(n.columnGrp[t+1].style.width=c))}else o.overflow&&(e.style.minWidth=e.tableWidth+l+r.PX);i&&(a.w=d,s.w=o.fixed?p:s.w,n&&(n.columns[t].w=d,n.columns[t+1].w=o.fixed?p:s.w))}}));try{this.store=sessionStorage}catch(e){this.store={}}this.grip=null,this.tb=e,window.addEventListener("resize",this.onResize),Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector),this.init(i)}));n.DEFAULTS={resizeMode:"fit",draggingClass:"grip-drag",gripInnerHtml:"",liveDrag:!1,minWidth:15,headerOnly:!1,hoverCursor:"col-resize",dragCursor:"col-resize",flush:!1,marginLeft:null,marginRight:null,remoteTable:null,disable:!1,partialRefresh:!1,disabledColumns:[],removePadding:!0,widths:[],currentWidths:[],serialize:!0,onDrag:null,onResize:null}})(),r})())); | ||
//# sourceMappingURL=column-resizer.js.map |
{ | ||
"name": "column-resizer", | ||
"version": "1.3.6", | ||
"version": "1.4.0", | ||
"description": "Javascript to resize table columns", | ||
@@ -19,3 +19,3 @@ "title": "ColumnResizer", | ||
"type": "git", | ||
"url": "https://github.com/MonsantoCo/column-resizer.git" | ||
"url": "https://github.com/jglynn43/column-resizer.git" | ||
}, | ||
@@ -26,3 +26,3 @@ "engines": { | ||
"bugs": { | ||
"url": "https://github.com/MonsantoCo/column-resizer/issues" | ||
"url": "https://github.com/jglynn43/column-resizer/issues" | ||
}, | ||
@@ -41,21 +41,21 @@ "license": "BSD-3-Clause", | ||
"devDependencies": { | ||
"@babel/cli": "~7.12.8", | ||
"@babel/core": "~7.12.9", | ||
"@babel/plugin-proposal-class-properties": "~7.12.1", | ||
"@babel/preset-env": "~7.12.7", | ||
"@babel/register": "~7.12.1", | ||
"@babel/runtime": "~7.12.5", | ||
"babel-eslint": "~10.1.0", | ||
"babel-loader": "~8.2.2", | ||
"canvas": "~2.6.1", | ||
"chai": "~4.2.0", | ||
"@babel/cli": "~7.20.7", | ||
"@babel/core": "~7.20.12", | ||
"@babel/plugin-proposal-class-properties": "~7.18.6", | ||
"@babel/preset-env": "~7.20.2", | ||
"@babel/register": "~7.18.9", | ||
"@babel/runtime": "~7.20.7", | ||
"@babel/eslint-parser": "~7.19.1", | ||
"babel-loader": "~9.1.2", | ||
"canvas": "~2.11.0", | ||
"chai": "~4.3.7", | ||
"cross-env": "~7.0.3", | ||
"eslint": "~7.14.0", | ||
"jsdom": "~16.4.0", | ||
"mocha": "~8.2.1", | ||
"mocha-chrome": "~2.2.0", | ||
"rimraf": "~3.0.2", | ||
"terser-webpack-plugin": "^5.0.3", | ||
"webpack": "~5.9.0", | ||
"webpack-cli": "~4.2.0" | ||
"eslint": "~8.32.0", | ||
"jsdom": "~21.0.0", | ||
"mocha": "~10.2.0", | ||
"mocha-chrome": "2.2.0", | ||
"rimraf": "~4.1.0", | ||
"terser-webpack-plugin": "^5.3.6", | ||
"webpack": "~5.75.0", | ||
"webpack-cli": "~5.0.1" | ||
}, | ||
@@ -62,0 +62,0 @@ "dependencies": { |
@@ -197,2 +197,7 @@ # ColumnResizer | ||
* **currentWidths**: [type: array of int] [default: []] | ||
An array of the current column widths. | ||
___ | ||
* **serialize**: [type:Boolean] [default: true] | ||
@@ -199,0 +204,0 @@ |
@@ -65,2 +65,5 @@ /** | ||
t.columns[i].locked = true; | ||
t.opt.currentWidths[i] = | ||
Number(window.getComputedStyle(t.columns[i]) | ||
.width.replace(/px/, '')).valueOf(); | ||
} | ||
@@ -254,3 +257,5 @@ } else { | ||
col.style.width = w[i]; | ||
col.w = Number(w[i].replace(/px/, '')).valueOf(); | ||
const width = Number(w[i].replace(/px/, '')).valueOf(); | ||
col.w = width; | ||
t.opt.currentWidths[i] = width; | ||
}); | ||
@@ -478,5 +483,2 @@ //allow table width changes | ||
} | ||
if (!t.opt.widths) { | ||
t.opt.widths = []; | ||
} | ||
th.forEach((header, index) => { | ||
@@ -519,2 +521,3 @@ const column = th[index]; | ||
} | ||
t.opt.currentWidths[index] = column.w; | ||
column.style.width = column.w + this.PX; | ||
@@ -673,2 +676,3 @@ column.removeAttribute('width'); | ||
widths: [], //array of initial column widths | ||
currentWidths: [], //array of the current column widths | ||
serialize: true, | ||
@@ -675,0 +679,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
135659
830
217