aloha-vue 2.57.3 → 2.57.4

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.57.3",
3
+ "version": "2.57.4",
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",
@@ -215,7 +215,7 @@ export default {
215
215
  } = IconsAPI(props);
216
216
 
217
217
  const {
218
- classesLocal,
218
+ actionsClassesLocal,
219
219
  } = ClassesAPI(props);
220
220
 
221
221
  const {
@@ -302,7 +302,7 @@ export default {
302
302
  canAddRow,
303
303
  canMoveRowDown,
304
304
  canMoveRowUp,
305
- classesLocal,
305
+ actionsClassesLocal,
306
306
  columnsStylesGrow,
307
307
  draggedRowIndex,
308
308
  dragOverPosition,
@@ -413,7 +413,7 @@ export default {
413
413
  return h(ATableFormRow, {
414
414
  key: rowKey,
415
415
  id: this.id,
416
- actionsClasses: this.actionsClasses,
416
+ actionsClasses: this.actionsClassesLocal,
417
417
  actionsDisabledCallback: this.actionsDisabledCallback,
418
418
  actionsHideCallback: this.actionsHideCallback,
419
419
  actionsTitleCallback: this.actionsTitleCallback,
@@ -469,7 +469,7 @@ export default {
469
469
  }),
470
470
  this.isAddRowActive && h(ATableFormRow, {
471
471
  id: this.id,
472
- actionsClasses: this.actionsClasses,
472
+ actionsClasses: this.actionsClassesLocal,
473
473
  actionsDisabledCallback: this.actionsDisabledCallback,
474
474
  actionsHideCallback: this.actionsHideCallback,
475
475
  actionsTitleCallback: this.actionsTitleCallback,
@@ -532,7 +532,7 @@ export default {
532
532
  }, this.rowsFooter.map((row, rowIndex) => {
533
533
  return h(ATableFormRow, {
534
534
  id: this.id,
535
- actionsClasses: this.actionsClasses,
535
+ actionsClasses: this.actionsClassesLocal,
536
536
  actionsDisabledCallback: this.actionsDisabledCallback,
537
537
  actionsHideCallback: this.actionsHideCallback,
538
538
  actionsTitleCallback: this.actionsTitleCallback,
@@ -582,7 +582,7 @@ export default {
582
582
  class: "a_mt_3 a_text_right",
583
583
  }, [
584
584
  h(AButton, {
585
- class: this.classesLocal.addRow,
585
+ class: this.actionsClassesLocal.addRow,
586
586
  disabled: this.isAddDisabled,
587
587
  extra: this.extra,
588
588
  iconLeft: this.iconsLocal.actionAddRow,
@@ -8,6 +8,7 @@ import ATranslation from "../../ATranslation/ATranslation";
8
8
  import DeleteAPI from "./compositionAPI/DeleteAPI";
9
9
  import DisabledAPI from "./compositionAPI/DisabledAPI";
10
10
  import HiddenAPI from "./compositionAPI/HiddenAPI";
11
+ import IdsAPI from "./compositionAPI/IdsAPI";
11
12
  import StylesAPI from "./compositionAPI/StylesAPI";
12
13
  import TitleAPI from "./compositionAPI/TitleAPI";
13
14
 
@@ -141,9 +142,16 @@ export default {
141
142
  } = HiddenAPI(props);
142
143
 
143
144
  const {
145
+ idBtnCancel,
144
146
  idBtnDelete,
147
+ idBtnEdit,
148
+ idBtnSave,
149
+ } = IdsAPI(props);
150
+
151
+ const {
145
152
  onDeleteClick,
146
153
  } = DeleteAPI(props, {
154
+ idBtnDelete,
147
155
  isActionsDisabled: isDeleteDisabled,
148
156
  });
149
157
 
@@ -160,7 +168,10 @@ export default {
160
168
  columnStyles,
161
169
  deleteTitle,
162
170
  editTitle,
171
+ idBtnCancel,
163
172
  idBtnDelete,
173
+ idBtnEdit,
174
+ idBtnSave,
164
175
  isDeleteDisabled,
165
176
  isDeleteHidden,
166
177
  isEditDisabled,
@@ -199,6 +210,7 @@ export default {
199
210
  }, this.isActiveEditMode ?
200
211
  [
201
212
  h(AButton, {
213
+ id: this.idBtnCancel,
202
214
  class: [
203
215
  "a_table_form__action_button",
204
216
  this.actionsClasses.editCancel,
@@ -209,11 +221,14 @@ export default {
209
221
  title: this.texts.actionEditCancel,
210
222
  textScreenReader: this.texts.actionEditCancel,
211
223
  onClick: () => this.onCancelEditRow({
224
+ id: this.id,
212
225
  row: this.row,
213
226
  rowIndex: this.rowIndex,
227
+ trigger: "cancel",
214
228
  }),
215
229
  }),
216
230
  h(AButton, {
231
+ id: this.idBtnSave,
217
232
  class: [
218
233
  "a_table_form__action_button",
219
234
  this.actionsClasses.editSave,
@@ -224,6 +239,7 @@ export default {
224
239
  title: this.texts.actionEditSave,
225
240
  textScreenReader: this.texts.actionEditSave,
226
241
  onClick: () => this.onSaveEditRow({
242
+ id: this.id,
227
243
  row: this.row,
228
244
  rowIndex: this.rowIndex,
229
245
  }),
@@ -244,6 +260,7 @@ export default {
244
260
  onClick: this.onDeleteClick,
245
261
  }),
246
262
  this.isEditable && !this.isEditHidden && h(AButton, {
263
+ id: this.idBtnEdit,
247
264
  class: [
248
265
  "a_table_form__action_button",
249
266
  this.actionsClasses.edit,
@@ -254,6 +271,7 @@ export default {
254
271
  title: this.editTitle,
255
272
  textScreenReader: this.editTitle,
256
273
  onClick: () => this.onEditRow({
274
+ id: this.id,
257
275
  row: this.row,
258
276
  rowIndex: this.rowIndex,
259
277
  }),
@@ -9,9 +9,9 @@ import {
9
9
  } from "../../../index";
10
10
 
11
11
  export default function DeleteAPI(props, {
12
+ idBtnDelete = computed(() => ""),
12
13
  isActionsDisabled = computed(() => false),
13
14
  }) {
14
- const id = toRef(props, "id");
15
15
  const isDeletable = toRef(props, "isDeletable");
16
16
  const isDeletableConfirm = toRef(props, "isDeletableConfirm");
17
17
  const onDeleteRow = toRef(props, "onDeleteRow");
@@ -24,10 +24,6 @@ export default function DeleteAPI(props, {
24
24
  openConfirm,
25
25
  } = AConfirmAPI();
26
26
 
27
- const idBtnDelete = computed(() => {
28
- return `${ id.value }_delete`;
29
- });
30
-
31
27
  const closeConfirmLocal = () => {
32
28
  closeConfirm();
33
29
  nextTick().then(
@@ -74,7 +70,6 @@ export default function DeleteAPI(props, {
74
70
  };
75
71
 
76
72
  return {
77
- idBtnDelete,
78
73
  onDeleteClick,
79
74
  };
80
75
  }
@@ -0,0 +1,31 @@
1
+ import {
2
+ computed,
3
+ toRef,
4
+ } from "vue";
5
+
6
+ export default function IdsAPI(props) {
7
+ const id = toRef(props, "id");
8
+
9
+ const idBtnDelete = computed(() => {
10
+ return `${ id.value }_delete`;
11
+ });
12
+
13
+ const idBtnEdit = computed(() => {
14
+ return `${ id.value }_edit`;
15
+ });
16
+
17
+ const idBtnCancel = computed(() => {
18
+ return `${ id.value }_cancel`;
19
+ });
20
+
21
+ const idBtnSave = computed(() => {
22
+ return `${ id.value }_save`;
23
+ });
24
+
25
+ return {
26
+ idBtnCancel,
27
+ idBtnDelete,
28
+ idBtnEdit,
29
+ idBtnSave,
30
+ };
31
+ }
@@ -5,7 +5,6 @@ import {
5
5
 
6
6
  import {
7
7
  cloneDeep,
8
- isPlainObject,
9
8
  set,
10
9
  unset,
11
10
  } from "lodash-es";
@@ -51,14 +50,16 @@ export default function EditAPI(props, {
51
50
  unset(errorsLocal.value, columnId);
52
51
  };
53
52
 
54
- const cancelEditRow = () => {
53
+ const cancelEditRow = ({ trigger, id } = {}) => {
55
54
  onCancelEditRow.value({
56
55
  row: row.value,
57
56
  rowIndex: rowIndex.value,
57
+ trigger,
58
+ id,
58
59
  });
59
60
  };
60
61
 
61
- const saveEditRow = async() => {
62
+ const saveEditRow = async({ id } = {}) => {
62
63
  if (isSaving.value) {
63
64
  return;
64
65
  }
@@ -79,7 +80,7 @@ export default function EditAPI(props, {
79
80
  return;
80
81
  }
81
82
 
82
- cancelEditRow();
83
+ cancelEditRow({ trigger: "save", id });
83
84
  } catch (error) {
84
85
  errorsLocal.value = error;
85
86
  } finally {
@@ -4,20 +4,20 @@ import {
4
4
  } from "vue";
5
5
 
6
6
  export default function ClassesAPI(props) {
7
- const classes = toRef(props, "actionsClasses");
7
+ const actionsClasses = toRef(props, "actionsClasses");
8
8
 
9
- const classesLocal = computed(() => {
9
+ const actionsClassesLocal = computed(() => {
10
10
  return {
11
11
  delete: "a_btn a_btn_transparent_danger",
12
12
  edit: "a_btn a_btn_transparent_primary",
13
13
  editCancel: "a_btn a_btn_transparent_primary",
14
14
  editSave: "a_btn a_btn_transparent_primary",
15
15
  addRow: "a_btn a_btn_outline_primary",
16
- ...classes.value,
16
+ ...actionsClasses.value,
17
17
  };
18
18
  });
19
19
 
20
20
  return {
21
- classesLocal,
21
+ actionsClassesLocal,
22
22
  };
23
23
  }
@@ -1,107 +1,119 @@
1
- import {
2
- computed,
3
- ref,
4
- toRef,
5
- } from "vue";
6
-
7
- import {
8
- cloneDeep,
9
- isFunction,
10
- } from "lodash-es";
11
-
12
- export default function EditAPI(props, {
13
- getRowKey = () => {},
14
- }) {
15
- const addRow = toRef(props, "addRow");
16
- const columns = toRef(props, "columns");
17
- const isAddable = toRef(props, "isAddable");
18
- const isEditable = toRef(props, "isEditable");
19
- const prepareEditModel = toRef(props, "prepareEditModel");
20
- const rows = toRef(props, "rows");
21
-
22
- const activeEditRowKey = ref(undefined);
23
- const activeEditModel = ref(undefined);
24
- const isAddRowActive = ref(false);
25
-
26
- const hasActiveEditRow = computed(() => {
27
- return !!activeEditRowKey.value || isAddRowActive.value;
28
- });
29
-
30
- const canAddRow = computed(() => {
31
- if (!isAddable.value) {
32
- return false;
33
- }
34
-
35
- return isFunction(addRow.value);
36
- });
37
-
38
- const hasRequiredEditableColumns = computed(() => {
39
- if (!isEditable.value) {
40
- return false;
41
- }
42
-
43
- return columns.value.some(column => {
44
- return !!column.formElement?.required;
45
- });
46
- });
47
-
48
- const getPreparedEditModel = params => {
49
- if (!isFunction(prepareEditModel.value)) {
50
- return undefined;
51
- }
52
-
53
- const result = prepareEditModel.value(params);
54
-
55
- if (result?.model === undefined) {
56
- return undefined;
57
- }
58
-
59
- return cloneDeep(result.model);
60
- };
61
-
62
- const onAddRow = () => {
63
- if (hasActiveEditRow.value || !canAddRow.value) {
64
- return;
65
- }
66
-
67
- activeEditRowKey.value = undefined;
68
- activeEditModel.value = getPreparedEditModel({
69
- rows: rows.value,
70
- });
71
- isAddRowActive.value = true;
72
- };
73
-
74
- const onCancelEditRow = () => {
75
- activeEditRowKey.value = undefined;
76
- activeEditModel.value = undefined;
77
- isAddRowActive.value = false;
78
- };
79
-
80
- const onEditRow = ({ row, rowIndex }) => {
81
- if (isAddRowActive.value) {
82
- return;
83
- }
84
-
85
- activeEditModel.value = getPreparedEditModel({
86
- row,
87
- rowIndex,
88
- rows: rows.value,
89
- });
90
- activeEditRowKey.value = getRowKey({
91
- row,
92
- rowIndex,
93
- });
94
- };
95
-
96
- return {
97
- activeEditRowKey,
98
- activeEditModel,
99
- canAddRow,
100
- hasActiveEditRow,
101
- hasRequiredEditableColumns,
102
- isAddRowActive,
103
- onAddRow,
104
- onCancelEditRow,
105
- onEditRow,
106
- };
107
- }
1
+ import {
2
+ computed,
3
+ ref,
4
+ toRef,
5
+ } from "vue";
6
+
7
+ import {
8
+ setFocusToElement,
9
+ } from "../../utils/utilsDOM";
10
+ import {
11
+ cloneDeep,
12
+ isFunction,
13
+ } from "lodash-es";
14
+
15
+ export default function EditAPI(props, {
16
+ getRowKey = () => {},
17
+ }) {
18
+ const addRow = toRef(props, "addRow");
19
+ const columns = toRef(props, "columns");
20
+ const isAddable = toRef(props, "isAddable");
21
+ const isEditable = toRef(props, "isEditable");
22
+ const prepareEditModel = toRef(props, "prepareEditModel");
23
+ const rows = toRef(props, "rows");
24
+
25
+ const activeEditRowKey = ref(undefined);
26
+ const activeEditModel = ref(undefined);
27
+ const isAddRowActive = ref(false);
28
+
29
+ const hasActiveEditRow = computed(() => {
30
+ return !!activeEditRowKey.value || isAddRowActive.value;
31
+ });
32
+
33
+ const canAddRow = computed(() => {
34
+ if (!isAddable.value) {
35
+ return false;
36
+ }
37
+
38
+ return isFunction(addRow.value);
39
+ });
40
+
41
+ const hasRequiredEditableColumns = computed(() => {
42
+ if (!isEditable.value) {
43
+ return false;
44
+ }
45
+
46
+ return columns.value.some(column => {
47
+ return !!column.formElement?.required;
48
+ });
49
+ });
50
+
51
+ const getPreparedEditModel = params => {
52
+ if (!isFunction(prepareEditModel.value)) {
53
+ return undefined;
54
+ }
55
+
56
+ const result = prepareEditModel.value(params);
57
+
58
+ if (result?.model === undefined) {
59
+ return undefined;
60
+ }
61
+
62
+ return cloneDeep(result.model);
63
+ };
64
+
65
+ const onAddRow = () => {
66
+ if (hasActiveEditRow.value || !canAddRow.value) {
67
+ return;
68
+ }
69
+
70
+ activeEditRowKey.value = undefined;
71
+ activeEditModel.value = getPreparedEditModel({
72
+ rows: rows.value,
73
+ });
74
+ isAddRowActive.value = true;
75
+ };
76
+
77
+ const onCancelEditRow = ({ trigger, id } = {}) => {
78
+ activeEditRowKey.value = undefined;
79
+ activeEditModel.value = undefined;
80
+ isAddRowActive.value = false;
81
+ if (trigger === "cancel") {
82
+ setTimeout(() => {
83
+ setFocusToElement({ selector: `#${ id }_edit` });
84
+ });
85
+ } else if (trigger === "save") {
86
+ setTimeout(() => {
87
+ setFocusToElement({ selector: `#${ id }` });
88
+ });
89
+ }
90
+ };
91
+
92
+ const onEditRow = ({ row, rowIndex }) => {
93
+ if (isAddRowActive.value) {
94
+ return;
95
+ }
96
+
97
+ activeEditModel.value = getPreparedEditModel({
98
+ row,
99
+ rowIndex,
100
+ rows: rows.value,
101
+ });
102
+ activeEditRowKey.value = getRowKey({
103
+ row,
104
+ rowIndex,
105
+ });
106
+ };
107
+
108
+ return {
109
+ activeEditRowKey,
110
+ activeEditModel,
111
+ canAddRow,
112
+ hasActiveEditRow,
113
+ hasRequiredEditableColumns,
114
+ isAddRowActive,
115
+ onAddRow,
116
+ onCancelEditRow,
117
+ onEditRow,
118
+ };
119
+ }
@@ -242,6 +242,10 @@ export default {
242
242
  required: false,
243
243
  default: () => AInputCurrencyPluginOptions.propsDefault.modelUndefined,
244
244
  },
245
+ skipRequiredModelInit: {
246
+ type: Boolean,
247
+ required: false,
248
+ },
245
249
  modelValue: {
246
250
  type: [String, Number],
247
251
  required: false,
@@ -30,6 +30,7 @@ export default function InputEventsAPI(props, {
30
30
  const modelValue = toRef(props, "modelValue");
31
31
  const readonly = toRef(props, "readonly");
32
32
  const required = toRef(props, "required");
33
+ const skipRequiredModelInit = toRef(props, "skipRequiredModelInit");
33
34
  const decimalPartLength = toRef(props, "decimalPartLength");
34
35
  const thousandDivider = toRef(props, "thousandDivider");
35
36
  const validationOnChange = toRef(props, "validationOnChange");
@@ -121,7 +122,7 @@ export default function InputEventsAPI(props, {
121
122
  };
122
123
 
123
124
  const handleInput = ($event, { value: _value, updateOutside = false, triggerDetails = "keydown" } = {}) => {
124
- if (!required.value && isNil(_value) && !$event?.target?.value) {
125
+ if ((!required.value || skipRequiredModelInit.value) && isNil(_value) && !$event?.target?.value) {
125
126
  setValueLocal({ value: _value, updateOutside, triggerDetails });
126
127
 
127
128
  return;
@@ -726,7 +727,7 @@ export default function InputEventsAPI(props, {
726
727
  valueToSet = `${ setMinusSymbol }${ intPart }${ decimalDivider.value }${ floatPart }${ zerosToAdd }`;
727
728
  }
728
729
  } else {
729
- valueToSet = required.value ?
730
+ valueToSet = required.value && !skipRequiredModelInit.value ?
730
731
  [
731
732
  "0",
732
733
  decimalDivider.value,
@@ -734,7 +735,7 @@ export default function InputEventsAPI(props, {
734
735
  ].join("") :
735
736
  modelUndefinedLocal.value;
736
737
  }
737
- const shouldInitModel = required.value && !hasModel;
738
+ const shouldInitModel = required.value && !skipRequiredModelInit.value && !hasModel;
738
739
  handleInput(null, { value: valueToSet, updateOutside: !shouldInitModel, triggerDetails: "init" });
739
740
  });
740
741
  };
@@ -17,6 +17,7 @@ export default function ModelAPI(props, {
17
17
  const modelValue = toRef(props, "modelValue");
18
18
  const modelType = toRef(props, "modelType");
19
19
  const modelUndefined = toRef(props, "modelUndefined");
20
+ const skipRequiredModelInit = toRef(props, "skipRequiredModelInit");
20
21
  const decimalDivider = toRef(props, "decimalDivider");
21
22
  const disabled = toRef(props, "disabled");
22
23
  const decimalPartLength = toRef(props, "decimalPartLength");
@@ -36,7 +37,7 @@ export default function ModelAPI(props, {
36
37
  });
37
38
 
38
39
  const modelUndefinedLocal = computed(() => {
39
- if (!required.value) {
40
+ if (!required.value || skipRequiredModelInit.value) {
40
41
  return modelUndefined.value;
41
42
  }
42
43
  if (!decimalPartLength.value) {
@@ -53,7 +54,7 @@ export default function ModelAPI(props, {
53
54
  const setCurrentValue = ({ value, updateOutside = false, trigger, triggerDetails } = {}) => {
54
55
  displayValue.value = isNil(value) ? "" : value;
55
56
  let newVal;
56
- if (!required.value && isNil(value)) {
57
+ if ((!required.value || skipRequiredModelInit.value) && isNil(value)) {
57
58
  newVal = modelUndefinedLocal.value;
58
59
  } else {
59
60
  newVal = modelType.value === "number" ?