@varlet/ui 1.24.11 → 1.25.0-alpha.1642582155449
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/es/app-bar/AppBar.js +25 -4
- package/es/button/Button.js +19 -7
- package/es/button/props.js +4 -0
- package/es/date-picker/DatePicker.js +39 -22
- package/es/date-picker/src/day-picker-panel.js +6 -2
- package/es/date-picker/src/month-picker-panel.js +4 -4
- package/es/snackbar/style/index.js +1 -1
- package/es/snackbar/style/less.js +1 -1
- package/es/swipe/Swipe.js +9 -3
- package/es/utils/shared.js +1 -0
- package/highlight/attributes.json +56 -52
- package/highlight/tags.json +1 -0
- package/highlight/web-types.json +72 -63
- package/lib/app-bar/AppBar.js +24 -3
- package/lib/button/Button.js +18 -6
- package/lib/button/props.js +4 -0
- package/lib/date-picker/DatePicker.js +39 -22
- package/lib/date-picker/src/day-picker-panel.js +6 -2
- package/lib/date-picker/src/month-picker-panel.js +4 -4
- package/lib/swipe/Swipe.js +8 -2
- package/lib/utils/shared.js +5 -1
- package/package.json +4 -4
- package/types/button.d.ts +1 -0
- package/umd/varlet.js +3 -3
package/es/app-bar/AppBar.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent } from 'vue';
|
|
1
|
+
import { defineComponent, ref, onMounted, onUpdated } from 'vue';
|
|
2
2
|
import { props } from './props';
|
|
3
3
|
import { renderSlot as _renderSlot, toDisplayString as _toDisplayString, createTextVNode as _createTextVNode, normalizeStyle as _normalizeStyle, openBlock as _openBlock, createElementBlock as _createElementBlock, createCommentVNode as _createCommentVNode, createElementVNode as _createElementVNode, normalizeClass as _normalizeClass, pushScopeId as _pushScopeId, popScopeId as _popScopeId } from "vue";
|
|
4
4
|
|
|
@@ -27,7 +27,7 @@ export function render(_ctx, _cache) {
|
|
|
27
27
|
key: 0,
|
|
28
28
|
class: "var-app-bar__title",
|
|
29
29
|
style: _normalizeStyle({
|
|
30
|
-
paddingLeft: _ctx
|
|
30
|
+
paddingLeft: _ctx.paddingLeft
|
|
31
31
|
})
|
|
32
32
|
}, [_renderSlot(_ctx.$slots, "default", {}, () => [_createTextVNode(_toDisplayString(_ctx.title), 1
|
|
33
33
|
/* TEXT */
|
|
@@ -39,7 +39,7 @@ export function render(_ctx, _cache) {
|
|
|
39
39
|
key: 0,
|
|
40
40
|
class: "var-app-bar__title",
|
|
41
41
|
style: _normalizeStyle({
|
|
42
|
-
paddingRight: _ctx
|
|
42
|
+
paddingRight: _ctx.paddingRight
|
|
43
43
|
})
|
|
44
44
|
}, [_renderSlot(_ctx.$slots, "default", {}, () => [_createTextVNode(_toDisplayString(_ctx.title), 1
|
|
45
45
|
/* TEXT */
|
|
@@ -52,5 +52,26 @@ export function render(_ctx, _cache) {
|
|
|
52
52
|
export default defineComponent({
|
|
53
53
|
render,
|
|
54
54
|
name: 'VarAppBar',
|
|
55
|
-
props
|
|
55
|
+
props,
|
|
56
|
+
|
|
57
|
+
setup(props, _ref) {
|
|
58
|
+
var {
|
|
59
|
+
slots
|
|
60
|
+
} = _ref;
|
|
61
|
+
var paddingLeft = ref();
|
|
62
|
+
var paddingRight = ref();
|
|
63
|
+
|
|
64
|
+
var computePadding = () => {
|
|
65
|
+
paddingLeft.value = slots.left ? 0 : undefined;
|
|
66
|
+
paddingRight.value = slots.right ? 0 : undefined;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
onMounted(computePadding);
|
|
70
|
+
onUpdated(computePadding);
|
|
71
|
+
return {
|
|
72
|
+
paddingLeft,
|
|
73
|
+
paddingRight
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
56
77
|
});
|
package/es/button/Button.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Ripple from '../ripple';
|
|
2
2
|
import VarLoading from '../loading';
|
|
3
|
-
import { defineComponent } from 'vue';
|
|
3
|
+
import { defineComponent, ref } from 'vue';
|
|
4
4
|
import { props } from './props';
|
|
5
5
|
import { resolveComponent as _resolveComponent, openBlock as _openBlock, createBlock as _createBlock, createCommentVNode as _createCommentVNode, renderSlot as _renderSlot, normalizeClass as _normalizeClass, createElementVNode as _createElementVNode, normalizeStyle as _normalizeStyle, resolveDirective as _resolveDirective, withDirectives as _withDirectives, createElementBlock as _createElementBlock, pushScopeId as _pushScopeId, popScopeId as _popScopeId } from "vue";
|
|
6
6
|
|
|
@@ -25,7 +25,7 @@ export function render(_ctx, _cache) {
|
|
|
25
25
|
onTouchstart: _cache[1] || (_cache[1] = function () {
|
|
26
26
|
return _ctx.handleTouchstart && _ctx.handleTouchstart(...arguments);
|
|
27
27
|
})
|
|
28
|
-
}, [_ctx.loading ? (_openBlock(), _createBlock(_component_var_loading, {
|
|
28
|
+
}, [_ctx.loading || _ctx.pending ? (_openBlock(), _createBlock(_component_var_loading, {
|
|
29
29
|
key: 0,
|
|
30
30
|
class: "var-button__loading",
|
|
31
31
|
"var-button-cover": "",
|
|
@@ -35,7 +35,7 @@ export function render(_ctx, _cache) {
|
|
|
35
35
|
}, null, 8
|
|
36
36
|
/* PROPS */
|
|
37
37
|
, ["type", "size", "radius"])) : _createCommentVNode("v-if", true), _createElementVNode("div", {
|
|
38
|
-
class: _normalizeClass(["var-button__content", [_ctx.loading ? 'var-button--hidden' : null]])
|
|
38
|
+
class: _normalizeClass(["var-button__content", [_ctx.loading || _ctx.pending ? 'var-button--hidden' : null]])
|
|
39
39
|
}, [_renderSlot(_ctx.$slots, "default")], 2
|
|
40
40
|
/* CLASS */
|
|
41
41
|
)], 46
|
|
@@ -56,6 +56,17 @@ export default defineComponent({
|
|
|
56
56
|
props,
|
|
57
57
|
|
|
58
58
|
setup(props) {
|
|
59
|
+
var pending = ref(false);
|
|
60
|
+
|
|
61
|
+
var attemptAutoLoading = result => {
|
|
62
|
+
if (props.autoLoading) {
|
|
63
|
+
pending.value = true;
|
|
64
|
+
Promise.resolve(result).finally(() => {
|
|
65
|
+
pending.value = false;
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
59
70
|
var handleClick = e => {
|
|
60
71
|
var {
|
|
61
72
|
loading,
|
|
@@ -63,11 +74,11 @@ export default defineComponent({
|
|
|
63
74
|
onClick
|
|
64
75
|
} = props;
|
|
65
76
|
|
|
66
|
-
if (loading || disabled) {
|
|
77
|
+
if (!onClick || loading || disabled || pending.value) {
|
|
67
78
|
return;
|
|
68
79
|
}
|
|
69
80
|
|
|
70
|
-
onClick
|
|
81
|
+
attemptAutoLoading(onClick(e));
|
|
71
82
|
};
|
|
72
83
|
|
|
73
84
|
var handleTouchstart = e => {
|
|
@@ -77,14 +88,15 @@ export default defineComponent({
|
|
|
77
88
|
onTouchstart
|
|
78
89
|
} = props;
|
|
79
90
|
|
|
80
|
-
if (loading || disabled) {
|
|
91
|
+
if (!onTouchstart || loading || disabled || pending.value) {
|
|
81
92
|
return;
|
|
82
93
|
}
|
|
83
94
|
|
|
84
|
-
onTouchstart
|
|
95
|
+
attemptAutoLoading(onTouchstart(e));
|
|
85
96
|
};
|
|
86
97
|
|
|
87
98
|
return {
|
|
99
|
+
pending,
|
|
88
100
|
handleClick,
|
|
89
101
|
handleTouchstart
|
|
90
102
|
};
|
package/es/button/props.js
CHANGED
|
@@ -46,7 +46,7 @@ export function render(_ctx, _cache) {
|
|
|
46
46
|
var _ctx$chooseMonth, _ctx$chooseMonth2, _ctx$chooseMonth3;
|
|
47
47
|
|
|
48
48
|
return [_ctx.type === 'month' ? (_openBlock(), _createElementBlock("div", {
|
|
49
|
-
key: _ctx.chooseYear + ((_ctx$chooseMonth = _ctx.chooseMonth) == null ? void 0 : _ctx$chooseMonth.index)
|
|
49
|
+
key: "" + _ctx.chooseYear + ((_ctx$chooseMonth = _ctx.chooseMonth) == null ? void 0 : _ctx$chooseMonth.index)
|
|
50
50
|
}, [_ctx.range ? _renderSlot(_ctx.$slots, "range", {
|
|
51
51
|
key: 0,
|
|
52
52
|
choose: _ctx.getChoose.chooseRangeMonth
|
|
@@ -64,7 +64,7 @@ export function render(_ctx, _cache) {
|
|
|
64
64
|
}, () => [_createTextVNode(_toDisplayString(_ctx.getMonthTitle), 1
|
|
65
65
|
/* TEXT */
|
|
66
66
|
)])])) : (_openBlock(), _createElementBlock("div", {
|
|
67
|
-
key: _ctx.chooseYear + ((_ctx$chooseMonth3 = _ctx.chooseMonth) == null ? void 0 : _ctx$chooseMonth3.index) + _ctx.chooseDay
|
|
67
|
+
key: "" + _ctx.chooseYear + ((_ctx$chooseMonth3 = _ctx.chooseMonth) == null ? void 0 : _ctx$chooseMonth3.index) + _ctx.chooseDay
|
|
68
68
|
}, [_ctx.range ? _renderSlot(_ctx.$slots, "range", {
|
|
69
69
|
key: 0,
|
|
70
70
|
choose: _ctx.formatRange
|
|
@@ -142,21 +142,21 @@ export default defineComponent({
|
|
|
142
142
|
|
|
143
143
|
setup(props) {
|
|
144
144
|
var currentDate = dayjs().format('YYYY-MM-D');
|
|
145
|
-
var [currentYear, currentMonth
|
|
145
|
+
var [currentYear, currentMonth] = currentDate.split('-');
|
|
146
146
|
var monthDes = MONTH_LIST.find(month => month.index === currentMonth);
|
|
147
147
|
var isYearPanel = ref(false);
|
|
148
148
|
var isMonthPanel = ref(false);
|
|
149
149
|
var rangeDone = ref(true);
|
|
150
|
-
var chooseMonth = ref(
|
|
151
|
-
var chooseYear = ref(
|
|
152
|
-
var chooseDay = ref(
|
|
150
|
+
var chooseMonth = ref();
|
|
151
|
+
var chooseYear = ref();
|
|
152
|
+
var chooseDay = ref();
|
|
153
153
|
var previewMonth = ref(monthDes);
|
|
154
154
|
var previewYear = ref(currentYear);
|
|
155
155
|
var reverse = ref(false);
|
|
156
|
-
var chooseMonths = ref([
|
|
157
|
-
var chooseDays = ref([
|
|
158
|
-
var chooseRangeMonth = ref([
|
|
159
|
-
var chooseRangeDay = ref([
|
|
156
|
+
var chooseMonths = ref([]);
|
|
157
|
+
var chooseDays = ref([]);
|
|
158
|
+
var chooseRangeMonth = ref([]);
|
|
159
|
+
var chooseRangeDay = ref([]);
|
|
160
160
|
var componentProps = reactive({
|
|
161
161
|
allowedDates: props.allowedDates,
|
|
162
162
|
type: props.type,
|
|
@@ -182,14 +182,23 @@ export default defineComponent({
|
|
|
182
182
|
previewYear: previewYear.value
|
|
183
183
|
}));
|
|
184
184
|
var getMonthTitle = computed(() => {
|
|
185
|
-
var _pack$value$datePicke, _pack$value$datePicke2;
|
|
186
|
-
|
|
187
185
|
var {
|
|
188
186
|
multiple,
|
|
189
187
|
range
|
|
190
188
|
} = props;
|
|
191
|
-
|
|
192
|
-
|
|
189
|
+
|
|
190
|
+
if (range) {
|
|
191
|
+
return chooseRangeMonth.value.length ? chooseRangeMonth.value[0] + " ~ " + chooseRangeMonth.value[1] : '';
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
var monthName = '';
|
|
195
|
+
|
|
196
|
+
if (chooseMonth.value) {
|
|
197
|
+
var _pack$value$datePicke, _pack$value$datePicke2;
|
|
198
|
+
|
|
199
|
+
monthName = (_pack$value$datePicke = (_pack$value$datePicke2 = pack.value.datePickerMonthDict) == null ? void 0 : _pack$value$datePicke2[chooseMonth.value.index].name) != null ? _pack$value$datePicke : '';
|
|
200
|
+
}
|
|
201
|
+
|
|
193
202
|
return multiple ? "" + chooseMonths.value.length + pack.value.datePickerSelected : monthName;
|
|
194
203
|
});
|
|
195
204
|
var getDateTitle = computed(() => {
|
|
@@ -202,10 +211,11 @@ export default defineComponent({
|
|
|
202
211
|
|
|
203
212
|
if (range) {
|
|
204
213
|
var formatRangeDays = chooseRangeDay.value.map(date => dayjs(date).format('YYYY-MM-DD'));
|
|
205
|
-
return formatRangeDays[0] + " ~ " + formatRangeDays[1];
|
|
214
|
+
return formatRangeDays.length ? formatRangeDays[0] + " ~ " + formatRangeDays[1] : '';
|
|
206
215
|
}
|
|
207
216
|
|
|
208
217
|
if (multiple) return "" + chooseDays.value.length + pack.value.datePickerSelected;
|
|
218
|
+
if (!chooseYear.value || !chooseMonth.value || !chooseDay.value) return '';
|
|
209
219
|
var weekIndex = dayjs(chooseYear.value + "-" + chooseMonth.value.index + "-" + chooseDay.value).day();
|
|
210
220
|
var week = WEEK_HEADER.find(value => value.index === "" + weekIndex);
|
|
211
221
|
var weekName = (_pack$value$datePicke3 = (_pack$value$datePicke4 = pack.value.datePickerWeekDict) == null ? void 0 : _pack$value$datePicke4[week.index].name) != null ? _pack$value$datePicke3 : '';
|
|
@@ -215,17 +225,23 @@ export default defineComponent({
|
|
|
215
225
|
return weekName.slice(0, 3) + ", " + monthName.slice(0, 3) + " " + chooseDay.value;
|
|
216
226
|
});
|
|
217
227
|
var slotProps = computed(() => {
|
|
218
|
-
var
|
|
228
|
+
var _chooseMonth$value, _chooseYear$value, _chooseMonth$value$in, _chooseMonth$value2, _chooseDay$value;
|
|
229
|
+
|
|
230
|
+
var weekIndex = dayjs(chooseYear.value + "-" + ((_chooseMonth$value = chooseMonth.value) == null ? void 0 : _chooseMonth$value.index) + "-" + chooseDay.value).day();
|
|
219
231
|
return {
|
|
220
232
|
week: "" + weekIndex,
|
|
221
|
-
year: chooseYear.value,
|
|
222
|
-
month: chooseMonth.value.index,
|
|
223
|
-
date: chooseDay.value
|
|
233
|
+
year: (_chooseYear$value = chooseYear.value) != null ? _chooseYear$value : '',
|
|
234
|
+
month: (_chooseMonth$value$in = (_chooseMonth$value2 = chooseMonth.value) == null ? void 0 : _chooseMonth$value2.index) != null ? _chooseMonth$value$in : '',
|
|
235
|
+
date: (_chooseDay$value = chooseDay.value) != null ? _chooseDay$value : ''
|
|
224
236
|
};
|
|
225
237
|
});
|
|
226
238
|
var formatRange = computed(() => getChoose.value.chooseRangeDay.map(choose => dayjs(choose).format('YYYY-MM-DD')));
|
|
227
239
|
var isSameYear = computed(() => chooseYear.value === previewYear.value);
|
|
228
|
-
var isSameMonth = computed(() =>
|
|
240
|
+
var isSameMonth = computed(() => {
|
|
241
|
+
var _chooseMonth$value3;
|
|
242
|
+
|
|
243
|
+
return ((_chooseMonth$value3 = chooseMonth.value) == null ? void 0 : _chooseMonth$value3.index) === previewMonth.value.index;
|
|
244
|
+
});
|
|
229
245
|
|
|
230
246
|
var clickEl = type => {
|
|
231
247
|
if (type === 'year') isYearPanel.value = true;else if (type === 'month') isMonthPanel.value = true;else {
|
|
@@ -264,6 +280,7 @@ export default defineComponent({
|
|
|
264
280
|
};
|
|
265
281
|
|
|
266
282
|
var getReverse = (dateType, date) => {
|
|
283
|
+
if (!chooseYear.value || !chooseMonth.value) return false;
|
|
267
284
|
if (!isSameYear.value) return chooseYear.value > previewYear.value;
|
|
268
285
|
if (dateType === 'month') return date.index < chooseMonth.value.index;
|
|
269
286
|
return isSameMonth.value ? date < toNumber(chooseDay.value) : chooseMonth.value.index > previewMonth.value.index;
|
|
@@ -356,7 +373,7 @@ export default defineComponent({
|
|
|
356
373
|
var invalidFormatDate = date => {
|
|
357
374
|
if (isArray(date)) return false;
|
|
358
375
|
|
|
359
|
-
if (date ===
|
|
376
|
+
if (date === 'Invalid Date') {
|
|
360
377
|
console.error('[Varlet] DatePicker: "modelValue" is an Invalid Date');
|
|
361
378
|
return true;
|
|
362
379
|
}
|
|
@@ -399,7 +416,7 @@ export default defineComponent({
|
|
|
399
416
|
};
|
|
400
417
|
|
|
401
418
|
watch(() => props.modelValue, value => {
|
|
402
|
-
if (!checkValue() || invalidFormatDate(value)) return;
|
|
419
|
+
if (!checkValue() || invalidFormatDate(value) || !value) return;
|
|
403
420
|
|
|
404
421
|
if (props.range) {
|
|
405
422
|
if (!isArray(value)) return;
|
|
@@ -130,7 +130,11 @@ export default defineComponent({
|
|
|
130
130
|
right: false
|
|
131
131
|
});
|
|
132
132
|
var isCurrent = computed(() => props.preview.previewYear === currentYear && props.preview.previewMonth.index === currentMonth);
|
|
133
|
-
var isSame = computed(() =>
|
|
133
|
+
var isSame = computed(() => {
|
|
134
|
+
var _props$choose$chooseM;
|
|
135
|
+
|
|
136
|
+
return props.choose.chooseYear === props.preview.previewYear && ((_props$choose$chooseM = props.choose.chooseMonth) == null ? void 0 : _props$choose$chooseM.index) === props.preview.previewMonth.index;
|
|
137
|
+
});
|
|
134
138
|
var sortWeekList = computed(() => {
|
|
135
139
|
var index = WEEK_HEADER.findIndex(week => week.index === props.componentProps.firstDayOfWeek);
|
|
136
140
|
if (index === -1 || index === 0) return WEEK_HEADER;
|
|
@@ -211,9 +215,9 @@ export default defineComponent({
|
|
|
211
215
|
range
|
|
212
216
|
}
|
|
213
217
|
} = props;
|
|
214
|
-
if (!chooseRangeDay.length) return false;
|
|
215
218
|
|
|
216
219
|
if (range) {
|
|
220
|
+
if (!chooseRangeDay.length) return false;
|
|
217
221
|
var isBeforeMax = dayjs(val).isSameOrBefore(dayjs(chooseRangeDay[1]), 'day');
|
|
218
222
|
var isAfterMin = dayjs(val).isSameOrAfter(dayjs(chooseRangeDay[0]), 'day');
|
|
219
223
|
return isBeforeMax && isAfterMin;
|
|
@@ -150,9 +150,9 @@ export default defineComponent({
|
|
|
150
150
|
range
|
|
151
151
|
}
|
|
152
152
|
} = props;
|
|
153
|
-
if (!chooseRangeMonth.length) return false;
|
|
154
153
|
|
|
155
154
|
if (range) {
|
|
155
|
+
if (!chooseRangeMonth.length) return false;
|
|
156
156
|
var isBeforeMax = dayjs(val).isSameOrBefore(dayjs(chooseRangeMonth[1]), 'month');
|
|
157
157
|
var isAfterMin = dayjs(val).isSameOrAfter(dayjs(chooseRangeMonth[0]), 'month');
|
|
158
158
|
return isBeforeMax && isAfterMin;
|
|
@@ -181,7 +181,7 @@ export default defineComponent({
|
|
|
181
181
|
|
|
182
182
|
var monthExist = () => {
|
|
183
183
|
if (range || multiple) return shouldChoose(val);
|
|
184
|
-
return chooseMonth.index === key && isSameYear.value;
|
|
184
|
+
return (chooseMonth == null ? void 0 : chooseMonth.index) === key && isSameYear.value;
|
|
185
185
|
};
|
|
186
186
|
|
|
187
187
|
var computeDisabled = () => {
|
|
@@ -195,7 +195,7 @@ export default defineComponent({
|
|
|
195
195
|
var computeText = () => {
|
|
196
196
|
if (disabled) return true;
|
|
197
197
|
if (range || multiple) return !shouldChoose(val);
|
|
198
|
-
return !isSameYear.value || chooseMonth.index !== key;
|
|
198
|
+
return !isSameYear.value || (chooseMonth == null ? void 0 : chooseMonth.index) !== key;
|
|
199
199
|
};
|
|
200
200
|
|
|
201
201
|
var computeOutline = () => {
|
|
@@ -206,7 +206,7 @@ export default defineComponent({
|
|
|
206
206
|
|
|
207
207
|
if (range || multiple) return !shouldChoose(val); // 同一年但是未被选择的情况
|
|
208
208
|
|
|
209
|
-
if (isSameYear.value) return chooseMonth.index !== currentMonth;
|
|
209
|
+
if (isSameYear.value) return (chooseMonth == null ? void 0 : chooseMonth.index) !== currentMonth;
|
|
210
210
|
return true;
|
|
211
211
|
};
|
|
212
212
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import '../../styles/common.css'
|
|
2
|
-
import '../SnackbarSfc.css'
|
|
3
2
|
import '../../styles/elevation.css'
|
|
4
3
|
import '../../loading/loading.css'
|
|
5
4
|
import '../../button/button.css'
|
|
6
5
|
import '../../icon/icon.css'
|
|
7
6
|
import '../snackbar.css'
|
|
8
7
|
import '../coreSfc.css'
|
|
8
|
+
import '../SnackbarSfc.css'
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import '../../styles/common.less'
|
|
2
|
-
import '../SnackbarSfc.less'
|
|
3
2
|
import '../../styles/elevation.less'
|
|
4
3
|
import '../../loading/loading.less'
|
|
5
4
|
import '../../button/button.less'
|
|
6
5
|
import '../../icon/icon.less'
|
|
7
6
|
import '../snackbar.less'
|
|
8
7
|
import '../coreSfc.less'
|
|
8
|
+
import '../SnackbarSfc.less'
|
package/es/swipe/Swipe.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
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 { defineComponent, ref, computed, watch, onMounted, onUnmounted } from 'vue';
|
|
2
6
|
import { useSwipeItems } from './provide';
|
|
3
|
-
import { nextTickFrame } from '../utils/elements';
|
|
7
|
+
import { doubleRaf, nextTickFrame } from '../utils/elements';
|
|
4
8
|
import { props } from './props';
|
|
5
9
|
import { isNumber, toNumber } from '../utils/shared';
|
|
6
10
|
var SWIPE_DELAY = 250;
|
|
@@ -376,10 +380,12 @@ export default defineComponent({
|
|
|
376
380
|
vertical
|
|
377
381
|
};
|
|
378
382
|
bindSwipeItems(swipeProvider);
|
|
379
|
-
watch(() => length.value, ()
|
|
383
|
+
watch(() => length.value, /*#__PURE__*/_asyncToGenerator(function* () {
|
|
384
|
+
// In nuxt, the size of the swipe cannot got when the route is change, need double raf
|
|
385
|
+
yield doubleRaf();
|
|
380
386
|
initialIndex();
|
|
381
387
|
resize();
|
|
382
|
-
});
|
|
388
|
+
}));
|
|
383
389
|
onMounted(() => {
|
|
384
390
|
window.addEventListener('resize', resize);
|
|
385
391
|
});
|
package/es/utils/shared.js
CHANGED
|
@@ -29,6 +29,7 @@ export var isBool = val => typeof val === 'boolean';
|
|
|
29
29
|
export var isNumber = val => typeof val === 'number';
|
|
30
30
|
export var isPlainObject = val => Object.prototype.toString.call(val) === '[object Object]';
|
|
31
31
|
export var isArray = val => Array.isArray(val);
|
|
32
|
+
export var isPromise = val => val instanceof Promise;
|
|
32
33
|
export var isURL = val => {
|
|
33
34
|
if (!val) {
|
|
34
35
|
return false;
|