@varlet/ui 3.3.12 → 3.3.13-alpha.1723094901591

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.
@@ -10,7 +10,7 @@ import { call, normalizeToArray } from "@varlet/shared";
10
10
  const { name, n, classes } = createNamespace("button");
11
11
  import { resolveComponent as _resolveComponent, normalizeClass as _normalizeClass, openBlock as _openBlock, createBlock as _createBlock, createCommentVNode as _createCommentVNode, renderSlot as _renderSlot, createElementVNode as _createElementVNode, createVNode as _createVNode, normalizeStyle as _normalizeStyle, resolveDirective as _resolveDirective, createElementBlock as _createElementBlock, withDirectives as _withDirectives, pushScopeId as _pushScopeId, popScopeId as _popScopeId } from "vue";
12
12
  const _withScopeId = (n2) => (_pushScopeId(""), n2 = n2(), _popScopeId(), n2);
13
- const _hoisted_1 = ["type", "disabled"];
13
+ const _hoisted_1 = ["tabindex", "type", "disabled"];
14
14
  function __render__(_ctx, _cache) {
15
15
  const _component_var_loading = _resolveComponent("var-loading");
16
16
  const _component_var_hover_overlay = _resolveComponent("var-hover-overlay");
@@ -34,6 +34,7 @@ function __render__(_ctx, _cache) {
34
34
  [_ctx.states.text && _ctx.disabled, _ctx.n("--text-disabled")]
35
35
  )
36
36
  ),
37
+ tabindex: _ctx.focusable ? void 0 : "-1",
37
38
  style: _normalizeStyle({
38
39
  color: _ctx.states.textColor,
39
40
  background: _ctx.states.color
@@ -42,7 +43,7 @@ function __render__(_ctx, _cache) {
42
43
  disabled: _ctx.disabled,
43
44
  onClick: _cache[0] || (_cache[0] = (...args) => _ctx.handleClick && _ctx.handleClick(...args)),
44
45
  onTouchstart: _cache[1] || (_cache[1] = (...args) => _ctx.handleTouchstart && _ctx.handleTouchstart(...args)),
45
- onFocus: _cache[2] || (_cache[2] = ($event) => _ctx.isFocusing = true),
46
+ onFocus: _cache[2] || (_cache[2] = (...args) => _ctx.handleFocus && _ctx.handleFocus(...args)),
46
47
  onBlur: _cache[3] || (_cache[3] = ($event) => _ctx.isFocusing = false)
47
48
  }, [
48
49
  _ctx.loading || _ctx.pending ? (_openBlock(), _createBlock(_component_var_loading, {
@@ -137,16 +138,23 @@ const __sfc__ = defineComponent({
137
138
  }
138
139
  attemptAutoLoading(call(onTouchstart, e));
139
140
  }
141
+ function handleFocus() {
142
+ if (!props2.focusable) {
143
+ return;
144
+ }
145
+ isFocusing.value = true;
146
+ }
140
147
  return {
141
148
  pending,
142
149
  states,
143
150
  hovering,
151
+ isFocusing,
144
152
  n,
145
153
  classes,
146
154
  handleHovering,
147
155
  handleClick,
148
156
  handleTouchstart,
149
- isFocusing
157
+ handleFocus
150
158
  };
151
159
  }
152
160
  });
@@ -38,6 +38,10 @@ const props = {
38
38
  type: Boolean,
39
39
  default: true
40
40
  },
41
+ focusable: {
42
+ type: Boolean,
43
+ default: true
44
+ },
41
45
  color: String,
42
46
  textColor: String,
43
47
  elevation: {
@@ -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.1723094901591'
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.1723094901591'
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,