Refactor hotkyes in its own lib folder (#660)

* Refactor hotkyes in its own lib folder

* Lint

* Fix PR comments

* rename hotkeysScope into hotkeyScope
This commit is contained in:
Charles Bochet
2023-07-14 12:27:26 -07:00
committed by GitHub
parent 7bcea343e2
commit e93a96b3b1
71 changed files with 398 additions and 386 deletions
@@ -1,8 +1,7 @@
import { useRef } from 'react';
import { Key } from 'ts-key-enum';
import { useScopedHotkeys } from '@/hotkeys/hooks/useScopedHotkeys';
import { InternalHotkeysScope } from '@/hotkeys/types/internal/InternalHotkeysScope';
import { useScopedHotkeys } from '@/lib/hotkeys/hooks/useScopedHotkeys';
import { EntityForSelect } from '@/relation-picker/types/EntityForSelect';
import { DropdownMenuItem } from '@/ui/components/menu/DropdownMenuItem';
import { DropdownMenuItemContainer } from '@/ui/components/menu/DropdownMenuItemContainer';
@@ -11,6 +10,7 @@ import { Avatar } from '@/users/components/Avatar';
import { isDefined } from '@/utils/type-guards/isDefined';
import { useEntitySelectScroll } from '../hooks/useEntitySelectScroll';
import { RelationPickerHotkeyScope } from '../types/RelationPickerHotkeyScope';
import { CompanyPickerSkeleton } from './skeletons/CompanyPickerSkeleton';
import { DropdownMenuItemContainerSkeleton } from './skeletons/DropdownMenuItemContainerSkeleton';
@@ -50,7 +50,7 @@ export function SingleEntitySelectBase<
onEntitySelected(entitiesInDropdown[hoveredIndex]);
resetScroll();
},
InternalHotkeysScope.RelationPicker,
RelationPickerHotkeyScope.RelationPicker,
[entitiesInDropdown, hoveredIndex, onEntitySelected],
);
@@ -59,7 +59,7 @@ export function SingleEntitySelectBase<
() => {
onCancel?.();
},
InternalHotkeysScope.RelationPicker,
RelationPickerHotkeyScope.RelationPicker,
[onCancel],
);
@@ -1,12 +1,12 @@
import scrollIntoView from 'scroll-into-view';
import { Key } from 'ts-key-enum';
import { useScopedHotkeys } from '@/hotkeys/hooks/useScopedHotkeys';
import { InternalHotkeysScope } from '@/hotkeys/types/internal/InternalHotkeysScope';
import { useScopedHotkeys } from '@/lib/hotkeys/hooks/useScopedHotkeys';
import { useRecoilScopedState } from '@/recoil-scope/hooks/useRecoilScopedState';
import { relationPickerHoverIndexScopedState } from '../states/relationPickerHoverIndexScopedState';
import { EntityForSelect } from '../types/EntityForSelect';
import { RelationPickerHotkeyScope } from '../types/RelationPickerHotkeyScope';
export function useEntitySelectScroll<
CustomEntityForSelect extends EntityForSelect,
@@ -60,7 +60,7 @@ export function useEntitySelectScroll<
});
}
},
InternalHotkeysScope.RelationPicker,
RelationPickerHotkeyScope.RelationPicker,
[setHoveredIndex, entities],
);
@@ -87,7 +87,7 @@ export function useEntitySelectScroll<
});
}
},
InternalHotkeysScope.RelationPicker,
RelationPickerHotkeyScope.RelationPicker,
[setHoveredIndex, entities],
);
@@ -0,0 +1,3 @@
export enum RelationPickerHotkeyScope {
RelationPicker = 'relation-picker',
}