@varlet/ui 2.12.2 → 2.12.3

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.
@@ -241,7 +241,7 @@ import './time-picker/style/index.mjs'
241
241
  import './tooltip/style/index.mjs'
242
242
  import './uploader/style/index.mjs'
243
243
 
244
- const version = '2.12.2'
244
+ const version = '2.12.3'
245
245
 
246
246
  function install(app) {
247
247
  ActionSheet.install && app.use(ActionSheet)
package/es/index.mjs CHANGED
@@ -160,7 +160,7 @@ export * from './time-picker/index.mjs'
160
160
  export * from './tooltip/index.mjs'
161
161
  export * from './uploader/index.mjs'
162
162
 
163
- const version = '2.12.2'
163
+ const version = '2.12.3'
164
164
 
165
165
  function install(app) {
166
166
  ActionSheet.install && app.use(ActionSheet)
@@ -47,6 +47,7 @@ function __render__(_ctx, _cache) {
47
47
  "append-icon": _withCtx(() => [_renderSlot(_ctx.$slots, "append-icon")]),
48
48
  default: _withCtx(() => [_ctx.normalizedType === 'password' ? (_openBlock(), _createElementBlock("input", {
49
49
  key: 0,
50
+ tabindex: "-1",
50
51
  class: _normalizeClass(_ctx.n('autocomplete')),
51
52
  placeholder: !_ctx.hint ? _ctx.placeholder : undefined,
52
53
  style: _normalizeStyle({
@@ -1,18 +1,17 @@
1
1
  import { defineComponent, computed } from 'vue';
2
2
  import { props } from './props.mjs';
3
3
  import { toNumber } from '@varlet/shared';
4
- import { toSizeUnit, multiplySizeUnit, toPxNum } from '../utils/elements.mjs';
4
+ import { toSizeUnit, toPxNum } from '../utils/elements.mjs';
5
5
  import { createNamespace } from '../utils/components.mjs';
6
6
  var {
7
7
  n,
8
8
  classes
9
9
  } = createNamespace('progress');
10
- var ONE_HUNDRED = 100;
11
10
  import { normalizeClass as _normalizeClass, normalizeStyle as _normalizeStyle, openBlock as _openBlock, createElementBlock as _createElementBlock, createCommentVNode as _createCommentVNode, createElementVNode as _createElementVNode, renderSlot as _renderSlot, toDisplayString as _toDisplayString, createTextVNode as _createTextVNode, pushScopeId as _pushScopeId, popScopeId as _popScopeId } from "vue";
12
11
  var _withScopeId = n => (_pushScopeId(""), n = n(), _popScopeId(), n);
13
12
  var _hoisted_1 = ["viewBox"];
14
- var _hoisted_2 = ["cx", "cy", "r", "stroke-width"];
15
- var _hoisted_3 = ["cx", "cy", "r", "stroke-width"];
13
+ var _hoisted_2 = ["r", "stroke-width", "stroke-dasharray"];
14
+ var _hoisted_3 = ["r", "stroke-width", "stroke-dasharray", "stroke-dashoffset"];
16
15
  function __render__(_ctx, _cache) {
17
16
  return _openBlock(), _createElementBlock("div", {
18
17
  class: _normalizeClass(_ctx.n())
@@ -30,18 +29,32 @@ function __render__(_ctx, _cache) {
30
29
  style: _normalizeStyle({
31
30
  background: _ctx.trackColor
32
31
  })
33
- }, null, 6 /* CLASS, STYLE */)) : _createCommentVNode("v-if", true), _createElementVNode("div", {
34
- class: _normalizeClass(_ctx.classes(_ctx.n('linear-certain'), [_ctx.ripple, _ctx.n('linear-ripple')])),
32
+ }, null, 6 /* CLASS, STYLE */)) : _createCommentVNode("v-if", true), _ctx.indeterminate ? (_openBlock(), _createElementBlock("div", {
33
+ key: 1,
34
+ class: _normalizeClass(_ctx.classes([_ctx.indeterminate, _ctx.n('linear-indeterminate')]))
35
+ }, [_createElementVNode("div", {
36
+ class: _normalizeClass(_ctx.classes(_ctx.n("linear--" + _ctx.type))),
37
+ style: _normalizeStyle({
38
+ background: _ctx.color
39
+ })
40
+ }, null, 6 /* CLASS, STYLE */), _createElementVNode("div", {
41
+ class: _normalizeClass(_ctx.classes(_ctx.n("linear--" + _ctx.type))),
42
+ style: _normalizeStyle({
43
+ background: _ctx.color
44
+ })
45
+ }, null, 6 /* CLASS, STYLE */)], 2 /* CLASS */)) : (_openBlock(), _createElementBlock("div", {
46
+ key: 2,
47
+ class: _normalizeClass(_ctx.classes(_ctx.n('linear-certain'), _ctx.n("linear--" + _ctx.type), [_ctx.ripple, _ctx.n('linear-ripple')])),
35
48
  style: _normalizeStyle({
36
49
  background: _ctx.color,
37
50
  width: _ctx.linearProps.width
38
51
  })
39
- }, null, 6 /* CLASS, STYLE */)], 6 /* CLASS, STYLE */), _ctx.label ? (_openBlock(), _createElementBlock("div", {
52
+ }, null, 6 /* CLASS, STYLE */))], 6 /* CLASS, STYLE */), _ctx.label ? (_openBlock(), _createElementBlock("div", {
40
53
  key: 0,
41
54
  class: _normalizeClass(_ctx.classes(_ctx.n('linear-label'), [_ctx.labelClass, _ctx.labelClass]))
42
55
  }, [_renderSlot(_ctx.$slots, "default", {}, () => [_createTextVNode(_toDisplayString(_ctx.linearProps.roundValue), 1 /* TEXT */)])], 2 /* CLASS */)) : _createCommentVNode("v-if", true)], 2 /* CLASS */)) : _createCommentVNode("v-if", true), _ctx.mode === 'circle' ? (_openBlock(), _createElementBlock("div", {
43
56
  key: 1,
44
- class: _normalizeClass(_ctx.n('circle')),
57
+ class: _normalizeClass(_ctx.classes(_ctx.n('circle'), [_ctx.indeterminate, _ctx.n('circle-indeterminate')])),
45
58
  style: _normalizeStyle({
46
59
  width: _ctx.toSizeUnit(_ctx.size),
47
60
  height: _ctx.toSizeUnit(_ctx.size)
@@ -55,24 +68,25 @@ function __render__(_ctx, _cache) {
55
68
  }, [_ctx.track ? (_openBlock(), _createElementBlock("circle", {
56
69
  key: 0,
57
70
  class: _normalizeClass(_ctx.n('circle-background')),
58
- cx: _ctx.multiplySizeUnit(_ctx.size, 0.5),
59
- cy: _ctx.multiplySizeUnit(_ctx.size, 0.5),
60
- r: _ctx.circleProps.radius,
71
+ cx: "50%",
72
+ cy: "50%",
73
+ r: _ctx.RADIUS,
61
74
  fill: "transparent",
62
- "stroke-width": _ctx.toSizeUnit(_ctx.lineWidth),
75
+ "stroke-width": _ctx.circleProps.strokeWidth,
76
+ "stroke-dasharray": _ctx.CIRCUMFERENCE,
63
77
  style: _normalizeStyle({
64
- strokeDasharray: _ctx.circleProps.perimeter,
65
78
  stroke: _ctx.trackColor
66
79
  })
67
80
  }, null, 14 /* CLASS, STYLE, PROPS */, _hoisted_2)) : _createCommentVNode("v-if", true), _createElementVNode("circle", {
68
- class: _normalizeClass(_ctx.n('circle-certain')),
69
- cx: _ctx.multiplySizeUnit(_ctx.size, 0.5),
70
- cy: _ctx.multiplySizeUnit(_ctx.size, 0.5),
71
- r: _ctx.circleProps.radius,
81
+ class: _normalizeClass(_ctx.classes(_ctx.n('circle-certain'), _ctx.n("circle--" + _ctx.type), [_ctx.indeterminate, _ctx.n('circle-overlay')])),
82
+ cx: "50%",
83
+ cy: "50%",
84
+ r: _ctx.RADIUS,
72
85
  fill: "transparent",
73
- "stroke-width": _ctx.toSizeUnit(_ctx.lineWidth),
86
+ "stroke-width": _ctx.circleProps.strokeWidth,
87
+ "stroke-dasharray": _ctx.CIRCUMFERENCE,
88
+ "stroke-dashoffset": _ctx.circleProps.strokeOffset,
74
89
  style: _normalizeStyle({
75
- strokeDasharray: _ctx.circleProps.strokeDasharray,
76
90
  stroke: _ctx.color
77
91
  })
78
92
  }, null, 14 /* CLASS, STYLE, PROPS */, _hoisted_3)], 14 /* CLASS, STYLE, PROPS */, _hoisted_1)), _ctx.label ? (_openBlock(), _createElementBlock("div", {
@@ -85,6 +99,9 @@ var __sfc__ = defineComponent({
85
99
  name: 'VarProgress',
86
100
  props,
87
101
  setup(props) {
102
+ var ONE_HUNDRED = 100;
103
+ var RADIUS = 20;
104
+ var CIRCUMFERENCE = 2 * Math.PI * RADIUS;
88
105
  var linearProps = computed(() => {
89
106
  var value = toNumber(props.value);
90
107
  var width = value > ONE_HUNDRED ? ONE_HUNDRED : value;
@@ -100,16 +117,15 @@ var __sfc__ = defineComponent({
100
117
  lineWidth,
101
118
  value
102
119
  } = props;
103
- var viewBox = "0 0 " + toPxNum(size) + " " + toPxNum(size);
120
+ var diameter = RADIUS / (1 - toPxNum(lineWidth) / toPxNum(size)) * 2;
121
+ var viewBox = "0 0 " + diameter + " " + diameter;
104
122
  var roundValue = toNumber(value) > ONE_HUNDRED ? ONE_HUNDRED : Math.round(toNumber(value));
105
- var radius = (toPxNum(size) - toPxNum(lineWidth)) / 2;
106
- var perimeter = 2 * Math.PI * radius;
107
- var strokeDasharray = roundValue / ONE_HUNDRED * perimeter + ", " + perimeter;
123
+ var strokeOffset = "" + (ONE_HUNDRED - roundValue) / ONE_HUNDRED * CIRCUMFERENCE;
124
+ var strokeWidth = toPxNum(lineWidth) / toPxNum(size) * diameter;
108
125
  return {
126
+ strokeWidth,
109
127
  viewBox,
110
- radius,
111
- strokeDasharray,
112
- perimeter,
128
+ strokeOffset,
113
129
  roundValue: roundValue + "%"
114
130
  };
115
131
  });
@@ -117,8 +133,9 @@ var __sfc__ = defineComponent({
117
133
  n,
118
134
  classes,
119
135
  toSizeUnit,
120
- multiplySizeUnit,
121
136
  linearProps,
137
+ CIRCUMFERENCE,
138
+ RADIUS,
122
139
  circleProps
123
140
  };
124
141
  }
@@ -1 +1 @@
1
- :root { --progress-font-size: var(--font-size-sm); --progress-ripple-color: #fff; --progress-track-color: #d8d8d8; --progress-label-color: #555; --progress-background: var(--color-primary);}.var-progress { position: relative; font-size: var(--progress-font-size);}.var-progress__linear { display: flex; align-items: center;}.var-progress__linear-block { flex: 1; position: relative; overflow: hidden; height: 4px;}.var-progress__linear-background,.var-progress__linear-certain { width: 100%; height: 100%;}.var-progress__linear-ripple::after { position: absolute; width: 0; background-color: var(--progress-ripple-color); height: 100%; opacity: 0; animation: ripple 1.8s cubic-bezier(0.4, 0, 0.2, 1) infinite; content: '';}.var-progress__linear-background { background-color: var(--progress-track-color);}.var-progress__linear-certain { position: absolute; background-color: var(--progress-background); top: 0; left: 0; transition: all 0.2s, background-color 0.8s;}.var-progress__linear-label { margin-left: 8px; flex: 0; color: var(--progress-label-color);}@keyframes ripple { 0% { width: 0; opacity: 0.1; } 20% { width: 0; opacity: 0.5; } 80% { width: 100%; opacity: 0; }}.var-progress__circle { position: relative; width: 40px; height: 40px;}.var-progress__circle-background { stroke: var(--progress-track-color);}.var-progress__circle-certain { transition: all 0.2s; stroke: var(--progress-background); position: absolute;}.var-progress__circle-label { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); color: var(--progress-label-color);}
1
+ :root { --progress-font-size: var(--font-size-sm); --progress-ripple-color: #fff; --progress-track-color: #d8d8d8; --progress-label-color: #555; --progress-background: var(--color-primary); --progress-default-color: #f5f5f5; --progress-primary-color: var(--color-primary); --progress-danger-color: var(--color-danger); --progress-success-color: var(--color-success); --progress-warning-color: var(--color-warning); --progress-info-color: var(--color-info);}.var-progress { position: relative; font-size: var(--progress-font-size);}.var-progress__linear { display: flex; align-items: center;}.var-progress__linear-block { flex: 1; position: relative; overflow: hidden; height: 4px;}.var-progress__linear-background,.var-progress__linear-certain { width: 100%; height: 100%;}.var-progress__linear-ripple::after { position: absolute; width: 0; background-color: var(--progress-ripple-color); height: 100%; opacity: 0; animation: ripple 1.8s cubic-bezier(0.4, 0, 0.2, 1) infinite; content: '';}.var-progress__linear-background { background-color: var(--progress-track-color);}.var-progress__linear-certain { position: absolute; background-color: var(--progress-background); top: 0; left: 0; transition: all 0.2s, background-color 0.8s;}.var-progress__linear-label { margin-left: 8px; flex: 0; color: var(--progress-label-color);}.var-progress__linear-indeterminate div { bottom: 0; height: inherit; left: 0; position: absolute; right: auto; top: 0; width: auto; will-change: left, right;}.var-progress__linear-indeterminate div:first-child { animation: progress-linear-long 2.2s infinite;}.var-progress__linear-indeterminate div:last-child { animation: progress-linear-short 2.2s infinite;}.var-progress__linear--success { background-color: var(--progress-success-color);}.var-progress__linear--default { background-color: var(--progress-default-color);}.var-progress__linear--primary { background-color: var(--progress-primary-color);}.var-progress__linear--warning { background-color: var(--progress-warning-color);}.var-progress__linear--danger { background-color: var(--progress-danger-color);}.var-progress__linear--info { background-color: var(--progress-info-color);}@keyframes progress-linear-long { 0% { left: -90%; right: 100%; } 60% { left: -90%; right: 100%; } 100% { left: 100%; right: -35%; }}@keyframes progress-linear-short { 0% { left: -200%; right: 100%; } 60% { left: 107%; right: -8%; } 100% { left: 107%; right: -8%; }}@keyframes ripple { 0% { width: 0; opacity: 0.1; } 20% { width: 0; opacity: 0.5; } 80% { width: 100%; opacity: 0; }}.var-progress__circle { position: relative; width: 40px; height: 40px;}.var-progress__circle-background { stroke: var(--progress-track-color); z-index: 1;}.var-progress__circle-certain { transition: all 0.2s; stroke: var(--progress-background); position: absolute;}.var-progress__circle-label { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); color: var(--progress-label-color);}.var-progress__circle--success { stroke: var(--progress-success-color);}.var-progress__circle--default { stroke: var(--progress-default-color);}.var-progress__circle--primary { stroke: var(--progress-primary-color);}.var-progress__circle--warning { stroke: var(--progress-warning-color);}.var-progress__circle--danger { stroke: var(--progress-danger-color);}.var-progress__circle--info { stroke: var(--progress-info-color);}.var-progress__circle-indeterminate svg { animation: progress-circle-rotate 1.4s linear infinite; transform-origin: center center; transition: all 0.2s ease-in-out; width: 100%; height: 100%; position: absolute; top: 0; bottom: 0; left: 0; right: 0; z-index: 0;}.var-progress__circle-overlay { animation: progress-circle-dash 1.4s ease-in-out infinite, progress-circle-rotate 1.4s linear infinite; stroke-dasharray: 25, 200; stroke-dashoffset: 0; stroke-linecap: round; transform-origin: center center; transform: rotate(-90deg); z-index: 2;}@keyframes progress-circle-dash { 0% { stroke-dasharray: 1, 200; stroke-dashoffset: 0; } 50% { stroke-dasharray: 100, 200; stroke-dashoffset: -15px; } 100% { stroke-dasharray: 100, 200; stroke-dashoffset: -124px; }}@keyframes progress-circle-rotate { 100% { transform: rotate(270deg); }}
@@ -1,6 +1,9 @@
1
1
  function modeValidator(mode) {
2
2
  return ['linear', 'circle'].includes(mode);
3
3
  }
4
+ function typeValidator(type) {
5
+ return ['default', 'primary', 'info', 'success', 'warning', 'danger'].includes(type);
6
+ }
4
7
  export var props = {
5
8
  mode: {
6
9
  type: String,
@@ -43,5 +46,14 @@ export var props = {
43
46
  track: {
44
47
  type: Boolean,
45
48
  default: true
49
+ },
50
+ indeterminate: {
51
+ type: Boolean,
52
+ default: false
53
+ },
54
+ type: {
55
+ type: String,
56
+ default: 'primary',
57
+ validator: typeValidator
46
58
  }
47
59
  };
@@ -4,7 +4,7 @@ import VarIcon from '../icon/index.mjs';
4
4
  import { defineComponent, ref, computed, watch, nextTick } from 'vue';
5
5
  import { getParentScroller, getScrollTop, getTarget, getRect } from '../utils/elements.mjs';
6
6
  import { props } from './props.mjs';
7
- import { isString, toNumber } from '@varlet/shared';
7
+ import { isNumber, isString, toNumber } from '@varlet/shared';
8
8
  import { call, createNamespace } from '../utils/components.mjs';
9
9
  import { useEventListener, onSmartMounted } from '@varlet/use';
10
10
  var {
@@ -97,7 +97,7 @@ var __sfc__ = defineComponent({
97
97
  eventTargetScroller = getParentScroller(event.target);
98
98
  };
99
99
  var touchMove = event => {
100
- if (!isTouchable.value) {
100
+ if (!isTouchable.value || !eventTargetScroller) {
101
101
  return;
102
102
  }
103
103
  if (eventTargetScroller !== scroller && getScrollTop(eventTargetScroller) > 0) {
@@ -117,7 +117,7 @@ var __sfc__ = defineComponent({
117
117
  refreshStatus.value = 'pulling';
118
118
  startPosition.value = event.touches[0].clientY;
119
119
  }
120
- if (isReachTop && distance.value > controlPosition.value) {
120
+ if (isReachTop && isNumber(distance.value) && distance.value > controlPosition.value) {
121
121
  lockEvent('add');
122
122
  }
123
123
  var moveDistance = (event.touches[0].clientY - startPosition.value) / 2 + controlPosition.value;
@@ -130,7 +130,7 @@ var __sfc__ = defineComponent({
130
130
  return;
131
131
  }
132
132
  isEnd.value = true;
133
- if (distance.value >= maxDistance.value * 0.2) {
133
+ if (toNumber(distance.value) >= maxDistance.value * 0.2) {
134
134
  yield startIconTransition('refresh');
135
135
  refreshStatus.value = 'loading';
136
136
  distance.value = maxDistance.value * 0.3;
package/es/step/Step.mjs CHANGED
@@ -2,6 +2,7 @@ import { computed, defineComponent } from 'vue';
2
2
  import { props } from './props.mjs';
3
3
  import { useSteps } from './provide.mjs';
4
4
  import VarIcon from '../icon/index.mjs';
5
+ import { toNumber } from '@varlet/shared';
5
6
  import { createNamespace } from '../utils/components.mjs';
6
7
  var {
7
8
  n,
@@ -71,7 +72,7 @@ var __sfc__ = defineComponent({
71
72
  clickStep
72
73
  } = steps;
73
74
  var isCurrent = computed(() => active.value === index.value);
74
- var isActive = computed(() => index.value !== -1 && active.value > index.value);
75
+ var isActive = computed(() => index.value !== -1 && toNumber(active.value) > index.value);
75
76
  var stepProvider = {
76
77
  index
77
78
  };