@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,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;}
@@ -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/lib/form/Form.js CHANGED
@@ -71,7 +71,7 @@ var _default = (0, _vue.defineComponent)({
71
71
  }));
72
72
 
73
73
  if (props.scrollToError) {
74
- var [_, errorIndex] = (0, _shared.find)(res, r => r === false, props.scrollToError);
74
+ var [, errorIndex] = (0, _shared.find)(res, r => r === false, props.scrollToError);
75
75
  var hasError = errorIndex > -1;
76
76
 
77
77
  if (hasError) {
@@ -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
 
@@ -37,13 +37,10 @@ function render(_ctx, _cache) {
37
37
  onTouchstart: _cache[0] || (_cache[0] = function () {
38
38
  return _ctx.touchStart && _ctx.touchStart(...arguments);
39
39
  }),
40
- onTouchmove: _cache[1] || (_cache[1] = function () {
41
- return _ctx.touchMove && _ctx.touchMove(...arguments);
42
- }),
43
- onTouchend: _cache[2] || (_cache[2] = function () {
40
+ onTouchend: _cache[1] || (_cache[1] = function () {
44
41
  return _ctx.touchEnd && _ctx.touchEnd(...arguments);
45
42
  }),
46
- onTouchcancel: _cache[3] || (_cache[3] = function () {
43
+ onTouchcancel: _cache[2] || (_cache[2] = function () {
47
44
  return _ctx.touchEnd && _ctx.touchEnd(...arguments);
48
45
  })
49
46
  }, [(0, _vue.createElementVNode)("div", {
@@ -82,7 +79,9 @@ var _default = (0, _vue.defineComponent)({
82
79
  var distance = (0, _vue.ref)(-999);
83
80
  var iconName = (0, _vue.ref)('arrow-down');
84
81
  var refreshStatus = (0, _vue.ref)('default');
85
- 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
86
85
 
87
86
  var iconHasChanged = (0, _vue.ref)(true);
88
87
  var isTouchable = (0, _vue.computed)(() => refreshStatus.value !== 'loading' && refreshStatus.value !== 'success' && !props.disabled);
@@ -104,16 +103,37 @@ var _default = (0, _vue.defineComponent)({
104
103
  });
105
104
  };
106
105
 
106
+ var lockEvent = action => {
107
+ var el = 'classList' in scroller ? scroller : document.body;
108
+ el.classList[action](n() + "--lock");
109
+ };
110
+
107
111
  var touchStart = event => {
108
- if (!isTouchable.value) return;
109
- refreshStatus.value = 'pulling';
110
- startPosition.value = event.touches[0].clientY;
112
+ startY = event.touches[0].clientY;
113
+ deltaY = 0;
111
114
  };
112
115
 
113
116
  var touchMove = event => {
114
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
+
115
126
  if (scrollTop > 0 || !isTouchable.value) return;
116
- if (scrollTop === 0 && distance.value > controlPosition.value) event.cancelable && event.preventDefault();
127
+
128
+ if (refreshStatus.value !== 'pulling') {
129
+ refreshStatus.value = 'pulling';
130
+ startPosition.value = event.touches[0].clientY;
131
+ }
132
+
133
+ if (isReachTop && distance.value > controlPosition.value) {
134
+ lockEvent('add');
135
+ }
136
+
117
137
  var moveDistance = (event.touches[0].clientY - startPosition.value) / 2 + controlPosition.value;
118
138
  distance.value = moveDistance >= maxDistance.value ? maxDistance.value : moveDistance;
119
139
 
@@ -137,12 +157,14 @@ var _default = (0, _vue.defineComponent)({
137
157
  distance.value = maxDistance.value * 0.3;
138
158
  (0, _components.call)(props['onUpdate:modelValue'], true);
139
159
  (0, _components.call)(props.onRefresh);
160
+ lockEvent('remove');
140
161
  } else {
141
162
  refreshStatus.value = 'loosing';
142
163
  iconName.value = 'arrow-down';
143
164
  distance.value = controlPosition.value;
144
165
  setTimeout(() => {
145
166
  isEnd.value = false;
167
+ lockEvent('remove');
146
168
  }, (0, _shared.toNumber)(props.animationDuration));
147
169
  }
148
170
  });
@@ -180,8 +202,18 @@ var _default = (0, _vue.defineComponent)({
180
202
  }
181
203
  });
182
204
  (0, _vue.onMounted)(() => {
205
+ var _freshNode$value;
206
+
183
207
  scroller = props.target ? (0, _elements.getTarget)(props.target, 'PullRefresh') : (0, _elements.getParentScroller)(freshNode.value);
184
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);
185
217
  });
186
218
  return {
187
219
  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); }}