@varlet/ui 2.8.5 → 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.
- package/es/app-bar/AppBar.mjs +3 -2
- package/es/avatar/Avatar.mjs +3 -2
- package/es/back-top/BackTop.mjs +26 -15
- package/es/bottom-navigation/BottomNavigation.mjs +3 -2
- package/es/countdown/Countdown.mjs +24 -7
- package/es/date-picker/src/day-picker-panel.mjs +3 -2
- package/es/date-picker/src/year-picker-panel.mjs +3 -2
- package/es/divider/Divider.mjs +10 -5
- package/es/index-bar/IndexBar.mjs +54 -22
- package/es/index.bundle.mjs +1 -1
- package/es/index.mjs +1 -1
- package/es/input/Input.mjs +53 -15
- package/es/list/List.mjs +3 -2
- package/es/menu/usePopover.mjs +9 -18
- package/es/pull-refresh/PullRefresh.mjs +9 -13
- package/es/slider/Slider.mjs +4 -3
- package/es/snackbar/core.mjs +3 -2
- package/es/sticky/Sticky.mjs +10 -7
- package/es/swipe/Swipe.mjs +6 -8
- package/es/tabs/Tabs.mjs +3 -3
- package/es/utils/components.mjs +3 -8
- package/es/varlet.esm.js +4972 -4892
- package/highlight/web-types.en-US.json +1 -1
- package/highlight/web-types.zh-CN.json +1 -1
- package/lib/varlet.cjs.js +241 -115
- package/package.json +6 -5
- package/umd/varlet.js +5 -5
- package/es/utils/types.mjs +0 -1
package/es/menu/usePopover.mjs
CHANGED
|
@@ -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
|
-
|
|
107
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
191
|
-
|
|
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,
|
package/es/slider/Slider.mjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import VarFormDetails from '../form-details/index.mjs';
|
|
2
|
+
import { defineComponent, ref, computed, reactive, nextTick, watch } from 'vue';
|
|
2
3
|
import { useValidation, createNamespace, call } from '../utils/components.mjs';
|
|
3
4
|
import { useForm } from '../form/provide.mjs';
|
|
4
5
|
import { getLeft, multiplySizeUnit } from '../utils/elements.mjs';
|
|
5
6
|
import { isArray, isNumber, toNumber } from '@varlet/shared';
|
|
6
7
|
import { props, Thumbs } from './props.mjs';
|
|
7
|
-
import
|
|
8
|
+
import { useMounted } from '@varlet/use';
|
|
8
9
|
var {
|
|
9
10
|
n,
|
|
10
11
|
classes
|
|
@@ -379,7 +380,7 @@ var __sfc__ = defineComponent({
|
|
|
379
380
|
setProps(modelValue, toNumber(step));
|
|
380
381
|
});
|
|
381
382
|
watch(maxWidth, () => setProps());
|
|
382
|
-
|
|
383
|
+
useMounted(() => {
|
|
383
384
|
if (!stepValidator() || !valueValidator()) return;
|
|
384
385
|
maxWidth.value = sliderEl.value.offsetWidth;
|
|
385
386
|
});
|
package/es/snackbar/core.mjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { defineComponent, watch, ref, onMounted, computed } from 'vue';
|
|
2
1
|
import VarLoading from '../loading/index.mjs';
|
|
3
2
|
import VarIcon from '../icon/index.mjs';
|
|
3
|
+
import { defineComponent, watch, ref, computed } from 'vue';
|
|
4
4
|
import { useZIndex } from '../context/zIndex.mjs';
|
|
5
5
|
import { props } from './props.mjs';
|
|
6
6
|
import { useLock } from '../context/lock.mjs';
|
|
7
7
|
import { SNACKBAR_TYPE } from './index.mjs';
|
|
8
8
|
import { call, createNamespace } from '../utils/components.mjs';
|
|
9
|
+
import { useMounted } from '@varlet/use';
|
|
9
10
|
var {
|
|
10
11
|
n,
|
|
11
12
|
classes
|
|
@@ -104,7 +105,7 @@ var __sfc__ = defineComponent({
|
|
|
104
105
|
clearTimeout(timer.value);
|
|
105
106
|
updateAfterDuration();
|
|
106
107
|
});
|
|
107
|
-
|
|
108
|
+
useMounted(() => {
|
|
108
109
|
if (props.show) {
|
|
109
110
|
call(props.onOpen);
|
|
110
111
|
updateAfterDuration();
|
package/es/sticky/Sticky.mjs
CHANGED
|
@@ -2,11 +2,12 @@ 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 { defineComponent, ref,
|
|
5
|
+
import { defineComponent, ref, onUnmounted, onDeactivated, computed, watch } from 'vue';
|
|
6
6
|
import { props } from './props.mjs';
|
|
7
7
|
import { doubleRaf, getParentScroller, raf, toPxNum } from '../utils/elements.mjs';
|
|
8
8
|
import { toNumber } from '@varlet/shared';
|
|
9
9
|
import { call, createNamespace } from '../utils/components.mjs';
|
|
10
|
+
import { useEventListener, useMounted } from '@varlet/use';
|
|
10
11
|
var {
|
|
11
12
|
n,
|
|
12
13
|
classes
|
|
@@ -112,7 +113,11 @@ var __sfc__ = defineComponent({
|
|
|
112
113
|
};
|
|
113
114
|
|
|
114
115
|
var handleScroll = () => {
|
|
115
|
-
|
|
116
|
+
if (!scroller) {
|
|
117
|
+
return;
|
|
118
|
+
} // returns undefined when disabled = true
|
|
119
|
+
|
|
120
|
+
|
|
116
121
|
var fixedParams = computeFixedParams();
|
|
117
122
|
|
|
118
123
|
if (fixedParams) {
|
|
@@ -138,7 +143,6 @@ var __sfc__ = defineComponent({
|
|
|
138
143
|
yield doubleRaf();
|
|
139
144
|
scroller = getParentScroller(stickyEl.value);
|
|
140
145
|
scroller !== window && scroller.addEventListener('scroll', handleScroll);
|
|
141
|
-
window.addEventListener('scroll', handleScroll);
|
|
142
146
|
handleScroll();
|
|
143
147
|
});
|
|
144
148
|
|
|
@@ -149,14 +153,13 @@ var __sfc__ = defineComponent({
|
|
|
149
153
|
|
|
150
154
|
var removeScrollListener = () => {
|
|
151
155
|
scroller !== window && scroller.removeEventListener('scroll', handleScroll);
|
|
152
|
-
window.removeEventListener('scroll', handleScroll);
|
|
153
156
|
};
|
|
154
157
|
|
|
155
158
|
watch(() => props.disabled, resize);
|
|
156
|
-
|
|
157
|
-
onDeactivated(removeScrollListener);
|
|
158
|
-
onMounted(addScrollListener);
|
|
159
|
+
useMounted(addScrollListener);
|
|
159
160
|
onUnmounted(removeScrollListener);
|
|
161
|
+
onDeactivated(removeScrollListener);
|
|
162
|
+
useEventListener(window, 'scroll', handleScroll);
|
|
160
163
|
return {
|
|
161
164
|
n,
|
|
162
165
|
classes,
|
package/es/swipe/Swipe.mjs
CHANGED
|
@@ -2,12 +2,13 @@ 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 { defineComponent, ref, computed, watch,
|
|
5
|
+
import { defineComponent, ref, computed, watch, onUnmounted, onDeactivated, onActivated } from 'vue';
|
|
6
6
|
import { useSwipeItems } from './provide.mjs';
|
|
7
7
|
import { doubleRaf, nextTickFrame } from '../utils/elements.mjs';
|
|
8
8
|
import { props } from './props.mjs';
|
|
9
9
|
import { isNumber, toNumber } from '@varlet/shared';
|
|
10
10
|
import { call, createNamespace } from '../utils/components.mjs';
|
|
11
|
+
import { useEventListener } from '@varlet/use';
|
|
11
12
|
var SWIPE_DELAY = 250;
|
|
12
13
|
var SWIPE_DISTANCE = 20;
|
|
13
14
|
var {
|
|
@@ -408,13 +409,10 @@ var __sfc__ = defineComponent({
|
|
|
408
409
|
initialIndex();
|
|
409
410
|
resize();
|
|
410
411
|
}));
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
window.removeEventListener('resize', resize);
|
|
416
|
-
stopAutoplay();
|
|
417
|
-
});
|
|
412
|
+
onActivated(resize);
|
|
413
|
+
onDeactivated(stopAutoplay);
|
|
414
|
+
onUnmounted(stopAutoplay);
|
|
415
|
+
useEventListener(window, 'resize', resize);
|
|
418
416
|
return {
|
|
419
417
|
n,
|
|
420
418
|
classes,
|
package/es/tabs/Tabs.mjs
CHANGED
|
@@ -3,13 +3,14 @@ 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 VarSticky from '../sticky/index.mjs';
|
|
6
|
-
import { defineComponent, watch, ref, computed, Transition
|
|
6
|
+
import { defineComponent, watch, ref, computed, Transition } from 'vue';
|
|
7
7
|
import { props } from './props.mjs';
|
|
8
8
|
import { useTabList } from './provide.mjs';
|
|
9
9
|
import { isNumber } from '@varlet/shared';
|
|
10
10
|
import { linear } from '../utils/shared.mjs';
|
|
11
11
|
import { toSizeUnit, scrollTo, doubleRaf } from '../utils/elements.mjs';
|
|
12
12
|
import { createNamespace, call } from '../utils/components.mjs';
|
|
13
|
+
import { useEventListener } from '@varlet/use';
|
|
13
14
|
var {
|
|
14
15
|
n,
|
|
15
16
|
classes
|
|
@@ -217,8 +218,7 @@ var __sfc__ = defineComponent({
|
|
|
217
218
|
resize();
|
|
218
219
|
}));
|
|
219
220
|
watch(() => props.active, resize);
|
|
220
|
-
|
|
221
|
-
onUnmounted(() => window.removeEventListener('resize', resize));
|
|
221
|
+
useEventListener(window, 'resize', resize);
|
|
222
222
|
return {
|
|
223
223
|
stickyComponent,
|
|
224
224
|
indicatorWidth,
|
package/es/utils/components.mjs
CHANGED
|
@@ -8,6 +8,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
8
8
|
|
|
9
9
|
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); }
|
|
10
10
|
|
|
11
|
+
import { useEventListener } from '@varlet/use';
|
|
11
12
|
import { createApp, h, getCurrentInstance, inject, onUnmounted, computed, provide, reactive, isVNode, onMounted, onBeforeUnmount, nextTick, ref, onActivated, onDeactivated } from 'vue';
|
|
12
13
|
import { isArray, removeItem } from '@varlet/shared';
|
|
13
14
|
export function pickProps(props, propsKey) {
|
|
@@ -232,14 +233,8 @@ export function useValidation() {
|
|
|
232
233
|
};
|
|
233
234
|
}
|
|
234
235
|
export function useRouteListener(cb) {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
window.addEventListener('popstate', cb);
|
|
238
|
-
});
|
|
239
|
-
onUnmounted(() => {
|
|
240
|
-
window.removeEventListener('hashchange', cb);
|
|
241
|
-
window.removeEventListener('popstate', cb);
|
|
242
|
-
});
|
|
236
|
+
useEventListener(window, 'hashchange', cb);
|
|
237
|
+
useEventListener(window, 'popstate', cb);
|
|
243
238
|
}
|
|
244
239
|
export function useTeleport() {
|
|
245
240
|
var disabled = ref(false);
|