aloha-vue 2.45.0 → 2.45.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aloha-vue",
3
- "version": "2.45.0",
3
+ "version": "2.45.2",
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",
@@ -65,6 +65,7 @@
65
65
  font-size: var(--a_pagination_font_size);
66
66
  background-color: var(--a_pagination_link_bg);
67
67
  border: var(--a_pagination_link_border_width) solid var(--a_pagination_link_border_color);
68
+ height: 100%;
68
69
  }
69
70
  .a_pagination__item__link {
70
71
  position: relative;
@@ -77,6 +78,7 @@
77
78
  border: var(--a_pagination_link_border_width) solid var(--a_pagination_link_border_color);
78
79
  transition: color .15s ease-in-out,background-color .15s ease-in-out,border-color .15s ease-in-out,box-shadow .15s ease-in-out;
79
80
  cursor: pointer;
81
+ height: 100%;
80
82
  .a_pagination__item:first-child & {
81
83
  border-top-left-radius: var(--a_pagination_link_border_radius);
82
84
  border-bottom-left-radius: var(--a_pagination_link_border_radius);
@@ -2,7 +2,6 @@ import {
2
2
  h,
3
3
  } from "vue";
4
4
 
5
- import AMobileAPI from "../compositionAPI/AMobileAPI";
6
5
  import ComponentsAPI from "./compositionAPI/ComponentsAPI";
7
6
  import EmitsAPI from "./compositionAPI/EmitsAPI";
8
7
 
@@ -41,27 +40,14 @@ export default {
41
40
  * perPage: inline / group / select
42
41
  * pagination: normal / short / loadMore
43
42
  */
44
- desktop: {
45
- perPage: {
46
- mode: "group",
47
- position: 0,
48
- showTextCountFromTo: true,
49
- },
50
- pagination: {
51
- mode: "normal",
52
- position: 1,
53
- },
43
+ perPage: {
44
+ mode: "group",
45
+ position: 0,
46
+ showTextCountFromTo: true,
54
47
  },
55
- mobile: {
56
- perPage: {
57
- mode: "select",
58
- position: 0,
59
- showTextCountFromTo: false,
60
- },
61
- pagination: {
62
- mode: "short",
63
- position: 1,
64
- },
48
+ pagination: {
49
+ mode: "normal",
50
+ position: 1,
65
51
  },
66
52
  }),
67
53
  },
@@ -73,6 +59,22 @@ export default {
73
59
  type: Number,
74
60
  required: true,
75
61
  },
62
+ texts: {
63
+ type: Object,
64
+ required: false,
65
+ default: () => ({
66
+ pagesFirstPage: "_A_PAGINATION_FIRST_PAGE_",
67
+ pagesLastPage: "_A_PAGINATION_LAST_PAGE_",
68
+ pagesMobile: "_A_PAGINATION_MOBILE_{{currentPage}}_{{allPages}}_",
69
+ pagesNavigation: "_A_PAGINATION_NAVIGATION_",
70
+ pagesNextPage: "_A_PAGINATION_NEXT_PAGE_",
71
+ pagesPreviousPage: "_A_PAGINATION_PREVIOUS_PAGE_",
72
+ pagesToPage: "_A_PAGINATION_TO_PAGE_{{page}}_",
73
+ countFromTo: "_A_COUNT_PER_PAGE_{{start}}_{{current}}_{{count}}_",
74
+ countPerPage: "_A_COUNT_PER_PAGE_",
75
+ countPerPageItem: "_A_COUNT_PER_PAGE_ITEM_{{count}}_",
76
+ }),
77
+ },
76
78
  totalCount: {
77
79
  type: Number,
78
80
  required: true,
@@ -83,10 +85,6 @@ export default {
83
85
  "update:offset",
84
86
  ],
85
87
  setup(props, context) {
86
- const {
87
- isMobileWidth: isMobile,
88
- } = AMobileAPI();
89
-
90
88
  const {
91
89
  updateLimit,
92
90
  updateOffset,
@@ -95,7 +93,6 @@ export default {
95
93
  const {
96
94
  components,
97
95
  } = ComponentsAPI(props, {
98
- isMobile,
99
96
  updateLimit,
100
97
  updateOffset,
101
98
  });
@@ -8,6 +8,7 @@ import ATranslation from "../../ATranslation/ATranslation";
8
8
 
9
9
  import LimitAPI from "./compositionAPI/LimitAPI";
10
10
  import MainAPI from "./compositionAPI/MainAPI";
11
+ import TextsAPI from "./compositionAPI/TextsAPI";
11
12
 
12
13
  export default {
13
14
  name: "APaginationCountPerPage",
@@ -48,6 +49,15 @@ export default {
48
49
  required: false,
49
50
  default: true,
50
51
  },
52
+ texts: {
53
+ type: Object,
54
+ required: false,
55
+ default: () => ({
56
+ countFromTo: "_A_COUNT_PER_PAGE_{{start}}_{{current}}_{{count}}_",
57
+ countPerPage: "_A_COUNT_PER_PAGE_",
58
+ countPerPageItem: "_A_COUNT_PER_PAGE_ITEM_{{count}}_",
59
+ }),
60
+ },
51
61
  },
52
62
  emits: [
53
63
  "update:limit",
@@ -64,12 +74,27 @@ export default {
64
74
  extraForTranslate,
65
75
  } = MainAPI(props);
66
76
 
77
+ const {
78
+ getTextCountPerPageItem,
79
+ isTextCountPerPageItemFunction,
80
+ textCountFromTo,
81
+ textCountPerPage,
82
+ textCountPerPageItem,
83
+ } = TextsAPI(props, {
84
+ extraForTranslate,
85
+ });
86
+
67
87
  return {
68
88
  changeLimit,
69
89
  changeLimitFromSelect,
70
90
  extraForTranslate,
91
+ getTextCountPerPageItem,
92
+ isTextCountPerPageItemFunction,
71
93
  keyDownChangeLimit,
72
94
  limitString,
95
+ textCountFromTo,
96
+ textCountPerPage,
97
+ textCountPerPageItem,
73
98
  };
74
99
  },
75
100
  render() {
@@ -80,14 +105,14 @@ export default {
80
105
  this.showTextCountFromTo ?
81
106
  h(ATranslation, {
82
107
  class: "a_pagination__count_from_to",
83
- html: "_A_COUNT_PER_PAGE_{{start}}_{{current}}_{{count}}_",
108
+ html: this.textCountFromTo,
84
109
  extra: this.extraForTranslate,
85
110
  }) :
86
111
  "",
87
112
  h(ATranslation, {
88
113
  tag: "span",
89
114
  class: "a_pagination__count__text",
90
- html: "_A_COUNT_PER_PAGE_",
115
+ html: this.textCountPerPage,
91
116
  }),
92
117
  this.mode === "inline" ?
93
118
  h("div", {
@@ -95,6 +120,9 @@ export default {
95
120
  }, [
96
121
  this.limitsPerPage.map(count => {
97
122
  const IS_ACTIVE = +count === this.limit;
123
+ const TITLE = this.isTextCountPerPageItemFunction ?
124
+ this.getTextCountPerPageItem({ count }) :
125
+ this.textCountPerPageItem;
98
126
 
99
127
  return h("div", {
100
128
  class: "a_pagination__count__item",
@@ -108,8 +136,8 @@ export default {
108
136
  },
109
137
  text: count,
110
138
  textAriaHidden: true,
111
- textScreenReader: "_A_COUNT_PER_PAGE_ITEM_{{count}}_",
112
- title: "_A_COUNT_PER_PAGE_ITEM_{{count}}_",
139
+ textScreenReader: TITLE,
140
+ title: TITLE,
113
141
  type: "button",
114
142
  onClick: () => this.changeLimit(count),
115
143
  }),
@@ -121,6 +149,9 @@ export default {
121
149
  }, [
122
150
  this.limitsPerPage.map(count => {
123
151
  const IS_ACTIVE = +count === this.limit;
152
+ const TITLE = this.isTextCountPerPageItemFunction ?
153
+ this.getTextCountPerPageItem({ count }) :
154
+ this.textCountPerPageItem;
124
155
 
125
156
  return h("li", {
126
157
  class: [
@@ -143,8 +174,8 @@ export default {
143
174
  tag: "a",
144
175
  text: count,
145
176
  textAriaHidden: true,
146
- textScreenReader: "_A_COUNT_PER_PAGE_ITEM_{{count}}_",
147
- title: "_A_COUNT_PER_PAGE_ITEM_{{count}}_",
177
+ textScreenReader: TITLE,
178
+ title: TITLE,
148
179
  type: "button",
149
180
  onClick: () => this.changeLimit(count),
150
181
  onKeydown: $event => this.keyDownChangeLimit($event, count),
@@ -157,12 +188,12 @@ export default {
157
188
  this.showTextCountFromTo ?
158
189
  h(ATranslation, {
159
190
  class: "a_pagination__count_from_to",
160
- html: "_A_COUNT_PER_PAGE_{{start}}_{{current}}_{{count}}_",
191
+ html: this.textCountFromTo,
161
192
  extra: this.extraForTranslate,
162
193
  }) :
163
194
  "",
164
195
  h(ASelect, {
165
- label: "_A_COUNT_PER_PAGE_",
196
+ label: this.textCountPerPage,
166
197
  labelClass: "a_sr_only",
167
198
  data: this.limitsPerPage,
168
199
  isDataSimpleArray: true,
@@ -0,0 +1,54 @@
1
+ import {
2
+ computed,
3
+ toRef,
4
+ } from "vue";
5
+
6
+ import {
7
+ isFunction,
8
+ } from "lodash-es";
9
+
10
+ export default function TextsAPI(props, {
11
+ extraForTranslate = computed(() => ({})),
12
+ }) {
13
+ const texts = toRef(props, "texts");
14
+
15
+ const textCountFromTo = computed(() => {
16
+ if (isFunction(texts.value.countFromTo)) {
17
+ return texts.value.countFromTo({
18
+ start: extraForTranslate.value.start,
19
+ current: extraForTranslate.value.current,
20
+ count: extraForTranslate.value.count,
21
+ });
22
+ }
23
+
24
+ return texts.value.countFromTo || "_A_COUNT_PER_PAGE_{{start}}_{{current}}_{{count}}_";
25
+ });
26
+
27
+ const textCountPerPage = computed(() => {
28
+ return texts.value.countPerPage || "_A_COUNT_PER_PAGE_";
29
+ });
30
+
31
+ const isTextCountPerPageItemFunction = computed(() => {
32
+ return isFunction(texts.value.countPerPageItem);
33
+ });
34
+
35
+ const textCountPerPageItem = computed(() => {
36
+ return texts.value.countPerPageItem || "_A_COUNT_PER_PAGE_ITEM_{{count}}_";
37
+ });
38
+
39
+ const getTextCountPerPageItem = ({ count }) => {
40
+ if (isTextCountPerPageItemFunction.value) {
41
+ return texts.value.countPerPageItem({ count });
42
+ }
43
+
44
+ return undefined;
45
+ };
46
+
47
+ return {
48
+ getTextCountPerPageItem,
49
+ isTextCountPerPageItemFunction,
50
+ textCountFromTo,
51
+ textCountPerPage,
52
+ textCountPerPageItem,
53
+ };
54
+ }
@@ -1,7 +1,6 @@
1
1
  import {
2
2
  computed,
3
3
  h,
4
- ref,
5
4
  toRef,
6
5
  } from "vue";
7
6
 
@@ -16,51 +15,22 @@ import {
16
15
  } from "lodash-es";
17
16
 
18
17
  export default function ComponentsAPI(props, {
19
- isMobile = ref(false),
20
18
  updateLimit = () => {},
21
19
  updateOffset = () => {},
22
20
  }) {
23
- const modes = toRef(props, "modes");
24
- const totalCount = toRef(props, "totalCount");
25
21
  const disabled = toRef(props, "disabled");
26
- const limitsPerPage = toRef(props, "limitsPerPage");
27
22
  const limit = toRef(props, "limit");
23
+ const limitsPerPage = toRef(props, "limitsPerPage");
24
+ const maxPages = toRef(props, "maxPages");
25
+ const modes = toRef(props, "modes");
28
26
  const offset = toRef(props, "offset");
29
27
  const rowsLength = toRef(props, "rowsLength");
30
- const maxPages = toRef(props, "maxPages");
31
-
32
- const currentMode = computed(() => {
33
- if (isMobile.value) {
34
- return modes.value.mobile ||
35
- {
36
- perPage: {
37
- mode: "select",
38
- position: 0,
39
- showTextCountFromTo: false,
40
- },
41
- pagination: {
42
- mode: "short",
43
- position: 1,
44
- },
45
- };
46
- }
47
- return modes.value.desktop ||
48
- {
49
- perPage: {
50
- mode: "inline",
51
- position: 0,
52
- showTextCountFromTo: true,
53
- },
54
- pagination: {
55
- mode: "normal",
56
- position: 1,
57
- },
58
- };
59
- });
28
+ const texts = toRef(props, "texts");
29
+ const totalCount = toRef(props, "totalCount");
60
30
 
61
31
  const currentModeSorted = computed(() => {
62
32
  const LIST = [];
63
- forEach(currentMode.value, (item, component) => {
33
+ forEach(modes.value, (item, component) => {
64
34
  LIST.push({
65
35
  ...item,
66
36
  component,
@@ -75,24 +45,26 @@ export default function ComponentsAPI(props, {
75
45
  forEach(currentModeSorted.value, item => {
76
46
  if (item.component === "perPage") {
77
47
  LIST.push(h(APaginationCountPerPage, {
78
- totalCount: totalCount.value,
79
48
  disabled: disabled.value,
80
- limitsPerPage: limitsPerPage.value,
81
49
  limit: limit.value,
50
+ limitsPerPage: limitsPerPage.value,
51
+ mode: item.mode,
82
52
  offset: offset.value,
83
53
  rowsLength: rowsLength.value,
84
- mode: item.mode,
85
54
  showTextCountFromTo: item.showTextCountFromTo,
55
+ texts: texts.value,
56
+ totalCount: totalCount.value,
86
57
  "onUpdate:limit": updateLimit,
87
58
  }));
88
59
  } else if (item.component === "pagination") {
89
60
  LIST.push(h(APaginationPages, {
90
- totalCount: totalCount.value,
91
61
  disabled: disabled.value,
92
62
  limit: limit.value,
63
+ maxPages: maxPages.value,
93
64
  mode: item.mode,
94
65
  offset: offset.value,
95
- maxPages: maxPages.value,
66
+ texts: texts.value,
67
+ totalCount: totalCount.value,
96
68
  "onUpdate:offset": updateOffset,
97
69
  }));
98
70
  }