@varlet/ui 1.27.6 → 1.27.7-alpha.1650880107793

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.
@@ -69,11 +69,11 @@
69
69
  },
70
70
  "var-back-top/bottom": {
71
71
  "type": "string | number",
72
- "description": "`BackTop` 距离页面底部的高度 默认值:40"
72
+ "description": "`BackTop` 距离页面底部的距离 默认值:40"
73
73
  },
74
74
  "var-back-top/right": {
75
75
  "type": "string | number",
76
- "description": "`BackTop` 距离页面右侧的宽度 默认值:40"
76
+ "description": "`BackTop` 距离页面右侧的距离 默认值:40"
77
77
  },
78
78
  "var-back-top/duration": {
79
79
  "type": "number",
@@ -225,7 +225,7 @@
225
225
  },
226
226
  {
227
227
  "name": "bottom",
228
- "description": "`BackTop` 距离页面底部的高度",
228
+ "description": "`BackTop` 距离页面底部的距离",
229
229
  "default": "40",
230
230
  "value": {
231
231
  "type": "string | number",
@@ -234,7 +234,7 @@
234
234
  },
235
235
  {
236
236
  "name": "right",
237
- "description": "`BackTop` 距离页面右侧的宽度",
237
+ "description": "`BackTop` 距离页面右侧的距离",
238
238
  "default": "40",
239
239
  "value": {
240
240
  "type": "string | number",
@@ -1 +1 @@
1
- :root { --counter-padding: 0 4px; --counter-font-color: #fff; --counter-background: var(--color-primary); --counter-input-width: 28px; --counter-input-margin: 0 4px; --counter-input-font-size: 14px; --counter-button-size: 28px; --counter-button-icon-size: 100%; --counter-disabled-color: var(--color-text-disabled); --input-error-color: var(--color-danger);}.var-counter { display: inline-flex; flex-direction: column; align-items: flex-start;}.var-counter__controller { display: flex; align-items: center; color: var(--counter-font-color); border-radius: var(--counter-button-size); padding: var(--counter-padding); background: var(--counter-background); transition: background-color 0.25s;}.var-counter__decrement-button[var-counter-cover] { width: var(--counter-button-size); height: var(--counter-button-size); font-size: var(--counter-button-icon-size); border-radius: 50%; cursor: pointer; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);}.var-counter__input { width: var(--counter-input-width); font-size: var(--counter-input-font-size); outline: none; border: none; background: transparent; padding: 0; text-align: center; color: var(--counter-font-color); margin: var(--counter-input-margin);}.var-counter__input[disabled] { background: transparent;}.var-counter__increment-button[var-counter-cover] { width: var(--counter-button-size); height: var(--counter-button-size); font-size: var(--counter-button-icon-size); border-radius: 50%; cursor: pointer; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);}.var-counter--disabled { background: var(--counter-disabled-color);}.var-counter--hidden { opacity: 0;}.var-counter--error { background: var(--color-danger);}
1
+ :root { --counter-padding: 0 4px; --counter-font-color: #fff; --counter-background: var(--color-primary); --counter-input-width: 28px; --counter-input-margin: 0 4px; --counter-input-font-size: 14px; --counter-button-size: 28px; --counter-button-icon-size: 100%; --counter-disabled-color: var(--color-text-disabled); --input-error-color: var(--color-danger);}.var-counter { display: inline-flex; flex-direction: column; align-items: flex-start;}.var-counter__controller { display: flex; align-items: center; color: var(--counter-font-color); border-radius: var(--counter-button-size); padding: var(--counter-padding); background: var(--counter-background); transition: background-color 0.25s;}.var-counter__decrement-button[var-counter-cover] { width: var(--counter-button-size); height: var(--counter-button-size); font-size: var(--counter-button-icon-size); border-radius: 50%; cursor: pointer; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); -webkit-user-select: none; user-select: none;}.var-counter__input { width: var(--counter-input-width); font-size: var(--counter-input-font-size); outline: none; border: none; background: transparent; padding: 0; text-align: center; color: var(--counter-font-color); margin: var(--counter-input-margin);}.var-counter__input[disabled] { background: transparent;}.var-counter__increment-button[var-counter-cover] { width: var(--counter-button-size); height: var(--counter-button-size); font-size: var(--counter-button-icon-size); border-radius: 50%; cursor: pointer; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); -webkit-user-select: none; user-select: none;}.var-counter--disabled { background: var(--counter-disabled-color);}.var-counter--hidden { opacity: 0;}.var-counter--error { background: var(--color-danger);}
@@ -44,6 +44,8 @@
44
44
  border-radius: 50%;
45
45
  cursor: pointer;
46
46
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
47
+ -webkit-user-select: none; // for safari
48
+ user-select: none;
47
49
  }
48
50
 
49
51
  &__input {
@@ -69,6 +71,8 @@
69
71
  border-radius: 50%;
70
72
  cursor: pointer;
71
73
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
74
+ -webkit-user-select: none; // for safari
75
+ user-select: none;
72
76
  }
73
77
 
74
78
  &--disabled {
@@ -18,13 +18,17 @@ var _components = require("../utils/components");
18
18
 
19
19
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
20
 
21
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
22
+
23
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
24
+
21
25
  var {
22
26
  n,
23
27
  classes
24
28
  } = (0, _components.createNamespace)('pull-refresh');
25
29
  var MAX_DISTANCE = 100;
26
30
  var CONTROL_POSITION = -50;
27
- var scroller;
31
+ var ICON_TRANSITION = 150;
28
32
 
29
33
  function render(_ctx, _cache) {
30
34
  var _component_var_icon = (0, _vue.resolveComponent)("var-icon");
@@ -49,12 +53,12 @@ function render(_ctx, _cache) {
49
53
  style: (0, _vue.normalizeStyle)(_ctx.controlStyle)
50
54
  }, [(0, _vue.createVNode)(_component_var_icon, {
51
55
  name: _ctx.iconName,
52
- transition: 200,
53
- class: (0, _vue.normalizeClass)(_ctx.classes(_ctx.n('icon'), [_ctx.refreshStatus === 'loading', _ctx.n('animation')])),
56
+ transition: _ctx.ICON_TRANSITION,
57
+ class: (0, _vue.normalizeClass)(_ctx.classes(_ctx.n('icon'), [_ctx.refreshStatus === 'loading' && _ctx.iconHasChanged, _ctx.n('animation')])),
54
58
  "var-pull-refresh-cover": ""
55
59
  }, null, 8
56
60
  /* PROPS */
57
- , ["name", "class"])], 6
61
+ , ["name", "transition", "class"])], 6
58
62
  /* CLASS, STYLE */
59
63
  ), (0, _vue.renderSlot)(_ctx.$slots, "default")], 34
60
64
  /* CLASS, HYDRATE_EVENTS */
@@ -70,12 +74,16 @@ var _default = (0, _vue.defineComponent)({
70
74
  props: _props.props,
71
75
 
72
76
  setup(props) {
77
+ var scroller;
78
+ var changing;
73
79
  var freshNode = (0, _vue.ref)(null);
74
80
  var startPosition = (0, _vue.ref)(0);
75
81
  var distance = (0, _vue.ref)(CONTROL_POSITION);
76
82
  var iconName = (0, _vue.ref)('arrow-down');
77
83
  var refreshStatus = (0, _vue.ref)('default');
78
- var isEnd = (0, _vue.ref)(false);
84
+ var isEnd = (0, _vue.ref)(false); // https://github.com/varletjs/varlet/issues/509
85
+
86
+ var iconHasChanged = (0, _vue.ref)(true);
79
87
  var isTouchable = (0, _vue.computed)(() => refreshStatus.value !== 'loading' && refreshStatus.value !== 'success' && !props.disabled);
80
88
  var controlStyle = (0, _vue.computed)(() => ({
81
89
  transform: "translate3d(0px, " + distance.value + "px, 0px) translate(-50%, 0)",
@@ -85,6 +93,15 @@ var _default = (0, _vue.defineComponent)({
85
93
  }));
86
94
  var isSuccess = (0, _vue.computed)(() => refreshStatus.value === 'success');
87
95
 
96
+ var changeIcon = () => {
97
+ return new Promise(resolve => {
98
+ window.setTimeout(() => {
99
+ iconHasChanged.value = true;
100
+ resolve();
101
+ }, ICON_TRANSITION);
102
+ });
103
+ };
104
+
88
105
  var touchStart = event => {
89
106
  if (!isTouchable.value) return;
90
107
  refreshStatus.value = 'pulling';
@@ -97,30 +114,44 @@ var _default = (0, _vue.defineComponent)({
97
114
  if (scrollTop === 0 && distance.value > CONTROL_POSITION) event.cancelable && event.preventDefault();
98
115
  var moveDistance = (event.touches[0].clientY - startPosition.value) / 2 + CONTROL_POSITION;
99
116
  distance.value = moveDistance >= MAX_DISTANCE ? MAX_DISTANCE : moveDistance;
100
- iconName.value = distance.value >= MAX_DISTANCE * 0.2 ? 'refresh' : 'arrow-down';
101
- };
102
-
103
- var touchEnd = () => {
104
- if (!isTouchable.value) return;
105
- isEnd.value = true;
106
117
 
107
118
  if (distance.value >= MAX_DISTANCE * 0.2) {
108
- var _props$onUpdateModel;
109
-
110
- refreshStatus.value = 'loading';
111
- distance.value = MAX_DISTANCE * 0.3;
112
- (_props$onUpdateModel = props['onUpdate:modelValue']) == null ? void 0 : _props$onUpdateModel.call(props, true);
113
- props.onRefresh == null ? void 0 : props.onRefresh();
119
+ iconHasChanged.value = false;
120
+ iconName.value = 'refresh';
121
+ changing = changeIcon();
114
122
  } else {
115
- refreshStatus.value = 'loosing';
116
123
  iconName.value = 'arrow-down';
117
- distance.value = CONTROL_POSITION;
118
- setTimeout(() => {
119
- isEnd.value = false;
120
- }, (0, _shared.toNumber)(props.animationDuration));
121
124
  }
122
125
  };
123
126
 
127
+ var touchEnd = /*#__PURE__*/function () {
128
+ var _ref = _asyncToGenerator(function* () {
129
+ if (!isTouchable.value) return;
130
+ isEnd.value = true;
131
+
132
+ if (distance.value >= MAX_DISTANCE * 0.2) {
133
+ var _props$onUpdateModel;
134
+
135
+ yield changing;
136
+ refreshStatus.value = 'loading';
137
+ distance.value = MAX_DISTANCE * 0.3;
138
+ (_props$onUpdateModel = props['onUpdate:modelValue']) == null ? void 0 : _props$onUpdateModel.call(props, true);
139
+ props.onRefresh == null ? void 0 : props.onRefresh();
140
+ } else {
141
+ refreshStatus.value = 'loosing';
142
+ iconName.value = 'arrow-down';
143
+ distance.value = CONTROL_POSITION;
144
+ setTimeout(() => {
145
+ isEnd.value = false;
146
+ }, (0, _shared.toNumber)(props.animationDuration));
147
+ }
148
+ });
149
+
150
+ return function touchEnd() {
151
+ return _ref.apply(this, arguments);
152
+ };
153
+ }();
154
+
124
155
  var reset = () => {
125
156
  setTimeout(() => {
126
157
  refreshStatus.value = 'default';
@@ -146,6 +177,8 @@ var _default = (0, _vue.defineComponent)({
146
177
  return {
147
178
  n,
148
179
  classes,
180
+ iconHasChanged,
181
+ ICON_TRANSITION,
149
182
  refreshStatus,
150
183
  freshNode,
151
184
  touchStart,