@varlet/ui 3.2.13 → 3.2.14
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/style/index.mjs +1 -1
- package/es/app-bar/AppBar.mjs +111 -77
- package/es/app-bar/props.mjs +2 -1
- package/es/avatar/avatar.css +1 -1
- package/es/bottom-navigation/BottomNavigation.mjs +2 -1
- package/es/bottom-navigation-item/bottomNavigationItem.css +1 -1
- package/es/checkbox/Checkbox.mjs +3 -3
- package/es/checkbox-group/style/index.mjs +3 -0
- package/es/collapse-item/collapseItem.css +1 -1
- package/es/ellipsis/ellipsis.css +1 -1
- package/es/index.bundle.mjs +1 -1
- package/es/index.mjs +1 -1
- package/es/link/link.css +1 -1
- package/es/paper/paper.css +1 -1
- package/es/radio/Radio.mjs +1 -1
- package/es/radio-group/RadioGroup.mjs +22 -4
- package/es/radio-group/RadioGroupOption.mjs +45 -0
- package/es/radio-group/props.mjs +9 -0
- package/es/radio-group/style/index.mjs +4 -0
- package/es/snackbar/style/index.mjs +1 -1
- package/es/style-provider/index.mjs +25 -7
- package/es/style.css +1 -1
- package/es/swipe/Swipe.mjs +25 -5
- package/es/swipe-item/SwipeItem.mjs +15 -8
- package/es/swipe-item/swipeItem.css +1 -1
- package/es/varlet.esm.js +5253 -5142
- package/highlight/web-types.en-US.json +37 -1
- package/highlight/web-types.zh-CN.json +37 -1
- package/lib/style.css +1 -1
- package/lib/varlet.cjs.js +1017 -876
- package/package.json +7 -7
- package/types/appBar.d.ts +1 -0
- package/types/radio.d.ts +5 -1
- package/types/radioGroup.d.ts +14 -1
- package/types/styleVars.d.ts +17 -801
- package/umd/varlet.js +8 -6
package/es/swipe/Swipe.mjs
CHANGED
|
@@ -26,8 +26,9 @@ import { useSwipeItems } from "./provide.mjs";
|
|
|
26
26
|
import { props } from "./props.mjs";
|
|
27
27
|
import { clamp, isNumber, toNumber, doubleRaf, preventDefault, call } from "@varlet/shared";
|
|
28
28
|
import { createNamespace } from "../utils/components.mjs";
|
|
29
|
-
import { onSmartUnmounted, onWindowResize, useTouch } from "@varlet/use";
|
|
29
|
+
import { onSmartUnmounted, onWindowResize, useEventListener, useTouch } from "@varlet/use";
|
|
30
30
|
import { usePopup } from "../popup/provide.mjs";
|
|
31
|
+
import { toSizeUnit } from "../utils/elements.mjs";
|
|
31
32
|
const SWIPE_DELAY = 250;
|
|
32
33
|
const SWIPE_OFFSET = 20;
|
|
33
34
|
const { name, n, classes } = createNamespace("swipe");
|
|
@@ -50,10 +51,10 @@ function __render__(_ctx, _cache) {
|
|
|
50
51
|
{
|
|
51
52
|
class: _normalizeClass(_ctx.classes(_ctx.n("track"), [_ctx.vertical, _ctx.n("--vertical")])),
|
|
52
53
|
style: _normalizeStyle({
|
|
53
|
-
width: !_ctx.vertical ?
|
|
54
|
-
height: _ctx.vertical ?
|
|
55
|
-
transform: `translate${_ctx.vertical ? "Y" : "X"}(${_ctx.trackTranslate}
|
|
56
|
-
transitionDuration: _ctx.lockDuration ?
|
|
54
|
+
width: !_ctx.vertical ? _ctx.toSizeUnit(_ctx.trackSize) : void 0,
|
|
55
|
+
height: _ctx.vertical ? _ctx.toSizeUnit(_ctx.trackSize) : void 0,
|
|
56
|
+
transform: `translate${_ctx.vertical ? "Y" : "X"}(${_ctx.toSizeUnit(_ctx.trackTranslate)})`,
|
|
57
|
+
transitionDuration: _ctx.lockDuration ? "0ms" : `${_ctx.toNumber(_ctx.duration)}ms`
|
|
57
58
|
}),
|
|
58
59
|
onTouchstart: _cache[0] || (_cache[0] = (...args) => _ctx.handleTouchstart && _ctx.handleTouchstart(...args)),
|
|
59
60
|
onTouchmove: _cache[1] || (_cache[1] = (...args) => _ctx.handleTouchmove && _ctx.handleTouchmove(...args)),
|
|
@@ -235,6 +236,7 @@ const __sfc__ = defineComponent({
|
|
|
235
236
|
vertical
|
|
236
237
|
};
|
|
237
238
|
bindSwipeItems(swipeProvider);
|
|
239
|
+
useEventListener(() => window, "keydown", handleKeydown);
|
|
238
240
|
call(bindPopup, null);
|
|
239
241
|
watch(
|
|
240
242
|
() => length.value,
|
|
@@ -406,6 +408,23 @@ const __sfc__ = defineComponent({
|
|
|
406
408
|
}
|
|
407
409
|
return n(`--navigation${props2.vertical ? "-vertical" : ""}-${type}-animation`);
|
|
408
410
|
}
|
|
411
|
+
function handleKeydown(event) {
|
|
412
|
+
if (!swipeItems.length) {
|
|
413
|
+
return;
|
|
414
|
+
}
|
|
415
|
+
const focusingSwipeItemIndex = swipeItems.findIndex(({ isFocusing }) => isFocusing.value);
|
|
416
|
+
if (focusingSwipeItemIndex === -1) {
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
const { key } = event;
|
|
420
|
+
preventDefault(event);
|
|
421
|
+
if (key === "ArrowLeft") {
|
|
422
|
+
prev();
|
|
423
|
+
}
|
|
424
|
+
if (key === "ArrowRight") {
|
|
425
|
+
next();
|
|
426
|
+
}
|
|
427
|
+
}
|
|
409
428
|
function resize() {
|
|
410
429
|
if (!swipeEl.value) {
|
|
411
430
|
return;
|
|
@@ -489,6 +508,7 @@ const __sfc__ = defineComponent({
|
|
|
489
508
|
lockDuration,
|
|
490
509
|
hovering,
|
|
491
510
|
n,
|
|
511
|
+
toSizeUnit,
|
|
492
512
|
classes,
|
|
493
513
|
handleTouchstart,
|
|
494
514
|
handleTouchmove,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { defineComponent, ref } from "vue";
|
|
1
|
+
import { computed, defineComponent, ref } from "vue";
|
|
2
2
|
import { useSwipe } from "./provide.mjs";
|
|
3
3
|
import { createNamespace } from "../utils/components.mjs";
|
|
4
|
+
import { toSizeUnit } from "../utils/elements.mjs";
|
|
4
5
|
const { name, n } = createNamespace("swipe-item");
|
|
5
6
|
import { renderSlot as _renderSlot, normalizeClass as _normalizeClass, normalizeStyle as _normalizeStyle, openBlock as _openBlock, createElementBlock as _createElementBlock, pushScopeId as _pushScopeId, popScopeId as _popScopeId } from "vue";
|
|
6
7
|
const _withScopeId = (n2) => (_pushScopeId(""), n2 = n2(), _popScopeId(), n2);
|
|
@@ -9,24 +10,28 @@ function __render__(_ctx, _cache) {
|
|
|
9
10
|
return _openBlock(), _createElementBlock("div", {
|
|
10
11
|
class: _normalizeClass(_ctx.n()),
|
|
11
12
|
style: _normalizeStyle({
|
|
12
|
-
width: !_ctx.vertical ?
|
|
13
|
-
height: _ctx.vertical ?
|
|
14
|
-
transform: `translate${_ctx.vertical ? "Y" : "X"}(${_ctx.translate}
|
|
13
|
+
width: !_ctx.vertical ? _ctx.toSizeUnit(_ctx.size) : void 0,
|
|
14
|
+
height: _ctx.vertical ? _ctx.toSizeUnit(_ctx.size) : void 0,
|
|
15
|
+
transform: `translate${_ctx.vertical ? "Y" : "X"}(${_ctx.toSizeUnit(_ctx.translate)})`
|
|
15
16
|
}),
|
|
16
17
|
tabindex: "-1",
|
|
17
|
-
"aria-hidden": _ctx.currentIndex
|
|
18
|
+
"aria-hidden": _ctx.currentIndex !== _ctx.index,
|
|
19
|
+
onFocus: _cache[0] || (_cache[0] = ($event) => _ctx.isFocusing = true),
|
|
20
|
+
onBlur: _cache[1] || (_cache[1] = ($event) => _ctx.isFocusing = false)
|
|
18
21
|
}, [
|
|
19
22
|
_renderSlot(_ctx.$slots, "default")
|
|
20
|
-
],
|
|
23
|
+
], 46, _hoisted_1);
|
|
21
24
|
}
|
|
22
25
|
const __sfc__ = defineComponent({
|
|
23
26
|
name,
|
|
24
27
|
setup() {
|
|
25
28
|
const translate = ref(0);
|
|
29
|
+
const isFocusing = ref(false);
|
|
26
30
|
const { swipe, bindSwipe, index } = useSwipe();
|
|
27
31
|
const { size, currentIndex, vertical } = swipe;
|
|
28
32
|
const swipeItemProvider = {
|
|
29
33
|
index,
|
|
34
|
+
isFocusing: computed(() => isFocusing.value),
|
|
30
35
|
setTranslate
|
|
31
36
|
};
|
|
32
37
|
bindSwipe(swipeItemProvider);
|
|
@@ -34,12 +39,14 @@ const __sfc__ = defineComponent({
|
|
|
34
39
|
translate.value = x;
|
|
35
40
|
}
|
|
36
41
|
return {
|
|
37
|
-
|
|
42
|
+
isFocusing,
|
|
38
43
|
size,
|
|
39
44
|
index,
|
|
40
45
|
currentIndex,
|
|
41
46
|
vertical,
|
|
42
|
-
translate
|
|
47
|
+
translate,
|
|
48
|
+
n,
|
|
49
|
+
toSizeUnit
|
|
43
50
|
};
|
|
44
51
|
}
|
|
45
52
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.var-swipe-item { flex-shrink: 0; width: 100%; height: 100%;}
|
|
1
|
+
.var-swipe-item { flex-shrink: 0; width: 100%; height: 100%;}.var-swipe-item:focus { outline: none;}
|