@hexdspace/react 0.1.51 → 0.1.53
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.js +82 -18
- package/package.json +1 -1
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
|
-
...
|
|
1817
|
+
...contentProps,
|
|
1816
1818
|
children: /* @__PURE__ */ jsx7(
|
|
1817
1819
|
motion.div,
|
|
1818
1820
|
{
|
|
@@ -3671,9 +3673,21 @@ import { useCallback as useCallback5, useEffect as useEffect7, useMemo as useMem
|
|
|
3671
3673
|
var scopeBindings = /* @__PURE__ */ new Map();
|
|
3672
3674
|
function notify(entry) {
|
|
3673
3675
|
for (const notifySub of entry.subscribers.values()) {
|
|
3674
|
-
notifySub(entry
|
|
3676
|
+
notifySub(entry);
|
|
3675
3677
|
}
|
|
3676
3678
|
}
|
|
3679
|
+
function getScopeEntry(keyboardScopeId) {
|
|
3680
|
+
const existing = scopeBindings.get(keyboardScopeId);
|
|
3681
|
+
if (existing) return existing;
|
|
3682
|
+
const entry = {
|
|
3683
|
+
ownerId: null,
|
|
3684
|
+
subscribers: /* @__PURE__ */ new Map(),
|
|
3685
|
+
modifierActionsByOwner: /* @__PURE__ */ new Map(),
|
|
3686
|
+
modifierActionsVersion: 0
|
|
3687
|
+
};
|
|
3688
|
+
scopeBindings.set(keyboardScopeId, entry);
|
|
3689
|
+
return entry;
|
|
3690
|
+
}
|
|
3677
3691
|
function useVimBindings(regionKey, keyboardScopeId, options = {}) {
|
|
3678
3692
|
const vim = useVimController();
|
|
3679
3693
|
const enabled = options.enabled ?? true;
|
|
@@ -3681,20 +3695,18 @@ function useVimBindings(regionKey, keyboardScopeId, options = {}) {
|
|
|
3681
3695
|
const modifierMovementActions = options.modifierMovementActions;
|
|
3682
3696
|
const ownerIdRef = useRef3(Symbol("vim-binding-owner"));
|
|
3683
3697
|
const [isOwner, setIsOwner] = useState5(false);
|
|
3684
|
-
const
|
|
3685
|
-
|
|
3698
|
+
const [modifierActionsVersion, setModifierActionsVersion] = useState5(0);
|
|
3699
|
+
const handleEntryChange = useCallback5((entry) => {
|
|
3700
|
+
setIsOwner(entry.ownerId === ownerIdRef.current);
|
|
3701
|
+
setModifierActionsVersion(entry.modifierActionsVersion);
|
|
3686
3702
|
}, []);
|
|
3687
3703
|
useEffect7(() => {
|
|
3688
3704
|
if (!enabled) {
|
|
3689
3705
|
setIsOwner(false);
|
|
3690
3706
|
return;
|
|
3691
3707
|
}
|
|
3692
|
-
const entry =
|
|
3693
|
-
|
|
3694
|
-
subscribers: /* @__PURE__ */ new Map()
|
|
3695
|
-
};
|
|
3696
|
-
scopeBindings.set(keyboardScopeId, entry);
|
|
3697
|
-
entry.subscribers.set(ownerIdRef.current, handleOwnerChange);
|
|
3708
|
+
const entry = getScopeEntry(keyboardScopeId);
|
|
3709
|
+
entry.subscribers.set(ownerIdRef.current, handleEntryChange);
|
|
3698
3710
|
if (!entry.ownerId) {
|
|
3699
3711
|
entry.ownerId = ownerIdRef.current;
|
|
3700
3712
|
}
|
|
@@ -3704,18 +3716,38 @@ function useVimBindings(regionKey, keyboardScopeId, options = {}) {
|
|
|
3704
3716
|
if (entry.ownerId === ownerIdRef.current) {
|
|
3705
3717
|
const nextOwner = entry.subscribers.keys().next().value ?? null;
|
|
3706
3718
|
entry.ownerId = nextOwner;
|
|
3707
|
-
if (!nextOwner && entry.subscribers.size === 0) {
|
|
3719
|
+
if (!nextOwner && entry.subscribers.size === 0 && entry.modifierActionsByOwner.size === 0) {
|
|
3708
3720
|
scopeBindings.delete(keyboardScopeId);
|
|
3709
3721
|
return;
|
|
3710
3722
|
}
|
|
3711
3723
|
notify(entry);
|
|
3712
3724
|
return;
|
|
3713
3725
|
}
|
|
3714
|
-
if (entry.subscribers.size === 0) {
|
|
3726
|
+
if (entry.subscribers.size === 0 && entry.modifierActionsByOwner.size === 0) {
|
|
3715
3727
|
scopeBindings.delete(keyboardScopeId);
|
|
3716
3728
|
}
|
|
3717
3729
|
};
|
|
3718
|
-
}, [enabled,
|
|
3730
|
+
}, [enabled, handleEntryChange, keyboardScopeId]);
|
|
3731
|
+
useEffect7(() => {
|
|
3732
|
+
if (!enabled) {
|
|
3733
|
+
return;
|
|
3734
|
+
}
|
|
3735
|
+
const entry = getScopeEntry(keyboardScopeId);
|
|
3736
|
+
entry.modifierActionsByOwner.set(ownerIdRef.current, modifierMovementActions ?? null);
|
|
3737
|
+
entry.modifierActionsVersion += 1;
|
|
3738
|
+
notify(entry);
|
|
3739
|
+
return () => {
|
|
3740
|
+
const existing = scopeBindings.get(keyboardScopeId);
|
|
3741
|
+
if (!existing) return;
|
|
3742
|
+
existing.modifierActionsByOwner.delete(ownerIdRef.current);
|
|
3743
|
+
existing.modifierActionsVersion += 1;
|
|
3744
|
+
if (!existing.ownerId && existing.subscribers.size === 0 && existing.modifierActionsByOwner.size === 0) {
|
|
3745
|
+
scopeBindings.delete(keyboardScopeId);
|
|
3746
|
+
return;
|
|
3747
|
+
}
|
|
3748
|
+
notify(existing);
|
|
3749
|
+
};
|
|
3750
|
+
}, [enabled, keyboardScopeId, modifierMovementActions]);
|
|
3719
3751
|
useEffect7(() => {
|
|
3720
3752
|
if (!enabled) {
|
|
3721
3753
|
vim.setModifierMovementActions(regionKey, null);
|
|
@@ -3757,11 +3789,12 @@ function useVimBindings(regionKey, keyboardScopeId, options = {}) {
|
|
|
3757
3789
|
shift: { label: "Shift", prefix: "Shift" },
|
|
3758
3790
|
ctrlShift: { label: "Ctrl+Shift", prefix: "Control+Shift" }
|
|
3759
3791
|
};
|
|
3792
|
+
const modifierAvailability = getModifierAvailability(keyboardScopeId);
|
|
3760
3793
|
const modifierBindings = (modifier, actions) => {
|
|
3761
3794
|
if (!actions) return [];
|
|
3762
3795
|
const { label, prefix } = modifierLabels[modifier];
|
|
3763
3796
|
return movementEntries.flatMap((entry) => {
|
|
3764
|
-
if (!actions
|
|
3797
|
+
if (!actions[entry.dir]) return [];
|
|
3765
3798
|
const combos = [`${prefix}+${entry.char.toUpperCase()}`];
|
|
3766
3799
|
if (entry.arrow) {
|
|
3767
3800
|
combos.push(`${prefix}+${entry.arrow}`);
|
|
@@ -3817,13 +3850,44 @@ function useVimBindings(regionKey, keyboardScopeId, options = {}) {
|
|
|
3817
3850
|
group: "vim"
|
|
3818
3851
|
},
|
|
3819
3852
|
{ combos: ["Escape"], handler: (e) => vim.handleEscape(e), description: "vim: escape", group: "vim" },
|
|
3820
|
-
...modifierBindings("ctrl",
|
|
3821
|
-
...modifierBindings("shift",
|
|
3822
|
-
...modifierBindings("ctrlShift",
|
|
3853
|
+
...modifierBindings("ctrl", modifierAvailability?.ctrl),
|
|
3854
|
+
...modifierBindings("shift", modifierAvailability?.shift),
|
|
3855
|
+
...modifierBindings("ctrlShift", modifierAvailability?.ctrlShift)
|
|
3823
3856
|
];
|
|
3824
|
-
}, [allowArrowKeys, enabled, isOwner,
|
|
3857
|
+
}, [allowArrowKeys, enabled, isOwner, keyboardScopeId, modifierActionsVersion, vim]);
|
|
3825
3858
|
useShortcut(keyboardScopeId, bindings, { ignoreTyping: true, preventDefault: true });
|
|
3826
3859
|
}
|
|
3860
|
+
function getModifierAvailability(keyboardScopeId) {
|
|
3861
|
+
const entry = scopeBindings.get(keyboardScopeId);
|
|
3862
|
+
if (!entry) return null;
|
|
3863
|
+
const result = {
|
|
3864
|
+
ctrl: {},
|
|
3865
|
+
shift: {},
|
|
3866
|
+
ctrlShift: {}
|
|
3867
|
+
};
|
|
3868
|
+
for (const actions of entry.modifierActionsByOwner.values()) {
|
|
3869
|
+
if (!actions) continue;
|
|
3870
|
+
const ctrl = actions.ctrl;
|
|
3871
|
+
if (ctrl) {
|
|
3872
|
+
for (const dir of Object.keys(ctrl)) {
|
|
3873
|
+
if (ctrl[dir]) result.ctrl[dir] = true;
|
|
3874
|
+
}
|
|
3875
|
+
}
|
|
3876
|
+
const shift = actions.shift;
|
|
3877
|
+
if (shift) {
|
|
3878
|
+
for (const dir of Object.keys(shift)) {
|
|
3879
|
+
if (shift[dir]) result.shift[dir] = true;
|
|
3880
|
+
}
|
|
3881
|
+
}
|
|
3882
|
+
const ctrlShift = actions.ctrlShift;
|
|
3883
|
+
if (ctrlShift) {
|
|
3884
|
+
for (const dir of Object.keys(ctrlShift)) {
|
|
3885
|
+
if (ctrlShift[dir]) result.ctrlShift[dir] = true;
|
|
3886
|
+
}
|
|
3887
|
+
}
|
|
3888
|
+
}
|
|
3889
|
+
return result;
|
|
3890
|
+
}
|
|
3827
3891
|
|
|
3828
3892
|
// src/feature/vim-navigation/infra/web/react/hook/use-vim-region.tsx
|
|
3829
3893
|
import { useEffect as useEffect9, useMemo as useMemo8, useRef as useRef4, useSyncExternalStore } from "react";
|