@varlet/ui 2.11.1-alpha.1684493331817 → 2.11.2-alpha.1684942134064
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/image-preview/ImagePreview.mjs +60 -15
- package/es/image-preview/imagePreview.css +1 -1
- package/es/image-preview/props.mjs +6 -1
- package/es/index.bundle.mjs +1 -1
- package/es/index.mjs +1 -1
- package/es/picker/Picker.mjs +18 -12
- package/es/progress/Progress.mjs +5 -4
- package/es/snackbar/style/index.mjs +1 -1
- package/es/style.css +1 -1
- package/es/tab-item/TabItem.mjs +11 -6
- package/es/tabs-items/TabsItems.mjs +12 -9
- package/es/utils/components.mjs +3 -1
- package/es/varlet.esm.js +7087 -7048
- package/highlight/web-types.en-US.json +14 -1
- package/highlight/web-types.zh-CN.json +14 -1
- package/lib/style.css +1 -1
- package/lib/varlet.cjs.js +116 -59
- package/package.json +6 -6
- package/types/imagePreview.d.ts +4 -0
- package/umd/varlet.js +5 -5
|
@@ -5,6 +5,7 @@ import VarPopup from '../popup/index.mjs';
|
|
|
5
5
|
import { defineComponent, ref, computed, watch } from 'vue';
|
|
6
6
|
import { props } from './props.mjs';
|
|
7
7
|
import { toNumber } from '@varlet/shared';
|
|
8
|
+
import { useEventListener } from '@varlet/use';
|
|
8
9
|
import { call, createNamespace } from '../utils/components.mjs';
|
|
9
10
|
var {
|
|
10
11
|
n,
|
|
@@ -14,11 +15,13 @@ var DISTANCE_OFFSET = 12;
|
|
|
14
15
|
var EVENT_DELAY = 200;
|
|
15
16
|
var TAP_DELAY = 350;
|
|
16
17
|
var ANIMATION_DURATION = 200;
|
|
18
|
+
var LONG_PRESS_DELAY = 500;
|
|
17
19
|
import { renderList as _renderList, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock, normalizeClass as _normalizeClass, createElementVNode as _createElementVNode, normalizeStyle as _normalizeStyle, resolveComponent as _resolveComponent, withCtx as _withCtx, createBlock as _createBlock, renderSlot as _renderSlot, toDisplayString as _toDisplayString, createCommentVNode as _createCommentVNode, mergeProps as _mergeProps, createVNode as _createVNode, pushScopeId as _pushScopeId, popScopeId as _popScopeId } from "vue";
|
|
18
20
|
|
|
19
21
|
var _withScopeId = n => (_pushScopeId(""), n = n(), _popScopeId(), n);
|
|
20
22
|
|
|
21
|
-
var _hoisted_1 = ["
|
|
23
|
+
var _hoisted_1 = ["onTouchstart"];
|
|
24
|
+
var _hoisted_2 = ["src", "alt"];
|
|
22
25
|
|
|
23
26
|
function __render__(_ctx, _cache) {
|
|
24
27
|
var _component_var_swipe_item = _resolveComponent("var-swipe-item");
|
|
@@ -53,7 +56,7 @@ function __render__(_ctx, _cache) {
|
|
|
53
56
|
loop: _ctx.loop,
|
|
54
57
|
onChange: _ctx.onChange
|
|
55
58
|
}, _ctx.$attrs), {
|
|
56
|
-
default: _withCtx(() => [(_openBlock(true), _createElementBlock(_Fragment, null, _renderList(_ctx.images, image => {
|
|
59
|
+
default: _withCtx(() => [(_openBlock(true), _createElementBlock(_Fragment, null, _renderList(_ctx.images, (image, idx) => {
|
|
57
60
|
return _openBlock(), _createBlock(_component_var_swipe_item, {
|
|
58
61
|
class: _normalizeClass(_ctx.n('swipe-item')),
|
|
59
62
|
"var-image-preview-cover": "",
|
|
@@ -66,24 +69,25 @@ function __render__(_ctx, _cache) {
|
|
|
66
69
|
transitionTimingFunction: _ctx.transitionTimingFunction,
|
|
67
70
|
transitionDuration: _ctx.transitionDuration
|
|
68
71
|
}),
|
|
69
|
-
onTouchstart:
|
|
70
|
-
|
|
71
|
-
}),
|
|
72
|
-
onTouchmove: _cache[1] || (_cache[1] = function () {
|
|
72
|
+
onTouchstart: $event => _ctx.handleTouchstart($event, idx),
|
|
73
|
+
onTouchmove: _cache[0] || (_cache[0] = function () {
|
|
73
74
|
return _ctx.handleTouchmove && _ctx.handleTouchmove(...arguments);
|
|
74
75
|
}),
|
|
75
|
-
onTouchend: _cache[
|
|
76
|
+
onTouchend: _cache[1] || (_cache[1] = function () {
|
|
76
77
|
return _ctx.handleTouchend && _ctx.handleTouchend(...arguments);
|
|
78
|
+
}),
|
|
79
|
+
onTouchcancel: _cache[2] || (_cache[2] = function () {
|
|
80
|
+
return _ctx.handleTouchcancel && _ctx.handleTouchcancel(...arguments);
|
|
77
81
|
})
|
|
78
82
|
}, [_createElementVNode("img", {
|
|
79
|
-
class: _normalizeClass(_ctx.n('image')),
|
|
83
|
+
class: _normalizeClass(_ctx.classes(_ctx.n('image'), [_ctx.isPreventDefault, _ctx.n('--prevent')])),
|
|
80
84
|
src: image,
|
|
81
85
|
alt: image
|
|
82
86
|
}, null, 10
|
|
83
87
|
/* CLASS, PROPS */
|
|
84
|
-
,
|
|
85
|
-
/* CLASS, STYLE, HYDRATE_EVENTS */
|
|
86
|
-
)]),
|
|
88
|
+
, _hoisted_2)], 46
|
|
89
|
+
/* CLASS, STYLE, PROPS, HYDRATE_EVENTS */
|
|
90
|
+
, _hoisted_1)]),
|
|
87
91
|
_: 2
|
|
88
92
|
/* DYNAMIC */
|
|
89
93
|
|
|
@@ -164,6 +168,15 @@ var __sfc__ = defineComponent({
|
|
|
164
168
|
var startTouch = null;
|
|
165
169
|
var prevTouch = null;
|
|
166
170
|
var closeRunner = null;
|
|
171
|
+
var longPressRunner = null;
|
|
172
|
+
var isLongPress = false;
|
|
173
|
+
var isPreventDefault = computed(() => {
|
|
174
|
+
var {
|
|
175
|
+
imagePreventDefault,
|
|
176
|
+
show
|
|
177
|
+
} = props;
|
|
178
|
+
return show && imagePreventDefault;
|
|
179
|
+
});
|
|
167
180
|
|
|
168
181
|
var getDistance = (touch, target) => {
|
|
169
182
|
var {
|
|
@@ -220,7 +233,20 @@ var __sfc__ = defineComponent({
|
|
|
220
233
|
return getDistance(startTouch, prevTouch) <= DISTANCE_OFFSET && performance.now() - prevTouch.timestamp < TAP_DELAY && (target === startTouch.target || target.parentNode === startTouch.target);
|
|
221
234
|
};
|
|
222
235
|
|
|
236
|
+
var handleTouchcancel = () => {
|
|
237
|
+
window.clearTimeout(longPressRunner);
|
|
238
|
+
isLongPress = false;
|
|
239
|
+
startTouch = null;
|
|
240
|
+
};
|
|
241
|
+
|
|
223
242
|
var handleTouchend = event => {
|
|
243
|
+
window.clearTimeout(longPressRunner); // avoid triggering tap event sometimes
|
|
244
|
+
|
|
245
|
+
if (isLongPress) {
|
|
246
|
+
isLongPress = false;
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
|
|
224
250
|
var isTap = isTapTouch(event.target);
|
|
225
251
|
closeRunner = window.setTimeout(() => {
|
|
226
252
|
isTap && close();
|
|
@@ -228,10 +254,18 @@ var __sfc__ = defineComponent({
|
|
|
228
254
|
}, EVENT_DELAY);
|
|
229
255
|
};
|
|
230
256
|
|
|
231
|
-
var handleTouchstart = event => {
|
|
232
|
-
|
|
257
|
+
var handleTouchstart = (event, idx) => {
|
|
258
|
+
window.clearTimeout(closeRunner);
|
|
259
|
+
window.clearTimeout(longPressRunner);
|
|
233
260
|
var currentTouch = createVarTouch(event.touches[0], event.currentTarget);
|
|
234
261
|
startTouch = currentTouch;
|
|
262
|
+
longPressRunner = window.setTimeout(() => {
|
|
263
|
+
var {
|
|
264
|
+
onLongPress
|
|
265
|
+
} = props;
|
|
266
|
+
isLongPress = true;
|
|
267
|
+
call(onLongPress, idx);
|
|
268
|
+
}, LONG_PRESS_DELAY);
|
|
235
269
|
|
|
236
270
|
if (isDoubleTouch(currentTouch)) {
|
|
237
271
|
scale.value > 1 ? zoomOut() : zoomIn();
|
|
@@ -313,6 +347,10 @@ var __sfc__ = defineComponent({
|
|
|
313
347
|
var target = event.currentTarget;
|
|
314
348
|
var currentTouch = createVarTouch(event.touches[0], target);
|
|
315
349
|
|
|
350
|
+
if (getDistance(currentTouch, prevTouch) > DISTANCE_OFFSET) {
|
|
351
|
+
window.clearTimeout(longPressRunner);
|
|
352
|
+
}
|
|
353
|
+
|
|
316
354
|
if (scale.value > 1) {
|
|
317
355
|
var moveX = currentTouch.clientX - prevTouch.clientX;
|
|
318
356
|
var moveY = currentTouch.clientY - prevTouch.clientY;
|
|
@@ -335,14 +373,20 @@ var __sfc__ = defineComponent({
|
|
|
335
373
|
call(props['onUpdate:show'], false);
|
|
336
374
|
};
|
|
337
375
|
|
|
338
|
-
|
|
339
|
-
|
|
376
|
+
var preventImageDefault = event => {
|
|
377
|
+
props.imagePreventDefault && props.show && event.preventDefault();
|
|
378
|
+
};
|
|
379
|
+
|
|
380
|
+
useEventListener(() => document, 'contextmenu', preventImageDefault);
|
|
381
|
+
watch(() => props.show, newShow => {
|
|
382
|
+
popupShow.value = newShow;
|
|
340
383
|
}, {
|
|
341
384
|
immediate: true
|
|
342
385
|
});
|
|
343
386
|
return {
|
|
344
387
|
n,
|
|
345
388
|
classes,
|
|
389
|
+
isPreventDefault,
|
|
346
390
|
initialIndex,
|
|
347
391
|
popupShow,
|
|
348
392
|
scale,
|
|
@@ -354,6 +398,7 @@ var __sfc__ = defineComponent({
|
|
|
354
398
|
handleTouchstart,
|
|
355
399
|
handleTouchmove,
|
|
356
400
|
handleTouchend,
|
|
401
|
+
handleTouchcancel,
|
|
357
402
|
close
|
|
358
403
|
};
|
|
359
404
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
:root { --image-preview-swipe-indicators-text-color: #ddd; --image-preview-swipe-indicators-padding: 16px 0; --image-preview-zoom-container-background: #000; --image-preview-close-icon-top: 14px; --image-preview-close-icon-right: 14px; --image-preview-extra-top: 14px; --image-preview-extra-left: 14px; --image-preview-close-icon-size: 22px; --image-preview-close-icon-color: #fff;}.var-image-preview__popup[var-image-preview-cover] { height: 100%; background: var(--image-preview-zoom-container-background);}.var-image-preview__swipe[var-image-preview-cover] { width: 100vw; height: 100%;}.var-image-preview__swipe-item[var-image-preview-cover] { overflow: hidden;}.var-image-preview__close-icon[var-image-preview-cover] { position: absolute; top: var(--image-preview-close-icon-top); right: var(--image-preview-close-icon-right); color: var(--image-preview-close-icon-color); font-size: var(--image-preview-close-icon-size);}.var-image-preview__extra { position: absolute; top: var(--image-preview-extra-top); left: var(--image-preview-extra-left);}.var-image-preview__indicators { position: absolute; top: 0; width: 100%; padding: var(--image-preview-swipe-indicators-padding); color: var(--image-preview-swipe-indicators-text-color); text-align: center;}.var-image-preview__image { width: 100%; height: 100%; object-fit: contain; -webkit-user-drag: none;}.var-image-preview__zoom-container { display: flex; justify-content: center; align-items: center; width: 100vw; height: 100%; transition: transform 0.2s;}
|
|
1
|
+
:root { --image-preview-swipe-indicators-text-color: #ddd; --image-preview-swipe-indicators-padding: 16px 0; --image-preview-zoom-container-background: #000; --image-preview-close-icon-top: 14px; --image-preview-close-icon-right: 14px; --image-preview-extra-top: 14px; --image-preview-extra-left: 14px; --image-preview-close-icon-size: 22px; --image-preview-close-icon-color: #fff;}.var-image-preview__popup[var-image-preview-cover] { height: 100%; background: var(--image-preview-zoom-container-background);}.var-image-preview__swipe[var-image-preview-cover] { width: 100vw; height: 100%;}.var-image-preview__swipe-item[var-image-preview-cover] { overflow: hidden;}.var-image-preview__close-icon[var-image-preview-cover] { position: absolute; top: var(--image-preview-close-icon-top); right: var(--image-preview-close-icon-right); color: var(--image-preview-close-icon-color); font-size: var(--image-preview-close-icon-size);}.var-image-preview__extra { position: absolute; top: var(--image-preview-extra-top); left: var(--image-preview-extra-left);}.var-image-preview__indicators { position: absolute; top: 0; width: 100%; padding: var(--image-preview-swipe-indicators-padding); color: var(--image-preview-swipe-indicators-text-color); text-align: center;}.var-image-preview__image { width: 100%; height: 100%; object-fit: contain; -webkit-user-drag: none;}.var-image-preview--prevent { -webkit-touch-callout: none; pointer-events: none;}.var-image-preview__zoom-container { display: flex; justify-content: center; align-items: center; width: 100vw; height: 100%; transition: transform 0.2s;}
|
|
@@ -8,6 +8,10 @@ export var props = _extends({
|
|
|
8
8
|
type: Boolean,
|
|
9
9
|
default: false
|
|
10
10
|
},
|
|
11
|
+
imagePreventDefault: {
|
|
12
|
+
type: Boolean,
|
|
13
|
+
default: false
|
|
14
|
+
},
|
|
11
15
|
images: {
|
|
12
16
|
type: Array,
|
|
13
17
|
default: () => []
|
|
@@ -23,6 +27,7 @@ export var props = _extends({
|
|
|
23
27
|
type: Boolean,
|
|
24
28
|
default: false
|
|
25
29
|
},
|
|
26
|
-
'onUpdate:show': defineListenerProp()
|
|
30
|
+
'onUpdate:show': defineListenerProp(),
|
|
31
|
+
onLongPress: defineListenerProp()
|
|
27
32
|
}, pickProps(swipeProps, ['loop', 'indicator', 'onChange']), pickProps(popupProps, ['lockScroll', 'teleport', 'onOpen', 'onClose', 'onOpened', 'onClosed', // internal for function call closes the dialog
|
|
28
33
|
'onRouteChange']));
|
package/es/index.bundle.mjs
CHANGED
|
@@ -241,7 +241,7 @@ import './time-picker/style/index.mjs'
|
|
|
241
241
|
import './tooltip/style/index.mjs'
|
|
242
242
|
import './uploader/style/index.mjs'
|
|
243
243
|
|
|
244
|
-
const version = '2.11.
|
|
244
|
+
const version = '2.11.2-alpha.1684942134064'
|
|
245
245
|
|
|
246
246
|
function install(app) {
|
|
247
247
|
ActionSheet.install && app.use(ActionSheet)
|
package/es/index.mjs
CHANGED
|
@@ -160,7 +160,7 @@ export * from './time-picker/index.mjs'
|
|
|
160
160
|
export * from './tooltip/index.mjs'
|
|
161
161
|
export * from './uploader/index.mjs'
|
|
162
162
|
|
|
163
|
-
const version = '2.11.
|
|
163
|
+
const version = '2.11.2-alpha.1684942134064'
|
|
164
164
|
|
|
165
165
|
function install(app) {
|
|
166
166
|
ActionSheet.install && app.use(ActionSheet)
|
package/es/picker/Picker.mjs
CHANGED
|
@@ -20,7 +20,7 @@ import { renderSlot as _renderSlot, toDisplayString as _toDisplayString, createT
|
|
|
20
20
|
|
|
21
21
|
var _withScopeId = n => (_pushScopeId(""), n = n(), _popScopeId(), n);
|
|
22
22
|
|
|
23
|
-
var _hoisted_1 = ["
|
|
23
|
+
var _hoisted_1 = ["onTouchstartPassive", "onTouchmove", "onTouchend"];
|
|
24
24
|
var _hoisted_2 = ["onTransitionend"];
|
|
25
25
|
var _hoisted_3 = ["onClick"];
|
|
26
26
|
|
|
@@ -94,7 +94,7 @@ function __render__(_ctx, _cache) {
|
|
|
94
94
|
return _openBlock(), _createElementBlock("div", {
|
|
95
95
|
class: _normalizeClass(_ctx.n('column')),
|
|
96
96
|
key: c.id,
|
|
97
|
-
|
|
97
|
+
onTouchstartPassive: $event => _ctx.handleTouchstart(c),
|
|
98
98
|
onTouchmove: _withModifiers($event => _ctx.handleTouchmove($event, c), ["prevent"]),
|
|
99
99
|
onTouchend: $event => _ctx.handleTouchend($event, c)
|
|
100
100
|
}, [_createElementVNode("div", {
|
|
@@ -249,10 +249,8 @@ var __sfc__ = defineComponent({
|
|
|
249
249
|
scrollTo(scrollColumn, TRANSITION_DURATION);
|
|
250
250
|
};
|
|
251
251
|
|
|
252
|
-
var handleTouchstart =
|
|
252
|
+
var handleTouchstart = scrollColumn => {
|
|
253
253
|
scrollColumn.touching = true;
|
|
254
|
-
scrollColumn.scrolling = false;
|
|
255
|
-
scrollColumn.duration = 0;
|
|
256
254
|
scrollColumn.translate = getTranslateY(scrollColumn.scrollEl);
|
|
257
255
|
};
|
|
258
256
|
|
|
@@ -262,6 +260,8 @@ var __sfc__ = defineComponent({
|
|
|
262
260
|
}
|
|
263
261
|
|
|
264
262
|
dragging = true;
|
|
263
|
+
scrollColumn.scrolling = false;
|
|
264
|
+
scrollColumn.duration = 0;
|
|
265
265
|
var {
|
|
266
266
|
clientY
|
|
267
267
|
} = event.touches[0];
|
|
@@ -377,12 +377,23 @@ var __sfc__ = defineComponent({
|
|
|
377
377
|
createChildren(scrollColumns.value, scrollColumn.columns[scrollColumn.index].children, scrollColumn.columnIndex + 1);
|
|
378
378
|
};
|
|
379
379
|
|
|
380
|
+
var isSamePicked = () => {
|
|
381
|
+
var {
|
|
382
|
+
indexes
|
|
383
|
+
} = getPicked();
|
|
384
|
+
return indexes.every((index, idx) => index === prevIndexes[idx]);
|
|
385
|
+
};
|
|
386
|
+
|
|
380
387
|
var change = scrollColumn => {
|
|
381
388
|
var {
|
|
382
389
|
cascade,
|
|
383
390
|
onChange
|
|
384
391
|
} = props;
|
|
385
392
|
|
|
393
|
+
if (isSamePicked()) {
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
396
|
+
|
|
386
397
|
if (cascade) {
|
|
387
398
|
rebuildChildren(scrollColumn);
|
|
388
399
|
}
|
|
@@ -391,18 +402,13 @@ var __sfc__ = defineComponent({
|
|
|
391
402
|
|
|
392
403
|
if (hasScrolling) {
|
|
393
404
|
return;
|
|
394
|
-
}
|
|
405
|
+
} // rebuild will update the value of picked, so need to get the latest value again.
|
|
406
|
+
|
|
395
407
|
|
|
396
408
|
var {
|
|
397
409
|
texts,
|
|
398
410
|
indexes
|
|
399
411
|
} = getPicked();
|
|
400
|
-
var samePicked = indexes.every((index, idx) => index === prevIndexes[idx]);
|
|
401
|
-
|
|
402
|
-
if (samePicked) {
|
|
403
|
-
return;
|
|
404
|
-
}
|
|
405
|
-
|
|
406
412
|
prevIndexes = [...indexes];
|
|
407
413
|
call(onChange, texts, indexes);
|
|
408
414
|
};
|
package/es/progress/Progress.mjs
CHANGED
|
@@ -7,6 +7,7 @@ var {
|
|
|
7
7
|
n,
|
|
8
8
|
classes
|
|
9
9
|
} = createNamespace('progress');
|
|
10
|
+
var ONE_HUNDRED = 100;
|
|
10
11
|
import { normalizeClass as _normalizeClass, normalizeStyle as _normalizeStyle, openBlock as _openBlock, createElementBlock as _createElementBlock, createCommentVNode as _createCommentVNode, createElementVNode as _createElementVNode, renderSlot as _renderSlot, toDisplayString as _toDisplayString, createTextVNode as _createTextVNode, pushScopeId as _pushScopeId, popScopeId as _popScopeId } from "vue";
|
|
11
12
|
|
|
12
13
|
var _withScopeId = n => (_pushScopeId(""), n = n(), _popScopeId(), n);
|
|
@@ -116,8 +117,8 @@ var __sfc__ = defineComponent({
|
|
|
116
117
|
setup(props) {
|
|
117
118
|
var linearProps = computed(() => {
|
|
118
119
|
var value = toNumber(props.value);
|
|
119
|
-
var width = value >
|
|
120
|
-
var roundValue = value >
|
|
120
|
+
var width = value > ONE_HUNDRED ? ONE_HUNDRED : value;
|
|
121
|
+
var roundValue = value > ONE_HUNDRED ? ONE_HUNDRED : Math.round(value);
|
|
121
122
|
return {
|
|
122
123
|
width: width + "%",
|
|
123
124
|
roundValue: roundValue + "%"
|
|
@@ -130,10 +131,10 @@ var __sfc__ = defineComponent({
|
|
|
130
131
|
value
|
|
131
132
|
} = props;
|
|
132
133
|
var viewBox = "0 0 " + toPxNum(size) + " " + toPxNum(size);
|
|
133
|
-
var roundValue = toNumber(value) >
|
|
134
|
+
var roundValue = toNumber(value) > ONE_HUNDRED ? ONE_HUNDRED : Math.round(toNumber(value));
|
|
134
135
|
var radius = (toPxNum(size) - toPxNum(lineWidth)) / 2;
|
|
135
136
|
var perimeter = 2 * Math.PI * radius;
|
|
136
|
-
var strokeDasharray = roundValue /
|
|
137
|
+
var strokeDasharray = roundValue / ONE_HUNDRED * perimeter + ", " + perimeter;
|
|
137
138
|
return {
|
|
138
139
|
viewBox,
|
|
139
140
|
radius,
|
|
@@ -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'
|