@vxe-ui/plugin-menu 3.0.4 → 3.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -50,9 +50,13 @@ VxeUI.use(VxeUIPluginMenu)
50
50
  | EDIT_CELL | 编辑选中单元格 | — |
51
51
  | EDIT_ROW | 编辑选中行并激活选中单元格 | — |
52
52
  | INSERT_ROW | 插入数据 | records |
53
+ | INSERT_NEXT_ROW | 插入数据 | records |
53
54
  | INSERT_EDIT_ROW | 插入数据并激活编辑状态 | Array\<records, field\> |
55
+ | INSERT_NEXT_EDIT_ROW | 插入数据并激活编辑状态 | Array\<records, field\> |
54
56
  | INSERT_AT_ROW | 插入数据到指定位置 | records |
57
+ | INSERT_NEXT_AT_ROW | 插入数据到指定位置 | records |
55
58
  | INSERT_AT_EDIT_ROW | 插入数据到指定位置并激活编辑状态 | Array\<records, field\> |
59
+ | INSERT_NEXT_AT_EDIT_ROW | 插入数据到指定位置并激活编辑状态 | Array\<records, field\> |
56
60
  | DELETE_ROW | 移除行数据 | — |
57
61
  | DELETE_AREA_ROW | 如果启用 mouse-config.area 功能,移除所选区域行数据;否则删除当前行 | — |
58
62
  | DELETE_CHECKBOX_ROW | 移除复选框选中行数据 | — |
@@ -352,7 +352,7 @@ var VxeUIPluginMenu = exports.VxeUIPluginMenu = {
352
352
  VxeUI = core;
353
353
  // 检查版本
354
354
  if (!/^(3)\./.test(VxeUI.uiVersion)) {
355
- console.error('[@vxe-ui/plugin-menu 3.0.4] Requires vxe-table 3.9.0+ version. https://vxeui.com/other3/#/plugin-export-xlsx/install');
355
+ console.error('[@vxe-ui/plugin-menu 3.0.5] Requires vxe-table 3.9.0+ version. https://vxeui.com/other3/#/plugin-export-xlsx/install');
356
356
  }
357
357
  pluginSetup(options);
358
358
  VxeUI.menus.mixin({
@@ -781,6 +781,19 @@ var VxeUIPluginMenu = exports.VxeUIPluginMenu = {
781
781
  }
782
782
  }
783
783
  },
784
+ /**
785
+ * 插入数据到指定位置
786
+ */
787
+ INSERT_NEXT_AT_ROW: {
788
+ menuMethod: function menuMethod(params) {
789
+ var $table = params.$table,
790
+ menu = params.menu,
791
+ row = params.row;
792
+ if (row) {
793
+ $table.insertNextAt(menu.params, row);
794
+ }
795
+ }
796
+ },
784
797
  /**
785
798
  * 插入数据到指定位置并激活编辑状态
786
799
  */
@@ -827,6 +840,29 @@ var VxeUIPluginMenu = exports.VxeUIPluginMenu = {
827
840
  }
828
841
  }
829
842
  },
843
+ /**
844
+ * 插入数据到指定位置并激活编辑状态
845
+ */
846
+ INSERT_NEXT_AT_EDIT_ROW: {
847
+ menuMethod: function menuMethod(params) {
848
+ var $table = params.$table,
849
+ menu = params.menu,
850
+ row = params.row,
851
+ column = params.column;
852
+ if (row) {
853
+ var args = menu.params || []; // [{}, 'field']
854
+ $table.insertNextAt(args[0], row).then(function (_ref11) {
855
+ var row = _ref11.row;
856
+ if ($table.setEditCell) {
857
+ $table.setEditCell(row, args[1] || column);
858
+ } else {
859
+ // 兼容老版本
860
+ $table.setActiveCell(row, args[1] || column.field);
861
+ }
862
+ });
863
+ }
864
+ }
865
+ },
830
866
  /**
831
867
  * 移除行数据
832
868
  */
package/dist/index.umd.js CHANGED
@@ -365,7 +365,7 @@
365
365
  VxeUI = core;
366
366
  // 检查版本
367
367
  if (!/^(3)\./.test(VxeUI.uiVersion)) {
368
- console.error('[@vxe-ui/plugin-menu 3.0.4] Requires vxe-table 3.9.0+ version. https://vxeui.com/other3/#/plugin-export-xlsx/install');
368
+ console.error('[@vxe-ui/plugin-menu 3.0.5] Requires vxe-table 3.9.0+ version. https://vxeui.com/other3/#/plugin-export-xlsx/install');
369
369
  }
370
370
  pluginSetup(options);
371
371
  VxeUI.menus.mixin({
@@ -794,6 +794,19 @@
794
794
  }
795
795
  }
796
796
  },
797
+ /**
798
+ * 插入数据到指定位置
799
+ */
800
+ INSERT_NEXT_AT_ROW: {
801
+ menuMethod: function menuMethod(params) {
802
+ var $table = params.$table,
803
+ menu = params.menu,
804
+ row = params.row;
805
+ if (row) {
806
+ $table.insertNextAt(menu.params, row);
807
+ }
808
+ }
809
+ },
797
810
  /**
798
811
  * 插入数据到指定位置并激活编辑状态
799
812
  */
