3157 refactor scoped states to move to v3 (#3180)
* renaming * renaming * create getDropdownScopeInjectors * update useDropdown * create internal hooks folder * update record-table states to be scoped states * update record-table selectors to be scoped selectors * create utils scope injector * refactor record-table wip * refactor record-table wip * wip * inject scopeId in selectors * update intenal hooks * update intenal hooks * update intenal hooks * update intenal hooks * update intenal hooks * update intenal hooks * update internal hooks * update internal hooks * update internal hooks * update internal hooks * update useTableColumns * update states and hooks * refactoring * refactoring * refactoring * refactoring * refactoring * refactoring * refactoring * refactoring * refactoring * fix scopeId not in context * fix lint errors * fix error in story * fix errors: wip * fix errors * fix error * fix jest test * fix scopeId not defined * fix jest test * Bug fixes --------- Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
@ -27,11 +27,10 @@ export const useSelectableListHotKeys = (
|
||||
}
|
||||
};
|
||||
|
||||
const { getSelectableListScopedSnapshotValue } = useSelectableListScopedState(
|
||||
{
|
||||
const { injectSnapshotValueWithSelectableListScopeId } =
|
||||
useSelectableListScopedState({
|
||||
selectableListScopeId: scopeId,
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
const handleSelect = useRecoilCallback(
|
||||
({ snapshot, set }) =>
|
||||
@ -42,11 +41,11 @@ export const useSelectableListHotKeys = (
|
||||
isSelectedItemIdFamilyScopeInjector,
|
||||
} = getSelectableListScopeInjectors();
|
||||
|
||||
const selectedItemId = getSelectableListScopedSnapshotValue(
|
||||
const selectedItemId = injectSnapshotValueWithSelectableListScopeId(
|
||||
snapshot,
|
||||
selectedItemIdScopeInjector,
|
||||
);
|
||||
const selectableItemIds = getSelectableListScopedSnapshotValue(
|
||||
const selectableItemIds = injectSnapshotValueWithSelectableListScopeId(
|
||||
snapshot,
|
||||
selectableItemIdsScopeInjector,
|
||||
);
|
||||
@ -120,7 +119,7 @@ export const useSelectableListHotKeys = (
|
||||
}
|
||||
}
|
||||
},
|
||||
[getSelectableListScopedSnapshotValue, scopeId],
|
||||
[injectSnapshotValueWithSelectableListScopeId, scopeId],
|
||||
);
|
||||
|
||||
useScopedHotkeys(Key.ArrowUp, () => handleSelect('up'), hotkeyScope, []);
|
||||
@ -145,12 +144,12 @@ export const useSelectableListHotKeys = (
|
||||
selectedItemIdScopeInjector,
|
||||
selectableListOnEnterScopeInjector,
|
||||
} = getSelectableListScopeInjectors();
|
||||
const selectedItemId = getSelectableListScopedSnapshotValue(
|
||||
const selectedItemId = injectSnapshotValueWithSelectableListScopeId(
|
||||
snapshot,
|
||||
selectedItemIdScopeInjector,
|
||||
);
|
||||
|
||||
const onEnter = getSelectableListScopedSnapshotValue(
|
||||
const onEnter = injectSnapshotValueWithSelectableListScopeId(
|
||||
snapshot,
|
||||
selectableListOnEnterScopeInjector,
|
||||
);
|
||||
@ -159,7 +158,7 @@ export const useSelectableListHotKeys = (
|
||||
onEnter?.(selectedItemId);
|
||||
}
|
||||
},
|
||||
[getSelectableListScopedSnapshotValue],
|
||||
[injectSnapshotValueWithSelectableListScopeId],
|
||||
),
|
||||
hotkeyScope,
|
||||
[],
|
||||
|
||||
@ -23,9 +23,10 @@ export const useSelectableListScopedState = ({
|
||||
|
||||
return {
|
||||
scopeId,
|
||||
getSelectableListScopedState: getScopedState,
|
||||
getSelectableListScopedFamilyState: getScopedFamilyState,
|
||||
getSelectableListScopedSnapshotValue: getScopedSnapshotValue,
|
||||
getSelectableListScopedFamilySnapshotValue: getScopedFamilySnapshotValue,
|
||||
injectStateWithSelectableListScopeId: getScopedState,
|
||||
injectFamilyStateWithSelectableListScopeId: getScopedFamilyState,
|
||||
injectSnapshotValueWithSelectableListScopeId: getScopedSnapshotValue,
|
||||
injectFamilySnapshotValueWithSelectableListScopeId:
|
||||
getScopedFamilySnapshotValue,
|
||||
};
|
||||
};
|
||||
|
||||
@ -3,13 +3,13 @@ import { useResetRecoilState, useSetRecoilState } from 'recoil';
|
||||
import { useSelectableListScopedState } from '@/ui/layout/selectable-list/hooks/internal/useSelectableListScopedState';
|
||||
import { getSelectableListScopeInjectors } from '@/ui/layout/selectable-list/utils/internal/getSelectableListScopeInjectors';
|
||||
|
||||
export const useSelectableList = (selectableListScopeId?: string) => {
|
||||
export const useSelectableList = (selectableListId?: string) => {
|
||||
const {
|
||||
getSelectableListScopedState,
|
||||
getSelectableListScopedFamilyState,
|
||||
injectStateWithSelectableListScopeId,
|
||||
injectFamilyStateWithSelectableListScopeId,
|
||||
scopeId,
|
||||
} = useSelectableListScopedState({
|
||||
selectableListScopeId,
|
||||
selectableListScopeId: selectableListId,
|
||||
});
|
||||
|
||||
const {
|
||||
@ -20,17 +20,18 @@ export const useSelectableList = (selectableListScopeId?: string) => {
|
||||
} = getSelectableListScopeInjectors();
|
||||
|
||||
const setSelectableItemIds = useSetRecoilState(
|
||||
getSelectableListScopedState(selectableItemIdsScopeInjector),
|
||||
injectStateWithSelectableListScopeId(selectableItemIdsScopeInjector),
|
||||
);
|
||||
const setSelectableListOnEnter = useSetRecoilState(
|
||||
getSelectableListScopedState(selectableListOnEnterScopeInjector),
|
||||
);
|
||||
const isSelectedItemIdFamilyState = getSelectableListScopedFamilyState(
|
||||
isSelectedItemIdFamilyScopeInjector,
|
||||
injectStateWithSelectableListScopeId(selectableListOnEnterScopeInjector),
|
||||
);
|
||||
const isSelectedItemIdFamilyState =
|
||||
injectFamilyStateWithSelectableListScopeId(
|
||||
isSelectedItemIdFamilyScopeInjector,
|
||||
);
|
||||
|
||||
const resetSelectedItemIdState = useResetRecoilState(
|
||||
getSelectableListScopedState(selectedItemIdScopeInjector),
|
||||
injectStateWithSelectableListScopeId(selectedItemIdScopeInjector),
|
||||
);
|
||||
|
||||
const resetSelectedItem = () => {
|
||||
|
||||
Reference in New Issue
Block a user