yc-design-vue 1.1.3 → 1.1.5
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/Alert/index.vue2.js +2 -2
- package/es/Calendar/Calendar.vue2.js +2 -2
- package/es/Carousel/Carousel.vue.js +1 -1
- package/es/Carousel/Carousel.vue2.js +15 -14
- package/es/Carousel/hooks/useContext.js +4 -3
- package/es/Cascader/CascaderIcon.vue2.js +2 -2
- package/es/Checkbox/Checkbox.vue2.js +2 -2
- package/es/Collapse/CollapseItem.vue2.js +2 -2
- package/es/Drawer/Drawer.vue2.js +2 -2
- package/es/Image/ImagePreview.vue.js +1 -1
- package/es/Image/ImagePreview.vue2.js +8 -5
- package/es/Input/Input.vue2.js +2 -2
- package/es/Input/InputSuffix.vue2.js +2 -2
- package/es/InputTag/index.vue2.js +2 -2
- package/es/Menu/SubMenu.vue2.js +2 -2
- package/es/Message/Message.vue2.js +2 -2
- package/es/Modal/Modal.vue2.js +2 -2
- package/es/Notification/Notification.vue2.js +2 -2
- package/es/PageHeader/index.vue2.js +2 -2
- package/es/Radio/Radio.vue2.js +2 -2
- package/es/Select/SelectIcon.vue2.js +2 -2
- package/es/Tabs/TabButton.vue2.js +2 -2
- package/es/Tag/index.vue2.js +2 -2
- package/es/Textarea/index.vue2.js +2 -2
- package/es/TimePicker/TimePicker.vue2.js +2 -2
- package/es/Transfer/TransferPanel.vue2.js +4 -4
- package/es/Trigger/index.vue2.js +2 -2
- package/es/_shared/components/{ExpandTransition.vue.js → ExpandTransition.vue2.js} +1 -1
- package/es/_shared/components/{IconButton.vue2.js → IconButton.vue.js} +1 -1
- package/es/_shared/icons/IconDelete.vue.js +1 -16
- package/es/_shared/icons/IconDelete.vue2.js +16 -1
- package/es/_shared/icons/IconSearch.vue.js +1 -16
- package/es/_shared/icons/IconSearch.vue2.js +16 -1
- package/es/_shared/utils/dom.js +6 -6
- package/es/node_modules/@vueuse/core/index.js +3 -1
- package/es/node_modules/@vueuse/shared/index.js +76 -1
- package/es/style.css +1 -1
- package/lib/Alert/index.vue2.js +1 -1
- package/lib/Calendar/Calendar.vue2.js +1 -1
- package/lib/Carousel/Carousel.vue.js +1 -1
- package/lib/Carousel/Carousel.vue2.js +1 -1
- package/lib/Carousel/hooks/useContext.js +1 -1
- package/lib/Cascader/CascaderIcon.vue2.js +1 -1
- package/lib/Checkbox/Checkbox.vue2.js +1 -1
- package/lib/Collapse/CollapseItem.vue2.js +1 -1
- package/lib/Drawer/Drawer.vue2.js +1 -1
- package/lib/Image/ImagePreview.vue.js +1 -1
- package/lib/Image/ImagePreview.vue2.js +1 -1
- package/lib/Input/Input.vue2.js +1 -1
- package/lib/Input/InputSuffix.vue2.js +1 -1
- package/lib/InputTag/index.vue2.js +1 -1
- package/lib/Menu/SubMenu.vue2.js +1 -1
- package/lib/Message/Message.vue2.js +1 -1
- package/lib/Modal/Modal.vue2.js +1 -1
- package/lib/Notification/Notification.vue2.js +1 -1
- package/lib/PageHeader/index.vue2.js +1 -1
- package/lib/Radio/Radio.vue2.js +1 -1
- package/lib/Select/SelectIcon.vue2.js +1 -1
- package/lib/Tabs/TabButton.vue2.js +1 -1
- package/lib/Tag/index.vue2.js +1 -1
- package/lib/Textarea/index.vue2.js +1 -1
- package/lib/TimePicker/TimePicker.vue2.js +1 -1
- package/lib/Transfer/TransferPanel.vue2.js +1 -1
- package/lib/Trigger/index.vue2.js +1 -1
- package/lib/_shared/components/ExpandTransition.vue2.js +1 -0
- package/lib/_shared/components/IconButton.vue.js +1 -0
- package/lib/_shared/icons/IconDelete.vue.js +1 -1
- package/lib/_shared/icons/IconDelete.vue2.js +1 -1
- package/lib/_shared/icons/IconSearch.vue.js +1 -1
- package/lib/_shared/icons/IconSearch.vue2.js +1 -1
- package/lib/_shared/utils/dom.js +1 -1
- package/lib/node_modules/@vueuse/core/index.js +1 -1
- package/lib/node_modules/@vueuse/shared/index.js +1 -1
- package/lib/style.css +1 -1
- package/package.json +1 -1
- package/lib/_shared/components/ExpandTransition.vue.js +0 -1
- package/lib/_shared/components/IconButton.vue2.js +0 -1
@@ -1,4 +1,4 @@
|
|
1
|
-
import { getCurrentScope, onScopeDispose, watch, onMounted, nextTick, isRef, toRefs as toRefs$1, customRef, toValue, getCurrentInstance, hasInjectionContext, inject,
|
1
|
+
import { getCurrentScope, onScopeDispose, watch, onMounted, nextTick, isRef, toRefs as toRefs$1, customRef, toValue, getCurrentInstance, shallowRef, hasInjectionContext, inject, readonly } from "vue";
|
2
2
|
function tryOnScopeDispose(fn) {
|
3
3
|
if (getCurrentScope()) {
|
4
4
|
onScopeDispose(fn);
|
@@ -240,6 +240,79 @@ function tryOnMounted(fn, sync = true, target) {
|
|
240
240
|
else
|
241
241
|
nextTick(fn);
|
242
242
|
}
|
243
|
+
function useIntervalFn(cb, interval = 1e3, options = {}) {
|
244
|
+
const {
|
245
|
+
immediate = true,
|
246
|
+
immediateCallback = false
|
247
|
+
} = options;
|
248
|
+
let timer = null;
|
249
|
+
const isActive = shallowRef(false);
|
250
|
+
function clean() {
|
251
|
+
if (timer) {
|
252
|
+
clearInterval(timer);
|
253
|
+
timer = null;
|
254
|
+
}
|
255
|
+
}
|
256
|
+
function pause() {
|
257
|
+
isActive.value = false;
|
258
|
+
clean();
|
259
|
+
}
|
260
|
+
function resume() {
|
261
|
+
const intervalValue = toValue(interval);
|
262
|
+
if (intervalValue <= 0)
|
263
|
+
return;
|
264
|
+
isActive.value = true;
|
265
|
+
if (immediateCallback)
|
266
|
+
cb();
|
267
|
+
clean();
|
268
|
+
if (isActive.value)
|
269
|
+
timer = setInterval(cb, intervalValue);
|
270
|
+
}
|
271
|
+
if (immediate && isClient)
|
272
|
+
resume();
|
273
|
+
if (isRef(interval) || typeof interval === "function") {
|
274
|
+
const stopWatch = watch(interval, () => {
|
275
|
+
if (isActive.value && isClient)
|
276
|
+
resume();
|
277
|
+
});
|
278
|
+
tryOnScopeDispose(stopWatch);
|
279
|
+
}
|
280
|
+
tryOnScopeDispose(pause);
|
281
|
+
return {
|
282
|
+
isActive,
|
283
|
+
pause,
|
284
|
+
resume
|
285
|
+
};
|
286
|
+
}
|
287
|
+
function useInterval(interval = 1e3, options = {}) {
|
288
|
+
const {
|
289
|
+
controls: exposeControls = false,
|
290
|
+
immediate = true,
|
291
|
+
callback
|
292
|
+
} = options;
|
293
|
+
const counter = shallowRef(0);
|
294
|
+
const update = () => counter.value += 1;
|
295
|
+
const reset = () => {
|
296
|
+
counter.value = 0;
|
297
|
+
};
|
298
|
+
const controls = useIntervalFn(
|
299
|
+
callback ? () => {
|
300
|
+
update();
|
301
|
+
callback(counter.value);
|
302
|
+
} : update,
|
303
|
+
interval,
|
304
|
+
{ immediate }
|
305
|
+
);
|
306
|
+
if (exposeControls) {
|
307
|
+
return {
|
308
|
+
counter,
|
309
|
+
reset,
|
310
|
+
...controls
|
311
|
+
};
|
312
|
+
} else {
|
313
|
+
return counter;
|
314
|
+
}
|
315
|
+
}
|
243
316
|
function useTimeoutFn(cb, interval, options = {}) {
|
244
317
|
const {
|
245
318
|
immediate = true,
|
@@ -310,6 +383,8 @@ export {
|
|
310
383
|
tryOnMounted,
|
311
384
|
tryOnScopeDispose,
|
312
385
|
useDebounceFn,
|
386
|
+
useInterval,
|
387
|
+
useIntervalFn,
|
313
388
|
useThrottleFn,
|
314
389
|
useTimeoutFn,
|
315
390
|
watchImmediate
|