@varlet/ui 2.5.1 → 2.5.2

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.
@@ -1071,6 +1071,10 @@
1071
1071
  "type": "string",
1072
1072
  "description": "菜单触发方式,可选值为 `click` `hover`, `click` 为点击时触发, `hover` 为悬停时触发 默认值:click"
1073
1073
  },
1074
+ "var-menu/same-width": {
1075
+ "type": "boolean",
1076
+ "description": "是否与触发元素同宽 默认值:false"
1077
+ },
1074
1078
  "var-menu/default-style": {
1075
1079
  "type": "boolean",
1076
1080
  "description": "是否启用默认样式 默认值:true"
@@ -409,6 +409,7 @@
409
409
  "teleport",
410
410
  "disabled",
411
411
  "trigger",
412
+ "same-width",
412
413
  "default-style"
413
414
  ]
414
415
  },
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://raw.githubusercontent.com/JetBrains/web-types/master/schema/web-types.json",
3
3
  "framework": "vue",
4
- "version": "2.5.0",
4
+ "version": "2.5.1",
5
5
  "name": "VARLET",
6
6
  "contributions": {
7
7
  "html": {
@@ -3198,6 +3198,15 @@
3198
3198
  "kind": "expression"
3199
3199
  }
3200
3200
  },
3201
+ {
3202
+ "name": "same-width",
3203
+ "description": "是否与触发元素同宽",
3204
+ "default": "false",
3205
+ "value": {
3206
+ "type": "boolean",
3207
+ "kind": "expression"
3208
+ }
3209
+ },
3201
3210
  {
3202
3211
  "name": "default-style",
3203
3212
  "description": "是否启用默认样式",
package/lib/menu/Menu.js CHANGED
@@ -12,6 +12,8 @@ var _props = require("./props");
12
12
 
13
13
  var _usePopover = require("./usePopover");
14
14
 
15
+ var _elements = require("../utils/elements");
16
+
15
17
  var {
16
18
  n,
17
19
  classes
@@ -40,7 +42,8 @@ function render(_ctx, _cache) {
40
42
  default: (0, _vue.withCtx)(() => [(0, _vue.withDirectives)((0, _vue.createElementVNode)("div", {
41
43
  ref: "popover",
42
44
  style: (0, _vue.normalizeStyle)({
43
- zIndex: _ctx.zIndex
45
+ zIndex: _ctx.zIndex,
46
+ width: _ctx.sameWidth ? _ctx.toSizeUnit(Math.ceil(_ctx.hostSize.width)) : undefined
44
47
  }),
45
48
  class: (0, _vue.normalizeClass)(_ctx.classes(_ctx.n('menu'), [_ctx.defaultStyle, _ctx.n('--menu-background-color') + " " + _ctx.n('$-elevation--3')])),
46
49
  onClick: _cache[0] || (_cache[0] = (0, _vue.withModifiers)(() => {}, ["stop"])),
@@ -96,6 +99,7 @@ var _default = (0, _vue.defineComponent)({
96
99
  hostSize,
97
100
  show,
98
101
  zIndex,
102
+ toSizeUnit: _elements.toSizeUnit,
99
103
  n,
100
104
  classes,
101
105
  handleHostClick,
package/lib/menu/menu.css CHANGED
@@ -1 +1 @@
1
- :root { --menu-background-color: #fff;}.var-menu-enter-from,.var-menu-leave-to { opacity: 0;}.var-menu-enter-active,.var-menu-leave-active { transition-property: opacity; transition-duration: 0.25s;}.var-menu { display: inline-block;}.var-menu--menu-background-color { background: var(--menu-background-color); transition: opacity 0.25s, background-color 0.25s;}
1
+ :root { --menu-background-color: #fff;}.var-menu-enter-from,.var-menu-leave-to { opacity: 0;}.var-menu-enter-active,.var-menu-leave-active { transition-property: opacity; transition-duration: 0.25s;}.var-menu { display: inline-block;}.var-menu__menu { overflow: auto;}.var-menu--menu-background-color { background: var(--menu-background-color); transition: opacity 0.25s, background-color 0.25s;}
package/lib/menu/props.js CHANGED
@@ -44,6 +44,10 @@ var props = {
44
44
  type: [String, Object],
45
45
  default: 'body'
46
46
  },
47
+ sameWidth: {
48
+ type: Boolean,
49
+ default: false
50
+ },
47
51
  defaultStyle: {
48
52
  type: Boolean,
49
53
  default: true
@@ -29,6 +29,10 @@ function usePopover(options) {
29
29
  var host = (0, _vue.ref)(null);
30
30
  var popover = (0, _vue.ref)(null);
31
31
  var show = (0, _vue.ref)(false);
32
+ var hostSize = (0, _vue.ref)({
33
+ width: 0,
34
+ height: 0
35
+ });
32
36
  var {
33
37
  zIndex
34
38
  } = (0, _zIndex.useZIndex)(() => show.value, 1);
@@ -36,17 +40,13 @@ function usePopover(options) {
36
40
  var clickSelf = false;
37
41
  var enterPopover = false;
38
42
  var enterHost = false;
39
- var hostSize = {
40
- width: 0,
41
- height: 0
42
- };
43
43
 
44
44
  var computeHostSize = () => {
45
45
  var {
46
46
  width,
47
47
  height
48
48
  } = window.getComputedStyle(host.value);
49
- hostSize = {
49
+ hostSize.value = {
50
50
  width: (0, _elements.toPxNum)(width),
51
51
  height: (0, _elements.toPxNum)(height)
52
52
  };
@@ -138,56 +138,56 @@ function usePopover(options) {
138
138
  return {
139
139
  placement: 'bottom',
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-top-start':
145
145
  return {
146
146
  placement: 'bottom-start',
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-top-end':
152
152
  return {
153
153
  placement: 'bottom-end',
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':
159
159
  return {
160
160
  placement: 'top',
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-bottom-start':
166
166
  return {
167
167
  placement: 'top-start',
168
168
  skidding: offset.x,
169
- distance: -offset.y - hostSize.height
169
+ distance: -offset.y - hostSize.value.height
170
170
  };
171
171
 
172
172
  case 'cover-bottom-end':
173
173
  return {
174
174
  placement: 'top-end',
175
175
  skidding: offset.x,
176
- distance: -offset.y - hostSize.height
176
+ distance: -offset.y - hostSize.value.height
177
177
  };
178
178
 
179
179
  case 'cover-left':
180
180
  return {
181
181
  placement: 'right',
182
182
  skidding: offset.y,
183
- distance: offset.x - hostSize.width
183
+ distance: offset.x - hostSize.value.width
184
184
  };
185
185
 
186
186
  case 'cover-right':
187
187
  return {
188
188
  placement: 'left',
189
189
  skidding: offset.y,
190
- distance: -offset.x - hostSize.width
190
+ distance: -offset.x - hostSize.value.width
191
191
  };
192
192
 
193
193
  case 'left':