@hexdspace/react 0.1.44 → 0.1.46

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.d.ts CHANGED
@@ -933,6 +933,7 @@ declare function useVimController(): VimController;
933
933
 
934
934
  type VimBindingOptions = {
935
935
  enabled?: boolean;
936
+ allowArrowKeys?: boolean;
936
937
  };
937
938
  declare function useVimBindings(keyboardScopeId: string, options?: VimBindingOptions): void;
938
939
 
@@ -949,6 +950,7 @@ type UseVimRegionArgs = {
949
950
  focusOnCursorChange?: boolean;
950
951
  keyboardScopeId?: string;
951
952
  bindKeys?: boolean;
953
+ allowArrowKeys?: boolean;
952
954
  refreshDeps?: React__default.DependencyList;
953
955
  };
954
956
  type UseVimRegionResult = {
package/dist/index.js CHANGED
@@ -3370,7 +3370,7 @@ var VimHandleKeyUseCase = class {
3370
3370
  if (e.ctrlKey || e.metaKey || e.altKey) return;
3371
3371
  const scopeId = this.query.getActiveScope();
3372
3372
  if (!scopeId) return;
3373
- this.selection.exitSelectMode(scopeId);
3373
+ this.selection.clearSelection({ kind: "activeScope" });
3374
3374
  const st = this.stateByScope.get(scopeId);
3375
3375
  if (st) {
3376
3376
  st.count = "";
@@ -3637,6 +3637,7 @@ function notify(entry) {
3637
3637
  function useVimBindings(keyboardScopeId, options = {}) {
3638
3638
  const vim = useVimController();
3639
3639
  const enabled = options.enabled ?? true;
3640
+ const allowArrowKeys = options.allowArrowKeys ?? true;
3640
3641
  const ownerIdRef = useRef3(Symbol("vim-binding-owner"));
3641
3642
  const [isOwner, setIsOwner] = useState5(false);
3642
3643
  const handleOwnerChange = useCallback5((ownerId) => {
@@ -3690,12 +3691,38 @@ function useVimBindings(keyboardScopeId, options = {}) {
3690
3691
  group: "vim"
3691
3692
  });
3692
3693
  }
3694
+ const arrowCombos = allowArrowKeys ? {
3695
+ left: "ArrowLeft",
3696
+ down: "ArrowDown",
3697
+ up: "ArrowUp",
3698
+ right: "ArrowRight"
3699
+ } : { left: null, down: null, up: null, right: null };
3693
3700
  return [
3694
3701
  ...digitBindings,
3695
- { combos: [charCombo("h")], handler: onChar("h"), description: "vim: left", group: "vim" },
3696
- { combos: [charCombo("j")], handler: onChar("j"), description: "vim: down", group: "vim" },
3697
- { combos: [charCombo("k")], handler: onChar("k"), description: "vim: up", group: "vim" },
3698
- { combos: [charCombo("l")], handler: onChar("l"), description: "vim: right", group: "vim" },
3702
+ {
3703
+ combos: [charCombo("h"), arrowCombos.left].filter(Boolean),
3704
+ handler: onChar("h"),
3705
+ description: "vim: left",
3706
+ group: "vim"
3707
+ },
3708
+ {
3709
+ combos: [charCombo("j"), arrowCombos.down].filter(Boolean),
3710
+ handler: onChar("j"),
3711
+ description: "vim: down",
3712
+ group: "vim"
3713
+ },
3714
+ {
3715
+ combos: [charCombo("k"), arrowCombos.up].filter(Boolean),
3716
+ handler: onChar("k"),
3717
+ description: "vim: up",
3718
+ group: "vim"
3719
+ },
3720
+ {
3721
+ combos: [charCombo("l"), arrowCombos.right].filter(Boolean),
3722
+ handler: onChar("l"),
3723
+ description: "vim: right",
3724
+ group: "vim"
3725
+ },
3699
3726
  { combos: [charCombo("g")], handler: onChar("g"), description: "vim: g prefix", group: "vim" },
3700
3727
  { combos: [charCombo("G")], handler: onChar("G"), description: "vim: G", group: "vim" },
3701
3728
  {
@@ -3704,10 +3731,15 @@ function useVimBindings(keyboardScopeId, options = {}) {
3704
3731
  description: "vim: toggle select",
3705
3732
  group: "vim"
3706
3733
  },
3707
- { combos: [charCombo(" ")], handler: onChar(" "), description: "vim: toggle item", group: "vim" },
3734
+ {
3735
+ combos: ["Space"],
3736
+ handler: (e) => vim.handleCharKey(" ", e),
3737
+ description: "vim: toggle item",
3738
+ group: "vim"
3739
+ },
3708
3740
  { combos: ["Escape"], handler: (e) => vim.handleEscape(e), description: "vim: escape", group: "vim" }
3709
3741
  ];
3710
- }, [enabled, isOwner, vim]);
3742
+ }, [allowArrowKeys, enabled, isOwner, vim]);
3711
3743
  useShortcut(keyboardScopeId, bindings, { ignoreTyping: true, preventDefault: true });
3712
3744
  }
3713
3745
 
@@ -3790,7 +3822,7 @@ function useVimRegion(containerRef, args) {
3790
3822
  keyboard.handleEnableScope(keyboardScopeId);
3791
3823
  return () => keyboard.handleDisableScope(keyboardScopeId);
3792
3824
  }, [bindKeys, keyboard, keyboardScopeId]);
3793
- useVimBindings(keyboardScopeId, { enabled: bindKeys });
3825
+ useVimBindings(keyboardScopeId, { enabled: bindKeys, allowArrowKeys: args.allowArrowKeys });
3794
3826
  useSyncExternalStore(
3795
3827
  (listener) => selection.subscribe(listener),
3796
3828
  () => selection.getVersion(),
@@ -4758,11 +4790,7 @@ function DropdownMenu({
4758
4790
  children: /* @__PURE__ */ jsx22(
4759
4791
  motion4.div,
4760
4792
  {
4761
- className: cn(
4762
- dropdownMenuContentVariants({ chrome, orientation }),
4763
- className,
4764
- contentClassName
4765
- ),
4793
+ className: cn(dropdownMenuContentVariants({ chrome, orientation }), className, contentClassName),
4766
4794
  ref: composedContentRef,
4767
4795
  initial: initialMotionState,
4768
4796
  animate: openMotionState,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hexdspace/react",
3
- "version": "0.1.44",
3
+ "version": "0.1.46",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",