@varlet/ui 2.22.0 → 2.22.1

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.
@@ -1,7 +1,7 @@
1
1
  import Ripple from "../ripple/index.mjs";
2
2
  import VarBadge from "../badge/index.mjs";
3
3
  import VarIcon from "../icon/index.mjs";
4
- import { defineComponent, computed, ref, watch } from "vue";
4
+ import { defineComponent, computed } from "vue";
5
5
  import { props } from "./props.mjs";
6
6
  import { useBottomNavigation } from "./provide.mjs";
7
7
  import { createNamespace } from "../utils/components.mjs";
@@ -11,7 +11,7 @@ const defaultBadgeProps = {
11
11
  type: "danger",
12
12
  dot: true
13
13
  };
14
- import { resolveComponent as _resolveComponent, normalizeClass as _normalizeClass, openBlock as _openBlock, createBlock as _createBlock, createCommentVNode as _createCommentVNode, renderSlot as _renderSlot, mergeProps as _mergeProps, toDisplayString as _toDisplayString, createTextVNode as _createTextVNode, Fragment as _Fragment, createElementBlock as _createElementBlock, createElementVNode as _createElementVNode, normalizeStyle as _normalizeStyle, resolveDirective as _resolveDirective, withDirectives as _withDirectives } from "vue";
14
+ import { renderSlot as _renderSlot, resolveComponent as _resolveComponent, normalizeClass as _normalizeClass, openBlock as _openBlock, createBlock as _createBlock, createCommentVNode as _createCommentVNode, mergeProps as _mergeProps, toDisplayString as _toDisplayString, createTextVNode as _createTextVNode, createElementVNode as _createElementVNode, normalizeStyle as _normalizeStyle, resolveDirective as _resolveDirective, createElementBlock as _createElementBlock, withDirectives as _withDirectives } from "vue";
15
15
  function __render__(_ctx, _cache) {
16
16
  const _component_var_icon = _resolveComponent("var-icon");
17
17
  const _component_var_badge = _resolveComponent("var-badge");
@@ -19,24 +19,23 @@ function __render__(_ctx, _cache) {
19
19
  return _withDirectives((_openBlock(), _createElementBlock(
20
20
  "button",
21
21
  {
22
- class: _normalizeClass(_ctx.classes(_ctx.n(), _ctx.n("$--box"), [_ctx.active === _ctx.index || _ctx.active === _ctx.name, _ctx.n("--active")])),
22
+ class: _normalizeClass(_ctx.classes(_ctx.n(), _ctx.n("$--box"), [_ctx.isActive, _ctx.n("--active")])),
23
23
  style: _normalizeStyle({
24
- color: _ctx.computeColorStyle()
24
+ color: _ctx.isActive ? _ctx.activeColor : _ctx.inactiveColor
25
25
  }),
26
26
  onClick: _cache[0] || (_cache[0] = (...args) => _ctx.handleClick && _ctx.handleClick(...args))
27
27
  },
28
28
  [
29
- _ctx.icon && !_ctx.$slots.icon ? (_openBlock(), _createBlock(_component_var_icon, {
30
- key: 0,
31
- name: _ctx.icon,
32
- namespace: _ctx.namespace,
33
- class: _normalizeClass(_ctx.n("icon")),
34
- "var-bottom-navigation-item-cover": ""
35
- }, null, 8, ["name", "namespace", "class"])) : _createCommentVNode("v-if", true),
36
- _renderSlot(_ctx.$slots, "icon", {
37
- active: _ctx.active === _ctx.index || _ctx.active === _ctx.name
38
- }),
39
- _ctx.badge ? (_openBlock(), _createBlock(_component_var_badge, _mergeProps({ key: 1 }, _ctx.badgeProps, {
29
+ _renderSlot(_ctx.$slots, "icon", { active: _ctx.isActive }, () => [
30
+ _ctx.icon ? (_openBlock(), _createBlock(_component_var_icon, {
31
+ key: 0,
32
+ name: _ctx.icon,
33
+ namespace: _ctx.namespace,
34
+ class: _normalizeClass(_ctx.n("icon")),
35
+ "var-bottom-navigation-item-cover": ""
36
+ }, null, 8, ["name", "namespace", "class"])) : _createCommentVNode("v-if", true)
37
+ ]),
38
+ _ctx.badge ? (_openBlock(), _createBlock(_component_var_badge, _mergeProps({ key: 0 }, _ctx.badgeProps, {
40
39
  class: _ctx.n("badge"),
41
40
  "var-bottom-navigation-item-cover": ""
42
41
  }), null, 16, ["class"])) : _createCommentVNode("v-if", true),
@@ -46,20 +45,13 @@ function __render__(_ctx, _cache) {
46
45
  class: _normalizeClass(_ctx.n("label"))
47
46
  },
48
47
  [
49
- !_ctx.$slots.default ? (_openBlock(), _createElementBlock(
50
- _Fragment,
51
- { key: 0 },
52
- [
53
- _createTextVNode(
54
- _toDisplayString(_ctx.label),
55
- 1
56
- /* TEXT */
57
- )
58
- ],
59
- 64
60
- /* STABLE_FRAGMENT */
61
- )) : _createCommentVNode("v-if", true),
62
- _renderSlot(_ctx.$slots, "default")
48
+ _renderSlot(_ctx.$slots, "default", {}, () => [
49
+ _createTextVNode(
50
+ _toDisplayString(_ctx.label),
51
+ 1
52
+ /* TEXT */
53
+ )
54
+ ])
63
55
  ],
64
56
  2
65
57
  /* CLASS */
@@ -81,8 +73,8 @@ const __sfc__ = defineComponent({
81
73
  props,
82
74
  setup(props2) {
83
75
  const name2 = computed(() => props2.name);
84
- const badge = computed(() => props2.badge);
85
- const badgeProps = ref({});
76
+ const isActive = computed(() => [name2.value, index.value].includes(active.value));
77
+ const badgeProps = computed(() => props2.badge === true ? defaultBadgeProps : props2.badge);
86
78
  const { index, bottomNavigation, bindBottomNavigation } = useBottomNavigation();
87
79
  const { active, activeColor, inactiveColor } = bottomNavigation;
88
80
  const bottomNavigationItemProvider = {
@@ -90,16 +82,6 @@ const __sfc__ = defineComponent({
90
82
  index
91
83
  };
92
84
  bindBottomNavigation(bottomNavigationItemProvider);
93
- watch(
94
- () => badge.value,
95
- (newValue) => {
96
- badgeProps.value = newValue === true ? defaultBadgeProps : badge.value;
97
- },
98
- { immediate: true }
99
- );
100
- function computeColorStyle() {
101
- return active.value === name2.value || active.value === index.value ? activeColor.value : inactiveColor.value;
102
- }
103
85
  function handleClick() {
104
86
  var _a;
105
87
  const active2 = (_a = name2.value) != null ? _a : index.value;
@@ -107,13 +89,12 @@ const __sfc__ = defineComponent({
107
89
  call(bottomNavigation.onToggle, active2);
108
90
  }
109
91
  return {
110
- index,
111
- active,
112
- badge,
92
+ activeColor,
93
+ inactiveColor,
113
94
  badgeProps,
95
+ isActive,
114
96
  n,
115
97
  classes,
116
- computeColorStyle,
117
98
  handleClick
118
99
  };
119
100
  }
@@ -42,7 +42,6 @@ const __sfc__ = defineComponent({
42
42
  inheritAttrs: false,
43
43
  props,
44
44
  setup(props2) {
45
- const ownTop = ref(0);
46
45
  const disabled = ref(false);
47
46
  const name2 = computed(() => props2.index);
48
47
  const anchorEl = ref(null);
@@ -51,16 +50,15 @@ const __sfc__ = defineComponent({
51
50
  const indexAnchorProvider = {
52
51
  index,
53
52
  name: name2,
54
- ownTop,
55
- setOwnTop,
56
- setDisabled
53
+ setDisabled,
54
+ getOffsetTop
57
55
  };
58
56
  bindIndexBar(indexAnchorProvider);
59
- function setOwnTop() {
57
+ function getOffsetTop() {
60
58
  if (!anchorEl.value) {
61
- return;
59
+ return 0;
62
60
  }
63
- ownTop.value = anchorEl.value.$el ? anchorEl.value.$el.offsetTop : anchorEl.value.offsetTop;
61
+ return anchorEl.value.$el ? anchorEl.value.$el.offsetTop : anchorEl.value.offsetTop;
64
62
  }
65
63
  function setDisabled(value) {
66
64
  disabled.value = value;
@@ -112,10 +112,9 @@ const __sfc__ = defineComponent({
112
112
  () => length.value,
113
113
  () => __async(this, null, function* () {
114
114
  yield doubleRaf();
115
- indexAnchors.forEach(({ name: name2, setOwnTop }) => {
115
+ indexAnchors.forEach(({ name: name2 }) => {
116
116
  if (name2.value)
117
117
  anchorNameList.value.push(name2.value);
118
- setOwnTop();
119
118
  });
120
119
  })
121
120
  );
@@ -158,9 +157,9 @@ const __sfc__ = defineComponent({
158
157
  const scrollHeight = scroller === window ? document.body.scrollHeight : scroller.scrollHeight;
159
158
  const offsetTop = getOffsetTop();
160
159
  indexAnchors.forEach((anchor, index) => {
161
- const anchorTop = anchor.ownTop.value;
160
+ const anchorTop = anchor.getOffsetTop();
162
161
  const top = scrollTop - anchorTop + stickyOffsetTop.value - offsetTop;
163
- const distance = index === indexAnchors.length - 1 ? scrollHeight : indexAnchors[index + 1].ownTop.value - anchor.ownTop.value;
162
+ const distance = index === indexAnchors.length - 1 ? scrollHeight : indexAnchors[index + 1].getOffsetTop() - anchor.getOffsetTop();
164
163
  anchor.setDisabled(true);
165
164
  if (top >= 0 && top < distance && clickedName.value === "") {
166
165
  anchor.setDisabled(false);
@@ -181,7 +180,8 @@ const __sfc__ = defineComponent({
181
180
  return;
182
181
  }
183
182
  const offsetTop = getOffsetTop();
184
- const top = indexAnchor.ownTop.value - stickyOffsetTop.value + offsetTop;
183
+ const indexAnchorTop = indexAnchor.getOffsetTop();
184
+ const top = indexAnchorTop - stickyOffsetTop.value + offsetTop;
185
185
  const left = getScrollLeft(scroller);
186
186
  clickedName.value = anchorName;
187
187
  emitEvent(anchorName, options);
@@ -262,7 +262,7 @@ import './tooltip/style/index.mjs'
262
262
  import './uploader/style/index.mjs'
263
263
  import './watermark/style/index.mjs'
264
264
 
265
- const version = '2.22.0'
265
+ const version = '2.22.1'
266
266
 
267
267
  function install(app) {
268
268
  ActionSheet.install && app.use(ActionSheet)
package/es/index.mjs CHANGED
@@ -174,7 +174,7 @@ export * from './tooltip/index.mjs'
174
174
  export * from './uploader/index.mjs'
175
175
  export * from './watermark/index.mjs'
176
176
 
177
- const version = '2.22.0'
177
+ const version = '2.22.1'
178
178
 
179
179
  function install(app) {
180
180
  ActionSheet.install && app.use(ActionSheet)
@@ -67,6 +67,9 @@ function usePopover(options) {
67
67
  let enterPopover = false;
68
68
  let enterHost = false;
69
69
  const computeHostSize = () => {
70
+ if (!host.value) {
71
+ return;
72
+ }
70
73
  const { width, height } = getStyle(host.value);
71
74
  hostSize.value = {
72
75
  width: toPxNum(width),