@autoafleveren/ui 1.4.13 → 1.4.15

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.15",
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>
@@ -7,6 +7,7 @@
7
7
  import AppDataTableFooter from './AppDataTableFooter.vue';
8
8
 
9
9
  import type { ServerOptions, UpdateSortArgument } from 'vue3-easy-data-table';
10
+ import type { Action } from '~components/AppActionBar/index.d';
10
11
  import type { Props, DataTableInstance } from '.';
11
12
 
12
13
  const props = withDefaults(defineProps<Props<Item>>(), {
@@ -130,6 +131,14 @@
130
131
  emit('sortClient', value);
131
132
  }
132
133
 
134
+ function contextMenuOpen(item: unknown, event: PointerEvent | MouseEvent, confirmed?: Action['name']): void {
135
+ const result = props.onContextMenu?.(item, event, confirmed);
136
+
137
+ if (result !== false) {
138
+ contextMenu.open(item, event, confirmed);
139
+ }
140
+ }
141
+
133
142
  defineExpose({ dataTableInstance });
134
143
 
135
144
  defineOptions({ inheritAttrs: false });
@@ -160,7 +169,7 @@
160
169
  body-row-class-name="drop-shadow-xs rounded-xl"
161
170
  @update:items-selected="updateSelection"
162
171
  @click-row="clickRow"
163
- @contextmenu-row="contextMenu.open"
172
+ @contextmenu-row="contextMenuOpen"
164
173
  @update:server-options="onUpdateServerOptions"
165
174
  @update-sort="onUpdateClientSort"
166
175
  >
@@ -1,4 +1,5 @@
1
1
  import type { Header } from 'vue3-easy-data-table';
2
+ import type { Action } from '~components/AppActionBar/index.d';
2
3
 
3
4
  export interface Props<Item> {
4
5
  headers: Header[];
@@ -10,6 +11,7 @@ export interface Props<Item> {
10
11
  actionBarSelection?: boolean;
11
12
  actionBarSelectionKey?: string;
12
13
  hideFooter?: boolean;
14
+ onContextMenu?: (item: unknown, event: PointerEvent | MouseEvent, confirmed?: Action['name']) => void | false;
13
15
  }
14
16
 
15
17
  export interface DataTableInstance {