sard-uniapp 1.18.0 → 1.19.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/CHANGELOG.md +28 -0
- package/README.md +6 -1
- package/components/button/button.vue +2 -0
- package/components/button/common.d.ts +1 -0
- package/components/button/index.scss +9 -0
- package/components/cascader/cascader.vue +7 -0
- package/components/cascader-input/cascader-input.vue +1 -1
- package/components/crop-image/crop-image.vue +7 -7
- package/components/dialog-agent/common.d.ts +3 -0
- package/components/dialog-agent/dialog-agent.vue +10 -1
- package/components/dropdown/common.d.ts +5 -0
- package/components/dropdown/index.d.ts +1 -1
- package/components/dropdown-item/dropdown-item.vue +77 -21
- package/components/floating-bubble/floating-bubble.vue +4 -4
- package/components/form/form.vue +4 -1
- package/components/form-item/index.scss +10 -0
- package/components/marquee/marquee.vue +8 -5
- package/components/notice-bar/notice-bar.vue +8 -5
- package/components/notify/notify.vue +10 -7
- package/components/picker-item/index.scss +0 -1
- package/components/pull-down-refresh/pull-down-refresh.vue +15 -9
- package/components/swipe-action/common.d.ts +23 -0
- package/components/swipe-action/common.js +1 -0
- package/components/swipe-action/index.d.ts +1 -0
- package/components/swipe-action/index.js +1 -0
- package/components/swipe-action/index.scss +53 -0
- package/components/swipe-action/swipe-action.d.ts +16 -0
- package/components/swipe-action/swipe-action.vue +275 -0
- package/components/swipe-action/variables.scss +3 -0
- package/components/toast/toast.vue +10 -7
- package/global.d.ts +1 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/index.scss +1 -0
- package/package.json +2 -7
- package/use/index.d.ts +3 -1
- package/use/index.js +3 -1
- package/use/useScrollSpy.js +4 -4
- package/use/useSimulatedClick.js +4 -4
- package/use/useSimulatedPress.js +5 -5
- package/use/useStopMovedClick.d.ts +6 -0
- package/use/useStopMovedClick.js +26 -0
- package/use/useTimeout.d.ts +11 -0
- package/use/useTimeout.js +39 -0
- package/use/useTimeoutLoading.js +9 -7
- package/use/useSetTimeout.d.ts +0 -1
- package/use/useSetTimeout.js +0 -24
package/use/useTimeoutLoading.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { computed, watch } from 'vue';
|
|
2
2
|
import { ref } from 'vue';
|
|
3
|
-
import {
|
|
3
|
+
import { useTimeout } from './useTimeout';
|
|
4
4
|
export function useTimeoutLoading(loading, options = {}) {
|
|
5
5
|
const { leading = 150, trailing = 20000 } = options;
|
|
6
6
|
const status = ref('idle');
|
|
7
7
|
let startTime = 0;
|
|
8
|
-
|
|
8
|
+
let trailingDuration = 0;
|
|
9
|
+
const { start: waitTrailing, stop: cancelTrailing } = useTimeout(() => {
|
|
9
10
|
status.value = 'idle';
|
|
10
|
-
});
|
|
11
|
-
const
|
|
11
|
+
}, () => trailingDuration);
|
|
12
|
+
const { start: waitLeading, stop: cancelLeading } = useTimeout(() => {
|
|
12
13
|
status.value = 'loading';
|
|
13
14
|
startTime = Date.now();
|
|
14
|
-
});
|
|
15
|
+
}, leading);
|
|
15
16
|
watch(loading, () => {
|
|
16
17
|
cancelLeading();
|
|
17
18
|
cancelTrailing();
|
|
@@ -19,7 +20,7 @@ export function useTimeoutLoading(loading, options = {}) {
|
|
|
19
20
|
switch (status.value) {
|
|
20
21
|
case 'idle':
|
|
21
22
|
status.value = 'leading';
|
|
22
|
-
waitLeading(
|
|
23
|
+
waitLeading();
|
|
23
24
|
break;
|
|
24
25
|
case 'trailing':
|
|
25
26
|
status.value = 'loading';
|
|
@@ -39,7 +40,8 @@ export function useTimeoutLoading(loading, options = {}) {
|
|
|
39
40
|
}
|
|
40
41
|
else {
|
|
41
42
|
status.value = 'trailing';
|
|
42
|
-
|
|
43
|
+
trailingDuration = trailing - duration;
|
|
44
|
+
waitTrailing();
|
|
43
45
|
}
|
|
44
46
|
break;
|
|
45
47
|
}
|
package/use/useSetTimeout.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function useSetTimeout(callback: (...args: any[]) => any): readonly [(duration: number, ...args: any[]) => void, () => void, () => boolean];
|
package/use/useSetTimeout.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { onUnmounted } from 'vue';
|
|
2
|
-
export function useSetTimeout(callback) {
|
|
3
|
-
let timer;
|
|
4
|
-
const cancel = () => {
|
|
5
|
-
if (timer) {
|
|
6
|
-
clearTimeout(timer);
|
|
7
|
-
timer = null;
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
const doSomethingLater = (duration, ...args) => {
|
|
11
|
-
cancel();
|
|
12
|
-
timer = setTimeout(() => {
|
|
13
|
-
timer = null;
|
|
14
|
-
callback(...args);
|
|
15
|
-
}, duration);
|
|
16
|
-
};
|
|
17
|
-
const isWaitingToDoSomething = () => {
|
|
18
|
-
return !!timer;
|
|
19
|
-
};
|
|
20
|
-
onUnmounted(() => {
|
|
21
|
-
cancel();
|
|
22
|
-
});
|
|
23
|
-
return [doSomethingLater, cancel, isWaitingToDoSomething];
|
|
24
|
-
}
|