@autoafleveren/ui 1.4.13 → 1.4.14

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": "@autoafleveren/ui",
3
- "version": "1.4.13",
3
+ "version": "1.4.14",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist/*",
@@ -19,6 +19,7 @@
19
19
  },
20
20
  );
21
21
  const selected = ref([1]);
22
+ const openIndex = ref<number | null>(null);
22
23
 
23
24
  const selectionTextWithValue = computed((): string => {
24
25
  return selectionText.value.replace(':selection', String(selection.value.length));
@@ -38,11 +39,17 @@
38
39
  }
39
40
 
40
41
  function closeActionBar(): void {
42
+ openIndex.value = null;
43
+
41
44
  resetSelection();
42
45
 
43
46
  close();
44
47
  }
45
48
 
49
+ function onOpen(index: number): void {
50
+ openIndex.value = index;
51
+ }
52
+
46
53
  onKeyStroke(['Escape'], (event: Event) => {
47
54
  event.preventDefault();
48
55
 
@@ -81,6 +88,8 @@
81
88
  v-for="(action, index) in actions"
82
89
  :key="`action-item-${index}`"
83
90
  :action="action"
91
+ :is-open="openIndex === index"
92
+ @open="() => onOpen(index)"
84
93
  @close="closeActionBar"
85
94
  />
86
95
  </div>
@@ -1,5 +1,5 @@
1
1
  <script lang="ts" setup>
2
- import { computed, nextTick, onMounted, ref, toValue, useTemplateRef } from 'vue';
2
+ import { computed, nextTick, onMounted, ref, toValue, useTemplateRef, watch } from 'vue';
3
3
  import { WarningIcon } from '~icons';
4
4
  import { AppLoader } from '~components';
5
5
  import { useActionBar, useContextMenu, useFocusTrap } from '~composables';
@@ -19,6 +19,7 @@
19
19
  (event: 'close'): void;
20
20
  (event: 'confirm'): void;
21
21
  (event: 'confirmed'): void;
22
+ (event: 'open'): void;
22
23
  }>();
23
24
 
24
25
  const actionBar = useActionBar();
@@ -55,6 +56,12 @@
55
56
  return props.action.hidden;
56
57
  });
57
58
 
59
+ watch(() => props.isOpen, (value: boolean) => {
60
+ if (!value) {
61
+ subMenuClose();
62
+ }
63
+ });
64
+
58
65
  onMounted(() => {
59
66
  if (props.confirmed) {
60
67
  confirm.value = true;
@@ -78,6 +85,8 @@
78
85
  }
79
86
  }
80
87
 
88
+ emit('open');
89
+
81
90
  return;
82
91
  }
83
92
 
@@ -110,7 +119,6 @@
110
119
 
111
120
  emit('close');
112
121
  }
113
-
114
122
  onEscape(close);
115
123
  onBack(subMenuClose);
116
124
  </script>
@@ -143,6 +151,7 @@
143
151
  :is="action.suffixIcon"
144
152
  v-if="action.suffixIcon && context"
145
153
  class="size-5 ml-auto"
154
+ @close="subMenuClose"
146
155
  />
147
156
  </div>
148
157
 
@@ -7,7 +7,7 @@
7
7
  import type { ActionItemProps } from '../index.d';
8
8
 
9
9
  const props = withDefaults(
10
- defineProps<Omit<ActionItemProps, 'context' | 'confirmed'> & { submitButtonText?: string; cancelButtonText?: string }>(),
10
+ defineProps<Omit<ActionItemProps, 'context' | 'confirmed' | 'isOpen'> & { submitButtonText?: string; cancelButtonText?: string }>(),
11
11
  {
12
12
  submitButtonText: 'Opslaan',
13
13
  cancelButtonText: 'Annuleren',
@@ -28,4 +28,5 @@ export interface ActionItemProps {
28
28
  confirmed?: boolean;
29
29
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
30
30
  item?: any;
31
+ isOpen?: boolean;
31
32
  }
@@ -18,6 +18,7 @@
18
18
 
19
19
  const isOpen = ref(true);
20
20
  const isLoading = ref(false);
21
+ const openIndex = ref<number | null>(null);
21
22
  const actionbar = useActionBar();
22
23
  const contextMenu = useContextMenu();
23
24
  const contextMenuElement = ref<HTMLDivElement>();
@@ -62,6 +63,10 @@
62
63
  }, 300);
63
64
  }
64
65
 
66
+ function onItemOpen(index: number): void {
67
+ openIndex.value = index;
68
+ }
69
+
65
70
  defineExpose({ isOpen, open, close, submit });
66
71
  onClickOutside(contextMenuElement, close);
67
72
  onEscape(close);
@@ -94,6 +99,7 @@
94
99
  :key="`action-item-${index}`"
95
100
  :action="action"
96
101
  :context="true"
102
+ :is-open="openIndex === index"
97
103
  :item="item"
98
104
  :confirmed="confirmed && confirmed === action.key"
99
105
  :tabindex="`100${index}`"
@@ -102,6 +108,7 @@
102
108
  @confirmed="activate"
103
109
  @close="close"
104
110
  @mouseover="($event) => ($event.target as HTMLDivElement | undefined)?.focus()"
111
+ @open="() => onItemOpen(index)"
105
112
  >
106
113
  <span class="text-base">{{ action.name }}</span>
107
114
  </AppActionBarItem>