@varlet/ui 2.5.5-alpha.1672917688708 → 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;}
@@ -1 +1 @@
1
- :root { --back-top-right: 40px; --back-top-bottom: 40px; --back-top-button-size: 40px;}.var-back-top { position: fixed; right: var(--back-top-right); bottom: var(--back-top-bottom); transform: scale(0); transition: 0.3s var(--cubic-bezier); -webkit-tap-highlight-color: rgba(0, 0, 0, 0);}.var-back-top .var-button[var-back-top-cover] { width: var(--back-top-button-size); height: var(--back-top-button-size);}.var-back-top--active { transform: scale(1);}
1
+ :root { --back-top-right: 40px; --back-top-bottom: 40px; --back-top-button-size: 40px;}.var-back-top { position: fixed; z-index: 100; right: var(--back-top-right); bottom: var(--back-top-bottom); transform: scale(0); transition: 0.3s var(--cubic-bezier); -webkit-tap-highlight-color: rgba(0, 0, 0, 0);}.var-back-top .var-button[var-back-top-cover] { width: var(--back-top-button-size); height: var(--back-top-button-size);}.var-back-top--active { transform: scale(1);}
package/es/form/Form.js CHANGED
@@ -57,7 +57,7 @@ export default defineComponent({
57
57
  }));
58
58
 
59
59
  if (props.scrollToError) {
60
- var [_, errorIndex] = find(res, r => r === false, props.scrollToError);
60
+ var [, errorIndex] = find(res, r => r === false, props.scrollToError);
61
61
  var hasError = errorIndex > -1;
62
62
 
63
63
  if (hasError) {
@@ -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';
@@ -23,13 +23,10 @@ export function render(_ctx, _cache) {
23
23
  onTouchstart: _cache[0] || (_cache[0] = function () {
24
24
  return _ctx.touchStart && _ctx.touchStart(...arguments);
25
25
  }),
26
- onTouchmove: _cache[1] || (_cache[1] = function () {
27
- return _ctx.touchMove && _ctx.touchMove(...arguments);
28
- }),
29
- onTouchend: _cache[2] || (_cache[2] = function () {
26
+ onTouchend: _cache[1] || (_cache[1] = function () {
30
27
  return _ctx.touchEnd && _ctx.touchEnd(...arguments);
31
28
  }),
32
- onTouchcancel: _cache[3] || (_cache[3] = function () {
29
+ onTouchcancel: _cache[2] || (_cache[2] = function () {
33
30
  return _ctx.touchEnd && _ctx.touchEnd(...arguments);
34
31
  })
35
32
  }, [_createElementVNode("div", {
@@ -67,7 +64,9 @@ export default defineComponent({
67
64
  var distance = ref(-999);
68
65
  var iconName = ref('arrow-down');
69
66
  var refreshStatus = ref('default');
70
- 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
71
70
 
72
71
  var iconHasChanged = ref(true);
73
72
  var isTouchable = computed(() => refreshStatus.value !== 'loading' && refreshStatus.value !== 'success' && !props.disabled);
@@ -89,16 +88,37 @@ export default defineComponent({
89
88
  });
90
89
  };
91
90
 
91
+ var lockEvent = action => {
92
+ var el = 'classList' in scroller ? scroller : document.body;
93
+ el.classList[action](n() + "--lock");
94
+ };
95
+
92
96
  var touchStart = event => {
93
- if (!isTouchable.value) return;
94
- refreshStatus.value = 'pulling';
95
- startPosition.value = event.touches[0].clientY;
97
+ startY = event.touches[0].clientY;
98
+ deltaY = 0;
96
99
  };
97
100
 
98
101
  var touchMove = event => {
99
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
+
100
111
  if (scrollTop > 0 || !isTouchable.value) return;
101
- if (scrollTop === 0 && distance.value > controlPosition.value) event.cancelable && event.preventDefault();
112
+
113
+ if (refreshStatus.value !== 'pulling') {
114
+ refreshStatus.value = 'pulling';
115
+ startPosition.value = event.touches[0].clientY;
116
+ }
117
+
118
+ if (isReachTop && distance.value > controlPosition.value) {
119
+ lockEvent('add');
120
+ }
121
+
102
122
  var moveDistance = (event.touches[0].clientY - startPosition.value) / 2 + controlPosition.value;
103
123
  distance.value = moveDistance >= maxDistance.value ? maxDistance.value : moveDistance;
104
124
 
@@ -122,12 +142,14 @@ export default defineComponent({
122
142
  distance.value = maxDistance.value * 0.3;
123
143
  call(props['onUpdate:modelValue'], true);
124
144
  call(props.onRefresh);
145
+ lockEvent('remove');
125
146
  } else {
126
147
  refreshStatus.value = 'loosing';
127
148
  iconName.value = 'arrow-down';
128
149
  distance.value = controlPosition.value;
129
150
  setTimeout(() => {
130
151
  isEnd.value = false;
152
+ lockEvent('remove');
131
153
  }, toNumber(props.animationDuration));
132
154
  }
133
155
  });
@@ -165,8 +187,18 @@ export default defineComponent({
165
187
  }
166
188
  });
167
189
  onMounted(() => {
190
+ var _freshNode$value;
191
+
168
192
  scroller = props.target ? getTarget(props.target, 'PullRefresh') : getParentScroller(freshNode.value);
169
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);
170
202
  });
171
203
  return {
172
204
  n,
@@ -1 +1 @@
1
- :root { --pull-refresh-size: 40px; --pull-refresh-background: #fff; --pull-refresh-color: var(--color-primary); --pull-refresh-success-color: var(--color-success); --pull-refresh-icon-size: 25px;}.var-pull-refresh { overflow: hidden; position: relative; user-select: none; width: 100%;}.var-pull-refresh__control { display: flex; width: var(--pull-refresh-size); height: var(--pull-refresh-size); align-items: center; justify-content: center; background-color: var(--pull-refresh-background); border-radius: 50%; position: absolute; left: 50%; z-index: 90; color: var(--pull-refresh-color);}.var-pull-refresh__control-success { color: var(--pull-refresh-success-color);}.var-pull-refresh__icon[var-pull-refresh-cover] { font-size: var(--pull-refresh-icon-size);}.var-pull-refresh__animation { transform: rotate(0deg); animation: iconRotate 0.6s infinite linear;}@keyframes iconRotate { from { transform: rotate(0deg); } to { transform: rotate(360deg); }}
1
+ :root { --pull-refresh-size: 40px; --pull-refresh-background: #fff; --pull-refresh-color: var(--color-primary); --pull-refresh-success-color: var(--color-success); --pull-refresh-icon-size: 25px;}.var-pull-refresh { overflow: hidden; position: relative; user-select: none; width: 100%;}.var-pull-refresh__control { display: flex; width: var(--pull-refresh-size); height: var(--pull-refresh-size); align-items: center; justify-content: center; background-color: var(--pull-refresh-background); border-radius: 50%; position: absolute; left: 50%; z-index: 90; color: var(--pull-refresh-color);}.var-pull-refresh__control-success { color: var(--pull-refresh-success-color);}.var-pull-refresh__icon[var-pull-refresh-cover] { font-size: var(--pull-refresh-icon-size);}.var-pull-refresh__animation { transform: rotate(0deg); animation: iconRotate 0.6s infinite linear;}.var-pull-refresh--lock { overflow: hidden !important;}@keyframes iconRotate { from { transform: rotate(0deg); } to { transform: rotate(360deg); }}