@varlet/ui 3.8.0 → 3.8.2
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/index.bundle.mjs +1 -1
- package/es/index.mjs +1 -1
- package/es/menu-option/MenuOption.mjs +2 -4
- package/es/menu-select/MenuSelect.mjs +24 -1
- package/es/snackbar/style/index.mjs +1 -1
- package/es/utils/elements.mjs +14 -9
- package/es/varlet.esm.js +2529 -2511
- package/highlight/web-types.en-US.json +1 -1
- package/highlight/web-types.zh-CN.json +1 -1
- package/lib/varlet.cjs.js +41 -15
- package/package.json +7 -7
- package/umd/varlet.js +5 -5
package/lib/varlet.cjs.js
CHANGED
|
@@ -2589,36 +2589,41 @@ function isDisplayNoneElement(element) {
|
|
|
2589
2589
|
return false;
|
|
2590
2590
|
}
|
|
2591
2591
|
const focusableSelector = ["button", "input", "select", "textarea", "[tabindex]", "[href]"].map((s) => `${s}:not([disabled])`).join(", ");
|
|
2592
|
-
function focusChildElementByKey(
|
|
2593
|
-
var _a;
|
|
2592
|
+
function focusChildElementByKey(referenceElement, parentElement, key3, beforeFocus) {
|
|
2594
2593
|
const focusableElements = Array.from(parentElement.querySelectorAll(focusableSelector)).filter(
|
|
2595
2594
|
(element) => !isDisplayNoneElement(element)
|
|
2596
2595
|
);
|
|
2597
2596
|
if (!focusableElements.length) {
|
|
2598
2597
|
return;
|
|
2599
2598
|
}
|
|
2600
|
-
const
|
|
2599
|
+
const isActiveInReferenceElements = [referenceElement, ...Array.from(referenceElement.querySelectorAll(focusableSelector))].findIndex(
|
|
2601
2600
|
(el) => el === document.activeElement
|
|
2602
2601
|
) !== -1;
|
|
2603
2602
|
const activeElementIndex = Array.from(focusableElements).findIndex((el) => el === document.activeElement);
|
|
2604
2603
|
if (key3 === "ArrowDown") {
|
|
2605
|
-
if (
|
|
2606
|
-
focusableElements[0]
|
|
2604
|
+
if (isActiveInReferenceElements && activeElementIndex === -1 || activeElementIndex === focusableElements.length - 1) {
|
|
2605
|
+
focus(focusableElements[0]);
|
|
2607
2606
|
return;
|
|
2608
2607
|
}
|
|
2609
2608
|
if (activeElementIndex !== -1 && activeElementIndex < focusableElements.length - 1) {
|
|
2610
|
-
focusableElements[activeElementIndex + 1]
|
|
2609
|
+
focus(focusableElements[activeElementIndex + 1]);
|
|
2611
2610
|
return;
|
|
2612
2611
|
}
|
|
2613
2612
|
}
|
|
2614
2613
|
if (key3 === "ArrowUp") {
|
|
2615
|
-
if (
|
|
2616
|
-
(
|
|
2614
|
+
if (isActiveInReferenceElements && activeElementIndex === -1 || activeElementIndex === 0) {
|
|
2615
|
+
focus(focusableElements[focusableElements.length - 1]);
|
|
2617
2616
|
return;
|
|
2618
2617
|
}
|
|
2619
2618
|
if (activeElementIndex > 0) {
|
|
2620
|
-
focusableElements[activeElementIndex - 1]
|
|
2619
|
+
focus(focusableElements[activeElementIndex - 1]);
|
|
2620
|
+
}
|
|
2621
|
+
}
|
|
2622
|
+
function focus(nextActiveElement) {
|
|
2623
|
+
if (beforeFocus && !beforeFocus(document.activeElement, nextActiveElement, isActiveInReferenceElements)) {
|
|
2624
|
+
return;
|
|
2621
2625
|
}
|
|
2626
|
+
nextActiveElement.focus();
|
|
2622
2627
|
}
|
|
2623
2628
|
}
|
|
2624
2629
|
var __async$l = (__this, __arguments, generator) => {
|
|
@@ -7348,10 +7353,8 @@ const __sfc__$1k = vue.defineComponent({
|
|
|
7348
7353
|
if (!isFocusing.value && !((_a = checkbox.value) == null ? void 0 : _a.isFocusing)) {
|
|
7349
7354
|
return;
|
|
7350
7355
|
}
|
|
7351
|
-
if (event.key === "ArrowRight") {
|
|
7352
|
-
|
|
7353
|
-
}
|
|
7354
|
-
if (event.key === "ArrowLeft") {
|
|
7356
|
+
if (event.key === "ArrowRight" || event.key === "ArrowLeft") {
|
|
7357
|
+
preventDefault(event);
|
|
7355
7358
|
call(props2.onKeyArrowX, event.key);
|
|
7356
7359
|
}
|
|
7357
7360
|
if (!isFocusing.value) {
|
|
@@ -8054,8 +8057,31 @@ const __sfc__$1i = vue.defineComponent({
|
|
|
8054
8057
|
return;
|
|
8055
8058
|
}
|
|
8056
8059
|
if (key3 === "ArrowDown" || key3 === "ArrowUp") {
|
|
8057
|
-
focusChildElementByKey(
|
|
8060
|
+
focusChildElementByKey(
|
|
8061
|
+
menu.value.$el,
|
|
8062
|
+
menuOptionsRef.value,
|
|
8063
|
+
key3,
|
|
8064
|
+
(activeElement, nextActiveElement, isActiveInReferenceElements) => {
|
|
8065
|
+
if (isActiveInReferenceElements) {
|
|
8066
|
+
return true;
|
|
8067
|
+
}
|
|
8068
|
+
return getActiveElementParent(activeElement) === getActiveElementParent(nextActiveElement);
|
|
8069
|
+
}
|
|
8070
|
+
);
|
|
8071
|
+
}
|
|
8072
|
+
}
|
|
8073
|
+
function getActiveElementParent(activeElement) {
|
|
8074
|
+
var _a, _b, _c;
|
|
8075
|
+
if (activeElement.classList.contains("var-menu-option--children-trigger")) {
|
|
8076
|
+
return (_a = activeElement.parentNode) == null ? void 0 : _a.parentNode;
|
|
8077
|
+
}
|
|
8078
|
+
if (activeElement.classList.contains("var-checkbox__action")) {
|
|
8079
|
+
const optionElement = (_c = (_b = activeElement.parentNode) == null ? void 0 : _b.parentNode) == null ? void 0 : _c.parentNode;
|
|
8080
|
+
if (optionElement) {
|
|
8081
|
+
return getActiveElementParent(optionElement);
|
|
8082
|
+
}
|
|
8058
8083
|
}
|
|
8084
|
+
return activeElement.parentNode;
|
|
8059
8085
|
}
|
|
8060
8086
|
function allowChildrenClose(option) {
|
|
8061
8087
|
var _a;
|
|
@@ -31480,7 +31506,7 @@ withInstall(stdin_default$1);
|
|
|
31480
31506
|
withPropsDefaultsSetter(stdin_default$1, props);
|
|
31481
31507
|
const _WatermarkComponent = stdin_default$1;
|
|
31482
31508
|
var stdin_default = stdin_default$1;
|
|
31483
|
-
const version = "3.8.
|
|
31509
|
+
const version = "3.8.2";
|
|
31484
31510
|
function install(app) {
|
|
31485
31511
|
stdin_default$5X.install && app.use(stdin_default$5X);
|
|
31486
31512
|
stdin_default$5V.install && app.use(stdin_default$5V);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@varlet/ui",
|
|
3
|
-
"version": "3.8.
|
|
3
|
+
"version": "3.8.2",
|
|
4
4
|
"description": "A material like components library",
|
|
5
5
|
"main": "lib/varlet.cjs.js",
|
|
6
6
|
"module": "es/index.mjs",
|
|
@@ -48,9 +48,9 @@
|
|
|
48
48
|
"@popperjs/core": "^2.11.6",
|
|
49
49
|
"dayjs": "^1.10.4",
|
|
50
50
|
"decimal.js": "^10.2.1",
|
|
51
|
-
"@varlet/icons": "3.8.
|
|
52
|
-
"@varlet/
|
|
53
|
-
"@varlet/
|
|
51
|
+
"@varlet/icons": "3.8.2",
|
|
52
|
+
"@varlet/shared": "3.8.2",
|
|
53
|
+
"@varlet/use": "3.8.2"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@types/node": "^18.7.18",
|
|
@@ -66,9 +66,9 @@
|
|
|
66
66
|
"vue": "3.4.21",
|
|
67
67
|
"vue-router": "4.2.0",
|
|
68
68
|
"zod": "^3.23.8",
|
|
69
|
-
"@varlet/
|
|
70
|
-
"@varlet/touch-emulator": "3.8.
|
|
71
|
-
"@varlet/
|
|
69
|
+
"@varlet/cli": "3.8.2",
|
|
70
|
+
"@varlet/touch-emulator": "3.8.2",
|
|
71
|
+
"@varlet/ui": "3.8.2"
|
|
72
72
|
},
|
|
73
73
|
"scripts": {
|
|
74
74
|
"dev": "varlet-cli dev",
|