@varlet/ui 2.5.1 → 2.5.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/es/menu/Menu.js CHANGED
@@ -2,6 +2,7 @@ import { createNamespace } from '../utils/components';
2
2
  import { defineComponent } from 'vue';
3
3
  import { props } from './props';
4
4
  import { usePopover } from './usePopover';
5
+ import { toSizeUnit } from '../utils/elements';
5
6
  var {
6
7
  n,
7
8
  classes
@@ -30,7 +31,8 @@ export function render(_ctx, _cache) {
30
31
  default: _withCtx(() => [_withDirectives(_createElementVNode("div", {
31
32
  ref: "popover",
32
33
  style: _normalizeStyle({
33
- zIndex: _ctx.zIndex
34
+ zIndex: _ctx.zIndex,
35
+ width: _ctx.sameWidth ? _ctx.toSizeUnit(Math.ceil(_ctx.hostSize.width)) : undefined
34
36
  }),
35
37
  class: _normalizeClass(_ctx.classes(_ctx.n('menu'), [_ctx.defaultStyle, _ctx.n('--menu-background-color') + " " + _ctx.n('$-elevation--3')])),
36
38
  onClick: _cache[0] || (_cache[0] = _withModifiers(() => {}, ["stop"])),
@@ -85,6 +87,7 @@ export default defineComponent({
85
87
  hostSize,
86
88
  show,
87
89
  zIndex,
90
+ toSizeUnit,
88
91
  n,
89
92
  classes,
90
93
  handleHostClick,
package/es/menu/props.js CHANGED
@@ -39,6 +39,10 @@ export var props = {
39
39
  type: [String, Object],
40
40
  default: 'body'
41
41
  },
42
+ sameWidth: {
43
+ type: Boolean,
44
+ default: false
45
+ },
42
46
  defaultStyle: {
43
47
  type: Boolean,
44
48
  default: true
@@ -15,6 +15,10 @@ export function usePopover(options) {
15
15
  var host = ref(null);
16
16
  var popover = ref(null);
17
17
  var show = ref(false);
18
+ var hostSize = ref({
19
+ width: 0,
20
+ height: 0
21
+ });
18
22
  var {
19
23
  zIndex
20
24
  } = useZIndex(() => show.value, 1);
@@ -22,17 +26,13 @@ export function usePopover(options) {
22
26
  var clickSelf = false;
23
27
  var enterPopover = false;
24
28
  var enterHost = false;
25
- var hostSize = {
26
- width: 0,
27
- height: 0
28
- };
29
29
 
30
30
  var computeHostSize = () => {
31
31
  var {
32
32
  width,
33
33
  height
34
34
  } = window.getComputedStyle(host.value);
35
- hostSize = {
35
+ hostSize.value = {
36
36
  width: toPxNum(width),
37
37
  height: toPxNum(height)
38
38
  };
@@ -124,56 +124,56 @@ export function usePopover(options) {
124
124
  return {
125
125
  placement: 'bottom',
126
126
  skidding: offset.x,
127
- distance: offset.y - hostSize.height
127
+ distance: offset.y - hostSize.value.height
128
128
  };
129
129
 
130
130
  case 'cover-top-start':
131
131
  return {
132
132
  placement: 'bottom-start',
133
133
  skidding: offset.x,
134
- distance: offset.y - hostSize.height
134
+ distance: offset.y - hostSize.value.height
135
135
  };
136
136
 
137
137
  case 'cover-top-end':
138
138
  return {
139
139
  placement: 'bottom-end',
140
140
  skidding: offset.x,
141
- distance: offset.y - hostSize.height
141
+ distance: offset.y - hostSize.value.height
142
142
  };
143
143
 
144
144
  case 'cover-bottom':
145
145
  return {
146
146
  placement: 'top',
147
147
  skidding: offset.x,
148
- distance: -offset.y - hostSize.height
148
+ distance: -offset.y - hostSize.value.height
149
149
  };
150
150
 
151
151
  case 'cover-bottom-start':
152
152
  return {
153
153
  placement: 'top-start',
154
154
  skidding: offset.x,
155
- distance: -offset.y - hostSize.height
155
+ distance: -offset.y - hostSize.value.height
156
156
  };
157
157
 
158
158
  case 'cover-bottom-end':
159
159
  return {
160
160
  placement: 'top-end',
161
161
  skidding: offset.x,
162
- distance: -offset.y - hostSize.height
162
+ distance: -offset.y - hostSize.value.height
163
163
  };
164
164
 
165
165
  case 'cover-left':
166
166
  return {
167
167
  placement: 'right',
168
168
  skidding: offset.y,
169
- distance: offset.x - hostSize.width
169
+ distance: offset.x - hostSize.value.width
170
170
  };
171
171
 
172
172
  case 'cover-right':
173
173
  return {
174
174
  placement: 'left',
175
175
  skidding: offset.y,
176
- distance: -offset.x - hostSize.width
176
+ distance: -offset.x - hostSize.value.width
177
177
  };
178
178
 
179
179
  case 'left':
@@ -72,7 +72,6 @@ export default defineComponent({
72
72
  var {
73
73
  popover,
74
74
  host,
75
- hostSize,
76
75
  show,
77
76
  zIndex,
78
77
  handleHostClick,
@@ -91,7 +90,6 @@ export default defineComponent({
91
90
  return {
92
91
  popover,
93
92
  host,
94
- hostSize,
95
93
  show,
96
94
  zIndex,
97
95
  n,