giggles 0.5.3 → 0.6.0
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.
|
@@ -400,9 +400,8 @@ var FocusStore = class {
|
|
|
400
400
|
});
|
|
401
401
|
const registration = {
|
|
402
402
|
bindings: new Map(entries),
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
passthrough: (options == null ? void 0 : options.passthrough) ? new Set(options.passthrough) : void 0
|
|
403
|
+
fallback: options == null ? void 0 : options.fallback,
|
|
404
|
+
bubble: (options == null ? void 0 : options.bubble) ? new Set(options.bubble) : void 0
|
|
406
405
|
};
|
|
407
406
|
if (!this.keybindings.has(nodeId)) {
|
|
408
407
|
this.keybindings.set(nodeId, /* @__PURE__ */ new Map());
|
|
@@ -422,28 +421,21 @@ var FocusStore = class {
|
|
|
422
421
|
const nodeRegistrations = this.keybindings.get(nodeId);
|
|
423
422
|
if (!nodeRegistrations || nodeRegistrations.size === 0) return void 0;
|
|
424
423
|
const mergedBindings = /* @__PURE__ */ new Map();
|
|
425
|
-
let
|
|
426
|
-
let
|
|
427
|
-
let finalPassthrough;
|
|
424
|
+
let finalFallback;
|
|
425
|
+
let finalBubble;
|
|
428
426
|
for (const registration of nodeRegistrations.values()) {
|
|
429
|
-
const
|
|
430
|
-
|
|
431
|
-
if (shouldIncludeBindings) {
|
|
432
|
-
for (const [key, entry] of registration.bindings) {
|
|
433
|
-
mergedBindings.set(key, entry);
|
|
434
|
-
}
|
|
427
|
+
for (const [key, entry] of registration.bindings) {
|
|
428
|
+
mergedBindings.set(key, entry);
|
|
435
429
|
}
|
|
436
|
-
if (registration.
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
finalPassthrough = registration.passthrough;
|
|
430
|
+
if (registration.fallback) {
|
|
431
|
+
finalFallback = registration.fallback;
|
|
432
|
+
finalBubble = registration.bubble;
|
|
440
433
|
}
|
|
441
434
|
}
|
|
442
435
|
return {
|
|
443
436
|
bindings: mergedBindings,
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
passthrough: finalPassthrough
|
|
437
|
+
fallback: finalFallback,
|
|
438
|
+
bubble: finalBubble
|
|
447
439
|
};
|
|
448
440
|
}
|
|
449
441
|
getAllBindings() {
|
|
@@ -466,21 +458,21 @@ var FocusStore = class {
|
|
|
466
458
|
// Input dispatch
|
|
467
459
|
// ---------------------------------------------------------------------------
|
|
468
460
|
// Bridge target for InputRouter. Walks the active branch path with passive-scope
|
|
469
|
-
// skipping,
|
|
461
|
+
// skipping, fallback handlers, and trap boundary — the full dispatch algorithm.
|
|
470
462
|
//
|
|
471
463
|
// Priority order (per node, walking focused → root):
|
|
472
464
|
// 1. Named bindings — always checked first
|
|
473
|
-
// 2.
|
|
474
|
-
//
|
|
475
|
-
// Keys in `
|
|
476
|
-
// 3. Trap boundary — stops the walk;
|
|
465
|
+
// 2. Fallback handler — deferred until after the full path walk, so named
|
|
466
|
+
// bindings at any ancestor still fire before the fallback kicks in.
|
|
467
|
+
// Keys in `bubble` skip the fallback and continue to the next ancestor.
|
|
468
|
+
// 3. Trap boundary — stops the walk; fallback inside the trap still fires.
|
|
477
469
|
dispatch(input, key) {
|
|
478
470
|
var _a;
|
|
479
471
|
const keyName = normalizeKey(input, key);
|
|
480
472
|
if (!keyName) return;
|
|
481
473
|
const path = this.getActiveBranchPath();
|
|
482
474
|
const trapNodeId = this.trapNodeId;
|
|
483
|
-
let
|
|
475
|
+
let pendingFallback;
|
|
484
476
|
for (const nodeId of path) {
|
|
485
477
|
if (this.passiveSet.has(nodeId)) continue;
|
|
486
478
|
const nodeBindings = this.getNodeBindings(nodeId);
|
|
@@ -490,18 +482,18 @@ var FocusStore = class {
|
|
|
490
482
|
entry.handler(input, key);
|
|
491
483
|
return;
|
|
492
484
|
}
|
|
493
|
-
if (!
|
|
494
|
-
if ((_a = nodeBindings.
|
|
485
|
+
if (!pendingFallback && nodeBindings.fallback) {
|
|
486
|
+
if ((_a = nodeBindings.bubble) == null ? void 0 : _a.has(keyName)) {
|
|
495
487
|
continue;
|
|
496
488
|
}
|
|
497
|
-
|
|
489
|
+
pendingFallback = nodeBindings.fallback;
|
|
498
490
|
}
|
|
499
491
|
}
|
|
500
492
|
if (nodeId === trapNodeId) {
|
|
501
493
|
break;
|
|
502
494
|
}
|
|
503
495
|
}
|
|
504
|
-
|
|
496
|
+
pendingFallback == null ? void 0 : pendingFallback(input, key);
|
|
505
497
|
}
|
|
506
498
|
// ---------------------------------------------------------------------------
|
|
507
499
|
// Private helpers
|
package/dist/index.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { BoxProps } from 'ink';
|
|
4
4
|
export { Key } from 'ink';
|
|
5
|
-
import { K as Keybindings, a as KeybindingOptions, R as RegisteredKeybinding } from './types-
|
|
6
|
-
export { b as KeyHandler } from './types-
|
|
5
|
+
import { K as Keybindings, a as KeybindingOptions, R as RegisteredKeybinding } from './types-HR6Vak_5.js';
|
|
6
|
+
export { b as KeyHandler } from './types-HR6Vak_5.js';
|
|
7
7
|
|
|
8
8
|
declare class GigglesError extends Error {
|
|
9
9
|
constructor(message: string);
|
package/dist/index.js
CHANGED
|
@@ -9,9 +9,8 @@ type KeybindingDefinition = KeyHandler | {
|
|
|
9
9
|
};
|
|
10
10
|
type Keybindings = Partial<Record<KeyName, KeybindingDefinition>>;
|
|
11
11
|
type KeybindingOptions = {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
passthrough?: string[];
|
|
12
|
+
fallback?: (input: string, key: Key) => void;
|
|
13
|
+
bubble?: string[];
|
|
15
14
|
};
|
|
16
15
|
type RegisteredKeybinding = {
|
|
17
16
|
nodeId: string;
|
package/dist/ui/index.d.ts
CHANGED
package/dist/ui/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
useFocusNode,
|
|
5
5
|
useKeybindingRegistry,
|
|
6
6
|
useKeybindings
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-QV7GQTKO.js";
|
|
8
8
|
import {
|
|
9
9
|
CodeBlock
|
|
10
10
|
} from "../chunk-SKSDNDQF.js";
|
|
@@ -77,8 +77,7 @@ function Inner({ onClose, render }) {
|
|
|
77
77
|
}
|
|
78
78
|
},
|
|
79
79
|
{
|
|
80
|
-
|
|
81
|
-
onKeypress: (input, key) => {
|
|
80
|
+
fallback: (input, key) => {
|
|
82
81
|
if (input.length === 1 && !key.ctrl) {
|
|
83
82
|
setQuery((q) => q + input);
|
|
84
83
|
setSelectedIndex(0);
|
|
@@ -178,15 +177,14 @@ function TextInput({ label, value, onChange, onSubmit, placeholder, render }) {
|
|
|
178
177
|
...onSubmit && { enter: () => onSubmit(value) }
|
|
179
178
|
},
|
|
180
179
|
{
|
|
181
|
-
|
|
182
|
-
passthrough: ["tab", "shift+tab", "enter", "escape", "backspace", "delete", "left", "right", "home", "end"],
|
|
183
|
-
onKeypress: (input, key) => {
|
|
180
|
+
fallback: (input, key) => {
|
|
184
181
|
if (input.length === 1 && !key.ctrl && !key.return && !key.escape && !key.tab) {
|
|
185
182
|
const c = cursorRef.current;
|
|
186
183
|
cursorRef.current = c + 1;
|
|
187
184
|
onChange(value.slice(0, c) + input + value.slice(c));
|
|
188
185
|
}
|
|
189
|
-
}
|
|
186
|
+
},
|
|
187
|
+
bubble: ["tab", "shift+tab", "enter", "escape", "backspace", "delete", "left", "right", "home", "end"]
|
|
190
188
|
}
|
|
191
189
|
);
|
|
192
190
|
const before = value.slice(0, cursor);
|
|
@@ -642,15 +640,14 @@ function Autocomplete({
|
|
|
642
640
|
}
|
|
643
641
|
},
|
|
644
642
|
{
|
|
645
|
-
|
|
646
|
-
passthrough: ["tab", "shift+tab", "escape"],
|
|
647
|
-
onKeypress: (input, key) => {
|
|
643
|
+
fallback: (input, key) => {
|
|
648
644
|
if (input.length === 1 && !key.ctrl && !key.return && !key.escape && !key.tab) {
|
|
649
645
|
const c = cursorRef.current;
|
|
650
646
|
cursorRef.current = c + 1;
|
|
651
647
|
updateQuery(query.slice(0, c) + input + query.slice(c));
|
|
652
648
|
}
|
|
653
|
-
}
|
|
649
|
+
},
|
|
650
|
+
bubble: ["tab", "shift+tab", "escape"]
|
|
654
651
|
}
|
|
655
652
|
);
|
|
656
653
|
const before = query.slice(0, cursor);
|