aloha-vue 1.2.163 → 1.2.164

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.163",
17
+ "version": "1.2.164",
18
18
  "author": {
19
19
  "name": "Ilia Brykin",
20
20
  "email": "brykin.ilia@gmail.com"
@@ -239,7 +239,7 @@ export default {
239
239
  change: this.changeModelFiltersSaved,
240
240
  class: "a_filters_top__save_select",
241
241
  data: this.filtersSavedLocal,
242
- deselect: false,
242
+ deselectable: false,
243
243
  keyId: "label",
244
244
  keyLabel: "label",
245
245
  keyGroup: "group",
@@ -41,6 +41,9 @@ import {
41
41
  tablePluginOptions,
42
42
  } from "../plugins/ATablePlugin";
43
43
 
44
+ import {
45
+ getRowIdOrIndex,
46
+ } from "./utils/utils";
44
47
  import {
45
48
  isInteger,
46
49
  uniqueId,
@@ -213,7 +216,7 @@ export default {
213
216
  keyId: {
214
217
  type: String,
215
218
  required: false,
216
- default: "id",
219
+ default: undefined,
217
220
  },
218
221
  keyChildren: {
219
222
  type: String,
@@ -448,6 +451,7 @@ export default {
448
451
  columnWidthDefault: computed(() => this.columnWidthDefault),
449
452
  isLoadingOptions: computed(() => this.isLoadingOptions),
450
453
  isLoadingTable: computed(() => this.isLoadingTable),
454
+ keyId: computed(() => this.keyId),
451
455
  rowActions: computed(() => this.rowActions),
452
456
  tableId: computed(() => this.id),
453
457
  valuesForColumnDefault: computed(() => this.valuesForColumnDefault),
@@ -623,7 +627,7 @@ export default {
623
627
  mousedownResizePreviewRight,
624
628
  mousemoveResizePreviewRight,
625
629
  mouseupResizePreviewRight,
626
- previewDownRowIndexes,
630
+ previewDownRowIds,
627
631
  previewRightRowIndex,
628
632
  previewRightRowIndexLast,
629
633
  togglePreviewResize,
@@ -747,7 +751,7 @@ export default {
747
751
  mouseupResizePreviewRight,
748
752
  offset,
749
753
  onTogglePreview,
750
- previewDownRowIndexes,
754
+ previewDownRowIds,
751
755
  previewRightRowIndex,
752
756
  renderedGroupedColumns,
753
757
  rowsLocal,
@@ -902,8 +906,10 @@ export default {
902
906
  role: this.tableChildRole,
903
907
  }, {
904
908
  default: () => this.rowsLocal.map((row, rowIndex) => {
909
+ const ROW_ID = getRowIdOrIndex({ row, rowIndex, keyId: this.keyId });
910
+
905
911
  return h(ATableTr, {
906
- key: row[this.keyId] || rowIndex,
912
+ key: ROW_ID,
907
913
  allVisibleMobileColumns: this.allVisibleMobileColumns,
908
914
  areAllRowsSelected: this.areAllRowsSelected,
909
915
  countVisibleMobileColumns: this.countVisibleMobileColumns,
@@ -911,7 +917,7 @@ export default {
911
917
  disabledPreviewRowCallback: this.disabledPreviewRowCallback,
912
918
  disabledRowActions: this.disabledRowActions,
913
919
  isFooter: false,
914
- isPreviewDownOpen: this.previewDownRowIndexes[rowIndex],
920
+ isPreviewDownOpen: this.previewDownRowIds[ROW_ID],
915
921
  isRowActionsStickyLocal: this.isRowActionsStickyLocal,
916
922
  isTree: this.isTree,
917
923
  keyChildren: this.keyChildren,
@@ -943,7 +949,10 @@ export default {
943
949
  class: "a_table__footer",
944
950
  role: this.tableChildRole,
945
951
  }, this.rowsFooter.map((row, rowIndex) => {
952
+ const ROW_ID = getRowIdOrIndex({ row, rowIndex, keyId: this.keyId });
953
+
946
954
  return h(ATableTr, {
955
+ key: ROW_ID,
947
956
  allVisibleMobileColumns: this.allVisibleMobileColumns,
948
957
  areAllRowsSelected: this.areAllRowsSelected,
949
958
  countVisibleMobileColumns: this.countVisibleMobileColumns,
@@ -141,7 +141,7 @@ export default {
141
141
  eventsLocal,
142
142
  roleLocal,
143
143
  rowClassComputed,
144
- rowId,
144
+ rowHtmlId,
145
145
  } = AttributesAPI(props, {
146
146
  hasChildren,
147
147
  hasPreviewLocal,
@@ -184,7 +184,7 @@ export default {
184
184
  previewAttributes,
185
185
  roleLocal,
186
186
  rowClassComputed,
187
- rowId,
187
+ rowHtmlId,
188
188
  textBtnToggleAllColumns,
189
189
  toggleAllColumnsVisibleMobile,
190
190
  toggleCheckbox,
@@ -248,7 +248,7 @@ export default {
248
248
 
249
249
  return [
250
250
  h("div", {
251
- id: this.rowId,
251
+ id: this.rowHtmlId,
252
252
  role: this.roleLocal,
253
253
  class: this.rowClassComputed,
254
254
  "aria-expanded": this.ariaExpanded,
@@ -4,13 +4,13 @@ import {
4
4
  toRef,
5
5
  } from "vue";
6
6
 
7
- import {
8
- isFunction,
9
- } from "lodash-es";
10
7
  import AKeysCode from "../../../const/AKeysCode";
11
8
  import {
12
9
  isClickTags,
13
10
  } from "../../utils/utils";
11
+ import {
12
+ isFunction,
13
+ } from "lodash-es";
14
14
 
15
15
  export default function AttributesAPI(props, {
16
16
  hasChildren = computed(() => false),
@@ -31,7 +31,7 @@ export default function AttributesAPI(props, {
31
31
  const onTogglePreview = inject("onTogglePreview");
32
32
  const tableId = inject("tableId");
33
33
 
34
- const rowId = computed(() => {
34
+ const rowHtmlId = computed(() => {
35
35
  const FOOTER_ID = isFooter.value ? "_footer" : "";
36
36
  return `${ tableId.value }${ FOOTER_ID }_${ rowIndex.value }`;
37
37
  });
@@ -113,6 +113,6 @@ export default function AttributesAPI(props, {
113
113
  eventsLocal,
114
114
  roleLocal,
115
115
  rowClassComputed,
116
- rowId,
116
+ rowHtmlId,
117
117
  };
118
118
  }
@@ -12,6 +12,7 @@ import {
12
12
  } from "../../utils/utilsDOM";
13
13
  import {
14
14
  getPreviewRightId,
15
+ getRowIdOrIndex,
15
16
  } from "../utils/utils";
16
17
  import {
17
18
  isNil,
@@ -39,10 +40,15 @@ export default function PreviewAPI(props, context, {
39
40
  aTableRef,
40
41
  tableGrandparentRef,
41
42
  });
42
- const emit = context.emit;
43
-
43
+ const keyId = toRef(props, "keyId");
44
44
  const preview = toRef(props, "preview");
45
45
  const tableId = toRef(props, "id");
46
+
47
+ const emit = context.emit;
48
+ const previewDownRowIds = ref({});
49
+ const previewRightRowIndex = ref(undefined);
50
+ const previewRightRowIndexLast = ref(undefined);
51
+
46
52
  const hasPreview = computed(() => {
47
53
  return !!preview.value;
48
54
  });
@@ -64,8 +70,7 @@ export default function PreviewAPI(props, context, {
64
70
  const isPreviewRight = computed(() => {
65
71
  return preview.value === "right" || isMobile.value;
66
72
  });
67
- const previewRightRowIndex = ref(undefined);
68
- const previewRightRowIndexLast = ref(undefined);
73
+
69
74
  const isPreviewRightOpen = computed(() => {
70
75
  return !isNil(previewRightRowIndex.value);
71
76
  });
@@ -99,14 +104,14 @@ export default function PreviewAPI(props, context, {
99
104
  return preview.value === "down";
100
105
  });
101
106
 
102
- const previewDownRowIndexes = ref({});
107
+ const closePreviewDown = ({ rowIndex, row }) => {
108
+ const ID = getRowIdOrIndex({ row, rowIndex, keyId: keyId.value });
103
109
 
104
- const closePreviewDown = ({ rowIndex }) => {
105
- previewDownRowIndexes.value[rowIndex] = undefined;
110
+ delete previewDownRowIds.value[ID];
106
111
  };
107
112
 
108
113
  const closePreviewDownAll = () => {
109
- previewDownRowIndexes.value = {};
114
+ previewDownRowIds.value = {};
110
115
  };
111
116
 
112
117
  const closePreviewAll = () => {
@@ -114,12 +119,11 @@ export default function PreviewAPI(props, context, {
114
119
  closePreviewDownAll();
115
120
  };
116
121
 
117
- const closePreview = ({ rowIndex } = {}) => {
122
+ const closePreview = ({ rowIndex, row } = {}) => {
118
123
  if (isPreviewRight.value) {
119
124
  closePreviewRight();
120
- }
121
- if (isPreviewDown.value) {
122
- closePreviewDown({ rowIndex });
125
+ } else if (isPreviewDown.value) {
126
+ closePreviewDown({ rowIndex, row });
123
127
  }
124
128
  };
125
129
 
@@ -145,15 +149,18 @@ export default function PreviewAPI(props, context, {
145
149
  openPreviewRight({ rowIndex });
146
150
  }
147
151
  };
148
- const onTogglePreviewDown = ({ rowIndex }) => {
149
- if (previewDownRowIndexes.value[rowIndex]) {
150
- previewDownRowIndexes.value[rowIndex] = undefined;
152
+
153
+ const onTogglePreviewDown = ({ rowIndex, row }) => {
154
+ const ID = getRowIdOrIndex({ row, rowIndex, keyId: keyId.value });
155
+
156
+ if (previewDownRowIds.value[ID]) {
157
+ delete previewDownRowIds.value[ID];
151
158
  } else {
152
- previewDownRowIndexes.value[rowIndex] = true;
159
+ previewDownRowIds.value[ID] = true;
153
160
  }
154
161
  };
155
162
 
156
- const onTogglePreview = ({ rowIndex }) => {
163
+ const onTogglePreview = ({ row, rowIndex }) => {
157
164
  if (isDropdownGlobalOpen.value) {
158
165
  return;
159
166
  }
@@ -162,7 +169,7 @@ export default function PreviewAPI(props, context, {
162
169
  return;
163
170
  }
164
171
  if (isPreviewDown.value) {
165
- onTogglePreviewDown({ rowIndex });
172
+ onTogglePreviewDown({ row, rowIndex });
166
173
  }
167
174
  };
168
175
 
@@ -175,7 +182,7 @@ export default function PreviewAPI(props, context, {
175
182
  mousemoveResizePreviewRight,
176
183
  mouseupResizePreviewRight,
177
184
  onTogglePreview,
178
- previewDownRowIndexes,
185
+ previewDownRowIds,
179
186
  previewRightRowIndex,
180
187
  previewRightRowIndexLast,
181
188
  togglePreviewResize,
@@ -1,4 +1,4 @@
1
- import { isNil } from "lodash-es";
1
+ import { get, isNil } from "lodash-es";
2
2
 
3
3
  export function getModelColumnsVisibleDefault(columns) {
4
4
  const MODEL_COLUMNS_VISIBLE = {};
@@ -78,3 +78,11 @@ export function getMultiplePanelId({ tableId }) {
78
78
  export function getTableLabelId({ tableId }) {
79
79
  return `${ tableId }_header_label`;
80
80
  }
81
+
82
+ export function getRowIdOrIndex({ row, rowIndex, keyId }) {
83
+ if (keyId) {
84
+ return get(row, keyId);
85
+ }
86
+
87
+ return rowIndex;
88
+ }
@@ -674,7 +674,7 @@ export default {
674
674
  "aria-labelledby": this.ariaLabelledby,
675
675
  role: "combobox",
676
676
  tabindex: this.tabindex,
677
- ariaHaspopup: "listbox",
677
+ "aria-haspopup": "listbox",
678
678
  ariaExpanded: this.isOpen,
679
679
  ariaRequired: this.required,
680
680
  ariaDisabled: this.disabled,