@varlet/ui 2.5.5 → 2.5.6

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://raw.githubusercontent.com/JetBrains/web-types/master/schema/web-types.json",
3
3
  "framework": "vue",
4
- "version": "2.5.4",
4
+ "version": "2.5.5",
5
5
  "name": "VARLET",
6
6
  "contributions": {
7
7
  "html": {
@@ -1 +1 @@
1
- :root { --action-sheet-border-radius: 2px; --action-sheet-title-color: #888; --action-sheet-title-padding: 10px 16px; --action-sheet-title-font-size: 14px; --action-sheet-action-item-height: 48px; --action-sheet-action-item-padding: 0 18px; --action-sheet-action-item-color: #333; --action-sheet-action-item-disabled-color: var(--color-text-disabled); --action-sheet-icon-margin: 0 20px 0 0; --action-sheet-icon-size: 24px; --action-sheet-background: #fff;}.var-action-sheet { padding: 10px 0; max-height: 80%; background: var(--action-sheet-background); transition: background-color 0.25s;}.var-action-sheet__popup-radius { border-radius: var(--action-sheet-border-radius);}.var-action-sheet__title { padding: var(--action-sheet-title-padding); color: var(--action-sheet-title-color); font-size: var(--action-sheet-title-font-size);}.var-action-sheet__action-item { display: flex; align-items: center; height: var(--action-sheet-action-item-height); padding: var(--action-sheet-action-item-padding); color: var(--action-sheet-action-item-color); cursor: pointer;}.var-action-sheet__action-name { overflow: auto; max-height: var(--action-sheet-action-item-height);}.var-action-sheet__action-icon[var-action-sheet-cover] { margin: var(--action-sheet-icon-margin); width: var(--action-sheet-icon-size); height: var(--action-sheet-icon-size); font-size: var(--action-sheet-icon-size);}.var-action-sheet--disabled { color: var(--action-sheet-action-item-disabled-color) !important; cursor: not-allowed;}
1
+ :root { --action-sheet-border-radius: 2px; --action-sheet-title-color: #888; --action-sheet-title-padding: 10px 16px; --action-sheet-title-font-size: 14px; --action-sheet-action-item-height: 48px; --action-sheet-action-item-padding: 0 18px; --action-sheet-action-item-color: #333; --action-sheet-action-item-disabled-color: var(--color-text-disabled); --action-sheet-icon-margin: 0 20px 0 0; --action-sheet-icon-size: 24px; --action-sheet-background: #fff;}.var-action-sheet { padding: 10px 0; background: var(--action-sheet-background); transition: background-color 0.25s;}.var-action-sheet__popup-radius { border-radius: var(--action-sheet-border-radius);}.var-action-sheet__title { padding: var(--action-sheet-title-padding); color: var(--action-sheet-title-color); font-size: var(--action-sheet-title-font-size);}.var-action-sheet__action-item { display: flex; align-items: center; height: var(--action-sheet-action-item-height); padding: var(--action-sheet-action-item-padding); color: var(--action-sheet-action-item-color); cursor: pointer;}.var-action-sheet__action-name { overflow: auto; max-height: var(--action-sheet-action-item-height);}.var-action-sheet__action-icon[var-action-sheet-cover] { margin: var(--action-sheet-icon-margin); width: var(--action-sheet-icon-size); height: var(--action-sheet-icon-size); font-size: var(--action-sheet-icon-size);}.var-action-sheet--disabled { color: var(--action-sheet-action-item-disabled-color) !important; cursor: not-allowed;}
@@ -273,15 +273,9 @@ var _default = (0, _vue.defineComponent)({
273
273
  current.value = (0, _shared.toNumber)(newCurrent) || 1;
274
274
  size.value = (0, _shared.toNumber)(newSize || 10);
275
275
  });
276
- (0, _vue.watch)([current, size], (_ref2, _ref3) => {
277
- var [newCurrent, newSize] = _ref2;
276
+ (0, _vue.watch)([current, size, pageCount], (_ref2, _ref3) => {
277
+ var [newCurrent, newSize, newCount] = _ref2;
278
278
  var [oldCurrent, oldSize] = _ref3;
279
-
280
- if (newCurrent > pageCount.value) {
281
- current.value = pageCount.value;
282
- return;
283
- }
284
-
285
279
  var list = [];
286
280
  var {
287
281
  maxPagerCount,
@@ -289,11 +283,11 @@ var _default = (0, _vue.defineComponent)({
289
283
  onChange
290
284
  } = props;
291
285
  var oldCount = Math.ceil((0, _shared.toNumber)(total) / (0, _shared.toNumber)(oldSize));
292
- var rEllipseSign = pageCount.value - (maxPagerCount - activePosition.value) - 1;
286
+ var rEllipseSign = newCount - (maxPagerCount - activePosition.value) - 1;
293
287
  simpleValue.value = "" + newCurrent;
294
288
 
295
- if (pageCount.value - 2 > maxPagerCount) {
296
- if (oldCurrent === undefined || pageCount.value !== oldCount) {
289
+ if (newCount - 2 > maxPagerCount) {
290
+ if (oldCurrent === undefined || newCount !== oldCount) {
297
291
  for (var i = 2; i < maxPagerCount + 2; i++) {
298
292
  list.push(i);
299
293
  }
@@ -329,23 +323,23 @@ var _default = (0, _vue.defineComponent)({
329
323
  list = [];
330
324
 
331
325
  for (var _i3 = 1; _i3 < maxPagerCount + 1; _i3++) {
332
- list.push(pageCount.value - (maxPagerCount - _i3) - 1);
326
+ list.push(newCount - (maxPagerCount - _i3) - 1);
333
327
  }
334
328
 
335
329
  isHideEllipsisHead.value = false;
336
330
  isHideEllipsisTail.value = true;
337
331
  }
338
332
 
339
- list = [1, '...', ...list, '...', pageCount.value];
333
+ list = [1, '...', ...list, '...', newCount];
340
334
  } else {
341
- for (var _i4 = 1; _i4 <= pageCount.value; _i4++) {
335
+ for (var _i4 = 1; _i4 <= newCount; _i4++) {
342
336
  list.push(_i4);
343
337
  }
344
338
  }
345
339
 
346
340
  pageList.value = list;
347
341
 
348
- if (oldCurrent !== undefined && pageCount.value > 0) {
342
+ if (oldCurrent !== undefined && newCount > 0) {
349
343
  (0, _components.call)(onChange, newCurrent, newSize);
350
344
  }
351
345
 
@@ -34,8 +34,8 @@ function render(_ctx, _cache) {
34
34
  return (0, _vue.openBlock)(), (0, _vue.createElementBlock)("div", {
35
35
  ref: "freshNode",
36
36
  class: (0, _vue.normalizeClass)(_ctx.n()),
37
- onTouchmove: _cache[0] || (_cache[0] = function () {
38
- return _ctx.touchMove && _ctx.touchMove(...arguments);
37
+ onTouchstart: _cache[0] || (_cache[0] = function () {
38
+ return _ctx.touchStart && _ctx.touchStart(...arguments);
39
39
  }),
40
40
  onTouchend: _cache[1] || (_cache[1] = function () {
41
41
  return _ctx.touchEnd && _ctx.touchEnd(...arguments);
@@ -79,7 +79,9 @@ var _default = (0, _vue.defineComponent)({
79
79
  var distance = (0, _vue.ref)(-999);
80
80
  var iconName = (0, _vue.ref)('arrow-down');
81
81
  var refreshStatus = (0, _vue.ref)('default');
82
- var isEnd = (0, _vue.ref)(false); // https://github.com/varletjs/varlet/issues/509
82
+ var isEnd = (0, _vue.ref)(false);
83
+ var startY = 0;
84
+ var deltaY = 0; // https://github.com/varletjs/varlet/issues/509
83
85
 
84
86
  var iconHasChanged = (0, _vue.ref)(true);
85
87
  var isTouchable = (0, _vue.computed)(() => refreshStatus.value !== 'loading' && refreshStatus.value !== 'success' && !props.disabled);
@@ -106,8 +108,21 @@ var _default = (0, _vue.defineComponent)({
106
108
  el.classList[action](n() + "--lock");
107
109
  };
108
110
 
111
+ var touchStart = event => {
112
+ startY = event.touches[0].clientY;
113
+ deltaY = 0;
114
+ };
115
+
109
116
  var touchMove = event => {
110
117
  var scrollTop = (0, _elements.getScrollTop)(scroller);
118
+ var isReachTop = scrollTop === 0;
119
+ var touch = event.touches[0];
120
+ deltaY = touch.clientY - startY;
121
+
122
+ if (isReachTop && deltaY >= 0) {
123
+ event.preventDefault();
124
+ }
125
+
111
126
  if (scrollTop > 0 || !isTouchable.value) return;
112
127
 
113
128
  if (refreshStatus.value !== 'pulling') {
@@ -115,7 +130,10 @@ var _default = (0, _vue.defineComponent)({
115
130
  startPosition.value = event.touches[0].clientY;
116
131
  }
117
132
 
118
- if (scrollTop === 0 && distance.value > controlPosition.value) lockEvent('add');
133
+ if (isReachTop && distance.value > controlPosition.value) {
134
+ lockEvent('add');
135
+ }
136
+
119
137
  var moveDistance = (event.touches[0].clientY - startPosition.value) / 2 + controlPosition.value;
120
138
  distance.value = moveDistance >= maxDistance.value ? maxDistance.value : moveDistance;
121
139
 
@@ -184,8 +202,18 @@ var _default = (0, _vue.defineComponent)({
184
202
  }
185
203
  });
186
204
  (0, _vue.onMounted)(() => {
205
+ var _freshNode$value;
206
+
187
207
  scroller = props.target ? (0, _elements.getTarget)(props.target, 'PullRefresh') : (0, _elements.getParentScroller)(freshNode.value);
188
208
  setPosition();
209
+ (_freshNode$value = freshNode.value) == null ? void 0 : _freshNode$value.addEventListener('touchmove', touchMove, {
210
+ passive: false
211
+ });
212
+ });
213
+ (0, _vue.onBeforeUnmount)(() => {
214
+ var _freshNode$value2;
215
+
216
+ (_freshNode$value2 = freshNode.value) == null ? void 0 : _freshNode$value2.removeEventListener('touchmove', touchMove);
189
217
  });
190
218
  return {
191
219
  n,
@@ -195,6 +223,7 @@ var _default = (0, _vue.defineComponent)({
195
223
  refreshStatus,
196
224
  freshNode,
197
225
  controlNode,
226
+ touchStart,
198
227
  touchMove,
199
228
  touchEnd,
200
229
  iconName,