Update recoil v4 states to getters (#3451)
Update v4 states to getters Co-authored-by: Thomas Trompette <thomast@twenty.com>
This commit is contained in:
@ -69,8 +69,8 @@ export const TaskGroups = ({
|
|||||||
|
|
||||||
const openCreateActivity = useOpenCreateActivityDrawer();
|
const openCreateActivity = useOpenCreateActivityDrawer();
|
||||||
|
|
||||||
const { activeTabIdState } = useTabList(TASKS_TAB_LIST_COMPONENT_ID);
|
const { getActiveTabIdState } = useTabList(TASKS_TAB_LIST_COMPONENT_ID);
|
||||||
const activeTabId = useRecoilValue(activeTabIdState());
|
const activeTabId = useRecoilValue(getActiveTabIdState());
|
||||||
|
|
||||||
if (
|
if (
|
||||||
(activeTabId !== 'done' &&
|
(activeTabId !== 'done' &&
|
||||||
|
|||||||
@ -26,12 +26,15 @@ export const useObjectRecordTable = (objectNamePlural: string) => {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
const { tableFiltersState, tableSortsState, tableLastRowVisibleState } =
|
const {
|
||||||
useRecordTableStates();
|
getTableFiltersState,
|
||||||
|
getTableSortsState,
|
||||||
|
getTableLastRowVisibleState,
|
||||||
|
} = useRecordTableStates();
|
||||||
|
|
||||||
const tableFilters = useRecoilValue(tableFiltersState());
|
const tableFilters = useRecoilValue(getTableFiltersState());
|
||||||
const tableSorts = useRecoilValue(tableSortsState());
|
const tableSorts = useRecoilValue(getTableSortsState());
|
||||||
const setLastRowVisible = useSetRecoilState(tableLastRowVisibleState());
|
const setLastRowVisible = useSetRecoilState(getTableLastRowVisibleState());
|
||||||
|
|
||||||
const requestFilters = turnObjectDropdownFilterIntoQueryFilter(
|
const requestFilters = turnObjectDropdownFilterIntoQueryFilter(
|
||||||
tableFilters,
|
tableFilters,
|
||||||
|
|||||||
@ -11,9 +11,9 @@ type RecordTableBodyProps = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const RecordTableBody = ({ objectNamePlural }: RecordTableBodyProps) => {
|
export const RecordTableBody = ({ objectNamePlural }: RecordTableBodyProps) => {
|
||||||
const { tableRowIdsState } = useRecordTableStates();
|
const { getTableRowIdsState } = useRecordTableStates();
|
||||||
|
|
||||||
const tableRowIds = useRecoilValue(tableRowIdsState());
|
const tableRowIds = useRecoilValue(getTableRowIdsState());
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@ -20,10 +20,10 @@ export const RecordTableBodyEffect = ({
|
|||||||
loading,
|
loading,
|
||||||
} = useObjectRecordTable(objectNamePlural);
|
} = useObjectRecordTable(objectNamePlural);
|
||||||
|
|
||||||
const { tableLastRowVisibleState } = useRecordTableStates();
|
const { getTableLastRowVisibleState } = useRecordTableStates();
|
||||||
|
|
||||||
const [tableLastRowVisible, setTableLastRowVisible] = useRecoilState(
|
const [tableLastRowVisible, setTableLastRowVisible] = useRecoilState(
|
||||||
tableLastRowVisibleState(),
|
getTableLastRowVisibleState(),
|
||||||
);
|
);
|
||||||
|
|
||||||
const isFetchingMoreObjects = useRecoilValue(
|
const isFetchingMoreObjects = useRecoilValue(
|
||||||
|
|||||||
@ -25,9 +25,9 @@ export const RecordTableCellContainer = ({
|
|||||||
const setContextMenuPosition = useSetRecoilState(contextMenuPositionState);
|
const setContextMenuPosition = useSetRecoilState(contextMenuPositionState);
|
||||||
const setContextMenuOpenState = useSetRecoilState(contextMenuIsOpenState);
|
const setContextMenuOpenState = useSetRecoilState(contextMenuIsOpenState);
|
||||||
const currentRowId = useContext(RowIdContext);
|
const currentRowId = useContext(RowIdContext);
|
||||||
const { objectMetadataConfigState } = useRecordTableStates();
|
const { getObjectMetadataConfigState } = useRecordTableStates();
|
||||||
|
|
||||||
const objectMetadataConfig = useRecoilValue(objectMetadataConfigState());
|
const objectMetadataConfig = useRecoilValue(getObjectMetadataConfigState());
|
||||||
|
|
||||||
const { setCurrentRowSelected } = useCurrentRowSelected();
|
const { setCurrentRowSelected } = useCurrentRowSelected();
|
||||||
|
|
||||||
|
|||||||
@ -81,17 +81,17 @@ export const RecordTableHeaderCell = ({
|
|||||||
createRecord: () => void;
|
createRecord: () => void;
|
||||||
}) => {
|
}) => {
|
||||||
const {
|
const {
|
||||||
resizeFieldOffsetState,
|
getResizeFieldOffsetState,
|
||||||
tableColumnsState,
|
getTableColumnsState,
|
||||||
tableColumnsByKeySelector,
|
tableColumnsByKeySelector,
|
||||||
visibleTableColumnsSelector,
|
visibleTableColumnsSelector,
|
||||||
} = useRecordTableStates();
|
} = useRecordTableStates();
|
||||||
|
|
||||||
const [resizeFieldOffset, setResizeFieldOffset] = useRecoilState(
|
const [resizeFieldOffset, setResizeFieldOffset] = useRecoilState(
|
||||||
resizeFieldOffsetState(),
|
getResizeFieldOffsetState(),
|
||||||
);
|
);
|
||||||
|
|
||||||
const tableColumns = useRecoilValue(tableColumnsState());
|
const tableColumns = useRecoilValue(getTableColumnsState());
|
||||||
const tableColumnsByKey = useRecoilValue(tableColumnsByKeySelector);
|
const tableColumnsByKey = useRecoilValue(tableColumnsByKeySelector);
|
||||||
const visibleTableColumns = useRecoilValue(visibleTableColumnsSelector);
|
const visibleTableColumns = useRecoilValue(visibleTableColumnsSelector);
|
||||||
|
|
||||||
@ -127,7 +127,7 @@ export const RecordTableHeaderCell = ({
|
|||||||
|
|
||||||
const resizeFieldOffset = getSnapshotValue(
|
const resizeFieldOffset = getSnapshotValue(
|
||||||
snapshot,
|
snapshot,
|
||||||
resizeFieldOffsetState(),
|
getResizeFieldOffsetState(),
|
||||||
);
|
);
|
||||||
|
|
||||||
const nextWidth = Math.round(
|
const nextWidth = Math.round(
|
||||||
@ -137,7 +137,7 @@ export const RecordTableHeaderCell = ({
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
set(resizeFieldOffsetState(), 0);
|
set(getResizeFieldOffsetState(), 0);
|
||||||
setInitialPointerPositionX(null);
|
setInitialPointerPositionX(null);
|
||||||
setResizedFieldKey(null);
|
setResizedFieldKey(null);
|
||||||
|
|
||||||
@ -153,8 +153,8 @@ export const RecordTableHeaderCell = ({
|
|||||||
},
|
},
|
||||||
[
|
[
|
||||||
resizedFieldKey,
|
resizedFieldKey,
|
||||||
|
getResizeFieldOffsetState,
|
||||||
tableColumnsByKey,
|
tableColumnsByKey,
|
||||||
resizeFieldOffsetState,
|
|
||||||
tableColumns,
|
tableColumns,
|
||||||
handleColumnsChange,
|
handleColumnsChange,
|
||||||
],
|
],
|
||||||
|
|||||||
@ -82,13 +82,13 @@ export const RecordTableWithWrappers = ({
|
|||||||
}: RecordTableWithWrappersProps) => {
|
}: RecordTableWithWrappersProps) => {
|
||||||
const tableBodyRef = useRef<HTMLDivElement>(null);
|
const tableBodyRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
const { numberOfTableRowsState, isRecordTableInitialLoadingState } =
|
const { getNumberOfTableRowsState, getIsRecordTableInitialLoadingState } =
|
||||||
useRecordTableStates(recordTableId);
|
useRecordTableStates(recordTableId);
|
||||||
|
|
||||||
const numberOfTableRows = useRecoilValue(numberOfTableRowsState());
|
const numberOfTableRows = useRecoilValue(getNumberOfTableRowsState());
|
||||||
|
|
||||||
const isRecordTableInitialLoading = useRecoilValue(
|
const isRecordTableInitialLoading = useRecoilValue(
|
||||||
isRecordTableInitialLoadingState(),
|
getIsRecordTableInitialLoadingState(),
|
||||||
);
|
);
|
||||||
|
|
||||||
const { resetTableRowSelection, setRowSelectedState } = useRecordTable({
|
const { resetTableRowSelection, setRowSelectedState } = useRecordTable({
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import { getSnapshotValue } from '@/ui/utilities/recoil-scope/utils/getSnapshotV
|
|||||||
|
|
||||||
export const useCloseCurrentTableCellInEditMode = (recordTableId?: string) => {
|
export const useCloseCurrentTableCellInEditMode = (recordTableId?: string) => {
|
||||||
const {
|
const {
|
||||||
currentTableCellInEditModePositionState,
|
getCurrentTableCellInEditModePositionState,
|
||||||
isTableCellInEditModeFamilyState,
|
isTableCellInEditModeFamilyState,
|
||||||
} = useRecordTableStates(recordTableId);
|
} = useRecordTableStates(recordTableId);
|
||||||
|
|
||||||
@ -14,7 +14,7 @@ export const useCloseCurrentTableCellInEditMode = (recordTableId?: string) => {
|
|||||||
return async () => {
|
return async () => {
|
||||||
const currentTableCellInEditModePosition = getSnapshotValue(
|
const currentTableCellInEditModePosition = getSnapshotValue(
|
||||||
snapshot,
|
snapshot,
|
||||||
currentTableCellInEditModePositionState(),
|
getCurrentTableCellInEditModePositionState(),
|
||||||
);
|
);
|
||||||
|
|
||||||
set(
|
set(
|
||||||
@ -23,6 +23,9 @@ export const useCloseCurrentTableCellInEditMode = (recordTableId?: string) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
[currentTableCellInEditModePositionState, isTableCellInEditModeFamilyState],
|
[
|
||||||
|
getCurrentTableCellInEditModePositionState,
|
||||||
|
isTableCellInEditModeFamilyState,
|
||||||
|
],
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -5,8 +5,8 @@ import { getSnapshotValue } from '@/ui/utilities/recoil-scope/utils/getSnapshotV
|
|||||||
|
|
||||||
export const useDisableSoftFocus = (recordTableId?: string) => {
|
export const useDisableSoftFocus = (recordTableId?: string) => {
|
||||||
const {
|
const {
|
||||||
softFocusPositionState,
|
getSoftFocusPositionState,
|
||||||
isSoftFocusActiveState,
|
getIsSoftFocusActiveState,
|
||||||
isSoftFocusOnTableCellFamilyState,
|
isSoftFocusOnTableCellFamilyState,
|
||||||
} = useRecordTableStates(recordTableId);
|
} = useRecordTableStates(recordTableId);
|
||||||
|
|
||||||
@ -15,18 +15,18 @@ export const useDisableSoftFocus = (recordTableId?: string) => {
|
|||||||
return () => {
|
return () => {
|
||||||
const currentPosition = getSnapshotValue(
|
const currentPosition = getSnapshotValue(
|
||||||
snapshot,
|
snapshot,
|
||||||
softFocusPositionState(),
|
getSoftFocusPositionState(),
|
||||||
);
|
);
|
||||||
|
|
||||||
set(isSoftFocusActiveState(), false);
|
set(getIsSoftFocusActiveState(), false);
|
||||||
|
|
||||||
set(isSoftFocusOnTableCellFamilyState(currentPosition), false);
|
set(isSoftFocusOnTableCellFamilyState(currentPosition), false);
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
[
|
[
|
||||||
isSoftFocusActiveState,
|
getIsSoftFocusActiveState,
|
||||||
|
getSoftFocusPositionState,
|
||||||
isSoftFocusOnTableCellFamilyState,
|
isSoftFocusOnTableCellFamilyState,
|
||||||
softFocusPositionState,
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import { getSnapshotValue } from '@/ui/utilities/recoil-scope/utils/getSnapshotV
|
|||||||
|
|
||||||
export const useGetIsSomeCellInEditModeState = (recordTableId?: string) => {
|
export const useGetIsSomeCellInEditModeState = (recordTableId?: string) => {
|
||||||
const {
|
const {
|
||||||
currentTableCellInEditModePositionState,
|
getCurrentTableCellInEditModePositionState,
|
||||||
isTableCellInEditModeFamilyState,
|
isTableCellInEditModeFamilyState,
|
||||||
} = useRecordTableStates(recordTableId);
|
} = useRecordTableStates(recordTableId);
|
||||||
|
|
||||||
@ -14,7 +14,7 @@ export const useGetIsSomeCellInEditModeState = (recordTableId?: string) => {
|
|||||||
() => {
|
() => {
|
||||||
const currentTableCellInEditModePosition = getSnapshotValue(
|
const currentTableCellInEditModePosition = getSnapshotValue(
|
||||||
snapshot,
|
snapshot,
|
||||||
currentTableCellInEditModePositionState(),
|
getCurrentTableCellInEditModePositionState(),
|
||||||
);
|
);
|
||||||
|
|
||||||
const isSomeCellInEditModeState = isTableCellInEditModeFamilyState(
|
const isSomeCellInEditModeState = isTableCellInEditModeFamilyState(
|
||||||
@ -23,6 +23,9 @@ export const useGetIsSomeCellInEditModeState = (recordTableId?: string) => {
|
|||||||
|
|
||||||
return isSomeCellInEditModeState;
|
return isSomeCellInEditModeState;
|
||||||
},
|
},
|
||||||
[currentTableCellInEditModePositionState, isTableCellInEditModeFamilyState],
|
[
|
||||||
|
getCurrentTableCellInEditModePositionState,
|
||||||
|
isTableCellInEditModeFamilyState,
|
||||||
|
],
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -14,14 +14,14 @@ export const useLeaveTableFocus = (recordTableId?: string) => {
|
|||||||
const closeCurrentCellInEditMode =
|
const closeCurrentCellInEditMode =
|
||||||
useCloseCurrentTableCellInEditMode(recordTableId);
|
useCloseCurrentTableCellInEditMode(recordTableId);
|
||||||
|
|
||||||
const { isSoftFocusActiveState } = useRecordTableStates(recordTableId);
|
const { getIsSoftFocusActiveState } = useRecordTableStates(recordTableId);
|
||||||
|
|
||||||
return useRecoilCallback(
|
return useRecoilCallback(
|
||||||
({ snapshot }) =>
|
({ snapshot }) =>
|
||||||
() => {
|
() => {
|
||||||
const isSoftFocusActive = getSnapshotValue(
|
const isSoftFocusActive = getSnapshotValue(
|
||||||
snapshot,
|
snapshot,
|
||||||
isSoftFocusActiveState(),
|
getIsSoftFocusActiveState(),
|
||||||
);
|
);
|
||||||
|
|
||||||
const currentHotkeyScope = snapshot
|
const currentHotkeyScope = snapshot
|
||||||
@ -39,6 +39,6 @@ export const useLeaveTableFocus = (recordTableId?: string) => {
|
|||||||
closeCurrentCellInEditMode();
|
closeCurrentCellInEditMode();
|
||||||
disableSoftFocus();
|
disableSoftFocus();
|
||||||
},
|
},
|
||||||
[closeCurrentCellInEditMode, disableSoftFocus, isSoftFocusActiveState],
|
[closeCurrentCellInEditMode, disableSoftFocus, getIsSoftFocusActiveState],
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -8,7 +8,7 @@ import { TableCellPosition } from '../../types/TableCellPosition';
|
|||||||
export const useMoveEditModeToTableCellPosition = (recordTableId?: string) => {
|
export const useMoveEditModeToTableCellPosition = (recordTableId?: string) => {
|
||||||
const {
|
const {
|
||||||
isTableCellInEditModeFamilyState,
|
isTableCellInEditModeFamilyState,
|
||||||
currentTableCellInEditModePositionState,
|
getCurrentTableCellInEditModePositionState,
|
||||||
} = useRecordTableStates(recordTableId);
|
} = useRecordTableStates(recordTableId);
|
||||||
|
|
||||||
return useRecoilCallback(
|
return useRecoilCallback(
|
||||||
@ -16,7 +16,7 @@ export const useMoveEditModeToTableCellPosition = (recordTableId?: string) => {
|
|||||||
return (newPosition: TableCellPosition) => {
|
return (newPosition: TableCellPosition) => {
|
||||||
const currentTableCellInEditModePosition = getSnapshotValue(
|
const currentTableCellInEditModePosition = getSnapshotValue(
|
||||||
snapshot,
|
snapshot,
|
||||||
currentTableCellInEditModePositionState(),
|
getCurrentTableCellInEditModePositionState(),
|
||||||
);
|
);
|
||||||
|
|
||||||
set(
|
set(
|
||||||
@ -24,11 +24,14 @@ export const useMoveEditModeToTableCellPosition = (recordTableId?: string) => {
|
|||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
|
|
||||||
set(currentTableCellInEditModePositionState(), newPosition);
|
set(getCurrentTableCellInEditModePositionState(), newPosition);
|
||||||
|
|
||||||
set(isTableCellInEditModeFamilyState(newPosition), true);
|
set(isTableCellInEditModeFamilyState(newPosition), true);
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
[currentTableCellInEditModePositionState, isTableCellInEditModeFamilyState],
|
[
|
||||||
|
getCurrentTableCellInEditModePositionState,
|
||||||
|
isTableCellInEditModeFamilyState,
|
||||||
|
],
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -37,29 +37,35 @@ export const useRecordTableStates = (recordTableId?: string) => {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
scopeId,
|
scopeId,
|
||||||
availableTableColumnsState: getState(
|
getAvailableTableColumnsState: getState(
|
||||||
availableTableColumnsStateScopeMap,
|
availableTableColumnsStateScopeMap,
|
||||||
scopeId,
|
scopeId,
|
||||||
),
|
),
|
||||||
tableFiltersState: getState(tableFiltersStateScopeMap, scopeId),
|
getTableFiltersState: getState(tableFiltersStateScopeMap, scopeId),
|
||||||
tableSortsState: getState(tableSortsStateScopeMap, scopeId),
|
getTableSortsState: getState(tableSortsStateScopeMap, scopeId),
|
||||||
tableColumnsState: getState(tableColumnsStateScopeMap, scopeId),
|
getTableColumnsState: getState(tableColumnsStateScopeMap, scopeId),
|
||||||
objectMetadataConfigState: getState(
|
getObjectMetadataConfigState: getState(
|
||||||
objectMetadataConfigStateScopeMap,
|
objectMetadataConfigStateScopeMap,
|
||||||
scopeId,
|
scopeId,
|
||||||
),
|
),
|
||||||
onColumnsChangeState: getState(onColumnsChangeStateScopeMap, scopeId),
|
getOnColumnsChangeState: getState(onColumnsChangeStateScopeMap, scopeId),
|
||||||
onEntityCountChangeState: getState(
|
getOnEntityCountChangeState: getState(
|
||||||
onEntityCountChangeStateScopeMap,
|
onEntityCountChangeStateScopeMap,
|
||||||
scopeId,
|
scopeId,
|
||||||
),
|
),
|
||||||
tableLastRowVisibleState: getState(
|
getTableLastRowVisibleState: getState(
|
||||||
tableLastRowVisibleStateScopeMap,
|
tableLastRowVisibleStateScopeMap,
|
||||||
scopeId,
|
scopeId,
|
||||||
),
|
),
|
||||||
softFocusPositionState: getState(softFocusPositionStateScopeMap, scopeId),
|
getSoftFocusPositionState: getState(
|
||||||
numberOfTableRowsState: getState(numberOfTableRowsStateScopeMap, scopeId),
|
softFocusPositionStateScopeMap,
|
||||||
currentTableCellInEditModePositionState: getState(
|
scopeId,
|
||||||
|
),
|
||||||
|
getNumberOfTableRowsState: getState(
|
||||||
|
numberOfTableRowsStateScopeMap,
|
||||||
|
scopeId,
|
||||||
|
),
|
||||||
|
getCurrentTableCellInEditModePositionState: getState(
|
||||||
currentTableCellInEditModePositionStateScopeMap,
|
currentTableCellInEditModePositionStateScopeMap,
|
||||||
scopeId,
|
scopeId,
|
||||||
),
|
),
|
||||||
@ -67,21 +73,27 @@ export const useRecordTableStates = (recordTableId?: string) => {
|
|||||||
isTableCellInEditModeFamilyStateScopeMap,
|
isTableCellInEditModeFamilyStateScopeMap,
|
||||||
scopeId,
|
scopeId,
|
||||||
),
|
),
|
||||||
isSoftFocusActiveState: getState(isSoftFocusActiveStateScopeMap, scopeId),
|
getIsSoftFocusActiveState: getState(
|
||||||
|
isSoftFocusActiveStateScopeMap,
|
||||||
|
scopeId,
|
||||||
|
),
|
||||||
|
getTableRowIdsState: getState(tableRowIdsStateScopeMap, scopeId),
|
||||||
|
getIsRecordTableInitialLoadingState: getState(
|
||||||
|
isRecordTableInitialLoadingStateScopeMap,
|
||||||
|
scopeId,
|
||||||
|
),
|
||||||
|
getResizeFieldOffsetState: getState(
|
||||||
|
resizeFieldOffsetStateScopeMap,
|
||||||
|
scopeId,
|
||||||
|
),
|
||||||
isSoftFocusOnTableCellFamilyState: getFamilyState(
|
isSoftFocusOnTableCellFamilyState: getFamilyState(
|
||||||
isSoftFocusOnTableCellFamilyStateScopeMap,
|
isSoftFocusOnTableCellFamilyStateScopeMap,
|
||||||
scopeId,
|
scopeId,
|
||||||
),
|
),
|
||||||
tableRowIdsState: getState(tableRowIdsStateScopeMap, scopeId),
|
|
||||||
isRowSelectedFamilyState: getFamilyState(
|
isRowSelectedFamilyState: getFamilyState(
|
||||||
isRowSelectedFamilyStateScopeMap,
|
isRowSelectedFamilyStateScopeMap,
|
||||||
scopeId,
|
scopeId,
|
||||||
),
|
),
|
||||||
isRecordTableInitialLoadingState: getState(
|
|
||||||
isRecordTableInitialLoadingStateScopeMap,
|
|
||||||
scopeId,
|
|
||||||
),
|
|
||||||
resizeFieldOffsetState: getState(resizeFieldOffsetStateScopeMap, scopeId),
|
|
||||||
allRowsSelectedStatusSelector: getSelector(
|
allRowsSelectedStatusSelector: getSelector(
|
||||||
allRowsSelectedStatusSelectorScopeMap,
|
allRowsSelectedStatusSelectorScopeMap,
|
||||||
scopeId,
|
scopeId,
|
||||||
|
|||||||
@ -4,18 +4,18 @@ import { useRecordTableStates } from '@/object-record/record-table/hooks/interna
|
|||||||
import { getSnapshotValue } from '@/ui/utilities/recoil-scope/utils/getSnapshotValue';
|
import { getSnapshotValue } from '@/ui/utilities/recoil-scope/utils/getSnapshotValue';
|
||||||
|
|
||||||
export const useResetTableRowSelection = (recordTableId?: string) => {
|
export const useResetTableRowSelection = (recordTableId?: string) => {
|
||||||
const { tableRowIdsState, isRowSelectedFamilyState } =
|
const { getTableRowIdsState, isRowSelectedFamilyState } =
|
||||||
useRecordTableStates(recordTableId);
|
useRecordTableStates(recordTableId);
|
||||||
|
|
||||||
return useRecoilCallback(
|
return useRecoilCallback(
|
||||||
({ snapshot, set }) =>
|
({ snapshot, set }) =>
|
||||||
() => {
|
() => {
|
||||||
const tableRowIds = getSnapshotValue(snapshot, tableRowIdsState());
|
const tableRowIds = getSnapshotValue(snapshot, getTableRowIdsState());
|
||||||
|
|
||||||
for (const rowId of tableRowIds) {
|
for (const rowId of tableRowIds) {
|
||||||
set(isRowSelectedFamilyState(rowId), false);
|
set(isRowSelectedFamilyState(rowId), false);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[isRowSelectedFamilyState, tableRowIdsState],
|
[getTableRowIdsState, isRowSelectedFamilyState],
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import { getSnapshotValue } from '@/ui/utilities/recoil-scope/utils/getSnapshotV
|
|||||||
export const useSelectAllRows = (recordTableId?: string) => {
|
export const useSelectAllRows = (recordTableId?: string) => {
|
||||||
const {
|
const {
|
||||||
allRowsSelectedStatusSelector,
|
allRowsSelectedStatusSelector,
|
||||||
tableRowIdsState,
|
getTableRowIdsState,
|
||||||
isRowSelectedFamilyState,
|
isRowSelectedFamilyState,
|
||||||
} = useRecordTableStates(recordTableId);
|
} = useRecordTableStates(recordTableId);
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ export const useSelectAllRows = (recordTableId?: string) => {
|
|||||||
allRowsSelectedStatusSelector,
|
allRowsSelectedStatusSelector,
|
||||||
);
|
);
|
||||||
|
|
||||||
const tableRowIds = getSnapshotValue(snapshot, tableRowIdsState());
|
const tableRowIds = getSnapshotValue(snapshot, getTableRowIdsState());
|
||||||
|
|
||||||
if (
|
if (
|
||||||
allRowsSelectedStatus === 'none' ||
|
allRowsSelectedStatus === 'none' ||
|
||||||
@ -33,7 +33,11 @@ export const useSelectAllRows = (recordTableId?: string) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[allRowsSelectedStatusSelector, isRowSelectedFamilyState, tableRowIdsState],
|
[
|
||||||
|
allRowsSelectedStatusSelector,
|
||||||
|
getTableRowIdsState,
|
||||||
|
isRowSelectedFamilyState,
|
||||||
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@ -17,7 +17,7 @@ export const useSetRecordTableData = ({
|
|||||||
}: useSetRecordTableDataProps) => {
|
}: useSetRecordTableDataProps) => {
|
||||||
const resetTableRowSelection = useResetTableRowSelection(recordTableId);
|
const resetTableRowSelection = useResetTableRowSelection(recordTableId);
|
||||||
|
|
||||||
const { tableRowIdsState, numberOfTableRowsState } =
|
const { getTableRowIdsState, getNumberOfTableRowsState } =
|
||||||
useRecordTableStates(recordTableId);
|
useRecordTableStates(recordTableId);
|
||||||
|
|
||||||
return useRecoilCallback(
|
return useRecoilCallback(
|
||||||
@ -33,24 +33,24 @@ export const useSetRecordTableData = ({
|
|||||||
set(entityFieldsFamilyState(entity.id), entity);
|
set(entityFieldsFamilyState(entity.id), entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const currentRowIds = getSnapshotValue(snapshot, tableRowIdsState());
|
const currentRowIds = getSnapshotValue(snapshot, getTableRowIdsState());
|
||||||
|
|
||||||
const entityIds = newEntityArray.map((entity) => entity.id);
|
const entityIds = newEntityArray.map((entity) => entity.id);
|
||||||
|
|
||||||
if (!isDeeplyEqual(currentRowIds, entityIds)) {
|
if (!isDeeplyEqual(currentRowIds, entityIds)) {
|
||||||
set(tableRowIdsState(), entityIds);
|
set(getTableRowIdsState(), entityIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
resetTableRowSelection();
|
resetTableRowSelection();
|
||||||
|
|
||||||
set(numberOfTableRowsState(), entityIds.length);
|
set(getNumberOfTableRowsState(), entityIds.length);
|
||||||
onEntityCountChange(entityIds.length);
|
onEntityCountChange(entityIds.length);
|
||||||
},
|
},
|
||||||
[
|
[
|
||||||
numberOfTableRowsState,
|
getNumberOfTableRowsState,
|
||||||
|
getTableRowIdsState,
|
||||||
onEntityCountChange,
|
onEntityCountChange,
|
||||||
resetTableRowSelection,
|
resetTableRowSelection,
|
||||||
tableRowIdsState,
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -7,8 +7,8 @@ import { TableCellPosition } from '../../types/TableCellPosition';
|
|||||||
|
|
||||||
export const useSetSoftFocusPosition = (recordTableId?: string) => {
|
export const useSetSoftFocusPosition = (recordTableId?: string) => {
|
||||||
const {
|
const {
|
||||||
softFocusPositionState,
|
getSoftFocusPositionState,
|
||||||
isSoftFocusActiveState,
|
getIsSoftFocusActiveState,
|
||||||
isSoftFocusOnTableCellFamilyState,
|
isSoftFocusOnTableCellFamilyState,
|
||||||
} = useRecordTableStates(recordTableId);
|
} = useRecordTableStates(recordTableId);
|
||||||
|
|
||||||
@ -17,21 +17,21 @@ export const useSetSoftFocusPosition = (recordTableId?: string) => {
|
|||||||
return (newPosition: TableCellPosition) => {
|
return (newPosition: TableCellPosition) => {
|
||||||
const currentPosition = getSnapshotValue(
|
const currentPosition = getSnapshotValue(
|
||||||
snapshot,
|
snapshot,
|
||||||
softFocusPositionState(),
|
getSoftFocusPositionState(),
|
||||||
);
|
);
|
||||||
|
|
||||||
set(isSoftFocusActiveState(), true);
|
set(getIsSoftFocusActiveState(), true);
|
||||||
|
|
||||||
set(isSoftFocusOnTableCellFamilyState(currentPosition), false);
|
set(isSoftFocusOnTableCellFamilyState(currentPosition), false);
|
||||||
|
|
||||||
set(softFocusPositionState(), newPosition);
|
set(getSoftFocusPositionState(), newPosition);
|
||||||
|
|
||||||
set(isSoftFocusOnTableCellFamilyState(newPosition), true);
|
set(isSoftFocusOnTableCellFamilyState(newPosition), true);
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
[
|
[
|
||||||
softFocusPositionState,
|
getSoftFocusPositionState,
|
||||||
isSoftFocusActiveState,
|
getIsSoftFocusActiveState,
|
||||||
isSoftFocusOnTableCellFamilyState,
|
isSoftFocusOnTableCellFamilyState,
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|||||||
@ -29,45 +29,47 @@ export const useRecordTable = (props?: useRecordTableProps) => {
|
|||||||
|
|
||||||
const {
|
const {
|
||||||
scopeId,
|
scopeId,
|
||||||
availableTableColumnsState,
|
getAvailableTableColumnsState,
|
||||||
tableFiltersState,
|
getTableFiltersState,
|
||||||
tableSortsState,
|
getTableSortsState,
|
||||||
tableColumnsState,
|
getTableColumnsState,
|
||||||
objectMetadataConfigState,
|
getObjectMetadataConfigState,
|
||||||
onEntityCountChangeState,
|
getOnEntityCountChangeState,
|
||||||
softFocusPositionState,
|
getSoftFocusPositionState,
|
||||||
numberOfTableRowsState,
|
getNumberOfTableRowsState,
|
||||||
onColumnsChangeState,
|
getOnColumnsChangeState,
|
||||||
isRecordTableInitialLoadingState,
|
getIsRecordTableInitialLoadingState,
|
||||||
tableLastRowVisibleState,
|
getTableLastRowVisibleState,
|
||||||
numberOfTableColumnsSelector,
|
numberOfTableColumnsSelector,
|
||||||
selectedRowIdsSelector,
|
selectedRowIdsSelector,
|
||||||
} = useRecordTableStates(recordTableId);
|
} = useRecordTableStates(recordTableId);
|
||||||
|
|
||||||
const setAvailableTableColumns = useSetRecoilState(
|
const setAvailableTableColumns = useSetRecoilState(
|
||||||
availableTableColumnsState(),
|
getAvailableTableColumnsState(),
|
||||||
);
|
);
|
||||||
|
|
||||||
const setOnEntityCountChange = useSetRecoilState(onEntityCountChangeState());
|
const setOnEntityCountChange = useSetRecoilState(
|
||||||
|
getOnEntityCountChangeState(),
|
||||||
|
);
|
||||||
|
|
||||||
const setTableFilters = useSetRecoilState(tableFiltersState());
|
const setTableFilters = useSetRecoilState(getTableFiltersState());
|
||||||
|
|
||||||
const setObjectMetadataConfig = useSetRecoilState(
|
const setObjectMetadataConfig = useSetRecoilState(
|
||||||
objectMetadataConfigState(),
|
getObjectMetadataConfigState(),
|
||||||
);
|
);
|
||||||
|
|
||||||
const setTableSorts = useSetRecoilState(tableSortsState());
|
const setTableSorts = useSetRecoilState(getTableSortsState());
|
||||||
|
|
||||||
const setTableColumns = useSetRecoilState(tableColumnsState());
|
const setTableColumns = useSetRecoilState(getTableColumnsState());
|
||||||
|
|
||||||
const setOnColumnsChange = useSetRecoilState(onColumnsChangeState());
|
const setOnColumnsChange = useSetRecoilState(getOnColumnsChangeState());
|
||||||
|
|
||||||
const setIsRecordTableInitialLoading = useSetRecoilState(
|
const setIsRecordTableInitialLoading = useSetRecoilState(
|
||||||
isRecordTableInitialLoadingState(),
|
getIsRecordTableInitialLoadingState(),
|
||||||
);
|
);
|
||||||
|
|
||||||
const setRecordTableLastRowVisible = useSetRecoilState(
|
const setRecordTableLastRowVisible = useSetRecoilState(
|
||||||
tableLastRowVisibleState(),
|
getTableLastRowVisibleState(),
|
||||||
);
|
);
|
||||||
|
|
||||||
const onColumnsChange = useRecoilCallback(
|
const onColumnsChange = useRecoilCallback(
|
||||||
@ -75,12 +77,12 @@ export const useRecordTable = (props?: useRecordTableProps) => {
|
|||||||
(columns: ColumnDefinition<FieldMetadata>[]) => {
|
(columns: ColumnDefinition<FieldMetadata>[]) => {
|
||||||
const onColumnsChange = getSnapshotValue(
|
const onColumnsChange = getSnapshotValue(
|
||||||
snapshot,
|
snapshot,
|
||||||
onColumnsChangeState(),
|
getOnColumnsChangeState(),
|
||||||
);
|
);
|
||||||
|
|
||||||
onColumnsChange?.(columns);
|
onColumnsChange?.(columns);
|
||||||
},
|
},
|
||||||
[onColumnsChangeState],
|
[getOnColumnsChangeState],
|
||||||
);
|
);
|
||||||
|
|
||||||
const onEntityCountChange = useRecoilCallback(
|
const onEntityCountChange = useRecoilCallback(
|
||||||
@ -88,12 +90,12 @@ export const useRecordTable = (props?: useRecordTableProps) => {
|
|||||||
(count: number) => {
|
(count: number) => {
|
||||||
const onEntityCountChange = getSnapshotValue(
|
const onEntityCountChange = getSnapshotValue(
|
||||||
snapshot,
|
snapshot,
|
||||||
onEntityCountChangeState(),
|
getOnEntityCountChangeState(),
|
||||||
);
|
);
|
||||||
|
|
||||||
onEntityCountChange?.(count);
|
onEntityCountChange?.(count);
|
||||||
},
|
},
|
||||||
[onEntityCountChangeState],
|
[getOnEntityCountChangeState],
|
||||||
);
|
);
|
||||||
|
|
||||||
const setRecordTableData = useSetRecordTableData({
|
const setRecordTableData = useSetRecordTableData({
|
||||||
@ -116,7 +118,7 @@ export const useRecordTable = (props?: useRecordTableProps) => {
|
|||||||
() => {
|
() => {
|
||||||
const softFocusPosition = getSnapshotValue(
|
const softFocusPosition = getSnapshotValue(
|
||||||
snapshot,
|
snapshot,
|
||||||
softFocusPositionState(),
|
getSoftFocusPositionState(),
|
||||||
);
|
);
|
||||||
|
|
||||||
let newRowNumber = softFocusPosition.row - 1;
|
let newRowNumber = softFocusPosition.row - 1;
|
||||||
@ -130,7 +132,7 @@ export const useRecordTable = (props?: useRecordTableProps) => {
|
|||||||
row: newRowNumber,
|
row: newRowNumber,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
[setSoftFocusPosition, softFocusPositionState],
|
[getSoftFocusPositionState, setSoftFocusPosition],
|
||||||
);
|
);
|
||||||
|
|
||||||
const moveDown = useRecoilCallback(
|
const moveDown = useRecoilCallback(
|
||||||
@ -138,12 +140,12 @@ export const useRecordTable = (props?: useRecordTableProps) => {
|
|||||||
() => {
|
() => {
|
||||||
const softFocusPosition = getSnapshotValue(
|
const softFocusPosition = getSnapshotValue(
|
||||||
snapshot,
|
snapshot,
|
||||||
softFocusPositionState(),
|
getSoftFocusPositionState(),
|
||||||
);
|
);
|
||||||
|
|
||||||
const numberOfTableRows = getSnapshotValue(
|
const numberOfTableRows = getSnapshotValue(
|
||||||
snapshot,
|
snapshot,
|
||||||
numberOfTableRowsState(),
|
getNumberOfTableRowsState(),
|
||||||
);
|
);
|
||||||
|
|
||||||
let newRowNumber = softFocusPosition.row + 1;
|
let newRowNumber = softFocusPosition.row + 1;
|
||||||
@ -157,7 +159,11 @@ export const useRecordTable = (props?: useRecordTableProps) => {
|
|||||||
row: newRowNumber,
|
row: newRowNumber,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
[numberOfTableRowsState, setSoftFocusPosition, softFocusPositionState],
|
[
|
||||||
|
getNumberOfTableRowsState,
|
||||||
|
setSoftFocusPosition,
|
||||||
|
getSoftFocusPositionState,
|
||||||
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
const moveRight = useRecoilCallback(
|
const moveRight = useRecoilCallback(
|
||||||
@ -165,7 +171,7 @@ export const useRecordTable = (props?: useRecordTableProps) => {
|
|||||||
() => {
|
() => {
|
||||||
const softFocusPosition = getSnapshotValue(
|
const softFocusPosition = getSnapshotValue(
|
||||||
snapshot,
|
snapshot,
|
||||||
softFocusPositionState(),
|
getSoftFocusPositionState(),
|
||||||
);
|
);
|
||||||
|
|
||||||
const numberOfTableColumns = getSnapshotValue(
|
const numberOfTableColumns = getSnapshotValue(
|
||||||
@ -175,7 +181,7 @@ export const useRecordTable = (props?: useRecordTableProps) => {
|
|||||||
|
|
||||||
const numberOfTableRows = getSnapshotValue(
|
const numberOfTableRows = getSnapshotValue(
|
||||||
snapshot,
|
snapshot,
|
||||||
numberOfTableRowsState(),
|
getNumberOfTableRowsState(),
|
||||||
);
|
);
|
||||||
const currentColumnNumber = softFocusPosition.column;
|
const currentColumnNumber = softFocusPosition.column;
|
||||||
const currentRowNumber = softFocusPosition.row;
|
const currentRowNumber = softFocusPosition.row;
|
||||||
@ -208,9 +214,9 @@ export const useRecordTable = (props?: useRecordTableProps) => {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
[
|
[
|
||||||
softFocusPositionState,
|
getSoftFocusPositionState,
|
||||||
numberOfTableColumnsSelector,
|
numberOfTableColumnsSelector,
|
||||||
numberOfTableRowsState,
|
getNumberOfTableRowsState,
|
||||||
setSoftFocusPosition,
|
setSoftFocusPosition,
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
@ -220,7 +226,7 @@ export const useRecordTable = (props?: useRecordTableProps) => {
|
|||||||
() => {
|
() => {
|
||||||
const softFocusPosition = getSnapshotValue(
|
const softFocusPosition = getSnapshotValue(
|
||||||
snapshot,
|
snapshot,
|
||||||
softFocusPositionState(),
|
getSoftFocusPositionState(),
|
||||||
);
|
);
|
||||||
|
|
||||||
const numberOfTableColumns = getSnapshotValue(
|
const numberOfTableColumns = getSnapshotValue(
|
||||||
@ -256,7 +262,7 @@ export const useRecordTable = (props?: useRecordTableProps) => {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
[
|
[
|
||||||
softFocusPositionState,
|
getSoftFocusPositionState,
|
||||||
numberOfTableColumnsSelector,
|
numberOfTableColumnsSelector,
|
||||||
setSoftFocusPosition,
|
setSoftFocusPosition,
|
||||||
],
|
],
|
||||||
|
|||||||
@ -18,14 +18,14 @@ export const useTableColumns = (props?: useRecordTableProps) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const {
|
const {
|
||||||
availableTableColumnsState,
|
getAvailableTableColumnsState,
|
||||||
tableColumnsState,
|
getTableColumnsState,
|
||||||
visibleTableColumnsSelector,
|
visibleTableColumnsSelector,
|
||||||
} = useRecordTableStates(props?.recordTableId);
|
} = useRecordTableStates(props?.recordTableId);
|
||||||
|
|
||||||
const availableTableColumns = useRecoilValue(availableTableColumnsState());
|
const availableTableColumns = useRecoilValue(getAvailableTableColumnsState());
|
||||||
|
|
||||||
const tableColumns = useRecoilValue(tableColumnsState());
|
const tableColumns = useRecoilValue(getTableColumnsState());
|
||||||
const visibleTableColumns = useRecoilValue(visibleTableColumnsSelector);
|
const visibleTableColumns = useRecoilValue(visibleTableColumnsSelector);
|
||||||
|
|
||||||
const { handleColumnMove } = useMoveViewColumns();
|
const { handleColumnMove } = useMoveViewColumns();
|
||||||
|
|||||||
@ -12,7 +12,7 @@ export const useMoveSoftFocusToCurrentCellOnHover = () => {
|
|||||||
const setSoftFocusOnCurrentTableCell = useSetSoftFocusOnCurrentTableCell();
|
const setSoftFocusOnCurrentTableCell = useSetSoftFocusOnCurrentTableCell();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
currentTableCellInEditModePositionState,
|
getCurrentTableCellInEditModePositionState,
|
||||||
isTableCellInEditModeFamilyState,
|
isTableCellInEditModeFamilyState,
|
||||||
} = useRecordTableStates();
|
} = useRecordTableStates();
|
||||||
|
|
||||||
@ -21,7 +21,7 @@ export const useMoveSoftFocusToCurrentCellOnHover = () => {
|
|||||||
() => {
|
() => {
|
||||||
const currentTableCellInEditModePosition = getSnapshotValue(
|
const currentTableCellInEditModePosition = getSnapshotValue(
|
||||||
snapshot,
|
snapshot,
|
||||||
currentTableCellInEditModePositionState(),
|
getCurrentTableCellInEditModePositionState(),
|
||||||
);
|
);
|
||||||
|
|
||||||
const isSomeCellInEditMode = snapshot
|
const isSomeCellInEditMode = snapshot
|
||||||
@ -49,7 +49,7 @@ export const useMoveSoftFocusToCurrentCellOnHover = () => {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
[
|
[
|
||||||
currentTableCellInEditModePositionState,
|
getCurrentTableCellInEditModePositionState,
|
||||||
isTableCellInEditModeFamilyState,
|
isTableCellInEditModeFamilyState,
|
||||||
setSoftFocusOnCurrentTableCell,
|
setSoftFocusOnCurrentTableCell,
|
||||||
],
|
],
|
||||||
|
|||||||
@ -10,7 +10,7 @@ import { TableHotkeyScope } from '../../types/TableHotkeyScope';
|
|||||||
export const useSetSoftFocus = () => {
|
export const useSetSoftFocus = () => {
|
||||||
const { setSoftFocusPosition } = useRecordTable();
|
const { setSoftFocusPosition } = useRecordTable();
|
||||||
|
|
||||||
const { isSoftFocusActiveState } = useRecordTableStates();
|
const { getIsSoftFocusActiveState } = useRecordTableStates();
|
||||||
|
|
||||||
const setHotkeyScope = useSetHotkeyScope();
|
const setHotkeyScope = useSetHotkeyScope();
|
||||||
|
|
||||||
@ -19,10 +19,10 @@ export const useSetSoftFocus = () => {
|
|||||||
(newPosition: TableCellPosition) => {
|
(newPosition: TableCellPosition) => {
|
||||||
setSoftFocusPosition(newPosition);
|
setSoftFocusPosition(newPosition);
|
||||||
|
|
||||||
set(isSoftFocusActiveState(), true);
|
set(getIsSoftFocusActiveState(), true);
|
||||||
|
|
||||||
setHotkeyScope(TableHotkeyScope.TableSoftFocus);
|
setHotkeyScope(TableHotkeyScope.TableSoftFocus);
|
||||||
},
|
},
|
||||||
[setSoftFocusPosition, isSoftFocusActiveState, setHotkeyScope],
|
[setSoftFocusPosition, getIsSoftFocusActiveState, setHotkeyScope],
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -26,10 +26,10 @@ export const DEFAULT_CELL_SCOPE: HotkeyScope = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const useTableCell = () => {
|
export const useTableCell = () => {
|
||||||
const { objectMetadataConfigState, tableRowIdsState } =
|
const { getObjectMetadataConfigState, getTableRowIdsState } =
|
||||||
useRecordTableStates();
|
useRecordTableStates();
|
||||||
|
|
||||||
const objectMetadataConfig = useRecoilValue(objectMetadataConfigState());
|
const objectMetadataConfig = useRecoilValue(getObjectMetadataConfigState());
|
||||||
|
|
||||||
const basePathToShowPage = objectMetadataConfig?.basePathToShowPage;
|
const basePathToShowPage = objectMetadataConfig?.basePathToShowPage;
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ export const useTableCell = () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const deleteRow = useRecoilCallback(({ snapshot }) => async () => {
|
const deleteRow = useRecoilCallback(({ snapshot }) => async () => {
|
||||||
const tableRowIds = getSnapshotValue(snapshot, tableRowIdsState());
|
const tableRowIds = getSnapshotValue(snapshot, getTableRowIdsState());
|
||||||
|
|
||||||
await deleteOneRecord(tableRowIds[0]);
|
await deleteOneRecord(tableRowIds[0]);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -57,8 +57,8 @@ export const ShowPageRightContainer = ({
|
|||||||
}: ShowPageRightContainerProps) => {
|
}: ShowPageRightContainerProps) => {
|
||||||
const isMessagingEnabled = useIsFeatureEnabled('IS_MESSAGING_ENABLED');
|
const isMessagingEnabled = useIsFeatureEnabled('IS_MESSAGING_ENABLED');
|
||||||
|
|
||||||
const { activeTabIdState } = useTabList(TAB_LIST_COMPONENT_ID);
|
const { getActiveTabIdState } = useTabList(TAB_LIST_COMPONENT_ID);
|
||||||
const activeTabId = useRecoilValue(activeTabIdState());
|
const activeTabId = useRecoilValue(getActiveTabIdState());
|
||||||
|
|
||||||
const { objectMetadataItem: targetableObjectMetadataItem } =
|
const { objectMetadataItem: targetableObjectMetadataItem } =
|
||||||
useObjectMetadataItem({
|
useObjectMetadataItem({
|
||||||
|
|||||||
@ -34,9 +34,9 @@ const StyledContainer = styled.div`
|
|||||||
export const TabList = ({ tabs, tabListId }: TabListProps) => {
|
export const TabList = ({ tabs, tabListId }: TabListProps) => {
|
||||||
const initialActiveTabId = tabs[0].id;
|
const initialActiveTabId = tabs[0].id;
|
||||||
|
|
||||||
const { activeTabIdState, setActiveTabId } = useTabList(tabListId);
|
const { getActiveTabIdState, setActiveTabId } = useTabList(tabListId);
|
||||||
|
|
||||||
const activeTabId = useRecoilValue(activeTabIdState());
|
const activeTabId = useRecoilValue(getActiveTabIdState());
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
setActiveTabId(initialActiveTabId);
|
setActiveTabId(initialActiveTabId);
|
||||||
|
|||||||
@ -15,6 +15,6 @@ export const useTabListStates = ({ tabListScopeId }: useTabListStatesProps) => {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
scopeId,
|
scopeId,
|
||||||
activeTabIdState: getState(activeTabIdStateScopeMap, scopeId),
|
getActiveTabIdState: getState(activeTabIdStateScopeMap, scopeId),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@ -3,14 +3,14 @@ import { useSetRecoilState } from 'recoil';
|
|||||||
import { useTabListStates } from '@/ui/layout/tab/hooks/internal/useTabListStates';
|
import { useTabListStates } from '@/ui/layout/tab/hooks/internal/useTabListStates';
|
||||||
|
|
||||||
export const useTabList = (tabListId?: string) => {
|
export const useTabList = (tabListId?: string) => {
|
||||||
const { activeTabIdState } = useTabListStates({
|
const { getActiveTabIdState } = useTabListStates({
|
||||||
tabListScopeId: `${tabListId}-scope`,
|
tabListScopeId: `${tabListId}-scope`,
|
||||||
});
|
});
|
||||||
|
|
||||||
const setActiveTabId = useSetRecoilState(activeTabIdState());
|
const setActiveTabId = useSetRecoilState(getActiveTabIdState());
|
||||||
|
|
||||||
return {
|
return {
|
||||||
activeTabIdState,
|
getActiveTabIdState,
|
||||||
setActiveTabId,
|
setActiveTabId,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user