@nick-skriabin/glyph 0.1.35 → 0.1.37
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/dist/index.cjs +21 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +21 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -4371,8 +4371,11 @@ function JumpNav({
|
|
|
4371
4371
|
hintBg = "yellow",
|
|
4372
4372
|
hintFg = "black",
|
|
4373
4373
|
hintChars = "asdfghjklqwertyuiopzxcvbnm",
|
|
4374
|
-
enabled = true
|
|
4374
|
+
enabled = true,
|
|
4375
|
+
debug = false
|
|
4375
4376
|
}) {
|
|
4377
|
+
const log = debug ? (...args) => console.error("[JumpNav]", ...args) : () => {
|
|
4378
|
+
};
|
|
4376
4379
|
const [isActive, setIsActive] = React15.useState(false);
|
|
4377
4380
|
const [inputBuffer, setInputBuffer] = React15.useState("");
|
|
4378
4381
|
const [hasChildJumpNav, setHasChildJumpNav] = React15.useState(false);
|
|
@@ -4423,8 +4426,12 @@ function JumpNav({
|
|
|
4423
4426
|
return result;
|
|
4424
4427
|
}, [layoutCtx]);
|
|
4425
4428
|
const refreshElements = React15.useCallback(() => {
|
|
4426
|
-
if (!wrapperRef.current)
|
|
4429
|
+
if (!wrapperRef.current) {
|
|
4430
|
+
log("refreshElements: no wrapper ref");
|
|
4431
|
+
return;
|
|
4432
|
+
}
|
|
4427
4433
|
const descendants = findFocusableDescendants(wrapperRef.current);
|
|
4434
|
+
log("Found", descendants.length, "focusable elements");
|
|
4428
4435
|
descendants.sort((a, b) => {
|
|
4429
4436
|
if (a.layout.y !== b.layout.y) {
|
|
4430
4437
|
return a.layout.y - b.layout.y;
|
|
@@ -4432,7 +4439,7 @@ function JumpNav({
|
|
|
4432
4439
|
return a.layout.x - b.layout.x;
|
|
4433
4440
|
});
|
|
4434
4441
|
setElements(descendants);
|
|
4435
|
-
}, [findFocusableDescendants]);
|
|
4442
|
+
}, [findFocusableDescendants, log]);
|
|
4436
4443
|
const wasActiveRef = React15.useRef(false);
|
|
4437
4444
|
React15.useEffect(() => {
|
|
4438
4445
|
if (isActive && !wasActiveRef.current) {
|
|
@@ -4454,9 +4461,19 @@ function JumpNav({
|
|
|
4454
4461
|
return map;
|
|
4455
4462
|
}, [visibleElements, visibleHints]);
|
|
4456
4463
|
React15.useEffect(() => {
|
|
4457
|
-
|
|
4464
|
+
log("Mounted, inputCtx:", !!inputCtx, "enabled:", enabled, "activationKey:", activationKey);
|
|
4465
|
+
log("Parsed key:", activationKeyParsed);
|
|
4466
|
+
}, []);
|
|
4467
|
+
React15.useEffect(() => {
|
|
4468
|
+
if (!inputCtx || !enabled) {
|
|
4469
|
+
log("Not subscribing - inputCtx:", !!inputCtx, "enabled:", enabled);
|
|
4470
|
+
return;
|
|
4471
|
+
}
|
|
4472
|
+
log("Subscribing to priority input");
|
|
4458
4473
|
const handler = (key) => {
|
|
4474
|
+
log("Key received:", key.name, "ctrl:", key.ctrl, "isActive:", isActive, "hasChild:", hasChildJumpNav);
|
|
4459
4475
|
if (!isActive && !hasChildJumpNav && key.name === activationKeyParsed.name && !!key.ctrl === activationKeyParsed.ctrl && !!key.alt === activationKeyParsed.alt && !!key.shift === activationKeyParsed.shift && !!key.meta === activationKeyParsed.meta) {
|
|
4476
|
+
log("Activation key matched! Activating...");
|
|
4460
4477
|
setIsActive(true);
|
|
4461
4478
|
setInputBuffer("");
|
|
4462
4479
|
return true;
|