@v1nt1248/3nclient-lib 0.2.3 → 0.2.5

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
@@ -2,7 +2,7 @@
2
2
  "name": "@v1nt1248/3nclient-lib",
3
3
  "license": "AGPL-3.0-or-later",
4
4
  "author": "v1nt1248",
5
- "version": "0.2.3",
5
+ "version": "0.2.5",
6
6
  "description": "Library for 3NWeb clients",
7
7
  "type": "module",
8
8
  "files": [
@@ -1,7 +1,8 @@
1
- import { VNode } from 'vue';
1
+ import type { VNode } from 'vue';
2
2
 
3
3
  export interface Ui3nMenuProps {
4
4
  modelValue?: boolean;
5
+ triggerElement?: HTMLElement;
5
6
  positionStrategy?: 'absolute' | 'fixed';
6
7
  positionAutoupdate?: boolean;
7
8
  offsetX?: number;
@@ -22,6 +22,8 @@
22
22
  const menuContentElement = ref<HTMLDivElement | null>(null);
23
23
  const isShow = ref(false);
24
24
 
25
+ const outerTriggerElement = computed(() => props.triggerElement || null);
26
+
25
27
  const contentBorderRadiusCss = computed(() => {
26
28
  if (typeof props.contentBorderRadius === 'number') {
27
29
  return `${props.contentBorderRadius}px`;
@@ -32,27 +34,23 @@
32
34
  });
33
35
  const zIndexCss = computed(() => props.zIndex);
34
36
 
35
- const { floatingStyles, isPositioned } = useFloating(
36
- menuTriggerElement,
37
- menuContentElement,
38
- {
39
- placement: 'bottom-start',
40
- strategy: props.positionStrategy,
41
- middleware: [
42
- offset({
43
- mainAxis: props.offsetY,
44
- crossAxis: props.offsetX + 2,
45
- }),
46
- flip({
47
- fallbackAxisSideDirection: 'end',
48
- flipAlignment: false,
49
- fallbackPlacements: ['bottom-end'],
50
- }),
51
- shift(),
52
- ],
53
- whileElementsMounted: props.positionAutoupdate || props.positionStrategy === 'fixed' ? autoUpdate : undefined,
54
- },
55
- );
37
+ const { floatingStyles, isPositioned } = useFloating(outerTriggerElement || menuTriggerElement, menuContentElement, {
38
+ placement: 'bottom-start',
39
+ strategy: props.positionStrategy,
40
+ middleware: [
41
+ offset({
42
+ mainAxis: props.offsetY,
43
+ crossAxis: props.offsetX + 2,
44
+ }),
45
+ flip({
46
+ fallbackAxisSideDirection: 'end',
47
+ flipAlignment: false,
48
+ fallbackPlacements: ['bottom-end'],
49
+ }),
50
+ shift(),
51
+ ],
52
+ whileElementsMounted: props.positionAutoupdate || props.positionStrategy === 'fixed' ? autoUpdate : undefined,
53
+ });
56
54
 
57
55
  function toggleMenu() {
58
56
  if (props.disabled) {
@@ -79,12 +77,9 @@
79
77
  }
80
78
  }
81
79
 
82
- watch(
83
- isPositioned,
84
- val => {
85
- val ? emits('opened') : emits('closed');
86
- },
87
- );
80
+ watch(isPositioned, val => {
81
+ val ? emits('opened') : emits('closed');
82
+ });
88
83
 
89
84
  watch(
90
85
  () => props.modelValue,
@@ -92,12 +87,16 @@
92
87
  if (isShow.value !== val) {
93
88
  isShow.value = val;
94
89
  }
95
- }, { immediate: true },
90
+ },
91
+ { immediate: true },
96
92
  );
97
93
  </script>
98
94
 
99
95
  <template>
100
- <div ref="menuElement" :class="$style.ui3nMenu">
96
+ <div
97
+ ref="menuElement"
98
+ :class="$style.ui3nMenu"
99
+ >
101
100
  <div
102
101
  ref="menuTriggerElement"
103
102
  :class="[$style.ui3nMenuTrigger, disabled && $style.ui3nMenuTriggerDisabled]"