vxe-table-select-area
Version:
一个基于 vxe-table 的可区域选中复制、粘贴的组件
1 lines • 32.2 kB
JavaScript
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _methods,_vue=require("vue"),_xeUtils=_interopRequireDefault(require("xe-utils")),_mouseEvent=require("../utils/mouse-event"),_scrollBar=require("../utils/scroll-bar"),_index=require("../utils/index"),_constant=require("../utils/constant"),_common=require("../common"),_clipboard=require("../common/clipboard"),_constant2=require("../common/constant"),_eventKeyCodes=require("../utils/event-key-codes");function _interopRequireDefault(e){return e&&e.__esModule?e:{default: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})(e)}function ownKeys(t,e){var o,l=Object.keys(t);return Object.getOwnPropertySymbols&&(o=Object.getOwnPropertySymbols(t),e&&(o=o.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),l.push.apply(l,o)),l}function _objectSpread(t){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(Object(o),!0).forEach(function(e){_defineProperty(t,e,o[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):ownKeys(Object(o)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))})}return t}function _defineProperty(e,t,o){return(t=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}function _toPropertyKey(e){e=_toPrimitive(e,"string");return"symbol"===_typeof(e)?e:String(e)}function _toPrimitive(e,t){if("object"!==_typeof(e)||null===e)return e;var o=e[Symbol.toPrimitive];if(void 0===o)return("string"===t?String:Number)(e);o=o.call(e,t||"default");if("object"!==_typeof(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}var _default={name:"VxeSelection",data:function(){return{currentCellEl:null,isBodyCellMousedown:!1,cellSelectionData:{currentCell:{rowKey:"",colKey:"",rowIndex:-1},normalEndCell:{rowKey:"",colKey:"",rowIndex:-1},autoFillEndCell:{rowKey:"",colKey:""}},cellSelectionRangeData:{leftColKey:"",rightColKey:"",topRowKey:"",bottomRowKey:""},bodyIndicatorRowKeys:{startRowKey:"",startRowKeyIndex:-1,endRowKey:"",endRowKeyIndex:-1},tableContainerRef:"$el",tableContentWrapperRef:"tableBody",colgroups:[],cellSelectionRect:{currentCellRect:{left:0,top:0,width:0,height:0},normalEndCellRect:{left:0,top:0,width:0,height:0},autoFillEndCellRect:{left:0,top:0,width:0,height:0}},domRect:{},currentCellSelectionType:"",isAutofillStarting:!1,isColumnResizing:!1,enableStopEditing:!0}},computed:{allRowKeys:function(){var e=[],t=this.rowOpts.keyField,t=(this.rowKeyFieldName=t,this.tableData),o=this.rowKeyFieldName;return e=o?t.map(function(e){return e[o]}):e},enableCellSelection:function(){var e=!0,t=this.cellSelectionOption,o=this.rowKeyFieldName;return e=(0,_index.isEmptyValue)(o)||t&&(0,_index.isBoolean)(t.enable)&&!1===t.enable?!1:e},showCorner:function(){var e,t,o=!0;return o=this.cellAutofillOption&&(e=(t=this.cellAutofillOption).directionX,t=t.directionY,!(0,_index.isBoolean)(t)||t||!(0,_index.isBoolean)(e)||e)?o:!1}},watch:{tableColumn:{handler:function(e){var t=this;this.$nextTick(function(){t.tableEl=t.$refs[t.tableContentWrapperRef].$refs.table,t.tableColumn.forEach(function(e){e={field:e.field||e.id,edit:!0,key:e.id,title:e.title||e.type,width:e.minWidth,_colspan:e.colSpan,_keys:e.id,_level:e.level,_realTimeWidth:e.renderWidth,_rowspan:e.rowSpan};t.colgroups.push(e)})})},immediate:!1},allRowKeys:{handler:function(e){var t;Array.isArray(e)&&-1<(t=this.cellSelectionData.currentCell).rowIndex&&-1===e.indexOf(t.rowKey)&&this.clearCellSelectionCurrentCell()},immediate:!1},"cellSelectionData.currentCell":{handler:function(e){this.setCurrentCellSelectionType();var t=e.rowKey,e=e.colKey;(0,_index.isEmptyValue)(t)||(0,_index.isEmptyValue)(e)?this[_constant2.INSTANCE_METHODS.CLEAR_CURRENT_CELL_RECT]():(this.setCurrentCellEl(),this.setSelectionPositions({type:"currentCell"})),this.setCellSelectionRangeData()},deep:!0,immediate:!0},"cellSelectionData.normalEndCell":{handler:function(e){this.setCurrentCellSelectionType();var t=e.rowKey,e=e.colKey;(0,_index.isEmptyValue)(t)||(0,_index.isEmptyValue)(e)?this[_constant2.INSTANCE_METHODS.CLEAR_NORMAL_END_CELL_RECT]():(this.setNormalEndCellEl(),this.setSelectionPositions({type:"normalEndCell"})),this.setCellSelectionRangeData()},deep:!0,immediate:!0},"cellSelectionData.autoFillEndCell":{handler:function(e){var t=e.rowKey,e=e.colKey;(0,_index.isEmptyValue)(t)||(0,_index.isEmptyValue)(e)?this.clearAutofillEndCellRect():(this.setAutofillEndCellEl(),this.setSelectionPositions({type:"autoFillEndCell"}))},deep:!0,immediate:!0},isAutofillStarting:{handler:function(e){e||(this.setCellSelectionByAutofill(),this.clearCellSelectionAutofillEndCell())}}},methods:(_defineProperty(_methods={setCurrentCellSelectionType:function(){var e=this.cellSelectionData,t=e.currentCell,e=e.normalEndCell,t=(0,_index.isEmptyValue)(t.rowKey)||(0,_index.isEmptyValue)(t.colKey)?"":(0,_index.isEmptyValue)(e.rowKey)||(0,_index.isEmptyValue)(e.colKey)?_constant2.CURRENT_CELL_SELECTION_TYPES.SINGLE:_constant2.CURRENT_CELL_SELECTION_TYPES.RANGE;this.currentCellSelectionType=t},resetCellPositions:function(){var e=this.cellSelectionData,t=e.currentCell,e=e.normalEndCell;(0,_index.isEmptyValue)(t.rowKey)||(0,_index.isEmptyValue)(t.colKey)||this.setSelectionPositions({type:"currentCell"}),(0,_index.isEmptyValue)(e.rowKey)||(0,_index.isEmptyValue)(e.colKey)||this.setSelectionPositions({type:"normalEndCell"})},cellSelectionRangeDataChange:function(e){this.cellSelectionRangeData=Object.assign(this.cellSelectionRangeData,e)},cellSelectionCornerMousedown:function(e){e.event;this.isAutofillStarting=!0},autofillingDirectionChange:function(e){this.autofillingDirection=e},cellSelectionCornerMouseup:function(e){e.event;this.isAutofillStarting=!1},handleCellAreaEvent:function(e,t){var o=e.shiftKey,l=t.row,t=t.column,i=this.getRowid,r=this.cellSelectionData,n=this.cellSelectionRangeData,s=this.colgroups,c=this.allRowKeys,i=i(l),a=t.id,d=r.currentCell,e=(0,_mouseEvent.getMouseEventClickType)(e);this.isBodyCellMousedown=!0,(0,_common.isClearSelectionByBodyCellRightClick)({mouseEventClickType:e,cellData:{rowKey:i,colKey:a},cellSelectionData:r,cellSelectionRangeData:n,colgroups:s,allRowKeys:c})&&(this.clearBodyIndicatorRowKeys(),o&&-1<d.rowIndex?this.cellSelectionNormalEndCellChange({rowKey:i,colKey:a}):(this.cellSelectionByClick({rowData:l,column:t}),this.clearCellSelectionNormalEndCell()))},tableClickOutside:function(e){if((0,_common.isContextmenuPanelClicked)(e))return!1;this.isHeaderCellMousedown=!1,this.isBodyCellMousedown=!1,this.isBodyOperationColumnMousedown=!1,this.isAutofillStarting=!1,this.setIsColumnResizing(!1),this.clearCellSelectionCurrentCell(),this.clearCellSelectionNormalEndCell(),this.clearBodyIndicatorRowKeys()},clearHeaderIndicatorColKeys:function(){this.headerIndicatorColKeys.startColKey="",this.headerIndicatorColKeys.startColKeyIndex=-1,this.headerIndicatorColKeys.endColKey="",this.headerIndicatorColKeys.endColKeyIndex=-1},clearCellSelectionCurrentCell:function(){this.cellSelectionCurrentCellChange({rowKey:"",colKey:"",rowIndex:-1})},setIsColumnResizing:function(e){this.isColumnResizing=e},setCellSelectionRangeData:function(){var e=this.currentCellSelectionType,t=this.cellSelectionData,o=t.currentCell,t=t.normalEndCell,l={};e===_constant2.CURRENT_CELL_SELECTION_TYPES.SINGLE?l={leftColKey:o.colKey,rightColKey:o.colKey,topRowKey:o.rowKey,bottomRowKey:o.rowKey}:e===_constant2.CURRENT_CELL_SELECTION_TYPES.RANGE?((0,_common.getLeftmostColKey)({colgroups:this.colgroups,colKeys:[o.colKey,t.colKey]})===o.colKey?(l.leftColKey=o.colKey,l.rightColKey=t.colKey):(l.leftColKey=t.colKey,l.rightColKey=o.colKey),o.rowIndex<t.rowIndex?(l.topRowKey=o.rowKey,l.bottomRowKey=t.rowKey):(l.topRowKey=t.rowKey,l.bottomRowKey=o.rowKey)):l={leftColKey:"",rightColKey:"",topRowKey:"",bottomRowKey:""},this.$emit(_constant2.EMIT_EVENTS.CELL_SELECTION_RANGE_DATA_CHANGE,l)},cellSelectionByClick:function(e){var t=e.rowData,e=e.column,t=(0,this.getRowid)(t);this[_constant2.INSTANCE_METHODS.SET_CELL_SELECTION]({rowKey:t,colKey:e.id,isScrollToRow:!1}),this.rowToVisible(_constant.KEY_CODES.ARROW_UP,t),this.rowToVisible(_constant.KEY_CODES.ARROW_DOWN,t)},setAutofillEndCellEl:function(){var e=this.cellSelectionData,t=this.tableEl,e=e.autoFillEndCell,o=e.rowKey,e=e.colKey;t&&(t=t.querySelector('tbody tr[rowid="'.concat(o,'"] td[colid="').concat(e,'"]')))&&(this.autoFillEndCellEl=t)}},_constant2.INSTANCE_METHODS.SET_CELL_SELECTION,function(e){var t=e.rowKey,o=e.colKey,e=e.isScrollToRow,e=void 0===e||e;this.enableCellSelection;(0,_index.isEmptyValue)(t)||(0,_index.isEmptyValue)(o)||(this.cellSelectionCurrentCellChange({rowKey:t,colKey:o}),(0,_common.getColumnByColkey)(o,this.colgroups),e&&this[_constant2.INSTANCE_METHODS.SCROLL_TO_ROW_KEY]({rowKey:t}))}),_defineProperty(_methods,_constant2.INSTANCE_METHODS.SCROLL_TO_ROW_KEY,function(e){var t=e.rowKey;if((0,_index.isEmptyValue)(t))return!1;var o,l=0,e=this.isVirtualScroll,i=this.headerTotalHeight,r=this.$refs[this.tableContainerRef];e?((o=this.virtualScrollPositions.find(function(e){return e.rowKey===t}))&&(l=o.top),setTimeout(function(){scrollTo(r,{top:l,behavior:"auto"})},200)):l=this.$el.querySelector("tbody tr[".concat(_constant2.COMPS_CUSTOM_ATTRS.BODY_ROW_KEY,'="').concat(t,'"]')).offsetTop-i,scrollTo(r,{top:l,behavior:e?"auto":"smooth"})}),_defineProperty(_methods,_constant2.INSTANCE_METHODS.CLEAR_CURRENT_CELL_RECT,function(){this.currentCellEl=null,this.cellSelectionRect.currentCellRect={left:0,top:0,width:0,height:0}}),_defineProperty(_methods,"rowToVisible",function(e,t){var o,l,i=this[this.tableContainerRef],r=this.$refs[this.tableContentWrapperRef].$refs.table,n=this.isVirtualScroll,s=this.headerTotalHeight,c=this.footerTotalHeight,a=i.clientHeight,d=i.scrollTop,h=this.$el.querySelector("tbody tr[".concat(_constant2.COMPS_CUSTOM_ATTRS.BODY_ROW_KEY,'="').concat(t,'"]'));h&&(o=h.offsetTop,h=h.clientHeight,r=r.offsetTop,e===_constant.KEY_CODES.ARROW_UP?(l=0)<(l=n?s-(o-(d-r)):d+s-o)&&(i.scrollTop=d-l):e===_constant.KEY_CODES.ARROW_DOWN&&(s=0)<=(s=n?o-(d-r)+h+c-a:o+h+c-(a+d))&&(i.scrollTop=d+s),l=this.cellSelectionData.currentCell,this.cellSelectionCurrentCellChange({rowKey:t,colKey:l.colKey}))}),_defineProperty(_methods,"cellSelectionCurrentCellChange",function(e){var t=e.rowKey,e=e.colKey;this.cellSelectionData.currentCell.colKey=e,this.cellSelectionData.currentCell.rowKey=t,this.cellSelectionData.currentCell.rowIndex=this.allRowKeys.indexOf(t)}),_defineProperty(_methods,"clearCellSelectionNormalEndCell",function(){this.cellSelectionNormalEndCellChange({rowKey:"",colKey:"",rowIndex:-1})}),_defineProperty(_methods,"cellSelectionNormalEndCellChange",function(e){var t=e.rowKey,e=e.colKey;this.cellSelectionData.normalEndCell.colKey=e,this.cellSelectionData.normalEndCell.rowKey=t,this.cellSelectionData.normalEndCell.rowIndex=this.allRowKeys.indexOf(t)}),_defineProperty(_methods,"cellSelectionAutofillCellChange",function(e){var t=e.rowKey,e=e.colKey;this.cellSelectionData.autoFillEndCell.colKey=e,this.cellSelectionData.autoFillEndCell.rowKey=t}),_defineProperty(_methods,"clearBodyIndicatorRowKeys",function(){this.bodyIndicatorRowKeys.startRowKey="",this.bodyIndicatorRowKeys.startRowKeyIndex=-1,this.bodyIndicatorRowKeys.endRowKey="",this.bodyIndicatorRowKeys.endRowKeyIndex=-1}),_defineProperty(_methods,"setCurrentCellEl",function(){var e=this.cellSelectionData.currentCell,t=e.rowKey,e=e.colKey;(0,_index.isEmptyValue)(t)||(0,_index.isEmptyValue)(e)||(t=this.getTableCellEl({rowKey:t,colKey:e}))&&(this.currentCellEl=t)}),_defineProperty(_methods,"setNormalEndCellEl",function(){var e=this.cellSelectionData.normalEndCell,t=e.rowKey,e=e.colKey;(0,_index.isEmptyValue)(t)||(0,_index.isEmptyValue)(e)||(t=this.getTableCellEl({rowKey:t,colKey:e}))&&(this.normalEndCellEl=t)}),_defineProperty(_methods,"setSelectionPositions",function(e){var t,o,l,i,r,e=e.type,n=this.allRowKeys,s=this.tableEl,c=this.currentCellEl,a=this.normalEndCellEl,d=this.autoFillEndCellEl,h=this.cellSelectionData,y=this.virtualScrollVisibleIndexs;return 0!==n.length&&!!s&&(t=(n=s.getBoundingClientRect()).left,n=n.top,l=o=!1,"currentCell"===e&&(o=!0,c)&&(c=this.getCellPosition({cellEl:c,tableLeft:t,tableTop:n}),this.domRect=c)&&(o=!1,this.cellSelectionRect.currentCellRect=c),"normalEndCell"===e&&(l=!0,a)&&(c=this.getCellPosition({cellEl:a,tableLeft:t,tableTop:n}))&&(l=!1,this.cellSelectionRect.normalEndCellRect=c),(o||l)&&this.isVirtualScroll&&(a=h.currentCell,c=h.normalEndCell,h=(o?(i=a.colKey,a):(i=c.colKey,c)).rowIndex,o&&!this.cellSelectionRect.currentCellRect.height||l&&!this.cellSelectionRect.normalEndCellRect.height?(a={tableLeft:t,tableTop:n,colKey:i},h<y.start?r=this.getCellPositionByColKey(_objectSpread(_objectSpread({},a),{},{isFirstRow:!0})):h>y.end&&(r=this.getCellPositionByColKey(_objectSpread(_objectSpread({},a),{},{isLastRow:!0})))):h<y.start?r={top:0}:h>y.end&&(r={top:s.clientHeight}),o?Object.assign(this.cellSelectionRect.currentCellRect,r):Object.assign(this.cellSelectionRect.normalEndCellRect,r)),void(d&&"autoFillEndCell"===e&&(c=this.getCellPosition({cellEl:d,tableLeft:t,tableTop:n}))&&(this.cellSelectionRect.autoFillEndCellRect=c)))}),_defineProperty(_methods,"getCellPosition",function(e){var t=e.cellEl,o=e.tableLeft,e=e.tableTop,t=t.getBoundingClientRect(),l=t.left,i=t.top,r=t.height,t=t.width;if(r&&t)return{left:l-o,top:i-e,width:t,height:r}}),_defineProperty(_methods,"getTableCellEl",function(e){var t=e.rowKey,e=e.colKey,o=null,l=this.$refs[this.tableContentWrapperRef].$refs.table;return o=l?l.querySelector('tbody tr[rowid="'.concat(t,'"] td[colid="').concat(e,'"]')):o}),_defineProperty(_methods,"getSelectionCurrent",function(e){var e=e.fixedType,t={selectionCurrent:null,autoFillArea:null},o=this.cellSelectionRect,l=this.colgroups,i=this.cellSelectionData,r=o.currentCellRect,o=o.normalEndCellRect;return r.width&&((r={borderWidth:r.width+1,borderHeight:r.height,topBorder:{show:!0,width:0,height:2,top:r.top-1,left:r.left-1},rightBorder:{show:!0,width:2,height:0,top:r.top,left:r.left+r.width-2},bottomBorder:{show:!0,width:0,height:2,top:r.top+r.height-2,left:r.left-1},leftBorder:{show:!0,width:2,height:0,top:r.top,left:r.left-1},corner:{show:!o.width,top:0,left:0}}).corner.top=r.bottomBorder.top-3,r.corner.left=r.rightBorder.left-3,o.width||(t.autoFillArea=this.getSelectionAutofillArea({areaPostions:r,fixedType:e})),i=[i.currentCell.colKey],l=(0,_common.getColKeysByFixedTypeWithinColKeys)({colKeys:i,fixedType:e,colgroups:l}),t.selectionCurrent=this.getBorders(_objectSpread(_objectSpread({},r),{},{showCorner:!o.width,className:"selection-current",fixedType:e,totalColKeys:i,fixedColKeys:l}))),t}),_defineProperty(_methods,"getSelectionAutofillArea",function(e){var t=e.areaPostions,e=e.fixedType,o=this.cellAutofillOption,l=this.cellSelectionRangeData,i=this.cellSelectionRect,r=this.cellSelectionData,n=this.isAutofillStarting,s=this.currentCellSelectionType,c=this.colgroups;if(!n)return null;n=i.currentCellRect,i=i.autoFillEndCellRect;if(!n.width||!i.width)return null;if(!t)return null;var a,d,h,n={borderWidth:0,borderHeight:0,topBorder:{show:!0,width:0,height:1,top:0,left:0},rightBorder:{show:!0,width:1,height:0,top:0,left:0},bottomBorder:{show:!0,width:0,height:1,top:0,left:0},leftBorder:{show:!0,width:1,height:0,top:0,left:0},corner:{show:!1,top:0,left:0}},y=r.currentCell,r=r.autoFillEndCell,u=l.leftColKey,l=l.rightColKey;if(s===_constant2.CURRENT_CELL_SELECTION_TYPES.SINGLE&&(u=y.colKey,l=y.colKey),u!==r.colKey&&(f=(0,_common.getLeftmostColKey)({colgroups:c,colKeys:[u,r.colKey]})),l!==r.colKey&&(p=(0,_common.getRightmostColKey)({colgroups:c,colKeys:[l,r.colKey]})),i.top>t.bottomBorder.top)a=_constant2.AUTOFILLING_DIRECTION.DOWN,d=u,h=l,n.topBorder.show=!1,n.borderWidth=t.borderWidth,n.borderHeight=i.top-t.bottomBorder.top+i.height,n.rightBorder.top=t.bottomBorder.top,n.rightBorder.left=t.rightBorder.left,s===_constant2.CURRENT_CELL_SELECTION_TYPES.SINGLE&&n.rightBorder.left++,n.leftBorder.top=t.bottomBorder.top,n.leftBorder.left=t.leftBorder.left,n.bottomBorder.top=i.top+i.height-1,n.bottomBorder.left=t.bottomBorder.left;else if(i.top<t.topBorder.top)a=_constant2.AUTOFILLING_DIRECTION.UP,d=u,h=l,n.bottomBorder.show=!1,n.borderWidth=t.borderWidth,n.borderHeight=t.topBorder.top-i.top,n.topBorder.top=i.top-1,n.topBorder.left=t.topBorder.left,n.rightBorder.top=i.top,n.rightBorder.left=t.rightBorder.left,s===_constant2.CURRENT_CELL_SELECTION_TYPES.SINGLE&&n.rightBorder.left++,n.leftBorder.top=i.top,n.leftBorder.left=t.leftBorder.left;else if(p!==r.colKey||(0,_index.isEmptyValue)(p)){if(f!==r.colKey||(0,_index.isEmptyValue)(f))return null;a=_constant2.AUTOFILLING_DIRECTION.LEFT,d=(0,_common.getPreviewColKey)({colgroups:c,currentColKey:u}),h=r.colKey,n.rightBorder.show=!1,n.borderWidth=t.leftBorder.left-i.left+1,n.borderHeight=t.borderHeight,n.topBorder.top=t.topBorder.top,n.topBorder.left=i.left,n.rightBorder.left=t.topBorder.left,n.bottomBorder.top=t.bottomBorder.top,n.bottomBorder.left=i.left,n.leftBorder.top=t.topBorder.top,n.leftBorder.left=i.left}else a=_constant2.AUTOFILLING_DIRECTION.RIGHT,d=(0,_common.getNextColKey)({colgroups:c,currentColKey:l}),h=r.colKey,n.leftBorder.show=!1,n.borderWidth=i.left-t.rightBorder.left+i.width+1,n.borderHeight=t.borderHeight,n.topBorder.top=t.topBorder.top,n.topBorder.left=t.rightBorder.left-1,n.rightBorder.top=t.topBorder.top,n.rightBorder.left=i.left+i.width-1,n.bottomBorder.top=t.bottomBorder.top,n.bottomBorder.left=t.rightBorder.left-1;var p,f,y=o.directionX,s=o.directionY;return!((0,_index.isBoolean)(y)&&!y&&(a===_constant2.AUTOFILLING_DIRECTION.LEFT||a===_constant2.AUTOFILLING_DIRECTION.RIGHT)||(0,_index.isBoolean)(s)&&!s&&(a===_constant2.AUTOFILLING_DIRECTION.UP||a===_constant2.AUTOFILLING_DIRECTION.DOWN))&&(p=(0,_common.getColKeysByRangeColKeys)({colKey1:d,colKey2:h,colgroups:c}),f=(0,_common.getColKeysByFixedTypeWithinColKeys)({colKeys:p,fixedType:e,colgroups:c}),(u=this.getBorders(_objectSpread(_objectSpread({className:"selection-autofill-area"},n),{},{fixedType:e,totalColKeys:p,fixedColKeys:f})))&&this.$emit(_constant2.EMIT_EVENTS.AUTOFILLING_DIRECTION_CHANGE,a),u)}),_defineProperty(_methods,"cornerCellInfo",function(){var e,t=this.allRowKeys,o=this.colgroups,l=this.cellSelectionRangeData,i=l.rightColKey,l=l.bottomRowKey,r=!1,n=!1;return{isLastColumn:r=!(0,_common.isLastColumnByColKey)(i,o)&&(e=o.findIndex(function(e){return e.key===i}),o[e+1].fixed!==_constant2.COLUMN_FIXED_TYPE.RIGHT||o[e].fixed===_constant2.COLUMN_FIXED_TYPE.RIGHT)?r:!0,isLastRow:n=(0,_common.isLastRowByRowKey)(l,t)?!0:n}}),_defineProperty(_methods,"getBorders",function(e){var t=this,o=e.borderWidth,l=e.borderHeight,i=e.topBorder,r=e.rightBorder,n=e.bottomBorder,s=e.leftBorder,c=e.corner,a=e.className,d=e.fixedType,h=e.totalColKeys,e=e.fixedColKeys,y=this.cornerCellInfo,u=this.colgroups,p=this.isFirstSelectionRow,f=this.isFirstSelectionCol,C=this.isFirstNotFixedSelectionCol,_=this.showCorner,K=this.scrollYStore,E=K.startIndex,K=K.rowHeight,E=Math.max(0,E*K);return(d?(0,_common.isExistGivenFixedColKey)({fixedType:d,colKeys:h,colgroups:u}):(0,_common.isExistNotFixedColKey)({colKeys:h,colgroups:u}))?(K=0,e.length&&(K=(0,_common.getTotalWidthByColKeys)({colKeys:e,colgroups:u})),d&&(o=K,d===_constant2.COLUMN_FIXED_TYPE.LEFT)&&(o+=1),d===_constant2.COLUMN_FIXED_TYPE.LEFT&&h.length!==e.length&&(r.show=!1,c.show=!1),d===_constant2.COLUMN_FIXED_TYPE.RIGHT&&(h.length!==e.length&&(s.show=!1),i.left=r.left-o+1,n.left=r.left-o+1),p&&(i.top+=1),f&&(s.left+=1),C&&(s.left+=1),u=c.top,K=c.left,h=d="1px",y.isLastRow&&(u-=3,h="0px"),y.isLastColumn&&(K-=3,d="0px"),_||(c.show=!1),e={class:(0,_common.clsName)("selection-corner"),style:{display:c.show?"block":"none",top:E?u+E+"px":u+"px",left:K+"px",borderWidth:"1px ".concat(d," ").concat(h," 1px")},on:{mousedown:function(e){t.$emit(_constant2.EMIT_EVENTS.SELECTION_CORNER_MOUSEDOWN,{event:e})},mouseup:function(e){t.$emit(_constant2.EMIT_EVENTS.SELECTION_CORNER_MOUSEUP,{event:e})}}},(0,_vue.h)("div",{class:(0,_common.clsName)(a)},[(0,_vue.h)("div",{class:(0,_common.clsName)("selection-border"),style:{display:i.show?"block":"none",width:o+"px",height:i.height+"px",top:E?i.top+E+"px":i.top+"px",left:i.left+"px"}}),(0,_vue.h)("div",{class:(0,_common.clsName)("selection-border"),style:{display:r.show?"block":"none",width:r.width+"px",height:l+"px",top:E?r.top+E+"px":r.top+"px",left:r.left+"px"}}),(0,_vue.h)("div",{class:(0,_common.clsName)("selection-border"),style:{display:n.show?"block":"none",width:o+"px",height:n.height+"px",top:E?n.top+E+"px":n.top+"px",left:n.left+"px"}}),(0,_vue.h)("div",{class:(0,_common.clsName)("selection-border"),style:{display:s.show?"block":"none",width:s.width+"px",height:l+"px",top:E?s.top+E+"px":s.top+"px",left:s.left+"px"}}),(0,_vue.h)("div",_objectSpread({},e))])):null}),_defineProperty(_methods,"getSelectionAreas",function(e){var t,o,e=e.fixedType,l={normalArea:null,autoFillArea:null},i=this.cellSelectionData,r=i.currentCell,i=i.normalEndCell,n=this.cellSelectionRect,s=this.cellSelectionRangeData,c=this.colgroups,a=n.currentCellRect,n=n.normalEndCellRect;return a.width&&n.width&&(t={borderWidth:0,borderHeight:0,topBorder:{show:!0,width:0,height:1,top:0,left:0},rightBorder:{show:!0,width:1,height:0,top:0,left:0},bottomBorder:{show:!0,width:0,height:1,top:0,left:0},leftBorder:{show:!0,width:1,height:0,top:0,left:0},corner:{show:!0,top:0,left:0}},(o=(0,_common.getLeftmostColKey)({colgroups:this.colgroups,colKeys:[r.colKey,i.colKey]}))===r.colKey?(t.borderWidth=n.left-a.left+n.width+1,t.topBorder.left=a.left-1,t.bottomBorder.left=a.left-1,t.leftBorder.left=a.left-1,t.rightBorder.left=n.left+n.width-1):o===i.colKey&&(t.borderWidth=a.left-n.left+a.width+1,t.topBorder.left=n.left-1,t.rightBorder.left=a.left+a.width-1,t.bottomBorder.left=n.left-1,t.leftBorder.left=n.left-1),n.top>a.top?(t.borderHeight=n.top-a.top+n.height,t.topBorder.top=a.top-1,t.rightBorder.top=a.top,t.bottomBorder.top=n.top+n.height-1,t.leftBorder.top=a.top):n.top<=a.top&&(t.borderHeight=a.top-n.top+a.height,t.topBorder.top=n.top-1,t.rightBorder.top=n.top,t.bottomBorder.top=a.top+a.height-1,t.leftBorder.top=n.top),t.corner.top=t.bottomBorder.top-4,t.corner.left=t.rightBorder.left-4,n.width&&(l.autoFillArea=this.getSelectionAutofillArea({areaPostions:t,fixedType:e})),r=s.leftColKey,o=s.rightColKey,i=(0,_common.getColKeysByRangeColKeys)({colKey1:r,colKey2:o,colgroups:c}),a=(0,_common.getColKeysByFixedTypeWithinColKeys)({colKeys:i,fixedType:e,colgroups:c}),l.normalArea=this.getBorders(_objectSpread(_objectSpread({},t),{},{className:"selection-normal-area",fixedType:e,totalColKeys:i,fixedColKeys:a})),l.normalAreaLayer=this.getAreaLayer(_objectSpread(_objectSpread({},t),{},{className:"selection-normal-area-layer",fixedType:e,totalColKeys:i,fixedColKeys:a}))),l}),_defineProperty(_methods,"getAreaLayer",function(e){var t=e.borderWidth,o=e.borderHeight,l=e.topBorder,i=e.className,r=e.fixedType,n=e.totalColKeys,e=e.fixedColKeys,s=this.colgroups,c=this.scrollYStore,a=c.startIndex,c=c.rowHeight,a=Math.max(0,a*c);return(r?(0,_common.isExistGivenFixedColKey)({fixedType:r,colKeys:n,colgroups:s}):(0,_common.isExistNotFixedColKey)({colKeys:n,colgroups:s}))?(c=0,e.length&&(c=(0,_common.getTotalWidthByColKeys)({colKeys:e,colgroups:s})),r&&(t=c,r===_constant2.COLUMN_FIXED_TYPE.LEFT)&&(t+=1),(0,_vue.h)("div",{class:(0,_common.clsName)(i),style:{top:a?l.top+a+"px":l.top+"px",left:l.left+"px",width:t+"px",height:o+"px"}})):null}),_defineProperty(_methods,"bodyCellMouseover",function(e){e.event;var e=e.params,t=(this.rowKeyFieldName,this.isBodyCellMousedown),o=this.isAutofillStarting,l=this.isHeaderCellMousedown,i=this.isBodyOperationColumnMousedown,r=this.getRowid,n=e.row,e=e.column,r=r(n),n=e.id;if(t){if((0,_common.isOperationColumn)(n,this.colgroups))return!1;this.cellSelectionNormalEndCellChange({rowKey:r,colKey:n})}if(i&&this.bodyIndicatorRowKeysChange({startRowKey:this.bodyIndicatorRowKeys.startRowKey,endRowKey:r}),l&&this.headerIndicatorColKeysChange({startColKey:this.headerIndicatorColKeys.startColKey,endColKey:n}),o){if((0,_common.isOperationColumn)(n,this.colgroups))return!1;this.cellSelectionAutofillCellChange({rowKey:r,colKey:n})}}),_defineProperty(_methods,"tableContainerMouseup",function(){this.isHeaderCellMousedown=!1,this.isBodyCellMousedown=!1,this.isBodyOperationColumnMousedown=!1,this.isAutofillStarting=!1}),_defineProperty(_methods,_constant2.INSTANCE_METHODS.CLEAR_NORMAL_END_CELL_RECT,function(){this.normalEndCellEl=null,this.cellSelectionRect.normalEndCellRect={left:0,top:0,width:0,height:0}}),_defineProperty(_methods,"clearAutofillEndCellRect",function(){this.autoFillEndCellEl=null,this.cellSelectionRect.autoFillEndCellRect={left:0,top:0,width:0,height:0}}),_defineProperty(_methods,"bodyCellDoubleClick",function(e){e.event,e.rowData,e.column,this.colgroups}),_defineProperty(_methods,"clearCellSelectionAutofillEndCell",function(){this.cellSelectionAutofillCellChange({rowKey:"",colKey:""})}),_defineProperty(_methods,"enableClipboard",function(){return this.rowKeyFieldName}),_defineProperty(_methods,"editorCopy",function(e){var t=this.isCellEditing,o=this.enableClipboard,l=this.clipboardOption,i=this.cellSelectionRangeData,r=this.tableData,n=this.colgroups,s=this.allRowKeys;if(!o)return!1;if(t)return!1;o=l||{},t=o.copy,l=o.beforeCopy,o=o.afterCopy;if((0,_index.isBoolean)(t)&&!t)return!1;e.preventDefault();t=(0,_common.getSelectionRangeData)({cellSelectionRangeData:i,resultType:"flat",tableData:r,colgroups:n,allRowKeys:s}),r=(0,_clipboard.onBeforeCopy)({cellSelectionRangeData:i,selectionRangeData:t,colgroups:n,allRowKeys:s});if((0,_index.isFunction)(l)){i=l(r);if((0,_index.isBoolean)(i)&&!i)return!1}(0,_clipboard.onAfterCopy)({event:e,selectionRangeData:t}),(0,_index.isFunction)(o)&&o(r)}),_defineProperty(_methods,"editorPaste",function(e){var t=this.isCellEditing,o=this.enableClipboard,l=this.clipboardOption;if(!o)return!1;if(t)return!1;o=l||{},t=o.paste,l=o.beforePaste,o=o.afterPaste;if((0,_index.isBoolean)(t)&&!t)return!1;e.preventDefault();t=(0,_clipboard.onBeforePaste)({event:e,cellSelectionRangeData:this.cellSelectionRangeData,colgroups:this.colgroups,allRowKeys:this.allRowKeys,rowKeyFieldName:this.rowKeyFieldName});if(t&&Array.isArray(t.data)&&t.data.length){if((0,_index.isFunction)(l)){e=l(t);if((0,_index.isBoolean)(e)&&!e)return!1}(0,_clipboard.onAfterPaste)({tableData:this.tableData,beforePasteResponse:t}),(0,_index.isFunction)(o)&&o(t);l=t.selectionRangeKeys,e=l.startColKey,o=l.endColKey,t=l.startRowKey,l=l.endRowKey;this.cellSelectionCurrentCellChange({rowKey:t,colKey:e}),this.cellSelectionNormalEndCellChange({rowKey:l,colKey:o})}}),_defineProperty(_methods,"setCellSelectionByAutofill",function(){var e=this.cellAutofillOption,t=this.cellSelectionRangeData,o=this.colgroups,l=this.allRowKeys,i=this.autofillingDirection,r=this.currentCellSelectionType,n=this.cellSelectionData,s=n.autoFillEndCell,n=n.currentCell,c=s.rowKey,a=s.colKey;if((0,_index.isEmptyValue)(c)||(0,_index.isEmptyValue)(a))return!1;var d={},h={},y=t.leftColKey,u=t.rightColKey,p=t.topRowKey,f=t.bottomRowKey;if(r===_constant2.CURRENT_CELL_SELECTION_TYPES.RANGE){if((0,_common.isCellInSelectionRange)({cellData:s,cellSelectionRangeData:t,colgroups:o,allRowKeys:l}))return!1;i===_constant2.AUTOFILLING_DIRECTION.RIGHT?(d={rowKey:p,colKey:y},h={rowKey:f,colKey:a}):i===_constant2.AUTOFILLING_DIRECTION.DOWN?(d={rowKey:p,colKey:y},h={rowKey:c,colKey:u}):i===_constant2.AUTOFILLING_DIRECTION.UP?(d={rowKey:c,colKey:y},h={rowKey:f,colKey:u}):i===_constant2.AUTOFILLING_DIRECTION.LEFT&&(d={rowKey:p,colKey:a},h={rowKey:f,colKey:u})}else if(r===_constant2.CURRENT_CELL_SELECTION_TYPES.SINGLE){if(n.rowKey===c&&n.colKey===a)return!1;i===_constant2.AUTOFILLING_DIRECTION.RIGHT?(d={rowKey:c,colKey:y},h={rowKey:c,colKey:a}):i===_constant2.AUTOFILLING_DIRECTION.DOWN?(d={rowKey:p,colKey:y},h={rowKey:c,colKey:y}):i===_constant2.AUTOFILLING_DIRECTION.UP?(d={rowKey:c,colKey:y},h={rowKey:f,colKey:y}):i===_constant2.AUTOFILLING_DIRECTION.LEFT&&(d={rowKey:c,colKey:a},h={rowKey:c,colKey:u})}s={tableData:this.tableData,allRowKeys:this.allRowKeys,colgroups:this.colgroups,rowKeyFieldName:this.rowKeyFieldName,direction:i,currentCellSelectionType:r,cellSelectionRangeData:t,nextCurrentCell:d,nextNormalEndCell:h};if(e){o=e.beforeAutofill,l=e.afterAutofill;if((0,_index.isFunction)(o)){n=o((0,_common.cellAutofill)(_objectSpread({isReplaceData:!1},s)));if((0,_index.isBoolean)(n)&&!n)return!1}p=(0,_common.cellAutofill)(_objectSpread({isReplaceData:!0},s));(0,_index.isFunction)(l)&&l(p)}(0,_index.isEmptyValue)(d.rowKey)||this.cellSelectionCurrentCellChange({rowKey:d.rowKey,colKey:d.colKey}),(0,_index.isEmptyValue)(h.rowKey)||this.cellSelectionNormalEndCellChange({rowKey:h.rowKey,colKey:h.colKey})}),_defineProperty(_methods,"editorCut",function(e){var t=this.isCellEditing,o=this.enableClipboard,l=this.clipboardOption,i=this.cellSelectionRangeData,r=this.tableData,n=this.colgroups,s=this.allRowKeys;if(!o)return!1;if(t)return!1;o=l||{},t=o.cut,l=o.beforeCut,o=o.afterCut;if((0,_index.isBoolean)(t)&&!t)return!1;e.preventDefault();t=(0,_common.getSelectionRangeData)({cellSelectionRangeData:i,resultType:"flat",tableData:r,colgroups:n,allRowKeys:s}),i=(0,_clipboard.onBeforeCut)({cellSelectionRangeData:i,selectionRangeData:t,colgroups:n,allRowKeys:s});if((0,_index.isFunction)(l)){s=l(i);if((0,_index.isBoolean)(s)&&!s)return!1}(0,_clipboard.onAfterCut)({event:e,tableData:r,colgroups:n,selectionRangeData:t,selectionRangeIndexes:i.selectionRangeIndexes}),(0,_index.isFunction)(o)&&o(i)}),_defineProperty(_methods,"getScrollBarWidth",function(){var e=0,t=this.scrollBarWidth;return t?e=t:(e=(0,_scrollBar.getScrollbarWidth)(),this.scrollBarWidth=e),e}),_defineProperty(_methods,"selectCellByDirection",function(e){var t,e=e.direction,o=this.colgroups,l=this.allRowKeys,i=this.cellSelectionData.currentCell,r=i.rowKey,n=i.colKey,i=o.findIndex(function(e){return e.key===n}),r=l.indexOf(r);e===_constant2.CELL_SELECTION_DIRECTION.LEFT?0<i&&(t=o[i-1],this.cellSelectionData.currentCell.colKey=t.key,this.columnToVisible(t)):e===_constant2.CELL_SELECTION_DIRECTION.RIGHT?i<o.length-1&&(t=o[i+1],this.cellSelectionData.currentCell.colKey=t.key,this.columnToVisible(t)):e===_constant2.CELL_SELECTION_DIRECTION.UP?0<r&&(o=l[r-1],this.rowToVisible(_constant.KEY_CODES.ARROW_UP,o)):e===_constant2.CELL_SELECTION_DIRECTION.DOWN&&r<l.length-1&&(i=l[r+1],this.rowToVisible(_constant.KEY_CODES.ARROW_DOWN,i))}),_defineProperty(_methods,"deleteCellSelectionRangeValue",function(){var e=this.isCellEditing,t=this.enableClipboard,o=this.clipboardOption,l=this.cellSelectionRangeData,i=this.tableData,r=this.colgroups,n=this.allRowKeys;if(!t)return!1;if(e)return!1;t=o||{},e=t.delete,o=t.beforeDelete,t=t.afterDelete;if((0,_index.isBoolean)(e)&&!e)return!1;e=(0,_common.getSelectionRangeData)({cellSelectionRangeData:l,resultType:"flat",tableData:i,colgroups:r,allRowKeys:n}),l=(0,_clipboard.onBeforeDelete)({cellSelectionRangeData:l,selectionRangeData:e,colgroups:r,allRowKeys:n});if((0,_index.isFunction)(o)){e=o(l);if((0,_index.isBoolean)(e)&&!e)return!1}(0,_clipboard.onAfterDelete)({tableData:i,colgroups:r,selectionRangeIndexes:l.selectionRangeIndexes}),(0,_index.isFunction)(t)&&t(l)}),_defineProperty(_methods,"dealKeydownEvent",function(e){this.colgroups;var t=this.cellSelectionData,o=(this.enableStopEditing,this.isCellEditing),l=e.keyCode,t=(e.ctrlKey,e.shiftKey,e.altKey,e.metaKey,t.currentCell),i=t.rowKey,t=t.colKey;(0,_index.isEmptyValue)(i)||(0,_index.isEmptyValue)(t)||l!==_constant.KEY_CODES.DELETE||o||(this.deleteCellSelectionRangeValue(),e.preventDefault())}),_methods),mounted:function(){document.addEventListener("keydown",this.dealKeydownEvent)},destroyed:function(){document.removeEventListener("keydown",this.dealKeydownEvent)}};exports.default=_default;