@varlet/ui 3.8.1 → 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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://raw.githubusercontent.com/JetBrains/web-types/master/schema/web-types.json",
3
3
  "framework": "vue",
4
- "version": "3.8.1",
4
+ "version": "3.8.2",
5
5
  "name": "VARLET",
6
6
  "contributions": {
7
7
  "html": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://raw.githubusercontent.com/JetBrains/web-types/master/schema/web-types.json",
3
3
  "framework": "vue",
4
- "version": "3.8.1",
4
+ "version": "3.8.2",
5
5
  "name": "VARLET",
6
6
  "contributions": {
7
7
  "html": {
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(hostElement, parentElement, key3) {
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 isActiveHostElement = [hostElement, ...Array.from(hostElement.querySelectorAll(focusableSelector))].findIndex(
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 (isActiveHostElement && activeElementIndex === -1 || activeElementIndex === focusableElements.length - 1) {
2606
- focusableElements[0].focus();
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].focus();
2609
+ focus(focusableElements[activeElementIndex + 1]);
2611
2610
  return;
2612
2611
  }
2613
2612
  }
2614
2613
  if (key3 === "ArrowUp") {
2615
- if (isActiveHostElement && activeElementIndex === -1 || activeElementIndex === 0) {
2616
- (_a = focusableElements[focusableElements.length - 1]) == null ? void 0 : _a.focus();
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].focus();
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) => {
@@ -8052,8 +8057,31 @@ const __sfc__$1i = vue.defineComponent({
8052
8057
  return;
8053
8058
  }
8054
8059
  if (key3 === "ArrowDown" || key3 === "ArrowUp") {
8055
- focusChildElementByKey(menu.value.$el, menuOptionsRef.value, key3);
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
+ }
8056
8083
  }
8084
+ return activeElement.parentNode;
8057
8085
  }
8058
8086
  function allowChildrenClose(option) {
8059
8087
  var _a;
@@ -31478,7 +31506,7 @@ withInstall(stdin_default$1);
31478
31506
  withPropsDefaultsSetter(stdin_default$1, props);
31479
31507
  const _WatermarkComponent = stdin_default$1;
31480
31508
  var stdin_default = stdin_default$1;
31481
- const version = "3.8.1";
31509
+ const version = "3.8.2";
31482
31510
  function install(app) {
31483
31511
  stdin_default$5X.install && app.use(stdin_default$5X);
31484
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.1",
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.1",
52
- "@varlet/use": "3.8.1",
53
- "@varlet/shared": "3.8.1"
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/touch-emulator": "3.8.1",
70
- "@varlet/ui": "3.8.1",
71
- "@varlet/cli": "3.8.1"
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",