@varlet/ui 2.8.6-alpha.1677756540023 → 2.8.6-alpha.1678026101378

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,6 +1,7 @@
1
- import { defineComponent, ref, onMounted, onUpdated, computed } from 'vue';
1
+ import { defineComponent, ref, onUpdated, computed } from 'vue';
2
2
  import { props } from './props.mjs';
3
3
  import { createNamespace } from '../utils/components.mjs';
4
+ import { useMounted } from '@varlet/use';
4
5
  var {
5
6
  n,
6
7
  classes
@@ -93,7 +94,7 @@ var __sfc__ = defineComponent({
93
94
  color: textColor
94
95
  };
95
96
  });
96
- onMounted(computePadding);
97
+ useMounted(computePadding);
97
98
  onUpdated(computePadding);
98
99
  return {
99
100
  n,
@@ -1,8 +1,9 @@
1
1
  import Lazy from '../lazy/index.mjs';
2
- import { defineComponent, ref, onMounted, onUpdated } from 'vue';
2
+ import { defineComponent, ref, onUpdated } from 'vue';
3
3
  import { props, internalSizeValidator, sizeValidator } from './props.mjs';
4
4
  import { toSizeUnit } from '../utils/elements.mjs';
5
5
  import { createNamespace, call } from '../utils/components.mjs';
6
+ import { useMounted } from '@varlet/use';
6
7
  var {
7
8
  n,
8
9
  classes
@@ -128,7 +129,7 @@ var __sfc__ = defineComponent({
128
129
  call(props.onClick, e);
129
130
  };
130
131
 
131
- onMounted(getScale);
132
+ useMounted(getScale);
132
133
  onUpdated(getScale);
133
134
  return {
134
135
  internalSizeValidator,
@@ -1,6 +1,6 @@
1
- import { defineComponent, ref, onMounted, onBeforeUnmount } from 'vue';
2
1
  import VarButton from '../button/index.mjs';
3
2
  import VarIcon from '../icon/index.mjs';
3
+ import { defineComponent, ref, onBeforeUnmount, onDeactivated, onMounted, onActivated } from 'vue';
4
4
  import { props } from './props.mjs';
5
5
  import { throttle } from '@varlet/shared';
6
6
  import { easeInOutCubic } from '../utils/shared.mjs';
@@ -29,7 +29,7 @@ function __render__(_ctx, _cache) {
29
29
  }
30
30
  }, _ctx.$attrs, {
31
31
  onClick: _cache[0] || (_cache[0] = _withModifiers(function () {
32
- return _ctx.click && _ctx.click(...arguments);
32
+ return _ctx.handleClick && _ctx.handleClick(...arguments);
33
33
  }, ["stop"]))
34
34
  }), [_renderSlot(_ctx.$slots, "default", {}, () => [_createVNode(_component_var_button, {
35
35
  type: "primary",
@@ -62,31 +62,42 @@ var __sfc__ = defineComponent({
62
62
  var show = ref(false);
63
63
  var backTopEl = ref(null);
64
64
  var disabled = ref(true);
65
- var target;
65
+ var scroller;
66
66
 
67
- var click = event => {
67
+ var handleClick = event => {
68
68
  call(props.onClick, event);
69
- var left = getScrollLeft(target);
70
- scrollTo(target, {
69
+ var left = getScrollLeft(scroller);
70
+ scrollTo(scroller, {
71
71
  left,
72
72
  duration: props.duration,
73
73
  animation: easeInOutCubic
74
74
  });
75
75
  };
76
76
 
77
- var scroll = () => {
78
- show.value = getScrollTop(target) >= toPxNum(props.visibilityHeight);
77
+ var handleScroll = throttle(() => {
78
+ show.value = getScrollTop(scroller) >= toPxNum(props.visibilityHeight);
79
+ }, 200);
80
+
81
+ var setScroller = () => {
82
+ scroller = props.target ? getTarget(props.target, 'BackTop') : getParentScroller(backTopEl.value);
83
+ };
84
+
85
+ var addScrollerEventListener = () => {
86
+ scroller.addEventListener('scroll', handleScroll);
87
+ };
88
+
89
+ var removeScrollerEventListener = () => {
90
+ scroller.removeEventListener('scroll', handleScroll);
79
91
  };
80
92
 
81
- var throttleScroll = throttle(scroll, 200);
82
93
  onMounted(() => {
83
- target = props.target ? getTarget(props.target, 'BackTop') : getParentScroller(backTopEl.value);
84
- target.addEventListener('scroll', throttleScroll);
94
+ setScroller();
95
+ addScrollerEventListener();
85
96
  disabled.value = false;
86
97
  });
87
- onBeforeUnmount(() => {
88
- target.removeEventListener('scroll', throttleScroll);
89
- });
98
+ onActivated(addScrollerEventListener);
99
+ onBeforeUnmount(removeScrollerEventListener);
100
+ onDeactivated(removeScrollerEventListener);
90
101
  return {
91
102
  disabled,
92
103
  show,
@@ -94,7 +105,7 @@ var __sfc__ = defineComponent({
94
105
  toSizeUnit,
95
106
  n,
96
107
  classes,
97
- click
108
+ handleClick
98
109
  };
99
110
  }
100
111
 
@@ -1,11 +1,12 @@
1
1
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
2
 
3
3
  import VarButton from '../button/index.mjs';
4
- import { defineComponent, ref, computed, onMounted, onUpdated, watch } from 'vue';
4
+ import { defineComponent, ref, computed, onUpdated, watch } from 'vue';
5
5
  import { props } from './props.mjs';
6
6
  import { useBottomNavigationItems } from './provide.mjs';
7
7
  import { createNamespace, call } from '../utils/components.mjs';
8
8
  import { isNumber, isArray } from '@varlet/shared';
9
+ import { useMounted } from '@varlet/use';
9
10
  var {
10
11
  n,
11
12
  classes
@@ -186,7 +187,7 @@ var __sfc__ = defineComponent({
186
187
  immediate: true,
187
188
  deep: true
188
189
  });
189
- onMounted(() => {
190
+ useMounted(() => {
190
191
  if (!slots.fab) {
191
192
  return;
192
193
  }
@@ -1,4 +1,4 @@
1
- import { defineComponent, ref, watch } from 'vue';
1
+ import { defineComponent, onActivated, onDeactivated, onUnmounted, ref, watch } from 'vue';
2
2
  import { props } from './props.mjs';
3
3
  import { requestAnimationFrame, cancelAnimationFrame } from '../utils/elements.mjs';
4
4
  import { call, createNamespace } from '../utils/components.mjs';
@@ -93,9 +93,17 @@ var __sfc__ = defineComponent({
93
93
  autoStart
94
94
  } = props;
95
95
  var now = performance.now();
96
- if (!endTime.value) endTime.value = now + toNumber(time);
96
+
97
+ if (!endTime.value) {
98
+ endTime.value = now + toNumber(time);
99
+ }
100
+
97
101
  var durationTime = endTime.value - now;
98
- if (durationTime < 0) durationTime = 0;
102
+
103
+ if (durationTime < 0) {
104
+ durationTime = 0;
105
+ }
106
+
99
107
  pauseTime.value = durationTime;
100
108
  formatTime(durationTime);
101
109
 
@@ -104,20 +112,26 @@ var __sfc__ = defineComponent({
104
112
  return;
105
113
  }
106
114
 
107
- if (autoStart || isStart.value) handle.value = requestAnimationFrame(countdown);
115
+ if (autoStart || isStart.value) {
116
+ handle.value = requestAnimationFrame(countdown);
117
+ }
108
118
  }; // expose
109
119
 
110
120
 
111
121
  var start = () => {
112
- if (isStart.value) return;
122
+ if (isStart.value) {
123
+ return;
124
+ }
125
+
113
126
  isStart.value = true;
114
- endTime.value = Date.now() + (pauseTime.value || toNumber(props.time));
127
+ endTime.value = performance.now() + (pauseTime.value || toNumber(props.time));
115
128
  countdown();
116
129
  }; // expose
117
130
 
118
131
 
119
132
  var pause = () => {
120
133
  isStart.value = false;
134
+ cancelAnimationFrame(handle.value);
121
135
  }; // expose
122
136
 
123
137
 
@@ -128,9 +142,12 @@ var __sfc__ = defineComponent({
128
142
  countdown();
129
143
  };
130
144
 
131
- watch(() => props.time, () => reset(), {
145
+ watch(() => props.time, reset, {
132
146
  immediate: true
133
147
  });
148
+ onActivated(start);
149
+ onDeactivated(pause);
150
+ onUnmounted(pause);
134
151
  return {
135
152
  showTime,
136
153
  timeData,
@@ -5,11 +5,12 @@ import isSameOrBefore from 'dayjs/esm/plugin/isSameOrBefore';
5
5
  import isSameOrAfter from 'dayjs/esm/plugin/isSameOrAfter';
6
6
  import PanelHeader from './panel-header.mjs';
7
7
  import VarButton from '../../button/index.mjs';
8
- import { defineComponent, ref, computed, watch, onMounted, reactive } from 'vue';
8
+ import { defineComponent, ref, computed, watch, reactive } from 'vue';
9
9
  import { WEEK_HEADER } from '../props.mjs';
10
10
  import { toNumber } from '@varlet/shared';
11
11
  import { createNamespace } from '../../utils/components.mjs';
12
12
  import { pack } from '../../locale/index.mjs';
13
+ import { useMounted } from '@varlet/use';
13
14
  dayjs.extend(isSameOrBefore);
14
15
  dayjs.extend(isSameOrAfter);
15
16
  var {
@@ -327,7 +328,7 @@ var __sfc__ = defineComponent({
327
328
  headerEl.value.checkDate(checkType);
328
329
  };
329
330
 
330
- onMounted(() => {
331
+ useMounted(() => {
331
332
  initDate();
332
333
  initHeader();
333
334
  });
@@ -1,7 +1,8 @@
1
- import { defineComponent, computed, onMounted } from 'vue';
2
1
  import dayjs from 'dayjs/esm';
2
+ import { defineComponent, computed } from 'vue';
3
3
  import { toNumber } from '@varlet/shared';
4
4
  import { createNamespace } from '../../utils/components.mjs';
5
+ import { useMounted } from '@varlet/use';
5
6
  var {
6
7
  n,
7
8
  classes
@@ -89,7 +90,7 @@ var __sfc__ = defineComponent({
89
90
  emit('choose-year', year);
90
91
  };
91
92
 
92
- onMounted(() => {
93
+ useMounted(() => {
93
94
  var activeEl = document.querySelector("." + n('item--active'));
94
95
  activeEl == null ? void 0 : activeEl.scrollIntoView({
95
96
  block: 'center'
@@ -1,10 +1,11 @@
1
1
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
2
 
3
- import { defineComponent, computed, reactive, onMounted, onUpdated, toRefs } from 'vue';
3
+ import { defineComponent, computed, reactive, onUpdated, toRefs } from 'vue';
4
4
  import { toSizeUnit } from '../utils/elements.mjs';
5
5
  import { isBoolean, toNumber } from '@varlet/shared';
6
6
  import { props } from './props.mjs';
7
7
  import { createNamespace } from '../utils/components.mjs';
8
+ import { useMounted } from '@varlet/use';
8
9
  var {
9
10
  n,
10
11
  classes
@@ -36,7 +37,9 @@ var __sfc__ = defineComponent({
36
37
  var state = reactive({
37
38
  withText: false
38
39
  });
39
- var isInset = computed(() => isBoolean(props.inset) ? props.inset : true);
40
+ var isInset = computed(() => {
41
+ return isBoolean(props.inset) ? props.inset : true;
42
+ });
40
43
  var style = computed(() => {
41
44
  var {
42
45
  inset,
@@ -46,10 +49,12 @@ var __sfc__ = defineComponent({
46
49
  var baseStyle = {
47
50
  margin
48
51
  };
49
- if (isBoolean(inset) || inset === 0) return _extends({}, baseStyle); // -18px -> -18
50
52
 
51
- var _inset = toNumber(inset); // -18px -> 18px
53
+ if (isBoolean(inset) || inset === 0) {
54
+ return _extends({}, baseStyle);
55
+ }
52
56
 
57
+ var _inset = toNumber(inset);
53
58
 
54
59
  var absInsetWithUnit = Math.abs(_inset) + (inset + '').replace(_inset + '', '');
55
60
  return vertical ? _extends({}, baseStyle, {
@@ -64,7 +69,7 @@ var __sfc__ = defineComponent({
64
69
  state.withText = Boolean(slots.default) || Boolean(props.description);
65
70
  };
66
71
 
67
- onMounted(() => {
72
+ useMounted(() => {
68
73
  checkHasText();
69
74
  });
70
75
  onUpdated(() => {
@@ -2,13 +2,14 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
2
2
 
3
3
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
4
4
 
5
- import { computed, defineComponent, ref, watch, onMounted, onBeforeUnmount } from 'vue';
5
+ import { computed, defineComponent, ref, watch, onBeforeUnmount, onDeactivated } from 'vue';
6
6
  import { isPlainObject, toNumber } from '@varlet/shared';
7
7
  import { easeInOutCubic } from '../utils/shared.mjs';
8
8
  import { doubleRaf, getParentScroller, getScrollLeft, getScrollTop, nextTickFrame, requestAnimationFrame, scrollTo as varScrollTo, toPxNum } from '../utils/elements.mjs';
9
9
  import { useIndexAnchors } from './provide.mjs';
10
10
  import { props } from './props.mjs';
11
11
  import { createNamespace, call } from '../utils/components.mjs';
12
+ import { useMounted } from '@varlet/use';
12
13
  var {
13
14
  n,
14
15
  classes
@@ -63,7 +64,6 @@ var __sfc__ = defineComponent({
63
64
  bindIndexAnchors
64
65
  } = useIndexAnchors();
65
66
  var clickedName = ref('');
66
- var scroller = ref(null);
67
67
  var barEl = ref(null);
68
68
  var anchorNameList = ref([]);
69
69
  var active = ref();
@@ -71,6 +71,7 @@ var __sfc__ = defineComponent({
71
71
  var cssMode = computed(() => props.cssMode);
72
72
  var stickyOffsetTop = computed(() => toPxNum(props.stickyOffsetTop));
73
73
  var zIndex = computed(() => props.zIndex);
74
+ var scroller = null;
74
75
  var indexBarProvider = {
75
76
  active,
76
77
  sticky,
@@ -91,13 +92,16 @@ var __sfc__ = defineComponent({
91
92
  };
92
93
 
93
94
  var getOffsetTop = () => {
94
- if (!('getBoundingClientRect' in scroller.value)) return 0;
95
+ if (!('getBoundingClientRect' in scroller)) {
96
+ return 0;
97
+ }
98
+
95
99
  var {
96
100
  top: parentTop
97
- } = scroller.value.getBoundingClientRect();
101
+ } = scroller.getBoundingClientRect();
98
102
  var {
99
103
  scrollTop
100
- } = scroller.value;
104
+ } = scroller;
101
105
  var {
102
106
  top: targetTop
103
107
  } = barEl.value.getBoundingClientRect();
@@ -105,8 +109,8 @@ var __sfc__ = defineComponent({
105
109
  };
106
110
 
107
111
  var handleScroll = () => {
108
- var scrollTop = getScrollTop(scroller.value);
109
- var scrollHeight = scroller.value === window ? document.body.scrollHeight : scroller.value.scrollHeight;
112
+ var scrollTop = getScrollTop(scroller);
113
+ var scrollHeight = scroller === window ? document.body.scrollHeight : scroller.scrollHeight;
110
114
  var offsetTop = getOffsetTop();
111
115
  indexAnchors.forEach((anchor, index) => {
112
116
  var anchorTop = anchor.ownTop.value;
@@ -131,21 +135,32 @@ var __sfc__ = defineComponent({
131
135
  manualCall = false,
132
136
  options
133
137
  } = _ref;
134
- if (manualCall) call(props.onClick, anchorName);
135
- if (anchorName === active.value) return;
138
+
139
+ if (manualCall) {
140
+ call(props.onClick, anchorName);
141
+ }
142
+
143
+ if (anchorName === active.value) {
144
+ return;
145
+ }
146
+
136
147
  var indexAnchor = indexAnchors.find(_ref3 => {
137
148
  var {
138
149
  name
139
150
  } = _ref3;
140
151
  return anchorName === name.value;
141
152
  });
142
- if (!indexAnchor) return;
153
+
154
+ if (!indexAnchor) {
155
+ return;
156
+ }
157
+
143
158
  var offsetTop = getOffsetTop();
144
159
  var top = indexAnchor.ownTop.value - stickyOffsetTop.value + offsetTop;
145
- var left = getScrollLeft(scroller.value);
160
+ var left = getScrollLeft(scroller);
146
161
  clickedName.value = anchorName;
147
162
  emitEvent(anchorName, options);
148
- yield varScrollTo(scroller.value, {
163
+ yield varScrollTo(scroller, {
149
164
  left,
150
165
  top,
151
166
  animation: easeInOutCubic,
@@ -159,7 +174,26 @@ var __sfc__ = defineComponent({
159
174
  return function anchorClick(_x) {
160
175
  return _ref2.apply(this, arguments);
161
176
  };
162
- }(); // expose
177
+ }();
178
+
179
+ var setScroller = /*#__PURE__*/function () {
180
+ var _ref4 = _asyncToGenerator(function* () {
181
+ yield doubleRaf();
182
+ scroller = getParentScroller(barEl.value);
183
+ });
184
+
185
+ return function setScroller() {
186
+ return _ref4.apply(this, arguments);
187
+ };
188
+ }();
189
+
190
+ var addScrollerListener = () => {
191
+ scroller.addEventListener('scroll', handleScroll);
192
+ };
193
+
194
+ var removeScrollerListener = () => {
195
+ scroller.removeEventListener('scroll', handleScroll);
196
+ }; // expose
163
197
 
164
198
 
165
199
  var scrollTo = (index, options) => {
@@ -171,23 +205,21 @@ var __sfc__ = defineComponent({
171
205
 
172
206
  watch(() => length.value, /*#__PURE__*/_asyncToGenerator(function* () {
173
207
  yield doubleRaf();
174
- indexAnchors.forEach(_ref5 => {
208
+ indexAnchors.forEach(_ref6 => {
175
209
  var {
176
210
  name,
177
211
  setOwnTop
178
- } = _ref5;
212
+ } = _ref6;
179
213
  if (name.value) anchorNameList.value.push(name.value);
180
214
  setOwnTop();
181
215
  });
182
216
  }));
183
- onMounted( /*#__PURE__*/_asyncToGenerator(function* () {
184
- yield doubleRaf();
185
- scroller.value = getParentScroller(barEl.value);
186
- scroller.value.addEventListener('scroll', handleScroll);
217
+ useMounted( /*#__PURE__*/_asyncToGenerator(function* () {
218
+ yield setScroller();
219
+ addScrollerListener();
187
220
  }));
188
- onBeforeUnmount(() => {
189
- call(scroller.value.removeEventListener, 'scroll', handleScroll);
190
- });
221
+ onBeforeUnmount(removeScrollerListener);
222
+ onDeactivated(removeScrollerListener);
191
223
  return {
192
224
  n,
193
225
  classes,
@@ -235,7 +235,7 @@ import './time-picker/style/index.mjs'
235
235
  import './tooltip/style/index.mjs'
236
236
  import './uploader/style/index.mjs'
237
237
 
238
- const version = '2.8.6-alpha.1677756540023'
238
+ const version = '2.8.6-alpha.1678026101378'
239
239
 
240
240
  function install(app) {
241
241
  ActionSheet.install && app.use(ActionSheet)
package/es/index.mjs CHANGED
@@ -156,7 +156,7 @@ export * from './time-picker/index.mjs'
156
156
  export * from './tooltip/index.mjs'
157
157
  export * from './uploader/index.mjs'
158
158
 
159
- const version = '2.8.6-alpha.1677756540023'
159
+ const version = '2.8.6-alpha.1678026101378'
160
160
 
161
161
  function install(app) {
162
162
  ActionSheet.install && app.use(ActionSheet)
@@ -1,10 +1,11 @@
1
1
  import VarFormDetails from '../form-details/index.mjs';
2
2
  import VarIcon from '../icon/index.mjs';
3
- import { defineComponent, getCurrentInstance, ref, computed, nextTick, onMounted } from 'vue';
3
+ import { defineComponent, getCurrentInstance, ref, computed, nextTick } from 'vue';
4
4
  import { props } from './props.mjs';
5
5
  import { isEmpty, toNumber } from '@varlet/shared';
6
6
  import { useValidation, createNamespace, call } from '../utils/components.mjs';
7
7
  import { useForm } from '../form/provide.mjs';
8
+ import { useMounted } from '@varlet/use';
8
9
  var {
9
10
  n,
10
11
  classes
@@ -287,7 +288,6 @@ var __sfc__ = defineComponent({
287
288
  var {
288
289
  composing
289
290
  } = e.target;
290
- console.log(composing);
291
291
 
292
292
  if (composing) {
293
293
  return;
@@ -397,7 +397,7 @@ var __sfc__ = defineComponent({
397
397
  resetValidation
398
398
  };
399
399
  call(bindForm, inputProvider);
400
- onMounted(() => {
400
+ useMounted(() => {
401
401
  if (props.autofocus) {
402
402
  focus();
403
403
  }
package/es/list/List.mjs CHANGED
@@ -4,13 +4,14 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
4
4
 
5
5
  import VarLoading from '../loading/index.mjs';
6
6
  import Ripple from '../ripple/index.mjs';
7
- import { defineComponent, onMounted, onUnmounted, ref, nextTick } from 'vue';
7
+ import { defineComponent, onUnmounted, ref, nextTick } from 'vue';
8
8
  import { getParentScroller, toPxNum } from '../utils/elements.mjs';
9
9
  import { props } from './props.mjs';
10
10
  import { isNumber } from '@varlet/shared';
11
11
  import { dt } from '../utils/shared.mjs';
12
12
  import { createNamespace, call } from '../utils/components.mjs';
13
13
  import { pack } from '../locale/index.mjs';
14
+ import { useMounted } from '@varlet/use';
14
15
  var {
15
16
  n,
16
17
  classes
@@ -116,7 +117,7 @@ var __sfc__ = defineComponent({
116
117
  };
117
118
  }();
118
119
 
119
- onMounted(() => {
120
+ useMounted(() => {
120
121
  scroller = getParentScroller(listEl.value);
121
122
  props.immediateCheck && check();
122
123
  scroller.addEventListener('scroll', check);
@@ -6,6 +6,7 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
6
6
 
7
7
  import flip from '@popperjs/core/lib/modifiers/flip';
8
8
  import offset from '@popperjs/core/lib/modifiers/offset';
9
+ import { useClickOutside } from '@varlet/use';
9
10
  import { doubleRaf, toPxNum } from '../utils/elements.mjs';
10
11
  import { call } from '../utils/components.mjs';
11
12
  import { onMounted, onUnmounted, ref, watch } from 'vue';
@@ -23,7 +24,6 @@ export function usePopover(options) {
23
24
  zIndex
24
25
  } = useZIndex(() => show.value, 1);
25
26
  var popoverInstance = null;
26
- var clickSelf = false;
27
27
  var enterPopover = false;
28
28
  var enterHost = false;
29
29
 
@@ -99,17 +99,19 @@ export function usePopover(options) {
99
99
 
100
100
  var handleHostClick = () => {
101
101
  open();
102
- clickSelf = true;
103
102
  };
104
103
 
105
104
  var handlePopoverClose = () => {
106
- if (clickSelf) {
107
- clickSelf = false;
105
+ show.value = false;
106
+ call(options['onUpdate:show'], false);
107
+ };
108
+
109
+ var handleClickOutside = () => {
110
+ if (options.trigger !== 'click') {
108
111
  return;
109
112
  }
110
113
 
111
- show.value = false;
112
- call(options['onUpdate:show'], false);
114
+ handlePopoverClose();
113
115
  };
114
116
 
115
117
  var getPosition = () => {
@@ -258,6 +260,7 @@ export function usePopover(options) {
258
260
  call(options['onUpdate:show'], false);
259
261
  };
260
262
 
263
+ useClickOutside(host, 'click', handleClickOutside);
261
264
  watch(() => options.show, newValue => {
262
265
  show.value = newValue != null ? newValue : false;
263
266
  }, {
@@ -274,23 +277,11 @@ export function usePopover(options) {
274
277
  call(options.onClose);
275
278
  }
276
279
  });
277
- watch(() => options.trigger, newValue => {
278
- if (newValue === 'click') {
279
- document.addEventListener('click', handlePopoverClose);
280
- } else {
281
- document.removeEventListener('click', handlePopoverClose);
282
- }
283
- });
284
280
  watch(() => options.disabled, close);
285
281
  onMounted(() => {
286
282
  popoverInstance = createPopper(host.value, popover.value, getPopperOptions());
287
-
288
- if (options.trigger === 'click') {
289
- document.addEventListener('click', handlePopoverClose);
290
- }
291
283
  });
292
284
  onUnmounted(() => {
293
- document.removeEventListener('click', handlePopoverClose);
294
285
  popoverInstance.destroy();
295
286
  });
296
287
  return {
@@ -3,11 +3,12 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
3
3
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
4
4
 
5
5
  import VarIcon from '../icon/index.mjs';
6
- import { defineComponent, ref, computed, watch, onMounted, onBeforeUnmount } from 'vue';
6
+ import { defineComponent, ref, computed, watch } from 'vue';
7
7
  import { getParentScroller, getScrollTop, getTarget } from '../utils/elements.mjs';
8
8
  import { props } from './props.mjs';
9
9
  import { toNumber } from '@varlet/shared';
10
10
  import { call, createNamespace } from '../utils/components.mjs';
11
+ import { useEventListener, useMounted } from '@varlet/use';
11
12
  var {
12
13
  n,
13
14
  classes
@@ -168,6 +169,10 @@ var __sfc__ = defineComponent({
168
169
  controlPosition.value = -(width + width * 0.25);
169
170
  };
170
171
 
172
+ var setScroller = () => {
173
+ scroller = props.target ? getTarget(props.target, 'PullRefresh') : getParentScroller(freshNode.value);
174
+ };
175
+
171
176
  var reset = () => {
172
177
  setTimeout(() => {
173
178
  refreshStatus.value = 'default';
@@ -187,20 +192,11 @@ var __sfc__ = defineComponent({
187
192
  }, toNumber(props.successDuration));
188
193
  }
189
194
  });
190
- onMounted(() => {
191
- var _freshNode$value;
192
-
193
- scroller = props.target ? getTarget(props.target, 'PullRefresh') : getParentScroller(freshNode.value);
195
+ useMounted(() => {
196
+ setScroller();
194
197
  setPosition();
195
- (_freshNode$value = freshNode.value) == null ? void 0 : _freshNode$value.addEventListener('touchmove', touchMove, {
196
- passive: false
197
- });
198
- });
199
- onBeforeUnmount(() => {
200
- var _freshNode$value2;
201
-
202
- (_freshNode$value2 = freshNode.value) == null ? void 0 : _freshNode$value2.removeEventListener('touchmove', touchMove);
203
198
  });
199
+ useEventListener(freshNode, 'touchmove', touchMove);
204
200
  return {
205
201
  n,
206
202
  classes,