aloha-vue 2.67.0 → 2.68.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 +5 -0
- package/dist/aloha-vue.es.js +2411 -2388
- package/dist/aloha-vue.umd.js +36 -36
- package/package.json +1 -1
- package/src/ui/ACheckbox/ACheckbox.js +11 -6
- package/src/ui/AMultiselectOrdered/AMultiselectOrdered.js +11 -6
- package/src/ui/ARadio/ARadio.js +11 -6
- package/src/ui/ASelect/ASelect.js +11 -6
- package/src/ui/compositionApi/UiDataWithKeyIdAndLabelAPI.js +12 -4
- package/src/ui/compositionApi/__tests__/UiDataWithKeyIdAndLabelAPI.test.js +128 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aloha-vue",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.68.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",
|
|
@@ -88,12 +88,17 @@ export default {
|
|
|
88
88
|
required: false,
|
|
89
89
|
default: undefined,
|
|
90
90
|
},
|
|
91
|
-
dataExtra: {
|
|
92
|
-
type: Array,
|
|
93
|
-
required: false,
|
|
94
|
-
default: () => [],
|
|
95
|
-
},
|
|
96
|
-
|
|
91
|
+
dataExtra: {
|
|
92
|
+
type: Array,
|
|
93
|
+
required: false,
|
|
94
|
+
default: () => [],
|
|
95
|
+
},
|
|
96
|
+
mergeData: {
|
|
97
|
+
type: Boolean,
|
|
98
|
+
required: false,
|
|
99
|
+
default: false,
|
|
100
|
+
},
|
|
101
|
+
dependencies: {
|
|
97
102
|
type: [Array, Object],
|
|
98
103
|
required: false,
|
|
99
104
|
default: undefined,
|
|
@@ -119,12 +119,17 @@ export default {
|
|
|
119
119
|
required: false,
|
|
120
120
|
default: undefined,
|
|
121
121
|
},
|
|
122
|
-
dataExtra: {
|
|
123
|
-
type: Array,
|
|
124
|
-
required: false,
|
|
125
|
-
default: () => [],
|
|
126
|
-
},
|
|
127
|
-
|
|
122
|
+
dataExtra: {
|
|
123
|
+
type: Array,
|
|
124
|
+
required: false,
|
|
125
|
+
default: () => [],
|
|
126
|
+
},
|
|
127
|
+
mergeData: {
|
|
128
|
+
type: Boolean,
|
|
129
|
+
required: false,
|
|
130
|
+
default: false,
|
|
131
|
+
},
|
|
132
|
+
dependencies: {
|
|
128
133
|
type: [Array, Object],
|
|
129
134
|
required: false,
|
|
130
135
|
default: undefined,
|
package/src/ui/ARadio/ARadio.js
CHANGED
|
@@ -88,12 +88,17 @@ export default {
|
|
|
88
88
|
required: false,
|
|
89
89
|
default: undefined,
|
|
90
90
|
},
|
|
91
|
-
dataExtra: {
|
|
92
|
-
type: Array,
|
|
93
|
-
required: false,
|
|
94
|
-
default: () => [],
|
|
95
|
-
},
|
|
96
|
-
|
|
91
|
+
dataExtra: {
|
|
92
|
+
type: Array,
|
|
93
|
+
required: false,
|
|
94
|
+
default: () => [],
|
|
95
|
+
},
|
|
96
|
+
mergeData: {
|
|
97
|
+
type: Boolean,
|
|
98
|
+
required: false,
|
|
99
|
+
default: false,
|
|
100
|
+
},
|
|
101
|
+
dependencies: {
|
|
97
102
|
type: [Array, Object],
|
|
98
103
|
required: false,
|
|
99
104
|
default: undefined,
|
|
@@ -122,12 +122,17 @@ export default {
|
|
|
122
122
|
required: false,
|
|
123
123
|
default: undefined,
|
|
124
124
|
},
|
|
125
|
-
dataExtra: {
|
|
126
|
-
type: Array,
|
|
127
|
-
required: false,
|
|
128
|
-
default: () => ASelectPluginOptions.propsDefault.dataExtra,
|
|
129
|
-
},
|
|
130
|
-
|
|
125
|
+
dataExtra: {
|
|
126
|
+
type: Array,
|
|
127
|
+
required: false,
|
|
128
|
+
default: () => ASelectPluginOptions.propsDefault.dataExtra,
|
|
129
|
+
},
|
|
130
|
+
mergeData: {
|
|
131
|
+
type: Boolean,
|
|
132
|
+
required: false,
|
|
133
|
+
default: false,
|
|
134
|
+
},
|
|
135
|
+
dependencies: {
|
|
131
136
|
type: [Array, Object],
|
|
132
137
|
required: false,
|
|
133
138
|
default: undefined,
|
|
@@ -31,9 +31,10 @@ export default function UiDataWithKeyIdAndLabelAPI(props) {
|
|
|
31
31
|
const data = toRef(props, "data");
|
|
32
32
|
const dataExtra = toRef(props, "dataExtra");
|
|
33
33
|
const isDataSimpleArray = toRef(props, "isDataSimpleArray");
|
|
34
|
-
const keyId = toRef(props, "keyId");
|
|
35
|
-
const keyLabel = toRef(props, "keyLabel");
|
|
36
|
-
const keyLabelCallback = toRef(props, "keyLabelCallback");
|
|
34
|
+
const keyId = toRef(props, "keyId");
|
|
35
|
+
const keyLabel = toRef(props, "keyLabel");
|
|
36
|
+
const keyLabelCallback = toRef(props, "keyLabelCallback");
|
|
37
|
+
const mergeData = toRef(props, "mergeData");
|
|
37
38
|
const searchTextInHtml = toRef(props, "searchTextInHtml");
|
|
38
39
|
const translateData = toRef(props, "translateData");
|
|
39
40
|
|
|
@@ -156,7 +157,14 @@ export default function UiDataWithKeyIdAndLabelAPI(props) {
|
|
|
156
157
|
let DATA_LOCAL = data.value || [];
|
|
157
158
|
|
|
158
159
|
if (dataFromServer.value.length) {
|
|
159
|
-
|
|
160
|
+
if (mergeData.value) {
|
|
161
|
+
DATA_LOCAL = uniqBy([
|
|
162
|
+
...dataFromServer.value,
|
|
163
|
+
...DATA_LOCAL,
|
|
164
|
+
], item => get(item, keyId.value, item));
|
|
165
|
+
} else {
|
|
166
|
+
DATA_LOCAL = dataFromServer.value;
|
|
167
|
+
}
|
|
160
168
|
}
|
|
161
169
|
|
|
162
170
|
if (!dataFromRetrieve.value.length) {
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createApp,
|
|
3
|
+
defineComponent,
|
|
4
|
+
} from "vue";
|
|
5
|
+
import {
|
|
6
|
+
describe,
|
|
7
|
+
expect,
|
|
8
|
+
it,
|
|
9
|
+
jest,
|
|
10
|
+
} from "@jest/globals";
|
|
11
|
+
|
|
12
|
+
import UiDataWithKeyIdAndLabelAPI from "../UiDataWithKeyIdAndLabelAPI";
|
|
13
|
+
|
|
14
|
+
import {
|
|
15
|
+
AKeyId,
|
|
16
|
+
AKeyLabel,
|
|
17
|
+
} from "../../../const/AKeys";
|
|
18
|
+
|
|
19
|
+
jest.mock("../../../index", () => ({
|
|
20
|
+
AKeyId: "_a_id",
|
|
21
|
+
AKeyLabel: "_a_label",
|
|
22
|
+
AKeyLabelSearch: "_a_label_search",
|
|
23
|
+
extractTextFromHtml: value => value,
|
|
24
|
+
getTranslatedText: ({ placeholder }) => placeholder,
|
|
25
|
+
isArrayOfArrays: value => Array.isArray(value) && value.every(Array.isArray),
|
|
26
|
+
isPlaceholderTranslate: () => false,
|
|
27
|
+
}));
|
|
28
|
+
|
|
29
|
+
const createProps = ({
|
|
30
|
+
data,
|
|
31
|
+
isDataSimpleArray = false,
|
|
32
|
+
mergeData = false,
|
|
33
|
+
}) => ({
|
|
34
|
+
alwaysTranslate: false,
|
|
35
|
+
data,
|
|
36
|
+
dataExtra: [],
|
|
37
|
+
isDataSimpleArray,
|
|
38
|
+
keyId: "id",
|
|
39
|
+
keyLabel: "label",
|
|
40
|
+
keyLabelCallback: undefined,
|
|
41
|
+
mergeData,
|
|
42
|
+
searchTextInHtml: false,
|
|
43
|
+
translateData: false,
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const useDataAPI = props => {
|
|
47
|
+
let result;
|
|
48
|
+
const app = createApp(defineComponent({
|
|
49
|
+
name: "TestUiDataWithKeyIdAndLabelAPI",
|
|
50
|
+
setup() {
|
|
51
|
+
result = UiDataWithKeyIdAndLabelAPI(props);
|
|
52
|
+
return () => null;
|
|
53
|
+
},
|
|
54
|
+
}));
|
|
55
|
+
|
|
56
|
+
app.mount(document.createElement("div"));
|
|
57
|
+
return result;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
describe("UiDataWithKeyIdAndLabelAPI", () => {
|
|
61
|
+
it("keeps replacing prop data with internally loaded data by default", () => {
|
|
62
|
+
const {
|
|
63
|
+
dataFromServer,
|
|
64
|
+
dataLocal,
|
|
65
|
+
} = useDataAPI(createProps({
|
|
66
|
+
data: [
|
|
67
|
+
{ id: 1, label: "Prop one" },
|
|
68
|
+
{ id: 3, label: "Prop three" },
|
|
69
|
+
],
|
|
70
|
+
}));
|
|
71
|
+
|
|
72
|
+
dataFromServer.value = [
|
|
73
|
+
{ id: 1, label: "Internal one" },
|
|
74
|
+
{ id: 2, label: "Internal two" },
|
|
75
|
+
];
|
|
76
|
+
|
|
77
|
+
expect(dataLocal.value.map(item => item[AKeyLabel])).toEqual([
|
|
78
|
+
"Internal one",
|
|
79
|
+
"Internal two",
|
|
80
|
+
]);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("merges prop and internally loaded data by ID with internal items taking precedence", () => {
|
|
84
|
+
const {
|
|
85
|
+
dataFromServer,
|
|
86
|
+
dataLocal,
|
|
87
|
+
} = useDataAPI(createProps({
|
|
88
|
+
data: [
|
|
89
|
+
{ id: 1, label: "Prop one" },
|
|
90
|
+
{ id: 3, label: "Prop three" },
|
|
91
|
+
],
|
|
92
|
+
mergeData: true,
|
|
93
|
+
}));
|
|
94
|
+
|
|
95
|
+
dataFromServer.value = [
|
|
96
|
+
{ id: 1, label: "Internal one" },
|
|
97
|
+
{ id: 2, label: "Internal two" },
|
|
98
|
+
];
|
|
99
|
+
|
|
100
|
+
expect(dataLocal.value.map(item => ({
|
|
101
|
+
id: item[AKeyId],
|
|
102
|
+
label: item[AKeyLabel],
|
|
103
|
+
}))).toEqual([
|
|
104
|
+
{ id: 1, label: "Internal one" },
|
|
105
|
+
{ id: 2, label: "Internal two" },
|
|
106
|
+
{ id: 3, label: "Prop three" },
|
|
107
|
+
]);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it("merges simple arrays by their values", () => {
|
|
111
|
+
const {
|
|
112
|
+
dataFromServer,
|
|
113
|
+
dataLocal,
|
|
114
|
+
} = useDataAPI(createProps({
|
|
115
|
+
data: ["one", "three"],
|
|
116
|
+
isDataSimpleArray: true,
|
|
117
|
+
mergeData: true,
|
|
118
|
+
}));
|
|
119
|
+
|
|
120
|
+
dataFromServer.value = ["one", "two"];
|
|
121
|
+
|
|
122
|
+
expect(dataLocal.value.map(item => item[AKeyId])).toEqual([
|
|
123
|
+
"one",
|
|
124
|
+
"two",
|
|
125
|
+
"three",
|
|
126
|
+
]);
|
|
127
|
+
});
|
|
128
|
+
});
|