@autoafleveren/ui 1.4.14 → 1.5.1

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.14",
3
+ "version": "1.5.1",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist/*",
@@ -8,7 +8,7 @@ export const domClassesPerType: Record<Type, string[]> = {
8
8
  };
9
9
 
10
10
  export const domClassesPerMenu: Record<'contextMenu' | 'actionBar', string[]> = {
11
- contextMenu: ['focus:bg-zinc-600', 'px-2', 'py-1'],
11
+ contextMenu: ['hover:bg-zinc-600', 'focus:bg-zinc-600', 'px-2', 'py-1'],
12
12
  actionBar: ['hover:bg-black-100/20'],
13
13
  };
14
14
 
@@ -67,6 +67,10 @@
67
67
  openIndex.value = index;
68
68
  }
69
69
 
70
+ function focus(event: MouseEvent): void {
71
+ (event.target as HTMLDivElement | undefined)?.focus();
72
+ }
73
+
70
74
  defineExpose({ isOpen, open, close, submit });
71
75
  onClickOutside(contextMenuElement, close);
72
76
  onEscape(close);
@@ -107,7 +111,7 @@
107
111
  @confirm="deactivate"
108
112
  @confirmed="activate"
109
113
  @close="close"
110
- @mouseover="($event) => ($event.target as HTMLDivElement | undefined)?.focus()"
114
+ @mouseenter="focus"
111
115
  @open="() => onItemOpen(index)"
112
116
  >
113
117
  <span class="text-base">{{ action.name }}</span>
@@ -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 {
@@ -5,7 +5,7 @@
5
5
 
6
6
  import type { DrawerProps } from './index.d';
7
7
 
8
- withDefaults(defineProps<Omit<DrawerProps, 'router' | 'unique' | 'onOpen' | 'onClose' | 'plugins'>>(), {
8
+ withDefaults(defineProps<Omit<DrawerProps, 'router' | 'unique' | 'onOpen' | 'onClose' | 'plugins' | 'forceCreate'>>(), {
9
9
  withBackdrop: true,
10
10
  withFooter: true,
11
11
  preventBackdropClose: false,
@@ -110,7 +110,7 @@
110
110
  <span class="sr-only">Close panel</span>
111
111
 
112
112
  <FontAwesomeIcon
113
- :icon="byPrefixAndName.far?.['chevron-right']"
113
+ :icon="closeIcon ?? byPrefixAndName.far?.['chevron-right']"
114
114
  class="size-6"
115
115
  aria-hidden="true"
116
116
  />
@@ -1,5 +1,6 @@
1
1
  import type { Component, Plugin } from 'vue';
2
2
  import type { RouteRecordRaw } from 'vue-router';
3
+ import type { FontAwesomeIconProps } from '@fortawesome/vue-fontawesome';
3
4
  import type { AppDrawer } from '~components';
4
5
 
5
6
  export type OnClose = () => unknown;
@@ -18,10 +19,13 @@ export interface DrawerProps {
18
19
  onClose?: OnClose;
19
20
  onOpen?: OnOpen;
20
21
  router?: RouteRecordRaw;
22
+ forceCreate?: boolean;
23
+ closeIcon?: FontAwesomeIconProps['icon'];
21
24
  }
22
25
 
23
26
  export interface ModalInstance {
24
27
  ref: AppDrawer;
25
28
  instance: App;
26
29
  element: HTMLDivElement;
30
+ withRouter: boolean;
27
31
  }
@@ -9,7 +9,7 @@ const state = {
9
9
  instances: ref<ModalInstance[]>([]),
10
10
  };
11
11
 
12
- function closeDrawer(modalInstance: ModalInstance): void {
12
+ function closeDrawer(modalInstance: Omit<ModalInstance, 'withRouter'>): void {
13
13
  modalInstance?.instance?.unmount();
14
14
  modalInstance?.element?.remove();
15
15
 
@@ -23,7 +23,7 @@ function closeDrawer(modalInstance: ModalInstance): void {
23
23
  export function useDrawer(component?: MaybeRef<Component | string>, options?: DrawerProps) {
24
24
  const instance = ref<ModalInstance>();
25
25
 
26
- function mountDrawer(modalInstance: ModalInstance['instance'], modalRootElement: ModalInstance['element']): void {
26
+ function mountDrawer(modalInstance: ModalInstance['instance'], modalRootElement: ModalInstance['element'], withRouter = false): void {
27
27
  const modalRef = modalInstance.mount(modalRootElement) as unknown as typeof AppDrawer;
28
28
 
29
29
  modalRef.open();
@@ -32,6 +32,7 @@ export function useDrawer(component?: MaybeRef<Component | string>, options?: Dr
32
32
  ref: modalRef,
33
33
  instance: modalInstance,
34
34
  element: modalRootElement,
35
+ withRouter,
35
36
  };
36
37
 
37
38
  state.instances.value.push(instance.value);
@@ -55,8 +56,10 @@ export function useDrawer(component?: MaybeRef<Component | string>, options?: Dr
55
56
  let modalRef = null as null | typeof AppDrawer;
56
57
 
57
58
  return new Promise(resolve => {
58
- if (state.instances.value.length > 0 && openOptions.router) {
59
- state.instances.value[state.instances.value.length - 1]?.instance?.config?.globalProperties?.$router?.push?.(openOptions.router);
59
+ const instancesWithRouter = state.instances.value.filter(stateInstance => stateInstance.withRouter);
60
+
61
+ if (openOptions.forceCreate !== true && instancesWithRouter.length > 0 && openOptions.router) {
62
+ instancesWithRouter[instancesWithRouter.length - 1]?.instance?.config?.globalProperties?.$router?.push?.(openOptions.router);
60
63
 
61
64
  return;
62
65
  }
@@ -85,7 +88,7 @@ export function useDrawer(component?: MaybeRef<Component | string>, options?: Dr
85
88
  });
86
89
 
87
90
  if (!hasReadyListener) {
88
- mountDrawer(modalInstance, modalRootElement);
91
+ mountDrawer(modalInstance, modalRootElement, !!openOptions.router);
89
92
 
90
93
  if (openOptions.router) {
91
94
  modalInstance?.config?.globalProperties?.$router?.push?.(openOptions.router);
@@ -95,7 +98,7 @@ export function useDrawer(component?: MaybeRef<Component | string>, options?: Dr
95
98
  }
96
99
 
97
100
  hasReadyListener?.isReady()?.then?.(() => {
98
- mountDrawer(modalInstance, modalRootElement);
101
+ mountDrawer(modalInstance, modalRootElement, !!openOptions.router);
99
102
 
100
103
  if (openOptions.router) {
101
104
  modalInstance?.config?.globalProperties?.$router?.push?.(openOptions.router);