@@ -840,6 +853,29 @@
840
853
  }
841
854
  }
842
855
  },
856
+ /**
857
+ * 插入数据到指定位置并激活编辑状态
858
+ */
859
+ INSERT_NEXT_AT_EDIT_ROW: {
860
+ menuMethod: function menuMethod(params) {
861
+ var $table = params.$table,
862
+ menu = params.menu,
863
+ row = params.row,
864
+ column = params.column;
865
+ if (row) {
866
+ var args = menu.params || []; // [{}, 'field']
867
+ $table.insertNextAt(args[0], row).then(function (_ref11) {
868
+ var row = _ref11.row;
869
+ if ($table.setEditCell) {
870
+ $table.setEditCell(row, args[1] || column);
871
+ } else {
872
+ // 兼容老版本
873
+ $table.setActiveCell(row, args[1] || column.field);
874
+ }
875
+ });
876
+ }
877
+ }
878
+ },
843
879
  /**
844
880
  * 移除行数据
845
881
  */
@@ -1 +1 @@
1
- ((e,t)=>{"function"==typeof define&&define.amd?define("@vxe-ui/plugin-menu",["exports","xe-utils"],t):"undefined"!=typeof exports?t(exports,require("xe-utils")):(t(t={},e.XEUtils),e.VxeUIPluginMenu=t)})("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:this,function(e,s){var u,c;Object.defineProperty(e,"__esModule",{value:!0}),e.default=e.VxeUIPluginMenu=void 0,s=(t=s)&&t.__esModule?t:{default:t};var a,L=function(e,t){return s.default.findIndexOf(e,function(e){return e.id===t.id})},h=function(e,t,n){return e.findRowIndexOf(t,n)};function n(n){return{menuMethod:function(e){var t=e.$table;s.default.eachTree([e.column],function(e){e.fixed=n}),t.refreshColumn()}}}function C(){var e=u.globalStore;return e?e.clipboard||"":(e=u.config)&&e.clipboard?e.clipboard:null}function E(e){var t,n;try{t=e,a||((a=document.createElement("textarea")).id="$XECopy",(n=a.style).width="48px",n.height="24px",n.position="fixed",n.zIndex="0",n.left="-500px",n.top="-500px",document.body.appendChild(a)),a.value=null==t?"":""+t,a.select(),a.setSelectionRange(0,a.value.length),document.execCommand("copy"),a.blur()}catch(e){}}function o(e,t){var n,a,o,r=e.$event,l=e.$table,i=e.row,e=e.column;i&&e&&(n=l.mouseConfig,o=l.computeMouseOpts,a="",n&&o.area?(t?l.triggerCutCellAreaEvent(r):l.triggerCopyCellAreaEvent(r),a=(n=C())?n.text:""):(a=s.default.toValueString(s.default.get(i,e.field)),o={text:a,html:""},(t=u.globalStore)?t.clipboard=o:u.config&&(u.config.clipboard=o)),(s.default.isFunction(c)?c:E)(a))}function m(e){var s=e.$table,e=s.mouseConfig,t=s.computeMouseOpts,u=s.getTableData().visibleData,c=s.getTableColumn().visibleColumn,n=e&&t.area?s.getCellAreas():[];return s.getMergeCells().filter(function(e){var o=e.row,r=e.col,l=e.rowspan,i=e.colspan;return n.some(function(e){var t=e.rows,e=e.cols,n=h(s,u,t[0]),t=h(s,u,t[t.length-1]),a=L(c,e[0]),e=L(c,e[e.length-1]);return n<=o&&o+l-1<=t&&a<=r&&r+i-1<=e})})}function l(e){var t=e.$table,e=m(e);return e.length&&t.removeMergeCells(e),e}function r(e,t){var n=e.code,a=t.$table,o=t.row,r=t.column,l=t.type,i=a.editConfig,s=a.mouseConfig;switch(n){case"CLEAR_ALL_SORT":var u=a.getSortColumns();e.disabled=!u.length;break;case"CLEAR_ALL_FILTER":u=a.getCheckedFilters();e.disabled=!u.length;break;case"CLEAR_ALL_MERGE":var u=a.getMergeCells(),c=a.getMergeFooterItems();e.disabled=!u.length&&!c.length;break;case"CLEAR_MERGE_CELL":u=m(t);e.disabled=!u.length;break;case"COPY_TITLE":e.disabled=!r||"header"!==l;break;case"EDIT_CELL":case"CLEAR_CELL":case"CLEAR_ROW":case"COPY_CELL":case"CUT_CELL":case"PASTE_CELL":case"MERGE_OR_CLEAR":case"MERGE_CELL":case"REVERT_CELL":case"REVERT_ROW":case"INSERT_AT_ROW":case"INSERT_AT_ACTIVED_ROW":case"INSERT_AT_EDIT_ROW":case"DELETE_ROW":case"DELETE_AREA_ROW":case"CLEAR_SORT":case"SORT_ASC":case"SORT_DESC":case"CLEAR_FILTER":case"FILTER_CELL":case"EXPORT_ROW":case"OPEN_FIND":case"OPEN_REPLACE":case"HIDDEN_COLUMN":case"FIXED_LEFT_COLUMN":case"FIXED_RIGHT_COLUMN":case"CLEAR_FIXED_COLUMN":if(e.disabled=!r,r){var E=a.computeMouseOpts,d=!!r.parentId;switch(n){case"CLEAR_SORT":e.disabled=!r.sortable||!r.order;break;case"SORT_ASC":case"SORT_DESC":e.disabled=!r.sortable;break;case"FILTER_CELL":case"CLEAR_FILTER":e.disabled=!r.filters||!r.filters.length,e.disabled||"CLEAR_FILTER"===n&&(e.disabled=!r.filters.some(function(e){return e.checked}));break;case"REVERT_CELL":e.disabled=!o||!r.field||!a.isUpdateByRow(o,r.field);break;case"REVERT_ROW":e.disabled=!o||!r.field||!a.isUpdateByRow(o);break;case"OPEN_FIND":case"OPEN_REPLACE":e.disabled=!(s&&E.area);break;case"EDIT_CELL":e.disabled=!i||!r.editRender;break;case"COPY_CELL":case"CUT_CELL":case"PASTE_CELL":var f=s&&E.area?a.getCellAreas():[];e.disabled=1<f.length,e.disabled||"PASTE_CELL"===n&&(f=C(),e.disabled=!f||!f.text);break;case"MERGE_OR_CLEAR":case"MERGE_CELL":f=s&&E.area?a.getCellAreas():[];e.disabled=!f.length||1===f.length&&1===f[0].rows.length&&1===f[0].cols.length||!((e,t)=>{for(var n=e.$table,a=n.getTableData().visibleData,o=n.getTableColumn().visibleColumn,r={},l=0,i=t.length;l<i;l++)for(var s=t[l],u=s.rows,c=s.cols,E=0,d=u.length;E<d;E++)for(var f=u[E],C=h(n,a,f),m=0,R=c.length;m<R;m++){var _=c[m],_=C+":"+L(o,_);if(r[_])return;r[_]=!0}return 1})(t,f);break;case"FIXED_LEFT_COLUMN":e.disabled=d||"left"===r.fixed;break;case"FIXED_RIGHT_COLUMN":e.disabled=d||"right"===r.fixed;break;case"CLEAR_FIXED_COLUMN":e.disabled=d||!r.fixed}}}}function i(t){return t.options.forEach(function(e){e.forEach(function(e){r(e,t),e.children&&e.children.forEach(function(e){r(e,t)})})}),!0}function d(e){e&&e.copy&&(c=e.copy)}var t=e.VxeUIPluginMenu={setConfig:d,install:function(e,t){u=e,/^(3)\./.test(u.uiVersion)||console.error("[@vxe-ui/plugin-menu 3.0.4] Requires vxe-table 3.9.0+ version. https://vxeui.com/other3/#/plugin-export-xlsx/install"),d(t),u.menus.mixin({CLEAR_CELL:{menuMethod:function(e){var t,n,a=e.$table,o=e.row,e=e.column;o&&e&&(n=a.mouseConfig,t=a.computeMouseOpts,n&&t.area?(n=a.getCellAreas())&&n.length&&n.forEach(function(e){var n=e.rows;e.cols.forEach(function(t){n.forEach(function(e){a.clearData(e,t.field)})})}):a.clearData(o,e.field))}},CLEAR_ROW:{menuMethod:function(e){var t=e.$table,e=e.row;e&&t.clearData(e)}},CLEAR_CHECKBOX_ROW:{menuMethod:function(e){e=e.$table;e.clearData(e.getCheckboxRecords())}},CLEAR_AREA_ROW:{menuMethod:function(e){var a=e.$table,t=e.row,e=e.column,n=a.mouseConfig,o=a.computeMouseOpts;n&&o.area?(n&&o.area?a.getCellAreas():[]).forEach(function(e){var t=e.rows,n=e.cols;t.forEach(function(t){n.forEach(function(e){a.clearData(t)})})}):t&&e&&a.clearData(t)}},CLEAR_ALL:{menuMethod:function(e){e.$table.clearData()}},REVERT_CELL:{menuMethod:function(e){var t,n,a=e.$table,o=e.row,e=e.column;o&&e&&(n=a.mouseConfig,t=a.computeMouseOpts,n&&t.area?(n=a.getCellAreas())&&n.length&&n.forEach(function(e){var n=e.rows;e.cols.forEach(function(t){n.forEach(function(e){a.revertData(e,t.field)})})}):a.revertData(o,e.field))}},REVERT_ROW:{menuMethod:function(e){var t=e.$table,e=e.row;e&&t.revertData(e)}},REVERT_CHECKBOX_ROW:{menuMethod:function(e){e=e.$table;e.revertData(e.getCheckboxRecords())}},REVERT_ALL:{menuMethod:function(e){e.$table.revertData()}},COPY_TITLE:{menuMethod:function(e){e=e.column.getTitle();e&&(s.default.isFunction(c)?c:E)(e)}},COPY_CELL:{menuMethod:function(e){o(e)}},CUT_CELL:{menuMethod:function(e){o(e,!0)}},PASTE_CELL:{menuMethod:function(e){var t=e.$event,n=e.$table,a=e.row,e=e.column,o=n.mouseConfig,r=n.computeMouseOpts;o&&r.area?n.triggerPasteCellAreaEvent(t):(o=C())&&o.text&&s.default.set(a,e.field,o.text)}},MERGE_OR_CLEAR:{menuMethod:function(e){var t=e.$event,n=e.$table,a=n.getCellAreas(),e=m(e),o=!1,e=(e.length?n.removeMergeCells(e):(o=!0,n.setMergeCells(a.map(function(e){var t=e.rows,e=e.cols;return{row:t[0],col:e[0],rowspan:t.length,colspan:e.length}}))),a.map(function(e){return{rows:e.rows,cols:e.cols}}));n.dispatchEvent("cell-area-merge",{status:o,targetAreas:e},t)}},MERGE_CELL:{menuMethod:function(e){var t=e.$event,n=e.$table,a=n.getTableData().visibleData,o=n.getTableColumn().visibleColumn,r=n.getCellAreas();l(e),r.some(function(e){return e.rows.length===a.length||e.cols.length===o.length})?u.modal&&u.modal.message({content:u.getI18n("vxe.pro.area.mergeErr"),status:"error",id:"operErr"}):(n.setMergeCells(r.map(function(e){var t=e.rows,e=e.cols;return{row:t[0],col:e[0],rowspan:t.length,colspan:e.length}})),e=r.map(function(e){return{rows:e.rows,cols:e.cols}}),n.dispatchEvent("cell-area-merge",{status:!0,targetAreas:e},t))}},CLEAR_MERGE_CELL:{menuMethod:function(e){var t=e.$event,n=e.$table,e=l(e);e.length&&n.dispatchEvent("clear-cell-area-merge",{mergeCells:e},t)}},CLEAR_ALL_MERGE:{menuMethod:function(e){var t=e.$event,e=e.$table,n=e.getMergeCells(),a=e.getMergeFooterItems();e.clearMergeCells(),e.clearMergeFooterItems(),e.dispatchEvent("clear-merge",{mergeCells:n,mergeFooterItems:a},t)}},EDIT_CELL:{menuMethod:function(e){var t=e.$table,n=e.row,e=e.column;t.setEditCell?t.setEditCell(n,e):t.setActiveCell(n,e.field)}},EDIT_ROW:{menuMethod:function(e){var t=e.$table,e=e.row;t.setEditRow?t.setEditRow(e):t.setActiveRow(e)}},INSERT_ROW:{menuMethod:function(e){e.$table.insert(e.menu.params)}},INSERT_ACTIVED_ROW:{menuMethod:function(e){var t=e.$table,n=e.column,a=e.menu.params||[];t.insert(a[0]).then(function(e){e=e.row;t.setEditCell?t.setEditCell(e,a[1]||n):t.setActiveCell(e,a[1]||n.field)})}},INSERT_EDIT_ROW:{menuMethod:function(e){var t=e.$table,n=e.column,a=e.menu.params||[];t.insert(a[0]).then(function(e){e=e.row;t.setEditCell?t.setEditCell(e,a[1]||n):t.setActiveCell(e,a[1]||n.field)})}},INSERT_AT_ROW:{menuMethod:function(e){var t=e.$table,n=e.row;n&&t.insertAt(e.menu.params,n)}},INSERT_AT_ACTIVED_ROW:{menuMethod:function(e){var t,n=e.$table,a=e.row,o=e.column;a&&(t=e.menu.params||[],n.insertAt(t[0],a).then(function(e){e=e.row;n.setEditCell?n.setEditCell(e,t[1]||o):n.setActiveCell(e,t[1]||o.field)}))}},INSERT_AT_EDIT_ROW:{menuMethod:function(e){var t,n=e.$table,a=e.row,o=e.column;a&&(t=e.menu.params||[],n.insertAt(t[0],a).then(function(e){e=e.row;n.setEditCell?n.setEditCell(e,t[1]||o):n.setActiveCell(e,t[1]||o.field)}))}},DELETE_ROW:{menuMethod:function(e){var t=e.$table,e=e.row;e&&t.remove(e)}},DELETE_AREA_ROW:{menuMethod:function(e){var t=e.$table,e=e.row,n=t.mouseConfig,a=t.computeMouseOpts;n&&a.area?(n&&a.area?t.getCellAreas():[]).forEach(function(e){e=e.rows;t.remove(e)}):e&&t.remove(e)}},DELETE_CHECKBOX_ROW:{menuMethod:function(e){e.$table.removeCheckboxRow()}},DELETE_ALL:{menuMethod:function(e){e.$table.remove()}},CLEAR_SORT:{menuMethod:function(e){var t=e.$event,n=e.$table,e=e.column;e&&n.triggerSortEvent(t,e,null)}},CLEAR_ALL_SORT:{menuMethod:function(e){var t=e.$event,e=e.$table,n=e.getSortColumns();n.length&&(e.clearSort(),e.dispatchEvent("clear-sort",{sortList:n},t))}},SORT_ASC:{menuMethod:function(e){var t=e.$event,n=e.$table,e=e.column;e&&n.triggerSortEvent(t,e,"asc")}},SORT_DESC:{menuMethod:function(e){var t=e.$event,n=e.$table,e=e.column;e&&n.triggerSortEvent(t,e,"desc")}},CLEAR_FILTER:{menuMethod:function(e){var t=e.$event,n=e.$table,e=e.column;e&&(n.handleClearFilter(e),n.confirmFilterEvent(t))}},CLEAR_ALL_FILTER:{menuMethod:function(e){var t=e.$event,e=e.$table,n=e.getCheckedFilters();n.length&&(e.clearFilter(),e.dispatchEvent("clear-filter",{filterList:n},t))}},FILTER_CELL:{menuMethod:function(e){var t,n=e.$table,a=e.row,e=e.column;a&&e&&(t=e.field,(e=e.filters).length)&&((e=e[0]).data=s.default.get(a,t),e.checked=!0,n.updateData())}},EXPORT_ROW:{menuMethod:function(e){var t=e.$table,n=e.menu,e=e.row;e&&t.exportData(s.default.assign({},n.params?n.params[0]:{},{data:[e]}))}},EXPORT_CHECKBOX_ROW:{menuMethod:function(e){var t=e.$table,e=e.menu,n={data:t.getCheckboxRecords()};t.exportData(s.default.assign({},e.params?e.params[0]:{},n))}},EXPORT_ALL:{menuMethod:function(e){e.$table.exportData(e.menu.params)}},PRINT_ALL:{menuMethod:function(e){e.$table.print(e.menu.params)}},PRINT_CHECKBOX_ROW:{menuMethod:function(e){var t=e.$table,e=e.menu,n={data:t.getCheckboxRecords()};t.print(s.default.assign(n,e.params))}},OPEN_FIND:{menuMethod:function(e){var t=e.$event;e.$table.triggerFNROpenEvent(t,"find")}},OPEN_REPLACE:{menuMethod:function(e){var t=e.$event;e.$table.triggerFNROpenEvent(t,"replace")}},HIDDEN_COLUMN:{menuMethod:function(e){var t=e.$table,e=e.column;e&&t.hideColumn(e)}},FIXED_LEFT_COLUMN:n("left"),FIXED_RIGHT_COLUMN:n("right"),CLEAR_FIXED_COLUMN:n(null),RESET_COLUMN:{menuMethod:function(e){e.$table.resetColumn({visible:!0,resizable:!1})}},RESET_RESIZABLE:{menuMethod:function(e){e.$table.resetColumn({visible:!1,resizable:!0})}},RESET_ALL:{menuMethod:function(e){e.$table.resetColumn(!0)}}}),u.interceptor.add("event.showMenu",i)}};"undefined"!=typeof window&&window.VxeUI&&window.VxeUI.use&&window.VxeUI.use(t),e.default=t});
1
+ ((e,t)=>{"function"==typeof define&&define.amd?define("@vxe-ui/plugin-menu",["exports","xe-utils"],t):"undefined"!=typeof exports?t(exports,require("xe-utils")):(t(t={},e.XEUtils),e.VxeUIPluginMenu=t)})("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:this,function(e,s){var u,c;Object.defineProperty(e,"__esModule",{value:!0}),e.default=e.VxeUIPluginMenu=void 0,s=(t=s)&&t.__esModule?t:{default:t};var a,L=function(e,t){return s.default.findIndexOf(e,function(e){return e.id===t.id})},h=function(e,t,n){return e.findRowIndexOf(t,n)};function n(n){return{menuMethod:function(e){var t=e.$table;s.default.eachTree([e.column],function(e){e.fixed=n}),t.refreshColumn()}}}function C(){var e=u.globalStore;return e?e.clipboard||"":(e=u.config)&&e.clipboard?e.clipboard:null}function E(e){var t,n;try{t=e,a||((a=document.createElement("textarea")).id="$XECopy",(n=a.style).width="48px",n.height="24px",n.position="fixed",n.zIndex="0",n.left="-500px",n.top="-500px",document.body.appendChild(a)),a.value=null==t?"":""+t,a.select(),a.setSelectionRange(0,a.value.length),document.execCommand("copy"),a.blur()}catch(e){}}function o(e,t){var n,a,o,r=e.$event,l=e.$table,i=e.row,e=e.column;i&&e&&(n=l.mouseConfig,o=l.computeMouseOpts,a="",n&&o.area?(t?l.triggerCutCellAreaEvent(r):l.triggerCopyCellAreaEvent(r),a=(n=C())?n.text:""):(a=s.default.toValueString(s.default.get(i,e.field)),o={text:a,html:""},(t=u.globalStore)?t.clipboard=o:u.config&&(u.config.clipboard=o)),(s.default.isFunction(c)?c:E)(a))}function m(e){var s=e.$table,e=s.mouseConfig,t=s.computeMouseOpts,u=s.getTableData().visibleData,c=s.getTableColumn().visibleColumn,n=e&&t.area?s.getCellAreas():[];return s.getMergeCells().filter(function(e){var o=e.row,r=e.col,l=e.rowspan,i=e.colspan;return n.some(function(e){var t=e.rows,e=e.cols,n=h(s,u,t[0]),t=h(s,u,t[t.length-1]),a=L(c,e[0]),e=L(c,e[e.length-1]);return n<=o&&o+l-1<=t&&a<=r&&r+i-1<=e})})}function l(e){var t=e.$table,e=m(e);return e.length&&t.removeMergeCells(e),e}function r(e,t){var n=e.code,a=t.$table,o=t.row,r=t.column,l=t.type,i=a.editConfig,s=a.mouseConfig;switch(n){case"CLEAR_ALL_SORT":var u=a.getSortColumns();e.disabled=!u.length;break;case"CLEAR_ALL_FILTER":u=a.getCheckedFilters();e.disabled=!u.length;break;case"CLEAR_ALL_MERGE":var u=a.getMergeCells(),c=a.getMergeFooterItems();e.disabled=!u.length&&!c.length;break;case"CLEAR_MERGE_CELL":u=m(t);e.disabled=!u.length;break;case"COPY_TITLE":e.disabled=!r||"header"!==l;break;case"EDIT_CELL":case"CLEAR_CELL":case"CLEAR_ROW":case"COPY_CELL":case"CUT_CELL":case"PASTE_CELL":case"MERGE_OR_CLEAR":case"MERGE_CELL":case"REVERT_CELL":case"REVERT_ROW":case"INSERT_AT_ROW":case"INSERT_AT_ACTIVED_ROW":case"INSERT_AT_EDIT_ROW":case"DELETE_ROW":case"DELETE_AREA_ROW":case"CLEAR_SORT":case"SORT_ASC":case"SORT_DESC":case"CLEAR_FILTER":case"FILTER_CELL":case"EXPORT_ROW":case"OPEN_FIND":case"OPEN_REPLACE":case"HIDDEN_COLUMN":case"FIXED_LEFT_COLUMN":case"FIXED_RIGHT_COLUMN":case"CLEAR_FIXED_COLUMN":if(e.disabled=!r,r){var E=a.computeMouseOpts,d=!!r.parentId;switch(n){case"CLEAR_SORT":e.disabled=!r.sortable||!r.order;break;case"SORT_ASC":case"SORT_DESC":e.disabled=!r.sortable;break;case"FILTER_CELL":case"CLEAR_FILTER":e.disabled=!r.filters||!r.filters.length,e.disabled||"CLEAR_FILTER"===n&&(e.disabled=!r.filters.some(function(e){return e.checked}));break;case"REVERT_CELL":e.disabled=!o||!r.field||!a.isUpdateByRow(o,r.field);break;case"REVERT_ROW":e.disabled=!o||!r.field||!a.isUpdateByRow(o);break;case"OPEN_FIND":case"OPEN_REPLACE":e.disabled=!(s&&E.area);break;case"EDIT_CELL":e.disabled=!i||!r.editRender;break;case"COPY_CELL":case"CUT_CELL":case"PASTE_CELL":var f=s&&E.area?a.getCellAreas():[];e.disabled=1<f.length,e.disabled||"PASTE_CELL"===n&&(f=C(),e.disabled=!f||!f.text);break;case"MERGE_OR_CLEAR":case"MERGE_CELL":f=s&&E.area?a.getCellAreas():[];e.disabled=!f.length||1===f.length&&1===f[0].rows.length&&1===f[0].cols.length||!((e,t)=>{for(var n=e.$table,a=n.getTableData().visibleData,o=n.getTableColumn().visibleColumn,r={},l=0,i=t.length;l<i;l++)for(var s=t[l],u=s.rows,c=s.cols,E=0,d=u.length;E<d;E++)for(var f=u[E],C=h(n,a,f),m=0,_=c.length;m<_;m++){var R=c[m],R=C+":"+L(o,R);if(r[R])return;r[R]=!0}return 1})(t,f);break;case"FIXED_LEFT_COLUMN":e.disabled=d||"left"===r.fixed;break;case"FIXED_RIGHT_COLUMN":e.disabled=d||"right"===r.fixed;break;case"CLEAR_FIXED_COLUMN":e.disabled=d||!r.fixed}}}}function i(t){return t.options.forEach(function(e){e.forEach(function(e){r(e,t),e.children&&e.children.forEach(function(e){r(e,t)})})}),!0}function d(e){e&&e.copy&&(c=e.copy)}var t=e.VxeUIPluginMenu={setConfig:d,install:function(e,t){u=e,/^(3)\./.test(u.uiVersion)||console.error("[@vxe-ui/plugin-menu 3.0.5] Requires vxe-table 3.9.0+ version. https://vxeui.com/other3/#/plugin-export-xlsx/install"),d(t),u.menus.mixin({CLEAR_CELL:{menuMethod:function(e){var t,n,a=e.$table,o=e.row,e=e.column;o&&e&&(n=a.mouseConfig,t=a.computeMouseOpts,n&&t.area?(n=a.getCellAreas())&&n.length&&n.forEach(function(e){var n=e.rows;e.cols.forEach(function(t){n.forEach(function(e){a.clearData(e,t.field)})})}):a.clearData(o,e.field))}},CLEAR_ROW:{menuMethod:function(e){var t=e.$table,e=e.row;e&&t.clearData(e)}},CLEAR_CHECKBOX_ROW:{menuMethod:function(e){e=e.$table;e.clearData(e.getCheckboxRecords())}},CLEAR_AREA_ROW:{menuMethod:function(e){var a=e.$table,t=e.row,e=e.column,n=a.mouseConfig,o=a.computeMouseOpts;n&&o.area?(n&&o.area?a.getCellAreas():[]).forEach(function(e){var t=e.rows,n=e.cols;t.forEach(function(t){n.forEach(function(e){a.clearData(t)})})}):t&&e&&a.clearData(t)}},CLEAR_ALL:{menuMethod:function(e){e.$table.clearData()}},REVERT_CELL:{menuMethod:function(e){var t,n,a=e.$table,o=e.row,e=e.column;o&&e&&(n=a.mouseConfig,t=a.computeMouseOpts,n&&t.area?(n=a.getCellAreas())&&n.length&&n.forEach(function(e){var n=e.rows;e.cols.forEach(function(t){n.forEach(function(e){a.revertData(e,t.field)})})}):a.revertData(o,e.field))}},REVERT_ROW:{menuMethod:function(e){var t=e.$table,e=e.row;e&&t.revertData(e)}},REVERT_CHECKBOX_ROW:{menuMethod:function(e){e=e.$table;e.revertData(e.getCheckboxRecords())}},REVERT_ALL:{menuMethod:function(e){e.$table.revertData()}},COPY_TITLE:{menuMethod:function(e){e=e.column.getTitle();e&&(s.default.isFunction(c)?c:E)(e)}},COPY_CELL:{menuMethod:function(e){o(e)}},CUT_CELL:{menuMethod:function(e){o(e,!0)}},PASTE_CELL:{menuMethod:function(e){var t=e.$event,n=e.$table,a=e.row,e=e.column,o=n.mouseConfig,r=n.computeMouseOpts;o&&r.area?n.triggerPasteCellAreaEvent(t):(o=C())&&o.text&&s.default.set(a,e.field,o.text)}},MERGE_OR_CLEAR:{menuMethod:function(e){var t=e.$event,n=e.$table,a=n.getCellAreas(),e=m(e),o=!1,e=(e.length?n.removeMergeCells(e):(o=!0,n.setMergeCells(a.map(function(e){var t=e.rows,e=e.cols;return{row:t[0],col:e[0],rowspan:t.length,colspan:e.length}}))),a.map(function(e){return{rows:e.rows,cols:e.cols}}));n.dispatchEvent("cell-area-merge",{status:o,targetAreas:e},t)}},MERGE_CELL:{menuMethod:function(e){var t=e.$event,n=e.$table,a=n.getTableData().visibleData,o=n.getTableColumn().visibleColumn,r=n.getCellAreas();l(e),r.some(function(e){return e.rows.length===a.length||e.cols.length===o.length})?u.modal&&u.modal.message({content:u.getI18n("vxe.pro.area.mergeErr"),status:"error",id:"operErr"}):(n.setMergeCells(r.map(function(e){var t=e.rows,e=e.cols;return{row:t[0],col:e[0],rowspan:t.length,colspan:e.length}})),e=r.map(function(e){return{rows:e.rows,cols:e.cols}}),n.dispatchEvent("cell-area-merge",{status:!0,targetAreas:e},t))}},CLEAR_MERGE_CELL:{menuMethod:function(e){var t=e.$event,n=e.$table,e=l(e);e.length&&n.dispatchEvent("clear-cell-area-merge",{mergeCells:e},t)}},CLEAR_ALL_MERGE:{menuMethod:function(e){var t=e.$event,e=e.$table,n=e.getMergeCells(),a=e.getMergeFooterItems();e.clearMergeCells(),e.clearMergeFooterItems(),e.dispatchEvent("clear-merge",{mergeCells:n,mergeFooterItems:a},t)}},EDIT_CELL:{menuMethod:function(e){var t=e.$table,n=e.row,e=e.column;t.setEditCell?t.setEditCell(n,e):t.setActiveCell(n,e.field)}},EDIT_ROW:{menuMethod:function(e){var t=e.$table,e=e.row;t.setEditRow?t.setEditRow(e):t.setActiveRow(e)}},INSERT_ROW:{menuMethod:function(e){e.$table.insert(e.menu.params)}},INSERT_ACTIVED_ROW:{menuMethod:function(e){var t=e.$table,n=e.column,a=e.menu.params||[];t.insert(a[0]).then(function(e){e=e.row;t.setEditCell?t.setEditCell(e,a[1]||n):t.setActiveCell(e,a[1]||n.field)})}},INSERT_EDIT_ROW:{menuMethod:function(e){var t=e.$table,n=e.column,a=e.menu.params||[];t.insert(a[0]).then(function(e){e=e.row;t.setEditCell?t.setEditCell(e,a[1]||n):t.setActiveCell(e,a[1]||n.field)})}},INSERT_AT_ROW:{menuMethod:function(e){var t=e.$table,n=e.row;n&&t.insertAt(e.menu.params,n)}},INSERT_NEXT_AT_ROW:{menuMethod:function(e){var t=e.$table,n=e.row;n&&t.insertNextAt(e.menu.params,n)}},INSERT_AT_ACTIVED_ROW:{menuMethod:function(e){var t,n=e.$table,a=e.row,o=e.column;a&&(t=e.menu.params||[],n.insertAt(t[0],a).then(function(e){e=e.row;n.setEditCell?n.setEditCell(e,t[1]||o):n.setActiveCell(e,t[1]||o.field)}))}},INSERT_AT_EDIT_ROW:{menuMethod:function(e){var t,n=e.$table,a=e.row,o=e.column;a&&(t=e.menu.params||[],n.insertAt(t[0],a).then(function(e){e=e.row;n.setEditCell?n.setEditCell(e,t[1]||o):n.setActiveCell(e,t[1]||o.field)}))}},INSERT_NEXT_AT_EDIT_ROW:{menuMethod:function(e){var t,n=e.$table,a=e.row,o=e.column;a&&(t=e.menu.params||[],n.insertNextAt(t[0],a).then(function(e){e=e.row;n.setEditCell?n.setEditCell(e,t[1]||o):n.setActiveCell(e,t[1]||o.field)}))}},DELETE_ROW:{menuMethod:function(e){var t=e.$table,e=e.row;e&&t.remove(e)}},DELETE_AREA_ROW:{menuMethod:function(e){var t=e.$table,e=e.row,n=t.mouseConfig,a=t.computeMouseOpts;n&&a.area?(n&&a.area?t.getCellAreas():[]).forEach(function(e){e=e.rows;t.remove(e)}):e&&t.remove(e)}},DELETE_CHECKBOX_ROW:{menuMethod:function(e){e.$table.removeCheckboxRow()}},DELETE_ALL:{menuMethod:function(e){e.$table.remove()}},CLEAR_SORT:{menuMethod:function(e){var t=e.$event,n=e.$table,e=e.column;e&&n.triggerSortEvent(t,e,null)}},CLEAR_ALL_SORT:{menuMethod:function(e){var t=e.$event,e=e.$table,n=e.getSortColumns();n.length&&(e.clearSort(),e.dispatchEvent("clear-sort",{sortList:n},t))}},SORT_ASC:{menuMethod:function(e){var t=e.$event,n=e.$table,e=e.column;e&&n.triggerSortEvent(t,e,"asc")}},SORT_DESC:{menuMethod:function(e){var t=e.$event,n=e.$table,e=e.column;e&&n.triggerSortEvent(t,e,"desc")}},CLEAR_FILTER:{menuMethod:function(e){var t=e.$event,n=e.$table,e=e.column;e&&(n.handleClearFilter(e),n.confirmFilterEvent(t))}},CLEAR_ALL_FILTER:{menuMethod:function(e){var t=e.$event,e=e.$table,n=e.getCheckedFilters();n.length&&(e.clearFilter(),e.dispatchEvent("clear-filter",{filterList:n},t))}},FILTER_CELL:{menuMethod:function(e){var t,n=e.$table,a=e.row,e=e.column;a&&e&&(t=e.field,(e=e.filters).length)&&((e=e[0]).data=s.default.get(a,t),e.checked=!0,n.updateData())}},EXPORT_ROW:{menuMethod:function(e){var t=e.$table,n=e.menu,e=e.row;e&&t.exportData(s.default.assign({},n.params?n.params[0]:{},{data:[e]}))}},EXPORT_CHECKBOX_ROW:{menuMethod:function(e){var t=e.$table,e=e.menu,n={data:t.getCheckboxRecords()};t.exportData(s.default.assign({},e.params?e.params[0]:{},n))}},EXPORT_ALL:{menuMethod:function(e){e.$table.exportData(e.menu.params)}},PRINT_ALL:{menuMethod:function(e){e.$table.print(e.menu.params)}},PRINT_CHECKBOX_ROW:{menuMethod:function(e){var t=e.$table,e=e.menu,n={data:t.getCheckboxRecords()};t.print(s.default.assign(n,e.params))}},OPEN_FIND:{menuMethod:function(e){var t=e.$event;e.$table.triggerFNROpenEvent(t,"find")}},OPEN_REPLACE:{menuMethod:function(e){var t=e.$event;e.$table.triggerFNROpenEvent(t,"replace")}},HIDDEN_COLUMN:{menuMethod:function(e){var t=e.$table,e=e.column;e&&t.hideColumn(e)}},FIXED_LEFT_COLUMN:n("left"),FIXED_RIGHT_COLUMN:n("right"),CLEAR_FIXED_COLUMN:n(null),RESET_COLUMN:{menuMethod:function(e){e.$table.resetColumn({visible:!0,resizable:!1})}},RESET_RESIZABLE:{menuMethod:function(e){e.$table.resetColumn({visible:!1,resizable:!0})}},RESET_ALL:{menuMethod:function(e){e.$table.resetColumn(!0)}}}),u.interceptor.add("event.showMenu",i)}};"undefined"!=typeof window&&window.VxeUI&&window.VxeUI.use&&window.VxeUI.use(t),e.default=t});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vxe-ui/plugin-menu",
3
- "version": "3.0.4",
3
+ "version": "3.0.5",
4
4
  "description": "Vxe UI plug-in supports context menu.",
5
5
  "scripts": {
6
6
  "lib": "gulp build"