@varlet/ui 2.16.1 → 2.16.3-alpha.1694267513697
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/action-sheet/ActionSheet.mjs +20 -16
- package/es/app-bar/AppBar.mjs +10 -9
- package/es/avatar/Avatar.mjs +16 -15
- package/es/avatar-group/AvatarGroup.mjs +4 -3
- package/es/back-top/BackTop.mjs +20 -19
- package/es/badge/Badge.mjs +4 -3
- package/es/bottom-navigation/BottomNavigation.mjs +70 -63
- package/es/bottom-navigation-item/BottomNavigationItem.mjs +13 -10
- package/es/breadcrumb/Breadcrumb.mjs +5 -4
- package/es/breadcrumbs/Breadcrumbs.mjs +2 -1
- package/es/button/Button.mjs +10 -9
- package/es/button-group/ButtonGroup.mjs +2 -1
- package/es/card/Card.mjs +28 -26
- package/es/cell/Cell.mjs +5 -4
- package/es/checkbox/Checkbox.mjs +32 -29
- package/es/checkbox-group/CheckboxGroup.mjs +45 -40
- package/es/chip/Chip.mjs +6 -5
- package/es/col/Col.mjs +21 -16
- package/es/collapse/Collapse.mjs +30 -29
- package/es/collapse-item/CollapseItem.mjs +52 -47
- package/es/countdown/Countdown.mjs +36 -35
- package/es/counter/Counter.mjs +63 -60
- package/es/date-picker/DatePicker.mjs +67 -63
- package/es/dialog/Dialog.mjs +39 -29
- package/es/divider/Divider.mjs +6 -9
- package/es/drag/Drag.mjs +47 -45
- package/es/ellipsis/Ellipsis.mjs +6 -5
- package/es/fab/Fab.mjs +21 -20
- package/es/field-decorator/FieldDecorator.mjs +14 -13
- package/es/form/Form.mjs +41 -36
- package/es/form-details/FormDetails.mjs +2 -1
- package/es/hover-overlay/HoverOverlay.mjs +6 -7
- package/es/icon/Icon.mjs +14 -12
- package/es/image/Image.mjs +14 -12
- package/es/image-preview/ImagePreview.mjs +51 -50
- package/es/index-anchor/IndexAnchor.mjs +15 -12
- package/es/index-bar/IndexBar.mjs +68 -65
- package/es/index.bundle.mjs +1 -1
- package/es/index.mjs +1 -1
- package/es/input/Input.mjs +63 -56
- package/es/link/Link.mjs +6 -5
- package/es/list/List.mjs +55 -46
- package/es/loading/Loading.mjs +11 -8
- package/es/loading-bar/LoadingBar.mjs +2 -1
- package/es/menu/Menu.mjs +2 -1
- package/es/option/Option.mjs +14 -11
- package/es/overlay/Overlay.mjs +18 -18
- package/es/pagination/Pagination.mjs +67 -64
- package/es/paper/Paper.mjs +4 -3
- package/es/picker/Picker.mjs +95 -85
- package/es/popup/Popup.mjs +26 -23
- package/es/progress/Progress.mjs +9 -8
- package/es/pull-refresh/PullRefresh.mjs +54 -51
- package/es/radio/Radio.mjs +25 -22
- package/es/radio-group/RadioGroup.mjs +30 -25
- package/es/rate/Rate.mjs +35 -28
- package/es/result/Result.mjs +6 -5
- package/es/row/Row.mjs +20 -18
- package/es/row/props.mjs +1 -1
- package/es/select/Select.mjs +57 -54
- package/es/skeleton/Skeleton.mjs +8 -9
- package/es/slider/Slider.mjs +86 -79
- package/es/snackbar/Snackbar.mjs +4 -3
- package/es/snackbar/style/index.mjs +1 -1
- package/es/space/Space.mjs +5 -2
- package/es/step/Step.mjs +7 -4
- package/es/steps/Steps.mjs +5 -4
- package/es/sticky/Sticky.mjs +30 -27
- package/es/style-provider/StyleProvider.mjs +2 -1
- package/es/swipe/Swipe.mjs +99 -90
- package/es/swipe-item/SwipeItem.mjs +5 -4
- package/es/switch/Switch.mjs +22 -17
- package/es/tab/Tab.mjs +16 -12
- package/es/tab-item/TabItem.mjs +7 -6
- package/es/table/Table.mjs +8 -9
- package/es/tabs/Tabs.mjs +57 -52
- package/es/tabs-items/TabsItems.mjs +38 -29
- package/es/time-picker/TimePicker.mjs +63 -60
- package/es/tooltip/Tooltip.mjs +3 -2
- package/es/uploader/Uploader.mjs +100 -85
- package/es/utils/components.mjs +2 -1
- package/es/utils/shared.mjs +0 -1
- package/es/varlet.esm.js +9605 -8923
- package/es/watermark/Watermark.mjs +29 -26
- package/highlight/web-types.en-US.json +3 -3
- package/highlight/web-types.zh-CN.json +3 -3
- package/lib/varlet.cjs.js +2388 -2118
- package/package.json +12 -14
- package/types/row.d.ts +1 -1
- package/types/swipe.d.ts +12 -3
- package/umd/varlet.js +4 -4
package/es/fab/Fab.mjs
CHANGED
|
@@ -20,11 +20,12 @@ function _isSlot(s) {
|
|
|
20
20
|
return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !_isVNode(s);
|
|
21
21
|
}
|
|
22
22
|
var {
|
|
23
|
+
name,
|
|
23
24
|
classes,
|
|
24
25
|
n
|
|
25
26
|
} = createNamespace('fab');
|
|
26
27
|
export default defineComponent({
|
|
27
|
-
name
|
|
28
|
+
name,
|
|
28
29
|
inheritAttrs: false,
|
|
29
30
|
props,
|
|
30
31
|
setup(props, _ref) {
|
|
@@ -35,7 +36,18 @@ export default defineComponent({
|
|
|
35
36
|
var isActive = useVModel(props, 'active');
|
|
36
37
|
var host = ref(null);
|
|
37
38
|
var dragRef = ref(null);
|
|
38
|
-
|
|
39
|
+
watch(() => props.trigger, () => {
|
|
40
|
+
isActive.value = false;
|
|
41
|
+
});
|
|
42
|
+
watch(() => props.disabled, () => {
|
|
43
|
+
isActive.value = false;
|
|
44
|
+
});
|
|
45
|
+
watch(() => [props.position, props.fixed, props.top, props.bottom, props.left, props.right], () => {
|
|
46
|
+
var _dragRef$value;
|
|
47
|
+
(_dragRef$value = dragRef.value) == null ? void 0 : _dragRef$value.reset();
|
|
48
|
+
});
|
|
49
|
+
useClickOutside(host, 'click', handleClickOutside);
|
|
50
|
+
function handleClick(e, value, childrenLength) {
|
|
39
51
|
e.stopPropagation();
|
|
40
52
|
if (props.trigger !== 'click' || props.disabled) {
|
|
41
53
|
return;
|
|
@@ -47,15 +59,15 @@ export default defineComponent({
|
|
|
47
59
|
isActive.value = value;
|
|
48
60
|
call(props.onClick, isActive.value, e);
|
|
49
61
|
call(isActive.value ? props.onOpen : props.onClose);
|
|
50
|
-
}
|
|
51
|
-
|
|
62
|
+
}
|
|
63
|
+
function handleMouse(value, childrenLength) {
|
|
52
64
|
if (props.trigger !== 'hover' || props.disabled || childrenLength === 0) {
|
|
53
65
|
return;
|
|
54
66
|
}
|
|
55
67
|
isActive.value = value;
|
|
56
68
|
call(isActive.value ? props.onOpen : props.onClose);
|
|
57
|
-
}
|
|
58
|
-
|
|
69
|
+
}
|
|
70
|
+
function handleClickOutside() {
|
|
59
71
|
if (props.trigger !== 'click' || props.disabled) {
|
|
60
72
|
return;
|
|
61
73
|
}
|
|
@@ -63,8 +75,8 @@ export default defineComponent({
|
|
|
63
75
|
isActive.value = false;
|
|
64
76
|
call(props.onClose);
|
|
65
77
|
}
|
|
66
|
-
}
|
|
67
|
-
|
|
78
|
+
}
|
|
79
|
+
function renderTrigger() {
|
|
68
80
|
if (slots.trigger) {
|
|
69
81
|
return props.show ? slots.trigger({
|
|
70
82
|
active: isActive.value
|
|
@@ -88,18 +100,7 @@ export default defineComponent({
|
|
|
88
100
|
"animationClass": n('--trigger-icon-animation')
|
|
89
101
|
}, null)]
|
|
90
102
|
}), [[_vShow, props.show]]);
|
|
91
|
-
}
|
|
92
|
-
watch(() => props.trigger, () => {
|
|
93
|
-
isActive.value = false;
|
|
94
|
-
});
|
|
95
|
-
watch(() => props.disabled, () => {
|
|
96
|
-
isActive.value = false;
|
|
97
|
-
});
|
|
98
|
-
watch(() => [props.position, props.fixed, props.top, props.bottom, props.left, props.right], () => {
|
|
99
|
-
var _dragRef$value;
|
|
100
|
-
(_dragRef$value = dragRef.value) == null ? void 0 : _dragRef$value.reset();
|
|
101
|
-
});
|
|
102
|
-
useClickOutside(host, 'click', handleClickOutside);
|
|
103
|
+
}
|
|
103
104
|
return () => {
|
|
104
105
|
var _slot;
|
|
105
106
|
var _call;
|
|
@@ -5,6 +5,7 @@ import { isEmpty, getStyle } from '@varlet/shared';
|
|
|
5
5
|
import { createNamespace, call } from '../utils/components.mjs';
|
|
6
6
|
import { onWindowResize, onSmartMounted } from '@varlet/use';
|
|
7
7
|
var {
|
|
8
|
+
name,
|
|
8
9
|
n,
|
|
9
10
|
classes
|
|
10
11
|
} = createNamespace('field-decorator');
|
|
@@ -78,7 +79,7 @@ function __render__(_ctx, _cache) {
|
|
|
78
79
|
}
|
|
79
80
|
|
|
80
81
|
var __sfc__ = defineComponent({
|
|
81
|
-
name
|
|
82
|
+
name,
|
|
82
83
|
components: {
|
|
83
84
|
VarIcon
|
|
84
85
|
},
|
|
@@ -89,9 +90,12 @@ var __sfc__ = defineComponent({
|
|
|
89
90
|
} = _ref;
|
|
90
91
|
var placeholderTextEl = ref(null);
|
|
91
92
|
var legendWidth = ref('');
|
|
92
|
-
var color = computed(() => !props.errorMessage ? props.isFocus ? props.focusColor : props.blurColor : undefined);
|
|
93
93
|
var isFloating = computed(() => props.hint && (!isEmpty(props.value) || props.isFocus || slots['prepend-icon']));
|
|
94
|
-
var
|
|
94
|
+
var color = computed(() => !props.errorMessage ? props.isFocus ? props.focusColor : props.blurColor : undefined);
|
|
95
|
+
onWindowResize(resize);
|
|
96
|
+
onSmartMounted(resize);
|
|
97
|
+
onUpdated(resize);
|
|
98
|
+
function computePlaceholderState() {
|
|
95
99
|
var {
|
|
96
100
|
hint,
|
|
97
101
|
value,
|
|
@@ -103,8 +107,8 @@ var __sfc__ = defineComponent({
|
|
|
103
107
|
if (isFloating.value) {
|
|
104
108
|
return n('--placeholder-hint');
|
|
105
109
|
}
|
|
106
|
-
}
|
|
107
|
-
|
|
110
|
+
}
|
|
111
|
+
function resize() {
|
|
108
112
|
var {
|
|
109
113
|
size,
|
|
110
114
|
hint,
|
|
@@ -118,16 +122,13 @@ var __sfc__ = defineComponent({
|
|
|
118
122
|
var placeholderTextStyle = getStyle(placeholderTextEl.value);
|
|
119
123
|
var placeholderSpace = "var(--field-decorator-outlined-" + size + "-placeholder-space)";
|
|
120
124
|
legendWidth.value = "calc(" + placeholderTextStyle.width + " * 0.75 + " + placeholderSpace + " * 2)";
|
|
121
|
-
}
|
|
122
|
-
|
|
125
|
+
}
|
|
126
|
+
function handleClear(e) {
|
|
123
127
|
call(props.onClear, e);
|
|
124
|
-
}
|
|
125
|
-
|
|
128
|
+
}
|
|
129
|
+
function handleClick(e) {
|
|
126
130
|
call(props.onClick, e);
|
|
127
|
-
}
|
|
128
|
-
onWindowResize(resize);
|
|
129
|
-
onSmartMounted(resize);
|
|
130
|
-
onUpdated(resize);
|
|
131
|
+
}
|
|
131
132
|
return {
|
|
132
133
|
placeholderTextEl,
|
|
133
134
|
color,
|
package/es/form/Form.mjs
CHANGED
|
@@ -8,6 +8,7 @@ import { find } from '@varlet/shared';
|
|
|
8
8
|
import { getParentScroller, getTop, scrollTo, toPxNum } from '../utils/elements.mjs';
|
|
9
9
|
import { linear } from '../utils/shared.mjs';
|
|
10
10
|
var {
|
|
11
|
+
name,
|
|
11
12
|
n
|
|
12
13
|
} = createNamespace('form');
|
|
13
14
|
import { renderSlot as _renderSlot, normalizeClass as _normalizeClass, openBlock as _openBlock, createElementBlock as _createElementBlock } from "vue";
|
|
@@ -24,7 +25,7 @@ function __render__(_ctx, _cache) {
|
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
var __sfc__ = defineComponent({
|
|
27
|
-
name
|
|
28
|
+
name,
|
|
28
29
|
props,
|
|
29
30
|
setup(props) {
|
|
30
31
|
var disabled = computed(() => props.disabled);
|
|
@@ -33,7 +34,12 @@ var __sfc__ = defineComponent({
|
|
|
33
34
|
formItems,
|
|
34
35
|
bindFormItems
|
|
35
36
|
} = useFormItems();
|
|
36
|
-
var
|
|
37
|
+
var formProvider = {
|
|
38
|
+
disabled,
|
|
39
|
+
readonly
|
|
40
|
+
};
|
|
41
|
+
bindFormItems(formProvider);
|
|
42
|
+
function scroll(formItemElement) {
|
|
37
43
|
// wait form-details animation end
|
|
38
44
|
setTimeout(() => {
|
|
39
45
|
var scroller = getParentScroller(formItemElement);
|
|
@@ -44,26 +50,30 @@ var __sfc__ = defineComponent({
|
|
|
44
50
|
animation: linear
|
|
45
51
|
});
|
|
46
52
|
}, 300);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
53
|
+
}
|
|
54
|
+
function handleSubmit(_x) {
|
|
55
|
+
return _handleSubmit.apply(this, arguments);
|
|
56
|
+
}
|
|
57
|
+
function _handleSubmit() {
|
|
58
|
+
_handleSubmit = _asyncToGenerator(function* (event) {
|
|
50
59
|
event.preventDefault();
|
|
51
60
|
var valid = yield validate();
|
|
52
61
|
call(props.onSubmit, valid);
|
|
53
62
|
});
|
|
54
|
-
return
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}();
|
|
58
|
-
var handleReset = event => {
|
|
63
|
+
return _handleSubmit.apply(this, arguments);
|
|
64
|
+
}
|
|
65
|
+
function handleReset(event) {
|
|
59
66
|
event.preventDefault();
|
|
60
67
|
reset();
|
|
61
68
|
call(props.onReset);
|
|
62
|
-
}
|
|
69
|
+
}
|
|
63
70
|
|
|
64
71
|
// expose
|
|
65
|
-
|
|
66
|
-
|
|
72
|
+
function validate() {
|
|
73
|
+
return _validate.apply(this, arguments);
|
|
74
|
+
} // expose
|
|
75
|
+
function _validate() {
|
|
76
|
+
_validate = _asyncToGenerator(function* () {
|
|
67
77
|
var res = yield Promise.all(formItems.map(_ref3 => {
|
|
68
78
|
var {
|
|
69
79
|
validate
|
|
@@ -82,31 +92,26 @@ var __sfc__ = defineComponent({
|
|
|
82
92
|
}
|
|
83
93
|
return res.every(result => result === true);
|
|
84
94
|
});
|
|
85
|
-
return
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
return reset();
|
|
96
|
-
});
|
|
95
|
+
return _validate.apply(this, arguments);
|
|
96
|
+
}
|
|
97
|
+
function reset() {
|
|
98
|
+
return formItems.forEach(_ref => {
|
|
99
|
+
var {
|
|
100
|
+
reset
|
|
101
|
+
} = _ref;
|
|
102
|
+
return reset();
|
|
103
|
+
});
|
|
104
|
+
}
|
|
97
105
|
|
|
98
106
|
// expose
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
readonly
|
|
108
|
-
};
|
|
109
|
-
bindFormItems(formProvider);
|
|
107
|
+
function resetValidation() {
|
|
108
|
+
return formItems.forEach(_ref2 => {
|
|
109
|
+
var {
|
|
110
|
+
resetValidation
|
|
111
|
+
} = _ref2;
|
|
112
|
+
return resetValidation();
|
|
113
|
+
});
|
|
114
|
+
}
|
|
110
115
|
return {
|
|
111
116
|
n,
|
|
112
117
|
handleSubmit,
|
|
@@ -2,6 +2,7 @@ import { defineComponent } from 'vue';
|
|
|
2
2
|
import { createNamespace } from '../utils/components.mjs';
|
|
3
3
|
import { props } from './props.mjs';
|
|
4
4
|
var {
|
|
5
|
+
name,
|
|
5
6
|
n
|
|
6
7
|
} = createNamespace('form-details');
|
|
7
8
|
import { toDisplayString as _toDisplayString, openBlock as _openBlock, createElementBlock as _createElementBlock, createCommentVNode as _createCommentVNode, Transition as _Transition, withCtx as _withCtx, createVNode as _createVNode, normalizeClass as _normalizeClass, createElementVNode as _createElementVNode, renderSlot as _renderSlot, createBlock as _createBlock, pushScopeId as _pushScopeId, popScopeId as _popScopeId } from "vue";
|
|
@@ -38,7 +39,7 @@ function __render__(_ctx, _cache) {
|
|
|
38
39
|
}, 8 /* PROPS */, ["name"]);
|
|
39
40
|
}
|
|
40
41
|
var __sfc__ = defineComponent({
|
|
41
|
-
name
|
|
42
|
+
name,
|
|
42
43
|
props,
|
|
43
44
|
setup: () => ({
|
|
44
45
|
n
|
|
@@ -2,6 +2,7 @@ import { defineComponent } from 'vue';
|
|
|
2
2
|
import { props } from './props.mjs';
|
|
3
3
|
import { createNamespace } from '../utils/components.mjs';
|
|
4
4
|
var {
|
|
5
|
+
name,
|
|
5
6
|
n,
|
|
6
7
|
classes
|
|
7
8
|
} = createNamespace('hover-overlay');
|
|
@@ -13,14 +14,12 @@ function __render__(_ctx, _cache) {
|
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
var __sfc__ = defineComponent({
|
|
16
|
-
name
|
|
17
|
+
name,
|
|
17
18
|
props,
|
|
18
|
-
setup() {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
};
|
|
23
|
-
}
|
|
19
|
+
setup: () => ({
|
|
20
|
+
n,
|
|
21
|
+
classes
|
|
22
|
+
})
|
|
24
23
|
});
|
|
25
24
|
__sfc__.render = __render__;
|
|
26
25
|
export default __sfc__;
|
package/es/icon/Icon.mjs
CHANGED
|
@@ -6,6 +6,7 @@ import { props } from './props.mjs';
|
|
|
6
6
|
import { toSizeUnit } from '../utils/elements.mjs';
|
|
7
7
|
import { createNamespace } from '../utils/components.mjs';
|
|
8
8
|
var {
|
|
9
|
+
name,
|
|
9
10
|
n,
|
|
10
11
|
classes
|
|
11
12
|
} = createNamespace('icon');
|
|
@@ -25,13 +26,19 @@ function __render__(_ctx, _cache) {
|
|
|
25
26
|
}, null, 8 /* PROPS */, ["class", "style", "src", "onClick"]);
|
|
26
27
|
}
|
|
27
28
|
var __sfc__ = defineComponent({
|
|
28
|
-
name
|
|
29
|
+
name,
|
|
29
30
|
props,
|
|
30
31
|
setup(props) {
|
|
31
32
|
var nextName = ref('');
|
|
32
33
|
var animateInProgress = ref(false);
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
watch(() => props.name, handleNameChange, {
|
|
35
|
+
immediate: true
|
|
36
|
+
});
|
|
37
|
+
function handleNameChange(_x, _x2) {
|
|
38
|
+
return _handleNameChange.apply(this, arguments);
|
|
39
|
+
}
|
|
40
|
+
function _handleNameChange() {
|
|
41
|
+
_handleNameChange = _asyncToGenerator(function* (newName, oldName) {
|
|
35
42
|
var {
|
|
36
43
|
transition
|
|
37
44
|
} = props;
|
|
@@ -48,18 +55,13 @@ var __sfc__ = defineComponent({
|
|
|
48
55
|
animateInProgress.value = false;
|
|
49
56
|
}, toNumber(transition));
|
|
50
57
|
});
|
|
51
|
-
return
|
|
52
|
-
|
|
53
|
-
};
|
|
54
|
-
}();
|
|
55
|
-
watch(() => props.name, handleNameChange, {
|
|
56
|
-
immediate: true
|
|
57
|
-
});
|
|
58
|
+
return _handleNameChange.apply(this, arguments);
|
|
59
|
+
}
|
|
58
60
|
return {
|
|
59
|
-
n,
|
|
60
|
-
classes,
|
|
61
61
|
nextName,
|
|
62
62
|
animateInProgress,
|
|
63
|
+
n,
|
|
64
|
+
classes,
|
|
63
65
|
isURL,
|
|
64
66
|
toNumber,
|
|
65
67
|
toSizeUnit
|
package/es/image/Image.mjs
CHANGED
|
@@ -5,6 +5,7 @@ import { props } from './props.mjs';
|
|
|
5
5
|
import { toSizeUnit } from '../utils/elements.mjs';
|
|
6
6
|
import { createNamespace, call } from '../utils/components.mjs';
|
|
7
7
|
var {
|
|
8
|
+
name,
|
|
8
9
|
n,
|
|
9
10
|
classes
|
|
10
11
|
} = createNamespace('image');
|
|
@@ -13,6 +14,7 @@ var _withScopeId = n => (_pushScopeId(""), n = n(), _popScopeId(), n);
|
|
|
13
14
|
var _hoisted_1 = ["alt", "title", "lazy-loading", "lazy-error"];
|
|
14
15
|
var _hoisted_2 = ["alt", "title", "src"];
|
|
15
16
|
function __render__(_ctx, _cache) {
|
|
17
|
+
var _ctx$src;
|
|
16
18
|
var _directive_lazy = _resolveDirective("lazy");
|
|
17
19
|
var _directive_ripple = _resolveDirective("ripple");
|
|
18
20
|
return _withDirectives((_openBlock(), _createElementBlock("div", {
|
|
@@ -38,7 +40,7 @@ function __render__(_ctx, _cache) {
|
|
|
38
40
|
onClick: _cache[1] || (_cache[1] = function () {
|
|
39
41
|
return _ctx.handleClick && _ctx.handleClick(...arguments);
|
|
40
42
|
})
|
|
41
|
-
}, null, 46 /* CLASS, STYLE, PROPS, HYDRATE_EVENTS */, _hoisted_1)), [[_directive_lazy, _ctx.src]]) : _createCommentVNode("v-if", true), !_ctx.lazy && !_ctx.showErrorSlot ? (_openBlock(), _createElementBlock("img", {
|
|
43
|
+
}, null, 46 /* CLASS, STYLE, PROPS, HYDRATE_EVENTS */, _hoisted_1)), [[_directive_lazy, (_ctx$src = _ctx.src) != null ? _ctx$src : '']]) : _createCommentVNode("v-if", true), !_ctx.lazy && !_ctx.showErrorSlot ? (_openBlock(), _createElementBlock("img", {
|
|
42
44
|
key: 1,
|
|
43
45
|
class: _normalizeClass(_ctx.n('image')),
|
|
44
46
|
alt: _ctx.alt,
|
|
@@ -63,7 +65,7 @@ function __render__(_ctx, _cache) {
|
|
|
63
65
|
}]]);
|
|
64
66
|
}
|
|
65
67
|
var __sfc__ = defineComponent({
|
|
66
|
-
name
|
|
68
|
+
name,
|
|
67
69
|
directives: {
|
|
68
70
|
Lazy,
|
|
69
71
|
Ripple
|
|
@@ -74,12 +76,15 @@ var __sfc__ = defineComponent({
|
|
|
74
76
|
slots
|
|
75
77
|
} = _ref;
|
|
76
78
|
var showErrorSlot = ref(false);
|
|
77
|
-
|
|
79
|
+
watch(() => props.src, () => {
|
|
80
|
+
showErrorSlot.value = false;
|
|
81
|
+
});
|
|
82
|
+
function handleError(e) {
|
|
78
83
|
// the value of showErrorSlot depends on whether there is an error slot
|
|
79
84
|
showErrorSlot.value = !!slots.error;
|
|
80
85
|
call(props.onError, e);
|
|
81
|
-
}
|
|
82
|
-
|
|
86
|
+
}
|
|
87
|
+
function handleLoad(e) {
|
|
83
88
|
var el = e.currentTarget;
|
|
84
89
|
if (props.lazy) {
|
|
85
90
|
if (el._lazy.state === 'success') {
|
|
@@ -92,17 +97,14 @@ var __sfc__ = defineComponent({
|
|
|
92
97
|
} else {
|
|
93
98
|
call(props.onLoad, e);
|
|
94
99
|
}
|
|
95
|
-
}
|
|
96
|
-
|
|
100
|
+
}
|
|
101
|
+
function handleClick(e) {
|
|
97
102
|
call(props.onClick, e);
|
|
98
|
-
}
|
|
99
|
-
watch(() => props.src, () => {
|
|
100
|
-
showErrorSlot.value = false;
|
|
101
|
-
});
|
|
103
|
+
}
|
|
102
104
|
return {
|
|
105
|
+
showErrorSlot,
|
|
103
106
|
n,
|
|
104
107
|
classes,
|
|
105
|
-
showErrorSlot,
|
|
106
108
|
toSizeUnit,
|
|
107
109
|
handleLoad,
|
|
108
110
|
handleError,
|
|
@@ -8,6 +8,7 @@ import { useEventListener, useTouch } from '@varlet/use';
|
|
|
8
8
|
import { props } from './props.mjs';
|
|
9
9
|
import { call, createNamespace } from '../utils/components.mjs';
|
|
10
10
|
var {
|
|
11
|
+
name,
|
|
11
12
|
n,
|
|
12
13
|
classes
|
|
13
14
|
} = createNamespace('image-preview');
|
|
@@ -110,7 +111,7 @@ function __render__(_ctx, _cache) {
|
|
|
110
111
|
}, 8 /* PROPS */, ["class", "transition", "show", "lock-scroll", "teleport", "onOpen", "onClose", "onClosed", "onOpened", "onRouteChange"]);
|
|
111
112
|
}
|
|
112
113
|
var __sfc__ = defineComponent({
|
|
113
|
-
name
|
|
114
|
+
name,
|
|
114
115
|
components: {
|
|
115
116
|
VarSwipe,
|
|
116
117
|
VarSwipeItem,
|
|
@@ -124,8 +125,8 @@ var __sfc__ = defineComponent({
|
|
|
124
125
|
var scale = ref(1);
|
|
125
126
|
var translateX = ref(0);
|
|
126
127
|
var translateY = ref(0);
|
|
127
|
-
var transitionTimingFunction = ref(
|
|
128
|
-
var transitionDuration = ref(
|
|
128
|
+
var transitionTimingFunction = ref();
|
|
129
|
+
var transitionDuration = ref();
|
|
129
130
|
var canSwipe = ref(true);
|
|
130
131
|
var swipeRef = ref(null);
|
|
131
132
|
var {
|
|
@@ -137,13 +138,6 @@ var __sfc__ = defineComponent({
|
|
|
137
138
|
moveTouch,
|
|
138
139
|
endTouch
|
|
139
140
|
} = useTouch();
|
|
140
|
-
var targets = {
|
|
141
|
-
start: null,
|
|
142
|
-
prev: null
|
|
143
|
-
};
|
|
144
|
-
var closeRunner = null;
|
|
145
|
-
var longPressRunner = null;
|
|
146
|
-
var isLongPress = false;
|
|
147
141
|
var initialIndex = computed(() => {
|
|
148
142
|
// For compatibility with current, temporarily keep this computed method
|
|
149
143
|
// Current will be replaced by initialIndex in the future
|
|
@@ -165,7 +159,20 @@ var __sfc__ = defineComponent({
|
|
|
165
159
|
} = props;
|
|
166
160
|
return show && imagePreventDefault;
|
|
167
161
|
});
|
|
168
|
-
var
|
|
162
|
+
var closeRunner = null;
|
|
163
|
+
var longPressRunner = null;
|
|
164
|
+
var isLongPress = false;
|
|
165
|
+
var targets = {
|
|
166
|
+
start: null,
|
|
167
|
+
prev: null
|
|
168
|
+
};
|
|
169
|
+
useEventListener(() => document, 'contextmenu', preventImageDefault);
|
|
170
|
+
watch(() => props.show, newShow => {
|
|
171
|
+
popupShow.value = newShow;
|
|
172
|
+
}, {
|
|
173
|
+
immediate: true
|
|
174
|
+
});
|
|
175
|
+
function zoomIn() {
|
|
169
176
|
scale.value = toNumber(props.zoom);
|
|
170
177
|
canSwipe.value = false;
|
|
171
178
|
targets.prev = null;
|
|
@@ -173,8 +180,8 @@ var __sfc__ = defineComponent({
|
|
|
173
180
|
transitionTimingFunction.value = 'linear';
|
|
174
181
|
transitionDuration.value = '0s';
|
|
175
182
|
}, ANIMATION_DURATION);
|
|
176
|
-
}
|
|
177
|
-
|
|
183
|
+
}
|
|
184
|
+
function zoomOut() {
|
|
178
185
|
scale.value = 1;
|
|
179
186
|
translateX.value = 0;
|
|
180
187
|
translateY.value = 0;
|
|
@@ -182,26 +189,26 @@ var __sfc__ = defineComponent({
|
|
|
182
189
|
targets.prev = null;
|
|
183
190
|
transitionTimingFunction.value = undefined;
|
|
184
191
|
transitionDuration.value = undefined;
|
|
185
|
-
}
|
|
186
|
-
|
|
192
|
+
}
|
|
193
|
+
function isDoubleTouch(target) {
|
|
187
194
|
if (!targets.prev) {
|
|
188
195
|
return false;
|
|
189
196
|
}
|
|
190
197
|
return distance.value <= DISTANCE_OFFSET && performance.now() - startTime.value <= EVENT_DELAY && targets.prev === target;
|
|
191
|
-
}
|
|
192
|
-
|
|
198
|
+
}
|
|
199
|
+
function isTapTouch(target) {
|
|
193
200
|
if (!target || !targets.start || !targets.prev) {
|
|
194
201
|
return false;
|
|
195
202
|
}
|
|
196
203
|
return distance.value <= DISTANCE_OFFSET && performance.now() - startTime.value < TAP_DELAY && (target === targets.start || target.parentNode === targets.start);
|
|
197
|
-
}
|
|
198
|
-
|
|
204
|
+
}
|
|
205
|
+
function handleTouchcancel() {
|
|
199
206
|
endTouch();
|
|
200
207
|
window.clearTimeout(longPressRunner);
|
|
201
208
|
isLongPress = false;
|
|
202
209
|
targets.start = null;
|
|
203
|
-
}
|
|
204
|
-
|
|
210
|
+
}
|
|
211
|
+
function handleTouchend(event) {
|
|
205
212
|
endTouch();
|
|
206
213
|
window.clearTimeout(longPressRunner);
|
|
207
214
|
|
|
@@ -215,8 +222,8 @@ var __sfc__ = defineComponent({
|
|
|
215
222
|
isTap && close();
|
|
216
223
|
targets.start = null;
|
|
217
224
|
}, EVENT_DELAY);
|
|
218
|
-
}
|
|
219
|
-
|
|
225
|
+
}
|
|
226
|
+
function handleTouchstart(event, idx) {
|
|
220
227
|
window.clearTimeout(closeRunner);
|
|
221
228
|
window.clearTimeout(longPressRunner);
|
|
222
229
|
var target = event.currentTarget;
|
|
@@ -231,8 +238,8 @@ var __sfc__ = defineComponent({
|
|
|
231
238
|
}
|
|
232
239
|
startTouch(event);
|
|
233
240
|
targets.prev = target;
|
|
234
|
-
}
|
|
235
|
-
|
|
241
|
+
}
|
|
242
|
+
function getZoom(target) {
|
|
236
243
|
var {
|
|
237
244
|
offsetWidth,
|
|
238
245
|
offsetHeight
|
|
@@ -248,8 +255,8 @@ var __sfc__ = defineComponent({
|
|
|
248
255
|
rootRadio: offsetHeight / offsetWidth,
|
|
249
256
|
zoom: toNumber(props.zoom)
|
|
250
257
|
};
|
|
251
|
-
}
|
|
252
|
-
|
|
258
|
+
}
|
|
259
|
+
function getLimitX(target) {
|
|
253
260
|
var {
|
|
254
261
|
zoom,
|
|
255
262
|
imageRadio,
|
|
@@ -262,8 +269,8 @@ var __sfc__ = defineComponent({
|
|
|
262
269
|
}
|
|
263
270
|
var displayWidth = imageRadio > rootRadio ? height / imageRadio : width;
|
|
264
271
|
return Math.max(0, (zoom * displayWidth - width) / 2) / zoom;
|
|
265
|
-
}
|
|
266
|
-
|
|
272
|
+
}
|
|
273
|
+
function getLimitY(target) {
|
|
267
274
|
var {
|
|
268
275
|
zoom,
|
|
269
276
|
imageRadio,
|
|
@@ -276,8 +283,8 @@ var __sfc__ = defineComponent({
|
|
|
276
283
|
}
|
|
277
284
|
var displayHeight = imageRadio > rootRadio ? height : width * imageRadio;
|
|
278
285
|
return Math.max(0, (zoom * displayHeight - height) / 2) / zoom;
|
|
279
|
-
}
|
|
280
|
-
|
|
286
|
+
}
|
|
287
|
+
function handleTouchmove(event) {
|
|
281
288
|
if (!targets.prev) {
|
|
282
289
|
return;
|
|
283
290
|
}
|
|
@@ -293,45 +300,37 @@ var __sfc__ = defineComponent({
|
|
|
293
300
|
translateY.value = clamp(translateY.value + moveY.value, -limitY, limitY);
|
|
294
301
|
}
|
|
295
302
|
targets.prev = target;
|
|
296
|
-
}
|
|
297
|
-
|
|
303
|
+
}
|
|
304
|
+
function close() {
|
|
298
305
|
if (scale.value > 1) {
|
|
299
306
|
zoomOut();
|
|
300
307
|
setTimeout(() => call(props['onUpdate:show'], false), ANIMATION_DURATION);
|
|
301
308
|
return;
|
|
302
309
|
}
|
|
303
310
|
call(props['onUpdate:show'], false);
|
|
304
|
-
}
|
|
311
|
+
}
|
|
305
312
|
|
|
306
313
|
// expose
|
|
307
|
-
|
|
314
|
+
function prev(options) {
|
|
308
315
|
var _swipeRef$value;
|
|
309
316
|
(_swipeRef$value = swipeRef.value) == null ? void 0 : _swipeRef$value.prev(options);
|
|
310
|
-
}
|
|
317
|
+
}
|
|
311
318
|
|
|
312
319
|
// expose
|
|
313
|
-
|
|
320
|
+
function next(options) {
|
|
314
321
|
var _swipeRef$value2;
|
|
315
322
|
(_swipeRef$value2 = swipeRef.value) == null ? void 0 : _swipeRef$value2.next(options);
|
|
316
|
-
}
|
|
323
|
+
}
|
|
317
324
|
|
|
318
325
|
// expose
|
|
319
|
-
|
|
326
|
+
function to(idx, options) {
|
|
320
327
|
var _swipeRef$value3;
|
|
321
328
|
(_swipeRef$value3 = swipeRef.value) == null ? void 0 : _swipeRef$value3.to(idx, options);
|
|
322
|
-
}
|
|
323
|
-
|
|
329
|
+
}
|
|
330
|
+
function preventImageDefault(event) {
|
|
324
331
|
props.imagePreventDefault && props.show && event.preventDefault();
|
|
325
|
-
}
|
|
326
|
-
useEventListener(() => document, 'contextmenu', preventImageDefault);
|
|
327
|
-
watch(() => props.show, newShow => {
|
|
328
|
-
popupShow.value = newShow;
|
|
329
|
-
}, {
|
|
330
|
-
immediate: true
|
|
331
|
-
});
|
|
332
|
+
}
|
|
332
333
|
return {
|
|
333
|
-
n,
|
|
334
|
-
classes,
|
|
335
334
|
swipeRef,
|
|
336
335
|
isPreventDefault,
|
|
337
336
|
initialIndex,
|
|
@@ -342,6 +341,8 @@ var __sfc__ = defineComponent({
|
|
|
342
341
|
canSwipe,
|
|
343
342
|
transitionTimingFunction,
|
|
344
343
|
transitionDuration,
|
|
344
|
+
n,
|
|
345
|
+
classes,
|
|
345
346
|
handleTouchstart,
|
|
346
347
|
handleTouchmove,
|
|
347
348
|
handleTouchend,
|