@varlet/ui 3.3.12 → 3.3.13-alpha.1722867213138

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.
@@ -265,7 +265,7 @@ import './tooltip/style/index.mjs'
265
265
  import './uploader/style/index.mjs'
266
266
  import './watermark/style/index.mjs'
267
267
 
268
- const version = '3.3.12'
268
+ const version = '3.3.13-alpha.1722867213138'
269
269
 
270
270
  function install(app) {
271
271
  ActionSheet.install && app.use(ActionSheet)
package/es/index.mjs CHANGED
@@ -176,7 +176,7 @@ export * from './tooltip/index.mjs'
176
176
  export * from './uploader/index.mjs'
177
177
  export * from './watermark/index.mjs'
178
178
 
179
- const version = '3.3.12'
179
+ const version = '3.3.13-alpha.1722867213138'
180
180
 
181
181
  function install(app) {
182
182
  ActionSheet.install && app.use(ActionSheet)
@@ -2,84 +2,89 @@ import LoadingBarComponent from "./LoadingBar.mjs";
2
2
  import { reactive } from "vue";
3
3
  import { mountInstance } from "../utils/components.mjs";
4
4
  import { props as loadingBarProps } from "./props.mjs";
5
+ const OPACITY_DELAY = 200;
5
6
  let valueTimer;
6
7
  let errorTimer;
7
- let opacityTimer;
8
8
  let finishTimer;
9
+ let finishErrorTimer;
10
+ let opacityTimer;
9
11
  let isMount;
10
- let setOptions = {};
12
+ let internalOptions = {};
11
13
  const internalProps = {
12
14
  value: 0,
13
15
  opacity: 0,
14
16
  error: false
15
17
  };
16
- const props = reactive(internalProps);
17
- const setDefaultOptions = (options) => {
18
- Object.assign(props, options);
19
- setOptions = options;
20
- };
18
+ const ctx = reactive(internalProps);
19
+ function setDefaultOptions(options) {
20
+ Object.assign(ctx, options);
21
+ internalOptions = options;
22
+ }
21
23
  const resetDefaultOptions = () => {
22
- Object.keys(setOptions).forEach((key) => {
23
- if (props[key] !== void 0) {
24
- props[key] = void 0;
24
+ Object.keys(internalOptions).forEach((key) => {
25
+ if (ctx[key] !== void 0) {
26
+ ctx[key] = void 0;
25
27
  }
26
28
  });
27
29
  };
28
30
  const mount = () => {
29
31
  if (!isMount) {
30
32
  isMount = true;
31
- mountInstance(LoadingBarComponent, props);
33
+ mountInstance(LoadingBarComponent, ctx);
32
34
  }
33
35
  };
34
- const tickValue = () => {
36
+ const tick = () => {
35
37
  valueTimer = window.setTimeout(() => {
36
- if (props.value >= 95)
38
+ if (ctx.value >= 95) {
37
39
  return;
38
- let num = Math.random();
39
- if (props.value < 70)
40
- num = Math.round(5 * Math.random());
41
- props.value += num;
42
- tickValue();
40
+ }
41
+ ctx.value += ctx.value < 70 ? Math.round(5 * Math.random()) : Math.random();
42
+ tick();
43
43
  }, 200);
44
44
  };
45
45
  const clearTimer = () => {
46
- window.clearTimeout(errorTimer);
47
46
  window.clearTimeout(valueTimer);
48
47
  window.clearTimeout(opacityTimer);
49
48
  window.clearTimeout(finishTimer);
49
+ window.clearTimeout(errorTimer);
50
+ window.clearTimeout(finishErrorTimer);
51
+ };
52
+ const finishTask = () => {
53
+ clearTimer();
54
+ ctx.value = 100;
55
+ opacityTimer = window.setTimeout(() => {
56
+ ctx.opacity = 0;
57
+ finishErrorTimer = window.setTimeout(() => {
58
+ ctx.error = false;
59
+ }, 250);
60
+ }, OPACITY_DELAY + 100);
50
61
  };
51
62
  const start = () => {
52
63
  clearTimer();
53
- props.error = false;
54
- props.value = 0;
64
+ ctx.error = false;
65
+ ctx.value = 0;
55
66
  mount();
56
67
  opacityTimer = window.setTimeout(() => {
57
- props.opacity = 1;
58
- }, 200);
59
- tickValue();
68
+ ctx.opacity = 1;
69
+ }, OPACITY_DELAY);
70
+ tick();
60
71
  };
61
72
  const finish = () => {
62
- clearTimer();
63
- props.value = 100;
64
- opacityTimer = window.setTimeout(() => {
65
- props.opacity = 0;
66
- errorTimer = window.setTimeout(() => {
67
- props.error = false;
68
- }, 250);
69
- }, 300);
73
+ var _a;
74
+ finishTimer = window.setTimeout(finishTask, (_a = ctx.finishDelay) != null ? _a : 0);
70
75
  };
71
76
  const error = () => {
72
77
  clearTimer();
73
- props.error = true;
74
- if (props.value === 100) {
75
- props.value = 0;
78
+ ctx.error = true;
79
+ if (ctx.value === 100) {
80
+ ctx.value = 0;
76
81
  }
77
82
  mount();
78
83
  opacityTimer = window.setTimeout(() => {
79
- props.opacity = 1;
80
- }, 200);
81
- tickValue();
82
- finishTimer = window.setTimeout(finish, 300);
84
+ ctx.opacity = 1;
85
+ }, OPACITY_DELAY);
86
+ tick();
87
+ errorTimer = window.setTimeout(finishTask, 300);
83
88
  };
84
89
  const LoadingBar = {
85
90
  start,
@@ -1,7 +1,7 @@
1
1
  import '../../styles/common.css'
2
- import '../SnackbarSfc.css'
3
2
  import '../../styles/elevation.css'
4
3
  import '../../loading/loading.css'
5
4
  import '../../icon/icon.css'
6
5
  import '../snackbar.css'
7
6
  import '../coreSfc.css'
7
+ import '../SnackbarSfc.css'