@vxe-ui/plugin-menu 4.0.0
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/LICENSE +21 -0
- package/README.md +89 -0
- package/dist/index.common.js +1043 -0
- package/dist/index.umd.js +1057 -0
- package/dist/index.umd.min.js +1 -0
- package/dist/style.css +0 -0
- package/dist/style.min.css +0 -0
- package/package.json +72 -0
- package/types/index.d.ts +14 -0
|
@@ -0,0 +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.VxeUIPluginExportPDF=t)})("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:this,function(e,u){var i,c;Object.defineProperty(e,"__esModule",{value:!0}),e.default=e.VxeUIPluginMenu=void 0,u=(t=u)&&t.__esModule?t:{default:t};var a,g=function(e,t){return u.default.findIndexOf(e,function(e){return e.id===t.id})},_=function(e,t,n){return e.findRowIndexOf(t,n)};function n(n){return{menuMethod:function(e){var t=e.$table;u.default.eachTree([e.column],function(e){e.fixed=n}),t.refreshColumn()}}}function C(){var e=i.globalStore;return e?e.clipboard||"":(e=i.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,s=e.row,e=e.column;s&&e&&(n=l.props.mouseConfig,o=l.getComputeMaps().computeMouseOpts.value,a="",n&&o.area?(t?l.triggerCutCellAreaEvent(r):l.triggerCopyCellAreaEvent(r),a=(n=C())?n.text:""):(a=u.default.toValueString(u.default.get(s,e.field)),o={text:a,html:""},(t=i.globalStore)?t.clipboard=o:i.config&&(i.config.clipboard=o)),(u.default.isFunction(c)?c:E)(a))}function m(e){var u=e.$table,e=u.props.mouseConfig,t=u.getComputeMaps().computeMouseOpts.value,i=u.getTableData().visibleData,c=u.getTableColumn().visibleColumn,n=e&&t.area?u.getCellAreas():[];return u.getMergeCells().filter(function(e){var o=e.row,r=e.col,l=e.rowspan,s=e.colspan;return n.some(function(e){var t=e.rows,e=e.cols,n=_(u,i,t[0]),t=_(u,i,t[t.length-1]),a=g(c,e[0]),e=g(c,e[e.length-1]);return n<=o&&o+l-1<=t&&a<=r&&r+s-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=a.props,s=l.editConfig,u=l.mouseConfig;switch(n){case"CLEAR_ALL_SORT":var i=a.getSortColumns();e.disabled=!i.length;break;case"CLEAR_ALL_FILTER":i=a.getCheckedFilters();e.disabled=!i.length;break;case"CLEAR_ALL_MERGE":var i=a.getMergeCells(),c=a.getMergeFooterItems();e.disabled=!i.length&&!c.length;break;case"CLEAR_MERGE_CELL":i=m(t);e.disabled=!i.length;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"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.getComputeMaps().computeMouseOpts.value,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=!(u&&E.area);break;case"EDIT_CELL":e.disabled=!s||!r.editRender;break;case"COPY_CELL":case"CUT_CELL":case"PASTE_CELL":var f=u&&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=u&&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,s=t.length;l<s;l++)for(var u=t[l],i=u.rows,c=u.cols,E=0,d=i.length;E<d;E++)for(var f=i[E],C=_(n,a,f),m=0,L=c.length;m<L;m++){var R=c[m],R=C+":"+g(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 s(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){i=e,/^(4)\./.test(i.uiVersion)||console.error("[plugin-export-pdf 4.x] Version 4.x is required"),d(t),i.menus.mixin({CLEAR_CELL:{menuMethod:function(e){var t,n,a=e.$table,o=e.row,e=e.column;o&&e&&(n=a.props.mouseConfig,t=a.getComputeMaps().computeMouseOpts.value,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_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.props.mouseConfig,t=a.getComputeMaps().computeMouseOpts.value,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_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.props.mouseConfig,r=n.getComputeMaps().computeMouseOpts.value;o&&r.area?n.triggerPasteCellAreaEvent(t):(o=C())&&o.text&&u.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})?i.modal&&i.modal.message({content:i.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_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)}))}},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=t.props.mouseConfig,n=t.getComputeMaps().computeMouseOpts.value;return(e&&n.area?t.getCellAreas():[]).forEach(function(e){e=e.rows;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=u.default.get(a,t),e.checked=!0,n.updateData())}},EXPORT_ROW:{menuMethod:function(e){var t=e.$table,n=e.row;n&&t.exportData(u.default.assign({data:[n]},e.menu.params[0]))}},EXPORT_CHECKBOX_ROW:{menuMethod:function(e){var t=e.$table,e=e.menu,n={data:t.getCheckboxRecords()};t.exportData(u.default.assign(n,e.params[0]))}},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(u.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)}}}),i.interceptor.add("event.showMenu",s)}};"undefined"!=typeof window&&window.VxeUI&&window.VxeUI.use&&window.VxeUI.use(t),e.default=t});
|
package/dist/style.css
ADDED
|
File without changes
|
|
File without changes
|
package/package.json
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vxe-ui/plugin-menu",
|
|
3
|
+
"version": "4.0.0",
|
|
4
|
+
"description": "Vxe UI plug-in supports context menu.",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"lib": "gulp build"
|
|
7
|
+
},
|
|
8
|
+
"files": [
|
|
9
|
+
"types",
|
|
10
|
+
"dist",
|
|
11
|
+
"*.ts",
|
|
12
|
+
"*.d.ts"
|
|
13
|
+
],
|
|
14
|
+
"main": "dist/index.common.js",
|
|
15
|
+
"unpkg": "dist/index.umd.js",
|
|
16
|
+
"jsdelivr": "dist/index.umd.js",
|
|
17
|
+
"style": "dist/style.css",
|
|
18
|
+
"typings": "types/index.d.ts",
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@babel/core": "^7.12.3",
|
|
21
|
+
"@babel/plugin-transform-runtime": "^7.12.1",
|
|
22
|
+
"@babel/preset-env": "^7.12.1",
|
|
23
|
+
"@babel/runtime": "^7.12.5",
|
|
24
|
+
"@typescript-eslint/eslint-plugin": "^4.6.1",
|
|
25
|
+
"@typescript-eslint/parser": "^4.6.1",
|
|
26
|
+
"del": "^6.0.0",
|
|
27
|
+
"eslint": "^7.13.0",
|
|
28
|
+
"eslint-config-prettier": "^6.15.0",
|
|
29
|
+
"eslint-config-standard": "^16.0.1",
|
|
30
|
+
"eslint-friendly-formatter": "^4.0.1",
|
|
31
|
+
"eslint-plugin-import": "^2.22.1",
|
|
32
|
+
"eslint-plugin-node": "^11.1.0",
|
|
33
|
+
"eslint-plugin-prettier": "^3.1.4",
|
|
34
|
+
"eslint-plugin-promise": "^4.2.1",
|
|
35
|
+
"eslint-plugin-standard": "^4.0.2",
|
|
36
|
+
"eslint-plugin-typescript": "^0.14.0",
|
|
37
|
+
"gulp": "^4.0.2",
|
|
38
|
+
"gulp-autoprefixer": "^8.0.0",
|
|
39
|
+
"gulp-babel": "^8.0.0",
|
|
40
|
+
"gulp-clean-css": "^4.3.0",
|
|
41
|
+
"gulp-concat": "^2.6.1",
|
|
42
|
+
"gulp-rename": "^2.0.0",
|
|
43
|
+
"gulp-replace": "^1.1.3",
|
|
44
|
+
"gulp-sass": "^5.1.0",
|
|
45
|
+
"gulp-sourcemaps": "^3.0.0",
|
|
46
|
+
"gulp-typescript": "^5.0.1",
|
|
47
|
+
"gulp-uglify": "^3.0.2",
|
|
48
|
+
"markdown-doctest": "^1.1.0",
|
|
49
|
+
"prettier": "^2.1.2",
|
|
50
|
+
"sass": "^1.55.0",
|
|
51
|
+
"typescript": "^4.6.4",
|
|
52
|
+
"vue": "3.4.27",
|
|
53
|
+
"vxe-pc-ui": "^4.1.13",
|
|
54
|
+
"vxe-table": "^4.7.74"
|
|
55
|
+
},
|
|
56
|
+
"repository": {
|
|
57
|
+
"type": "git",
|
|
58
|
+
"url": "git+https://github.com/x-extends/vxe-ui-plugins.git"
|
|
59
|
+
},
|
|
60
|
+
"keywords": [
|
|
61
|
+
"vxe-ui-plugins"
|
|
62
|
+
],
|
|
63
|
+
"author": {
|
|
64
|
+
"name": "Xu Liangzhan",
|
|
65
|
+
"email": "xu_liangzhan@163.com"
|
|
66
|
+
},
|
|
67
|
+
"license": "MIT",
|
|
68
|
+
"bugs": {
|
|
69
|
+
"url": "https://github.com/x-extends/vxe-ui-plugins/issues"
|
|
70
|
+
},
|
|
71
|
+
"homepage": "https://github.com/x-extends/vxe-ui-plugins#readme"
|
|
72
|
+
}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { VxeUIExport } from 'vxe-pc-ui'
|
|
2
|
+
|
|
3
|
+
export interface VxeUIPluginMenuOptions {
|
|
4
|
+
copy?: (content: string | number) => boolean;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 基于 Vxe UI 的扩展插件,支持右键菜单
|
|
9
|
+
*/
|
|
10
|
+
export declare const VxeUIPluginMenu: {
|
|
11
|
+
install (VxeUI: VxeUIExport, options?: VxeUIPluginMenuOptions): void
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default VxeUIPluginMenu
|