@vxe-ui/plugin-menu 3.3.4 → 3.4.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/dist/index.umd.js +36 -26
- package/dist/index.umd.min.js +1 -1
- package/es/index.esm.js +35 -26
- package/es/index.js +35 -26
- package/lib/index.common.js +36 -26
- package/lib/index.js +36 -26
- package/lib/index.umd.js +36 -26
- package/lib/index.umd.min.js +1 -1
- package/package.json +1 -1
- package/src/index.ts +34 -24
package/src/index.ts
CHANGED
|
@@ -7,6 +7,16 @@ import type { VxeUIPluginMenuOptions } from '../types'
|
|
|
7
7
|
let VxeUI: VxeUIExport
|
|
8
8
|
let handleCopy: ((content: string | number) => boolean) | undefined
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* 用于开关类型的配置项
|
|
12
|
+
* 局部启用规则:conf={}
|
|
13
|
+
* 局部禁用规则:conf={enabled:false}
|
|
14
|
+
* 全局默认启用规则:conf.enabled=true
|
|
15
|
+
*/
|
|
16
|
+
export function hasEnableConf (conf: any, opts: any): boolean {
|
|
17
|
+
return opts && (conf ? opts.enabled !== false : opts.enabled)
|
|
18
|
+
}
|
|
19
|
+
|
|
10
20
|
const columnIndexOf = (cols: VxeTableDefines.ColumnInfo[], column: VxeTableDefines.ColumnInfo) => {
|
|
11
21
|
return XEUtils.findIndexOf(cols, item => item.id === column.id)
|
|
12
22
|
}
|
|
@@ -90,7 +100,7 @@ function handleCopyOrCut (params: VxeGlobalMenusHandles.TableMenuMethodParams &
|
|
|
90
100
|
const { mouseConfig } = props
|
|
91
101
|
const mouseOpts = $table.computeMouseOpts
|
|
92
102
|
let text = ''
|
|
93
|
-
if (mouseConfig && mouseOpts.area) {
|
|
103
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
94
104
|
if (isCut) {
|
|
95
105
|
$table.triggerCutCellAreaEvent($event)
|
|
96
106
|
} else {
|
|
@@ -153,7 +163,7 @@ function getBeenMerges (params: (VxeGlobalMenusHandles.TableMenuMethodParams | V
|
|
|
153
163
|
const mouseOpts = $table.computeMouseOpts
|
|
154
164
|
const { visibleData } = $table.getTableData()
|
|
155
165
|
const { visibleColumn } = $table.getTableColumn()
|
|
156
|
-
const cellAreas = mouseConfig && mouseOpts.area ? $table.getCellAreas() : []
|
|
166
|
+
const cellAreas = hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area ? $table.getCellAreas() : []
|
|
157
167
|
const mergeList = $table.getMergeCells()
|
|
158
168
|
return mergeList.filter(({ row: mergeRowIndex, col: mergeColIndex, rowspan: mergeRowspan, colspan: mergeColspan }) => {
|
|
159
169
|
return cellAreas.some(areaItem => {
|
|
@@ -287,7 +297,7 @@ function checkPrivilege (item: VxeTableDefines.MenuFirstOption | VxeTableDefines
|
|
|
287
297
|
}
|
|
288
298
|
case 'OPEN_FIND':
|
|
289
299
|
case 'OPEN_REPLACE': {
|
|
290
|
-
item.disabled = !(mouseConfig && mouseOpts.area)
|
|
300
|
+
item.disabled = !(hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area)
|
|
291
301
|
break
|
|
292
302
|
}
|
|
293
303
|
case 'EDIT_CELL': {
|
|
@@ -300,7 +310,7 @@ function checkPrivilege (item: VxeTableDefines.MenuFirstOption | VxeTableDefines
|
|
|
300
310
|
case 'CUT_AREA_CELL':
|
|
301
311
|
case 'PASTE_CELL':
|
|
302
312
|
case 'PASTE_AREA_CELL': {
|
|
303
|
-
const cellAreas = mouseConfig && mouseOpts.area ? $table.getCellAreas() : []
|
|
313
|
+
const cellAreas = hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area ? $table.getCellAreas() : []
|
|
304
314
|
item.disabled = cellAreas.length > 1
|
|
305
315
|
if (!item.disabled) {
|
|
306
316
|
switch (code) {
|
|
@@ -316,7 +326,7 @@ function checkPrivilege (item: VxeTableDefines.MenuFirstOption | VxeTableDefines
|
|
|
316
326
|
}
|
|
317
327
|
case 'MERGE_OR_CLEAR':
|
|
318
328
|
case 'MERGE_CELL': {
|
|
319
|
-
const cellAreas = mouseConfig && mouseOpts.area ? $table.getCellAreas() : []
|
|
329
|
+
const cellAreas = hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area ? $table.getCellAreas() : []
|
|
320
330
|
item.disabled = !cellAreas.length || (cellAreas.length === 1 && cellAreas[0].rows.length === 1 && cellAreas[0].cols.length === 1) || !checkCellOverlay(params, cellAreas)
|
|
321
331
|
break
|
|
322
332
|
}
|
|
@@ -507,7 +517,7 @@ export const VxeUIPluginMenu = {
|
|
|
507
517
|
const tableProps = $table
|
|
508
518
|
const { mouseConfig } = tableProps
|
|
509
519
|
const mouseOpts = $table.computeMouseOpts
|
|
510
|
-
if (mouseConfig && mouseOpts.area) {
|
|
520
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
511
521
|
const cellAreas = $table.getCellAreas()
|
|
512
522
|
if (cellAreas && cellAreas.length) {
|
|
513
523
|
cellAreas.forEach(areaItem => {
|
|
@@ -535,7 +545,7 @@ export const VxeUIPluginMenu = {
|
|
|
535
545
|
const tableProps = $table
|
|
536
546
|
const { mouseConfig } = tableProps
|
|
537
547
|
const mouseOpts = $table.computeMouseOpts
|
|
538
|
-
if (mouseConfig && mouseOpts.area) {
|
|
548
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
539
549
|
const cellAreas = $table.getCellAreas()
|
|
540
550
|
if (cellAreas && cellAreas.length) {
|
|
541
551
|
cellAreas.forEach(areaItem => {
|
|
@@ -582,8 +592,8 @@ export const VxeUIPluginMenu = {
|
|
|
582
592
|
const tableProps = $table
|
|
583
593
|
const { mouseConfig } = tableProps
|
|
584
594
|
const mouseOpts = $table.computeMouseOpts
|
|
585
|
-
if (mouseConfig && mouseOpts.area) {
|
|
586
|
-
const cellAreas =
|
|
595
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
596
|
+
const cellAreas = mouseOpts.area ? $table.getCellAreas() : []
|
|
587
597
|
cellAreas.forEach(areaItem => {
|
|
588
598
|
const { rows, cols } = areaItem
|
|
589
599
|
rows.forEach(row => {
|
|
@@ -617,7 +627,7 @@ export const VxeUIPluginMenu = {
|
|
|
617
627
|
const tableProps = $table
|
|
618
628
|
const { mouseConfig } = tableProps
|
|
619
629
|
const mouseOpts = $table.computeMouseOpts
|
|
620
|
-
if (mouseConfig && mouseOpts.area) {
|
|
630
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
621
631
|
const { visibleData } = $table.getTableData()
|
|
622
632
|
const { visibleColumn } = $table.getTableColumn()
|
|
623
633
|
$table.setCellAreas([{
|
|
@@ -638,7 +648,7 @@ export const VxeUIPluginMenu = {
|
|
|
638
648
|
const tableProps = $table
|
|
639
649
|
const { mouseConfig } = tableProps
|
|
640
650
|
const mouseOpts = $table.computeMouseOpts
|
|
641
|
-
if (mouseConfig && mouseOpts.area) {
|
|
651
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
642
652
|
const { visibleColumn } = $table.getTableColumn()
|
|
643
653
|
const cellAreas = $table.getCellAreas()
|
|
644
654
|
if (cellAreas.length === 1) {
|
|
@@ -669,7 +679,7 @@ export const VxeUIPluginMenu = {
|
|
|
669
679
|
const tableProps = $table
|
|
670
680
|
const { mouseConfig } = tableProps
|
|
671
681
|
const mouseOpts = $table.computeMouseOpts
|
|
672
|
-
if (mouseConfig && mouseOpts.area) {
|
|
682
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
673
683
|
const { visibleColumn } = $table.getTableColumn()
|
|
674
684
|
const cellAreas = $table.getCellAreas()
|
|
675
685
|
if (cellAreas.length === 1) {
|
|
@@ -700,7 +710,7 @@ export const VxeUIPluginMenu = {
|
|
|
700
710
|
const tableProps = $table
|
|
701
711
|
const { mouseConfig } = tableProps
|
|
702
712
|
const mouseOpts = $table.computeMouseOpts
|
|
703
|
-
if (mouseConfig && mouseOpts.area) {
|
|
713
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
704
714
|
const { visibleData } = $table.getTableData()
|
|
705
715
|
const cellAreas = $table.getCellAreas()
|
|
706
716
|
if (cellAreas.length === 1) {
|
|
@@ -731,7 +741,7 @@ export const VxeUIPluginMenu = {
|
|
|
731
741
|
const tableProps = $table
|
|
732
742
|
const { mouseConfig } = tableProps
|
|
733
743
|
const mouseOpts = $table.computeMouseOpts
|
|
734
|
-
if (mouseConfig && mouseOpts.area) {
|
|
744
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
735
745
|
const { visibleData } = $table.getTableData()
|
|
736
746
|
const cellAreas = $table.getCellAreas()
|
|
737
747
|
if (cellAreas.length === 1) {
|
|
@@ -763,7 +773,7 @@ export const VxeUIPluginMenu = {
|
|
|
763
773
|
const tableProps = $table
|
|
764
774
|
const { mouseConfig } = tableProps
|
|
765
775
|
const mouseOpts = $table.computeMouseOpts
|
|
766
|
-
if (mouseConfig && mouseOpts.area) {
|
|
776
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
767
777
|
const cellAreas = $table.getCellAreas()
|
|
768
778
|
if (cellAreas && cellAreas.length) {
|
|
769
779
|
cellAreas.forEach(areaItem => {
|
|
@@ -868,7 +878,7 @@ export const VxeUIPluginMenu = {
|
|
|
868
878
|
const tableProps = $table
|
|
869
879
|
const { mouseConfig } = tableProps
|
|
870
880
|
const mouseOpts = $table.computeMouseOpts
|
|
871
|
-
if (mouseConfig && mouseOpts.area) {
|
|
881
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
872
882
|
$table.triggerPasteCellAreaEvent($event)
|
|
873
883
|
} else {
|
|
874
884
|
const clipboard = getClipboardObj()
|
|
@@ -888,7 +898,7 @@ export const VxeUIPluginMenu = {
|
|
|
888
898
|
const tableProps = $table
|
|
889
899
|
const { mouseConfig } = tableProps
|
|
890
900
|
const mouseOpts = $table.computeMouseOpts
|
|
891
|
-
if (mouseConfig && mouseOpts.area) {
|
|
901
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
892
902
|
$table.triggerPasteCellAreaEvent($event)
|
|
893
903
|
}
|
|
894
904
|
}
|
|
@@ -1014,7 +1024,7 @@ export const VxeUIPluginMenu = {
|
|
|
1014
1024
|
const { mouseConfig } = tableProps
|
|
1015
1025
|
const mouseOpts = $table.computeMouseOpts
|
|
1016
1026
|
$table.insert(menu.params || {}).then(({ rows }) => {
|
|
1017
|
-
if (column && mouseConfig && mouseOpts.area) {
|
|
1027
|
+
if (column && hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
1018
1028
|
$table.setCellAreas([
|
|
1019
1029
|
{ startRow: XEUtils.first(rows), endRow: XEUtils.last(rows), startColumn: column, endColumn: column }
|
|
1020
1030
|
])
|
|
@@ -1032,7 +1042,7 @@ export const VxeUIPluginMenu = {
|
|
|
1032
1042
|
const { mouseConfig } = tableProps
|
|
1033
1043
|
const mouseOpts = $table.computeMouseOpts;
|
|
1034
1044
|
(row ? $table.insertAt(menu.params || {}, row) : $table.insert(menu.params || {})).then(({ rows }) => {
|
|
1035
|
-
if (column && mouseConfig && mouseOpts.area) {
|
|
1045
|
+
if (column && hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
1036
1046
|
$table.setCellAreas([
|
|
1037
1047
|
{ startRow: XEUtils.first(rows), endRow: XEUtils.last(rows), startColumn: column, endColumn: column }
|
|
1038
1048
|
])
|
|
@@ -1053,7 +1063,7 @@ export const VxeUIPluginMenu = {
|
|
|
1053
1063
|
if (size) {
|
|
1054
1064
|
const records = XEUtils.range(0, size).map(() => Object.assign({}, menu.params));
|
|
1055
1065
|
(row ? $table.insertAt(records, row) : $table.insert(records)).then(({ rows }) => {
|
|
1056
|
-
if (column && mouseConfig && mouseOpts.area) {
|
|
1066
|
+
if (column && hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
1057
1067
|
$table.setCellAreas([
|
|
1058
1068
|
{ startRow: XEUtils.first(rows), endRow: XEUtils.last(rows), startColumn: column, endColumn: column }
|
|
1059
1069
|
])
|
|
@@ -1073,7 +1083,7 @@ export const VxeUIPluginMenu = {
|
|
|
1073
1083
|
const { mouseConfig } = tableProps
|
|
1074
1084
|
const mouseOpts = $table.computeMouseOpts;
|
|
1075
1085
|
(row ? $table.insertNextAt(menu.params || {}, row) : $table.insert(menu.params || {})).then(({ rows }) => {
|
|
1076
|
-
if (column && mouseConfig && mouseOpts.area) {
|
|
1086
|
+
if (column && hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
1077
1087
|
$table.setCellAreas([
|
|
1078
1088
|
{ startRow: XEUtils.first(rows), endRow: XEUtils.last(rows), startColumn: column, endColumn: column }
|
|
1079
1089
|
])
|
|
@@ -1094,7 +1104,7 @@ export const VxeUIPluginMenu = {
|
|
|
1094
1104
|
if (size) {
|
|
1095
1105
|
const records = XEUtils.range(0, size).map(() => Object.assign({}, menu.params));
|
|
1096
1106
|
(row ? $table.insertNextAt(records, row) : $table.insert(records)).then(({ rows }) => {
|
|
1097
|
-
if (column && mouseConfig && mouseOpts.area) {
|
|
1107
|
+
if (column && hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
1098
1108
|
$table.setCellAreas([
|
|
1099
1109
|
{ startRow: XEUtils.first(rows), endRow: XEUtils.last(rows), startColumn: column, endColumn: column }
|
|
1100
1110
|
])
|
|
@@ -1260,8 +1270,8 @@ export const VxeUIPluginMenu = {
|
|
|
1260
1270
|
const tableProps = $table
|
|
1261
1271
|
const { mouseConfig } = tableProps
|
|
1262
1272
|
const mouseOpts = $table.computeMouseOpts
|
|
1263
|
-
if (mouseConfig && mouseOpts.area) {
|
|
1264
|
-
const cellAreas =
|
|
1273
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
1274
|
+
const cellAreas = $table.getCellAreas()
|
|
1265
1275
|
cellAreas.forEach(areaItem => {
|
|
1266
1276
|
const { rows } = areaItem
|
|
1267
1277
|
$table.remove(rows)
|