aloha-vue 2.83.0 → 2.84.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/CHANGELOG.md +4 -0
- package/dist/aloha-vue.es.js +129 -121
- package/dist/aloha-vue.umd.js +55 -55
- package/package.json +1 -1
- package/src/ATable/ATable.js +26 -20
- package/src/ATable/__tests__/ATable.MultipleActionRows.test.js +86 -0
- package/src/ATable/compositionAPI/CountAPI.js +3 -2
- package/src/ATable/compositionAPI/MultipleActionAPI.js +1 -1
- package/src/ATable/compositionAPI/RowsAPI.js +15 -2
- package/src/ATable/compositionAPI/VariablesAPI.js +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aloha-vue",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.84.0",
|
|
4
4
|
"description": "Aloha-vue is a JavaScript library that provides a wide range of accessible components and directives for Vue.js. Accessibility is of paramount importance to us, and we have designed all our components to meet accessibility compliance criteria. This library is a valuable tool for frontend developers and has already been used in three projects, including two large-scale ones",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"accessibility compliance criteria",
|
package/src/ATable/ATable.js
CHANGED
|
@@ -530,12 +530,9 @@ export default {
|
|
|
530
530
|
modelIsTableWithoutScrollComputed,
|
|
531
531
|
} = SimpleTableAPI(props);
|
|
532
532
|
|
|
533
|
-
const {
|
|
534
|
-
countAllRowsLocal,
|
|
535
|
-
} = CountAPI(props);
|
|
536
|
-
|
|
537
533
|
const {
|
|
538
534
|
columnsScrollInvisible,
|
|
535
|
+
currentMultipleActions,
|
|
539
536
|
indexFirstScrollInvisibleColumn,
|
|
540
537
|
isMultipleActionsActive,
|
|
541
538
|
modelColumnsVisibleLocal,
|
|
@@ -572,10 +569,10 @@ export default {
|
|
|
572
569
|
const {
|
|
573
570
|
columnsOrderedFromSimpleTable,
|
|
574
571
|
renderedGroupedColumns,
|
|
575
|
-
} = ColumnsGroupedAPI(props, {
|
|
576
|
-
modelSort: modelSortLocal,
|
|
577
|
-
slots: context.slots,
|
|
578
|
-
});
|
|
572
|
+
} = ColumnsGroupedAPI(props, {
|
|
573
|
+
modelSort: modelSortLocal,
|
|
574
|
+
slots: context.slots,
|
|
575
|
+
});
|
|
579
576
|
|
|
580
577
|
const {
|
|
581
578
|
columnIdsGroupByLocked,
|
|
@@ -609,6 +606,7 @@ export default {
|
|
|
609
606
|
|
|
610
607
|
const {
|
|
611
608
|
addRow,
|
|
609
|
+
dataFiltered,
|
|
612
610
|
deleteRow,
|
|
613
611
|
hasRows,
|
|
614
612
|
rowsLocal,
|
|
@@ -617,13 +615,21 @@ export default {
|
|
|
617
615
|
stopRenderRows,
|
|
618
616
|
updateRow,
|
|
619
617
|
} = RowsAPI(props, {
|
|
618
|
+
currentMultipleActions,
|
|
620
619
|
dataSorted,
|
|
620
|
+
isMultipleActionsActive,
|
|
621
621
|
limit,
|
|
622
622
|
offset,
|
|
623
623
|
setEmptySelectedRowsIndexes,
|
|
624
624
|
usePaginationLocal,
|
|
625
625
|
});
|
|
626
626
|
|
|
627
|
+
const {
|
|
628
|
+
countAllRowsLocal,
|
|
629
|
+
} = CountAPI(props, {
|
|
630
|
+
data: dataFiltered,
|
|
631
|
+
});
|
|
632
|
+
|
|
627
633
|
const {
|
|
628
634
|
columnActionsBtnGroupMaxWidthStyle,
|
|
629
635
|
columnActionsWidthLocal,
|
|
@@ -678,7 +684,6 @@ export default {
|
|
|
678
684
|
areAllVisibleRowsSelected,
|
|
679
685
|
areSomeRowsSelected,
|
|
680
686
|
closeMultipleActionsActive,
|
|
681
|
-
currentMultipleActions,
|
|
682
687
|
hasMultipleActions,
|
|
683
688
|
selectedRows,
|
|
684
689
|
selectedRowsIndexes,
|
|
@@ -688,6 +693,7 @@ export default {
|
|
|
688
693
|
toggleMultipleActionsActive,
|
|
689
694
|
} = MultipleActionAPI(props, context, {
|
|
690
695
|
checkVisibleColumns,
|
|
696
|
+
currentMultipleActions,
|
|
691
697
|
isMultipleActionsActive,
|
|
692
698
|
rowsLocalAll,
|
|
693
699
|
rowsLocalLength,
|
|
@@ -1001,7 +1007,7 @@ export default {
|
|
|
1001
1007
|
onSetSelectedRowsIndexes: this.setSelectedRowsIndexes,
|
|
1002
1008
|
columnsForRender: this.renderedGroupedColumns,
|
|
1003
1009
|
}) :
|
|
1004
|
-
h(ATableHeader, {
|
|
1010
|
+
h(ATableHeader, {
|
|
1005
1011
|
areAllRowsSelected: this.areAllRowsSelected,
|
|
1006
1012
|
areAllVisibleRowsSelected: this.areAllVisibleRowsSelected,
|
|
1007
1013
|
areSomeRowsSelected: this.areSomeRowsSelected,
|
|
@@ -1014,8 +1020,8 @@ export default {
|
|
|
1014
1020
|
rowsLocalLength: this.rowsLocalLength,
|
|
1015
1021
|
showFirstSortingSequenceNumber: this.showFirstSortingSequenceNumber,
|
|
1016
1022
|
sortingSequenceNumberClass: this.sortingSequenceNumberClass,
|
|
1017
|
-
onSetSelectedRowsIndexes: this.setSelectedRowsIndexes,
|
|
1018
|
-
}, this.$slots),
|
|
1023
|
+
onSetSelectedRowsIndexes: this.setSelectedRowsIndexes,
|
|
1024
|
+
}, this.$slots),
|
|
1019
1025
|
h("div", {
|
|
1020
1026
|
class: "a_table__loading",
|
|
1021
1027
|
}, [
|
|
@@ -1050,10 +1056,10 @@ export default {
|
|
|
1050
1056
|
level: 1,
|
|
1051
1057
|
row,
|
|
1052
1058
|
rowActionsClass: this.rowActionsClass,
|
|
1053
|
-
rowClass: this.rowClass,
|
|
1054
|
-
rowIndex,
|
|
1055
|
-
rowIndexPath: `${ rowIndex }`,
|
|
1056
|
-
rowsLength: this.rowsLocal.length,
|
|
1059
|
+
rowClass: this.rowClass,
|
|
1060
|
+
rowIndex,
|
|
1061
|
+
rowIndexPath: `${ rowIndex }`,
|
|
1062
|
+
rowsLength: this.rowsLocal.length,
|
|
1057
1063
|
selectedRowsIndexes: this.selectedRowsIndexes,
|
|
1058
1064
|
onSetSelectedRowsIndexes: this.setSelectedRowsIndexes,
|
|
1059
1065
|
}, {
|
|
@@ -1101,10 +1107,10 @@ export default {
|
|
|
1101
1107
|
level: 1,
|
|
1102
1108
|
row,
|
|
1103
1109
|
rowActionsClass: this.rowActionsClass,
|
|
1104
|
-
rowClass: this.rowClass,
|
|
1105
|
-
rowIndex,
|
|
1106
|
-
rowIndexPath: `${ rowIndex }`,
|
|
1107
|
-
rowsLength: this.rowsFooter.length,
|
|
1110
|
+
rowClass: this.rowClass,
|
|
1111
|
+
rowIndex,
|
|
1112
|
+
rowIndexPath: `${ rowIndex }`,
|
|
1113
|
+
rowsLength: this.rowsFooter.length,
|
|
1108
1114
|
selectedRowsIndexes: this.selectedRowsIndexes,
|
|
1109
1115
|
onSetSelectedRowsIndexes: this.setSelectedRowsIndexes,
|
|
1110
1116
|
}, {
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import {
|
|
2
|
+
nextTick,
|
|
3
|
+
ref,
|
|
4
|
+
} from "vue";
|
|
5
|
+
import {
|
|
6
|
+
describe,
|
|
7
|
+
expect,
|
|
8
|
+
it,
|
|
9
|
+
vi,
|
|
10
|
+
} from "vitest";
|
|
11
|
+
|
|
12
|
+
import CountAPI from "../compositionAPI/CountAPI";
|
|
13
|
+
import MultipleActionAPI from "../compositionAPI/MultipleActionAPI";
|
|
14
|
+
import RowsAPI from "../compositionAPI/RowsAPI";
|
|
15
|
+
import VariablesAPI from "../compositionAPI/VariablesAPI";
|
|
16
|
+
|
|
17
|
+
describe("ATable multiple action row filtering", () => {
|
|
18
|
+
it("filters before pagination, updates counts and selection, and restores rows on close", async() => {
|
|
19
|
+
const data = [{ id: 1 }, { id: 2 }, { id: 3 }, { id: 4 }];
|
|
20
|
+
const callback = vi.fn(({ row }) => row.id === 2);
|
|
21
|
+
const props = {
|
|
22
|
+
clearSelectedRowsOnDataChange: true,
|
|
23
|
+
data,
|
|
24
|
+
multipleActions: [],
|
|
25
|
+
pagination: { isOutside: false },
|
|
26
|
+
rowsCountRenderPerTick: 0,
|
|
27
|
+
};
|
|
28
|
+
const {
|
|
29
|
+
currentMultipleActions,
|
|
30
|
+
isMultipleActionsActive,
|
|
31
|
+
} = VariablesAPI();
|
|
32
|
+
const clearSelection = vi.fn();
|
|
33
|
+
const rows = RowsAPI(props, {
|
|
34
|
+
currentMultipleActions,
|
|
35
|
+
dataSorted: ref(data),
|
|
36
|
+
isMultipleActionsActive,
|
|
37
|
+
limit: ref(2),
|
|
38
|
+
offset: ref(0),
|
|
39
|
+
setEmptySelectedRowsIndexes: clearSelection,
|
|
40
|
+
usePaginationLocal: ref(true),
|
|
41
|
+
});
|
|
42
|
+
const { countAllRowsLocal } = CountAPI(props, { data: rows.dataFiltered });
|
|
43
|
+
const actions = MultipleActionAPI(props, { emit: vi.fn() }, {
|
|
44
|
+
currentMultipleActions,
|
|
45
|
+
isMultipleActionsActive,
|
|
46
|
+
rowsLocalAll: rows.rowsLocalAll,
|
|
47
|
+
rowsLocalLength: rows.rowsLocalLength,
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
currentMultipleActions.value = { isRowHiddenCallback: callback };
|
|
51
|
+
expect(rows.rowsLocal.value).toEqual(data.slice(0, 2));
|
|
52
|
+
expect(callback).not.toHaveBeenCalled();
|
|
53
|
+
|
|
54
|
+
isMultipleActionsActive.value = true;
|
|
55
|
+
await nextTick();
|
|
56
|
+
|
|
57
|
+
expect(rows.rowsLocal.value).toEqual([data[0], data[2]]);
|
|
58
|
+
expect(countAllRowsLocal.value).toBe(3);
|
|
59
|
+
expect(callback).toHaveBeenCalledWith({ row: data[1], rowIndex: 1 });
|
|
60
|
+
expect(clearSelection).toHaveBeenCalledOnce();
|
|
61
|
+
actions.setSelectedRowsIndexes({ isAll: true });
|
|
62
|
+
expect(actions.selectedRows.value).toEqual([data[0], data[2]]);
|
|
63
|
+
|
|
64
|
+
actions.closeMultipleActionsActive();
|
|
65
|
+
await nextTick();
|
|
66
|
+
|
|
67
|
+
expect(rows.rowsLocal.value).toEqual(data.slice(0, 2));
|
|
68
|
+
expect(countAllRowsLocal.value).toBe(4);
|
|
69
|
+
expect(actions.selectedRows.value).toEqual([]);
|
|
70
|
+
expect(props.data).toEqual(data);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it.each([undefined, {}, { isRowHiddenCallback: true }, { isHiddenCallback: () => true }])(
|
|
74
|
+
"keeps rows when the active action has no row callback: %j",
|
|
75
|
+
action => {
|
|
76
|
+
const data = [{ id: 1 }];
|
|
77
|
+
const { rowsLocal } = RowsAPI({ pagination: {}, rowsCountRenderPerTick: 0 }, {
|
|
78
|
+
currentMultipleActions: ref(action),
|
|
79
|
+
dataSorted: ref(data),
|
|
80
|
+
isMultipleActionsActive: ref(true),
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
expect(rowsLocal.value).toEqual(data);
|
|
84
|
+
},
|
|
85
|
+
);
|
|
86
|
+
});
|
|
@@ -14,9 +14,10 @@ import {
|
|
|
14
14
|
isPlainObject,
|
|
15
15
|
} from "lodash-es";
|
|
16
16
|
|
|
17
|
-
export default function CountAPI(props
|
|
17
|
+
export default function CountAPI(props, {
|
|
18
|
+
data = toRef(props, "data"),
|
|
19
|
+
} = {}) {
|
|
18
20
|
const countAllRows = toRef(props, "countAllRows");
|
|
19
|
-
const data = toRef(props, "data");
|
|
20
21
|
const isTree = toRef(props, "isTree");
|
|
21
22
|
const keyChildren = toRef(props, "keyChildren");
|
|
22
23
|
const keyCountAllRowsInData = toRef(props, "keyCountAllRowsInData");
|
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
|
|
22
22
|
export default function MultipleActionAPI(props, { emit }, {
|
|
23
23
|
checkVisibleColumns = () => {},
|
|
24
|
+
currentMultipleActions = ref(undefined),
|
|
24
25
|
isMultipleActionsActive = ref(undefined),
|
|
25
26
|
rowsLocalAll = computed(() => []),
|
|
26
27
|
rowsLocalLength = computed(() => 0),
|
|
@@ -28,7 +29,6 @@ export default function MultipleActionAPI(props, { emit }, {
|
|
|
28
29
|
const id = toRef(props, "id");
|
|
29
30
|
const multipleActions = toRef(props, "multipleActions");
|
|
30
31
|
|
|
31
|
-
const currentMultipleActions = ref(undefined);
|
|
32
32
|
const selectedRowsIndexes = ref({});
|
|
33
33
|
const areAllRowsSelected = ref(false);
|
|
34
34
|
|
|
@@ -7,11 +7,14 @@ import {
|
|
|
7
7
|
|
|
8
8
|
import {
|
|
9
9
|
isEqual,
|
|
10
|
+
isFunction,
|
|
10
11
|
map,
|
|
11
12
|
} from "lodash-es";
|
|
12
13
|
|
|
13
14
|
export default function RowsAPI(props, {
|
|
15
|
+
currentMultipleActions = ref(undefined),
|
|
14
16
|
dataSorted = computed(() => []),
|
|
17
|
+
isMultipleActionsActive = ref(undefined),
|
|
15
18
|
limit = ref(0),
|
|
16
19
|
offset = ref(0),
|
|
17
20
|
setEmptySelectedRowsIndexes = () => {},
|
|
@@ -27,13 +30,22 @@ export default function RowsAPI(props, {
|
|
|
27
30
|
let rowsLocalIndex = 0;
|
|
28
31
|
let rowsLocalInterval = undefined;
|
|
29
32
|
|
|
33
|
+
const dataFiltered = computed(() => {
|
|
34
|
+
if (isMultipleActionsActive.value && isFunction(currentMultipleActions.value?.isRowHiddenCallback)) {
|
|
35
|
+
return dataSorted.value.filter((row, rowIndex) => {
|
|
36
|
+
return !currentMultipleActions.value.isRowHiddenCallback({ row, rowIndex });
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
return dataSorted.value;
|
|
40
|
+
});
|
|
41
|
+
|
|
30
42
|
const dataPaginated = computed(() => {
|
|
31
43
|
if (limit.value && !pagination.value.isOutside && usePaginationLocal.value) {
|
|
32
44
|
const INDEX_START = offset.value;
|
|
33
45
|
const INDEX_END = INDEX_START + limit.value;
|
|
34
|
-
return
|
|
46
|
+
return dataFiltered.value.slice(INDEX_START, INDEX_END);
|
|
35
47
|
}
|
|
36
|
-
return
|
|
48
|
+
return dataFiltered.value;
|
|
37
49
|
});
|
|
38
50
|
|
|
39
51
|
const rowsLocalAll = computed(() => {
|
|
@@ -110,6 +122,7 @@ export default function RowsAPI(props, {
|
|
|
110
122
|
|
|
111
123
|
return {
|
|
112
124
|
addRow,
|
|
125
|
+
dataFiltered,
|
|
113
126
|
deleteRow,
|
|
114
127
|
hasRows,
|
|
115
128
|
rowsLocal,
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
|
|
5
5
|
export default function VariablesAPI() {
|
|
6
6
|
const columnsScrollInvisible = ref([]);
|
|
7
|
+
const currentMultipleActions = ref(undefined);
|
|
7
8
|
const indexFirstScrollInvisibleColumn = ref(undefined);
|
|
8
9
|
const isMultipleActionsActive = ref(undefined);
|
|
9
10
|
const modelColumnsVisibleLocal = ref({});
|
|
@@ -12,6 +13,7 @@ export default function VariablesAPI() {
|
|
|
12
13
|
|
|
13
14
|
return {
|
|
14
15
|
columnsScrollInvisible,
|
|
16
|
+
currentMultipleActions,
|
|
15
17
|
indexFirstScrollInvisibleColumn,
|
|
16
18
|
isMultipleActionsActive,
|
|
17
19
|
modelColumnsVisibleLocal,
|