aloha-vue 2.1.13 → 2.3.0

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.1.13",
3
+ "version": "2.3.0",
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",
@@ -76,6 +76,7 @@
76
76
  "babel-plugin-module-resolver": "5.0.2",
77
77
  "eslint": "^9.19.0",
78
78
  "eslint-plugin-import": "^2.31.0",
79
+ "eslint-plugin-import-group": "^1.0.1",
79
80
  "eslint-plugin-jest": "28.11.0",
80
81
  "eslint-plugin-vue": "^9.32.0",
81
82
  "eslint-plugin-vue-pug": "^0.6.2",
@@ -6,6 +6,7 @@ import AButton from "../AButton/AButton";
6
6
  import AIcon from "../AIcon/AIcon";
7
7
  import ATranslation from "../ATranslation/ATranslation";
8
8
 
9
+ import AttributesAPI from "./compositionAPI/AttributesAPI";
9
10
  import ClassAPI from "./compositionAPI/ClassAPI";
10
11
  import CloseAPI from "./compositionAPI/CloseAPI";
11
12
  import IconAPI from "./compositionAPI/IconAPI";
@@ -31,6 +32,11 @@ export default {
31
32
  type: Boolean,
32
33
  required: false,
33
34
  },
35
+ ariaAtomic: {
36
+ type: Boolean,
37
+ required: false,
38
+ default: true,
39
+ },
34
40
  btnCloseAttributes: {
35
41
  type: Object,
36
42
  required: false,
@@ -71,6 +77,11 @@ export default {
71
77
  required: false,
72
78
  default: () => alertPluginOptions.value.propsDefault.removeAlertOnClose,
73
79
  },
80
+ role: {
81
+ type: String,
82
+ required: false,
83
+ default: "alert",
84
+ },
74
85
  safeHtml: {
75
86
  type: String,
76
87
  required: false,
@@ -118,6 +129,11 @@ export default {
118
129
  iconLocal,
119
130
  } = IconAPI(props);
120
131
 
132
+ const {
133
+ ariaAtomicLocal,
134
+ roleLocal,
135
+ } = AttributesAPI(props);
136
+
121
137
  expose({
122
138
  close,
123
139
  isHidden,
@@ -125,9 +141,11 @@ export default {
125
141
 
126
142
  return {
127
143
  alertClassLocal,
144
+ ariaAtomicLocal,
128
145
  close,
129
146
  iconLocal,
130
147
  isHidden,
148
+ roleLocal,
131
149
  };
132
150
  },
133
151
  render() {
@@ -143,8 +161,8 @@ export default {
143
161
  ],
144
162
  }, [
145
163
  h("div", {
146
- role: "alert",
147
- ariaAtomic: true,
164
+ role: this.roleLocal,
165
+ ariaAtomic: this.ariaAtomicLocal,
148
166
  }, [
149
167
  this.isVisible && h("div", {
150
168
  class: [this.alertClass, this.alertClassLocal],
@@ -0,0 +1,30 @@
1
+ import {
2
+ computed,
3
+ toRef,
4
+ } from "vue";
5
+
6
+ export default function AttributesAPI(props) {
7
+ const ariaAtomic = toRef(props, "ariaAtomic");
8
+ const role = toRef(props, "role");
9
+
10
+ const ariaAtomicLocal = computed(() => {
11
+ if (ariaAtomic.value) {
12
+ return true;
13
+ }
14
+
15
+ return undefined;
16
+ });
17
+
18
+ const roleLocal = computed(() => {
19
+ if (role.value) {
20
+ return role.value;
21
+ }
22
+
23
+ return undefined;
24
+ });
25
+
26
+ return {
27
+ ariaAtomicLocal,
28
+ roleLocal,
29
+ };
30
+ }
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  h,
3
3
  onBeforeUnmount,
4
- Teleport,
4
+ Teleport, toRef,
5
5
  withDirectives,
6
6
  } from "vue";
7
7
 
@@ -12,6 +12,7 @@ import AIcon from "../AIcon/AIcon";
12
12
  import AOnHooks from "../directives/AOnHooks";
13
13
 
14
14
  import ActionsAPI from "./compositionAPI/ActionsAPI";
15
+ import APopupAPI from "../compositionAPI/APopupAPI";
15
16
  import AttributesAPI from "./compositionAPI/AttributesAPI";
16
17
  import ClassAPI from "./compositionAPI/ClassAPI";
17
18
  import EventsAPI from "./compositionAPI/EventsAPI";
@@ -291,6 +292,13 @@ export default {
291
292
  "close",
292
293
  ],
293
294
  setup(props, context) {
295
+ const id = toRef(props, "id");
296
+
297
+ const {
298
+ closePopup,
299
+ openPopup,
300
+ } = APopupAPI();
301
+
294
302
  const {
295
303
  dropdownButtonRef,
296
304
  dropdownRef,
@@ -324,9 +332,11 @@ export default {
324
332
  triggerOpen,
325
333
  wasOpened,
326
334
  } = ToggleAPI(props, context, {
335
+ closePopup,
336
+ destroyPopover,
327
337
  dropdownButtonRef,
328
338
  dropdownRef,
329
- destroyPopover,
339
+ openPopup,
330
340
  setFocusToFirstElement,
331
341
  startPopper,
332
342
  });
@@ -376,6 +386,9 @@ export default {
376
386
  destroyEventCloseClick();
377
387
  destroyEventPressArrows();
378
388
  destroyPopover();
389
+ closePopup({
390
+ id: id.value,
391
+ });
379
392
  });
380
393
 
381
394
  return {
@@ -15,15 +15,18 @@ import {
15
15
  } from "lodash-es";
16
16
 
17
17
  export default function ToggleAPI(props, { emit }, {
18
+ closePopup = () => {},
18
19
  dropdownButtonRef = ref(undefined),
19
20
  dropdownRef = ref(undefined),
20
21
  destroyPopover = () => {},
22
+ openPopup = () => {},
21
23
  setFocusToFirstElement = () => {},
22
24
  startPopper = () => {},
23
25
  }) {
24
26
  const disabled = toRef(props, "disabled");
25
27
  const dropdownRenderDefault = toRef(props, "dropdownRenderDefault");
26
28
  const elementsForArrows = toRef(props, "elementsForArrows");
29
+ const id = toRef(props, "id");
27
30
  const isCloseByClickInside = toRef(props, "isCloseByClickInside");
28
31
  const isCloseByClickOutside = toRef(props, "isCloseByClickOutside");
29
32
  const isListWidthSameWithButton = toRef(props, "isListWidthSameWithButton");
@@ -183,6 +186,9 @@ export default function ToggleAPI(props, { emit }, {
183
186
  });
184
187
  }
185
188
  openDropdownGlobal();
189
+ openPopup({
190
+ id: id.value,
191
+ });
186
192
  emit("open");
187
193
  });
188
194
  };
@@ -227,6 +233,9 @@ export default function ToggleAPI(props, { emit }, {
227
233
  setFocusToButton();
228
234
  }
229
235
  triggerOpen.value = undefined;
236
+ closePopup({
237
+ id: id.value,
238
+ });
230
239
  emit("close");
231
240
  }
232
241
 
@@ -1,21 +1,27 @@
1
- import {
2
- toRef,
3
- } from "vue";
4
-
5
- export default function EscapeAPI(props) {
6
- const close = toRef(props, "close");
7
- const useEscape = toRef(props, "useEscape");
8
-
9
- const pressEscape = $event => {
10
- if (!useEscape.value) {
11
- return;
12
- }
13
- close.value();
14
- $event.preventDefault();
15
- $event.stopPropagation();
16
- };
17
-
18
- return {
19
- pressEscape,
20
- };
21
- }
1
+ import {
2
+ toRef,
3
+ } from "vue";
4
+
5
+ import APopupAPI from "../../compositionAPI/APopupAPI";
6
+
7
+ export default function EscapeAPI(props) {
8
+ const close = toRef(props, "close");
9
+ const useEscape = toRef(props, "useEscape");
10
+
11
+ const {
12
+ isOnePopupOpen,
13
+ } = APopupAPI();
14
+
15
+ const pressEscape = $event => {
16
+ if (!useEscape.value || isOnePopupOpen.value) {
17
+ return;
18
+ }
19
+ close.value();
20
+ $event.preventDefault();
21
+ $event.stopPropagation();
22
+ };
23
+
24
+ return {
25
+ pressEscape,
26
+ };
27
+ }
@@ -402,7 +402,11 @@ export function callHttpRequestAndCheckSavedApi({
402
402
  if (error?.code === "ERR_CANCELED") { // workaround. we'll remake this in v2.0.0
403
403
  return reject(error);
404
404
  }
405
- if (ignoreErrorHandler || checkErrorStatus({ error: error.response, showError, client: API, reject, resolve })) {
405
+ if (isFunction(ignoreErrorHandler)) {
406
+ if (ignoreErrorHandler({ error: error.response, showError, client: API })) {
407
+ return reject(error.response);
408
+ }
409
+ } else if (ignoreErrorHandler || checkErrorStatus({ error: error.response, showError, client: API, reject, resolve })) {
406
410
  return reject(error.response);
407
411
  }
408
412
  },
@@ -4,12 +4,14 @@ import {
4
4
  } from "vue";
5
5
 
6
6
  import {
7
+ forEach,
8
+ isEmpty,
7
9
  isUndefined,
8
10
  } from "lodash-es";
9
11
 
10
12
  const popupOpenIds = ref({});
11
13
 
12
- export default function APopupAPI({ id, idRef }) {
14
+ export default function APopupAPI({ id, idRef } = {}) {
13
15
  const isPopupOpen = computed(() => {
14
16
  if (idRef) {
15
17
  return isCurrentPopupOpen({ id: idRef.value });
@@ -17,9 +19,25 @@ export default function APopupAPI({ id, idRef }) {
17
19
  return isCurrentPopupOpen({ id });
18
20
  });
19
21
 
22
+ const isOnePopupOpen = computed(() => {
23
+ let isOneOpen = false;
24
+ if (isEmpty(popupOpenIds.value)) {
25
+ return isOneOpen;
26
+ }
27
+ forEach(popupOpenIds.value, _isOpen => {
28
+ if (_isOpen) {
29
+ isOneOpen = true;
30
+ return false;
31
+ }
32
+ });
33
+
34
+ return isOneOpen;
35
+ });
36
+
20
37
  return {
21
38
  closePopup,
22
39
  isCurrentPopupOpen,
40
+ isOnePopupOpen,
23
41
  isPopupOpen,
24
42
  openPopup,
25
43
  popupOpenIds,
@@ -18,8 +18,11 @@ import ASelectLabelElement from "./ASelectLabelElement";
18
18
  import ASelectValueCloseable from "./ASelectValueCloseable";
19
19
  import ATranslation from "../../ATranslation/ATranslation";
20
20
 
21
+ import APopupAPI from "../../compositionAPI/APopupAPI";
21
22
  import AttributesAPI from "./compositionAPI/AttributesAPI";
23
+ import DisabledAPI from "./compositionAPI/DisabledAPI";
22
24
  import DividerAPI from "./compositionAPI/DividerAPI";
25
+ import ExclusiveOptionsAPI from "./compositionAPI/ExclusiveOptionsAPI";
23
26
  import ModelAPI from "./compositionAPI/ModelAPI";
24
27
  import ModelChangeAPI from "./compositionAPI/ModelChangeAPI";
25
28
  import PopperContainerAPI from "../../ATooltip/compositionAPI/PopperContainerAPI";
@@ -141,6 +144,16 @@ export default {
141
144
  required: false,
142
145
  default: () => [],
143
146
  },
147
+ exclusiveOptionLabel: {
148
+ type: String,
149
+ required: false,
150
+ default: "_A_SELECT_EXCLUSIVE_",
151
+ },
152
+ exclusiveOptionValue: {
153
+ type: [String, Number, Boolean],
154
+ required: false,
155
+ default: "_exclusive_",
156
+ },
144
157
  extra: {
145
158
  type: Object,
146
159
  required: false,
@@ -198,6 +211,18 @@ export default {
198
211
  required: false,
199
212
  default: () => selectPluginOptions.value.propsDefault.isDeselectAll,
200
213
  },
214
+ isExclusiveOptionEnabled: {
215
+ type: Boolean,
216
+ required: false,
217
+ default: false,
218
+ validator: (value, props) => {
219
+ const type = props?.type;
220
+ if (type !== "multiselect") {
221
+ return value === false;
222
+ }
223
+ return true;
224
+ },
225
+ },
201
226
  isHide: {
202
227
  type: Boolean,
203
228
  required: false,
@@ -436,6 +461,11 @@ export default {
436
461
  onFocus,
437
462
  } = UiAPI(props, context);
438
463
 
464
+ const {
465
+ closePopup,
466
+ openPopup,
467
+ } = APopupAPI();
468
+
439
469
  const {
440
470
  dataAll,
441
471
  dataFromServer,
@@ -476,6 +506,18 @@ export default {
476
506
  dataLocal,
477
507
  });
478
508
 
509
+ const {
510
+ disabledAttribut,
511
+ disabledLocal,
512
+ disabledLocalAttribut,
513
+ isExclusiveOptionSelected,
514
+ } = DisabledAPI(props);
515
+
516
+ const {
517
+ exclusiveOption,
518
+ exclusiveDataKeyByKeyIdLocal,
519
+ } = ExclusiveOptionsAPI(props);
520
+
479
521
  const {
480
522
  isModelLengthLimitExceeded,
481
523
  isModelValue,
@@ -512,6 +554,7 @@ export default {
512
554
  });
513
555
 
514
556
  const {
557
+ hasNotElementsExclusiveWithSearch,
515
558
  hasNotElementsExtraWithSearch,
516
559
  hasNotElementsWithSearch,
517
560
  idForButtonSearchOutside,
@@ -521,6 +564,7 @@ export default {
521
564
  onSearchOutside,
522
565
  searching,
523
566
  searchingElements,
567
+ searchingElementsExclusive,
524
568
  searchingElementsExtra,
525
569
  searchingGroups,
526
570
  searchingGroupsWithSearchInGroup,
@@ -531,6 +575,7 @@ export default {
531
575
  } = UiSearchAPI(props, context, {
532
576
  data: dataSort,
533
577
  dataExtra: dataExtraLocal,
578
+ exclusiveOption,
534
579
  groupsForLever,
535
580
  hasKeyGroup,
536
581
  htmlIdLocal,
@@ -546,8 +591,12 @@ export default {
546
591
  menuParentRef,
547
592
  menuRef,
548
593
  togglePopover,
549
- } = ToggleAPI(props, context);
550
-
594
+ } = ToggleAPI(props, context, {
595
+ closePopup,
596
+ htmlIdLocal,
597
+ openPopup,
598
+ });
599
+
551
600
  const {
552
601
  deleteExceededItems,
553
602
  onChangeModelValue,
@@ -559,6 +608,7 @@ export default {
559
608
  changeModel,
560
609
  dataAll,
561
610
  dataKeyByKeyIdLocal,
611
+ disabledLocal,
562
612
  isMultiselect,
563
613
  togglePopover,
564
614
  });
@@ -600,6 +650,9 @@ export default {
600
650
 
601
651
  onBeforeUnmount(() => {
602
652
  destroyEventBusClickLabel();
653
+ closePopup({
654
+ id: htmlIdLocal.value,
655
+ });
603
656
  });
604
657
 
605
658
  return {
@@ -616,11 +669,17 @@ export default {
616
669
  dataLocal,
617
670
  dataSort,
618
671
  deleteExceededItems,
672
+ disabledAttribut,
673
+ disabledLocal,
674
+ disabledLocalAttribut,
619
675
  errorsId,
676
+ exclusiveDataKeyByKeyIdLocal,
677
+ exclusiveOption,
620
678
  groupsForLever,
621
679
  handleKeydown,
622
680
  hasDataExtra,
623
681
  hasKeyGroup,
682
+ hasNotElementsExclusiveWithSearch,
624
683
  hasNotElementsExtraWithSearch,
625
684
  hasNotElementsWithSearch,
626
685
  hasSelectedTitle,
@@ -630,6 +689,7 @@ export default {
630
689
  idForList,
631
690
  isDividerSelectDeselectVisible,
632
691
  isErrors,
692
+ isExclusiveOptionSelected,
633
693
  isModelLengthLimitExceeded,
634
694
  isModelValue,
635
695
  isMultiselect,
@@ -655,6 +715,7 @@ export default {
655
715
  popperContainerIdSelector,
656
716
  searching,
657
717
  searchingElements,
718
+ searchingElementsExclusive,
658
719
  searchingElementsExtra,
659
720
  searchingGroups,
660
721
  searchingGroupsWithSearchInGroup,
@@ -720,7 +781,7 @@ export default {
720
781
  "aria-haspopup": "listbox",
721
782
  ariaExpanded: this.isOpen,
722
783
  ariaRequired: this.required,
723
- ariaDisabled: this.disabled,
784
+ ariaDisabled: this.disabledLocal,
724
785
  ariaInvalid: this.isErrors,
725
786
  "aria-describedby": this.ariaDescribedbyLocal,
726
787
  title: this.hasSelectedTitle ? this.selectedTitle : undefined, // TODO: title
@@ -744,7 +805,7 @@ export default {
744
805
  return h(ASelectValueCloseable, {
745
806
  key: index,
746
807
  alwaysTranslate: this.alwaysTranslate,
747
- data: this.dataKeyByKeyIdLocal[item] || {},
808
+ data: this.dataKeyByKeyIdLocal[item] || this.exclusiveDataKeyByKeyIdLocal[item] || {},
748
809
  slotName: this.slotName,
749
810
  disabled: this.disabled,
750
811
  onChangeModelValue: this.onChangeModelValue,
@@ -754,7 +815,7 @@ export default {
754
815
  key: this.countMultiselect,
755
816
  alwaysTranslate: this.alwaysTranslate,
756
817
  data: this.limitExceededModelData,
757
- disabled: this.disabled,
818
+ disabled: this.disabledLocal,
758
819
  hideDeleteButton: !this.exceededItemsDeletable,
759
820
  onChangeModelValue: this.deleteExceededItems,
760
821
  }),
@@ -837,7 +898,7 @@ export default {
837
898
  h(AButton, {
838
899
  alwaysTranslate: this.alwaysTranslate,
839
900
  ariaDisabled: this.loadingSearchApi,
840
- disabled: this.disabled,
901
+ disabled: this.disabledLocal,
841
902
  class: "a_btn a_btn_primary a_select__element_clickable",
842
903
  type: "submit",
843
904
  iconLeft: Search,
@@ -866,7 +927,13 @@ export default {
866
927
  class: "a_select_menu__child",
867
928
  }, [
868
929
  (this.isMultiselect && this.isSelectAll) && h("div", {
869
- class: "a_select__menu__link a_select__menu__link_selected a_select__element_clickable",
930
+ class: [
931
+ "a_select__menu__link a_select__menu__link_selected a_select__element_clickable",
932
+ {
933
+ a_select__menu__link_disabled: this.disabledLocal,
934
+ },
935
+ ],
936
+ disabled: this.disabledLocalAttribut,
870
937
  role: "option",
871
938
  tabindex: "-1",
872
939
  onClick: this.onSelectAll,
@@ -882,7 +949,13 @@ export default {
882
949
  h("span", null, this.textSelectAll),
883
950
  ]),
884
951
  (this.isMultiselect && this.isDeselectAll) && h("div", {
885
- class: "a_select__menu__link a_select__menu__link_selected a_select__element_clickable",
952
+ class: [
953
+ "a_select__menu__link a_select__menu__link_selected a_select__element_clickable",
954
+ {
955
+ a_select__menu__link_disabled: this.disabled,
956
+ },
957
+ ],
958
+ disabled: this.disabledAttribut,
886
959
  role: "option",
887
960
  tabindex: "-1",
888
961
  onClick: this.onDeselectAll,
@@ -904,6 +977,23 @@ export default {
904
977
  (this.loadingLocal || this.loadingSearchApi) ?
905
978
  h(ACloak) :
906
979
  "",
980
+ (this.isMultiselect && this.isExclusiveOptionEnabled) && h("div", {}, [
981
+ h(ASelectElement, {
982
+ key: this.exclusiveOptionValue,
983
+ id: this.htmlIdLocal,
984
+ alwaysTranslate: true,
985
+ dataItem: this.exclusiveOption,
986
+ disabled: false,
987
+ searching: this.searching,
988
+ itemIndex: 0,
989
+ modelSearch: this.modelSearchLowerCase,
990
+ modelValue: this.modelValue,
991
+ searchingElements: this.searchingElementsExclusive,
992
+ searchingGroups: this.searchingGroups,
993
+ type: this.type,
994
+ onChangeModelValue: this.onChangeModelValue,
995
+ }, this.$slots),
996
+ ]),
907
997
  this.hasDataExtra && h("div", {}, [
908
998
  ...this.dataExtraLocal.map((item, itemIndex) => {
909
999
  return h(ASelectElement, {
@@ -911,10 +1001,10 @@ export default {
911
1001
  id: this.htmlIdLocal,
912
1002
  alwaysTranslate: this.alwaysTranslate,
913
1003
  dataItem: item,
914
- disabled: this.disabled,
1004
+ disabled: this.disabledLocal,
915
1005
  searching: this.searching,
916
1006
  searchingElements: this.searchingElementsExtra,
917
- itemIndex,
1007
+ itemIndex: this.isExclusiveOptionEnabled ? itemIndex + 1 : itemIndex,
918
1008
  keyDisabled: this.keyDisabled,
919
1009
  modelSearch: this.modelSearchLowerCase,
920
1010
  modelValue: this.modelValue,
@@ -923,7 +1013,7 @@ export default {
923
1013
  onChangeModelValue: this.onChangeModelValue,
924
1014
  }, this.$slots);
925
1015
  }),
926
- !this.hasNotElementsExtraWithSearch && h("div", {
1016
+ !this.hasNotElementsExtraWithSearch && !this.hasNotElementsExclusiveWithSearch && h("div", {
927
1017
  class: "a_select__divider",
928
1018
  ariaHidden: true,
929
1019
  }),
@@ -934,7 +1024,7 @@ export default {
934
1024
  id: `${ this.htmlIdLocal }_lev_0`,
935
1025
  alwaysTranslate: this.alwaysTranslate,
936
1026
  dataGrouped: this.dataGrouped,
937
- disabled: this.disabled,
1027
+ disabled: this.disabledLocal,
938
1028
  groupsForLever: this.groupsForLever,
939
1029
  isErrors: this.isErrors,
940
1030
  keyDisabled: this.keyDisabled,
@@ -958,7 +1048,7 @@ export default {
958
1048
  id: this.htmlIdLocal,
959
1049
  alwaysTranslate: this.alwaysTranslate,
960
1050
  dataItem: item,
961
- disabled: this.disabled,
1051
+ disabled: this.disabledLocal,
962
1052
  searching: this.searching,
963
1053
  searchingElements: this.searchingElements,
964
1054
  itemIndex,
@@ -0,0 +1,38 @@
1
+ import {
2
+ computed,
3
+ toRef,
4
+ } from "vue";
5
+
6
+ export default function DisabledAPI(props) {
7
+ const disabled = toRef(props, "disabled");
8
+ const exclusiveOptionValue = toRef(props, "exclusiveOptionValue");
9
+ const isExclusiveOptionEnabled = toRef(props, "isExclusiveOptionEnabled");
10
+ const modelValue = toRef(props, "modelValue");
11
+
12
+ const isExclusiveOptionSelected = computed(() => {
13
+ if (isExclusiveOptionEnabled.value) {
14
+ return modelValue.value && modelValue.value.indexOf(exclusiveOptionValue.value) !== -1;
15
+ }
16
+
17
+ return false;
18
+ });
19
+
20
+ const disabledLocal = computed(() => {
21
+ return isExclusiveOptionSelected.value || disabled.value;
22
+ });
23
+
24
+ const disabledLocalAttribut = computed(() => {
25
+ return disabledLocal.value || undefined;
26
+ });
27
+
28
+ const disabledAttribut = computed(() => {
29
+ return disabled.value || undefined;
30
+ });
31
+
32
+ return {
33
+ disabledAttribut,
34
+ disabledLocal,
35
+ disabledLocalAttribut,
36
+ isExclusiveOptionSelected,
37
+ };
38
+ }
@@ -0,0 +1,45 @@
1
+ import {
2
+ computed,
3
+ toRef,
4
+ } from "vue";
5
+
6
+ import AKeyId from "../../../const/AKeyId";
7
+ import AKeyLabel from "../../../const/AKeyLabel";
8
+
9
+ import {
10
+ getTranslatedText,
11
+ } from "../../../ATranslation/compositionAPI/UtilsAPI";
12
+
13
+ import {
14
+ keyBy,
15
+ } from "lodash-es";
16
+
17
+ export default function ExclusiveOptionsAPI(props) {
18
+ const exclusiveOptionLabel = toRef(props, "exclusiveOptionLabel");
19
+ const exclusiveOptionValue = toRef(props, "exclusiveOptionValue");
20
+ const extra = toRef(props, "extra");
21
+ const isExclusiveOptionEnabled = toRef(props, "isExclusiveOptionEnabled");
22
+
23
+ const exclusiveOption = computed(() => {
24
+ if (isExclusiveOptionEnabled.value) {
25
+ return {
26
+ [AKeyId]: exclusiveOptionValue.value,
27
+ [AKeyLabel]: getTranslatedText({
28
+ placeholder: exclusiveOptionLabel.value,
29
+ extra: extra.value,
30
+ }),
31
+ };
32
+ }
33
+
34
+ return undefined;
35
+ });
36
+
37
+ const exclusiveDataKeyByKeyIdLocal = computed(() => {
38
+ return keyBy([exclusiveOption.value], AKeyId);
39
+ });
40
+
41
+ return {
42
+ exclusiveOption,
43
+ exclusiveDataKeyByKeyIdLocal,
44
+ };
45
+ }