aloha-vue 2.60.0 → 2.61.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 +8 -0
- package/dist/aloha-vue.css +9 -0
- package/dist/aloha-vue.css.map +1 -1
- package/dist/aloha-vue.es.js +9553 -9379
- package/dist/aloha-vue.umd.js +49 -49
- package/package.json +1 -1
- package/scss/components/ATableForm.scss +13 -0
- package/src/ATableForm/ATableForm.js +18 -6
- package/src/ATableForm/ATableFormCellList/ATableFormCellList.js +122 -0
- package/src/ATableForm/ATableFormCellList/compositionAPI/DataAPI.js +60 -0
- package/src/ATableForm/ATableFormRow/ATableFormRow.js +463 -443
- package/src/ATableForm/ATableFormRow/compositionAPI/EditAPI.js +102 -98
- package/src/ATableForm/__tests__/ATableForm.DragAndDropAPI.test.js +3 -1
- package/src/ATableForm/__tests__/ATableForm.ListView.test.js +255 -0
- package/src/ATableForm/compositionAPI/ColumnsAPI.js +40 -39
- package/src/ATableForm/compositionAPI/DragAndDropAPI.js +6 -3
- package/src/ATableForm/compositionAPI/EditAPI.js +127 -119
- package/src/ui/AForm/AForm.js +14 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aloha-vue",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.61.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",
|
|
@@ -53,6 +53,19 @@
|
|
|
53
53
|
background-color: var(--a_table_form_bg);
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
.a_table_form__table_list {
|
|
57
|
+
.a_table_form__cell_reorder,
|
|
58
|
+
.a_table_form__cell_actions {
|
|
59
|
+
vertical-align: middle;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.a_table_form__cell_list {
|
|
64
|
+
.a_form {
|
|
65
|
+
min-width: 0;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
56
69
|
.a_table_form__cell {
|
|
57
70
|
padding: var(--a_table_form_cell_padding_y) var(--a_table_form_cell_padding_x);
|
|
58
71
|
border-top: 1px solid var(--a_table_form_border_color);
|
|
@@ -37,6 +37,12 @@ export default {
|
|
|
37
37
|
required: false,
|
|
38
38
|
default: () => ({}),
|
|
39
39
|
},
|
|
40
|
+
|
|
41
|
+
/*
|
|
42
|
+
* Supported callbacks:
|
|
43
|
+
* add: () => boolean
|
|
44
|
+
* delete, dnd, edit: ({ row, rowIndex }) => boolean
|
|
45
|
+
*/
|
|
40
46
|
actionsDisabledCallback: {
|
|
41
47
|
type: Object,
|
|
42
48
|
required: false,
|
|
@@ -66,11 +72,6 @@ export default {
|
|
|
66
72
|
required: false,
|
|
67
73
|
default: "",
|
|
68
74
|
},
|
|
69
|
-
dndDisabledCallback: {
|
|
70
|
-
type: Function,
|
|
71
|
-
required: false,
|
|
72
|
-
default: undefined,
|
|
73
|
-
},
|
|
74
75
|
changeModel: {
|
|
75
76
|
type: Function,
|
|
76
77
|
required: false,
|
|
@@ -166,6 +167,12 @@ export default {
|
|
|
166
167
|
required: false,
|
|
167
168
|
default: undefined,
|
|
168
169
|
},
|
|
170
|
+
rowView: {
|
|
171
|
+
type: String,
|
|
172
|
+
required: false,
|
|
173
|
+
default: "table",
|
|
174
|
+
validator: value => ["list", "table"].includes(value),
|
|
175
|
+
},
|
|
169
176
|
rows: {
|
|
170
177
|
type: Array,
|
|
171
178
|
required: false,
|
|
@@ -369,10 +376,11 @@ export default {
|
|
|
369
376
|
"a_table_form__table",
|
|
370
377
|
{
|
|
371
378
|
a_table_form_drag_active: this.draggedRowIndex !== undefined,
|
|
379
|
+
a_table_form__table_list: this.rowView === "list",
|
|
372
380
|
},
|
|
373
381
|
],
|
|
374
382
|
}, [
|
|
375
|
-
h("thead", {
|
|
383
|
+
this.rowView === "table" && h("thead", {
|
|
376
384
|
class: "a_table_form__head",
|
|
377
385
|
}, [
|
|
378
386
|
h(ATableFormRow, {
|
|
@@ -409,6 +417,7 @@ export default {
|
|
|
409
417
|
onEditRow: this.onEditRow,
|
|
410
418
|
row: {},
|
|
411
419
|
rowIndex: 0,
|
|
420
|
+
rowView: this.rowView,
|
|
412
421
|
rows: this.rows,
|
|
413
422
|
saveRow: this.saveRow,
|
|
414
423
|
texts: this.textsLocal,
|
|
@@ -466,6 +475,7 @@ export default {
|
|
|
466
475
|
row,
|
|
467
476
|
rowClass: this.rowClass,
|
|
468
477
|
rowIndex,
|
|
478
|
+
rowView: this.rowView,
|
|
469
479
|
rows: this.rows,
|
|
470
480
|
saveRow: this.saveRow,
|
|
471
481
|
texts: this.textsLocal,
|
|
@@ -523,6 +533,7 @@ export default {
|
|
|
523
533
|
row: {},
|
|
524
534
|
rowClass: this.rowClass,
|
|
525
535
|
rowIndex: this.rows.length,
|
|
536
|
+
rowView: this.rowView,
|
|
526
537
|
rows: this.rows,
|
|
527
538
|
saveRow: this.addRow,
|
|
528
539
|
texts: this.textsLocal,
|
|
@@ -585,6 +596,7 @@ export default {
|
|
|
585
596
|
row,
|
|
586
597
|
rowClass: this.rowClass,
|
|
587
598
|
rowIndex,
|
|
599
|
+
rowView: this.rowView,
|
|
588
600
|
rows: this.rowsFooter,
|
|
589
601
|
saveRow: this.saveRow,
|
|
590
602
|
texts: this.textsLocal,
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import {
|
|
2
|
+
computed,
|
|
3
|
+
h,
|
|
4
|
+
} from "vue";
|
|
5
|
+
|
|
6
|
+
import AForm from "../../ui/AForm/AForm";
|
|
7
|
+
|
|
8
|
+
import DataAPI from "./compositionAPI/DataAPI";
|
|
9
|
+
|
|
10
|
+
function hasItemWithId(items, id) {
|
|
11
|
+
return items?.some(item => {
|
|
12
|
+
return item?.id === id || hasItemWithId(item?.children, id);
|
|
13
|
+
}) || false;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export default {
|
|
17
|
+
name: "ATableFormCellList",
|
|
18
|
+
props: {
|
|
19
|
+
columns: {
|
|
20
|
+
type: Array,
|
|
21
|
+
required: true,
|
|
22
|
+
},
|
|
23
|
+
errors: {
|
|
24
|
+
type: Object,
|
|
25
|
+
required: false,
|
|
26
|
+
default: () => ({}),
|
|
27
|
+
},
|
|
28
|
+
id: {
|
|
29
|
+
type: String,
|
|
30
|
+
required: true,
|
|
31
|
+
},
|
|
32
|
+
isEditable: {
|
|
33
|
+
type: Boolean,
|
|
34
|
+
required: false,
|
|
35
|
+
default: false,
|
|
36
|
+
},
|
|
37
|
+
isEditMode: {
|
|
38
|
+
type: Boolean,
|
|
39
|
+
required: false,
|
|
40
|
+
default: false,
|
|
41
|
+
},
|
|
42
|
+
isFooter: {
|
|
43
|
+
type: Boolean,
|
|
44
|
+
required: false,
|
|
45
|
+
default: false,
|
|
46
|
+
},
|
|
47
|
+
row: {
|
|
48
|
+
type: Object,
|
|
49
|
+
required: true,
|
|
50
|
+
},
|
|
51
|
+
rowData: {
|
|
52
|
+
type: Object,
|
|
53
|
+
required: false,
|
|
54
|
+
default: undefined,
|
|
55
|
+
},
|
|
56
|
+
rowIndex: {
|
|
57
|
+
type: Number,
|
|
58
|
+
required: true,
|
|
59
|
+
},
|
|
60
|
+
rows: {
|
|
61
|
+
type: Array,
|
|
62
|
+
required: true,
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
emits: [
|
|
66
|
+
"updateRowData",
|
|
67
|
+
],
|
|
68
|
+
setup(props) {
|
|
69
|
+
const {
|
|
70
|
+
dataForm,
|
|
71
|
+
} = DataAPI(props);
|
|
72
|
+
|
|
73
|
+
return {
|
|
74
|
+
dataForm,
|
|
75
|
+
rowDataLocal: computed(() => props.rowData || props.row),
|
|
76
|
+
};
|
|
77
|
+
},
|
|
78
|
+
methods: {
|
|
79
|
+
updateRowData({
|
|
80
|
+
fullModel,
|
|
81
|
+
id,
|
|
82
|
+
item,
|
|
83
|
+
model,
|
|
84
|
+
}) {
|
|
85
|
+
const column = this.columns.find(columnLocal => {
|
|
86
|
+
return columnLocal.id === id ||
|
|
87
|
+
hasItemWithId(columnLocal.formElement?.children, id);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
this.$emit("updateRowData", {
|
|
91
|
+
column,
|
|
92
|
+
columnId: id,
|
|
93
|
+
fullModel,
|
|
94
|
+
item,
|
|
95
|
+
model,
|
|
96
|
+
});
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
render() {
|
|
100
|
+
return h("td", {
|
|
101
|
+
class: [
|
|
102
|
+
"a_table_form__cell",
|
|
103
|
+
"a_table_form__cell_td",
|
|
104
|
+
"a_table_form__cell_list",
|
|
105
|
+
],
|
|
106
|
+
}, [
|
|
107
|
+
h(AForm, {
|
|
108
|
+
data: this.dataForm,
|
|
109
|
+
errors: this.errors,
|
|
110
|
+
idPrefix: this.id,
|
|
111
|
+
modelValue: this.rowDataLocal,
|
|
112
|
+
readonly: this.isFooter || !this.isEditable,
|
|
113
|
+
showErrors: true,
|
|
114
|
+
showRequiredText: false,
|
|
115
|
+
tag: "div",
|
|
116
|
+
useFlatErrors: true,
|
|
117
|
+
useFlatModel: true,
|
|
118
|
+
onChange: this.updateRowData,
|
|
119
|
+
}, this.$slots),
|
|
120
|
+
]);
|
|
121
|
+
},
|
|
122
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import {
|
|
2
|
+
computed,
|
|
3
|
+
toRef,
|
|
4
|
+
} from "vue";
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
cloneDeep,
|
|
8
|
+
isNil,
|
|
9
|
+
} from "lodash-es";
|
|
10
|
+
|
|
11
|
+
function normalizeItem(item, {
|
|
12
|
+
isEditMode,
|
|
13
|
+
isRowDisabled,
|
|
14
|
+
} = {}) {
|
|
15
|
+
const ITEM = cloneDeep(item || {});
|
|
16
|
+
|
|
17
|
+
if (ITEM.useRowReadonly) {
|
|
18
|
+
ITEM.readonly = !isEditMode;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (ITEM.children?.length) {
|
|
22
|
+
ITEM.children = ITEM.children.map(child => normalizeItem(child, {
|
|
23
|
+
isEditMode,
|
|
24
|
+
}));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (isRowDisabled) {
|
|
28
|
+
ITEM.disabled = true;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return ITEM;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export default function DataAPI(props) {
|
|
35
|
+
const columns = toRef(props, "columns");
|
|
36
|
+
const isEditable = toRef(props, "isEditable");
|
|
37
|
+
const isEditMode = toRef(props, "isEditMode");
|
|
38
|
+
|
|
39
|
+
const dataForm = computed(() => {
|
|
40
|
+
const isRowDisabled = isEditable.value && !isEditMode.value;
|
|
41
|
+
|
|
42
|
+
return columns.value.map(column => {
|
|
43
|
+
const ITEM = normalizeItem(column.formElement, {
|
|
44
|
+
isEditMode: isEditMode.value,
|
|
45
|
+
isRowDisabled,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
ITEM.id = column.id;
|
|
49
|
+
if (isNil(ITEM.label)) {
|
|
50
|
+
ITEM.label = column.label;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return ITEM;
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
dataForm,
|
|
59
|
+
};
|
|
60
|
+
}
|