@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.
package/lib/varlet.cjs.js CHANGED
@@ -3849,24 +3849,23 @@ function __render__$1b(_ctx, _cache) {
3849
3849
  return vue.withDirectives((vue.openBlock(), vue.createElementBlock(
3850
3850
  "button",
3851
3851
  {
3852
- class: vue.normalizeClass(_ctx.classes(_ctx.n(), _ctx.n("$--box"), [_ctx.active === _ctx.index || _ctx.active === _ctx.name, _ctx.n("--active")])),
3852
+ class: vue.normalizeClass(_ctx.classes(_ctx.n(), _ctx.n("$--box"), [_ctx.isActive, _ctx.n("--active")])),
3853
3853
  style: vue.normalizeStyle({
3854
- color: _ctx.computeColorStyle()
3854
+ color: _ctx.isActive ? _ctx.activeColor : _ctx.inactiveColor
3855
3855
  }),
3856
3856
  onClick: _cache[0] || (_cache[0] = (...args) => _ctx.handleClick && _ctx.handleClick(...args))
3857
3857
  },
3858
3858
  [
3859
- _ctx.icon && !_ctx.$slots.icon ? (vue.openBlock(), vue.createBlock(_component_var_icon, {
3860
- key: 0,
3861
- name: _ctx.icon,
3862
- namespace: _ctx.namespace,
3863
- class: vue.normalizeClass(_ctx.n("icon")),
3864
- "var-bottom-navigation-item-cover": ""
3865
- }, null, 8, ["name", "namespace", "class"])) : vue.createCommentVNode("v-if", true),
3866
- vue.renderSlot(_ctx.$slots, "icon", {
3867
- active: _ctx.active === _ctx.index || _ctx.active === _ctx.name
3868
- }),
3869
- _ctx.badge ? (vue.openBlock(), vue.createBlock(_component_var_badge, vue.mergeProps({ key: 1 }, _ctx.badgeProps, {
3859
+ vue.renderSlot(_ctx.$slots, "icon", { active: _ctx.isActive }, () => [
3860
+ _ctx.icon ? (vue.openBlock(), vue.createBlock(_component_var_icon, {
3861
+ key: 0,
3862
+ name: _ctx.icon,
3863
+ namespace: _ctx.namespace,
3864
+ class: vue.normalizeClass(_ctx.n("icon")),
3865
+ "var-bottom-navigation-item-cover": ""
3866
+ }, null, 8, ["name", "namespace", "class"])) : vue.createCommentVNode("v-if", true)
3867
+ ]),
3868
+ _ctx.badge ? (vue.openBlock(), vue.createBlock(_component_var_badge, vue.mergeProps({ key: 0 }, _ctx.badgeProps, {
3870
3869
  class: _ctx.n("badge"),
3871
3870
  "var-bottom-navigation-item-cover": ""
3872
3871
  }), null, 16, ["class"])) : vue.createCommentVNode("v-if", true),
@@ -3876,20 +3875,13 @@ function __render__$1b(_ctx, _cache) {
3876
3875
  class: vue.normalizeClass(_ctx.n("label"))
3877
3876
  },
3878
3877
  [
3879
- !_ctx.$slots.default ? (vue.openBlock(), vue.createElementBlock(
3880
- vue.Fragment,
3881
- { key: 0 },
3882
- [
3883
- vue.createTextVNode(
3884
- vue.toDisplayString(_ctx.label),
3885
- 1
3886
- /* TEXT */
3887
- )
3888
- ],
3889
- 64
3890
- /* STABLE_FRAGMENT */
3891
- )) : vue.createCommentVNode("v-if", true),
3892
- vue.renderSlot(_ctx.$slots, "default")
3878
+ vue.renderSlot(_ctx.$slots, "default", {}, () => [
3879
+ vue.createTextVNode(
3880
+ vue.toDisplayString(_ctx.label),
3881
+ 1
3882
+ /* TEXT */
3883
+ )
3884
+ ])
3893
3885
  ],
3894
3886
  2
3895
3887
  /* CLASS */
@@ -3911,8 +3903,8 @@ const __sfc__$1c = vue.defineComponent({
3911
3903
  props: props$14,
3912
3904
  setup(props2) {
3913
3905
  const name2 = vue.computed(() => props2.name);
3914
- const badge = vue.computed(() => props2.badge);
3915
- const badgeProps = vue.ref({});
3906
+ const isActive = vue.computed(() => [name2.value, index.value].includes(active.value));
3907
+ const badgeProps = vue.computed(() => props2.badge === true ? defaultBadgeProps : props2.badge);
3916
3908
  const { index, bottomNavigation, bindBottomNavigation } = useBottomNavigation();
3917
3909
  const { active, activeColor, inactiveColor } = bottomNavigation;
3918
3910
  const bottomNavigationItemProvider = {
@@ -3920,16 +3912,6 @@ const __sfc__$1c = vue.defineComponent({
3920
3912
  index
3921
3913
  };
3922
3914
  bindBottomNavigation(bottomNavigationItemProvider);
3923
- vue.watch(
3924
- () => badge.value,
3925
- (newValue) => {
3926
- badgeProps.value = newValue === true ? defaultBadgeProps : badge.value;
3927
- },
3928
- { immediate: true }
3929
- );
3930
- function computeColorStyle() {
3931
- return active.value === name2.value || active.value === index.value ? activeColor.value : inactiveColor.value;
3932
- }
3933
3915
  function handleClick() {
3934
3916
  var _a;
3935
3917
  const active2 = (_a = name2.value) != null ? _a : index.value;
@@ -3937,13 +3919,12 @@ const __sfc__$1c = vue.defineComponent({
3937
3919
  call(bottomNavigation.onToggle, active2);
3938
3920
  }
3939
3921
  return {
3940
- index,
3941
- active,
3942
- badge,
3922
+ activeColor,
3923
+ inactiveColor,
3943
3924
  badgeProps,
3925
+ isActive,
3944
3926
  n: n$1b,
3945
3927
  classes: classes$Z,
3946
- computeColorStyle,
3947
3928
  handleClick
3948
3929
  };
3949
3930
  }
@@ -13202,6 +13183,9 @@ function usePopover(options) {
13202
13183
  let enterPopover = false;
13203
13184
  let enterHost = false;
13204
13185
  const computeHostSize = () => {
13186
+ if (!host.value) {
13187
+ return;
13188
+ }
13205
13189
  const { width, height } = getStyle$1(host.value);
13206
13190
  hostSize.value = {
13207
13191
  width: toPxNum(width),
@@ -15799,7 +15783,6 @@ const __sfc__$G = vue.defineComponent({
15799
15783
  inheritAttrs: false,
15800
15784
  props: props$C,
15801
15785
  setup(props2) {
15802
- const ownTop = vue.ref(0);
15803
15786
  const disabled = vue.ref(false);
15804
15787
  const name2 = vue.computed(() => props2.index);
15805
15788
  const anchorEl = vue.ref(null);
@@ -15808,16 +15791,15 @@ const __sfc__$G = vue.defineComponent({
15808
15791
  const indexAnchorProvider = {
15809
15792
  index,
15810
15793
  name: name2,
15811
- ownTop,
15812
- setOwnTop,
15813
- setDisabled
15794
+ setDisabled,
15795
+ getOffsetTop
15814
15796
  };
15815
15797
  bindIndexBar(indexAnchorProvider);
15816
- function setOwnTop() {
15798
+ function getOffsetTop() {
15817
15799
  if (!anchorEl.value) {
15818
- return;
15800
+ return 0;
15819
15801
  }
15820
- ownTop.value = anchorEl.value.$el ? anchorEl.value.$el.offsetTop : anchorEl.value.offsetTop;
15802
+ return anchorEl.value.$el ? anchorEl.value.$el.offsetTop : anchorEl.value.offsetTop;
15821
15803
  }
15822
15804
  function setDisabled(value) {
15823
15805
  disabled.value = value;
@@ -15963,10 +15945,9 @@ const __sfc__$F = vue.defineComponent({
15963
15945
  () => length.value,
15964
15946
  () => __async$6(this, null, function* () {
15965
15947
  yield doubleRaf();
15966
- indexAnchors.forEach(({ name: name2, setOwnTop }) => {
15948
+ indexAnchors.forEach(({ name: name2 }) => {
15967
15949
  if (name2.value)
15968
15950
  anchorNameList.value.push(name2.value);
15969
- setOwnTop();
15970
15951
  });
15971
15952
  })
15972
15953
  );
@@ -16009,9 +15990,9 @@ const __sfc__$F = vue.defineComponent({
16009
15990
  const scrollHeight = scroller === window ? document.body.scrollHeight : scroller.scrollHeight;
16010
15991
  const offsetTop = getOffsetTop();
16011
15992
  indexAnchors.forEach((anchor, index) => {
16012
- const anchorTop = anchor.ownTop.value;
15993
+ const anchorTop = anchor.getOffsetTop();
16013
15994
  const top2 = scrollTop - anchorTop + stickyOffsetTop.value - offsetTop;
16014
- const distance = index === indexAnchors.length - 1 ? scrollHeight : indexAnchors[index + 1].ownTop.value - anchor.ownTop.value;
15995
+ const distance = index === indexAnchors.length - 1 ? scrollHeight : indexAnchors[index + 1].getOffsetTop() - anchor.getOffsetTop();
16015
15996
  anchor.setDisabled(true);
16016
15997
  if (top2 >= 0 && top2 < distance && clickedName.value === "") {
16017
15998
  anchor.setDisabled(false);
@@ -16032,7 +16013,8 @@ const __sfc__$F = vue.defineComponent({
16032
16013
  return;
16033
16014
  }
16034
16015
  const offsetTop = getOffsetTop();
16035
- const top2 = indexAnchor.ownTop.value - stickyOffsetTop.value + offsetTop;
16016
+ const indexAnchorTop = indexAnchor.getOffsetTop();
16017
+ const top2 = indexAnchorTop - stickyOffsetTop.value + offsetTop;
16036
16018
  const left2 = getScrollLeft(scroller);
16037
16019
  clickedName.value = anchorName;
16038
16020
  emitEvent(anchorName, options);
@@ -25165,7 +25147,7 @@ withInstall(stdin_default$1);
25165
25147
  withPropsDefaultsSetter(stdin_default$1, props);
25166
25148
  const _WatermarkComponent = stdin_default$1;
25167
25149
  var stdin_default = stdin_default$1;
25168
- const version = "2.22.0";
25150
+ const version = "2.22.1";
25169
25151
  function install(app) {
25170
25152
  stdin_default$3m.install && app.use(stdin_default$3m);
25171
25153
  stdin_default$3k.install && app.use(stdin_default$3k);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@varlet/ui",
3
- "version": "2.22.0",
3
+ "version": "2.22.1",
4
4
  "description": "A material like components library",
5
5
  "main": "lib/varlet.cjs.js",
6
6
  "module": "es/index.mjs",
@@ -48,9 +48,9 @@
48
48
  "@popperjs/core": "^2.11.6",
49
49
  "dayjs": "^1.10.4",
50
50
  "decimal.js": "^10.2.1",
51
- "@varlet/icons": "2.22.0",
52
- "@varlet/shared": "2.22.0",
53
- "@varlet/use": "2.22.0"
51
+ "@varlet/icons": "2.22.1",
52
+ "@varlet/shared": "2.22.1",
53
+ "@varlet/use": "2.22.1"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@vue/runtime-core": "3.4.3",
@@ -66,9 +66,9 @@
66
66
  "typescript": "^5.1.5",
67
67
  "vue": "3.4.3",
68
68
  "vue-router": "4.2.0",
69
- "@varlet/cli": "2.22.0",
70
- "@varlet/ui": "2.22.0",
71
- "@varlet/touch-emulator": "2.22.0"
69
+ "@varlet/cli": "2.22.1",
70
+ "@varlet/ui": "2.22.1",
71
+ "@varlet/touch-emulator": "2.22.1"
72
72
  },
73
73
  "scripts": {
74
74
  "dev": "varlet-cli dev",
package/types/slider.d.ts CHANGED
@@ -30,7 +30,7 @@ export interface SliderProps extends BasicAttributes {
30
30
  disabled?: boolean
31
31
  readonly?: boolean
32
32
  direction?: SliderDirection
33
- rules?: Array<(value: any) => any>
33
+ rules?: Array<(value: number | Array<number>) => any>
34
34
  onChange?: ListenerProp<(value: number | Array<number>) => void>
35
35
  onStart?: ListenerProp<() => void>
36
36
  onEnd?: ListenerProp<(value: number | Array<number>) => void>