aloha-vue 2.58.0 → 2.60.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.
Files changed (33) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/aloha-vue.css +5 -0
  3. package/dist/aloha-vue.css.map +1 -1
  4. package/dist/aloha-vue.es.js +12294 -12208
  5. package/dist/aloha-vue.umd.js +48 -46
  6. package/package.json +1 -1
  7. package/scss/components/ATableForm.scss +261 -256
  8. package/src/ATableForm/ATableForm.js +613 -606
  9. package/src/ATableForm/ATableFormCellDnd/ATableFormCellDnd.js +182 -176
  10. package/src/ATableForm/__tests__/ATableForm.DragAndDropAPI.test.js +162 -0
  11. package/src/ATableForm/compositionAPI/DragAndDropAPI.js +302 -268
  12. package/src/ATableForm/compositionAPI/TextsAPI.js +35 -34
  13. package/src/ATableForm/i18n/ar.json +18 -17
  14. package/src/ATableForm/i18n/de.json +18 -17
  15. package/src/ATableForm/i18n/en.json +18 -17
  16. package/src/ATableForm/i18n/es.json +18 -17
  17. package/src/ATableForm/i18n/fr.json +18 -17
  18. package/src/ATableForm/i18n/hr.json +18 -17
  19. package/src/ATableForm/i18n/it.json +18 -17
  20. package/src/ATableForm/i18n/ru.json +18 -17
  21. package/src/plugins/AMultiselectOrderedPlugin.js +1 -0
  22. package/src/plugins/ASelectPlugin.js +5 -4
  23. package/src/ui/ACheckbox/ACheckbox.js +10 -5
  24. package/src/ui/AMultiselectOrdered/AMultiselectOrdered.js +13 -7
  25. package/src/ui/ARadio/ARadio.js +10 -5
  26. package/src/ui/ASelect/ASelect.js +18 -11
  27. package/src/ui/ASelect/ASelectValueCloseable/ASelectValueCloseable.js +5 -0
  28. package/src/ui/ASelect/ASelectValueCloseable/compositionAPI/GroupAPI.js +17 -2
  29. package/src/ui/ASelect/compositionAPI/SelectedTitleAPI.js +17 -2
  30. package/src/ui/ASelectIcon/ASelectIcon.js +11 -6
  31. package/src/ui/ASelectStyle/ASelectStyle.js +11 -6
  32. package/src/ui/compositionApi/UIDataGroupAPI.js +52 -39
  33. package/src/ui/compositionApi/__tests__/UIDataGroupAPI.test.js +106 -0
