Files
smart-table/dist/smartTable.min.js
2020-05-06 11:08:37 +08:00

2 lines
32 KiB
JavaScript

/*! smartTable v1.2.3 | (c) pengyajun 2020 | Released under the MIT License. */!function(e){var t={};function r(o){if(t[o])return t[o].exports;var n=t[o]={i:o,l:!1,exports:{}};return e[o].call(n.exports,n,n.exports,r),n.l=!0,n.exports}r.m=e,r.c=t,r.d=function(e,t,o){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(r.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)r.d(o,n,function(t){return e[t]}.bind(null,n));return o},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=2)}([function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createElement=function(e,t){var r=document.createElement(e);return t&&(r.className=t),r},t.appendChild=function(e,t){return e.appendChild(t)},t.hasAttribute=function(e,t){return e.hasAttribute(t)},t.setAttribute=function(e,t,r){return e.setAttribute(t,r||!0)},t.getAttribute=function(e,t){return e.getAttribute(t)},t.removeAttribute=function(e,t){return e.removeAttribute(t)},t.appendChildren=function(e,t){return t.forEach((function(t){e.appendChild(t)})),e},t.insertBefore=function(e,t,r){e.insertBefore(t,r)},t.nextSibling=function(e){return e.nextSibling},t.removeChild=function(e,t){e.removeChild(t)},t.cloneNode=function(e,t){return e.cloneNode(t)},t.querySelector=function(e,t){return e.querySelector(t)},t.querySelectorAll=function(e,t){return e.querySelectorAll(t)},t.offsetHeight=function(e){return e.offsetHeight},t.offsetWidth=function(e){return e.offsetWidth},t.styled=function(e,t){for(var r in t)e.style[r]=t[r];return e}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.refactorCell=function(e){var t=e.childNodes,r=(0,o.createElement)("div","stb_cell");for(;t.length;)(0,o.appendChild)(r,t[0]);(0,o.appendChild)(e,r)},t.createCheckbox=function(e,t){if(!e)return;var r=(0,o.createElement)(e);(0,o.setAttribute)(r,"rowspan",t);var n=(0,o.createElement)("label","std-checkbox"),i=(0,o.createElement)("span","std-checkbox_input");return(0,o.appendChild)(i,(0,o.createElement)("span","std-checkbox_inner")),(0,o.appendChild)(n,i),(0,o.appendChild)(r,n),r},t.createExpandTrigger=function(e,t){if(!e)return;var r=(0,o.createElement)(e,"td"===e?"expand-cell":"");(0,o.setAttribute)(r,"rowspan",t);var n=(0,o.createElement)("span","td"===e?"expand-trigger":"");return(0,o.appendChild)(r,n),r},t.createTableWrapper=function(e,t,r,i){var a=(0,o.createElement)("div",e),l=(0,o.createElement)("table","stb_"+r);return(0,o.styled)(l,{width:t.size.tableWidth+"px"}),(0,o.appendChildren)(l,[n(t.colgroup),i]),(0,o.appendChild)(a,l),a},t.replaceColGroup=function(e){(0,o.querySelectorAll)(e.$root,"table").forEach((function(t){(0,o.styled)(t,{width:e.size.tableWidth+"px"}),t.replaceChild(n(e.colgroup),(0,o.querySelector)(t,"colgroup"))}))},t.getAttrNumber=function(e,t,r){return Number.parseInt((0,o.getAttribute)(e,t)||r)},t.getEmptyIndexInArray=function(e){for(var t=0,r=e.length;t<r;t++)if(void 0===e[t])return t},t.throttle=function(e,t){var r=void 0,o=0;return function(){var n=this,i=(new Date).getTime()-o,a=arguments;function l(){o=(new Date).getTime(),t.apply(n,a)}r&&clearTimeout(r),i>e?l():r=setTimeout(l,e-i)}},t.debounce=function(e,t){var r=void 0;return function(){var o=this,n=arguments;function i(){t.apply(o,n)}r&&clearTimeout(r),r=setTimeout(i,e)}};var o=r(0);function n(e){if(e){var t=(0,o.createElement)("colgroup");return e.forEach((function(e){var r=(0,o.createElement)("col");(0,o.setAttribute)(r,"width",e),(0,o.appendChild)(t,r)})),t}}},function(e,t,r){"use strict";var o,n=r(3),i=(o=n)&&o.__esModule?o:{default:o};window.SmartTable=i.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),r(4);var o,n=r(8);function i(e){var t=this;this instanceof i||console.error("Smart Table is a constructor and should be called with the `new` keyword"),window.addEventListener("load",(function(){setTimeout(t._init(e),0)}))}(0,((o=n)&&o.__esModule?o:{default:o}).default)(i),t.default=i},function(e,t,r){var o=r(5),n=r(6);"string"==typeof(n=n.__esModule?n.default:n)&&(n=[[e.i,n,""]]);var i={insert:"head",singleton:!1},a=(o(e.i,n,i),n.locals?n.locals:{});e.exports=a},function(e,t,r){"use strict";var o,n=function(){return void 0===o&&(o=Boolean(window&&document&&document.all&&!window.atob)),o},i=function(){var e={};return function(t){if(void 0===e[t]){var r=document.querySelector(t);if(window.HTMLIFrameElement&&r instanceof window.HTMLIFrameElement)try{r=r.contentDocument.head}catch(e){r=null}e[t]=r}return e[t]}}(),a={};function l(e,t,r){for(var o=0;o<t.length;o++){var n={css:t[o][1],media:t[o][2],sourceMap:t[o][3]};a[e][o]?a[e][o](n):a[e].push(p(n,r))}}function d(e){var t=document.createElement("style"),o=e.attributes||{};if(void 0===o.nonce){var n=r.nc;n&&(o.nonce=n)}if(Object.keys(o).forEach((function(e){t.setAttribute(e,o[e])})),"function"==typeof e.insert)e.insert(t);else{var a=i(e.insert||"head");if(!a)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");a.appendChild(t)}return t}var s,c=(s=[],function(e,t){return s[e]=t,s.filter(Boolean).join("\n")});function f(e,t,r,o){var n=r?"":o.css;if(e.styleSheet)e.styleSheet.cssText=c(t,n);else{var i=document.createTextNode(n),a=e.childNodes;a[t]&&e.removeChild(a[t]),a.length?e.insertBefore(i,a[t]):e.appendChild(i)}}function u(e,t,r){var o=r.css,n=r.media,i=r.sourceMap;if(n?e.setAttribute("media",n):e.removeAttribute("media"),i&&btoa&&(o+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(i))))," */")),e.styleSheet)e.styleSheet.cssText=o;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(o))}}var h=null,b=0;function p(e,t){var r,o,n;if(t.singleton){var i=b++;r=h||(h=d(t)),o=f.bind(null,r,i,!1),n=f.bind(null,r,i,!0)}else r=d(t),o=u.bind(null,r,t),n=function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(r)};return o(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;o(e=t)}else n()}}e.exports=function(e,t,r){return(r=r||{}).singleton||"boolean"==typeof r.singleton||(r.singleton=n()),e=r.base?e+r.base:e,t=t||[],a[e]||(a[e]=[]),l(e,t,r),function(t){if(t=t||[],"[object Array]"===Object.prototype.toString.call(t)){a[e]||(a[e]=[]),l(e,t,r);for(var o=t.length;o<a[e].length;o++)a[e][o]();a[e].length=t.length,0===a[e].length&&delete a[e]}}}},function(e,t,r){(t=r(7)(!1)).push([e.i,'.smart-table{position:relative;overflow:hidden;box-sizing:border-box;width:100%;max-width:100%;background-color:#fff;color:#6A6B6F;border:1px solid #ECF0F5;border-right:none;border-bottom:none}.smart-table:after,.smart-table:before{content:"";position:absolute;background-color:#ECF0F5;z-index:1}.smart-table:before{left:0;bottom:0;width:100%;height:1px}.smart-table:after{top:0;right:0;width:1px;height:100%}.smart-table table{border-spacing:0;border:0}.smart-table thead{background:#F5F7FB;font-size:13px}.smart-table tr{-webkit-transition:background-color .25s ease;transition:background-color .25s ease}.smart-table tbody{font-size:12px}.smart-table tbody tr[expand] td:first-child{cursor:pointer}.smart-table tbody tr[expand] td:first-child:before{-webkit-transition:0.35s ease transform;transition:0.35s ease transform;-webkit-transform-origin:25% 50%;transform-origin:25% 50%;content:\'\';float:left;width:0;height:0;border-width:6px;border-style:solid;border-color:transparent transparent transparent #c0c4cc;margin:5px 0 0 5px}.smart-table tbody tr[expand][expanded]>td:first-child:before{-webkit-transform:rotate(90deg);transform:rotate(90deg)}.smart-table tbody .expand-trigger{display:inline-block;-webkit-transition:0.35s ease transform;transition:0.35s ease transform;-webkit-transform-origin:25% 50%;transform-origin:25% 50%;width:0;height:0;border-width:6px;border-style:solid;border-color:transparent transparent transparent #c0c4cc;margin-left:5px}.smart-table tbody .expand-cell>.stb_cell{cursor:pointer}.smart-table tbody .expand-cell>.stb_cell[open] .expand-trigger{-webkit-transform:rotate(90deg);transform:rotate(90deg)}.smart-table tbody .expand-cell>.stb_cell[loading] .expand-trigger{margin-left:0;width:1em;height:1em;border-color:none;-webkit-transform-origin:center;transform-origin:center;border:.2em solid transparent;border-left-color:currentcolor;border-right-color:currentcolor;border-radius:50%;-webkit-animation:1s loading linear infinite;animation:1s loading linear infinite}.smart-table tbody.stripe tr:nth-child(2n){background-color:#F9FBFF}.smart-table td,.smart-table th{padding:5px 0;text-overflow:ellipsis;vertical-align:middle;position:relative;border-bottom:1px solid #ECF0F5;border-right:1px solid #ECF0F5;text-align:center}.smart-table td.is-hidden>*,.smart-table th.is-hidden>*{visibility:hidden}.smart-table th{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;overflow:hidden}.smart-table th[sort]>.stb_cell{cursor:pointer}.smart-table th[sort]>.stb_cell:before,.smart-table th[sort]>.stb_cell:after{content:\'\';float:right;width:0;height:0;border-width:5px;border-style:solid}.smart-table th[sort]>.stb_cell:before{margin:1px 0 0 -10px;border-color:transparent transparent #c0c4cc transparent}.smart-table th[sort]>.stb_cell:after{margin:12px 0 0 4px;border-color:#c0c4cc transparent transparent transparent}.smart-table th[sort]>.stb_cell.desc:after{border-top-color:#409eff}.smart-table th[sort]>.stb_cell.asc:before{border-bottom-color:#409eff}.smart-table.stb-cust-large thead{font-size:16px}.smart-table.stb-cust-large tbody{font-size:15px}.smart-table.stb-cust-large td,.smart-table.stb-cust-large th{padding:12px 0}.smart-table.stb-cust-middle thead{font-size:15px}.smart-table.stb-cust-middle tbody{font-size:14px}.smart-table.stb-cust-middle td,.smart-table.stb-cust-middle th{padding:10px 0}.smart-table.stb-cust-left td,.smart-table.stb-cust-left th{text-align:left}.smart-table.stb-cust-right td,.smart-table.stb-cust-right th{text-align:right}.smart-table th[align="left"],.smart-table td[align="left"]{text-align:left}.smart-table th[align="center"],.smart-table td[align="center"]{text-align:center}.smart-table th[align="right"],.smart-table td[align="right"]{text-align:right}.smart-table th[nowrap] .stb_cell,.smart-table td[nowrap] .stb_cell{white-space:nowrap}.smart-table .std-checkbox_inner{display:inline-block;position:relative;border:1px solid #dcdfe6;border-radius:2px;box-sizing:border-box;width:14px;height:14px;background-color:#fff;z-index:1;-webkit-transition:border-color 0.25s cubic-bezier(0.71, -0.46, 0.29, 1.46),background-color 0.25s cubic-bezier(0.71, -0.46, 0.29, 1.46);transition:border-color 0.25s cubic-bezier(0.71, -0.46, 0.29, 1.46),background-color 0.25s cubic-bezier(0.71, -0.46, 0.29, 1.46)}.smart-table .std-checkbox_inner:after{box-sizing:content-box;content:"";border:1px solid #fff;border-left:0;border-top:0;height:7px;left:4px;position:absolute;top:1px;-webkit-transform:rotate(45deg) scaleY(0);transform:rotate(45deg) scaleY(0);width:3px;-webkit-transition:-webkit-transform .15s ease-in .05s;transition:-webkit-transform .15s ease-in .05s;transition:transform .15s ease-in .05s;transition:transform .15s ease-in .05s, -webkit-transform .15s ease-in .05s;-webkit-transform-origin:center;transform-origin:center}.smart-table .std-checkbox_input{white-space:nowrap;cursor:pointer;outline:none;display:inline-block;line-height:1;position:relative;vertical-align:middle}.smart-table .std-checkbox{color:#606266;font-weight:500;font-size:14px;position:relative;cursor:pointer;display:inline-block;white-space:nowrap;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.smart-table .std-checkbox[checked]>.std-checkbox_input>.std-checkbox_inner{background-color:#409eff;border-color:#409eff}.smart-table .std-checkbox[checked]>.std-checkbox_input>.std-checkbox_inner:after{-webkit-transform:rotate(45deg) scaleY(1);transform:rotate(45deg) scaleY(1)}.smart-table .stb_cell{overflow:hidden;text-overflow:ellipsis;white-space:normal;word-break:break-all;padding:0 4px;line-height:23px}.smart-table th>.stb_cell{display:inline-block;position:relative;vertical-align:middle}.smart-table .stb_body,.smart-table .stb_footer,.smart-table .stb_header{table-layout:fixed;border-collapse:separate;background:#fff}.smart-table .stb_header-wrapper{overflow:hidden}.smart-table .stb_body-wrapper{overflow:auto}.smart-table .stb_fixed,.smart-table .stb_fixed-right{position:absolute;top:0;left:0;overflow-x:hidden;overflow-y:hidden;box-shadow:0 -1px 8px rgba(0,0,0,0.08)}.smart-table .stb_fixed-right{top:0;left:auto;right:0;box-shadow:-1px 0 8px rgba(0,0,0,0.08)}.smart-table .stb_fixed-right .stb_fixed-body-wrapper,.smart-table .stb_fixed-right .stb_fixed-footer-wrapper,.smart-table .stb_fixed-right .stb_fixed-header-wrapper{left:auto;right:0}.smart-table .stb_fixed-right-patch{position:absolute;top:-1px;right:0;background-color:#F5F7FB}.smart-table .stb_fixed-header-wrapper{position:absolute;left:0;top:0;z-index:3}.smart-table .stb_fixed-body-wrapper{position:absolute;left:0;top:37px;overflow:hidden;z-index:3}.smart-table ::-webkit-scrollbar{width:8px;height:8px;background-color:#e9edf4}.smart-table ::-webkit-scrollbar-thumb{background-color:#ccc;border-radius:2em}.smart-table ::-webkit-scrollbar-thumb:hover{background-color:#919191}.smart-table *{box-sizing:border-box}@-webkit-keyframes loading{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}@keyframes loading{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}\n',""]),e.exports=t},function(e,t,r){"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var r=function(e,t){var r=e[1]||"",o=e[3];if(!o)return r;if(t&&"function"==typeof btoa){var n=(a=o,l=btoa(unescape(encodeURIComponent(JSON.stringify(a)))),d="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(l),"/*# ".concat(d," */")),i=o.sources.map((function(e){return"/*# sourceURL=".concat(o.sourceRoot||"").concat(e," */")}));return[r].concat(i).concat([n]).join("\n")}var a,l,d;return[r].join("\n")}(t,e);return t[2]?"@media ".concat(t[2]," {").concat(r,"}"):r})).join("")},t.i=function(e,r){"string"==typeof e&&(e=[[null,e,""]]);for(var o=0;o<e.length;o++){var n=[].concat(e[o]);r&&(n[2]?n[2]="".concat(r," and ").concat(n[2]):n[2]=r),t.push(n)}},t}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){e.prototype._init=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!e.selector)return console.error("Smart Table init need a selector");var t=String(e.selector).trim(),r=(0,n.querySelector)(document,t);if(!r)return console.error("Smart Table "+t+" not found");var o=(0,n.querySelector)(r,"table");if(!o)return console.error("Smart Table init need a table");var a=(0,n.querySelector)(o,"thead");if(!a)return console.error("Smart Table init need a thead");var d=(0,n.querySelector)(o,"tbody");if(!d)return console.error("Smart Table init need a tbody");r.classList.add("smart-table"),e.size&&r.classList.add("stb-cust-"+e.size),e.align&&r.classList.add("stb-cust-"+e.align),(0,n.hasAttribute)(o,"stripe")&&d.classList.add("stripe"),e.expand?((0,n.querySelectorAll)(a,"th[sort]").forEach((function(e){(0,n.removeAttribute)(e,"sort")})),(0,n.querySelectorAll)(a,"th[fixed]").forEach((function(e){(0,n.removeAttribute)(e,"fixed")}))):((0,n.querySelectorAll)(d,"tr[expand]").forEach((function(e){(0,n.removeAttribute)(e,"expand")})),(0,n.querySelectorAll)(a,"tr[expand-parent]").forEach((function(e){(0,n.removeAttribute)(e,"expand-parent")}))),e.expandCallback&&(0,n.querySelectorAll)(a,"th[fixed]").forEach((function(e){(0,n.removeAttribute)(e,"fixed")}));var u=this;u.$root=r,u.$thead=a,u.$tbody=d,u.options=e,u.gutterWidth=(0,l.default)(),u.style={radioBgColor:e.radioBgColor||"#D1E7FF",hoverBgColor:e.hoverBgColor||"#EFF8FF"},u.size={},u.hasCheckbox=!e.expand&&"checkbox"===e.selection,u.hasExpandCb=!!e.expandCallback,u.hasExpandCb&&s(u),u.hasCheckbox&&c(u),x(u),f(u,o),e.expand||(m(u),(0,i.default)(u,a,d)),v(u,d),e.expand&&y(u,d),h(u);var p=(0,n.createElement)("th");(0,n.styled)(p,{display:"none"}),(0,n.setAttribute)(p,"width",u.gutterWidth),(0,n.setAttribute)(p,"rowspan",u.props.shapes.length),(0,n.appendChild)((0,n.querySelector)(u.$thead,"tr"),p),u.$scrollTH=p,u.scrollY&&((0,n.styled)(u.$scrollTH,{display:"table-cell"}),b(u))}};var o=d(r(9)),n=r(0),i=d(r(10)),a=r(1),l=d(r(11));function d(e){return e&&e.__esModule?e:{default:e}}function s(e){var t=e.$thead,r=e.$tbody,o=(0,n.querySelector)(t,"tr"),i=o.querySelector("th"),l=(0,a.createExpandTrigger)("th",(0,a.getAttrNumber)(i,"rowspan",1));(0,n.hasAttribute)(i,"fixed")&&(0,n.setAttribute)(l,"fixed"),(0,n.insertBefore)(o,l,i),(0,n.querySelectorAll)(r,"tr").forEach((function(e){var t=e.querySelector("td");(0,n.insertBefore)(e,(0,a.createExpandTrigger)("td",(0,a.getAttrNumber)(t,"rowspan",1)),t)}))}function c(e){var t=e.$thead,r=e.$tbody,o=(0,n.querySelector)(t,"tr"),i=o.querySelector("th"),l=(0,a.createCheckbox)("th",(0,a.getAttrNumber)(i,"rowspan",1));(0,n.hasAttribute)(i,"fixed")&&(0,n.setAttribute)(l,"fixed"),(0,n.insertBefore)(o,l,i),(0,n.querySelectorAll)(r,"tr").forEach((function(e){var t=e.querySelector("td");(0,n.insertBefore)(e,(0,a.createCheckbox)("td",(0,a.getAttrNumber)(t,"rowspan",1)),t)}))}function f(e,t){var r=e.$root,o=e.$thead,i=e.$tbody,l=e.options.height;(0,n.querySelectorAll)(o,"th").forEach((function(e){return(0,a.refactorCell)(e)})),(0,n.querySelectorAll)(i,"td").forEach((function(e){return(0,a.refactorCell)(e)})),u(e),e.$theadWrapper=(0,a.createTableWrapper)("stb_header-wrapper",e,"header",o),e.$tbodyWrapper=(0,a.createTableWrapper)("stb_body-wrapper",e,"body",i),(0,n.appendChildren)(r,[e.$theadWrapper,e.$tbodyWrapper]);var d=(0,n.offsetHeight)(o),s=("function"==typeof l?l.call():l)||(0,n.offsetHeight)(r),c=s>d?s-d-1:d+150;(0,n.styled)(e.$tbodyWrapper,{height:c+"px"}),e.size.tbodyWrapperHeight=c,e.scrollY=(0,n.offsetHeight)(e.$tbody)>c,(0,n.removeChild)(t.parentNode,t)}function u(e){var t=e.$root,r=e.props,o=(0,n.offsetWidth)(t)-1,i=o-(e.scrollY?e.gutterWidth:0),l=[],d=0;r.shapes.forEach((function(e){e.forEach((function(e,t){e&&(1===(0,a.getAttrNumber)(e,"colspan",1)&&(l[t]=(0,a.getAttrNumber)(e,"width",0)))}))}));var s=0;if(l.forEach((function(e){d+=e,0===e&&s++})),s){var c=Math.floor((i-d)/s),f=c>80?c:80,u=0;d=0,l=l.map((function(t,r){return 0===t&&(t=(e.hasCheckbox||e.hasExpandCb)&&0===r?55:f,u=r),d+=t,t})),i>d&&(l[u]=l[u]+i-d,d=i)}else d=l.reduce((function(e,t){return t+e}),0);e.colgroup=l,e.size.rootWidth=o,e.size.tableWidth=d,e.scrollX=e.size.tableWidth>e.size.rootWidth}function h(e){!function(e){e.$tbodyWrapper.addEventListener("scroll",(function(){return function(e){(0,a.throttle)(20,(function(){e.$theadWrapper.scrollLeft=e.$tbodyWrapper.scrollLeft,e.$fixedLeftBody&&(e.$fixedLeftBody.scrollTop=e.$tbodyWrapper.scrollTop),e.$fixedRightBody&&(e.$fixedRightBody.scrollTop=e.$tbodyWrapper.scrollTop)}))()}(e)}),{passive:!0})}(e),function(e){var t=e.options,r=t.selection,o=t.selectionKey;o=o||0,e.hasExpandCb&&o++;var i=(0,n.querySelector)(e.$fixedLeft||e.$thead,"th>.stb_cell>label.std-checkbox");[].concat(e.data,e.unsortData).forEach((function(t){g(e,t.$el,[t.$fixedLeftEl,t.$fixedRightEl]),t.$fixedLeftEl&&g(e,t.$fixedLeftEl,[t.$el,t.$fixedRightEl]),t.$fixedRightEl&&g(e,t.$fixedRightEl,[t.$el,t.$fixedLeftEl]);var a=t["field-"+o];if(r)switch(r){case"radio":p(e,t.$el,[t.$fixedLeftEl,t.$fixedRightEl],a),t.$fixedLeftEl&&p(e,t.$fixedLeftEl,[t.$el,t.$fixedRightEl],a),t.$fixedRightEl&&p(e,t.$fixedRightEl,[t.$el,t.$fixedLeftEl],a);break;case"checkbox":!function(e,t,r,o){var i=(0,n.querySelector)(t,"label.std-checkbox");if(!i||!r)return;i.addEventListener("click",(function(){var t=e.selected;t=t||[];var a=!(0,n.hasAttribute)(i,"checked");a?(0,n.setAttribute)(i,"checked",!0):(0,n.removeAttribute)(i,"checked"),a?t.push(o):t.splice(t.indexOf(o),1);var l=t.length;l?(0,n.setAttribute)(e.$root,"selected",JSON.stringify(t)):(0,n.removeAttribute)(e.$root,"selected"),l===e.data.length+e.unsortData.length?(0,n.setAttribute)(r,"checked",!0):(0,n.removeAttribute)(r,"checked"),e.selected=t}))}(e,t.$fixedLeftEl||t.$el,i,a)}e.hasExpandCb&&function(e,t,r,o){var i=this,a=e.options,l=(0,n.querySelector)(t,".expand-cell>.stb_cell");if(!l)return;l.addEventListener("click",(function(d){l.hasAttribute("loading")||(l.hasAttribute("open")?((0,n.removeAttribute)(l,"open"),(0,n.querySelectorAll)(e.$root,"tr.expand-"+r).forEach((function(e){(0,n.removeChild)(e.parentNode,e)}))):((0,n.setAttribute)(l,"loading",!0),a.expandCallback.call(i,{open:function(o,i){var a=(0,n.createElement)("td");(0,n.setAttribute)(a,"colspan",e.colgroup.length);var d=(0,n.createElement)("div","std-dialog_content");i?d.innerHTML=o:(0,n.appendChild)(d,o),(0,n.appendChild)(a,d);var s=(0,n.createElement)("tr","std-expand-row expand-"+r);(0,n.appendChild)(s,a),(0,n.insertBefore)(t.parentNode,s,t.nextSibling),(0,n.setAttribute)(l,"open"),(0,n.removeAttribute)(l,"loading")}},o)),d.stopPropagation())}))}(e,t.$fixedLeftEl||t.$el,t.$key,a)})),e.hasCheckbox&&function(e,t){if(!t)return;var r=e.options.selectionKey;t.addEventListener("click",(function(){var o=e.selected;o=[];var i=!(0,n.hasAttribute)(t,"checked");i?(0,n.setAttribute)(t,"checked",!0):(0,n.removeAttribute)(t,"checked"),[].concat(e.data,e.unsortData).forEach((function(e){var t=(0,n.querySelector)(e.$fixedLeftEl||e.$el,"label.std-checkbox");i?(0,n.setAttribute)(t,"checked",!0):(0,n.removeAttribute)(t,"checked"),i&&o.push(e["field-"+(r||0)])})),o.length?(0,n.setAttribute)(e.$root,"selected",JSON.stringify(o)):(0,n.removeAttribute)(e.$root,"selected"),e.selected=o}))}(e,i)}(e),e.options.expand?function(e){!function e(t){t.forEach((function(t){t.expand&&((0,n.querySelector)(t.$el,"td").addEventListener("click",(function(){!function e(t,r){r?(0,n.setAttribute)(t.$el,"expanded"):(0,n.removeAttribute)(t.$el,"expanded"),t.children&&t.children.forEach((function(t){(0,n.styled)(t.$el,{display:r?"":"none"}),e(t,r)}))}(t,!(0,n.hasAttribute)(t.$el,"expanded"))})),t.children&&e(t.children))}))}(e.expandData)}(e):function(e){var t=Array.from((0,n.querySelectorAll)(e.$root,"th[sort]"));if(0===t.length)return;t.forEach((function(r){r.addEventListener("click",(function(i){i.stopPropagation();var a="ASC",l=(0,n.getAttribute)(r,"sort")||"string";r.classList.contains("asc")?(r.classList.remove("asc"),r.classList.add("desc"),a="DESC"):(r.classList.remove("desc"),r.classList.add("asc")),t=t.map((function(e){return r!=e&&e.classList.remove("asc","desc"),e})),(0,n.querySelectorAll)(e.$root,"tr.std-expand-row").forEach((function(e){(0,n.removeChild)(e.parentNode,e)})),(0,n.querySelectorAll)(e.$root,".expand-cell>.stb_cell[open]").forEach((function(e){(0,n.removeAttribute)(e,"open")})),(0,n.querySelectorAll)(e.$root,".expand-cell>.stb_cell[loading]").forEach((function(e){(0,n.removeAttribute)(e,"loading")})),(0,o.default)(e,(0,n.getAttribute)(r,"sortkey"),a,l)}))}))}(e),function(e){window.addEventListener("resize",(function(){return b(e)}),{passive:!0})}(e)}function b(e){(0,a.debounce)(500,(function(){var t=e.props,r=t.fixedLeft,o=t.fixedRight;u(e),(0,a.replaceColGroup)(e),e.scrollY=(0,n.offsetHeight)(e.$tbody)>e.size.tbodyWrapperHeight,(0,n.styled)(e.$scrollTH,{display:e.scrollY?"table-cell":"none"});var i=(0,n.offsetHeight)(e.$root)-(e.scrollX?e.gutterWidth:2),l=(0,n.offsetHeight)(e.$thead)+(0,n.offsetHeight)(e.$tbody);i=l>i?i:l;var d=e.size.tbodyWrapperHeight-(e.scrollX?e.gutterWidth:0),s=(0,n.offsetHeight)(e.$thead),c=0,f=0;e.$fixedLeft&&r.thead.length&&(r.thead.forEach((function(t,r){c+=e.colgroup[r]})),(0,n.styled)(e.$fixedLeftBody,{height:d+"px",top:s+"px"}),(0,n.styled)(e.$fixedLeft,{width:c+"px",height:i+"px"})),e.$fixedRight&&o.thead.length&&(o.thead.forEach((function(t,r){f+=e.colgroup[e.colgroup.length-r-1]})),(0,n.styled)(e.$fixedRightBody,{height:d+"px",top:s+"px"}),(0,n.styled)(e.$fixedRight,{width:f+"px",height:i+"px",right:(e.scrollY?e.gutterWidth:0)+"px"}),(0,n.styled)(e.$rightPatch,{display:e.scrollY?"block":"none",height:(0,n.offsetHeight)(e.$thead)+"px"}))}))()}function p(e,t,r,o){t&&t.addEventListener("click",(function(){var i=e.selected,a=!1;(i!==o||(0,n.hasAttribute)(t,"checked"))&&(i!==o?((0,n.querySelectorAll)(e.$root,"tr[checked]>td").forEach((function(e){return(0,n.styled)(e,{background:""})})),(0,n.querySelectorAll)(e.$root,"tr[checked]").forEach((function(e){return(0,n.removeAttribute)(e,"checked")})),a=!0):(0,n.hasAttribute)(t,"checked")&&(a=!1),i=a?o:null,a?(0,n.setAttribute)(t,"checked",!0):(0,n.removeAttribute)(t,"checked"),t.querySelectorAll("td").forEach((function(t){(0,n.styled)(t,{background:a?e.style.radioBgColor:""})})),r.forEach((function(t){t&&(a?(0,n.setAttribute)(t,"checked",!0):(0,n.removeAttribute)(t,"checked"),t.querySelectorAll("td").forEach((function(t){(0,n.styled)(t,{background:a?e.style.radioBgColor:""})})))})),a?(0,n.setAttribute)(e.$root,"selected",JSON.stringify(i)):(0,n.removeAttribute)(e.$root,"selected"),e.selected=i)}))}function g(e,t,r){t&&(t.addEventListener("mouseenter",(function(){(0,n.styled)(t,{background:e.style.hoverBgColor}),r.forEach((function(t){t&&(0,n.styled)(t,{background:e.style.hoverBgColor})}))})),t.addEventListener("mouseleave",(function(){(0,n.styled)(t,{background:""}),r.forEach((function(e){e&&(0,n.styled)(e,{background:""})}))})))}function x(e){var t={},r=[];(0,n.querySelectorAll)(e.$thead,"tr").forEach((function(e,t){var o=r[t]||[];(0,n.querySelectorAll)(e,"th").forEach((function(e){var i=(0,a.getAttrNumber)(e,"rowspan",1),l=(0,a.getAttrNumber)(e,"colspan",1),d=(0,a.getEmptyIndexInArray)(o)||o.length;if(o[d]=e,(0,n.hasAttribute)(e,"sort")&&(0,n.setAttribute)(e,"sortkey","field-"+d),l>1)for(var s=1;s<l;s++)o[d+s]=0;if(i>1)for(var c=1;c<i;c++){for(var f=r[t+c]||[],u=0;u<l;u++)f[d+u]=0;r[t+c]=f}r[t]=o}))})),t.shapes=r,e.props=t}function m(e){var t=e.colgroup,r=e.props,o=t.length,i={thead:[],tbody:[],width:0},l={thead:[],tbody:[],width:0},d=(0,n.querySelectorAll)(e.$thead,"tr:first-child>th"),s=d.length,c=0;if(0!==s){if((0,n.hasAttribute)(d[0],"fixed"))for(var f=0;f<s-1&&(0,n.hasAttribute)(d[f],"fixed");f++){c=f,i.thead.push("field-"+f);for(var u=(0,a.getAttrNumber)(d[f],"colspan",1),h=0;h<u;h++)i.tbody.push("field-"+(f+h)),i.width+=t[f+h]}if((0,n.hasAttribute)(d[s-1],"fixed"))for(var b=0,p=s-1;p>0&&(0,n.hasAttribute)(d[p],"fixed")&&p!==c;p--){l.thead.push("field-"+p);for(var g=(0,a.getAttrNumber)(d[p],"colspan",1),x=0;x<g;x++)b++,l.tbody.push("field-"+(o-b)),l.width+=t[o-b]}}r.fixedLeft=i,r.fixedRight=l}function y(e,t){var r=e.options.defaultExpandAll,o=[],i=[],a=[];(0,n.querySelectorAll)(t,"tr").forEach((function(e){var t=i.length,l=(0,n.hasAttribute)(e,"expand"),d=(0,n.hasAttribute)(e,"expand-parent"),s=(0,n.getAttribute)(e,"expand-parent");-1===a.indexOf(s)&&(d=!1);var c={$el:e,id:(0,n.getAttribute)(e,"expand"),expand:l};if(l&&(r?(0,n.setAttribute)(e,"expanded"):(0,n.removeAttribute)(e,"expanded")),l&&!d)c.children=[],i=[c],a.push(c.id),o.push(c);else if(d){for(var f=(0,n.getAttribute)(e,"expand-parent"),u=[],h=0;h<i.length&&(u.push(i[h]),i[h].id!==f);h++);t=(i=u).length;var b=i[i.length-1];b&&b.children.push(c),l&&(i.push(c),a.push(c.id),c.children=[])}else o.push(c);d&&((0,n.styled)((0,n.querySelector)(e,"td"),{paddingLeft:32*t+"px"}),(0,n.styled)(e,{display:r?"":"none"}))})),e.expandData=o,(0,n.styled)(e.$tbodyWrapper,{height:""}),(0,n.styled)(e.$tbodyWrapper,{maxHeight:e.size.tbodyWrapperHeight+"px"})}function v(e,t){var r=e.$fixedLeftBody&&(0,n.querySelectorAll)(e.$fixedLeftBody,"tbody tr"),o=e.$fixedRightBody&&(0,n.querySelectorAll)(e.$fixedRightBody,"tbody tr"),i=[],a=[];(0,n.querySelectorAll)(t,"tr").forEach((function(e,t){var l={$el:e,$fixedLeftEl:r&&r[t],$fixedRightEl:o&&o[t],$key:"rowkey"+t};(0,n.querySelectorAll)(e,"td .stb_cell").forEach((function(e,t){l["field-"+t]=e.innerHTML})),(0,n.hasAttribute)(e,"unsort")?a.push(l):i.push(l)})),e.data=i,e.unsortData=a}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r,i){if(e.data&&!(e.data.length<1)){var a=function e(t,r,o,i){if(t.length<=1)return t;for(var a=[],l=[],d=t.length,s=Math.floor(d/2),c=t.splice(s,1)[0],f=0;f<d-1;f++)n(t[f][r],c[r],o,i)?a.push(t[f]):l.push(t[f]);return e(a,r,o,i).concat(c,e(l,r,o,i))}(JSON.parse(JSON.stringify(e.data)),t,r,i);JSON.stringify(e.data)!==JSON.stringify(a)&&(!function(e,t){for(var r=0,n=0;n<t.length;n++)for(var i=t[n],a=0;a<e.length;a++){var l=e[a];if(i.$key===l.$key){if(i.$el=l.$el,i.$fixedLeftEl=l.$fixedLeftEl,i.$fixedRightEl=l.$fixedRightEl,a<r){var d=t[n-1],s=d.$el.nextSibling;if((0,o.insertBefore)(s.parentNode,l.$el,s),d.$fixedLeftEl){var c=d.$fixedLeftEl.nextSibling;(0,o.insertBefore)(c.parentNode,l.$fixedLeftEl,c)}if(d.$fixedRightEl){var f=d.$fixedRightEl.nextSibling;(0,o.insertBefore)(f.parentNode,l.$fixedRightEl,f)}}else r=a;break}}}(e.data,a),e.data=a)}};var o=r(0);function n(e,t,r,o){return"number"===o&&(e=parseFloat(e),t=parseFloat(t)),"ASC"===r?e<t:e>t}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r){var n=320,d=e.props,s=d.fixedLeft,c=d.fixedRight;if(s.thead.length>0){n=n>s.width?n:s.width;var f=i(e,t,s),u=a(e,r,s,"left");e.$fixedLeft=l(e,f,u,s,"stb_fixed","left"),(0,o.appendChild)(e.$root,e.$fixedLeft),e.$fixedLeftBody=u}if(c.thead.length>0){n+=c.width;var h=i(e,t,c),b=a(e,r,c,"right");e.$fixedRight=l(e,h,b,c,"stb_fixed-right","right"),(0,o.appendChild)(e.$root,e.$fixedRight),e.$fixedRightBody=b;var p=(0,o.createElement)("div","stb_fixed-right-patch");(0,o.styled)(p,{display:"none",width:e.gutterWidth+"px",height:(0,o.offsetHeight)(e.$thead)+"px"}),(0,o.appendChild)(e.$root,p),e.$rightPatch=p,e.scrollY&&(0,o.styled)(e.$rightPatch,{display:"block"})}(0,o.styled)(e.$root,{minWidth:n+"px"})};var o=r(0),n=r(1);function i(e,t,r){var i=(0,o.cloneNode)(t,!0);return(0,o.querySelectorAll)(i,"tr:first-child>th").forEach((function(e,t){-1===r.thead.indexOf("field-"+t)&&e.classList.add("is-hidden")})),(0,n.createTableWrapper)("stb_fixed-header-wrapper",e,"header",i)}function a(e,t,r,i){var a=(0,o.cloneNode)(t,!0);(0,o.querySelectorAll)(a,"tr").forEach((function(e){var t=-1;(0,o.querySelectorAll)(e,"td").forEach((function(e,o){"left"===i?t=o:t+=(0,n.getAttrNumber)(e,"colspan",1),-1===r.tbody.indexOf("field-"+t)&&e.classList.add("is-hidden")}))}));var l=(0,n.createTableWrapper)("stb_fixed-body-wrapper",e,"body",a);return(0,o.styled)(l,{top:(0,o.offsetHeight)(e.$thead)+"px",height:e.size.tbodyWrapperHeight-(e.scrollX?e.gutterWidth:0)+"px"}),l}function l(e,t,r,n,i,a){var l=(0,o.createElement)("div",i);(0,o.appendChildren)(l,[t,r]);var d=(0,o.offsetHeight)(e.$root)-(e.scrollX?e.gutterWidth:2),s=(0,o.offsetHeight)(e.$thead)+(0,o.offsetHeight)(e.$tbody);return(0,o.styled)(l,{width:n.width+"px",height:(s>d?d:s)+"px",right:"right"===a?(e.scrollY?e.gutterWidth:0)+"px":""}),l}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(){if(void 0!==n)return n;var e=(0,o.createElement)("div","smart-table");(0,o.appendChild)(document.body,e);var t=(0,o.createElement)("div");(0,o.styled)(t,{visibility:"hidden",width:"100px",position:"absolute",top:"-9999px"}),(0,o.appendChild)(e,t);var r=(0,o.offsetWidth)(t);(0,o.styled)(t,{overflow:"scroll"});var i=(0,o.createElement)("div");(0,o.styled)(i,{width:"100%"}),(0,o.appendChild)(t,i);var a=(0,o.offsetWidth)(i);return(0,o.removeChild)(e.parentNode,e),n=r-a};var o=r(0),n=void 0}]);
//# sourceMappingURL=smartTable.min.js.map