@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 +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;}
@@ -254,15 +254,9 @@ export default defineComponent({
254
254
  current.value = toNumber(newCurrent) || 1;
255
255
  size.value = toNumber(newSize || 10);
256
256
  });
257
- watch([current, size], (_ref2, _ref3) => {
258
- var [newCurrent, newSize] = _ref2;
257
+ watch([current, size, pageCount], (_ref2, _ref3) => {
258
+ var [newCurrent, newSize, newCount] = _ref2;
259
259
  var [oldCurrent, oldSize] = _ref3;
260
-
261
- if (newCurrent > pageCount.value) {
262
- current.value = pageCount.value;
263
- return;
264
- }
265
-
266
260
  var list = [];
267
261
  var {
268
262
  maxPagerCount,
@@ -270,11 +264,11 @@ export default defineComponent({
270
264
  onChange
271
265
  } = props;
272
266
  var oldCount = Math.ceil(toNumber(total) / toNumber(oldSize));
273
- var rEllipseSign = pageCount.value - (maxPagerCount - activePosition.value) - 1;
267
+ var rEllipseSign = newCount - (maxPagerCount - activePosition.value) - 1;
274
268
  simpleValue.value = "" + newCurrent;
275
269
 
276
- if (pageCount.value - 2 > maxPagerCount) {
277
- if (oldCurrent === undefined || pageCount.value !== oldCount) {
270
+ if (newCount - 2 > maxPagerCount) {
271
+ if (oldCurrent === undefined || newCount !== oldCount) {
278
272
  for (var i = 2; i < maxPagerCount + 2; i++) {
279
273
  list.push(i);
280
274
  }
@@ -310,23 +304,23 @@ export default defineComponent({
310
304
  list = [];
311
305
 
312
306
  for (var _i3 = 1; _i3 < maxPagerCount + 1; _i3++) {
313
- list.push(pageCount.value - (maxPagerCount - _i3) - 1);
307
+ list.push(newCount - (maxPagerCount - _i3) - 1);
314
308
  }
315
309
 
316
310
  isHideEllipsisHead.value = false;
317
311
  isHideEllipsisTail.value = true;
318
312
  }
319
313
 
320
- list = [1, '...', ...list, '...', pageCount.value];
314
+ list = [1, '...', ...list, '...', newCount];
321
315
  } else {
322
- for (var _i4 = 1; _i4 <= pageCount.value; _i4++) {
316
+ for (var _i4 = 1; _i4 <= newCount; _i4++) {
323
317
  list.push(_i4);
324
318
  }
325
319
  }
326
320
 
327
321
  pageList.value = list;
328
322
 
329
- if (oldCurrent !== undefined && pageCount.value > 0) {
323
+ if (oldCurrent !== undefined && newCount > 0) {
330
324
  call(onChange, newCurrent, newSize);
331
325
  }
332
326
 
@@ -3,7 +3,7 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
3
3
  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); }); }; }
4
4
 
5
5
  import VarIcon from '../icon';
6
- import { defineComponent, ref, computed, watch, onMounted } from 'vue';
6
+ import { defineComponent, ref, computed, watch, onMounted, onBeforeUnmount } from 'vue';
7
7
  import { getParentScroller, getScrollTop, getTarget } from '../utils/elements';
8
8
  import { props } from './props';
9
9
  import { toNumber } from '@varlet/shared';
@@ -20,8 +20,8 @@ export function render(_ctx, _cache) {
20
20
  return _openBlock(), _createElementBlock("div", {
21
21
  ref: "freshNode",
22
22
  class: _normalizeClass(_ctx.n()),
23
- onTouchmove: _cache[0] || (_cache[0] = function () {
24
- return _ctx.touchMove && _ctx.touchMove(...arguments);
23
+ onTouchstart: _cache[0] || (_cache[0] = function () {
24
+ return _ctx.touchStart && _ctx.touchStart(...arguments);
25
25
  }),
26
26
  onTouchend: _cache[1] || (_cache[1] = function () {
27
27
  return _ctx.touchEnd && _ctx.touchEnd(...arguments);
@@ -64,7 +64,9 @@ export default defineComponent({
64
64
  var distance = ref(-999);
65
65
  var iconName = ref('arrow-down');
66
66
  var refreshStatus = ref('default');
67
- var isEnd = ref(false); // https://github.com/varletjs/varlet/issues/509
67
+ var isEnd = ref(false);
68
+ var startY = 0;
69
+ var deltaY = 0; // https://github.com/varletjs/varlet/issues/509
68
70
 
69
71
  var iconHasChanged = ref(true);
70
72
  var isTouchable = computed(() => refreshStatus.value !== 'loading' && refreshStatus.value !== 'success' && !props.disabled);
@@ -91,8 +93,21 @@ export default defineComponent({
91
93
  el.classList[action](n() + "--lock");
92
94
  };
93
95
 
96
+ var touchStart = event => {
97
+ startY = event.touches[0].clientY;
98
+ deltaY = 0;
99
+ };
100
+
94
101
  var touchMove = event => {
95
102
  var scrollTop = getScrollTop(scroller);
103
+ var isReachTop = scrollTop === 0;
104
+ var touch = event.touches[0];
105
+ deltaY = touch.clientY - startY;
106
+
107
+ if (isReachTop && deltaY >= 0) {
108
+ event.preventDefault();
109
+ }
110
+
96
111
  if (scrollTop > 0 || !isTouchable.value) return;
97
112
 
98
113
  if (refreshStatus.value !== 'pulling') {
@@ -100,7 +115,10 @@ export default defineComponent({
100
115
  startPosition.value = event.touches[0].clientY;
101
116
  }
102
117
 
103
- if (scrollTop === 0 && distance.value > controlPosition.value) lockEvent('add');
118
+ if (isReachTop && distance.value > controlPosition.value) {
119
+ lockEvent('add');
120
+ }
121
+
104
122
  var moveDistance = (event.touches[0].clientY - startPosition.value) / 2 + controlPosition.value;
105
123
  distance.value = moveDistance >= maxDistance.value ? maxDistance.value : moveDistance;
106
124
 
@@ -169,8 +187,18 @@ export default defineComponent({
169
187
  }
170
188
  });
171
189
  onMounted(() => {
190
+ var _freshNode$value;
191
+
172
192
  scroller = props.target ? getTarget(props.target, 'PullRefresh') : getParentScroller(freshNode.value);
173
193
  setPosition();
194
+ (_freshNode$value = freshNode.value) == null ? void 0 : _freshNode$value.addEventListener('touchmove', touchMove, {
195
+ passive: false
196
+ });
197
+ });
198
+ onBeforeUnmount(() => {
199
+ var _freshNode$value2;
200
+
201
+ (_freshNode$value2 = freshNode.value) == null ? void 0 : _freshNode$value2.removeEventListener('touchmove', touchMove);
174
202
  });
175
203
  return {
176
204
  n,
@@ -180,6 +208,7 @@ export default defineComponent({
180
208
  refreshStatus,
181
209
  freshNode,
182
210
  controlNode,
211
+ touchStart,
183
212
  touchMove,
184
213
  touchEnd,
185
214
  iconName,