@v1nt1248/3nclient-lib 0.2.4 → 0.2.6
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
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { autoUpdate, flip, useFloating, offset, shift } from '@floating-ui/vue';
|
|
4
4
|
import { default as vClickOutside } from '../../directives/ui3n-click-outside';
|
|
5
5
|
import type { Ui3nMenuEmits, Ui3nMenuProps, Ui3nMenuSlots } from './types';
|
|
6
|
+
import { Nullable } from '@/components/types';
|
|
6
7
|
|
|
7
8
|
const props = withDefaults(defineProps<Ui3nMenuProps>(), {
|
|
8
9
|
positionStrategy: 'absolute',
|
|
@@ -22,6 +23,10 @@
|
|
|
22
23
|
const menuContentElement = ref<HTMLDivElement | null>(null);
|
|
23
24
|
const isShow = ref(false);
|
|
24
25
|
|
|
26
|
+
const outerTriggerElement = ref<Nullable<HTMLElement>>(props.triggerElement || null);
|
|
27
|
+
|
|
28
|
+
const usedTriggerElement = computed(() => outerTriggerElement.value || menuTriggerElement.value);
|
|
29
|
+
|
|
25
30
|
const contentBorderRadiusCss = computed(() => {
|
|
26
31
|
if (typeof props.contentBorderRadius === 'number') {
|
|
27
32
|
return `${props.contentBorderRadius}px`;
|
|
@@ -32,27 +37,29 @@
|
|
|
32
37
|
});
|
|
33
38
|
const zIndexCss = computed(() => props.zIndex);
|
|
34
39
|
|
|
35
|
-
const {
|
|
36
|
-
|
|
40
|
+
const {
|
|
41
|
+
floatingStyles,
|
|
42
|
+
isPositioned,
|
|
43
|
+
} = useFloating(
|
|
44
|
+
usedTriggerElement,
|
|
37
45
|
menuContentElement,
|
|
38
46
|
{
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
);
|
|
47
|
+
placement: 'bottom-start',
|
|
48
|
+
strategy: props.positionStrategy,
|
|
49
|
+
middleware: [
|
|
50
|
+
offset({
|
|
51
|
+
mainAxis: props.offsetY,
|
|
52
|
+
crossAxis: props.offsetX + 2,
|
|
53
|
+
}),
|
|
54
|
+
flip({
|
|
55
|
+
fallbackAxisSideDirection: 'end',
|
|
56
|
+
flipAlignment: false,
|
|
57
|
+
fallbackPlacements: ['bottom-end'],
|
|
58
|
+
}),
|
|
59
|
+
shift(),
|
|
60
|
+
],
|
|
61
|
+
whileElementsMounted: props.positionAutoupdate || props.positionStrategy === 'fixed' ? autoUpdate : undefined,
|
|
62
|
+
});
|
|
56
63
|
|
|
57
64
|
function toggleMenu() {
|
|
58
65
|
if (props.disabled) {
|
|
@@ -79,12 +86,9 @@
|
|
|
79
86
|
}
|
|
80
87
|
}
|
|
81
88
|
|
|
82
|
-
watch(
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
val ? emits('opened') : emits('closed');
|
|
86
|
-
},
|
|
87
|
-
);
|
|
89
|
+
watch(isPositioned, val => {
|
|
90
|
+
val ? emits('opened') : emits('closed');
|
|
91
|
+
});
|
|
88
92
|
|
|
89
93
|
watch(
|
|
90
94
|
() => props.modelValue,
|
|
@@ -92,12 +96,25 @@
|
|
|
92
96
|
if (isShow.value !== val) {
|
|
93
97
|
isShow.value = val;
|
|
94
98
|
}
|
|
95
|
-
},
|
|
99
|
+
},
|
|
100
|
+
{ immediate: true },
|
|
96
101
|
);
|
|
102
|
+
|
|
103
|
+
watch(
|
|
104
|
+
() => props.triggerElement,
|
|
105
|
+
val => {
|
|
106
|
+
if (val) {
|
|
107
|
+
outerTriggerElement.value = val;
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
)
|
|
97
111
|
</script>
|
|
98
112
|
|
|
99
113
|
<template>
|
|
100
|
-
<div
|
|
114
|
+
<div
|
|
115
|
+
ref="menuElement"
|
|
116
|
+
:class="$style.ui3nMenu"
|
|
117
|
+
>
|
|
101
118
|
<div
|
|
102
119
|
ref="menuTriggerElement"
|
|
103
120
|
:class="[$style.ui3nMenuTrigger, disabled && $style.ui3nMenuTriggerDisabled]"
|