@maas/vue-equipment 0.22.2 → 0.22.3
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/nuxt/module.json +1 -1
- package/dist/plugins/MagicCommand/demo/DefaultView.vue +2 -2
- package/dist/plugins/MagicCommand/src/components/MagicCommandBody.vue +8 -3
- package/dist/plugins/MagicCommand/src/composables/private/useCommandScroll.d.ts +1 -0
- package/dist/plugins/MagicCommand/src/composables/private/useCommandScroll.mjs +9 -0
- package/package.json +1 -1
package/dist/nuxt/module.json
CHANGED
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
:default="true"
|
|
5
5
|
class="bg-neutral-800 border border-solid border-neutral-600 w-[40rem] max-h-[30rem] rounded-xl overflow-hidden flex flex-col"
|
|
6
6
|
>
|
|
7
|
-
<magic-command-head class="
|
|
7
|
+
<magic-command-head class="px-2 pt-2">
|
|
8
8
|
<div class="w-full border border-neutral-600 p-3 border-b-solid">
|
|
9
9
|
<input type="text" placeholder="Search" />
|
|
10
10
|
</div>
|
|
11
11
|
</magic-command-head>
|
|
12
|
-
<magic-command-body class="h-full
|
|
12
|
+
<magic-command-body class="h-full py-2">
|
|
13
13
|
<magic-command-group>
|
|
14
14
|
<h2 class="p-4 text-xs text-neutral-600">Suggestions</h2>
|
|
15
15
|
<magic-command-item
|
|
@@ -19,8 +19,13 @@ const commandId = inject(CommandInstanceId, '')
|
|
|
19
19
|
const options = inject(CommandOptionsKey, {} as CommandOptions)
|
|
20
20
|
|
|
21
21
|
const { activeItem, nextItem, prevItem } = useCommandItem(commandId)
|
|
22
|
-
const {
|
|
23
|
-
|
|
22
|
+
const {
|
|
23
|
+
findElement,
|
|
24
|
+
isElementAbove,
|
|
25
|
+
isElementBelow,
|
|
26
|
+
scrollInFromBottom,
|
|
27
|
+
scrollInFromTop,
|
|
28
|
+
} = useCommandScroll(elRef)
|
|
24
29
|
|
|
25
30
|
const keys = useMagicKeys()
|
|
26
31
|
|
|
@@ -72,7 +77,7 @@ watch(activeItem, async (value) => {
|
|
|
72
77
|
const element = findElement(value)
|
|
73
78
|
if (element) {
|
|
74
79
|
if (isElementAbove(element)) {
|
|
75
|
-
element
|
|
80
|
+
scrollInFromTop(element)
|
|
76
81
|
} else if (isElementBelow(element)) {
|
|
77
82
|
scrollInFromBottom(element)
|
|
78
83
|
}
|
|
@@ -3,5 +3,6 @@ export declare function useCommandScroll(parent: MaybeRef<HTMLElement | undefine
|
|
|
3
3
|
isElementAbove: (element: MaybeRef<HTMLElement>) => boolean;
|
|
4
4
|
isElementBelow: (element: MaybeRef<HTMLElement>) => boolean;
|
|
5
5
|
findElement: (id: string) => HTMLElement | null;
|
|
6
|
+
scrollInFromTop: (element: HTMLElement) => void;
|
|
6
7
|
scrollInFromBottom: (element: HTMLElement) => void;
|
|
7
8
|
};
|
|
@@ -27,6 +27,14 @@ export function useCommandScroll(parent) {
|
|
|
27
27
|
function findElement(id) {
|
|
28
28
|
return mappedParent.value.querySelector(`[data-item-id="${id}"]`);
|
|
29
29
|
}
|
|
30
|
+
function scrollInFromTop(element) {
|
|
31
|
+
const elementRect = element.getBoundingClientRect();
|
|
32
|
+
const parentRect = mappedParent.value.getBoundingClientRect();
|
|
33
|
+
const scrollAmount = elementRect.top - parentRect.top - paddingTop.value;
|
|
34
|
+
mappedParent.value.scrollBy({
|
|
35
|
+
top: scrollAmount
|
|
36
|
+
});
|
|
37
|
+
}
|
|
30
38
|
function scrollInFromBottom(element) {
|
|
31
39
|
const elementRect = element.getBoundingClientRect();
|
|
32
40
|
const parentRect = mappedParent.value.getBoundingClientRect();
|
|
@@ -39,6 +47,7 @@ export function useCommandScroll(parent) {
|
|
|
39
47
|
isElementAbove,
|
|
40
48
|
isElementBelow,
|
|
41
49
|
findElement,
|
|
50
|
+
scrollInFromTop,
|
|
42
51
|
scrollInFromBottom
|
|
43
52
|
};
|
|
44
53
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maas/vue-equipment",
|
|
3
3
|
"description": "A magic collection of Vue composables, plugins, components and directives",
|
|
4
|
-
"version": "0.22.
|
|
4
|
+
"version": "0.22.3",
|
|
5
5
|
"author": "Robin Scholz <https://github.com/robinscholz>, Christoph Jeworutzki <https://github.com/ChristophJeworutzki>",
|
|
6
6
|
"devDependencies": {
|
|
7
7
|
"@antfu/ni": "^0.21.12",
|