aloha-vue 1.2.181 → 1.2.183

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
@@ -14,7 +14,7 @@
14
14
  "Vue.js"
15
15
  ],
16
16
  "homepage": "https://github.com/ilia-brykin/aloha/#README.md",
17
- "version": "1.2.181",
17
+ "version": "1.2.183",
18
18
  "author": {
19
19
  "name": "Ilia Brykin",
20
20
  "email": "brykin.ilia@gmail.com"
@@ -3,8 +3,8 @@ import {
3
3
  } from "vue";
4
4
 
5
5
  import AButton from "../../AButton/AButton";
6
+ import ATranslation from "../../ATranslation/ATranslation";
6
7
 
7
- import AriaLabelAPI from "./compositionAPI/AriaLabelAPI";
8
8
  import FocusAPI from "./compositionAPI/FocusAPI";
9
9
 
10
10
  export default {
@@ -23,10 +23,6 @@ export default {
23
23
  "onTogglePreview",
24
24
  ],
25
25
  setup() {
26
- const {
27
- previewAriaLabel,
28
- } = AriaLabelAPI();
29
-
30
26
  const {
31
27
  componentRef,
32
28
  setFocusToComponent,
@@ -38,7 +34,6 @@ export default {
38
34
 
39
35
  return {
40
36
  componentRef,
41
- previewAriaLabel,
42
37
  };
43
38
  },
44
39
  render() {
@@ -46,8 +41,11 @@ export default {
46
41
  ref: "componentRef",
47
42
  class: "a_table__preview_down",
48
43
  tabindex: -1,
49
- "aria-label": this.previewAriaLabel,
50
44
  }, [
45
+ h(ATranslation, {
46
+ class: "a_sr_only",
47
+ text: "_A_TABLE_PREVIEW_DOWN_ARIA_LABEL_",
48
+ }),
51
49
  this.$slots.preview && this.$slots.preview({
52
50
  row: this.row,
53
51
  rowIndex: this.rowIndex,
@@ -1,257 +1,254 @@
1
- import {
2
- h,
3
- onBeforeUnmount,
4
- onMounted, toRef,
5
- } from "vue";
6
-
7
- import AButton from "../../AButton/AButton";
8
- import ACloak from "../../ACloak/ACloak";
9
- import AModal from "../../AModal/AModal";
10
- import AResizer from "../../AResizer/AResizer";
11
- import ATranslation from "../../ATranslation/ATranslation";
12
-
13
- import AriaLabelAPI from "./compositionAPI/AriaLabelAPI";
14
- import ArrowsAPI from "./compositionAPI/ArrowsAPI";
15
- import IdAPI from "./compositionAPI/IdAPI";
16
- import MouseEventsAPI from "./compositionAPI/MouseEventsAPI";
17
- import PreviewRightRewAPI from "../compositionAPI/PreviewRightRewAPI";
18
- import RowAPI from "./compositionAPI/RowAPI";
19
-
20
- export default {
21
- name: "ATablePreviewRight",
22
- props: {
23
- countAllRows: {
24
- type: Number,
25
- required: true,
26
- },
27
- disabledPreviewRowCallback: {
28
- type: Function,
29
- required: false,
30
- default: () => {},
31
- },
32
- isLoadingTable: {
33
- type: Boolean,
34
- required: false,
35
- },
36
- isMobile: {
37
- type: Boolean,
38
- required: false,
39
- },
40
- limitPagination: {
41
- type: Number,
42
- required: false,
43
- default: undefined,
44
- },
45
- offsetPagination: {
46
- type: Number,
47
- required: false,
48
- default: undefined,
49
- },
50
- previewHeaderTag: {
51
- type: String,
52
- required: true,
53
- },
54
- previewStyles: {
55
- type: [String, Object],
56
- required: false,
57
- default: undefined,
58
- },
59
- rowIndex: {
60
- type: Number,
61
- required: true,
62
- },
63
- rows: {
64
- type: Array,
65
- required: true,
66
- },
67
- usePagination: {
68
- type: Boolean,
69
- required: false,
70
- },
71
- },
72
- emits: [
73
- "closePreview",
74
- "mousedownResizePreviewRight",
75
- "mousemoveResizePreviewRight",
76
- "mouseupResizePreviewRight",
77
- "togglePreviewResize",
78
- "togglePreview",
79
- "update:offset",
80
- ],
81
- inject: [
82
- "isLoadingOptions",
83
- ],
84
- setup(props, context) {
85
- const isMobile = toRef(props, "isMobile");
86
-
87
- const {
88
- previewRef,
89
- } = PreviewRightRewAPI();
90
-
91
- const {
92
- idLocal,
93
- } = IdAPI();
94
-
95
- const {
96
- previewAriaLabel,
97
- } = AriaLabelAPI();
98
-
99
- const {
100
- mousedown,
101
- mousemove,
102
- mouseup,
103
- } = MouseEventsAPI(context, {
104
- previewRef,
105
- });
106
-
107
- const {
108
- countAllRowsFormatted,
109
- currentRow,
110
- nextAvailableRowIndex,
111
- previousAvailableRowIndex,
112
- rowNumber,
113
- rowNumberFormatted,
114
- } = RowAPI(props);
115
-
116
- const {
117
- disabledBtnArrowLeft,
118
- disabledBtnArrowRight,
119
- toNextRow,
120
- toPreviousRow,
121
- } = ArrowsAPI(props, context, {
122
- nextAvailableRowIndex,
123
- previousAvailableRowIndex,
124
- rowNumber,
125
- });
126
-
127
- onMounted(() => {
128
- if (!isMobile.value) {
129
- context.emit("togglePreviewResize", {
130
- isOpen: true,
131
- previewRef: previewRef.value,
132
- });
133
- }
134
- });
135
-
136
- onBeforeUnmount(() => {
137
- if (!isMobile.value) {
138
- context.emit("togglePreviewResize", {
139
- isOpen: false,
140
- previewRef: previewRef.value,
141
- });
142
- }
143
- });
144
-
145
- return {
146
- countAllRowsFormatted,
147
- currentRow,
148
- disabledBtnArrowLeft,
149
- disabledBtnArrowRight,
150
- idLocal,
151
- mousedown,
152
- mousemove,
153
- mouseup,
154
- previewAriaLabel,
155
- previewRef,
156
- rowNumber,
157
- rowNumberFormatted,
158
- toNextRow,
159
- toPreviousRow,
160
- };
161
- },
162
- render() {
163
- const HEADER = [
164
- this.isLoadingTable ?
165
- h(ACloak) :
166
- h("div", {}, [
167
- h(ATranslation, {
168
- class: "a_table__preview_right__header__text",
169
- tag: "span",
170
- text: "_A_TABLE_PREVIEW_RIGHT_HEADER_{{rowNumber}}_{{rowNumberFormatted}}_{{countAllRows}}_{{countAllRowsFormatted}}_",
171
- extra: {
172
- rowNumber: this.rowNumber,
173
- rowNumberFormatted: this.rowNumberFormatted,
174
- countAllRows: this.countAllRows,
175
- countAllRowsFormatted: this.countAllRowsFormatted,
176
- },
177
- }),
178
- h("div", {
179
- class: "a_table__preview_right__header__icons",
180
- }, [
181
- h(AButton, {
182
- class: "a_btn a_btn_transparent_dark a_btn_small",
183
- disabled: this.disabledBtnArrowLeft,
184
- iconLeft: "ArrowLeft",
185
- title: "_A_TABLE_PREVIEW_RIGHT_PREVIOUS_ROW_",
186
- textScreenReader: "_A_TABLE_PREVIEW_RIGHT_PREVIOUS_ROW_",
187
- onClick: this.toPreviousRow,
188
- }),
189
- h(AButton, {
190
- class: "a_btn a_btn_transparent_dark a_btn_small",
191
- disabled: this.disabledBtnArrowRight,
192
- iconLeft: "ArrowRight",
193
- title: "_A_TABLE_PREVIEW_RIGHT_NEXT_ROW_",
194
- textScreenReader: "_A_TABLE_PREVIEW_RIGHT_NEXT_ROW_",
195
- onClick: this.toNextRow,
196
- }),
197
- ]),
198
- ]),
199
- !this.isMobile ? h(AButton, {
200
- class: "a_btn a_btn_transparent_dark a_table__preview_right__btn_close",
201
- iconLeft: "Close",
202
- iconClass: "a_table__preview_right__btn_close__icon",
203
- title: "_A_TABLE_PREVIEW_RIGHT_CLOSE_",
204
- textScreenReader: "_A_TABLE_PREVIEW_RIGHT_CLOSE_",
205
- onClick: () => this.$emit("closePreview"),
206
- }) : "",
207
- ];
208
-
209
- const BODY = [
210
- this.isLoadingTable ? h(ACloak) :
211
- this.$slots.preview ?
212
- this.$slots.preview({
213
- row: this.currentRow,
214
- rowIndex: this.rowIndex,
215
- }) :
216
- h(ATranslation, {
217
- text: "_A_TABLE_PREVIEW_RIGHT_HAS_NOT_SLOT_",
218
- }),
219
- ];
220
-
221
- if (this.isMobile) {
222
- return h(AModal, {
223
- hideFooter: true,
224
- close: () => this.$emit("closePreview"),
225
- size: "xxl",
226
- }, {
227
- modalHeader: () => HEADER,
228
- modalBody: () => BODY,
229
- });
230
- }
231
-
232
- return h("div", {
233
- ref: "previewRef",
234
- id: this.idLocal,
235
- "aria-label": this.previewAriaLabel,
236
- class: "a_table__preview_right",
237
- style: this.previewStyles,
238
- tabindex: -1,
239
- }, [
240
- h(AResizer, {
241
- class: "a_table__preview_right__resizer",
242
- direction: "x",
243
- disabled: this.isLoadingOptions,
244
- onMousedown: this.mousedown,
245
- onMousemove: this.mousemove,
246
- onMouseup: this.mouseup,
247
- onMouseoutDocument: this.mouseup,
248
- }),
249
- h(this.previewHeaderTag, {
250
- class: "a_table__preview_right__header",
251
- }, HEADER),
252
- h("div", {
253
- class: "a_table__preview_right__body",
254
- }, BODY),
255
- ]);
256
- },
257
- };
1
+ import {
2
+ h,
3
+ onBeforeUnmount,
4
+ onMounted, toRef,
5
+ } from "vue";
6
+
7
+ import AButton from "../../AButton/AButton";
8
+ import ACloak from "../../ACloak/ACloak";
9
+ import AModal from "../../AModal/AModal";
10
+ import AResizer from "../../AResizer/AResizer";
11
+ import ATranslation from "../../ATranslation/ATranslation";
12
+
13
+ import ArrowsAPI from "./compositionAPI/ArrowsAPI";
14
+ import IdAPI from "./compositionAPI/IdAPI";
15
+ import MouseEventsAPI from "./compositionAPI/MouseEventsAPI";
16
+ import PreviewRightRewAPI from "../compositionAPI/PreviewRightRewAPI";
17
+ import RowAPI from "./compositionAPI/RowAPI";
18
+
19
+ export default {
20
+ name: "ATablePreviewRight",
21
+ props: {
22
+ countAllRows: {
23
+ type: Number,
24
+ required: true,
25
+ },
26
+ disabledPreviewRowCallback: {
27
+ type: Function,
28
+ required: false,
29
+ default: () => {},
30
+ },
31
+ isLoadingTable: {
32
+ type: Boolean,
33
+ required: false,
34
+ },
35
+ isMobile: {
36
+ type: Boolean,
37
+ required: false,
38
+ },
39
+ limitPagination: {
40
+ type: Number,
41
+ required: false,
42
+ default: undefined,
43
+ },
44
+ offsetPagination: {
45
+ type: Number,
46
+ required: false,
47
+ default: undefined,
48
+ },
49
+ previewHeaderTag: {
50
+ type: String,
51
+ required: true,
52
+ },
53
+ previewStyles: {
54
+ type: [String, Object],
55
+ required: false,
56
+ default: undefined,
57
+ },
58
+ rowIndex: {
59
+ type: Number,
60
+ required: true,
61
+ },
62
+ rows: {
63
+ type: Array,
64
+ required: true,
65
+ },
66
+ usePagination: {
67
+ type: Boolean,
68
+ required: false,
69
+ },
70
+ },
71
+ emits: [
72
+ "closePreview",
73
+ "mousedownResizePreviewRight",
74
+ "mousemoveResizePreviewRight",
75
+ "mouseupResizePreviewRight",
76
+ "togglePreviewResize",
77
+ "togglePreview",
78
+ "update:offset",
79
+ ],
80
+ inject: [
81
+ "isLoadingOptions",
82
+ ],
83
+ setup(props, context) {
84
+ const isMobile = toRef(props, "isMobile");
85
+
86
+ const {
87
+ previewRef,
88
+ } = PreviewRightRewAPI();
89
+
90
+ const {
91
+ idLocal,
92
+ } = IdAPI();
93
+
94
+ const {
95
+ mousedown,
96
+ mousemove,
97
+ mouseup,
98
+ } = MouseEventsAPI(context, {
99
+ previewRef,
100
+ });
101
+
102
+ const {
103
+ countAllRowsFormatted,
104
+ currentRow,
105
+ nextAvailableRowIndex,
106
+ previousAvailableRowIndex,
107
+ rowNumber,
108
+ rowNumberFormatted,
109
+ } = RowAPI(props);
110
+
111
+ const {
112
+ disabledBtnArrowLeft,
113
+ disabledBtnArrowRight,
114
+ toNextRow,
115
+ toPreviousRow,
116
+ } = ArrowsAPI(props, context, {
117
+ nextAvailableRowIndex,
118
+ previousAvailableRowIndex,
119
+ rowNumber,
120
+ });
121
+
122
+ onMounted(() => {
123
+ if (!isMobile.value) {
124
+ context.emit("togglePreviewResize", {
125
+ isOpen: true,
126
+ previewRef: previewRef.value,
127
+ });
128
+ }
129
+ });
130
+
131
+ onBeforeUnmount(() => {
132
+ if (!isMobile.value) {
133
+ context.emit("togglePreviewResize", {
134
+ isOpen: false,
135
+ previewRef: previewRef.value,
136
+ });
137
+ }
138
+ });
139
+
140
+ return {
141
+ countAllRowsFormatted,
142
+ currentRow,
143
+ disabledBtnArrowLeft,
144
+ disabledBtnArrowRight,
145
+ idLocal,
146
+ mousedown,
147
+ mousemove,
148
+ mouseup,
149
+ previewRef,
150
+ rowNumber,
151
+ rowNumberFormatted,
152
+ toNextRow,
153
+ toPreviousRow,
154
+ };
155
+ },
156
+ render() {
157
+ const HEADER = [
158
+ this.isLoadingTable ?
159
+ h(ACloak) :
160
+ h("div", {}, [
161
+ h(ATranslation, {
162
+ class: "a_table__preview_right__header__text",
163
+ tag: "span",
164
+ text: "_A_TABLE_PREVIEW_RIGHT_HEADER_{{rowNumber}}_{{rowNumberFormatted}}_{{countAllRows}}_{{countAllRowsFormatted}}_",
165
+ extra: {
166
+ rowNumber: this.rowNumber,
167
+ rowNumberFormatted: this.rowNumberFormatted,
168
+ countAllRows: this.countAllRows,
169
+ countAllRowsFormatted: this.countAllRowsFormatted,
170
+ },
171
+ }),
172
+ h("div", {
173
+ class: "a_table__preview_right__header__icons",
174
+ }, [
175
+ h(AButton, {
176
+ class: "a_btn a_btn_transparent_dark a_btn_small",
177
+ disabled: this.disabledBtnArrowLeft,
178
+ iconLeft: "ArrowLeft",
179
+ title: "_A_TABLE_PREVIEW_RIGHT_PREVIOUS_ROW_",
180
+ textScreenReader: "_A_TABLE_PREVIEW_RIGHT_PREVIOUS_ROW_",
181
+ onClick: this.toPreviousRow,
182
+ }),
183
+ h(AButton, {
184
+ class: "a_btn a_btn_transparent_dark a_btn_small",
185
+ disabled: this.disabledBtnArrowRight,
186
+ iconLeft: "ArrowRight",
187
+ title: "_A_TABLE_PREVIEW_RIGHT_NEXT_ROW_",
188
+ textScreenReader: "_A_TABLE_PREVIEW_RIGHT_NEXT_ROW_",
189
+ onClick: this.toNextRow,
190
+ }),
191
+ ]),
192
+ ]),
193
+ !this.isMobile ? h(AButton, {
194
+ class: "a_btn a_btn_transparent_dark a_table__preview_right__btn_close",
195
+ iconLeft: "Close",
196
+ iconClass: "a_table__preview_right__btn_close__icon",
197
+ title: "_A_TABLE_PREVIEW_RIGHT_CLOSE_",
198
+ textScreenReader: "_A_TABLE_PREVIEW_RIGHT_CLOSE_",
199
+ onClick: () => this.$emit("closePreview"),
200
+ }) : "",
201
+ ];
202
+
203
+ const BODY = [
204
+ this.isLoadingTable ? h(ACloak) :
205
+ this.$slots.preview ?
206
+ this.$slots.preview({
207
+ row: this.currentRow,
208
+ rowIndex: this.rowIndex,
209
+ }) :
210
+ h(ATranslation, {
211
+ text: "_A_TABLE_PREVIEW_RIGHT_HAS_NOT_SLOT_",
212
+ }),
213
+ ];
214
+
215
+ if (this.isMobile) {
216
+ return h(AModal, {
217
+ hideFooter: true,
218
+ close: () => this.$emit("closePreview"),
219
+ size: "xxl",
220
+ }, {
221
+ modalHeader: () => HEADER,
222
+ modalBody: () => BODY,
223
+ });
224
+ }
225
+
226
+ return h("div", {
227
+ ref: "previewRef",
228
+ id: this.idLocal,
229
+ class: "a_table__preview_right",
230
+ style: this.previewStyles,
231
+ tabindex: -1,
232
+ }, [
233
+ h(AResizer, {
234
+ class: "a_table__preview_right__resizer",
235
+ direction: "x",
236
+ disabled: this.isLoadingOptions,
237
+ onMousedown: this.mousedown,
238
+ onMousemove: this.mousemove,
239
+ onMouseup: this.mouseup,
240
+ onMouseoutDocument: this.mouseup,
241
+ }),
242
+ h(ATranslation, {
243
+ class: "a_sr_only",
244
+ text: "_A_TABLE_PREVIEW_RIGHT_ARIA_LABEL_",
245
+ }),
246
+ h(this.previewHeaderTag, {
247
+ class: "a_table__preview_right__header",
248
+ }, HEADER),
249
+ h("div", {
250
+ class: "a_table__preview_right__body",
251
+ }, BODY),
252
+ ]);
253
+ },
254
+ };
@@ -33,19 +33,23 @@ export default function ScrollControlAPI(props, { emit }, {
33
33
 
34
34
  const aTableRef = ref(undefined);
35
35
  const columnsVisibleAdditionalSpaceForOneGrow = ref(0);
36
+ const resizeTimeout = ref(undefined);
36
37
  const tableWidth = ref(undefined);
37
38
  let changingTableWidth = false;
39
+ const delta = 18; // approx scrollbar width
38
40
 
39
41
  const columnActionsWidthMinLocal = computed(() => {
40
42
  if (isActionColumnVisible.value) {
41
43
  return columnActionsWidthMin.value;
42
44
  }
45
+
43
46
  return 0;
44
47
  });
45
48
 
46
49
  const columnsSpecialWidth = computed(() => {
47
50
  const columnMultipleActionsWidth = isMultipleActionsActive.value ? columnActionsWidthMin.value : 0;
48
- const scrollBarWidth = isSimpleTable.value ? 0 : 10; // delta for table resize when scrollbar appears
51
+ const scrollBarWidth = isSimpleTable.value ? 0 : delta; // delta for table resize when scrollbar appears
52
+
49
53
  return columnMultipleActionsWidth + scrollBarWidth;
50
54
  });
51
55
 
@@ -153,11 +157,12 @@ export default function ScrollControlAPI(props, { emit }, {
153
157
  setColumnsScrollInvisible();
154
158
  };
155
159
 
156
- const resizeOb = new ResizeObserver(entries => {
157
- // since we are observing only a single element, so we access the first element in entries array
158
- // TODO add delta for table resize when scrollbar appears
160
+ const adjustTableWidth = ({ entries, forceAdjust }) => {
159
161
  const RECT = entries[0].contentRect;
160
- if (tableWidth.value !== RECT.width) {
162
+ const tableWidthMissingOrExceededDelta = forceAdjust ||
163
+ tableWidth.value > RECT.width + delta ||
164
+ tableWidth.value < RECT.width - delta;
165
+ if (tableWidthMissingOrExceededDelta) {
161
166
  if (!changingTableWidth) {
162
167
  changingTableWidth = true;
163
168
  tableWidth.value = RECT.width;
@@ -165,6 +170,19 @@ export default function ScrollControlAPI(props, { emit }, {
165
170
  changingTableWidth = false;
166
171
  }
167
172
  }
173
+ };
174
+
175
+ const resizeOb = new ResizeObserver(entries => {
176
+ // since we are observing only a single element, so we access the first element in entries array
177
+ if (!tableWidth.value) {
178
+ adjustTableWidth({ entries, forceAdjust: true });
179
+ } else {
180
+ clearTimeout(resizeTimeout.value);
181
+
182
+ resizeTimeout.value = setTimeout(() => {
183
+ adjustTableWidth({ entries });
184
+ }, 300);
185
+ }
168
186
  });
169
187
 
170
188
  const onWatchMobileScrollControl = newValue => {
@@ -1,19 +0,0 @@
1
- import {
2
- computed,
3
- } from "vue";
4
-
5
- import {
6
- getTranslatedText,
7
- } from "../../../ATranslation/compositionAPI/UtilsAPI";
8
-
9
- export default function AriaLabelAPI() {
10
- const previewAriaLabel = computed(() => {
11
- return getTranslatedText({
12
- placeholder: "_A_TABLE_PREVIEW_DOWN_ARIA_LABEL_",
13
- });
14
- });
15
-
16
- return {
17
- previewAriaLabel,
18
- };
19
- }
@@ -1,19 +0,0 @@
1
- import {
2
- computed,
3
- } from "vue";
4
-
5
- import {
6
- getTranslatedText,
7
- } from "../../../ATranslation/compositionAPI/UtilsAPI";
8
-
9
- export default function AriaLabelAPI() {
10
- const previewAriaLabel = computed(() => {
11
- return getTranslatedText({
12
- placeholder: "_A_TABLE_PREVIEW_RIGHT_ARIA_LABEL_",
13
- });
14
- });
15
-
16
- return {
17
- previewAriaLabel,
18
- };
19
- }