@varlet/ui 2.13.0-alpha.1689346411483 → 2.13.0
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/divider/Divider.mjs +33 -24
- package/es/divider/divider.css +1 -1
- package/es/drag/Drag.mjs +32 -23
- package/es/index.bundle.mjs +1 -1
- package/es/index.mjs +1 -1
- package/es/style.css +1 -1
- package/es/varlet.esm.js +3942 -3944
- package/highlight/web-types.en-US.json +4 -4
- package/highlight/web-types.zh-CN.json +4 -4
- package/lib/style.css +1 -1
- package/lib/varlet.cjs.js +126 -125
- package/package.json +6 -6
- package/types/divider.d.ts +1 -1
- package/types/drag.d.ts +2 -0
- package/umd/varlet.js +5 -5
package/es/divider/Divider.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import { defineComponent, computed, reactive, onUpdated, toRefs } from 'vue';
|
|
1
|
+
import { defineComponent, computed, ref, onUpdated } from 'vue';
|
|
3
2
|
import { toSizeUnit } from '../utils/elements.mjs';
|
|
4
|
-
import {
|
|
3
|
+
import { toNumber, isBoolean } from '@varlet/shared';
|
|
5
4
|
import { props } from './props.mjs';
|
|
6
5
|
import { createNamespace } from '../utils/components.mjs';
|
|
7
6
|
import { onSmartMounted } from '@varlet/use';
|
|
@@ -12,12 +11,14 @@ var {
|
|
|
12
11
|
import { renderSlot as _renderSlot, toDisplayString as _toDisplayString, normalizeClass as _normalizeClass, openBlock as _openBlock, createElementBlock as _createElementBlock, createCommentVNode as _createCommentVNode, normalizeStyle as _normalizeStyle } from "vue";
|
|
13
12
|
function __render__(_ctx, _cache) {
|
|
14
13
|
return _openBlock(), _createElementBlock("div", {
|
|
15
|
-
class: _normalizeClass(_ctx.classes(_ctx.n(), _ctx.n('$--box'), [_ctx.vertical, _ctx.n('--vertical')], [_ctx.withText, _ctx.n('--with-text')], [_ctx.
|
|
14
|
+
class: _normalizeClass(_ctx.classes(_ctx.n(), _ctx.n('$--box'), [_ctx.vertical, _ctx.n('--vertical')], [_ctx.withText, _ctx.n('--with-text')], [_ctx.withPresetInset, _ctx.n('--inset')], [_ctx.dashed, _ctx.n('--dashed')], [_ctx.hairline, _ctx.n('--hairline')])),
|
|
16
15
|
style: _normalizeStyle(_ctx.style)
|
|
17
|
-
}, [_renderSlot(_ctx.$slots, "default", {
|
|
16
|
+
}, [!_ctx.vertical ? _renderSlot(_ctx.$slots, "default", {
|
|
17
|
+
key: 0
|
|
18
|
+
}, () => [_ctx.description ? (_openBlock(), _createElementBlock("span", {
|
|
18
19
|
key: 0,
|
|
19
20
|
class: _normalizeClass(_ctx.n('text'))
|
|
20
|
-
}, _toDisplayString(_ctx.description), 3 /* TEXT, CLASS */)) : _createCommentVNode("v-if", true)])], 6 /* CLASS, STYLE */);
|
|
21
|
+
}, _toDisplayString(_ctx.description), 3 /* TEXT, CLASS */)) : _createCommentVNode("v-if", true)]) : _createCommentVNode("v-if", true)], 6 /* CLASS, STYLE */);
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
var __sfc__ = defineComponent({
|
|
@@ -27,33 +28,41 @@ var __sfc__ = defineComponent({
|
|
|
27
28
|
var {
|
|
28
29
|
slots
|
|
29
30
|
} = _ref;
|
|
30
|
-
var
|
|
31
|
-
|
|
31
|
+
var withText = ref(false);
|
|
32
|
+
var withPresetInset = computed(() => {
|
|
33
|
+
// the inset is only effective in horizontal mode
|
|
34
|
+
var {
|
|
35
|
+
vertical,
|
|
36
|
+
inset
|
|
37
|
+
} = props;
|
|
38
|
+
return !vertical && inset === true;
|
|
32
39
|
});
|
|
33
|
-
var isInset = computed(() => isBoolean(props.inset) ? props.inset : true);
|
|
34
40
|
var style = computed(() => {
|
|
35
41
|
var {
|
|
36
42
|
inset,
|
|
37
43
|
vertical,
|
|
38
44
|
margin
|
|
39
45
|
} = props;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return _extends({}, baseStyle);
|
|
46
|
+
if (isBoolean(inset) || vertical) {
|
|
47
|
+
return {
|
|
48
|
+
margin
|
|
49
|
+
};
|
|
45
50
|
}
|
|
46
51
|
var _inset = toNumber(inset);
|
|
47
52
|
var absInsetWithUnit = Math.abs(_inset) + (inset + '').replace(_inset + '', '');
|
|
48
|
-
return
|
|
49
|
-
|
|
50
|
-
}) : _extends({}, baseStyle, {
|
|
53
|
+
return {
|
|
54
|
+
margin,
|
|
51
55
|
width: "calc(100% - " + toSizeUnit(absInsetWithUnit) + ")",
|
|
52
56
|
left: _inset > 0 ? toSizeUnit(absInsetWithUnit) : toSizeUnit(0)
|
|
53
|
-
}
|
|
57
|
+
};
|
|
54
58
|
});
|
|
55
59
|
var checkHasText = () => {
|
|
56
|
-
|
|
60
|
+
// the default slot or description is only effective in horizontal mode
|
|
61
|
+
var {
|
|
62
|
+
description,
|
|
63
|
+
vertical
|
|
64
|
+
} = props;
|
|
65
|
+
withText.value = (slots.default || description != null) && !vertical;
|
|
57
66
|
};
|
|
58
67
|
onSmartMounted(() => {
|
|
59
68
|
checkHasText();
|
|
@@ -61,13 +70,13 @@ var __sfc__ = defineComponent({
|
|
|
61
70
|
onUpdated(() => {
|
|
62
71
|
checkHasText();
|
|
63
72
|
});
|
|
64
|
-
return
|
|
73
|
+
return {
|
|
65
74
|
n,
|
|
66
|
-
classes
|
|
67
|
-
|
|
75
|
+
classes,
|
|
76
|
+
withText,
|
|
68
77
|
style,
|
|
69
|
-
|
|
70
|
-
}
|
|
78
|
+
withPresetInset
|
|
79
|
+
};
|
|
71
80
|
}
|
|
72
81
|
});
|
|
73
82
|
__sfc__.render = __render__;
|
package/es/divider/divider.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
:root { --divider-color: rgba(0, 0, 0, 0.12); --divider-text-color: #888; --divider-text-margin: 8px 0; --divider-text-padding: 0 8px; --divider-inset: 72px;
|
|
1
|
+
:root { --divider-color: rgba(0, 0, 0, 0.12); --divider-text-color: #888; --divider-text-margin: 8px 0; --divider-text-padding: 0 8px; --divider-inset: 72px;}.var-divider { position: relative; width: 100%; height: 0; border: none; border-top: 1px solid var(--divider-color); margin: var(--divider-text-margin); font-size: var(--font-size-md); color: var(--divider-text-color);}.var-divider--vertical { width: 0; height: auto; align-self: stretch; margin: 0 var(--divider-text-margin); border-top: none; border-left: 1px solid var(--divider-color);}.var-divider--inset { width: calc(100% - var(--divider-inset)); left: var(--divider-inset);}.var-divider__text { display: inline-block; padding: var(--divider-text-padding);}.var-divider--with-text { background-color: transparent; height: fit-content; display: flex; align-items: center; justify-content: center; border: none;}.var-divider--with-text::before,.var-divider--with-text::after { display: inline-block; content: ''; flex: 1; height: 0; border-top: 1px solid var(--divider-color);}.var-divider--dashed { border-top-style: dashed;}.var-divider--dashed.var-divider--vertical { border-top: none; border-left-style: dashed;}.var-divider--hairline { transform: scaleY(0.5);}.var-divider--hairline.var-divider--with-text { transform: none;}.var-divider--hairline.var-divider--with-text::before,.var-divider--hairline.var-divider--with-text::after { transform: scaleY(0.5);}.var-divider--hairline.var-divider--vertical { transform: scaleX(0.5);}
|
package/es/drag/Drag.mjs
CHANGED
|
@@ -52,19 +52,11 @@ var __sfc__ = defineComponent({
|
|
|
52
52
|
left: 0,
|
|
53
53
|
right: 0
|
|
54
54
|
});
|
|
55
|
-
var
|
|
55
|
+
var dragged = ref(false);
|
|
56
56
|
var enableTransition = ref(false);
|
|
57
57
|
var touching = false;
|
|
58
58
|
var prevX = 0;
|
|
59
59
|
var prevY = 0;
|
|
60
|
-
var saveXY = () => {
|
|
61
|
-
var {
|
|
62
|
-
left,
|
|
63
|
-
top
|
|
64
|
-
} = getOffset();
|
|
65
|
-
x.value = left;
|
|
66
|
-
y.value = top;
|
|
67
|
-
};
|
|
68
60
|
var handleTouchstart = event => {
|
|
69
61
|
if (props.disabled) {
|
|
70
62
|
return;
|
|
@@ -85,6 +77,7 @@ var __sfc__ = defineComponent({
|
|
|
85
77
|
}
|
|
86
78
|
event.preventDefault();
|
|
87
79
|
enableTransition.value = false;
|
|
80
|
+
dragged.value = true;
|
|
88
81
|
var {
|
|
89
82
|
clientX,
|
|
90
83
|
clientY
|
|
@@ -110,8 +103,17 @@ var __sfc__ = defineComponent({
|
|
|
110
103
|
return;
|
|
111
104
|
}
|
|
112
105
|
touching = false;
|
|
106
|
+
enableTransition.value = true;
|
|
113
107
|
attract();
|
|
114
108
|
};
|
|
109
|
+
var saveXY = () => {
|
|
110
|
+
var {
|
|
111
|
+
left,
|
|
112
|
+
top
|
|
113
|
+
} = getOffset();
|
|
114
|
+
x.value = left;
|
|
115
|
+
y.value = top;
|
|
116
|
+
};
|
|
115
117
|
var getOffset = () => {
|
|
116
118
|
var dragRect = getRect(drag.value);
|
|
117
119
|
var windowRect = getRect(window);
|
|
@@ -158,7 +160,6 @@ var __sfc__ = defineComponent({
|
|
|
158
160
|
if (props.attraction == null) {
|
|
159
161
|
return;
|
|
160
162
|
}
|
|
161
|
-
enableTransition.value = true;
|
|
162
163
|
var {
|
|
163
164
|
halfWidth,
|
|
164
165
|
halfHeight,
|
|
@@ -187,9 +188,6 @@ var __sfc__ = defineComponent({
|
|
|
187
188
|
}
|
|
188
189
|
};
|
|
189
190
|
var clampToBoundary = () => {
|
|
190
|
-
if (props.disabled) {
|
|
191
|
-
return;
|
|
192
|
-
}
|
|
193
191
|
var {
|
|
194
192
|
minX,
|
|
195
193
|
minY,
|
|
@@ -216,27 +214,37 @@ var __sfc__ = defineComponent({
|
|
|
216
214
|
var style = (_ref3 = attrs.style) != null ? _ref3 : {};
|
|
217
215
|
return _extends({}, attrs, {
|
|
218
216
|
style: _extends({}, style, {
|
|
219
|
-
// when the drag element is
|
|
220
|
-
top:
|
|
221
|
-
left:
|
|
222
|
-
right:
|
|
223
|
-
bottom:
|
|
224
|
-
transform:
|
|
217
|
+
// when the drag element is dragged for the first time, the inset should be cleared to avoid affecting translateX and translateY.
|
|
218
|
+
top: dragged.value ? 0 : style.top,
|
|
219
|
+
left: dragged.value ? 0 : style.left,
|
|
220
|
+
right: dragged.value ? 'auto' : style.right,
|
|
221
|
+
bottom: dragged.value ? 'auto' : style.bottom,
|
|
222
|
+
transform: dragged.value ? "translate(" + x.value + "px, " + y.value + "px)" : style.transform
|
|
225
223
|
})
|
|
226
224
|
});
|
|
227
225
|
};
|
|
228
226
|
|
|
229
227
|
// expose
|
|
230
228
|
var resize = () => {
|
|
231
|
-
|
|
229
|
+
if (!dragged.value) {
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
232
|
saveXY();
|
|
233
233
|
clampToBoundary();
|
|
234
234
|
};
|
|
235
|
-
|
|
235
|
+
|
|
236
|
+
// expose
|
|
237
|
+
var reset = () => {
|
|
238
|
+
enableTransition.value = false;
|
|
239
|
+
dragged.value = false;
|
|
240
|
+
x.value = 0;
|
|
241
|
+
y.value = 0;
|
|
242
|
+
};
|
|
243
|
+
watch(() => props.boundary, toPxBoundary);
|
|
236
244
|
onWindowResize(resize);
|
|
237
245
|
onSmartMounted(() => {
|
|
246
|
+
toPxBoundary();
|
|
238
247
|
resize();
|
|
239
|
-
mounted.value = true;
|
|
240
248
|
});
|
|
241
249
|
return {
|
|
242
250
|
drag,
|
|
@@ -249,7 +257,8 @@ var __sfc__ = defineComponent({
|
|
|
249
257
|
handleTouchstart,
|
|
250
258
|
handleTouchmove,
|
|
251
259
|
handleTouchend,
|
|
252
|
-
resize
|
|
260
|
+
resize,
|
|
261
|
+
reset
|
|
253
262
|
};
|
|
254
263
|
}
|
|
255
264
|
});
|
package/es/index.bundle.mjs
CHANGED
|
@@ -244,7 +244,7 @@ import './time-picker/style/index.mjs'
|
|
|
244
244
|
import './tooltip/style/index.mjs'
|
|
245
245
|
import './uploader/style/index.mjs'
|
|
246
246
|
|
|
247
|
-
const version = '2.13.0
|
|
247
|
+
const version = '2.13.0'
|
|
248
248
|
|
|
249
249
|
function install(app) {
|
|
250
250
|
ActionSheet.install && app.use(ActionSheet)
|
package/es/index.mjs
CHANGED
|
@@ -162,7 +162,7 @@ export * from './time-picker/index.mjs'
|
|
|
162
162
|
export * from './tooltip/index.mjs'
|
|
163
163
|
export * from './uploader/index.mjs'
|
|
164
164
|
|
|
165
|
-
const version = '2.13.0
|
|
165
|
+
const version = '2.13.0'
|
|
166
166
|
|
|
167
167
|
function install(app) {
|
|
168
168
|
ActionSheet.install && app.use(ActionSheet)
|