@v1nt1248/3nclient-lib 0.2.50 → 0.2.51

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.50",
5
+ "version": "0.2.51",
6
6
  "description": "Library for 3NWeb clients",
7
7
  "type": "module",
8
8
  "files": [
@@ -27,3 +27,7 @@ export interface Ui3nMenuSlots {
27
27
  default: () => VNode;
28
28
  menu?: () => VNode;
29
29
  }
30
+
31
+ export interface Ui3nMenuExpose {
32
+ update: () => void;
33
+ }
@@ -2,7 +2,7 @@
2
2
  import { computed, ref, watch } from 'vue';
3
3
  import { autoUpdate, flip, useFloating, offset, shift } from '@floating-ui/vue';
4
4
  import { default as vClickOutside } from '../../directives/ui3n-click-outside';
5
- import type { Ui3nMenuEmits, Ui3nMenuProps, Ui3nMenuSlots } from './types';
5
+ import type { Ui3nMenuEmits, Ui3nMenuProps, Ui3nMenuSlots, Ui3nMenuExpose } from './types';
6
6
  import { Nullable } from '@/types';
7
7
 
8
8
  const props = withDefaults(defineProps<Ui3nMenuProps>(), {
@@ -40,26 +40,27 @@
40
40
  const {
41
41
  floatingStyles,
42
42
  isPositioned,
43
+ update,
43
44
  } = useFloating(
44
45
  usedTriggerElement,
45
46
  menuContentElement,
46
47
  {
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
- });
48
+ placement: 'bottom-start',
49
+ strategy: props.positionStrategy,
50
+ middleware: [
51
+ offset({
52
+ mainAxis: props.offsetY,
53
+ crossAxis: props.offsetX + 2,
54
+ }),
55
+ flip({
56
+ fallbackAxisSideDirection: 'end',
57
+ flipAlignment: false,
58
+ fallbackPlacements: ['bottom-end'],
59
+ }),
60
+ shift(),
61
+ ],
62
+ whileElementsMounted: props.positionAutoupdate || props.positionStrategy === 'fixed' ? autoUpdate : undefined,
63
+ });
63
64
 
64
65
  function toggleMenu() {
65
66
  if (props.disabled) {
@@ -105,9 +106,23 @@
105
106
  val => {
106
107
  if (val) {
107
108
  outerTriggerElement.value = val;
109
+ update();
108
110
  }
109
111
  },
110
- )
112
+ );
113
+
114
+ watch(
115
+ [() => props.offsetX, () => props.offsetY],
116
+ ([offsetX, offsetY], [oldOffsetX, oldOffsetY]) => {
117
+ if (offsetX !== oldOffsetX || offsetY !== oldOffsetY) {
118
+ update();
119
+ }
120
+ },
121
+ );
122
+
123
+ defineExpose<Ui3nMenuExpose>({
124
+ update,
125
+ });
111
126
  </script>
112
127
 
113
128
  <template>