@manuscripts/style-guide 2.1.2-LEAN-4366.0 → 2.1.3
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.
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useMenus = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const menus_1 = require("../lib/menus");
|
|
6
|
-
const initialPointer = [-1, -1, -1];
|
|
6
|
+
const initialPointer = [-1, -1, -1, -1];
|
|
7
7
|
const transformPointer = (depth, index) => (pointer) => pointer.map((pointerPart, i) => {
|
|
8
8
|
if (i === depth) {
|
|
9
9
|
return index;
|
|
@@ -14,7 +14,8 @@ const transformPointer = (depth, index) => (pointer) => pointer.map((pointerPart
|
|
|
14
14
|
return pointerPart;
|
|
15
15
|
});
|
|
16
16
|
const isPart = (pointer, position) => {
|
|
17
|
-
const
|
|
17
|
+
const max = initialPointer.length;
|
|
18
|
+
const limit = position.length < max ? position.length : max;
|
|
18
19
|
for (let i = 0; i < limit; i++) {
|
|
19
20
|
if (position[i] !== pointer[i]) {
|
|
20
21
|
return false;
|
|
@@ -60,7 +61,7 @@ const useMenus = (menus) => {
|
|
|
60
61
|
}
|
|
61
62
|
if (menu.run) {
|
|
62
63
|
menu.run();
|
|
63
|
-
setPointer(
|
|
64
|
+
setPointer(initialPointer);
|
|
64
65
|
}
|
|
65
66
|
else if (menu.submenu) {
|
|
66
67
|
const depth = indices.length - 1;
|
|
@@ -72,7 +73,7 @@ const useMenus = (menus) => {
|
|
|
72
73
|
(0, react_1.useEffect)(() => {
|
|
73
74
|
const handleClickOutside = (event) => {
|
|
74
75
|
if (ref.current && !ref.current.contains(event.target)) {
|
|
75
|
-
setPointer(
|
|
76
|
+
setPointer(initialPointer);
|
|
76
77
|
}
|
|
77
78
|
};
|
|
78
79
|
document.addEventListener('click', handleClickOutside);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
2
|
import { isMenuSeparator, } from '../lib/menus';
|
|
3
|
-
const initialPointer = [-1, -1, -1];
|
|
3
|
+
const initialPointer = [-1, -1, -1, -1];
|
|
4
4
|
const transformPointer = (depth, index) => (pointer) => pointer.map((pointerPart, i) => {
|
|
5
5
|
if (i === depth) {
|
|
6
6
|
return index;
|
|
@@ -11,7 +11,8 @@ const transformPointer = (depth, index) => (pointer) => pointer.map((pointerPart
|
|
|
11
11
|
return pointerPart;
|
|
12
12
|
});
|
|
13
13
|
const isPart = (pointer, position) => {
|
|
14
|
-
const
|
|
14
|
+
const max = initialPointer.length;
|
|
15
|
+
const limit = position.length < max ? position.length : max;
|
|
15
16
|
for (let i = 0; i < limit; i++) {
|
|
16
17
|
if (position[i] !== pointer[i]) {
|
|
17
18
|
return false;
|
|
@@ -57,7 +58,7 @@ export const useMenus = (menus) => {
|
|
|
57
58
|
}
|
|
58
59
|
if (menu.run) {
|
|
59
60
|
menu.run();
|
|
60
|
-
setPointer(
|
|
61
|
+
setPointer(initialPointer);
|
|
61
62
|
}
|
|
62
63
|
else if (menu.submenu) {
|
|
63
64
|
const depth = indices.length - 1;
|
|
@@ -69,7 +70,7 @@ export const useMenus = (menus) => {
|
|
|
69
70
|
useEffect(() => {
|
|
70
71
|
const handleClickOutside = (event) => {
|
|
71
72
|
if (ref.current && !ref.current.contains(event.target)) {
|
|
72
|
-
setPointer(
|
|
73
|
+
setPointer(initialPointer);
|
|
73
74
|
}
|
|
74
75
|
};
|
|
75
76
|
document.addEventListener('click', handleClickOutside);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@manuscripts/style-guide",
|
|
3
3
|
"description": "Shared components for Manuscripts applications",
|
|
4
|
-
"version": "2.1.
|
|
4
|
+
"version": "2.1.3",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-style-guide",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|