@autoafleveren/ui 1.6.3 → 1.7.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/dist/types/components/AppDrawer/AppDrawer.vue.d.ts +2 -0
- package/dist/types/composables/useDrawer/index.d.ts +1 -0
- package/dist/ui.cjs +34 -34
- package/dist/ui.js +4179 -4171
- package/package.json +1 -1
- package/src/modules/components/AppContextMenu/AppContextMenu.vue +0 -5
- package/src/modules/components/AppDrawer/AppDrawer.vue +23 -15
- package/src/modules/composables/useActionBar/index.ts +5 -0
- package/src/modules/composables/useDrawer/index.ts +18 -2
- package/src/modules/composables/useFocusTrap/index.d.ts +2 -0
- package/src/modules/composables/useFocusTrap/index.ts +1 -1
package/package.json
CHANGED
|
@@ -84,10 +84,6 @@
|
|
|
84
84
|
openIndex.value = index;
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
function focus(event: MouseEvent): void {
|
|
88
|
-
(event.target as HTMLDivElement | undefined)?.focus();
|
|
89
|
-
}
|
|
90
|
-
|
|
91
87
|
defineExpose({ isOpen, open, close, submit });
|
|
92
88
|
onClickOutside(contextMenuElement, close);
|
|
93
89
|
onEscape(close);
|
|
@@ -139,7 +135,6 @@
|
|
|
139
135
|
@confirm="deactivate"
|
|
140
136
|
@confirmed="activate"
|
|
141
137
|
@close="close"
|
|
142
|
-
@mouseenter="focus"
|
|
143
138
|
@open="() => onItemOpen(index)"
|
|
144
139
|
>
|
|
145
140
|
<span class="text-base">{{ action.name }}</span>
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
|
|
2
|
+
/* eslint-disable vue/no-unused-properties */
|
|
3
|
+
import { ref, provide, computed } from 'vue';
|
|
3
4
|
import { Dialog, DialogPanel, TransitionChild, TransitionRoot } from '@headlessui/vue';
|
|
4
5
|
import { FontAwesomeIcon, byPrefixAndName } from '~icons';
|
|
5
6
|
|
|
6
7
|
import type { DrawerProps } from './index.d';
|
|
7
8
|
|
|
8
|
-
withDefaults(defineProps<Omit<DrawerProps, 'router' | 'unique' | 'onOpen' | 'onClose' | 'plugins' | 'forceCreate'>>(), {
|
|
9
|
+
const props = withDefaults(defineProps<Omit<DrawerProps, 'router' | 'unique' | 'onOpen' | 'onClose' | 'plugins' | 'forceCreate'>>(), {
|
|
9
10
|
withBackdrop: true,
|
|
10
11
|
withFooter: true,
|
|
11
12
|
preventBackdropClose: false,
|
|
@@ -21,6 +22,13 @@
|
|
|
21
22
|
}>();
|
|
22
23
|
|
|
23
24
|
const isOpen = ref(false);
|
|
25
|
+
const localOptions = ref<Partial<DrawerProps>>({});
|
|
26
|
+
|
|
27
|
+
const mergedProps = computed(() => ({ ...props, ...localOptions.value }));
|
|
28
|
+
|
|
29
|
+
function setOptions(options: DrawerProps): void {
|
|
30
|
+
localOptions.value = { ...localOptions.value, ...options };
|
|
31
|
+
}
|
|
24
32
|
|
|
25
33
|
async function open(): Promise<void> {
|
|
26
34
|
isOpen.value = true;
|
|
@@ -35,7 +43,7 @@
|
|
|
35
43
|
emit('close', { animation: async () => new Promise(resolve => setTimeout(resolve, 350)) });
|
|
36
44
|
}
|
|
37
45
|
|
|
38
|
-
defineExpose({ isOpen, open, close });
|
|
46
|
+
defineExpose({ isOpen, open, close, setOptions });
|
|
39
47
|
|
|
40
48
|
provide('isDrawer', true);
|
|
41
49
|
</script>
|
|
@@ -49,10 +57,10 @@
|
|
|
49
57
|
:static="true"
|
|
50
58
|
class="relative z-10 group/drawer is-drawer"
|
|
51
59
|
data-test-drawer-dialog
|
|
52
|
-
@close="() => (preventBackdropClose || !withBackdrop) ? undefined : close()"
|
|
60
|
+
@close="() => (mergedProps.preventBackdropClose || !mergedProps.withBackdrop) ? undefined : close()"
|
|
53
61
|
>
|
|
54
62
|
<TransitionChild
|
|
55
|
-
v-if="withBackdrop"
|
|
63
|
+
v-if="mergedProps.withBackdrop"
|
|
56
64
|
as="template"
|
|
57
65
|
enter="ease-in-out duration-300"
|
|
58
66
|
enter-from="opacity-0"
|
|
@@ -68,11 +76,11 @@
|
|
|
68
76
|
</TransitionChild>
|
|
69
77
|
|
|
70
78
|
<div
|
|
71
|
-
:class="{ 'pointer-events-none': !withBackdrop }"
|
|
79
|
+
:class="{ 'pointer-events-none': !mergedProps.withBackdrop }"
|
|
72
80
|
class="fixed inset-0 overflow-hidden"
|
|
73
81
|
>
|
|
74
82
|
<div
|
|
75
|
-
:class="{ 'pointer-events-none': !withBackdrop }"
|
|
83
|
+
:class="{ 'pointer-events-none': !mergedProps.withBackdrop }"
|
|
76
84
|
class="absolute inset-0 overflow-hidden"
|
|
77
85
|
>
|
|
78
86
|
<div class="pointer-events-none fixed inset-y-0 right-0 flex max-w-full pl-10">
|
|
@@ -86,7 +94,7 @@
|
|
|
86
94
|
leave-to="translate-x-full"
|
|
87
95
|
>
|
|
88
96
|
<DialogPanel
|
|
89
|
-
:class="panelClasses"
|
|
97
|
+
:class="mergedProps.panelClasses"
|
|
90
98
|
class="@container pointer-events-auto relative w-screen max-w-xl 2xl:max-w-4xl"
|
|
91
99
|
>
|
|
92
100
|
<TransitionChild
|
|
@@ -110,7 +118,7 @@
|
|
|
110
118
|
<span class="sr-only">Close panel</span>
|
|
111
119
|
|
|
112
120
|
<FontAwesomeIcon
|
|
113
|
-
:icon="closeIcon ?? byPrefixAndName.far?.['chevron-right']"
|
|
121
|
+
:icon="mergedProps.closeIcon ?? byPrefixAndName.far?.['chevron-right']"
|
|
114
122
|
class="size-6"
|
|
115
123
|
aria-hidden="true"
|
|
116
124
|
/>
|
|
@@ -119,22 +127,22 @@
|
|
|
119
127
|
</TransitionChild>
|
|
120
128
|
|
|
121
129
|
<div
|
|
122
|
-
:class="modalClasses"
|
|
130
|
+
:class="mergedProps.modalClasses"
|
|
123
131
|
class="flex h-full flex-col overflow-y-scroll rounded-l-[40px] bg-white pt-8 mb-8 shadow-[-6px_0px_6px_#20202010]"
|
|
124
132
|
>
|
|
125
133
|
<div
|
|
126
|
-
:class="`relative mt-6 flex-1 px-2 sm:px-6 ${contentClasses}`"
|
|
134
|
+
:class="`relative mt-6 flex-1 px-2 sm:px-6 ${mergedProps.contentClasses}`"
|
|
127
135
|
data-test-modal-content
|
|
128
136
|
>
|
|
129
137
|
<slot>
|
|
130
|
-
<template v-if="typeof content === 'string'">
|
|
131
|
-
{{ content }}
|
|
138
|
+
<template v-if="typeof mergedProps.content === 'string'">
|
|
139
|
+
{{ mergedProps.content }}
|
|
132
140
|
</template>
|
|
133
141
|
|
|
134
142
|
<Component
|
|
135
|
-
:is="content"
|
|
143
|
+
:is="mergedProps.content"
|
|
136
144
|
v-else
|
|
137
|
-
v-bind="properties"
|
|
145
|
+
v-bind="mergedProps.properties"
|
|
138
146
|
/>
|
|
139
147
|
</slot>
|
|
140
148
|
</div>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { shallowRef } from 'vue';
|
|
2
|
+
import { useContextMenu } from '~composables';
|
|
2
3
|
|
|
3
4
|
import type { Action } from '~components/AppActionBar/index.d';
|
|
4
5
|
import type { OnResetSelection } from './index.d';
|
|
@@ -13,6 +14,8 @@ const state = {
|
|
|
13
14
|
};
|
|
14
15
|
|
|
15
16
|
export function useActionBar<T = number>() {
|
|
17
|
+
const contextMenu = useContextMenu();
|
|
18
|
+
|
|
16
19
|
function setSelection(selection: T[]): void {
|
|
17
20
|
// @ts-expect-error type mismatch, but we want to allow any type of selection
|
|
18
21
|
state.selection.value = selection;
|
|
@@ -25,6 +28,8 @@ export function useActionBar<T = number>() {
|
|
|
25
28
|
}
|
|
26
29
|
|
|
27
30
|
function setActions(actions: Action[]): void {
|
|
31
|
+
contextMenu.setActions(undefined);
|
|
32
|
+
|
|
28
33
|
state.actions.value = actions;
|
|
29
34
|
|
|
30
35
|
open();
|
|
@@ -9,7 +9,7 @@ const state = {
|
|
|
9
9
|
instances: ref<ModalInstance[]>([]),
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
function closeDrawer(modalInstance: Omit<ModalInstance, 'withRouter'>): void {
|
|
12
|
+
function closeDrawer(modalInstance: Omit<ModalInstance, 'withRouter' | 'unique'>): void {
|
|
13
13
|
modalInstance?.instance?.unmount();
|
|
14
14
|
modalInstance?.element?.remove();
|
|
15
15
|
|
|
@@ -60,6 +60,7 @@ export function useDrawer(component?: MaybeRef<Component | string>, options?: Dr
|
|
|
60
60
|
|
|
61
61
|
if (openOptions.forceCreate !== true && instancesWithRouter.length > 0 && openOptions.router) {
|
|
62
62
|
instancesWithRouter[instancesWithRouter.length - 1]?.instance?.config?.globalProperties?.$router?.push?.(openOptions.router);
|
|
63
|
+
instancesWithRouter[instancesWithRouter.length - 1]?.ref?.setOptions(openOptions);
|
|
63
64
|
|
|
64
65
|
return;
|
|
65
66
|
}
|
|
@@ -90,7 +91,7 @@ export function useDrawer(component?: MaybeRef<Component | string>, options?: Dr
|
|
|
90
91
|
if (!hasReadyListener) {
|
|
91
92
|
mountDrawer(modalInstance, modalRootElement, !!openOptions.router);
|
|
92
93
|
|
|
93
|
-
if (openOptions.router) {
|
|
94
|
+
if (openOptions.router && !openOptions.unique) {
|
|
94
95
|
modalInstance?.config?.globalProperties?.$router?.push?.(openOptions.router);
|
|
95
96
|
}
|
|
96
97
|
|
|
@@ -130,10 +131,25 @@ export function useDrawer(component?: MaybeRef<Component | string>, options?: Dr
|
|
|
130
131
|
return Promise.resolve();
|
|
131
132
|
}
|
|
132
133
|
|
|
134
|
+
async function closeAll(): Promise<void> {
|
|
135
|
+
state.instances.value.forEach(stateInstance => {
|
|
136
|
+
stateInstance.ref.close();
|
|
137
|
+
|
|
138
|
+
setTimeout(() => {
|
|
139
|
+
if (instance.value) {
|
|
140
|
+
closeDrawer(stateInstance);
|
|
141
|
+
}
|
|
142
|
+
}, 300);
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
return Promise.resolve();
|
|
146
|
+
}
|
|
147
|
+
|
|
133
148
|
return {
|
|
134
149
|
...state,
|
|
135
150
|
instance,
|
|
136
151
|
open,
|
|
137
152
|
close,
|
|
153
|
+
closeAll,
|
|
138
154
|
};
|
|
139
155
|
}
|
|
@@ -8,7 +8,7 @@ import type { Options } from './index.d';
|
|
|
8
8
|
|
|
9
9
|
export function useFocusTrap(
|
|
10
10
|
target: MaybeRefOrGetter<Arrayable<MaybeRefOrGetter<string> | MaybeComputedElementRef>>,
|
|
11
|
-
options: Options = { allowOutsideClick: true, preventScroll: false },
|
|
11
|
+
options: Options = { allowOutsideClick: true, preventScroll: false, clickOutsideDeactivates: true, returnFocusOnDeactivate: true },
|
|
12
12
|
) {
|
|
13
13
|
const isActive = ref<boolean>(false);
|
|
14
14
|
const { activate: activateTrap, deactivate: deactivateTrap } = useFocusTrapVueUse(target, options);
|