@vxe-ui/plugin-menu 3.3.2 → 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 +104 -24
- package/dist/index.umd.min.js +1 -1
- package/es/index.esm.js +102 -26
- package/es/index.js +102 -26
- package/lib/index.common.js +104 -24
- package/lib/index.js +104 -24
- package/lib/index.umd.js +104 -24
- package/lib/index.umd.min.js +1 -1
- package/package.json +6 -7
- package/src/index.ts +100 -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 => {
|
|
@@ -227,10 +237,14 @@ function checkPrivilege (item: VxeTableDefines.MenuFirstOption | VxeTableDefines
|
|
|
227
237
|
}
|
|
228
238
|
case 'EDIT_CELL':
|
|
229
239
|
case 'CLEAR_CELL':
|
|
240
|
+
case 'CLEAR_AREA_CELL':
|
|
230
241
|
case 'CLEAR_ROW':
|
|
231
242
|
case 'COPY_CELL':
|
|
243
|
+
case 'COPY_AREA_CELL':
|
|
232
244
|
case 'CUT_CELL':
|
|
245
|
+
case 'CUT_AREA_CELL':
|
|
233
246
|
case 'PASTE_CELL':
|
|
247
|
+
case 'PASTE_AREA_CELL':
|
|
234
248
|
case 'MERGE_OR_CLEAR':
|
|
235
249
|
case 'MERGE_CELL':
|
|
236
250
|
case 'REVERT_CELL':
|
|
@@ -283,7 +297,7 @@ function checkPrivilege (item: VxeTableDefines.MenuFirstOption | VxeTableDefines
|
|
|
283
297
|
}
|
|
284
298
|
case 'OPEN_FIND':
|
|
285
299
|
case 'OPEN_REPLACE': {
|
|
286
|
-
item.disabled = !(mouseConfig && mouseOpts.area)
|
|
300
|
+
item.disabled = !(hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area)
|
|
287
301
|
break
|
|
288
302
|
}
|
|
289
303
|
case 'EDIT_CELL': {
|
|
@@ -291,13 +305,17 @@ function checkPrivilege (item: VxeTableDefines.MenuFirstOption | VxeTableDefines
|
|
|
291
305
|
break
|
|
292
306
|
}
|
|
293
307
|
case 'COPY_CELL':
|
|
308
|
+
case 'COPY_AREA_CELL':
|
|
294
309
|
case 'CUT_CELL':
|
|
295
|
-
case '
|
|
296
|
-
|
|
310
|
+
case 'CUT_AREA_CELL':
|
|
311
|
+
case 'PASTE_CELL':
|
|
312
|
+
case 'PASTE_AREA_CELL': {
|
|
313
|
+
const cellAreas = hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area ? $table.getCellAreas() : []
|
|
297
314
|
item.disabled = cellAreas.length > 1
|
|
298
315
|
if (!item.disabled) {
|
|
299
316
|
switch (code) {
|
|
300
|
-
case 'PASTE_CELL':
|
|
317
|
+
case 'PASTE_CELL':
|
|
318
|
+
case 'PASTE_AREA_CELL': {
|
|
301
319
|
const clipboard = getClipboardObj()
|
|
302
320
|
item.disabled = !clipboard || !clipboard.text
|
|
303
321
|
break
|
|
@@ -308,7 +326,7 @@ function checkPrivilege (item: VxeTableDefines.MenuFirstOption | VxeTableDefines
|
|
|
308
326
|
}
|
|
309
327
|
case 'MERGE_OR_CLEAR':
|
|
310
328
|
case 'MERGE_CELL': {
|
|
311
|
-
const cellAreas = mouseConfig && mouseOpts.area ? $table.getCellAreas() : []
|
|
329
|
+
const cellAreas = hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area ? $table.getCellAreas() : []
|
|
312
330
|
item.disabled = !cellAreas.length || (cellAreas.length === 1 && cellAreas[0].rows.length === 1 && cellAreas[0].cols.length === 1) || !checkCellOverlay(params, cellAreas)
|
|
313
331
|
break
|
|
314
332
|
}
|
|
@@ -499,7 +517,35 @@ export const VxeUIPluginMenu = {
|
|
|
499
517
|
const tableProps = $table
|
|
500
518
|
const { mouseConfig } = tableProps
|
|
501
519
|
const mouseOpts = $table.computeMouseOpts
|
|
502
|
-
if (mouseConfig && mouseOpts.area) {
|
|
520
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
521
|
+
const cellAreas = $table.getCellAreas()
|
|
522
|
+
if (cellAreas && cellAreas.length) {
|
|
523
|
+
cellAreas.forEach(areaItem => {
|
|
524
|
+
const { rows, cols } = areaItem
|
|
525
|
+
cols.forEach(column => {
|
|
526
|
+
rows.forEach(row => {
|
|
527
|
+
$table.clearData(row, column.field)
|
|
528
|
+
})
|
|
529
|
+
})
|
|
530
|
+
})
|
|
531
|
+
}
|
|
532
|
+
} else {
|
|
533
|
+
$table.clearData(row, column.field)
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
},
|
|
538
|
+
/**
|
|
539
|
+
* 清除单元格数据的值;如果启用 mouse-config.area 功能,则清除区域范围内的单元格数据
|
|
540
|
+
*/
|
|
541
|
+
CLEAR_AREA_CELL: {
|
|
542
|
+
tableMenuMethod (params) {
|
|
543
|
+
const { $table, row, column } = params
|
|
544
|
+
if (row && column) {
|
|
545
|
+
const tableProps = $table
|
|
546
|
+
const { mouseConfig } = tableProps
|
|
547
|
+
const mouseOpts = $table.computeMouseOpts
|
|
548
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
503
549
|
const cellAreas = $table.getCellAreas()
|
|
504
550
|
if (cellAreas && cellAreas.length) {
|
|
505
551
|
cellAreas.forEach(areaItem => {
|
|
@@ -546,8 +592,8 @@ export const VxeUIPluginMenu = {
|
|
|
546
592
|
const tableProps = $table
|
|
547
593
|
const { mouseConfig } = tableProps
|
|
548
594
|
const mouseOpts = $table.computeMouseOpts
|
|
549
|
-
if (mouseConfig && mouseOpts.area) {
|
|
550
|
-
const cellAreas =
|
|
595
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
596
|
+
const cellAreas = mouseOpts.area ? $table.getCellAreas() : []
|
|
551
597
|
cellAreas.forEach(areaItem => {
|
|
552
598
|
const { rows, cols } = areaItem
|
|
553
599
|
rows.forEach(row => {
|
|
@@ -581,7 +627,7 @@ export const VxeUIPluginMenu = {
|
|
|
581
627
|
const tableProps = $table
|
|
582
628
|
const { mouseConfig } = tableProps
|
|
583
629
|
const mouseOpts = $table.computeMouseOpts
|
|
584
|
-
if (mouseConfig && mouseOpts.area) {
|
|
630
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
585
631
|
const { visibleData } = $table.getTableData()
|
|
586
632
|
const { visibleColumn } = $table.getTableColumn()
|
|
587
633
|
$table.setCellAreas([{
|
|
@@ -602,7 +648,7 @@ export const VxeUIPluginMenu = {
|
|
|
602
648
|
const tableProps = $table
|
|
603
649
|
const { mouseConfig } = tableProps
|
|
604
650
|
const mouseOpts = $table.computeMouseOpts
|
|
605
|
-
if (mouseConfig && mouseOpts.area) {
|
|
651
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
606
652
|
const { visibleColumn } = $table.getTableColumn()
|
|
607
653
|
const cellAreas = $table.getCellAreas()
|
|
608
654
|
if (cellAreas.length === 1) {
|
|
@@ -633,7 +679,7 @@ export const VxeUIPluginMenu = {
|
|
|
633
679
|
const tableProps = $table
|
|
634
680
|
const { mouseConfig } = tableProps
|
|
635
681
|
const mouseOpts = $table.computeMouseOpts
|
|
636
|
-
if (mouseConfig && mouseOpts.area) {
|
|
682
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
637
683
|
const { visibleColumn } = $table.getTableColumn()
|
|
638
684
|
const cellAreas = $table.getCellAreas()
|
|
639
685
|
if (cellAreas.length === 1) {
|
|
@@ -664,7 +710,7 @@ export const VxeUIPluginMenu = {
|
|
|
664
710
|
const tableProps = $table
|
|
665
711
|
const { mouseConfig } = tableProps
|
|
666
712
|
const mouseOpts = $table.computeMouseOpts
|
|
667
|
-
if (mouseConfig && mouseOpts.area) {
|
|
713
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
668
714
|
const { visibleData } = $table.getTableData()
|
|
669
715
|
const cellAreas = $table.getCellAreas()
|
|
670
716
|
if (cellAreas.length === 1) {
|
|
@@ -695,7 +741,7 @@ export const VxeUIPluginMenu = {
|
|
|
695
741
|
const tableProps = $table
|
|
696
742
|
const { mouseConfig } = tableProps
|
|
697
743
|
const mouseOpts = $table.computeMouseOpts
|
|
698
|
-
if (mouseConfig && mouseOpts.area) {
|
|
744
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
699
745
|
const { visibleData } = $table.getTableData()
|
|
700
746
|
const cellAreas = $table.getCellAreas()
|
|
701
747
|
if (cellAreas.length === 1) {
|
|
@@ -727,7 +773,7 @@ export const VxeUIPluginMenu = {
|
|
|
727
773
|
const tableProps = $table
|
|
728
774
|
const { mouseConfig } = tableProps
|
|
729
775
|
const mouseOpts = $table.computeMouseOpts
|
|
730
|
-
if (mouseConfig && mouseOpts.area) {
|
|
776
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
731
777
|
const cellAreas = $table.getCellAreas()
|
|
732
778
|
if (cellAreas && cellAreas.length) {
|
|
733
779
|
cellAreas.forEach(areaItem => {
|
|
@@ -799,6 +845,14 @@ export const VxeUIPluginMenu = {
|
|
|
799
845
|
handleCopyOrCut(params as VxeGlobalMenusHandles.TableMenuMethodParams & { $table: VxeTableConstructor & VxeTablePrivateMethods })
|
|
800
846
|
}
|
|
801
847
|
},
|
|
848
|
+
/**
|
|
849
|
+
* 复制单元格数据的值;用于 mouse-config.area 功能,复制区域范围内的单元格数据,支持 Excel 和 WPS
|
|
850
|
+
*/
|
|
851
|
+
COPY_AREA_CELL: {
|
|
852
|
+
tableMenuMethod (params) {
|
|
853
|
+
handleCopyOrCut(params as VxeGlobalMenusHandles.TableMenuMethodParams & { $table: VxeTableConstructor & VxeTablePrivateMethods })
|
|
854
|
+
}
|
|
855
|
+
},
|
|
802
856
|
/**
|
|
803
857
|
* 剪贴单元格数据的值;如果启用 mouse-config.area 功能,则剪贴区域范围内的单元格数据,支持 Excel 和 WPS
|
|
804
858
|
*/
|
|
@@ -807,6 +861,14 @@ export const VxeUIPluginMenu = {
|
|
|
807
861
|
handleCopyOrCut(params as VxeGlobalMenusHandles.TableMenuMethodParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }, true)
|
|
808
862
|
}
|
|
809
863
|
},
|
|
864
|
+
/**
|
|
865
|
+
* 剪贴单元格数据的值;用于 mouse-config.area 功能,剪贴区域范围内的单元格数据,支持 Excel 和 WPS
|
|
866
|
+
*/
|
|
867
|
+
CUT_AREA_CELL: {
|
|
868
|
+
tableMenuMethod (params) {
|
|
869
|
+
handleCopyOrCut(params as VxeGlobalMenusHandles.TableMenuMethodParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }, true)
|
|
870
|
+
}
|
|
871
|
+
},
|
|
810
872
|
/**
|
|
811
873
|
* 粘贴从表格中被复制的数据;如果启用 mouse-config.area 功能,则粘贴区域范围内的单元格数据,不支持读取剪贴板
|
|
812
874
|
*/
|
|
@@ -816,7 +878,7 @@ export const VxeUIPluginMenu = {
|
|
|
816
878
|
const tableProps = $table
|
|
817
879
|
const { mouseConfig } = tableProps
|
|
818
880
|
const mouseOpts = $table.computeMouseOpts
|
|
819
|
-
if (mouseConfig && mouseOpts.area) {
|
|
881
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
820
882
|
$table.triggerPasteCellAreaEvent($event)
|
|
821
883
|
} else {
|
|
822
884
|
const clipboard = getClipboardObj()
|
|
@@ -827,6 +889,20 @@ export const VxeUIPluginMenu = {
|
|
|
827
889
|
}
|
|
828
890
|
}
|
|
829
891
|
},
|
|
892
|
+
/**
|
|
893
|
+
* 粘贴从表格中被复制的数据;用于 mouse-config.area 功能,粘贴区域范围内的单元格数据,不支持读取剪贴板
|
|
894
|
+
*/
|
|
895
|
+
PASTE_AREA_CELL: {
|
|
896
|
+
tableMenuMethod (params) {
|
|
897
|
+
const { $event, $table } = params as VxeGlobalMenusHandles.TableMenuMethodParams & { $table: VxeTableConstructor & VxeTablePrivateMethods }
|
|
898
|
+
const tableProps = $table
|
|
899
|
+
const { mouseConfig } = tableProps
|
|
900
|
+
const mouseOpts = $table.computeMouseOpts
|
|
901
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
902
|
+
$table.triggerPasteCellAreaEvent($event)
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
},
|
|
830
906
|
/**
|
|
831
907
|
* 如果启用 mouse-config.area 功能,如果所选区域内已存在合并单元格,则取消临时合并,否则临时合并
|
|
832
908
|
*/
|
|
@@ -948,7 +1024,7 @@ export const VxeUIPluginMenu = {
|
|
|
948
1024
|
const { mouseConfig } = tableProps
|
|
949
1025
|
const mouseOpts = $table.computeMouseOpts
|
|
950
1026
|
$table.insert(menu.params || {}).then(({ rows }) => {
|
|
951
|
-
if (column && mouseConfig && mouseOpts.area) {
|
|
1027
|
+
if (column && hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
952
1028
|
$table.setCellAreas([
|
|
953
1029
|
{ startRow: XEUtils.first(rows), endRow: XEUtils.last(rows), startColumn: column, endColumn: column }
|
|
954
1030
|
])
|
|
@@ -966,7 +1042,7 @@ export const VxeUIPluginMenu = {
|
|
|
966
1042
|
const { mouseConfig } = tableProps
|
|
967
1043
|
const mouseOpts = $table.computeMouseOpts;
|
|
968
1044
|
(row ? $table.insertAt(menu.params || {}, row) : $table.insert(menu.params || {})).then(({ rows }) => {
|
|
969
|
-
if (column && mouseConfig && mouseOpts.area) {
|
|
1045
|
+
if (column && hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
970
1046
|
$table.setCellAreas([
|
|
971
1047
|
{ startRow: XEUtils.first(rows), endRow: XEUtils.last(rows), startColumn: column, endColumn: column }
|
|
972
1048
|
])
|
|
@@ -987,7 +1063,7 @@ export const VxeUIPluginMenu = {
|
|
|
987
1063
|
if (size) {
|
|
988
1064
|
const records = XEUtils.range(0, size).map(() => Object.assign({}, menu.params));
|
|
989
1065
|
(row ? $table.insertAt(records, row) : $table.insert(records)).then(({ rows }) => {
|
|
990
|
-
if (column && mouseConfig && mouseOpts.area) {
|
|
1066
|
+
if (column && hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
991
1067
|
$table.setCellAreas([
|
|
992
1068
|
{ startRow: XEUtils.first(rows), endRow: XEUtils.last(rows), startColumn: column, endColumn: column }
|
|
993
1069
|
])
|
|
@@ -1007,7 +1083,7 @@ export const VxeUIPluginMenu = {
|
|
|
1007
1083
|
const { mouseConfig } = tableProps
|
|
1008
1084
|
const mouseOpts = $table.computeMouseOpts;
|
|
1009
1085
|
(row ? $table.insertNextAt(menu.params || {}, row) : $table.insert(menu.params || {})).then(({ rows }) => {
|
|
1010
|
-
if (column && mouseConfig && mouseOpts.area) {
|
|
1086
|
+
if (column && hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
1011
1087
|
$table.setCellAreas([
|
|
1012
1088
|
{ startRow: XEUtils.first(rows), endRow: XEUtils.last(rows), startColumn: column, endColumn: column }
|
|
1013
1089
|
])
|
|
@@ -1028,7 +1104,7 @@ export const VxeUIPluginMenu = {
|
|
|
1028
1104
|
if (size) {
|
|
1029
1105
|
const records = XEUtils.range(0, size).map(() => Object.assign({}, menu.params));
|
|
1030
1106
|
(row ? $table.insertNextAt(records, row) : $table.insert(records)).then(({ rows }) => {
|
|
1031
|
-
if (column && mouseConfig && mouseOpts.area) {
|
|
1107
|
+
if (column && hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
1032
1108
|
$table.setCellAreas([
|
|
1033
1109
|
{ startRow: XEUtils.first(rows), endRow: XEUtils.last(rows), startColumn: column, endColumn: column }
|
|
1034
1110
|
])
|
|
@@ -1194,8 +1270,8 @@ export const VxeUIPluginMenu = {
|
|
|
1194
1270
|
const tableProps = $table
|
|
1195
1271
|
const { mouseConfig } = tableProps
|
|
1196
1272
|
const mouseOpts = $table.computeMouseOpts
|
|
1197
|
-
if (mouseConfig && mouseOpts.area) {
|
|
1198
|
-
const cellAreas =
|
|
1273
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
1274
|
+
const cellAreas = $table.getCellAreas()
|
|
1199
1275
|
cellAreas.forEach(areaItem => {
|
|
1200
1276
|
const { rows } = areaItem
|
|
1201
1277
|
$table.remove(rows)
|