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
- capture: (options == null ? void 0 : options.capture) ?? false,
404
- onKeypress: options == null ? void 0 : options.onKeypress,
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 finalCapture = false;
426
- let finalOnKeypress;
427
- let finalPassthrough;
424
+ let finalFallback;
425
+ let finalBubble;
428
426
  for (const registration of nodeRegistrations.values()) {
429
- const isCaptureRegistration = registration.onKeypress !== void 0;
430
- const shouldIncludeBindings = !isCaptureRegistration || registration.capture;
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.capture) {
437
- finalCapture = true;
438
- finalOnKeypress = registration.onKeypress;
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
- capture: finalCapture,
445
- onKeypress: finalOnKeypress,
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, capture mode, and trap boundary — the full dispatch algorithm.
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. Capture mode (onKeypress) — deferred until after the full path walk,
474
- // so named bindings at any ancestor still fire before capture kicks in.
475
- // Keys in `passthrough` skip capture and bubble to the next ancestor.
476
- // 3. Trap boundary — stops the walk; capture inside the trap still fires.
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 pendingCapture;
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 (!pendingCapture && nodeBindings.capture && nodeBindings.onKeypress) {
494
- if ((_a = nodeBindings.passthrough) == null ? void 0 : _a.has(keyName)) {
485
+ if (!pendingFallback && nodeBindings.fallback) {
486
+ if ((_a = nodeBindings.bubble) == null ? void 0 : _a.has(keyName)) {
495
487
  continue;
496
488
  }
497
- pendingCapture = nodeBindings.onKeypress;
489
+ pendingFallback = nodeBindings.fallback;
498
490
  }
499
491
  }
500
492
  if (nodeId === trapNodeId) {
501
493
  break;
502
494
  }
503
495
  }
504
- pendingCapture == null ? void 0 : pendingCapture(input, key);
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-BODf7e7U.js';
6
- export { b as KeyHandler } from './types-BODf7e7U.js';
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
@@ -14,7 +14,7 @@ import {
14
14
  useKeybindingRegistry,
15
15
  useKeybindings,
16
16
  useStore
17
- } from "./chunk-RO3ZD423.js";
17
+ } from "./chunk-QV7GQTKO.js";
18
18
  import {
19
19
  ThemeProvider,
20
20
  useTheme
@@ -9,9 +9,8 @@ type KeybindingDefinition = KeyHandler | {
9
9
  };
10
10
  type Keybindings = Partial<Record<KeyName, KeybindingDefinition>>;
11
11
  type KeybindingOptions = {
12
- capture?: boolean;
13
- onKeypress?: (input: string, key: Key) => void;
14
- passthrough?: string[];
12
+ fallback?: (input: string, key: Key) => void;
13
+ bubble?: string[];
15
14
  };
16
15
  type RegisteredKeybinding = {
17
16
  nodeId: string;
@@ -1,5 +1,5 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { R as RegisteredKeybinding } from '../types-BODf7e7U.js';
2
+ import { R as RegisteredKeybinding } from '../types-HR6Vak_5.js';
3
3
  import React$1 from 'react';
4
4
  import { BoxProps } from 'ink';
5
5
 
package/dist/ui/index.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  useFocusNode,
5
5
  useKeybindingRegistry,
6
6
  useKeybindings
7
- } from "../chunk-RO3ZD423.js";
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
- capture: true,
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
- capture: true,
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
- capture: true,
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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "giggles",
3
- "version": "0.5.3",
3
+ "version": "0.6.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",