@mantine-vue/hooks 3.1.0 → 3.3.0
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/cjs/index.cjs +11 -10
- package/cjs/index.cjs.map +1 -1
- package/esm/index.mjs +11 -10
- package/esm/index.mjs.map +1 -1
- package/lib/use-pagination/use-pagination.d.ts +1 -1
- package/package.json +1 -1
package/esm/index.mjs
CHANGED
|
@@ -272,11 +272,14 @@ function useDebouncedValue(value, wait, options = {}) {
|
|
|
272
272
|
let timeout;
|
|
273
273
|
let cooldown = false;
|
|
274
274
|
let latestValue = toValue(value);
|
|
275
|
-
const
|
|
275
|
+
const clearTimer = () => {
|
|
276
276
|
if (timeout) {
|
|
277
277
|
clearTimeout(timeout);
|
|
278
278
|
timeout = void 0;
|
|
279
279
|
}
|
|
280
|
+
};
|
|
281
|
+
const cancel = () => {
|
|
282
|
+
clearTimer();
|
|
280
283
|
cooldown = false;
|
|
281
284
|
};
|
|
282
285
|
const flush = () => {
|
|
@@ -287,6 +290,7 @@ function useDebouncedValue(value, wait, options = {}) {
|
|
|
287
290
|
};
|
|
288
291
|
watch(() => toValue(value), (nextValue) => {
|
|
289
292
|
latestValue = nextValue;
|
|
293
|
+
clearTimer();
|
|
290
294
|
if (!cooldown && options.leading) {
|
|
291
295
|
cooldown = true;
|
|
292
296
|
debounced.value = nextValue;
|
|
@@ -294,14 +298,11 @@ function useDebouncedValue(value, wait, options = {}) {
|
|
|
294
298
|
cooldown = false;
|
|
295
299
|
timeout = void 0;
|
|
296
300
|
}, wait);
|
|
297
|
-
} else {
|
|
298
|
-
|
|
299
|
-
timeout =
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
debounced.value = nextValue;
|
|
303
|
-
}, wait);
|
|
304
|
-
}
|
|
301
|
+
} else timeout = setTimeout(() => {
|
|
302
|
+
cooldown = false;
|
|
303
|
+
timeout = void 0;
|
|
304
|
+
debounced.value = nextValue;
|
|
305
|
+
}, wait);
|
|
305
306
|
});
|
|
306
307
|
onBeforeUnmount(cancel);
|
|
307
308
|
return [
|
|
@@ -1005,7 +1006,7 @@ function range$1(start, end) {
|
|
|
1005
1006
|
}
|
|
1006
1007
|
function usePagination({ total, siblings = 1, boundaries = 1, page, initialPage, onChange, startValue = 1 }) {
|
|
1007
1008
|
const start = computed(() => Math.max(Math.trunc(startValue), 1));
|
|
1008
|
-
const end = computed(() => Math.max(Math.trunc(total), start.value));
|
|
1009
|
+
const end = computed(() => Math.max(Math.trunc(toValue(total)), start.value));
|
|
1009
1010
|
const totalPages = computed(() => end.value - start.value + 1);
|
|
1010
1011
|
const firstPage = computed(() => initialPage ?? start.value);
|
|
1011
1012
|
const [active, setActive] = useUncontrolled({
|