UNPKG

jiku-ui

Version:

A Component Library for Vue.js.

2 lines (1 loc) 12.1 kB
module.exports=function(e){var n={};function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:r})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var i in e)t.d(r,i,function(n){return e[n]}.bind(null,i));return r},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="",t(t.s=155)}({155:function(e,n,t){"use strict";t.r(n);var r=t(3),i={default:{order:""},selection:{width:48,minWidth:48,realWidth:48,order:"",className:"hn-table-column--selection"},expand:{width:48,minWidth:48,realWidth:48,order:""},index:{width:48,minWidth:48,realWidth:48,order:""}},o={selection:{renderHeader:function(e,n){var t=n.store;return e("hn-checkbox",{attrs:{disabled:t.states.data&&0===t.states.data.length,indeterminate:t.states.selection.length>0&&!this.isAllSelected,value:this.isAllSelected},nativeOn:{click:this.toggleAllSelection}})},renderCell:function(e,n){var t=n.row,r=n.column,i=n.store,o=n.$index;return e("hn-checkbox",{nativeOn:{click:function(e){return e.stopPropagation()}},attrs:{value:i.isSelected(t),disabled:!!r.selectable&&!r.selectable.call(null,t,o)},on:{input:function(){i.commit("rowSelectedChanged",t)}}})},sortable:!1,resizable:!1},index:{renderHeader:function(e,n){return n.column.label||"#"},renderCell:function(e,n){var t=n.$index,r=t+1,i=n.column.index;return"number"==typeof i?r=t+i:"function"==typeof i&&(r=i(t)),e("div",[r])},sortable:!1},expand:{renderHeader:function(e,n){return n.column.label||""},renderCell:function(e,n){var t=n.row,r=n.store,i=["hn-table__expand-icon"];r.states.expandRows.indexOf(t)>-1&&i.push("hn-table__expand-icon--expanded");return e("div",{class:i,on:{click:function(e){e.stopPropagation(),r.toggleRowExpansion(t)}}},[e("i",{class:"hn-icon hn-icon-arrow-right"})])},sortable:!1,resizable:!1,className:"hn-table__expand-column"}};function l(e,n){var t=n.row,i=n.column,o=n.$index,l=i.property,u=l&&Object(r.getPropByPath)(t,l).v;return i&&i.formatter?i.formatter(t,i,u,o):u}var u=t(8),a=t(18),s=t.n(a),c=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},d=1,f={name:"HnTableColumn",props:{type:{type:String,default:"default"},label:String,className:String,labelClassName:String,property:String,prop:String,width:{},minWidth:{},renderHeader:Function,sortable:{type:[Boolean,String],default:!1},sortMethod:Function,sortBy:[String,Function,Array],resizable:{type:Boolean,default:!0},columnKey:String,align:String,headerAlign:String,showTooltipWhenOverflow:Boolean,showOverflowTooltip:Boolean,fixed:[Boolean,String],formatter:Function,selectable:Function,reserveSelection:Boolean,filterMethod:Function,filteredValue:Array,filters:Array,filterPlacement:String,filterMultiple:{type:Boolean,default:!0},index:[Number,Function],sortOrders:{type:Array,default:function(){return["ascending","descending",null]},validator:function(e){return e.every((function(e){return["ascending","descending",null].indexOf(e)>-1}))}}},data:function(){return{isSubColumn:!1,columns:[]}},computed:{owner:function(){for(var e=this.$parent;e&&!e.tableId;)e=e.$parent;return e},columnOrTableParent:function(){for(var e=this.$parent;e&&!e.tableId&&!e.columnId;)e=e.$parent;return e},realWidth:function(){return Object(u.l)(this.width)},realMinWidth:function(){return Object(u.k)(this.minWidth)},realAlign:function(){return this.align?"is-"+this.align:null},realHeaderAlign:function(){return this.headerAlign?"is-"+this.headerAlign:this.realAlign}},methods:{getPropsData:function(){for(var e=this,n=arguments.length,t=Array(n),r=0;r<n;r++)t[r]=arguments[r];return t.reduce((function(n,t){return Array.isArray(t)&&t.forEach((function(t){n[t]=e[t]})),n}),{})},getColumnElIndex:function(e,n){return[].indexOf.call(e,n)},setColumnWidth:function(e){return this.realWidth&&(e.width=this.realWidth),this.realMinWidth&&(e.minWidth=this.realMinWidth),e.minWidth||(e.minWidth=80),e.realWidth=void 0===e.width?e.minWidth:e.width,e},setColumnForcedProps:function(e){var n=e.type,t=o[n]||{};return Object.keys(t).forEach((function(n){var r=t[n];void 0!==r&&(e[n]="className"===n?e[n]+" "+r:r)})),e},setColumnRenders:function(e){var n=this,t=(this.$createElement,Object.keys(o));this.renderHeader?console.warn("[Heiner Warn][TableColumn]Comparing to render-header, scoped-slot header is easier to use. We recommend users to use scoped-slot header."):-1===t.indexOf(e.type)&&(e.renderHeader=function(t,r){var i=n.$scopedSlots.header;return i?i(r):e.label});var r=e.renderCell;return"expand"===e.type?(e.renderCell=function(e,n){return e("div",{class:"cell"},[r(e,n)])},this.owner.renderExpanded=function(e,t){return n.$scopedSlots.default?n.$scopedSlots.default(t):n.$slots.default}):(r=r||l,e.renderCell=function(t,i){var o=null;o=n.$scopedSlots.default?n.$scopedSlots.default(i):r(t,i);var l=function(e,n){var t=n.row,r=n.treeNode,i=n.store;if(!r)return null;var o=[];if(r.indent&&o.push(e("span",{class:"hn-table__indent",style:{"padding-left":r.indent+"px"}})),"boolean"!=typeof r.expanded||r.noLazyChildren)o.push(e("span",{class:"hn-table__placeholder"}));else{var l=["hn-table__expand-icon",r.expanded?"hn-table__expand-icon--expanded":""],u=["hn-icon-arrow-right"];r.loading&&(u=["hn-icon-loading"]),o.push(e("div",{class:l,on:{click:function(e){e.stopPropagation(),i.loadOrToggle(t)}}},[e("i",{class:u})]))}return o}(t,i),u={class:"cell",style:{}};return e.showOverflowTooltip&&(u.class+=" hn-tooltip",u.style={width:(i.column.realWidth||i.column.width)-1+"px"}),t("div",u,[l,o])}),e},registerNormalWatchers:function(){var e=this,n={prop:"property",realAlign:"align",realHeaderAlign:"headerAlign",realWidth:"width"},t=["label","property","filters","filterMultiple","sortable","index","formatter","className","labelClassName","showOverflowTooltip"].reduce((function(e,n){return e[n]=n,e}),n);Object.keys(t).forEach((function(t){var r=n[t];e.$watch(t,(function(n){e.columnConfig[r]=n}))}))},registerComplexWatchers:function(){var e=this,n={realWidth:"width",realMinWidth:"minWidth"},t=["fixed"].reduce((function(e,n){return e[n]=n,e}),n);Object.keys(t).forEach((function(t){var r=n[t];e.$watch(t,(function(n){e.columnConfig[r]=n;var t="fixed"===r;e.owner.store.scheduleLayout(t)}))}))}},components:{HnCheckbox:s.a},beforeCreate:function(){this.row={},this.column={},this.$index=0,this.columnId=""},created:function(){var e=this.columnOrTableParent;this.isSubColumn=this.owner!==e,this.columnId=(e.tableId||e.columnId)+"_column_"+d++;var n=this.type||"default",t=""===this.sortable||this.sortable,r=c({},i[n],{id:this.columnId,type:n,property:this.prop||this.property,align:this.realAlign,headerAlign:this.realHeaderAlign,showOverflowTooltip:this.showOverflowTooltip||this.showTooltipWhenOverflow,filterable:this.filters||this.filterMethod,filteredValue:[],filterPlacement:"",isColumnGroup:!1,filterOpened:!1,sortable:t,index:this.index}),o=this.getPropsData(["columnKey","label","className","labelClassName","type","renderHeader","formatter","fixed","resizable"],["sortMethod","sortBy","sortOrders"],["selectable","reserveSelection"],["filterMethod","filters","filterMultiple","filterOpened","filteredValue","filterPlacement"]);o=Object(u.h)(r,o),o=Object(u.a)(this.setColumnRenders,this.setColumnWidth,this.setColumnForcedProps)(o),this.columnConfig=o,this.registerNormalWatchers(),this.registerComplexWatchers()},mounted:function(){var e=this.owner,n=this.columnOrTableParent,t=this.isSubColumn?n.$el.children:n.$refs.hiddenColumns.children,r=this.getColumnElIndex(t,this.$el);e.store.commit("insertColumn",this.columnConfig,r,this.isSubColumn?n.columnConfig:null)},destroyed:function(){if(this.$parent){var e=this.$parent;this.owner.store.commit("removeColumn",this.columnConfig,this.isSubColumn?e.columnConfig:null)}},render:function(e){return e("div",this.$slots.default)},install:function(e){e.component(f.name,f)}};n.default=f},18:function(e,n){e.exports=require("jiku-ui/lib/checkbox")},3:function(e,n){e.exports=require("jiku-ui/lib/utils/util")},8:function(e,n,t){"use strict";t.d(n,"b",(function(){return o})),t.d(n,"i",(function(){return u})),t.d(n,"d",(function(){return a})),t.d(n,"e",(function(){return s})),t.d(n,"c",(function(){return c})),t.d(n,"g",(function(){return d})),t.d(n,"f",(function(){return f})),t.d(n,"h",(function(){return p})),t.d(n,"l",(function(){return m})),t.d(n,"k",(function(){return b})),t.d(n,"j",(function(){return g})),t.d(n,"a",(function(){return y})),t.d(n,"m",(function(){return v})),t.d(n,"n",(function(){return x}));var r=t(3),i="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},o=function(e){for(var n=e.target;n&&"HTML"!==n.tagName.toUpperCase();){if("TD"===n.tagName.toUpperCase())return n;n=n.parentNode}return null},l=function(e){return null!==e&&"object"===(void 0===e?"undefined":i(e))},u=function(e,n,t,i,o){if(!n&&!i&&(!o||Array.isArray(o)&&!o.length))return e;t="string"==typeof t?"descending"===t?-1:1:t&&t<0?-1:1;var u=i?null:function(t,i){return o?(Array.isArray(o)||(o=[o]),o.map((function(n){return"string"==typeof n?Object(r.getValueByPath)(t,n):n(t,i,e)}))):("$key"!==n&&l(t)&&"$value"in t&&(t=t.$value),[l(t)?Object(r.getValueByPath)(t,n):t])};return e.map((function(e,n){return{value:e,index:n,key:u?u(e,n):null}})).sort((function(e,n){var r=function(e,n){if(i)return i(e.value,n.value);for(var t=0,r=e.key.length;t<r;t++){if(e.key[t]<n.key[t])return-1;if(e.key[t]>n.key[t])return 1}return 0}(e,n);return r||(r=e.index-n.index),r*t})).map((function(e){return e.value}))},a=function(e,n){var t=null;return e.columns.forEach((function(e){e.id===n&&(t=e)})),t},s=function(e,n){for(var t=null,r=0;r<e.columns.length;r++){var i=e.columns[r];if(i.columnKey===n){t=i;break}}return t},c=function(e,n){var t=(n.className||"").match(/hn-table_[^\s]+/gm);return t?a(e,t[0]):null},d=function(e,n){if(!e)throw new Error("row is required when get row identity");if("string"==typeof n){if(n.indexOf(".")<0)return e[n];for(var t=n.split("."),r=e,i=0;i<t.length;i++)r=r[t[i]];return r}if("function"==typeof n)return n.call(null,e)},f=function(e,n){var t={};return(e||[]).forEach((function(e,r){t[d(e,n)]={row:e,index:r}})),t};function h(e,n){return Object.prototype.hasOwnProperty.call(e,n)}function p(e,n){var t={},r=void 0;for(r in e)t[r]=e[r];for(r in n)if(h(n,r)){var i=n[r];void 0!==i&&(t[r]=i)}return t}function m(e){return void 0!==e&&(e=parseInt(e,10),isNaN(e)&&(e=null)),e}function b(e){return void 0!==e&&(e=m(e),isNaN(e)&&(e=80)),e}function g(e){return"number"==typeof e?e:"string"==typeof e?/^\d+(?:px)?$/.test(e)?parseInt(e,10):e:null}function y(){for(var e=arguments.length,n=Array(e),t=0;t<e;t++)n[t]=arguments[t];return 0===n.length?function(e){return e}:1===n.length?n[0]:n.reduce((function(e,n){return function(){return e(n.apply(void 0,arguments))}}))}function v(e,n,t){var r=!1,i=e.indexOf(n),o=-1!==i,l=function(){e.push(n),r=!0},u=function(){e.splice(i,1),r=!0};return"boolean"==typeof t?t&&!o?l():!t&&o&&u():o?u():l(),r}function x(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"children",r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"hasChildren",i=function(e){return!(Array.isArray(e)&&e.length)};function o(e,l,u){n(e,l,u),l.forEach((function(e){if(e[r])n(e,null,u+1);else{var l=e[t];i(l)||o(e,l,u+1)}}))}e.forEach((function(e){if(e[r])n(e,null,0);else{var l=e[t];i(l)||o(e,l,0)}}))}}}).default;