@vxe-ui/plugin-menu 4.3.4 → 4.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 +35 -25
- package/dist/index.umd.min.js +1 -1
- package/es/index.esm.js +34 -25
- package/es/index.js +34 -25
- package/lib/index.common.js +35 -25
- package/lib/index.js +35 -25
- package/lib/index.umd.js +35 -25
- package/lib/index.umd.min.js +1 -1
- package/package.json +1 -1
- package/src/index.ts +33 -23
package/src/index.ts
CHANGED
|
@@ -8,6 +8,16 @@ import type { VxeUIPluginMenuOptions } from '../types'
|
|
|
8
8
|
let VxeUI: VxeUIExport
|
|
9
9
|
let handleCopy: ((content: string | number) => boolean) | undefined
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* 用于开关类型的配置项
|
|
13
|
+
* 局部启用规则:conf={}
|
|
14
|
+
* 局部禁用规则:conf={enabled:false}
|
|
15
|
+
* 全局默认启用规则:conf.enabled=true
|
|
16
|
+
*/
|
|
17
|
+
export function hasEnableConf (conf: any, opts: any): boolean {
|
|
18
|
+
return opts && (conf ? opts.enabled !== false : opts.enabled)
|
|
19
|
+
}
|
|
20
|
+
|
|
11
21
|
const columnIndexOf = (cols: VxeTableDefines.ColumnInfo[], column: VxeTableDefines.ColumnInfo) => {
|
|
12
22
|
return XEUtils.findIndexOf(cols, item => item.id === column.id)
|
|
13
23
|
}
|
|
@@ -92,7 +102,7 @@ function handleCopyOrCut (params: VxeGlobalMenusHandles.TableMenuMethodParams &
|
|
|
92
102
|
const { computeMouseOpts } = $table.getComputeMaps()
|
|
93
103
|
const mouseOpts = computeMouseOpts.value
|
|
94
104
|
let text: string
|
|
95
|
-
if (mouseConfig && mouseOpts.area) {
|
|
105
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
96
106
|
if (isCut) {
|
|
97
107
|
$table.triggerCutCellAreaEvent($event)
|
|
98
108
|
} else {
|
|
@@ -156,7 +166,7 @@ function getBeenMerges (params: (VxeGlobalMenusHandles.TableMenuMethodParams | V
|
|
|
156
166
|
const mouseOpts = computeMouseOpts.value
|
|
157
167
|
const { visibleData } = $table.getTableData()
|
|
158
168
|
const { visibleColumn } = $table.getTableColumn()
|
|
159
|
-
const cellAreas = mouseConfig && mouseOpts.area ? $table.getCellAreas() : []
|
|
169
|
+
const cellAreas = hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area ? $table.getCellAreas() : []
|
|
160
170
|
const mergeList = $table.getMergeCells()
|
|
161
171
|
return mergeList.filter(({ row: mergeRowIndex, col: mergeColIndex, rowspan: mergeRowspan, colspan: mergeColspan }) => {
|
|
162
172
|
return cellAreas.some(areaItem => {
|
|
@@ -291,7 +301,7 @@ function checkPrivilege (item: VxeTableDefines.MenuFirstOption | VxeTableDefines
|
|
|
291
301
|
}
|
|
292
302
|
case 'OPEN_FIND':
|
|
293
303
|
case 'OPEN_REPLACE': {
|
|
294
|
-
item.disabled = !(mouseConfig && mouseOpts.area)
|
|
304
|
+
item.disabled = !(hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area)
|
|
295
305
|
break
|
|
296
306
|
}
|
|
297
307
|
case 'EDIT_CELL': {
|
|
@@ -304,7 +314,7 @@ function checkPrivilege (item: VxeTableDefines.MenuFirstOption | VxeTableDefines
|
|
|
304
314
|
case 'CUT_AREA_CELL':
|
|
305
315
|
case 'PASTE_CELL':
|
|
306
316
|
case 'PASTE_AREA_CELL': {
|
|
307
|
-
const cellAreas = mouseConfig && mouseOpts.area ? $table.getCellAreas() : []
|
|
317
|
+
const cellAreas = hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area ? $table.getCellAreas() : []
|
|
308
318
|
item.disabled = cellAreas.length > 1
|
|
309
319
|
if (!item.disabled) {
|
|
310
320
|
switch (code) {
|
|
@@ -320,7 +330,7 @@ function checkPrivilege (item: VxeTableDefines.MenuFirstOption | VxeTableDefines
|
|
|
320
330
|
}
|
|
321
331
|
case 'MERGE_OR_CLEAR':
|
|
322
332
|
case 'MERGE_CELL': {
|
|
323
|
-
const cellAreas = mouseConfig && mouseOpts.area ? $table.getCellAreas() : []
|
|
333
|
+
const cellAreas = hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area ? $table.getCellAreas() : []
|
|
324
334
|
item.disabled = !cellAreas.length || (cellAreas.length === 1 && cellAreas[0].rows.length === 1 && cellAreas[0].cols.length === 1) || !checkCellOverlay(params, cellAreas)
|
|
325
335
|
break
|
|
326
336
|
}
|
|
@@ -511,7 +521,7 @@ export const VxeUIPluginMenu = {
|
|
|
511
521
|
const { mouseConfig } = tableProps
|
|
512
522
|
const { computeMouseOpts } = $table.getComputeMaps()
|
|
513
523
|
const mouseOpts = computeMouseOpts.value
|
|
514
|
-
if (mouseConfig && mouseOpts.area) {
|
|
524
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
515
525
|
const cellAreas = $table.getCellAreas()
|
|
516
526
|
if (cellAreas && cellAreas.length) {
|
|
517
527
|
cellAreas.forEach(areaItem => {
|
|
@@ -540,7 +550,7 @@ export const VxeUIPluginMenu = {
|
|
|
540
550
|
const { mouseConfig } = tableProps
|
|
541
551
|
const { computeMouseOpts } = $table.getComputeMaps()
|
|
542
552
|
const mouseOpts = computeMouseOpts.value
|
|
543
|
-
if (mouseConfig && mouseOpts.area) {
|
|
553
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
544
554
|
const cellAreas = $table.getCellAreas()
|
|
545
555
|
if (cellAreas && cellAreas.length) {
|
|
546
556
|
cellAreas.forEach(areaItem => {
|
|
@@ -586,8 +596,8 @@ export const VxeUIPluginMenu = {
|
|
|
586
596
|
const { mouseConfig } = tableProps
|
|
587
597
|
const { computeMouseOpts } = $table.getComputeMaps()
|
|
588
598
|
const mouseOpts = computeMouseOpts.value
|
|
589
|
-
if (mouseConfig && mouseOpts.area) {
|
|
590
|
-
const cellAreas =
|
|
599
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
600
|
+
const cellAreas = mouseOpts.area ? $table.getCellAreas() : []
|
|
591
601
|
cellAreas.forEach(areaItem => {
|
|
592
602
|
const { rows } = areaItem
|
|
593
603
|
$table.clearData(rows)
|
|
@@ -618,7 +628,7 @@ export const VxeUIPluginMenu = {
|
|
|
618
628
|
const { mouseConfig } = tableProps
|
|
619
629
|
const { computeMouseOpts } = $table.getComputeMaps()
|
|
620
630
|
const mouseOpts = computeMouseOpts.value
|
|
621
|
-
if (mouseConfig && mouseOpts.area) {
|
|
631
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
622
632
|
const { visibleData } = $table.getTableData()
|
|
623
633
|
const { visibleColumn } = $table.getTableColumn()
|
|
624
634
|
$table.setCellAreas([{
|
|
@@ -640,7 +650,7 @@ export const VxeUIPluginMenu = {
|
|
|
640
650
|
const { mouseConfig } = tableProps
|
|
641
651
|
const { computeMouseOpts } = $table.getComputeMaps()
|
|
642
652
|
const mouseOpts = computeMouseOpts.value
|
|
643
|
-
if (row && column && mouseConfig && mouseOpts.area) {
|
|
653
|
+
if (row && column && hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
644
654
|
const { visibleColumn } = $table.getTableColumn()
|
|
645
655
|
const cellAreas = $table.getCellAreas()
|
|
646
656
|
if (cellAreas.length === 1) {
|
|
@@ -672,7 +682,7 @@ export const VxeUIPluginMenu = {
|
|
|
672
682
|
const { mouseConfig } = tableProps
|
|
673
683
|
const { computeMouseOpts } = $table.getComputeMaps()
|
|
674
684
|
const mouseOpts = computeMouseOpts.value
|
|
675
|
-
if (row && column && mouseConfig && mouseOpts.area) {
|
|
685
|
+
if (row && column && hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
676
686
|
const { visibleColumn } = $table.getTableColumn()
|
|
677
687
|
const cellAreas = $table.getCellAreas()
|
|
678
688
|
if (cellAreas.length === 1) {
|
|
@@ -704,7 +714,7 @@ export const VxeUIPluginMenu = {
|
|
|
704
714
|
const { mouseConfig } = tableProps
|
|
705
715
|
const { computeMouseOpts } = $table.getComputeMaps()
|
|
706
716
|
const mouseOpts = computeMouseOpts.value
|
|
707
|
-
if (row && column && mouseConfig && mouseOpts.area) {
|
|
717
|
+
if (row && column && hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
708
718
|
const { visibleData } = $table.getTableData()
|
|
709
719
|
const cellAreas = $table.getCellAreas()
|
|
710
720
|
if (cellAreas.length === 1) {
|
|
@@ -736,7 +746,7 @@ export const VxeUIPluginMenu = {
|
|
|
736
746
|
const { mouseConfig } = tableProps
|
|
737
747
|
const { computeMouseOpts } = $table.getComputeMaps()
|
|
738
748
|
const mouseOpts = computeMouseOpts.value
|
|
739
|
-
if (row && column && mouseConfig && mouseOpts.area) {
|
|
749
|
+
if (row && column && hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
740
750
|
const { visibleData } = $table.getTableData()
|
|
741
751
|
const cellAreas = $table.getCellAreas()
|
|
742
752
|
if (cellAreas.length === 1) {
|
|
@@ -769,7 +779,7 @@ export const VxeUIPluginMenu = {
|
|
|
769
779
|
const { mouseConfig } = tableProps
|
|
770
780
|
const { computeMouseOpts } = $table.getComputeMaps()
|
|
771
781
|
const mouseOpts = computeMouseOpts.value
|
|
772
|
-
if (mouseConfig && mouseOpts.area) {
|
|
782
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
773
783
|
const cellAreas = $table.getCellAreas()
|
|
774
784
|
if (cellAreas && cellAreas.length) {
|
|
775
785
|
cellAreas.forEach(areaItem => {
|
|
@@ -875,7 +885,7 @@ export const VxeUIPluginMenu = {
|
|
|
875
885
|
const { mouseConfig } = tableProps
|
|
876
886
|
const { computeMouseOpts } = $table.getComputeMaps()
|
|
877
887
|
const mouseOpts = computeMouseOpts.value
|
|
878
|
-
if (mouseConfig && mouseOpts.area) {
|
|
888
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
879
889
|
$table.triggerPasteCellAreaEvent($event)
|
|
880
890
|
} else {
|
|
881
891
|
const clipboard = getClipboardObj()
|
|
@@ -896,7 +906,7 @@ export const VxeUIPluginMenu = {
|
|
|
896
906
|
const { mouseConfig } = tableProps
|
|
897
907
|
const { computeMouseOpts } = $table.getComputeMaps()
|
|
898
908
|
const mouseOpts = computeMouseOpts.value
|
|
899
|
-
if (mouseConfig && mouseOpts.area) {
|
|
909
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
900
910
|
$table.triggerPasteCellAreaEvent($event)
|
|
901
911
|
}
|
|
902
912
|
}
|
|
@@ -1023,7 +1033,7 @@ export const VxeUIPluginMenu = {
|
|
|
1023
1033
|
const { computeMouseOpts } = $table.getComputeMaps()
|
|
1024
1034
|
const mouseOpts = computeMouseOpts.value
|
|
1025
1035
|
$table.insert(menu.params || {}).then(({ rows }) => {
|
|
1026
|
-
if (column && mouseConfig && mouseOpts.area) {
|
|
1036
|
+
if (column && hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
1027
1037
|
$table.setCellAreas([
|
|
1028
1038
|
{ startRow: XEUtils.first(rows), endRow: XEUtils.last(rows), startColumn: column, endColumn: column }
|
|
1029
1039
|
])
|
|
@@ -1042,7 +1052,7 @@ export const VxeUIPluginMenu = {
|
|
|
1042
1052
|
const { computeMouseOpts } = $table.getComputeMaps()
|
|
1043
1053
|
const mouseOpts = computeMouseOpts.value;
|
|
1044
1054
|
(row ? $table.insertAt(menu.params || {}, row) : $table.insert(menu.params || {})).then(({ rows }) => {
|
|
1045
|
-
if (column && mouseConfig && mouseOpts.area) {
|
|
1055
|
+
if (column && hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
1046
1056
|
$table.setCellAreas([
|
|
1047
1057
|
{ startRow: XEUtils.first(rows), endRow: XEUtils.last(rows), startColumn: column, endColumn: column }
|
|
1048
1058
|
])
|
|
@@ -1064,7 +1074,7 @@ export const VxeUIPluginMenu = {
|
|
|
1064
1074
|
if (size) {
|
|
1065
1075
|
const records = XEUtils.range(0, size).map(() => Object.assign({}, menu.params));
|
|
1066
1076
|
(row ? $table.insertAt(records, row) : $table.insert(records)).then(({ rows }) => {
|
|
1067
|
-
if (column && mouseConfig && mouseOpts.area) {
|
|
1077
|
+
if (column && hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
1068
1078
|
$table.setCellAreas([
|
|
1069
1079
|
{ startRow: XEUtils.first(rows), endRow: XEUtils.last(rows), startColumn: column, endColumn: column }
|
|
1070
1080
|
])
|
|
@@ -1085,7 +1095,7 @@ export const VxeUIPluginMenu = {
|
|
|
1085
1095
|
const { computeMouseOpts } = $table.getComputeMaps()
|
|
1086
1096
|
const mouseOpts = computeMouseOpts.value;
|
|
1087
1097
|
(row ? $table.insertNextAt(menu.params || {}, row) : $table.insert(menu.params || {})).then(({ rows }) => {
|
|
1088
|
-
if (column && mouseConfig && mouseOpts.area) {
|
|
1098
|
+
if (column && hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
1089
1099
|
$table.setCellAreas([
|
|
1090
1100
|
{ startRow: XEUtils.first(rows), endRow: XEUtils.last(rows), startColumn: column, endColumn: column }
|
|
1091
1101
|
])
|
|
@@ -1107,7 +1117,7 @@ export const VxeUIPluginMenu = {
|
|
|
1107
1117
|
if (size) {
|
|
1108
1118
|
const records = XEUtils.range(0, size).map(() => Object.assign({}, menu.params));
|
|
1109
1119
|
(row ? $table.insertNextAt(records, row) : $table.insert(records)).then(({ rows }) => {
|
|
1110
|
-
if (column && mouseConfig && mouseOpts.area) {
|
|
1120
|
+
if (column && hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
1111
1121
|
$table.setCellAreas([
|
|
1112
1122
|
{ startRow: XEUtils.first(rows), endRow: XEUtils.last(rows), startColumn: column, endColumn: column }
|
|
1113
1123
|
])
|
|
@@ -1274,7 +1284,7 @@ export const VxeUIPluginMenu = {
|
|
|
1274
1284
|
const { mouseConfig } = tableProps
|
|
1275
1285
|
const { computeMouseOpts } = $table.getComputeMaps()
|
|
1276
1286
|
const mouseOpts = computeMouseOpts.value
|
|
1277
|
-
if (mouseConfig && mouseOpts.area) {
|
|
1287
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
1278
1288
|
const cellAreas = $table.getCellAreas()
|
|
1279
1289
|
cellAreas.forEach(areaItem => {
|
|
1280
1290
|
const { rows } = areaItem
|