aloha-vue 2.60.1 → 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 +4 -0
- package/dist/aloha-vue.css +9 -0
- package/dist/aloha-vue.css.map +1 -1
- package/dist/aloha-vue.es.js +9156 -8987
- 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 +12 -1
- 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.ListView.test.js +255 -0
- package/src/ATableForm/compositionAPI/ColumnsAPI.js +40 -39
- 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);
|
|
@@ -167,6 +167,12 @@ export default {
|
|
|
167
167
|
required: false,
|
|
168
168
|
default: undefined,
|
|
169
169
|
},
|
|
170
|
+
rowView: {
|
|
171
|
+
type: String,
|
|
172
|
+
required: false,
|
|
173
|
+
default: "table",
|
|
174
|
+
validator: value => ["list", "table"].includes(value),
|
|
175
|
+
},
|
|
170
176
|
rows: {
|
|
171
177
|
type: Array,
|
|
172
178
|
required: false,
|
|
@@ -370,10 +376,11 @@ export default {
|
|
|
370
376
|
"a_table_form__table",
|
|
371
377
|
{
|
|
372
378
|
a_table_form_drag_active: this.draggedRowIndex !== undefined,
|
|
379
|
+
a_table_form__table_list: this.rowView === "list",
|
|
373
380
|
},
|
|
374
381
|
],
|
|
375
382
|
}, [
|
|
376
|
-
h("thead", {
|
|
383
|
+
this.rowView === "table" && h("thead", {
|
|
377
384
|
class: "a_table_form__head",
|
|
378
385
|
}, [
|
|
379
386
|
h(ATableFormRow, {
|
|
@@ -410,6 +417,7 @@ export default {
|
|
|
410
417
|
onEditRow: this.onEditRow,
|
|
411
418
|
row: {},
|
|
412
419
|
rowIndex: 0,
|
|
420
|
+
rowView: this.rowView,
|
|
413
421
|
rows: this.rows,
|
|
414
422
|
saveRow: this.saveRow,
|
|
415
423
|
texts: this.textsLocal,
|
|
@@ -467,6 +475,7 @@ export default {
|
|
|
467
475
|
row,
|
|
468
476
|
rowClass: this.rowClass,
|
|
469
477
|
rowIndex,
|
|
478
|
+
rowView: this.rowView,
|
|
470
479
|
rows: this.rows,
|
|
471
480
|
saveRow: this.saveRow,
|
|
472
481
|
texts: this.textsLocal,
|
|
@@ -524,6 +533,7 @@ export default {
|
|
|
524
533
|
row: {},
|
|
525
534
|
rowClass: this.rowClass,
|
|
526
535
|
rowIndex: this.rows.length,
|
|
536
|
+
rowView: this.rowView,
|
|
527
537
|
rows: this.rows,
|
|
528
538
|
saveRow: this.addRow,
|
|
529
539
|
texts: this.textsLocal,
|
|
@@ -586,6 +596,7 @@ export default {
|
|
|
586
596
|
row,
|
|
587
597
|
rowClass: this.rowClass,
|
|
588
598
|
rowIndex,
|
|
599
|
+
rowView: this.rowView,
|
|
589
600
|
rows: this.rowsFooter,
|
|
590
601
|
saveRow: this.saveRow,
|
|
591
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
|
+
}
|