@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.
package/LICENCE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 varlet
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -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 {
@@ -1,3 +1,7 @@
1
+ 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); } }
2
+
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
+
1
5
  import VarIcon from '../icon';
2
6
  import { defineComponent, ref, computed, watch, onMounted } from 'vue';
3
7
  import { getParentScroller, getScrollTop } from '../utils/elements';
@@ -10,7 +14,7 @@ var {
10
14
  } = createNamespace('pull-refresh');
11
15
  var MAX_DISTANCE = 100;
12
16
  var CONTROL_POSITION = -50;
13
- var scroller;
17
+ var ICON_TRANSITION = 150;
14
18
  import { resolveComponent as _resolveComponent, normalizeClass as _normalizeClass, createVNode as _createVNode, normalizeStyle as _normalizeStyle, createElementVNode as _createElementVNode, renderSlot as _renderSlot, openBlock as _openBlock, createElementBlock as _createElementBlock } from "vue";
15
19
  export function render(_ctx, _cache) {
16
20
  var _component_var_icon = _resolveComponent("var-icon");
@@ -35,12 +39,12 @@ export function render(_ctx, _cache) {
35
39
  style: _normalizeStyle(_ctx.controlStyle)
36
40
  }, [_createVNode(_component_var_icon, {
37
41
  name: _ctx.iconName,
38
- transition: 200,
39
- class: _normalizeClass(_ctx.classes(_ctx.n('icon'), [_ctx.refreshStatus === 'loading', _ctx.n('animation')])),
42
+ transition: _ctx.ICON_TRANSITION,
43
+ class: _normalizeClass(_ctx.classes(_ctx.n('icon'), [_ctx.refreshStatus === 'loading' && _ctx.iconHasChanged, _ctx.n('animation')])),
40
44
  "var-pull-refresh-cover": ""
41
45
  }, null, 8
42
46
  /* PROPS */
43
- , ["name", "class"])], 6
47
+ , ["name", "transition", "class"])], 6
44
48
  /* CLASS, STYLE */
45
49
  ), _renderSlot(_ctx.$slots, "default")], 34
46
50
  /* CLASS, HYDRATE_EVENTS */
@@ -55,12 +59,16 @@ export default defineComponent({
55
59
  props,
56
60
 
57
61
  setup(props) {
62
+ var scroller;
63
+ var changing;
58
64
  var freshNode = ref(null);
59
65
  var startPosition = ref(0);
60
66
  var distance = ref(CONTROL_POSITION);
61
67
  var iconName = ref('arrow-down');
62
68
  var refreshStatus = ref('default');
63
- var isEnd = ref(false);
69
+ var isEnd = ref(false); // https://github.com/varletjs/varlet/issues/509
70
+
71
+ var iconHasChanged = ref(true);
64
72
  var isTouchable = computed(() => refreshStatus.value !== 'loading' && refreshStatus.value !== 'success' && !props.disabled);
65
73
  var controlStyle = computed(() => ({
66
74
  transform: "translate3d(0px, " + distance.value + "px, 0px) translate(-50%, 0)",
@@ -70,6 +78,15 @@ export default defineComponent({
70
78
  }));
71
79
  var isSuccess = computed(() => refreshStatus.value === 'success');
72
80
 
81
+ var changeIcon = () => {
82
+ return new Promise(resolve => {
83
+ window.setTimeout(() => {
84
+ iconHasChanged.value = true;
85
+ resolve();
86
+ }, ICON_TRANSITION);
87
+ });
88
+ };
89
+
73
90
  var touchStart = event => {
74
91
  if (!isTouchable.value) return;
75
92
  refreshStatus.value = 'pulling';
@@ -82,30 +99,44 @@ export default defineComponent({
82
99
  if (scrollTop === 0 && distance.value > CONTROL_POSITION) event.cancelable && event.preventDefault();
83
100
  var moveDistance = (event.touches[0].clientY - startPosition.value) / 2 + CONTROL_POSITION;
84
101
  distance.value = moveDistance >= MAX_DISTANCE ? MAX_DISTANCE : moveDistance;
85
- iconName.value = distance.value >= MAX_DISTANCE * 0.2 ? 'refresh' : 'arrow-down';
86
- };
87
-
88
- var touchEnd = () => {
89
- if (!isTouchable.value) return;
90
- isEnd.value = true;
91
102
 
92
103
  if (distance.value >= MAX_DISTANCE * 0.2) {
93
- var _props$onUpdateModel;
94
-
95
- refreshStatus.value = 'loading';
96
- distance.value = MAX_DISTANCE * 0.3;
97
- (_props$onUpdateModel = props['onUpdate:modelValue']) == null ? void 0 : _props$onUpdateModel.call(props, true);
98
- props.onRefresh == null ? void 0 : props.onRefresh();
104
+ iconHasChanged.value = false;
105
+ iconName.value = 'refresh';
106
+ changing = changeIcon();
99
107
  } else {
100
- refreshStatus.value = 'loosing';
101
108
  iconName.value = 'arrow-down';
102
- distance.value = CONTROL_POSITION;
103
- setTimeout(() => {
104
- isEnd.value = false;
105
- }, toNumber(props.animationDuration));
106
109
  }
107
110
  };
108
111
 
112
+ var touchEnd = /*#__PURE__*/function () {
113
+ var _ref = _asyncToGenerator(function* () {
114
+ if (!isTouchable.value) return;
115
+ isEnd.value = true;
116
+
117
+ if (distance.value >= MAX_DISTANCE * 0.2) {
118
+ var _props$onUpdateModel;
119
+
120
+ yield changing;
121
+ refreshStatus.value = 'loading';
122
+ distance.value = MAX_DISTANCE * 0.3;
123
+ (_props$onUpdateModel = props['onUpdate:modelValue']) == null ? void 0 : _props$onUpdateModel.call(props, true);
124
+ props.onRefresh == null ? void 0 : props.onRefresh();
125
+ } else {
126
+ refreshStatus.value = 'loosing';
127
+ iconName.value = 'arrow-down';
128
+ distance.value = CONTROL_POSITION;
129
+ setTimeout(() => {
130
+ isEnd.value = false;
131
+ }, toNumber(props.animationDuration));
132
+ }
133
+ });
134
+
135
+ return function touchEnd() {
136
+ return _ref.apply(this, arguments);
137
+ };
138
+ }();
139
+
109
140
  var reset = () => {
110
141
  setTimeout(() => {
111
142
  refreshStatus.value = 'default';
@@ -131,6 +162,8 @@ export default defineComponent({
131
162
  return {
132
163
  n,
133
164
  classes,
165
+ iconHasChanged,
166
+ ICON_TRANSITION,
134
167
  refreshStatus,
135
168
  freshNode,
136
169
  touchStart,
@@ -1,8 +1,8 @@
1
1
  import '../../styles/common.css'
2
+ import '../SnackbarSfc.css'
2
3
  import '../../styles/elevation.css'
3
4
  import '../../loading/loading.css'
4
5
  import '../../button/button.css'
5
6
  import '../../icon/icon.css'
6
7
  import '../snackbar.css'
7
8
  import '../coreSfc.css'
8
- import '../SnackbarSfc.css'
@@ -1,8 +1,8 @@
1
1
  import '../../styles/common.less'
2
+ import '../SnackbarSfc.less'
2
3
  import '../../styles/elevation.less'
3
4
  import '../../loading/loading.less'
4
5
  import '../../button/button.less'
5
6
  import '../../icon/icon.less'
6
7
  import '../snackbar.less'
7
8
  import '../coreSfc.less'
8
- import '../SnackbarSfc.less'