aloha-vue 1.2.101 → 1.2.103

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.101",
17
+ "version": "1.2.103",
18
18
  "author": {
19
19
  "name": "Ilia Brykin",
20
20
  "email": "brykin.ilia@gmail.com"
@@ -407,6 +407,7 @@ export default {
407
407
  const {
408
408
  columnIdsGroupByLocked,
409
409
  columnsFilteredForRender,
410
+ columnsFilteredForRenderIndexesMapping,
410
411
  columnsOrdered,
411
412
  countNotHiddenColumns,
412
413
  } = ColumnsAPI(props, {
@@ -462,6 +463,7 @@ export default {
462
463
  } = ColumnsOrderingAPI(props, context, {
463
464
  checkVisibleColumns,
464
465
  columnIdsGroupByLocked,
466
+ columnsFilteredForRenderIndexesMapping,
465
467
  });
466
468
 
467
469
  const {
@@ -88,7 +88,8 @@ export default {
88
88
  } = DragAndDropParentAPI({
89
89
  classOver: "a_table__th_over",
90
90
  classOverRight: "a_table__th_over_right",
91
- classOverParent: "a_table__th"
91
+ classOverParent: "a_table__th",
92
+ inHeader: true,
92
93
  });
93
94
 
94
95
  const {
@@ -74,6 +74,7 @@ export default {
74
74
  root,
75
75
  } = DragAndDropChildAPI(props, context, {
76
76
  classOverString: "a_table__th_over",
77
+ inDropdown: false,
77
78
  });
78
79
 
79
80
  const {
@@ -53,6 +53,7 @@ export default {
53
53
  classOver: "a_table__th__dropdown__li_over",
54
54
  classOverRight: "a_table__th__dropdown__li_over_right",
55
55
  classOverParent: "a_table__th__dropdown__li",
56
+ inHeader: false,
56
57
  });
57
58
 
58
59
  const {
@@ -63,6 +63,7 @@ export default {
63
63
  root,
64
64
  } = DragAndDropChildAPI(props, context, {
65
65
  classOverString: "a_table__th__dropdown__li_over",
66
+ inDropdown: true,
66
67
  });
67
68
 
68
69
  const {
@@ -176,6 +176,9 @@ export default {
176
176
  labelClass: "a_sr_only",
177
177
  isLabelTitle: true,
178
178
  "onUpdate:modelValue": this.toggleCheckbox,
179
+ onClick: $event => {
180
+ $event.stopPropagation();
181
+ },
179
182
  }),
180
183
  ]),
181
184
  CHILDREN,
@@ -9,7 +9,6 @@ import {
9
9
  } from "../utils/utils.js";
10
10
  import {
11
11
  cloneDeep,
12
- filter,
13
12
  forEach,
14
13
  keyBy,
15
14
  } from "lodash-es";
@@ -68,17 +67,35 @@ export default function ColumnsAPI(props, {
68
67
  return COLUMNS;
69
68
  });
70
69
 
71
-
72
- const columnsFilteredForRender = computed(() => {
73
- return filter(columnsOrdered.value, (column, columnIndex) => {
74
- return isColumnVisible({
70
+ const columnsFilteredForRenderObj = computed(() => {
71
+ const COLUMNS = [];
72
+ const COLUMNS_INDEXES_MAPPING = {};
73
+ forEach(columnsOrdered.value, (column, columnIndex) => {
74
+ if (isColumnVisible({
75
75
  column,
76
76
  columnIndex,
77
77
  modelIsTableWithoutScroll: modelIsTableWithoutScroll.value,
78
78
  modelColumnsVisibleLocal: modelColumnsVisibleLocal.value,
79
79
  indexFirstScrollInvisibleColumn: indexFirstScrollInvisibleColumn.value,
80
- });
80
+ })) {
81
+ COLUMNS_INDEXES_MAPPING[COLUMNS.length] = columnIndex;
82
+ COLUMNS.push(column);
83
+ }
81
84
  });
85
+
86
+ return {
87
+ columns: COLUMNS,
88
+ columnsIndexesMapping: COLUMNS_INDEXES_MAPPING,
89
+ };
90
+ });
91
+
92
+ const columnsFilteredForRenderIndexesMapping = computed(() => {
93
+ return columnsFilteredForRenderObj.value.columnsIndexesMapping;
94
+ });
95
+
96
+
97
+ const columnsFilteredForRender = computed(() => {
98
+ return columnsFilteredForRenderObj.value.columns;
82
99
  });
83
100
 
84
101
  const countNotHiddenColumns = computed(() => {
@@ -98,6 +115,7 @@ export default function ColumnsAPI(props, {
98
115
  return {
99
116
  columnIdsGroupByLocked,
100
117
  columnsFilteredForRender,
118
+ columnsFilteredForRenderIndexesMapping,
101
119
  columnsOrdered,
102
120
  countNotHiddenColumns,
103
121
  };
@@ -20,14 +20,20 @@ export default function ColumnsOrderingAPI(props, { emit }, {
20
20
  trueColumns: [],
21
21
  falseColumns: [],
22
22
  })),
23
+ columnsFilteredForRenderIndexesMapping = computed(() => ({})),
23
24
  }) {
24
25
  const columns = toRef(props, "columns");
25
26
  const modelColumnsOrdering = toRef(props, "modelColumnsOrdering");
26
27
 
27
- const changeColumnsOrdering = ({ columnIndexDraggable, columnIndexOver, reset }) => {
28
+ const changeColumnsOrdering = ({ columnIndexDraggable, columnIndexOver, reset, inHeader }) => {
28
29
  if (columnIndexDraggable === columnIndexOver && !reset) {
29
30
  return;
30
31
  }
32
+ // Not all columns may be shown, so the order may be out of order
33
+ if (inHeader) {
34
+ columnIndexDraggable = columnsFilteredForRenderIndexesMapping.value[columnIndexDraggable];
35
+ columnIndexOver = columnsFilteredForRenderIndexesMapping.value[columnIndexOver];
36
+ }
31
37
  let modelColumnsOrderingLocal = [];
32
38
  if (reset) {
33
39
  modelColumnsOrderingLocal = [...columnIdsGroupByLocked.value.true, ...columnIdsGroupByLocked.value.false];
@@ -5,8 +5,11 @@ import {
5
5
  toRef,
6
6
  } from "vue";
7
7
 
8
+ const CLASS_DRAG = "a_table__drag_element";
9
+
8
10
  export default function DragAndDropChildAPI(props, { emit }, {
9
11
  classOverString = "",
12
+ inDropdown = false,
10
13
  }) {
11
14
  const column = toRef(props, "column");
12
15
  const columnIndex = toRef(props, "columnIndex");
@@ -25,7 +28,11 @@ export default function DragAndDropChildAPI(props, { emit }, {
25
28
  });
26
29
 
27
30
  const dragstart = $event => {
28
- $event.target.style.opacity = "0.4";
31
+ $event.target?.classList.add(CLASS_DRAG);
32
+ if (inDropdown) {
33
+ const HEIGHT = $event.target?.offsetHeight || 30;
34
+ $event.target?.parentElement.style.setProperty("--a_table_draggable_li_height", `${ HEIGHT }px`);
35
+ }
29
36
  $event.dataTransfer.effectAllowed = "move";
30
37
  emit("dragstartParent", {
31
38
  columnIndex: columnIndex.value,
@@ -33,8 +40,8 @@ export default function DragAndDropChildAPI(props, { emit }, {
33
40
  };
34
41
 
35
42
  const dragend = $event => {
36
- $event.target.style.opacity = "1";
37
- $event.target.classList.remove(classOver.value);
43
+ $event.target?.classList.remove(classOver.value);
44
+ $event.target?.classList.remove(CLASS_DRAG);
38
45
  emit("dragendParent");
39
46
  };
40
47
 
@@ -55,7 +62,7 @@ export default function DragAndDropChildAPI(props, { emit }, {
55
62
  };
56
63
 
57
64
  const dragleave = () => {
58
- if (root.value && root.value) {
65
+ if (root.value && root.value.classList) {
59
66
  root.value.classList.remove(classOver.value);
60
67
  }
61
68
  emit("dragleaveParent", {
@@ -13,6 +13,7 @@ export default function DragAndDropParentAPI({
13
13
  classOver = "",
14
14
  classOverRight = "",
15
15
  classOverParent = "",
16
+ inHeader = false,
16
17
  }) {
17
18
  const root = ref(undefined);
18
19
  const columnIndexDraggable = ref(undefined);
@@ -45,6 +46,7 @@ export default function DragAndDropParentAPI({
45
46
  changeColumnsOrdering({
46
47
  columnIndexDraggable: columnIndexDraggable.value,
47
48
  columnIndexOver: columnIndexOver.value,
49
+ inHeader,
48
50
  });
49
51
  $event.stopPropagation();
50
52
  return false;
@@ -44,6 +44,8 @@
44
44
  --a_table_multiple_items_selected_bg: var(--a_table_row_preview_was_open_bg);
45
45
  --a_table_sort_sequence_num_bg: var(--a_color_primary);
46
46
  --a_table_sort_sequence_num_color: var(--a_color_white);
47
+ --a_table_dnd_th_bg: var(--a_color_gray_500);
48
+ --a_table_dnd_th_width: 50px;
47
49
 
48
50
  width: 100%;
49
51
  overflow-x: hidden;
@@ -83,6 +85,7 @@
83
85
 
84
86
  .a_table__cell__child {
85
87
  width: 100%;
88
+ overflow-x: auto;
86
89
  }
87
90
  .a_table__cell_checkbox {
88
91
  --a_table_cell_padding_x: 0;
@@ -126,8 +129,13 @@
126
129
  align-items: center;
127
130
  position: relative;
128
131
  background-color: inherit;
132
+ padding: 0;
133
+ .a_table__cell__child {
134
+ padding: var(--a_table_cell_padding_y) var(--a_table_cell_padding_x);
135
+ }
129
136
  &.a_table__cell_action {
130
137
  background-color: inherit;
138
+ padding: var(--a_table_cell_padding_y) var(--a_table_cell_padding_x);
131
139
  }
132
140
  + .a_table__th {
133
141
  border-left: var(--a_table_th_border_left_width) solid var(--a_table_th_border_left_color);
@@ -155,41 +163,29 @@
155
163
  cursor: move;
156
164
  }
157
165
  .a_table__th_over {
158
- border-left: 6px solid var(--a_table_draggable_color);
159
166
  position: relative;
160
- &:before,
161
- &:after {
162
- content: "";
163
- position: absolute;
164
- left: -15px;
165
- border: 12px solid transparent;
166
- }
167
167
  &:before {
168
- top: 0;
169
- border-top: 15px solid var(--a_table_draggable_color);
170
- }
171
- &:after {
172
- bottom: calc(-1 * var(--a_table_th_border_bottom_width));
173
- border-bottom: 15px solid var(--a_table_draggable_color);
168
+ content: "";
169
+ display: block;
170
+ width: var(--a_table_dnd_th_width);
171
+ height: 100%;
172
+ background-color: var(--a_table_dnd_th_bg);
174
173
  }
175
174
  }
176
175
  .a_table__th_over_right {
177
- border-right: 6px solid var(--a_table_draggable_color);
178
- position: relative;
179
- &:before,
180
176
  &:after {
181
177
  content: "";
182
- position: absolute;
183
- right: -15px;
184
- border: 12px solid transparent;
185
- }
186
- &:before {
187
- top: 0;
188
- border-top: 15px solid var(--a_table_draggable_color);
178
+ display: block;
179
+ width: var(--a_table_dnd_th_width);
180
+ height: 100%;
181
+ background-color: var(--a_table_dnd_th_bg);
189
182
  }
190
- &:after {
191
- bottom: calc(-1 * var(--a_table_th_border_bottom_width));
192
- border-bottom: 15px solid var(--a_table_draggable_color);
183
+ }
184
+ .a_table__th,
185
+ .a_table__th__dropdown__li {
186
+ .a_sr_only,
187
+ .a_sr_only_focusable:not(:focus):not(:focus-within) {
188
+ position: absolute !important;
193
189
  }
194
190
  }
195
191
 
@@ -203,41 +199,19 @@
203
199
  }
204
200
 
205
201
  .a_table__th__dropdown__li_over {
206
- border-top: 6px solid var(--a_table_draggable_color);
207
- position: relative;
208
- &:before,
209
- &:after {
210
- content: "";
211
- position: absolute;
212
- top: -15px;
213
- border: 12px solid transparent;
214
- }
215
202
  &:before {
216
- left: 0;
217
- border-left: 15px solid var(--a_table_draggable_color);
218
- }
219
- &:after {
220
- right: 0;
221
- border-right: 15px solid var(--a_table_draggable_color);
203
+ content: "";
204
+ display: block;
205
+ height: var(--a_table_draggable_li_height);
206
+ background-color: var(--a_table_dnd_dropdown_li_bg);
222
207
  }
223
208
  }
224
209
  .a_table__th__dropdown__li_over_right {
225
- border-bottom: 6px solid var(--a_table_draggable_color);
226
- position: relative;
227
- &:before,
228
210
  &:after {
229
211
  content: "";
230
- position: absolute;
231
- bottom: -15px;
232
- border: 12px solid transparent;
233
- }
234
- &:before {
235
- left: 0;
236
- border-left: 15px solid var(--a_table_draggable_color);
237
- }
238
- &:after {
239
- right: 0;
240
- border-right: 15px solid var(--a_table_draggable_color);
212
+ display: block;
213
+ height: var(--a_table_draggable_li_height);
214
+ background-color: var(--a_table_dnd_dropdown_li_bg);
241
215
  }
242
216
  }
243
217
 
@@ -366,11 +340,17 @@
366
340
 
367
341
  .a_table__th__dropdown__ul {
368
342
  --a_table_draggable_color: var(--a_color_primary);
343
+ --a_table_dnd_dropdown_li_bg: var(--a_color_gray_200);
344
+ --a_table_draggable_li_height: 30px;
369
345
 
346
+ position: relative;
370
347
  list-style: none;
371
348
  margin: 0;
372
349
  padding: 0;
373
350
  }
351
+ .a_table__drag_element {
352
+ opacity: 0.4;
353
+ }
374
354
  .a_table__th__dropdown__ul_dragstart .a_table__th__dropdown__li > * {
375
355
  pointer-events: none;
376
356
  }