@@ -1,34 +1,41 @@
1
- import {
2
- computed,
3
- toRef,
4
- } from "vue";
5
-
6
- import {
7
- aOrderBy,
8
- extractTextFromHtml,
9
- } from "../../utils/utils";
10
-
11
- import {
12
- AKeyId,
13
- } from "../../const/AKeys";
14
- import {
15
- cloneDeep,
16
- forEach,
17
- get,
18
- isArray,
19
- isFunction,
20
- isNil,
21
- isString,
22
- values,
1
+ import {
2
+ computed,
3
+ toRef,
4
+ } from "vue";
5
+
6
+ import {
7
+ aOrderBy,
8
+ extractTextFromHtml,
9
+ } from "../../utils/utils";
10
+
11
+ import {
12
+ getTranslatedText,
13
+ isPlaceholderTranslate,
14
+ } from "../../ATranslation/compositionAPI/UtilsAPI";
15
+
16
+ import {
17
+ AKeyId,
18
+ } from "../../const/AKeys";
19
+ import {
20
+ cloneDeep,
21
+ forEach,
22
+ get,
23
+ isArray,
24
+ isFunction,
25
+ isNil,
26
+ isString,
27
+ values,
23
28
  } from "lodash-es";
24
29
 
25
- export default function UIDataGroupAPI(props, {
26
- data = computed(() => []),
27
- }) {
28
- const keyGroup = toRef(props, "keyGroup");
29
- const keyGroupLabelCallback = toRef(props, "keyGroupLabelCallback");
30
- const searchTextInHtml = toRef(props, "searchTextInHtml");
31
- const sortOrderGroup = toRef(props, "sortOrderGroup");
30
+ export default function UIDataGroupAPI(props, {
31
+ data = computed(() => []),
32
+ }) {
33
+ const alwaysTranslate = toRef(props, "alwaysTranslate");
34
+ const keyGroup = toRef(props, "keyGroup");
35
+ const keyGroupLabelCallback = toRef(props, "keyGroupLabelCallback");
36
+ const searchTextInHtml = toRef(props, "searchTextInHtml");
37
+ const sortOrderGroup = toRef(props, "sortOrderGroup");
38
+ const translateGroup = toRef(props, "translateGroup");
32
39
 
33
40
  const keyGroupArray = computed(() => {
34
41
  if (isArray(keyGroup.value)) {
@@ -65,21 +72,27 @@ export default function UIDataGroupAPI(props, {
65
72
  }
66
73
  allGroupKeys += `${ allGroupKeys ? "_" : "" }${ group }`;
67
74
  if (!GROUPS_FOR_LEVER[leverIndex][allGroupKeys]) {
68
- const GROUP_LABEL = isFunction(keyGroupLabelCallback.value) ?
69
- keyGroupLabelCallback.value({ group: group, item }) :
70
- group;
71
- GROUPS_FOR_LEVER[leverIndex][allGroupKeys] = {
72
- groupKey: group,
73
- groupLabel: GROUP_LABEL,
75
+ let groupLabel = isFunction(keyGroupLabelCallback.value) ?
76
+ keyGroupLabelCallback.value({ group: group, item }) :
77
+ group;
78
+ if (translateGroup.value && isPlaceholderTranslate(groupLabel)) {
79
+ groupLabel = getTranslatedText({
80
+ placeholder: groupLabel,
81
+ alwaysTranslate: alwaysTranslate.value,
82
+ });
83
+ }
84
+ GROUPS_FOR_LEVER[leverIndex][allGroupKeys] = {
85
+ groupKey: group,
86
+ groupLabel,
74
87
  groupParentKey: groupParentKey,
75
88
  allGroupKeys: allGroupKeys,
76
89
  allParentKeys: cloneDeep(allParentKeys),
77
90
  data: [],
78
91
  dataKeyByKeyId: {},
79
- };
80
- if (searchTextInHtml.value) {
81
- GROUPS_FOR_LEVER[leverIndex][allGroupKeys].groupLabelSearch = extractTextFromHtml(GROUP_LABEL);
82
- }
92
+ };
93
+ if (searchTextInHtml.value) {
94
+ GROUPS_FOR_LEVER[leverIndex][allGroupKeys].groupLabelSearch = extractTextFromHtml(groupLabel);
95
+ }
83
96
  }
84
97
  GROUPS_FOR_LEVER[leverIndex][allGroupKeys].data.push(item);
85
98
  GROUPS_FOR_LEVER[leverIndex][allGroupKeys].dataKeyByKeyId[item[AKeyId]] = item;
@@ -0,0 +1,106 @@
1
+ import {
2
+ computed,
3
+ nextTick,
4
+ } from "vue";
5
+ import {
6
+ beforeAll,
7
+ describe,
8
+ expect,
9
+ it,
10
+ } from "@jest/globals";
11
+
12
+ import UIDataGroupAPI from "../UIDataGroupAPI";
13
+ import {
14
+ setI18n,
15
+ setLanguage,
16
+ } from "../../../ATranslation/compositionAPI/ATranslationAPI";
17
+
18
+ import {
19
+ AKeyId,
20
+ } from "../../../const/AKeys";
21
+
22
+ describe("UIDataGroupAPI", () => {
23
+ beforeAll(async() => {
24
+ setI18n({
25
+ uiDataGroupApiTest: {
26
+ _GROUP_: "Translated group",
27
+ _GROUP_FROM_CALLBACK_: "Translated callback group",
28
+ },
29
+ });
30
+ setLanguage("uiDataGroupApiTest");
31
+ await nextTick();
32
+ });
33
+
34
+ it("translates a group label without changing its key", () => {
35
+ const props = {
36
+ alwaysTranslate: true,
37
+ keyGroup: "group",
38
+ keyGroupLabelCallback: undefined,
39
+ searchTextInHtml: false,
40
+ sortOrderGroup: undefined,
41
+ translateGroup: true,
42
+ };
43
+ const data = computed(() => [{
44
+ [AKeyId]: "item_1",
45
+ group: "_GROUP_",
46
+ }]);
47
+
48
+ const {
49
+ groupsForLever,
50
+ } = UIDataGroupAPI(props, {
51
+ data,
52
+ });
53
+
54
+ expect(groupsForLever.value[0][0]).toEqual(expect.objectContaining({
55
+ allGroupKeys: "_GROUP_",
56
+ groupKey: "_GROUP_",
57
+ groupLabel: "Translated group",
58
+ }));
59
+ });
60
+
61
+ it("does not translate a group label when translateGroup is false", () => {
62
+ const props = {
63
+ alwaysTranslate: true,
64
+ keyGroup: "group",
65
+ keyGroupLabelCallback: undefined,
66
+ searchTextInHtml: false,
67
+ sortOrderGroup: undefined,
68
+ translateGroup: false,
69
+ };
70
+ const data = computed(() => [{
71
+ [AKeyId]: "item_1",
72
+ group: "_GROUP_",
73
+ }]);
74
+
75
+ const {
76
+ groupsForLever,
77
+ } = UIDataGroupAPI(props, {
78
+ data,
79
+ });
80
+
81
+ expect(groupsForLever.value[0][0].groupLabel).toBe("_GROUP_");
82
+ });
83
+
84
+ it("translates a group label returned by keyGroupLabelCallback", () => {
85
+ const props = {
86
+ alwaysTranslate: true,
87
+ keyGroup: "group",
88
+ keyGroupLabelCallback: () => "_GROUP_FROM_CALLBACK_",
89
+ searchTextInHtml: false,
90
+ sortOrderGroup: undefined,
91
+ translateGroup: true,
92
+ };
93
+ const data = computed(() => [{
94
+ [AKeyId]: "item_1",
95
+ group: "group_1",
96
+ }]);
97
+
98
+ const {
99
+ groupsForLever,
100
+ } = UIDataGroupAPI(props, {
101
+ data,
102
+ });
103
+
104
+ expect(groupsForLever.value[0][0].groupLabel).toBe("Translated callback group");
105
+ });
106
+ });