@hexdspace/react 0.1.52 → 0.1.54

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
@@ -729,6 +729,7 @@ interface ShortcutRegistration {
729
729
  bindings: ShortcutBinding[];
730
730
  ignoreTyping?: boolean;
731
731
  preventDefault?: boolean;
732
+ blockWhileTyping?: (event: KeyboardEvent) => boolean;
732
733
  }
733
734
 
734
735
  interface ShortcutScope {
@@ -852,6 +853,7 @@ declare function useKeyboardController(): KeyboardController;
852
853
  declare function useShortcut(scopeId: string, bindings: ShortcutBinding[], opts?: {
853
854
  ignoreTyping?: boolean;
854
855
  preventDefault?: boolean;
856
+ blockWhileTyping?: (event: KeyboardEvent) => boolean;
855
857
  }): void;
856
858
 
857
859
  declare function useShortcutScope(scopeId: string, enabled?: boolean): void;
package/dist/index.js CHANGED
@@ -1697,6 +1697,7 @@ function Dialog({
1697
1697
  onKeyDown,
1698
1698
  ...props
1699
1699
  }) {
1700
+ const { "aria-describedby": ariaDescribedBy, ...contentProps } = props;
1700
1701
  const fallbackId = React3.useId();
1701
1702
  const resolvedRef = React3.useRef(false);
1702
1703
  const isControlled = open2 !== void 0;
@@ -1799,6 +1800,7 @@ function Dialog({
1799
1800
  {
1800
1801
  forceMount: true,
1801
1802
  asChild: true,
1803
+ "aria-describedby": ariaDescribedBy ?? void 0,
1802
1804
  onInteractOutside: (event) => {
1803
1805
  if (!dismissible) event.preventDefault();
1804
1806
  },
@@ -1812,7 +1814,7 @@ function Dialog({
1812
1814
  });
1813
1815
  },
1814
1816
  onKeyDown: handleKeyDown,
1815
- ...props,
1817
+ ...contentProps,
1816
1818
  children: /* @__PURE__ */ jsx7(
1817
1819
  motion.div,
1818
1820
  {
@@ -3004,7 +3006,7 @@ var RegisterShortcutUseCase = class {
3004
3006
  const id = uuid2();
3005
3007
  const reg = { preventDefault: true, ignoreTyping: true, ...regInput, id };
3006
3008
  const guard = (e) => {
3007
- if (reg.ignoreTyping && isTyping(e)) return false;
3009
+ if (reg.ignoreTyping && isTyping(e, reg.blockWhileTyping)) return false;
3008
3010
  return this.scopes.isScopeActive(reg.scopeId);
3009
3011
  };
3010
3012
  const handle = this.engine.register(reg.bindings, { guard, preventDefault: reg.preventDefault });
@@ -3028,11 +3030,12 @@ var RegisterShortcutUseCase = class {
3028
3030
  this.registry.removeByRegistration(id);
3029
3031
  }
3030
3032
  };
3031
- function isTyping(e) {
3033
+ function isTyping(e, blockWhileTyping) {
3032
3034
  const el = e.target;
3033
3035
  if (!el) return false;
3034
3036
  const inText = el.tagName === "INPUT" || el.tagName === "TEXTAREA" || el.isContentEditable;
3035
3037
  if (!inText) return false;
3038
+ if (blockWhileTyping?.(e)) return true;
3036
3039
  const k = e.key;
3037
3040
  const allow = k === "Escape" || k === "Tab" || k.startsWith("Arrow") || k === "PageUp" || k === "PageDown" || k === "Home" || k === "End" || e.ctrlKey || e.metaKey || e.altKey;
3038
3041
  return !allow;
@@ -3227,10 +3230,11 @@ function useShortcut(scopeId, bindings, opts) {
3227
3230
  scopeId,
3228
3231
  bindings: stableBindings,
3229
3232
  ignoreTyping: opts?.ignoreTyping ?? true,
3230
- preventDefault: opts?.preventDefault ?? true
3233
+ preventDefault: opts?.preventDefault ?? true,
3234
+ blockWhileTyping: opts?.blockWhileTyping
3231
3235
  });
3232
3236
  return () => controller.handleUnregisterShortcut(id);
3233
- }, [controller, stableBindings, opts?.ignoreTyping, opts?.preventDefault, scopeId]);
3237
+ }, [controller, stableBindings, opts?.ignoreTyping, opts?.preventDefault, opts?.blockWhileTyping, scopeId]);
3234
3238
  }
3235
3239
 
3236
3240
  // src/feature/keyboard/infra/web/react/useShortcutScope.tsx
@@ -3698,6 +3702,10 @@ function useVimBindings(regionKey, keyboardScopeId, options = {}) {
3698
3702
  setIsOwner(entry.ownerId === ownerIdRef.current);
3699
3703
  setModifierActionsVersion(entry.modifierActionsVersion);
3700
3704
  }, []);
3705
+ const blockWhileTyping = useCallback5(
3706
+ (e) => allowArrowKeys && e.key.startsWith("Arrow"),
3707
+ [allowArrowKeys]
3708
+ );
3701
3709
  useEffect7(() => {
3702
3710
  if (!enabled) {
3703
3711
  setIsOwner(false);
@@ -3853,7 +3861,11 @@ function useVimBindings(regionKey, keyboardScopeId, options = {}) {
3853
3861
  ...modifierBindings("ctrlShift", modifierAvailability?.ctrlShift)
3854
3862
  ];
3855
3863
  }, [allowArrowKeys, enabled, isOwner, keyboardScopeId, modifierActionsVersion, vim]);
3856
- useShortcut(keyboardScopeId, bindings, { ignoreTyping: true, preventDefault: true });
3864
+ useShortcut(keyboardScopeId, bindings, {
3865
+ ignoreTyping: true,
3866
+ preventDefault: true,
3867
+ blockWhileTyping
3868
+ });
3857
3869
  }
3858
3870
  function getModifierAvailability(keyboardScopeId) {
3859
3871
  const entry = scopeBindings.get(keyboardScopeId);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hexdspace/react",
3
- "version": "0.1.52",
3
+ "version": "0.1.54",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",