Introduce ComponentState (#4386)
* Proof of concept ComponentState * Migrate to createState and createFamilyState * Refactor * Fix * Fix tests * Fix lint * Fix tests * Re-enable coverage
This commit is contained in:
@ -57,7 +57,7 @@ describe('useFindManyRecords', () => {
|
||||
const { result } = renderHook(
|
||||
() => {
|
||||
const setCurrentWorkspaceMember = useSetRecoilState(
|
||||
currentWorkspaceMemberState,
|
||||
currentWorkspaceMemberState(),
|
||||
);
|
||||
setCurrentWorkspaceMember({
|
||||
id: '32219445-f587-4c40-b2b1-6d3205ed96da',
|
||||
@ -67,7 +67,7 @@ describe('useFindManyRecords', () => {
|
||||
|
||||
const mockObjectMetadataItems = getObjectMetadataItemsMock();
|
||||
|
||||
const setMetadataItems = useSetRecoilState(objectMetadataItemsState);
|
||||
const setMetadataItems = useSetRecoilState(objectMetadataItemsState());
|
||||
|
||||
setMetadataItems(mockObjectMetadataItems);
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@ import { isNonNullable } from '~/utils/isNonNullable';
|
||||
const Wrapper = getJestHookWrapper({
|
||||
apolloMocks: [],
|
||||
onInitializeRecoilSnapshot: (snapshot) => {
|
||||
snapshot.set(objectMetadataItemsState, getObjectMetadataItemsMock());
|
||||
snapshot.set(objectMetadataItemsState(), getObjectMetadataItemsMock());
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@ -69,7 +69,7 @@ export const useFindManyRecords = <T extends ObjectRecord = ObjectRecord>({
|
||||
);
|
||||
|
||||
const { enqueueSnackBar } = useSnackBar();
|
||||
const currentWorkspaceMember = useRecoilValue(currentWorkspaceMemberState);
|
||||
const currentWorkspaceMember = useRecoilValue(currentWorkspaceMemberState());
|
||||
|
||||
const { data, loading, error, fetchMore } = useQuery<
|
||||
ObjectRecordQueryResult<T>
|
||||
|
||||
@ -11,7 +11,7 @@ import { FieldMetadataType } from '~/generated/graphql';
|
||||
import { isNonNullable } from '~/utils/isNonNullable';
|
||||
|
||||
export const useMapConnectionToRecords = () => {
|
||||
const objectMetadataItems = useRecoilValue(objectMetadataItemsState);
|
||||
const objectMetadataItems = useRecoilValue(objectMetadataItemsState());
|
||||
|
||||
const mapConnectionToRecords = useCallback(
|
||||
<T extends ObjectRecord>({
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { StateScopeMapKey } from '@/ui/utilities/recoil-scope/scopes-internal/types/StateScopeMapKey';
|
||||
import { createScopeInternalContext } from '@/ui/utilities/recoil-scope/scopes-internal/utils/createScopeInternalContext';
|
||||
import { ComponentStateKey } from '@/ui/utilities/state/component-state/types/ComponentStateKey';
|
||||
|
||||
type ObjectFilterDropdownScopeInternalContextProps = StateScopeMapKey;
|
||||
type ObjectFilterDropdownScopeInternalContextProps = ComponentStateKey;
|
||||
|
||||
export const ObjectFilterDropdownScopeInternalContext =
|
||||
createScopeInternalContext<ObjectFilterDropdownScopeInternalContextProps>();
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { FilterDefinition } from '@/object-record/object-filter-dropdown/types/FilterDefinition';
|
||||
import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
|
||||
import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
|
||||
|
||||
export const availableFilterDefinitionsScopedState = createStateScopeMap<
|
||||
export const availableFilterDefinitionsScopedState = createComponentState<
|
||||
FilterDefinition[]
|
||||
>({
|
||||
key: 'availableFilterDefinitionsScopedState',
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
|
||||
import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
|
||||
|
||||
import { FilterDefinition } from '../types/FilterDefinition';
|
||||
|
||||
export const filterDefinitionUsedInDropdownScopedState =
|
||||
createStateScopeMap<FilterDefinition | null>({
|
||||
createComponentState<FilterDefinition | null>({
|
||||
key: 'filterDefinitionUsedInDropdownScopedState',
|
||||
defaultValue: null,
|
||||
});
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
|
||||
import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
|
||||
|
||||
export const isObjectFilterDropdownOperandSelectUnfoldedScopedState =
|
||||
createStateScopeMap<boolean>({
|
||||
createComponentState<boolean>({
|
||||
key: 'isObjectFilterDropdownOperandSelectUnfoldedScopedState',
|
||||
defaultValue: false,
|
||||
});
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
|
||||
import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
|
||||
|
||||
export const isObjectFilterDropdownUnfoldedScopedState =
|
||||
createStateScopeMap<boolean>({
|
||||
createComponentState<boolean>({
|
||||
key: 'isObjectFilterDropdownUnfoldedScopedState',
|
||||
defaultValue: false,
|
||||
});
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
|
||||
import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
|
||||
|
||||
export const objectFilterDropdownSearchInputScopedState =
|
||||
createStateScopeMap<string>({
|
||||
createComponentState<string>({
|
||||
key: 'objectFilterDropdownSearchInputScopedState',
|
||||
defaultValue: '',
|
||||
});
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
|
||||
import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
|
||||
|
||||
export const objectFilterDropdownSelectedEntityIdScopedState =
|
||||
createStateScopeMap<string | null>({
|
||||
createComponentState<string | null>({
|
||||
key: 'objectFilterDropdownSelectedEntityIdScopedState',
|
||||
defaultValue: null,
|
||||
});
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
|
||||
import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
|
||||
|
||||
export const objectFilterDropdownSelectedOptionValuesScopedState =
|
||||
createStateScopeMap<string[]>({
|
||||
createComponentState<string[]>({
|
||||
key: 'objectFilterDropdownSelectedOptionValuesScopedState',
|
||||
defaultValue: [],
|
||||
});
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
|
||||
import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
|
||||
|
||||
export const objectFilterDropdownSelectedRecordIdsScopedState =
|
||||
createStateScopeMap<string[]>({
|
||||
createComponentState<string[]>({
|
||||
key: 'objectFilterDropdownSelectedRecordIdsScopedState',
|
||||
defaultValue: [],
|
||||
});
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
|
||||
import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
|
||||
|
||||
import { Filter } from '../types/Filter';
|
||||
|
||||
export const onFilterSelectScopedState = createStateScopeMap<
|
||||
export const onFilterSelectScopedState = createComponentState<
|
||||
((filter: Filter | null) => void) | undefined
|
||||
>({
|
||||
key: 'onFilterSelectScopedState',
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
|
||||
import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
|
||||
|
||||
import { Filter } from '../types/Filter';
|
||||
|
||||
export const selectedFilterScopedState = createStateScopeMap<
|
||||
export const selectedFilterScopedState = createComponentState<
|
||||
Filter | undefined | null
|
||||
>({
|
||||
key: 'selectedFilterScopedState',
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
|
||||
import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
|
||||
import { ViewFilterOperand } from '@/views/types/ViewFilterOperand';
|
||||
|
||||
export const selectedOperandInDropdownScopedState =
|
||||
createStateScopeMap<ViewFilterOperand | null>({
|
||||
createComponentState<ViewFilterOperand | null>({
|
||||
key: 'selectedOperandInDropdownScopedState',
|
||||
defaultValue: null,
|
||||
});
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import { StateScopeMapKey } from '@/ui/utilities/recoil-scope/scopes-internal/types/StateScopeMapKey';
|
||||
import { createScopeInternalContext } from '@/ui/utilities/recoil-scope/scopes-internal/utils/createScopeInternalContext';
|
||||
import { ComponentStateKey } from '@/ui/utilities/state/component-state/types/ComponentStateKey';
|
||||
|
||||
import { Sort } from '../../types/Sort';
|
||||
|
||||
type ObjectSortDropdownScopeInternalContextProps = StateScopeMapKey & {
|
||||
type ObjectSortDropdownScopeInternalContextProps = ComponentStateKey & {
|
||||
onSortSelect?: (sort: Sort) => void;
|
||||
};
|
||||
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
|
||||
import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
|
||||
|
||||
import { SortDefinition } from '../types/SortDefinition';
|
||||
|
||||
export const availableSortDefinitionsScopedState = createStateScopeMap<
|
||||
export const availableSortDefinitionsScopedState = createComponentState<
|
||||
SortDefinition[]
|
||||
>({
|
||||
key: 'availableSortDefinitionsScopedState',
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
|
||||
import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
|
||||
|
||||
export const isSortSelectedScopedState = createStateScopeMap<boolean>({
|
||||
export const isSortSelectedScopedState = createComponentState<boolean>({
|
||||
key: 'isSortSelectedScopedState',
|
||||
defaultValue: false,
|
||||
});
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
|
||||
import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
|
||||
|
||||
import { Sort } from '../types/Sort';
|
||||
|
||||
export const onSortSelectScopedState = createStateScopeMap<
|
||||
export const onSortSelectScopedState = createComponentState<
|
||||
((sort: Sort) => void) | undefined
|
||||
>({
|
||||
key: 'onSortSelectScopedState',
|
||||
|
||||
@ -32,8 +32,8 @@ export const useRecordActionBar = ({
|
||||
selectedRecordIds,
|
||||
callback,
|
||||
}: useRecordActionBarProps) => {
|
||||
const setContextMenuEntries = useSetRecoilState(contextMenuEntriesState);
|
||||
const setActionBarEntriesState = useSetRecoilState(actionBarEntriesState);
|
||||
const setContextMenuEntries = useSetRecoilState(contextMenuEntriesState());
|
||||
const setActionBarEntriesState = useSetRecoilState(actionBarEntriesState());
|
||||
|
||||
const { createFavorite, favorites, deleteFavorite } = useFavorites();
|
||||
|
||||
|
||||
@ -1,24 +1,24 @@
|
||||
import { RecordBoardScopeInternalContext } from '@/object-record/record-board/scopes/scope-internal-context/RecordBoardScopeInternalContext';
|
||||
import { isFirstRecordBoardColumnFamilyStateScopeMap } from '@/object-record/record-board/states/isFirstRecordBoardColumnFamilyStateScopeMap';
|
||||
import { isLastRecordBoardColumnFamilyStateScopeMap } from '@/object-record/record-board/states/isLastRecordBoardColumnFamilyStateScopeMap';
|
||||
import { isRecordBoardCardSelectedFamilyStateScopeMap } from '@/object-record/record-board/states/isRecordBoardCardSelectedFamilyStateScopeMap';
|
||||
import { isRecordBoardCompactModeActiveStateScopeMap } from '@/object-record/record-board/states/isRecordBoardCompactModeActiveStateScopeMap';
|
||||
import { isRecordBoardFetchingRecordsStateScopeMap } from '@/object-record/record-board/states/isRecordBoardFetchingRecordsStateScopeMap';
|
||||
import { onRecordBoardFetchMoreVisibilityChangeStateScopeMap } from '@/object-record/record-board/states/onRecordBoardFetchMoreVisibilityChangeStateScopeMap';
|
||||
import { recordBoardColumnIdsStateScopeMap } from '@/object-record/record-board/states/recordBoardColumnIdsStateScopeMap';
|
||||
import { recordBoardFieldDefinitionsStateScopeMap } from '@/object-record/record-board/states/recordBoardFieldDefinitionsStateScopeMap';
|
||||
import { recordBoardFiltersStateScopeMap } from '@/object-record/record-board/states/recordBoardFiltersStateScopeMap';
|
||||
import { recordBoardObjectSingularNameStateScopeMap } from '@/object-record/record-board/states/recordBoardObjectSingularNameStateScopeMap';
|
||||
import { recordBoardRecordIdsByColumnIdFamilyStateScopeMap } from '@/object-record/record-board/states/recordBoardRecordIdsByColumnIdFamilyStateScopeMap';
|
||||
import { recordBoardSortsStateScopeMap } from '@/object-record/record-board/states/recordBoardSortsStateScopeMap';
|
||||
import { recordBoardColumnsFamilySelectorScopeMap } from '@/object-record/record-board/states/selectors/recordBoardColumnsFamilySelectorScopeMap';
|
||||
import { recordBoardSelectedRecordIdsSelectorScopeMap } from '@/object-record/record-board/states/selectors/recordBoardSelectedRecordIdsSelectorScopeMap';
|
||||
import { recordBoardVisibleFieldDefinitionsScopedSelector } from '@/object-record/record-board/states/selectors/recordBoardVisibleFieldDefinitionsScopedSelector';
|
||||
import { isFirstRecordBoardColumnComponentFamilyState } from '@/object-record/record-board/states/isFirstRecordBoardColumnComponentFamilyState';
|
||||
import { isLastRecordBoardColumnComponentFamilyState } from '@/object-record/record-board/states/isLastRecordBoardColumnComponentFamilyState';
|
||||
import { isRecordBoardCardSelectedComponentFamilyState } from '@/object-record/record-board/states/isRecordBoardCardSelectedComponentFamilyState';
|
||||
import { isRecordBoardCompactModeActiveComponentState } from '@/object-record/record-board/states/isRecordBoardCompactModeActiveComponentState';
|
||||
import { isRecordBoardFetchingRecordsComponentState } from '@/object-record/record-board/states/isRecordBoardFetchingRecordsComponentState';
|
||||
import { onRecordBoardFetchMoreVisibilityChangeComponentState } from '@/object-record/record-board/states/onRecordBoardFetchMoreVisibilityChangeComponentState';
|
||||
import { recordBoardColumnIdsComponentState } from '@/object-record/record-board/states/recordBoardColumnIdsComponentState';
|
||||
import { recordBoardFieldDefinitionsComponentState } from '@/object-record/record-board/states/recordBoardFieldDefinitionsComponentState';
|
||||
import { recordBoardFiltersComponentState } from '@/object-record/record-board/states/recordBoardFiltersComponentState';
|
||||
import { recordBoardObjectSingularNameComponentState } from '@/object-record/record-board/states/recordBoardObjectSingularNameComponentState';
|
||||
import { recordBoardRecordIdsByColumnIdComponentFamilyState } from '@/object-record/record-board/states/recordBoardRecordIdsByColumnIdComponentFamilyState';
|
||||
import { recordBoardSortsComponentState } from '@/object-record/record-board/states/recordBoardSortsComponentState';
|
||||
import { recordBoardColumnsComponentFamilySelector } from '@/object-record/record-board/states/selectors/recordBoardColumnsComponentFamilySelector';
|
||||
import { recordBoardSelectedRecordIdsComponentSelector } from '@/object-record/record-board/states/selectors/recordBoardSelectedRecordIdsComponentSelector';
|
||||
import { recordBoardVisibleFieldDefinitionsComponentSelector } from '@/object-record/record-board/states/selectors/recordBoardVisibleFieldDefinitionsComponentSelector';
|
||||
import { useAvailableScopeIdOrThrow } from '@/ui/utilities/recoil-scope/scopes-internal/hooks/useAvailableScopeId';
|
||||
import { getFamilyState } from '@/ui/utilities/recoil-scope/utils/getFamilyState';
|
||||
import { getScopeIdOrUndefinedFromComponentId } from '@/ui/utilities/recoil-scope/utils/getScopeIdOrUndefinedFromComponentId';
|
||||
import { getSelectorReadOnly } from '@/ui/utilities/recoil-scope/utils/getSelectorReadOnly';
|
||||
import { getState } from '@/ui/utilities/recoil-scope/utils/getState';
|
||||
import { extractComponentFamilyState } from '@/ui/utilities/state/component-state/utils/extractComponentFamilyState';
|
||||
import { extractComponentReadOnlySelector } from '@/ui/utilities/state/component-state/utils/extractComponentReadOnlySelector';
|
||||
import { extractComponentState } from '@/ui/utilities/state/component-state/utils/extractComponentState';
|
||||
|
||||
export const useRecordBoardStates = (recordBoardId?: string) => {
|
||||
const scopeId = useAvailableScopeIdOrThrow(
|
||||
@ -28,59 +28,68 @@ export const useRecordBoardStates = (recordBoardId?: string) => {
|
||||
|
||||
return {
|
||||
scopeId,
|
||||
getObjectSingularNameState: getState(
|
||||
recordBoardObjectSingularNameStateScopeMap,
|
||||
getObjectSingularNameState: extractComponentState(
|
||||
recordBoardObjectSingularNameComponentState,
|
||||
scopeId,
|
||||
),
|
||||
getIsFetchingRecordState: getState(
|
||||
isRecordBoardFetchingRecordsStateScopeMap,
|
||||
getIsFetchingRecordState: extractComponentState(
|
||||
isRecordBoardFetchingRecordsComponentState,
|
||||
scopeId,
|
||||
),
|
||||
getColumnIdsState: getState(recordBoardColumnIdsStateScopeMap, scopeId),
|
||||
isFirstColumnFamilyState: getFamilyState(
|
||||
isFirstRecordBoardColumnFamilyStateScopeMap,
|
||||
getColumnIdsState: extractComponentState(
|
||||
recordBoardColumnIdsComponentState,
|
||||
scopeId,
|
||||
),
|
||||
isLastColumnFamilyState: getFamilyState(
|
||||
isLastRecordBoardColumnFamilyStateScopeMap,
|
||||
isFirstColumnFamilyState: extractComponentFamilyState(
|
||||
isFirstRecordBoardColumnComponentFamilyState,
|
||||
scopeId,
|
||||
),
|
||||
columnsFamilySelector: getFamilyState(
|
||||
recordBoardColumnsFamilySelectorScopeMap,
|
||||
isLastColumnFamilyState: extractComponentFamilyState(
|
||||
isLastRecordBoardColumnComponentFamilyState,
|
||||
scopeId,
|
||||
),
|
||||
columnsFamilySelector: extractComponentFamilyState(
|
||||
recordBoardColumnsComponentFamilySelector,
|
||||
scopeId,
|
||||
),
|
||||
|
||||
getFiltersState: getState(recordBoardFiltersStateScopeMap, scopeId),
|
||||
getSortsState: getState(recordBoardSortsStateScopeMap, scopeId),
|
||||
getFieldDefinitionsState: getState(
|
||||
recordBoardFieldDefinitionsStateScopeMap,
|
||||
getFiltersState: extractComponentState(
|
||||
recordBoardFiltersComponentState,
|
||||
scopeId,
|
||||
),
|
||||
getVisibleFieldDefinitionsState: getSelectorReadOnly(
|
||||
recordBoardVisibleFieldDefinitionsScopedSelector,
|
||||
getSortsState: extractComponentState(
|
||||
recordBoardSortsComponentState,
|
||||
scopeId,
|
||||
),
|
||||
getFieldDefinitionsState: extractComponentState(
|
||||
recordBoardFieldDefinitionsComponentState,
|
||||
scopeId,
|
||||
),
|
||||
getVisibleFieldDefinitionsState: extractComponentReadOnlySelector(
|
||||
recordBoardVisibleFieldDefinitionsComponentSelector,
|
||||
scopeId,
|
||||
),
|
||||
|
||||
recordIdsByColumnIdFamilyState: getFamilyState(
|
||||
recordBoardRecordIdsByColumnIdFamilyStateScopeMap,
|
||||
recordIdsByColumnIdFamilyState: extractComponentFamilyState(
|
||||
recordBoardRecordIdsByColumnIdComponentFamilyState,
|
||||
scopeId,
|
||||
),
|
||||
isRecordBoardCardSelectedFamilyState: getFamilyState(
|
||||
isRecordBoardCardSelectedFamilyStateScopeMap,
|
||||
isRecordBoardCardSelectedFamilyState: extractComponentFamilyState(
|
||||
isRecordBoardCardSelectedComponentFamilyState,
|
||||
scopeId,
|
||||
),
|
||||
getSelectedRecordIdsSelector: getSelectorReadOnly(
|
||||
recordBoardSelectedRecordIdsSelectorScopeMap,
|
||||
getSelectedRecordIdsSelector: extractComponentReadOnlySelector(
|
||||
recordBoardSelectedRecordIdsComponentSelector,
|
||||
scopeId,
|
||||
),
|
||||
|
||||
getIsCompactModeActiveState: getState(
|
||||
isRecordBoardCompactModeActiveStateScopeMap,
|
||||
getIsCompactModeActiveState: extractComponentState(
|
||||
isRecordBoardCompactModeActiveComponentState,
|
||||
scopeId,
|
||||
),
|
||||
|
||||
getOnFetchMoreVisibilityChangeState: getState(
|
||||
onRecordBoardFetchMoreVisibilityChangeStateScopeMap,
|
||||
getOnFetchMoreVisibilityChangeState: extractComponentState(
|
||||
onRecordBoardFetchMoreVisibilityChangeComponentState,
|
||||
scopeId,
|
||||
),
|
||||
};
|
||||
|
||||
@ -152,8 +152,8 @@ export const RecordBoardCard = () => {
|
||||
|
||||
const record = useRecoilValue(recordStoreFamilyState(recordId));
|
||||
|
||||
const setContextMenuPosition = useSetRecoilState(contextMenuPositionState);
|
||||
const setContextMenuOpenState = useSetRecoilState(contextMenuIsOpenState);
|
||||
const setContextMenuPosition = useSetRecoilState(contextMenuPositionState());
|
||||
const setContextMenuOpenState = useSetRecoilState(contextMenuIsOpenState());
|
||||
|
||||
const handleContextMenu = (event: React.MouseEvent) => {
|
||||
event.preventDefault();
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
import { RecordBoardColumnDefinition } from '@/object-record/record-board/types/RecordBoardColumnDefinition';
|
||||
import { FieldDefinition } from '@/object-record/record-field/types/FieldDefinition';
|
||||
import { FieldMetadata } from '@/object-record/record-field/types/FieldMetadata';
|
||||
import { StateScopeMapKey } from '@/ui/utilities/recoil-scope/scopes-internal/types/StateScopeMapKey';
|
||||
import { createScopeInternalContext } from '@/ui/utilities/recoil-scope/scopes-internal/utils/createScopeInternalContext';
|
||||
import { ComponentStateKey } from '@/ui/utilities/state/component-state/types/ComponentStateKey';
|
||||
|
||||
type RecordBoardScopeInternalContextProps = StateScopeMapKey & {
|
||||
type RecordBoardScopeInternalContextProps = ComponentStateKey & {
|
||||
onFieldsChange: (fields: FieldDefinition<FieldMetadata>[]) => void;
|
||||
onColumnsChange: (column: RecordBoardColumnDefinition[]) => void;
|
||||
};
|
||||
|
||||
@ -0,0 +1,7 @@
|
||||
import { createComponentFamilyState } from '@/ui/utilities/state/component-state/utils/createComponentFamilyState';
|
||||
|
||||
export const isFirstRecordBoardColumnComponentFamilyState =
|
||||
createComponentFamilyState<boolean, string>({
|
||||
key: 'isFirstRecordBoardColumnComponentFamilyState',
|
||||
defaultValue: false,
|
||||
});
|
||||
@ -1,7 +0,0 @@
|
||||
import { createFamilyStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createFamilyStateScopeMap';
|
||||
|
||||
export const isFirstRecordBoardColumnFamilyStateScopeMap =
|
||||
createFamilyStateScopeMap<boolean, string>({
|
||||
key: 'isFirstRecordBoardColumnFamilyStateScopeMap',
|
||||
defaultValue: false,
|
||||
});
|
||||
@ -0,0 +1,7 @@
|
||||
import { createComponentFamilyState } from '@/ui/utilities/state/component-state/utils/createComponentFamilyState';
|
||||
|
||||
export const isLastRecordBoardColumnComponentFamilyState =
|
||||
createComponentFamilyState<boolean, string>({
|
||||
key: 'isLastRecordBoardColumnComponentFamilyState',
|
||||
defaultValue: false,
|
||||
});
|
||||
@ -1,7 +0,0 @@
|
||||
import { createFamilyStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createFamilyStateScopeMap';
|
||||
|
||||
export const isLastRecordBoardColumnFamilyStateScopeMap =
|
||||
createFamilyStateScopeMap<boolean, string>({
|
||||
key: 'isLastRecordBoardColumnFamilyStateScopeMap',
|
||||
defaultValue: false,
|
||||
});
|
||||
@ -0,0 +1,7 @@
|
||||
import { createComponentFamilyState } from '@/ui/utilities/state/component-state/utils/createComponentFamilyState';
|
||||
|
||||
export const isRecordBoardCardSelectedComponentFamilyState =
|
||||
createComponentFamilyState<boolean, string>({
|
||||
key: 'isRecordBoardCardSelectedComponentFamilyState',
|
||||
defaultValue: false,
|
||||
});
|
||||
@ -1,7 +0,0 @@
|
||||
import { createFamilyStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createFamilyStateScopeMap';
|
||||
|
||||
export const isRecordBoardCardSelectedFamilyStateScopeMap =
|
||||
createFamilyStateScopeMap<boolean, string>({
|
||||
key: 'isRecordBoardCardSelectedFamilyStateScopeMap',
|
||||
defaultValue: false,
|
||||
});
|
||||
@ -0,0 +1,7 @@
|
||||
import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
|
||||
|
||||
export const isRecordBoardCompactModeActiveComponentState =
|
||||
createComponentState<boolean>({
|
||||
key: 'isRecordBoardCompactModeActiveComponentState',
|
||||
defaultValue: false,
|
||||
});
|
||||
@ -1,7 +0,0 @@
|
||||
import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
|
||||
|
||||
export const isRecordBoardCompactModeActiveStateScopeMap =
|
||||
createStateScopeMap<boolean>({
|
||||
key: 'isRecordBoardCompactModeActiveStateScopeMap',
|
||||
defaultValue: false,
|
||||
});
|
||||
@ -0,0 +1,7 @@
|
||||
import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
|
||||
|
||||
export const isRecordBoardFetchingRecordsComponentState =
|
||||
createComponentState<boolean>({
|
||||
key: 'isRecordBoardFetchingRecordsComponentState',
|
||||
defaultValue: false,
|
||||
});
|
||||
@ -1,7 +0,0 @@
|
||||
import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
|
||||
|
||||
export const isRecordBoardFetchingRecordsStateScopeMap =
|
||||
createStateScopeMap<boolean>({
|
||||
key: 'isRecordBoardFetchingRecordsStateScopeMap',
|
||||
defaultValue: false,
|
||||
});
|
||||
@ -0,0 +1,7 @@
|
||||
import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
|
||||
|
||||
export const onRecordBoardFetchMoreVisibilityChangeComponentState =
|
||||
createComponentState<(visbility: boolean) => void>({
|
||||
key: 'onRecordBoardFetchMoreVisibilityChangeComponentState',
|
||||
defaultValue: () => {},
|
||||
});
|
||||
@ -1,7 +0,0 @@
|
||||
import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
|
||||
|
||||
export const onRecordBoardFetchMoreVisibilityChangeStateScopeMap =
|
||||
createStateScopeMap<(visbility: boolean) => void>({
|
||||
key: 'onRecordBoardFetchMoreVisibilityChangeStateScopeMap',
|
||||
defaultValue: () => {},
|
||||
});
|
||||
@ -0,0 +1,8 @@
|
||||
import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
|
||||
|
||||
export const recordBoardColumnIdsComponentState = createComponentState<
|
||||
string[]
|
||||
>({
|
||||
key: 'recordBoardColumnIdsComponentState',
|
||||
defaultValue: [],
|
||||
});
|
||||
@ -1,6 +0,0 @@
|
||||
import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
|
||||
|
||||
export const recordBoardColumnIdsStateScopeMap = createStateScopeMap<string[]>({
|
||||
key: 'recordBoardColumnIdsStateScopeMap',
|
||||
defaultValue: [],
|
||||
});
|
||||
@ -0,0 +1,8 @@
|
||||
import { RecordBoardColumnDefinition } from '@/object-record/record-board/types/RecordBoardColumnDefinition';
|
||||
import { createComponentFamilyState } from '@/ui/utilities/state/component-state/utils/createComponentFamilyState';
|
||||
|
||||
export const recordBoardColumnsComponentFamilyState =
|
||||
createComponentFamilyState<RecordBoardColumnDefinition | undefined, string>({
|
||||
key: 'recordBoardColumnsComponentFamilyState',
|
||||
defaultValue: undefined,
|
||||
});
|
||||
@ -1,10 +0,0 @@
|
||||
import { RecordBoardColumnDefinition } from '@/object-record/record-board/types/RecordBoardColumnDefinition';
|
||||
import { createFamilyStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createFamilyStateScopeMap';
|
||||
|
||||
export const recordBoardColumnsFamilyStateScopeMap = createFamilyStateScopeMap<
|
||||
RecordBoardColumnDefinition | undefined,
|
||||
string
|
||||
>({
|
||||
key: 'recordBoardColumnsFamilyStateScopeMap',
|
||||
defaultValue: undefined,
|
||||
});
|
||||
@ -1,10 +1,10 @@
|
||||
import { RecordBoardFieldDefinition } from '@/object-record/record-board/types/RecordBoardFieldDefinition';
|
||||
import { FieldMetadata } from '@/object-record/record-field/types/FieldMetadata';
|
||||
import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
|
||||
import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
|
||||
|
||||
export const recordBoardFieldDefinitionsStateScopeMap = createStateScopeMap<
|
||||
export const recordBoardFieldDefinitionsComponentState = createComponentState<
|
||||
RecordBoardFieldDefinition<FieldMetadata>[]
|
||||
>({
|
||||
key: 'recordBoardFieldDefinitionsStateScopeMap',
|
||||
key: 'recordBoardFieldDefinitionsComponentState',
|
||||
defaultValue: [],
|
||||
});
|
||||
@ -0,0 +1,7 @@
|
||||
import { Filter } from '@/object-record/object-filter-dropdown/types/Filter';
|
||||
import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
|
||||
|
||||
export const recordBoardFiltersComponentState = createComponentState<Filter[]>({
|
||||
key: 'recordBoardFiltersComponentState',
|
||||
defaultValue: [],
|
||||
});
|
||||
@ -1,7 +0,0 @@
|
||||
import { Filter } from '@/object-record/object-filter-dropdown/types/Filter';
|
||||
import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
|
||||
|
||||
export const recordBoardFiltersStateScopeMap = createStateScopeMap<Filter[]>({
|
||||
key: 'recordBoardFiltersStateScopeMap',
|
||||
defaultValue: [],
|
||||
});
|
||||
@ -0,0 +1,8 @@
|
||||
import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
|
||||
|
||||
export const recordBoardObjectSingularNameComponentState = createComponentState<
|
||||
string | undefined
|
||||
>({
|
||||
key: 'recordBoardObjectSingularNameComponentState',
|
||||
defaultValue: undefined,
|
||||
});
|
||||
@ -1,8 +0,0 @@
|
||||
import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
|
||||
|
||||
export const recordBoardObjectSingularNameStateScopeMap = createStateScopeMap<
|
||||
string | undefined
|
||||
>({
|
||||
key: 'recordBoardObjectSingularNameStateScopeMap',
|
||||
defaultValue: undefined,
|
||||
});
|
||||
@ -0,0 +1,7 @@
|
||||
import { createComponentFamilyState } from '@/ui/utilities/state/component-state/utils/createComponentFamilyState';
|
||||
|
||||
export const recordBoardRecordIdsByColumnIdComponentFamilyState =
|
||||
createComponentFamilyState<string[], string>({
|
||||
key: 'recordBoardRecordIdsByColumnIdComponentFamilyState',
|
||||
defaultValue: [],
|
||||
});
|
||||
@ -1,7 +0,0 @@
|
||||
import { createFamilyStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createFamilyStateScopeMap';
|
||||
|
||||
export const recordBoardRecordIdsByColumnIdFamilyStateScopeMap =
|
||||
createFamilyStateScopeMap<string[], string>({
|
||||
key: 'recordBoardRecordIdsByColumnIdFamilyStateScopeMap',
|
||||
defaultValue: [],
|
||||
});
|
||||
@ -0,0 +1,7 @@
|
||||
import { Sort } from '@/object-record/object-sort-dropdown/types/Sort';
|
||||
import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
|
||||
|
||||
export const recordBoardSortsComponentState = createComponentState<Sort[]>({
|
||||
key: 'recordBoardSortsComponentState',
|
||||
defaultValue: [],
|
||||
});
|
||||
@ -1,7 +0,0 @@
|
||||
import { Sort } from '@/object-record/object-sort-dropdown/types/Sort';
|
||||
import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
|
||||
|
||||
export const recordBoardSortsStateScopeMap = createStateScopeMap<Sort[]>({
|
||||
key: 'recordBoardSortsStateScopeMap',
|
||||
defaultValue: [],
|
||||
});
|
||||
@ -0,0 +1,118 @@
|
||||
import { isUndefined } from '@sniptt/guards';
|
||||
|
||||
import { isFirstRecordBoardColumnComponentFamilyState } from '@/object-record/record-board/states/isFirstRecordBoardColumnComponentFamilyState';
|
||||
import { isLastRecordBoardColumnComponentFamilyState } from '@/object-record/record-board/states/isLastRecordBoardColumnComponentFamilyState';
|
||||
import { recordBoardColumnIdsComponentState } from '@/object-record/record-board/states/recordBoardColumnIdsComponentState';
|
||||
import { recordBoardColumnsComponentFamilyState } from '@/object-record/record-board/states/recordBoardColumnsComponentFamilyState';
|
||||
import { RecordBoardColumnDefinition } from '@/object-record/record-board/types/RecordBoardColumnDefinition';
|
||||
import { guardRecoilDefaultValue } from '@/ui/utilities/recoil-scope/utils/guardRecoilDefaultValue';
|
||||
import { createComponentFamilySelector } from '@/ui/utilities/state/component-state/utils/createComponentFamilySelector';
|
||||
import { isNonNullable } from '~/utils/isNonNullable';
|
||||
|
||||
export const recordBoardColumnsComponentFamilySelector =
|
||||
createComponentFamilySelector<
|
||||
RecordBoardColumnDefinition | undefined,
|
||||
string
|
||||
>({
|
||||
key: 'recordBoardColumnsComponentFamilySelector',
|
||||
get:
|
||||
({
|
||||
scopeId,
|
||||
familyKey: columnId,
|
||||
}: {
|
||||
scopeId: string;
|
||||
familyKey: string;
|
||||
}) =>
|
||||
({ get }) => {
|
||||
return get(
|
||||
recordBoardColumnsComponentFamilyState({
|
||||
scopeId,
|
||||
familyKey: columnId,
|
||||
}),
|
||||
);
|
||||
},
|
||||
set:
|
||||
({
|
||||
scopeId,
|
||||
familyKey: columnId,
|
||||
}: {
|
||||
scopeId: string;
|
||||
familyKey: string;
|
||||
}) =>
|
||||
({ set, get }, newColumn) => {
|
||||
set(
|
||||
recordBoardColumnsComponentFamilyState({
|
||||
scopeId,
|
||||
familyKey: columnId,
|
||||
}),
|
||||
newColumn,
|
||||
);
|
||||
|
||||
if (guardRecoilDefaultValue(newColumn)) return;
|
||||
|
||||
const columnIds = get(recordBoardColumnIdsComponentState({ scopeId }));
|
||||
|
||||
const columns = columnIds
|
||||
.map((columnId) => {
|
||||
return get(
|
||||
recordBoardColumnsComponentFamilyState({
|
||||
scopeId,
|
||||
familyKey: columnId,
|
||||
}),
|
||||
);
|
||||
})
|
||||
.filter(isNonNullable);
|
||||
|
||||
const lastColumn = [...columns].sort(
|
||||
(a, b) => b.position - a.position,
|
||||
)[0];
|
||||
|
||||
const firstColumn = [...columns].sort(
|
||||
(a, b) => a.position - b.position,
|
||||
)[0];
|
||||
|
||||
if (!newColumn) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!lastColumn || newColumn.position > lastColumn.position) {
|
||||
set(
|
||||
isLastRecordBoardColumnComponentFamilyState({
|
||||
scopeId,
|
||||
familyKey: columnId,
|
||||
}),
|
||||
true,
|
||||
);
|
||||
|
||||
if (!isUndefined(lastColumn)) {
|
||||
set(
|
||||
isLastRecordBoardColumnComponentFamilyState({
|
||||
scopeId,
|
||||
familyKey: lastColumn.id,
|
||||
}),
|
||||
false,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (!firstColumn || newColumn.position < firstColumn.position) {
|
||||
set(
|
||||
isFirstRecordBoardColumnComponentFamilyState({
|
||||
scopeId,
|
||||
familyKey: columnId,
|
||||
}),
|
||||
true,
|
||||
);
|
||||
|
||||
if (!isUndefined(firstColumn)) {
|
||||
set(
|
||||
isFirstRecordBoardColumnComponentFamilyState({
|
||||
scopeId,
|
||||
familyKey: firstColumn.id,
|
||||
}),
|
||||
false,
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
@ -1,115 +0,0 @@
|
||||
import { isFirstRecordBoardColumnFamilyStateScopeMap } from '@/object-record/record-board/states/isFirstRecordBoardColumnFamilyStateScopeMap';
|
||||
import { isLastRecordBoardColumnFamilyStateScopeMap } from '@/object-record/record-board/states/isLastRecordBoardColumnFamilyStateScopeMap';
|
||||
import { recordBoardColumnIdsStateScopeMap } from '@/object-record/record-board/states/recordBoardColumnIdsStateScopeMap';
|
||||
import { recordBoardColumnsFamilyStateScopeMap } from '@/object-record/record-board/states/recordBoardColumnsFamilyStateScopeMap';
|
||||
import { RecordBoardColumnDefinition } from '@/object-record/record-board/types/RecordBoardColumnDefinition';
|
||||
import { createFamilySelectorScopeMap } from '@/ui/utilities/recoil-scope/utils/createFamilySelectorScopeMap';
|
||||
import { guardRecoilDefaultValue } from '@/ui/utilities/recoil-scope/utils/guardRecoilDefaultValue';
|
||||
import { isNonNullable } from '~/utils/isNonNullable';
|
||||
|
||||
export const recordBoardColumnsFamilySelectorScopeMap =
|
||||
createFamilySelectorScopeMap<RecordBoardColumnDefinition | undefined, string>(
|
||||
{
|
||||
key: 'recordBoardColumnsFamilySelectorScopeMap',
|
||||
get:
|
||||
({
|
||||
scopeId,
|
||||
familyKey: columnId,
|
||||
}: {
|
||||
scopeId: string;
|
||||
familyKey: string;
|
||||
}) =>
|
||||
({ get }) => {
|
||||
return get(
|
||||
recordBoardColumnsFamilyStateScopeMap({
|
||||
scopeId,
|
||||
familyKey: columnId,
|
||||
}),
|
||||
);
|
||||
},
|
||||
set:
|
||||
({
|
||||
scopeId,
|
||||
familyKey: columnId,
|
||||
}: {
|
||||
scopeId: string;
|
||||
familyKey: string;
|
||||
}) =>
|
||||
({ set, get }, newColumn) => {
|
||||
set(
|
||||
recordBoardColumnsFamilyStateScopeMap({
|
||||
scopeId,
|
||||
familyKey: columnId,
|
||||
}),
|
||||
newColumn,
|
||||
);
|
||||
|
||||
if (guardRecoilDefaultValue(newColumn)) return;
|
||||
|
||||
const columnIds = get(recordBoardColumnIdsStateScopeMap({ scopeId }));
|
||||
|
||||
const columns = columnIds
|
||||
.map((columnId) => {
|
||||
return get(
|
||||
recordBoardColumnsFamilyStateScopeMap({
|
||||
scopeId,
|
||||
familyKey: columnId,
|
||||
}),
|
||||
);
|
||||
})
|
||||
.filter(isNonNullable);
|
||||
|
||||
const lastColumn = [...columns].sort(
|
||||
(a, b) => b.position - a.position,
|
||||
)[0];
|
||||
|
||||
const firstColumn = [...columns].sort(
|
||||
(a, b) => a.position - b.position,
|
||||
)[0];
|
||||
|
||||
if (!newColumn) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!lastColumn || newColumn.position > lastColumn.position) {
|
||||
set(
|
||||
isLastRecordBoardColumnFamilyStateScopeMap({
|
||||
scopeId,
|
||||
familyKey: columnId,
|
||||
}),
|
||||
true,
|
||||
);
|
||||
|
||||
if (isNonNullable(lastColumn)) {
|
||||
set(
|
||||
isLastRecordBoardColumnFamilyStateScopeMap({
|
||||
scopeId,
|
||||
familyKey: lastColumn.id,
|
||||
}),
|
||||
false,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (!firstColumn || newColumn.position < firstColumn.position) {
|
||||
set(
|
||||
isFirstRecordBoardColumnFamilyStateScopeMap({
|
||||
scopeId,
|
||||
familyKey: columnId,
|
||||
}),
|
||||
true,
|
||||
);
|
||||
|
||||
if (isNonNullable(firstColumn)) {
|
||||
set(
|
||||
isFirstRecordBoardColumnFamilyStateScopeMap({
|
||||
scopeId,
|
||||
familyKey: firstColumn.id,
|
||||
}),
|
||||
false,
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
);
|
||||
@ -0,0 +1,35 @@
|
||||
import { isRecordBoardCardSelectedComponentFamilyState } from '@/object-record/record-board/states/isRecordBoardCardSelectedComponentFamilyState';
|
||||
import { recordBoardColumnIdsComponentState } from '@/object-record/record-board/states/recordBoardColumnIdsComponentState';
|
||||
import { recordBoardRecordIdsByColumnIdComponentFamilyState } from '@/object-record/record-board/states/recordBoardRecordIdsByColumnIdComponentFamilyState';
|
||||
import { createComponentReadOnlySelector } from '@/ui/utilities/state/component-state/utils/createComponentReadOnlySelector';
|
||||
|
||||
export const recordBoardSelectedRecordIdsComponentSelector =
|
||||
createComponentReadOnlySelector<string[]>({
|
||||
key: 'recordBoardSelectedRecordIdsSelector',
|
||||
get:
|
||||
({ scopeId }) =>
|
||||
({ get }) => {
|
||||
const columnIds = get(recordBoardColumnIdsComponentState({ scopeId }));
|
||||
|
||||
const recordIdsByColumn = columnIds.map((columnId) =>
|
||||
get(
|
||||
recordBoardRecordIdsByColumnIdComponentFamilyState({
|
||||
scopeId,
|
||||
familyKey: columnId,
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
const recordIds = recordIdsByColumn.flat();
|
||||
|
||||
return recordIds.filter(
|
||||
(recordId) =>
|
||||
get(
|
||||
isRecordBoardCardSelectedComponentFamilyState({
|
||||
scopeId,
|
||||
familyKey: recordId,
|
||||
}),
|
||||
) === true,
|
||||
);
|
||||
},
|
||||
});
|
||||
@ -1,35 +0,0 @@
|
||||
import { isRecordBoardCardSelectedFamilyStateScopeMap } from '@/object-record/record-board/states/isRecordBoardCardSelectedFamilyStateScopeMap';
|
||||
import { recordBoardColumnIdsStateScopeMap } from '@/object-record/record-board/states/recordBoardColumnIdsStateScopeMap';
|
||||
import { recordBoardRecordIdsByColumnIdFamilyStateScopeMap } from '@/object-record/record-board/states/recordBoardRecordIdsByColumnIdFamilyStateScopeMap';
|
||||
import { createSelectorReadOnlyScopeMap } from '@/ui/utilities/recoil-scope/utils/createSelectorReadOnlyScopeMap';
|
||||
|
||||
export const recordBoardSelectedRecordIdsSelectorScopeMap =
|
||||
createSelectorReadOnlyScopeMap<string[]>({
|
||||
key: 'recordBoardSelectedRecordIdsSelectorScopeMap',
|
||||
get:
|
||||
({ scopeId }) =>
|
||||
({ get }) => {
|
||||
const columnIds = get(recordBoardColumnIdsStateScopeMap({ scopeId }));
|
||||
|
||||
const recordIdsByColumn = columnIds.map((columnId) =>
|
||||
get(
|
||||
recordBoardRecordIdsByColumnIdFamilyStateScopeMap({
|
||||
scopeId,
|
||||
familyKey: columnId,
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
const recordIds = recordIdsByColumn.flat();
|
||||
|
||||
return recordIds.filter(
|
||||
(recordId) =>
|
||||
get(
|
||||
isRecordBoardCardSelectedFamilyStateScopeMap({
|
||||
scopeId,
|
||||
familyKey: recordId,
|
||||
}),
|
||||
) === true,
|
||||
);
|
||||
},
|
||||
});
|
||||
@ -0,0 +1,13 @@
|
||||
import { recordBoardFieldDefinitionsComponentState } from '@/object-record/record-board/states/recordBoardFieldDefinitionsComponentState';
|
||||
import { createComponentReadOnlySelector } from '@/ui/utilities/state/component-state/utils/createComponentReadOnlySelector';
|
||||
|
||||
export const recordBoardVisibleFieldDefinitionsComponentSelector =
|
||||
createComponentReadOnlySelector({
|
||||
key: 'recordBoardVisibleFieldDefinitionsComponentSelector',
|
||||
get:
|
||||
({ scopeId }) =>
|
||||
({ get }) =>
|
||||
get(recordBoardFieldDefinitionsComponentState({ scopeId }))
|
||||
.filter((field) => field.isVisible)
|
||||
.sort((a, b) => a.position - b.position),
|
||||
});
|
||||
@ -1,13 +0,0 @@
|
||||
import { recordBoardFieldDefinitionsStateScopeMap } from '@/object-record/record-board/states/recordBoardFieldDefinitionsStateScopeMap';
|
||||
import { createSelectorReadOnlyScopeMap } from '@/ui/utilities/recoil-scope/utils/createSelectorReadOnlyScopeMap';
|
||||
|
||||
export const recordBoardVisibleFieldDefinitionsScopedSelector =
|
||||
createSelectorReadOnlyScopeMap({
|
||||
key: 'recordBoardVisibleFieldDefinitionsScopedSelector',
|
||||
get:
|
||||
({ scopeId }) =>
|
||||
({ get }) =>
|
||||
get(recordBoardFieldDefinitionsStateScopeMap({ scopeId }))
|
||||
.filter((field) => field.isVisible)
|
||||
.sort((a, b) => a.position - b.position),
|
||||
});
|
||||
@ -1,9 +1,9 @@
|
||||
import { RecordFieldInputScopeInternalContext } from '@/object-record/record-field/scopes/scope-internal-context/RecordFieldInputScopeInternalContext';
|
||||
import { recordFieldInputDraftValueSelectorScopeMap } from '@/object-record/record-field/states/selectors/recordFieldInputDraftValueSelectorScopeMap';
|
||||
import { recordFieldInputDraftValueComponentSelector } from '@/object-record/record-field/states/selectors/recordFieldInputDraftValueComponentSelector';
|
||||
import { FieldInputDraftValue } from '@/object-record/record-field/types/FieldInputDraftValue';
|
||||
import { useAvailableScopeIdOrThrow } from '@/ui/utilities/recoil-scope/scopes-internal/hooks/useAvailableScopeId';
|
||||
import { getScopeIdOrUndefinedFromComponentId } from '@/ui/utilities/recoil-scope/utils/getScopeIdOrUndefinedFromComponentId';
|
||||
import { getSelector } from '@/ui/utilities/recoil-scope/utils/getSelector';
|
||||
import { extractComponentSelector } from '@/ui/utilities/state/component-state/utils/extractComponentSelector';
|
||||
|
||||
export const useRecordFieldInputStates = <FieldValue>(
|
||||
recordFieldInputId?: string,
|
||||
@ -15,8 +15,8 @@ export const useRecordFieldInputStates = <FieldValue>(
|
||||
|
||||
return {
|
||||
scopeId,
|
||||
getDraftValueSelector: getSelector<
|
||||
getDraftValueSelector: extractComponentSelector<
|
||||
FieldInputDraftValue<FieldValue> | undefined
|
||||
>(recordFieldInputDraftValueSelectorScopeMap, scopeId),
|
||||
>(recordFieldInputDraftValueComponentSelector, scopeId),
|
||||
};
|
||||
};
|
||||
|
||||
@ -30,9 +30,9 @@ import {
|
||||
} from '../RelationFieldInput';
|
||||
|
||||
const RelationWorkspaceSetterEffect = () => {
|
||||
const setCurrentWorkspace = useSetRecoilState(currentWorkspaceState);
|
||||
const setCurrentWorkspace = useSetRecoilState(currentWorkspaceState());
|
||||
const setCurrentWorkspaceMember = useSetRecoilState(
|
||||
currentWorkspaceMemberState,
|
||||
currentWorkspaceMemberState(),
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { StateScopeMapKey } from '@/ui/utilities/recoil-scope/scopes-internal/types/StateScopeMapKey';
|
||||
import { createScopeInternalContext } from '@/ui/utilities/recoil-scope/scopes-internal/utils/createScopeInternalContext';
|
||||
import { ComponentStateKey } from '@/ui/utilities/state/component-state/types/ComponentStateKey';
|
||||
|
||||
type RecordFieldInputScopeInternalContextProps = StateScopeMapKey;
|
||||
type RecordFieldInputScopeInternalContextProps = ComponentStateKey;
|
||||
|
||||
export const RecordFieldInputScopeInternalContext =
|
||||
createScopeInternalContext<RecordFieldInputScopeInternalContextProps>();
|
||||
|
||||
@ -0,0 +1,7 @@
|
||||
import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
|
||||
|
||||
export const recordFieldInputDraftValueComponentState =
|
||||
createComponentState<any>({
|
||||
key: 'recordFieldInputDraftValueComponentState',
|
||||
defaultValue: undefined,
|
||||
});
|
||||
@ -1,8 +0,0 @@
|
||||
import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
|
||||
|
||||
export const recordFieldInputDraftValueStateScopeMap = createStateScopeMap<any>(
|
||||
{
|
||||
key: 'recordFieldInputDraftValueStateScopeMap',
|
||||
defaultValue: undefined,
|
||||
},
|
||||
);
|
||||
@ -0,0 +1,16 @@
|
||||
import { recordFieldInputDraftValueComponentState } from '@/object-record/record-field/states/recordFieldInputDraftValueComponentState';
|
||||
import { createComponentSelector } from '@/ui/utilities/state/component-state/utils/createComponentSelector';
|
||||
|
||||
export const recordFieldInputDraftValueComponentSelector =
|
||||
createComponentSelector<any>({
|
||||
key: 'recordFieldInputDraftValueComponentSelector',
|
||||
get:
|
||||
<T>({ scopeId }: { scopeId: string }) =>
|
||||
({ get }) =>
|
||||
get(recordFieldInputDraftValueComponentState({ scopeId })) as T,
|
||||
set:
|
||||
<T>({ scopeId }: { scopeId: string }) =>
|
||||
({ set }, newValue: T) => {
|
||||
set(recordFieldInputDraftValueComponentState({ scopeId }), newValue);
|
||||
},
|
||||
});
|
||||
@ -1,16 +0,0 @@
|
||||
import { recordFieldInputDraftValueStateScopeMap } from '@/object-record/record-field/states/recordFieldInputDraftValueStateScopeMap';
|
||||
import { createSelectorScopeMap } from '@/ui/utilities/recoil-scope/utils/createSelectorScopeMap';
|
||||
|
||||
export const recordFieldInputDraftValueSelectorScopeMap =
|
||||
createSelectorScopeMap<any>({
|
||||
key: 'recordFieldInputDraftValueSelectorScopeMap',
|
||||
get:
|
||||
<T>({ scopeId }: { scopeId: string }) =>
|
||||
({ get }) =>
|
||||
get(recordFieldInputDraftValueStateScopeMap({ scopeId })) as T,
|
||||
set:
|
||||
<T>({ scopeId }: { scopeId: string }) =>
|
||||
({ set }, newValue: T) => {
|
||||
set(recordFieldInputDraftValueStateScopeMap({ scopeId }), newValue);
|
||||
},
|
||||
});
|
||||
@ -78,7 +78,7 @@ export const RecordIndexBoardContainerEffect = ({
|
||||
]);
|
||||
|
||||
const recordIndexFieldDefinitions = useRecoilValue(
|
||||
recordIndexFieldDefinitionsState,
|
||||
recordIndexFieldDefinitionsState(),
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@ -47,7 +47,7 @@ export const RecordIndexContainer = ({
|
||||
objectNamePlural,
|
||||
}: RecordIndexContainerProps) => {
|
||||
const [recordIndexViewType, setRecordIndexViewType] = useRecoilState(
|
||||
recordIndexViewTypeState,
|
||||
recordIndexViewTypeState(),
|
||||
);
|
||||
const { objectNameSingular } = useObjectNameSingularFromPlural({
|
||||
objectNamePlural,
|
||||
@ -60,10 +60,10 @@ export const RecordIndexContainer = ({
|
||||
const { columnDefinitions } =
|
||||
useColumnDefinitionsFromFieldMetadata(objectMetadataItem);
|
||||
|
||||
const setRecordIndexFilters = useSetRecoilState(recordIndexFiltersState);
|
||||
const setRecordIndexSorts = useSetRecoilState(recordIndexSortsState);
|
||||
const setRecordIndexFilters = useSetRecoilState(recordIndexFiltersState());
|
||||
const setRecordIndexSorts = useSetRecoilState(recordIndexSortsState());
|
||||
const setRecordIndexIsCompactModeActive = useSetRecoilState(
|
||||
recordIndexIsCompactModeActiveState,
|
||||
recordIndexIsCompactModeActiveState(),
|
||||
);
|
||||
|
||||
const { setTableFilters, setTableSorts, setTableColumns } = useRecordTable({
|
||||
@ -85,7 +85,7 @@ export const RecordIndexContainer = ({
|
||||
);
|
||||
|
||||
const existingRecordIndexFieldDefinitions = snapshot
|
||||
.getLoadable(recordIndexFieldDefinitionsState)
|
||||
.getLoadable(recordIndexFieldDefinitionsState())
|
||||
.getValue();
|
||||
|
||||
if (
|
||||
@ -94,7 +94,10 @@ export const RecordIndexContainer = ({
|
||||
newRecordIndexFieldDefinitions,
|
||||
)
|
||||
) {
|
||||
set(recordIndexFieldDefinitionsState, newRecordIndexFieldDefinitions);
|
||||
set(
|
||||
recordIndexFieldDefinitionsState(),
|
||||
newRecordIndexFieldDefinitions,
|
||||
);
|
||||
}
|
||||
},
|
||||
[columnDefinitions, setTableColumns],
|
||||
|
||||
@ -35,14 +35,14 @@ export const useLoadRecordIndexBoard = ({
|
||||
const { setRecords: setRecordsInStore } = useSetRecordInStore();
|
||||
|
||||
const recordIndexFieldDefinitions = useRecoilValue(
|
||||
recordIndexFieldDefinitionsState,
|
||||
recordIndexFieldDefinitionsState(),
|
||||
);
|
||||
useEffect(() => {
|
||||
setFieldDefinitions(recordIndexFieldDefinitions);
|
||||
}, [recordIndexFieldDefinitions, setFieldDefinitions]);
|
||||
|
||||
const recordIndexFilters = useRecoilValue(recordIndexFiltersState);
|
||||
const recordIndexSorts = useRecoilValue(recordIndexSortsState);
|
||||
const recordIndexFilters = useRecoilValue(recordIndexFiltersState());
|
||||
const recordIndexSorts = useRecoilValue(recordIndexSortsState());
|
||||
const requestFilters = turnObjectDropdownFilterIntoQueryFilter(
|
||||
recordIndexFilters,
|
||||
objectMetadataItem?.fields ?? [],
|
||||
@ -53,7 +53,7 @@ export const useLoadRecordIndexBoard = ({
|
||||
);
|
||||
|
||||
const recordIndexIsCompactModeActive = useRecoilValue(
|
||||
recordIndexIsCompactModeActiveState,
|
||||
recordIndexIsCompactModeActiveState(),
|
||||
);
|
||||
|
||||
const {
|
||||
|
||||
@ -38,7 +38,7 @@ export const useLoadRecordIndexTable = (objectNameSingular: string) => {
|
||||
useRecordTable();
|
||||
const { getTableLastRowVisibleState } = useRecordTableStates();
|
||||
const setLastRowVisible = useSetRecoilState(getTableLastRowVisibleState());
|
||||
const currentWorkspace = useRecoilValue(currentWorkspaceState);
|
||||
const currentWorkspace = useRecoilValue(currentWorkspaceState());
|
||||
const params = useFindManyParams(objectNameSingular);
|
||||
|
||||
const {
|
||||
|
||||
@ -28,7 +28,7 @@ export const useRecordIndexOptionsForBoard = ({
|
||||
viewBarId,
|
||||
}: useRecordIndexOptionsForBoardParams) => {
|
||||
const [recordIndexFieldDefinitions, setRecordIndexFieldDefinitions] =
|
||||
useRecoilState(recordIndexFieldDefinitionsState);
|
||||
useRecoilState(recordIndexFieldDefinitionsState());
|
||||
|
||||
const { persistViewFields } = useViewFields(viewBarId);
|
||||
const { updateView } = useViews(viewBarId);
|
||||
|
||||
@ -1,11 +1,10 @@
|
||||
import { atom } from 'recoil';
|
||||
|
||||
import { FieldMetadata } from '@/object-record/record-field/types/FieldMetadata';
|
||||
import { ColumnDefinition } from '@/object-record/record-table/types/ColumnDefinition';
|
||||
import { createState } from '@/ui/utilities/state/utils/createState';
|
||||
|
||||
export const recordIndexFieldDefinitionsState = atom<
|
||||
export const recordIndexFieldDefinitionsState = createState<
|
||||
ColumnDefinition<FieldMetadata>[]
|
||||
>({
|
||||
key: 'recordIndexFieldDefinitionsState',
|
||||
default: [],
|
||||
defaultValue: [],
|
||||
});
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
import { atom } from 'recoil';
|
||||
|
||||
import { Filter } from '@/object-record/object-filter-dropdown/types/Filter';
|
||||
import { createState } from '@/ui/utilities/state/utils/createState';
|
||||
|
||||
export const recordIndexFiltersState = atom<Filter[]>({
|
||||
export const recordIndexFiltersState = createState<Filter[]>({
|
||||
key: 'recordIndexFiltersState',
|
||||
default: [],
|
||||
defaultValue: [],
|
||||
});
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { atom } from 'recoil';
|
||||
import { createState } from '@/ui/utilities/state/utils/createState';
|
||||
|
||||
export const recordIndexIsCompactModeActiveState = atom<boolean>({
|
||||
export const recordIndexIsCompactModeActiveState = createState<boolean>({
|
||||
key: 'recordIndexIsCompactModeActiveState',
|
||||
default: false,
|
||||
defaultValue: false,
|
||||
});
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
import { atom } from 'recoil';
|
||||
|
||||
import { Sort } from '@/object-record/object-sort-dropdown/types/Sort';
|
||||
import { createState } from '@/ui/utilities/state/utils/createState';
|
||||
|
||||
export const recordIndexSortsState = atom<Sort[]>({
|
||||
export const recordIndexSortsState = createState<Sort[]>({
|
||||
key: 'recordIndexSortsState',
|
||||
default: [],
|
||||
defaultValue: [],
|
||||
});
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
import { atom } from 'recoil';
|
||||
|
||||
import { createState } from '@/ui/utilities/state/utils/createState';
|
||||
import { ViewType } from '@/views/types/ViewType';
|
||||
|
||||
export const recordIndexViewTypeState = atom<ViewType | undefined>({
|
||||
export const recordIndexViewTypeState = createState<ViewType | undefined>({
|
||||
key: 'recordIndexViewTypeState',
|
||||
default: undefined,
|
||||
defaultValue: undefined,
|
||||
});
|
||||
|
||||
@ -1,11 +1,10 @@
|
||||
import { atomFamily } from 'recoil';
|
||||
|
||||
import { HotkeyScope } from '@/ui/utilities/hotkey/types/HotkeyScope';
|
||||
import { createFamilyState } from '@/ui/utilities/state/utils/createFamilyState';
|
||||
|
||||
export const customEditHotkeyScopeForFieldScopedState = atomFamily<
|
||||
export const customEditHotkeyScopeForFieldScopedState = createFamilyState<
|
||||
HotkeyScope | null,
|
||||
string
|
||||
>({
|
||||
key: 'customEditHotkeyScopeForFieldScopedState',
|
||||
default: null,
|
||||
defaultValue: null,
|
||||
});
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
import { atomFamily } from 'recoil';
|
||||
import { createFamilyState } from '@/ui/utilities/state/utils/createFamilyState';
|
||||
|
||||
export const isInlineCellInEditModeScopedState = atomFamily<boolean, string>({
|
||||
export const isInlineCellInEditModeScopedState = createFamilyState<
|
||||
boolean,
|
||||
string
|
||||
>({
|
||||
key: 'isInlineCellInEditModeScopedState',
|
||||
default: false,
|
||||
defaultValue: false,
|
||||
});
|
||||
|
||||
@ -1,11 +1,10 @@
|
||||
import { atomFamily } from 'recoil';
|
||||
|
||||
import { HotkeyScope } from '@/ui/utilities/hotkey/types/HotkeyScope';
|
||||
import { createFamilyState } from '@/ui/utilities/state/utils/createFamilyState';
|
||||
|
||||
export const parentHotkeyScopeForFieldScopedState = atomFamily<
|
||||
export const parentHotkeyScopeForFieldScopedState = createFamilyState<
|
||||
HotkeyScope | null,
|
||||
string
|
||||
>({
|
||||
key: 'parentHotkeyScopeForFieldScopedState',
|
||||
default: null,
|
||||
defaultValue: null,
|
||||
});
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { atomFamily } from 'recoil';
|
||||
import { createFamilyState } from '@/ui/utilities/state/utils/createFamilyState';
|
||||
|
||||
export const recordLoadingFamilyState = atomFamily<boolean, string>({
|
||||
export const recordLoadingFamilyState = createFamilyState<boolean, string>({
|
||||
key: 'recordLoadingFamilyState',
|
||||
default: false,
|
||||
defaultValue: false,
|
||||
});
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
import { atomFamily } from 'recoil';
|
||||
|
||||
import { ObjectRecord } from '@/object-record/types/ObjectRecord';
|
||||
import { createFamilyState } from '@/ui/utilities/state/utils/createFamilyState';
|
||||
|
||||
export const recordStoreFamilyState = atomFamily<ObjectRecord | null, string>({
|
||||
export const recordStoreFamilyState = createFamilyState<
|
||||
ObjectRecord | null,
|
||||
string
|
||||
>({
|
||||
key: 'recordStoreFamilyState',
|
||||
default: null,
|
||||
defaultValue: null,
|
||||
});
|
||||
|
||||
@ -17,7 +17,7 @@ export const recordStoreIdentifierFamilySelector = selectorFamily({
|
||||
({ get }) => {
|
||||
const recordFromStore = get(recordStoreFamilyState(recordId));
|
||||
|
||||
const objectMetadataItems = get(objectMetadataItemsState);
|
||||
const objectMetadataItems = get(objectMetadataItemsState());
|
||||
|
||||
const objectMetadataItem = objectMetadataItems.find(
|
||||
(item) => item.nameSingular === objectNameSingular,
|
||||
|
||||
@ -22,7 +22,7 @@ const StyledContainer = styled.div`
|
||||
export const CheckboxCell = () => {
|
||||
const { recordId } = useContext(RecordTableRowContext);
|
||||
const { isRowSelectedFamilyState } = useRecordTableStates();
|
||||
const setActionBarOpenState = useSetRecoilState(actionBarOpenState);
|
||||
const setActionBarOpenState = useSetRecoilState(actionBarOpenState());
|
||||
const { setCurrentRowSelected } = useSetCurrentRowSelected();
|
||||
const currentRowSelected = useRecoilValue(isRowSelectedFamilyState(recordId));
|
||||
|
||||
|
||||
@ -53,7 +53,7 @@ export const ColumnHead = ({ column }: ColumnHeadProps) => {
|
||||
const { getIcon } = useIcons();
|
||||
const Icon = getIcon(column.iconName);
|
||||
|
||||
const scrollLeft = useRecoilValue(scrollLeftState);
|
||||
const scrollLeft = useRecoilValue(scrollLeftState());
|
||||
|
||||
return (
|
||||
<StyledTitle hideTitle={!!column.isLabelIdentifier && scrollLeft > 0}>
|
||||
|
||||
@ -122,7 +122,7 @@ export const RecordTable = ({
|
||||
createRecord,
|
||||
}: RecordTableProps) => {
|
||||
const { scopeId } = useRecordTableStates(recordTableId);
|
||||
const scrollLeft = useRecoilValue(scrollLeftState);
|
||||
const scrollLeft = useRecoilValue(scrollLeftState());
|
||||
|
||||
const { objectMetadataItem } = useObjectMetadataItemOnly({
|
||||
objectNameSingular,
|
||||
|
||||
@ -23,8 +23,8 @@ const StyledContainer = styled.td<{ isSelected: boolean }>`
|
||||
`;
|
||||
|
||||
export const RecordTableCellContainer = () => {
|
||||
const setContextMenuPosition = useSetRecoilState(contextMenuPositionState);
|
||||
const setContextMenuOpenState = useSetRecoilState(contextMenuIsOpenState);
|
||||
const setContextMenuPosition = useSetRecoilState(contextMenuPositionState());
|
||||
const setContextMenuOpenState = useSetRecoilState(contextMenuIsOpenState());
|
||||
|
||||
const { setCurrentRowSelected } = useSetCurrentRowSelected();
|
||||
|
||||
|
||||
@ -165,7 +165,7 @@ export const RecordTableHeaderCell = ({
|
||||
});
|
||||
|
||||
const isMobile = useIsMobile();
|
||||
const scrollLeft = useRecoilValue(scrollLeftState);
|
||||
const scrollLeft = useRecoilValue(scrollLeftState());
|
||||
|
||||
const disableColumnResize =
|
||||
column.isLabelIdentifier && isMobile && scrollLeft > 0;
|
||||
|
||||
@ -25,7 +25,7 @@ export const useLeaveTableFocus = (recordTableId?: string) => {
|
||||
);
|
||||
|
||||
const currentHotkeyScope = snapshot
|
||||
.getLoadable(currentHotkeyScopeState)
|
||||
.getLoadable(currentHotkeyScopeState())
|
||||
.getValue();
|
||||
|
||||
if (!isSoftFocusActive) {
|
||||
|
||||
@ -1,31 +1,31 @@
|
||||
import { isRowSelectedFamilyStateScopeMap } from '@/object-record/record-table/record-table-row/states/isRowSelectedFamilyStateScopeMap';
|
||||
import { isRowSelectedComponentFamilyState } from '@/object-record/record-table/record-table-row/states/isRowSelectedComponentFamilyState';
|
||||
import { RecordTableScopeInternalContext } from '@/object-record/record-table/scopes/scope-internal-context/RecordTableScopeInternalContext';
|
||||
import { availableTableColumnsStateScopeMap } from '@/object-record/record-table/states/availableTableColumnsStateScopeMap';
|
||||
import { currentTableCellInEditModePositionStateScopeMap } from '@/object-record/record-table/states/currentTableCellInEditModePositionStateScopeMap';
|
||||
import { isRecordTableInitialLoadingStateScopeMap } from '@/object-record/record-table/states/isRecordTableInitialLoadingStateScopeMap';
|
||||
import { isSoftFocusActiveStateScopeMap } from '@/object-record/record-table/states/isSoftFocusActiveStateScopeMap';
|
||||
import { isSoftFocusOnTableCellFamilyStateScopeMap } from '@/object-record/record-table/states/isSoftFocusOnTableCellFamilyStateScopeMap';
|
||||
import { isTableCellInEditModeFamilyStateScopeMap } from '@/object-record/record-table/states/isTableCellInEditModeFamilyStateScopeMap';
|
||||
import { numberOfTableRowsStateScopeMap } from '@/object-record/record-table/states/numberOfTableRowsStateScopeMap';
|
||||
import { onColumnsChangeStateScopeMap } from '@/object-record/record-table/states/onColumnsChangeStateScopeMap';
|
||||
import { onEntityCountChangeStateScopeMap } from '@/object-record/record-table/states/onEntityCountChangeStateScopeMap';
|
||||
import { resizeFieldOffsetStateScopeMap } from '@/object-record/record-table/states/resizeFieldOffsetStateScopeMap';
|
||||
import { allRowsSelectedStatusSelectorScopeMap } from '@/object-record/record-table/states/selectors/allRowsSelectedStatusSelectorScopeMap';
|
||||
import { hiddenTableColumnsSelectorScopeMap } from '@/object-record/record-table/states/selectors/hiddenTableColumnsSelectorScopeMap';
|
||||
import { numberOfTableColumnsSelectorScopeMap } from '@/object-record/record-table/states/selectors/numberOfTableColumnsSelectorScopeMap';
|
||||
import { selectedRowIdsSelectorScopeMap } from '@/object-record/record-table/states/selectors/selectedRowIdsSelectorScopeMap';
|
||||
import { visibleTableColumnsSelectorScopeMap } from '@/object-record/record-table/states/selectors/visibleTableColumnsSelectorScopeMap';
|
||||
import { softFocusPositionStateScopeMap } from '@/object-record/record-table/states/softFocusPositionStateScopeMap';
|
||||
import { tableColumnsStateScopeMap } from '@/object-record/record-table/states/tableColumnsStateScopeMap';
|
||||
import { tableFiltersStateScopeMap } from '@/object-record/record-table/states/tableFiltersStateScopeMap';
|
||||
import { tableLastRowVisibleStateScopeMap } from '@/object-record/record-table/states/tableLastRowVisibleStateScopeMap';
|
||||
import { tableRowIdsStateScopeMap } from '@/object-record/record-table/states/tableRowIdsStateScopeMap';
|
||||
import { tableSortsStateScopeMap } from '@/object-record/record-table/states/tableSortsStateScopeMap';
|
||||
import { availableTableColumnsComponentState } from '@/object-record/record-table/states/availableTableColumnsComponentState';
|
||||
import { currentTableCellInEditModePositionComponentState } from '@/object-record/record-table/states/currentTableCellInEditModePositionComponentState';
|
||||
import { isRecordTableInitialLoadingComponentState } from '@/object-record/record-table/states/isRecordTableInitialLoadingComponentState';
|
||||
import { isSoftFocusActiveComponentState } from '@/object-record/record-table/states/isSoftFocusActiveComponentState';
|
||||
import { isSoftFocusOnTableCellComponentFamilyState } from '@/object-record/record-table/states/isSoftFocusOnTableCellComponentFamilyState';
|
||||
import { isTableCellInEditModeComponentFamilyState } from '@/object-record/record-table/states/isTableCellInEditModeComponentFamilyState';
|
||||
import { numberOfTableRowsComponentState } from '@/object-record/record-table/states/numberOfTableRowsComponentState';
|
||||
import { onColumnsChangeComponentState } from '@/object-record/record-table/states/onColumnsChangeComponentState';
|
||||
import { onEntityCountChangeComponentState } from '@/object-record/record-table/states/onEntityCountChangeComponentState';
|
||||
import { resizeFieldOffsetComponentState } from '@/object-record/record-table/states/resizeFieldOffsetComponentState';
|
||||
import { allRowsSelectedStatusComponentSelector } from '@/object-record/record-table/states/selectors/allRowsSelectedStatusComponentSelector';
|
||||
import { hiddenTableColumnsComponentSelector } from '@/object-record/record-table/states/selectors/hiddenTableColumnsComponentSelector';
|
||||
import { numberOfTableColumnsComponentSelector } from '@/object-record/record-table/states/selectors/numberOfTableColumnsComponentSelector';
|
||||
import { selectedRowIdsComponentSelector } from '@/object-record/record-table/states/selectors/selectedRowIdsComponentSelector';
|
||||
import { visibleTableColumnsComponentSelector } from '@/object-record/record-table/states/selectors/visibleTableColumnsComponentSelector';
|
||||
import { softFocusPositionComponentState } from '@/object-record/record-table/states/softFocusPositionComponentState';
|
||||
import { tableColumnsComponentState } from '@/object-record/record-table/states/tableColumnsComponentState';
|
||||
import { tableFiltersComponentState } from '@/object-record/record-table/states/tableFiltersComponentState';
|
||||
import { tableLastRowVisibleComponentState } from '@/object-record/record-table/states/tableLastRowVisibleComponentState';
|
||||
import { tableRowIdsComponentState } from '@/object-record/record-table/states/tableRowIdsComponentState';
|
||||
import { tableSortsComponentState } from '@/object-record/record-table/states/tableSortsComponentState';
|
||||
import { useAvailableScopeIdOrThrow } from '@/ui/utilities/recoil-scope/scopes-internal/hooks/useAvailableScopeId';
|
||||
import { getFamilyState } from '@/ui/utilities/recoil-scope/utils/getFamilyState';
|
||||
import { getScopeIdOrUndefinedFromComponentId } from '@/ui/utilities/recoil-scope/utils/getScopeIdOrUndefinedFromComponentId';
|
||||
import { getSelectorReadOnly } from '@/ui/utilities/recoil-scope/utils/getSelectorReadOnly';
|
||||
import { getState } from '@/ui/utilities/recoil-scope/utils/getState';
|
||||
import { extractComponentFamilyState } from '@/ui/utilities/state/component-state/utils/extractComponentFamilyState';
|
||||
import { extractComponentReadOnlySelector } from '@/ui/utilities/state/component-state/utils/extractComponentReadOnlySelector';
|
||||
import { extractComponentState } from '@/ui/utilities/state/component-state/utils/extractComponentState';
|
||||
|
||||
export const useRecordTableStates = (recordTableId?: string) => {
|
||||
const scopeId = useAvailableScopeIdOrThrow(
|
||||
@ -35,78 +35,93 @@ export const useRecordTableStates = (recordTableId?: string) => {
|
||||
|
||||
return {
|
||||
scopeId,
|
||||
getAvailableTableColumnsState: getState(
|
||||
availableTableColumnsStateScopeMap,
|
||||
getAvailableTableColumnsState: extractComponentState(
|
||||
availableTableColumnsComponentState,
|
||||
scopeId,
|
||||
),
|
||||
getTableFiltersState: extractComponentState(
|
||||
tableFiltersComponentState,
|
||||
scopeId,
|
||||
),
|
||||
getTableSortsState: extractComponentState(
|
||||
tableSortsComponentState,
|
||||
scopeId,
|
||||
),
|
||||
getTableColumnsState: extractComponentState(
|
||||
tableColumnsComponentState,
|
||||
scopeId,
|
||||
),
|
||||
getTableFiltersState: getState(tableFiltersStateScopeMap, scopeId),
|
||||
getTableSortsState: getState(tableSortsStateScopeMap, scopeId),
|
||||
getTableColumnsState: getState(tableColumnsStateScopeMap, scopeId),
|
||||
|
||||
getOnColumnsChangeState: getState(onColumnsChangeStateScopeMap, scopeId),
|
||||
getOnEntityCountChangeState: getState(
|
||||
onEntityCountChangeStateScopeMap,
|
||||
getOnColumnsChangeState: extractComponentState(
|
||||
onColumnsChangeComponentState,
|
||||
scopeId,
|
||||
),
|
||||
getTableLastRowVisibleState: getState(
|
||||
tableLastRowVisibleStateScopeMap,
|
||||
getOnEntityCountChangeState: extractComponentState(
|
||||
onEntityCountChangeComponentState,
|
||||
scopeId,
|
||||
),
|
||||
getSoftFocusPositionState: getState(
|
||||
softFocusPositionStateScopeMap,
|
||||
getTableLastRowVisibleState: extractComponentState(
|
||||
tableLastRowVisibleComponentState,
|
||||
scopeId,
|
||||
),
|
||||
getNumberOfTableRowsState: getState(
|
||||
numberOfTableRowsStateScopeMap,
|
||||
getSoftFocusPositionState: extractComponentState(
|
||||
softFocusPositionComponentState,
|
||||
scopeId,
|
||||
),
|
||||
getCurrentTableCellInEditModePositionState: getState(
|
||||
currentTableCellInEditModePositionStateScopeMap,
|
||||
getNumberOfTableRowsState: extractComponentState(
|
||||
numberOfTableRowsComponentState,
|
||||
scopeId,
|
||||
),
|
||||
isTableCellInEditModeFamilyState: getFamilyState(
|
||||
isTableCellInEditModeFamilyStateScopeMap,
|
||||
getCurrentTableCellInEditModePositionState: extractComponentState(
|
||||
currentTableCellInEditModePositionComponentState,
|
||||
scopeId,
|
||||
),
|
||||
getIsSoftFocusActiveState: getState(
|
||||
isSoftFocusActiveStateScopeMap,
|
||||
isTableCellInEditModeFamilyState: extractComponentFamilyState(
|
||||
isTableCellInEditModeComponentFamilyState,
|
||||
scopeId,
|
||||
),
|
||||
getTableRowIdsState: getState(tableRowIdsStateScopeMap, scopeId),
|
||||
getIsRecordTableInitialLoadingState: getState(
|
||||
isRecordTableInitialLoadingStateScopeMap,
|
||||
getIsSoftFocusActiveState: extractComponentState(
|
||||
isSoftFocusActiveComponentState,
|
||||
scopeId,
|
||||
),
|
||||
getResizeFieldOffsetState: getState(
|
||||
resizeFieldOffsetStateScopeMap,
|
||||
getTableRowIdsState: extractComponentState(
|
||||
tableRowIdsComponentState,
|
||||
scopeId,
|
||||
),
|
||||
isSoftFocusOnTableCellFamilyState: getFamilyState(
|
||||
isSoftFocusOnTableCellFamilyStateScopeMap,
|
||||
getIsRecordTableInitialLoadingState: extractComponentState(
|
||||
isRecordTableInitialLoadingComponentState,
|
||||
scopeId,
|
||||
),
|
||||
isRowSelectedFamilyState: getFamilyState(
|
||||
isRowSelectedFamilyStateScopeMap,
|
||||
getResizeFieldOffsetState: extractComponentState(
|
||||
resizeFieldOffsetComponentState,
|
||||
scopeId,
|
||||
),
|
||||
getAllRowsSelectedStatusSelector: getSelectorReadOnly(
|
||||
allRowsSelectedStatusSelectorScopeMap,
|
||||
isSoftFocusOnTableCellFamilyState: extractComponentFamilyState(
|
||||
isSoftFocusOnTableCellComponentFamilyState,
|
||||
scopeId,
|
||||
),
|
||||
getHiddenTableColumnsSelector: getSelectorReadOnly(
|
||||
hiddenTableColumnsSelectorScopeMap,
|
||||
isRowSelectedFamilyState: extractComponentFamilyState(
|
||||
isRowSelectedComponentFamilyState,
|
||||
scopeId,
|
||||
),
|
||||
getNumberOfTableColumnsSelector: getSelectorReadOnly(
|
||||
numberOfTableColumnsSelectorScopeMap,
|
||||
getAllRowsSelectedStatusSelector: extractComponentReadOnlySelector(
|
||||
allRowsSelectedStatusComponentSelector,
|
||||
scopeId,
|
||||
),
|
||||
getSelectedRowIdsSelector: getSelectorReadOnly(
|
||||
selectedRowIdsSelectorScopeMap,
|
||||
getHiddenTableColumnsSelector: extractComponentReadOnlySelector(
|
||||
hiddenTableColumnsComponentSelector,
|
||||
scopeId,
|
||||
),
|
||||
getVisibleTableColumnsSelector: getSelectorReadOnly(
|
||||
visibleTableColumnsSelectorScopeMap,
|
||||
getNumberOfTableColumnsSelector: extractComponentReadOnlySelector(
|
||||
numberOfTableColumnsComponentSelector,
|
||||
scopeId,
|
||||
),
|
||||
getSelectedRowIdsSelector: extractComponentReadOnlySelector(
|
||||
selectedRowIdsComponentSelector,
|
||||
scopeId,
|
||||
),
|
||||
getVisibleTableColumnsSelector: extractComponentReadOnlySelector(
|
||||
visibleTableColumnsComponentSelector,
|
||||
scopeId,
|
||||
),
|
||||
};
|
||||
|
||||
@ -128,7 +128,7 @@ export const useRecordTable = (props?: useRecordTableProps) => {
|
||||
const setHotkeyScope = useSetHotkeyScope();
|
||||
|
||||
const setIsSoftFocusUsingMouseState = useSetRecoilState(
|
||||
isSoftFocusUsingMouseState,
|
||||
isSoftFocusUsingMouseState(),
|
||||
);
|
||||
|
||||
useScopedHotkeys(
|
||||
|
||||
@ -64,7 +64,7 @@ export const RecordTableCellContainer = ({
|
||||
const isSomeCellInEditMode = useRecoilValue(isSomeCellInEditModeState());
|
||||
|
||||
const setIsSoftFocusUsingMouseState = useSetRecoilState(
|
||||
isSoftFocusUsingMouseState,
|
||||
isSoftFocusUsingMouseState(),
|
||||
);
|
||||
|
||||
const moveSoftFocusToCurrentCellOnHover =
|
||||
|
||||
@ -24,7 +24,7 @@ export const RecordTableCellSoftFocusMode = ({
|
||||
const toggleEditOnlyInput = useToggleEditOnlyInput();
|
||||
const scrollRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
const isSoftFocusUsingMouse = useRecoilValue(isSoftFocusUsingMouseState);
|
||||
const isSoftFocusUsingMouse = useRecoilValue(isSoftFocusUsingMouseState());
|
||||
|
||||
useEffect(() => {
|
||||
if (!isSoftFocusUsingMouse) {
|
||||
|
||||
@ -13,19 +13,19 @@ import { TableCellPosition } from '@/object-record/record-table/types/TableCellP
|
||||
import { TableHotkeyScope } from '@/object-record/record-table/types/TableHotkeyScope';
|
||||
|
||||
const mockSoftFocusPositionState = {
|
||||
key: 'softFocusPositionStateScopeMap__{"scopeId":"scopeId"}',
|
||||
key: 'softFocusPositionComponentState__{"scopeId":"scopeId"}',
|
||||
};
|
||||
const mockSoftFocusActiveState = {
|
||||
key: 'isSoftFocusActiveStateScopeMap__{"scopeId":"scopeId"}',
|
||||
key: 'isSoftFocusActiveComponentState__{"scopeId":"scopeId"}',
|
||||
};
|
||||
const mockIsSoftFocusOnTableCellFamilyState = {
|
||||
key: 'isSoftFocusOnTableCellFamilyStateScopeMap__{"familyKey":{"column":1,"row":0},"scopeId":"scopeId"}',
|
||||
key: 'isSoftFocusOnTableCellFamilyComponentState__{"familyKey":{"column":1,"row":0},"scopeId":"scopeId"}',
|
||||
};
|
||||
const mockCurrentTableCellInEditModePositionState = {
|
||||
key: 'currentTableCellInEditModePositionStateScopeMap__{"scopeId":"scopeId"}',
|
||||
key: 'currentTableCellInEditModePositionComponentState__{"scopeId":"scopeId"}',
|
||||
};
|
||||
const mockIsTableCellInEditModeFamilyState = {
|
||||
key: 'isTableCellInEditModeFamilyStateScopeMap__{"familyKey":{"column":1,"row":0},"scopeId":"scopeId"}',
|
||||
key: 'isTableCellInEditModeFamilyComponentState__{"familyKey":{"column":1,"row":0},"scopeId":"scopeId"}',
|
||||
};
|
||||
const mockCurrentHotKeyScopeState = {
|
||||
key: 'currentHotkeyScopeState',
|
||||
|
||||
@ -48,19 +48,14 @@ describe('useSelectedTableCellEditMode', () => {
|
||||
|
||||
expect(mockCallbackInterface.set).toHaveBeenCalledWith(
|
||||
{
|
||||
key: 'isTableCellInEditModeFamilyStateScopeMap__{"familyKey":{"column":0,"row":0},"scopeId":"yourScopeId-scope"}',
|
||||
key: 'isTableCellInEditModeComponentFamilyState__{"familyKey":{"column":0,"row":0},"scopeId":"yourScopeId-scope"}',
|
||||
},
|
||||
false,
|
||||
);
|
||||
|
||||
expect(mockCallbackInterface.set).toHaveBeenCalledWith(
|
||||
{
|
||||
key: 'currentTableCellInEditModePositionStateScopeMap__{"scopeId":"yourScopeId-scope"}',
|
||||
},
|
||||
{ column: 5, row: 1 },
|
||||
);
|
||||
expect(mockCallbackInterface.set).toHaveBeenCalledWith(
|
||||
{
|
||||
key: 'isTableCellInEditModeFamilyStateScopeMap__{"familyKey":{"column":5,"row":1},"scopeId":"yourScopeId-scope"}',
|
||||
key: 'isTableCellInEditModeComponentFamilyState__{"familyKey":{"column":5,"row":1},"scopeId":"yourScopeId-scope"}',
|
||||
},
|
||||
true,
|
||||
);
|
||||
|
||||
@ -33,7 +33,7 @@ export const useMoveSoftFocusToCurrentCellOnHover = () => {
|
||||
.getValue();
|
||||
|
||||
const currentHotkeyScope = snapshot
|
||||
.getLoadable(currentHotkeyScopeState)
|
||||
.getLoadable(currentHotkeyScopeState())
|
||||
.getValue();
|
||||
|
||||
if (
|
||||
|
||||
@ -0,0 +1,9 @@
|
||||
import { createComponentFamilyState } from '@/ui/utilities/state/component-state/utils/createComponentFamilyState';
|
||||
|
||||
export const isRowSelectedComponentFamilyState = createComponentFamilyState<
|
||||
boolean,
|
||||
string
|
||||
>({
|
||||
key: 'isRowSelectedComponentFamilyState',
|
||||
defaultValue: false,
|
||||
});
|
||||
@ -1,9 +0,0 @@
|
||||
import { createFamilyStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createFamilyStateScopeMap';
|
||||
|
||||
export const isRowSelectedFamilyStateScopeMap = createFamilyStateScopeMap<
|
||||
boolean,
|
||||
string
|
||||
>({
|
||||
key: 'isRowSelectedFamilyStateScopeMap',
|
||||
defaultValue: false,
|
||||
});
|
||||
@ -1,10 +1,10 @@
|
||||
import { FieldMetadata } from '@/object-record/record-field/types/FieldMetadata';
|
||||
import { StateScopeMapKey } from '@/ui/utilities/recoil-scope/scopes-internal/types/StateScopeMapKey';
|
||||
import { createScopeInternalContext } from '@/ui/utilities/recoil-scope/scopes-internal/utils/createScopeInternalContext';
|
||||
import { ComponentStateKey } from '@/ui/utilities/state/component-state/types/ComponentStateKey';
|
||||
|
||||
import { ColumnDefinition } from '../../types/ColumnDefinition';
|
||||
|
||||
type RecordTableScopeInternalContextProps = StateScopeMapKey & {
|
||||
type RecordTableScopeInternalContextProps = ComponentStateKey & {
|
||||
onColumnsChange: (columns: ColumnDefinition<FieldMetadata>[]) => void;
|
||||
};
|
||||
|
||||
|
||||
@ -0,0 +1,11 @@
|
||||
import { FieldMetadata } from '@/object-record/record-field/types/FieldMetadata';
|
||||
import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
|
||||
|
||||
import { ColumnDefinition } from '../types/ColumnDefinition';
|
||||
|
||||
export const availableTableColumnsComponentState = createComponentState<
|
||||
ColumnDefinition<FieldMetadata>[]
|
||||
>({
|
||||
key: 'availableTableColumnsComponentState',
|
||||
defaultValue: [],
|
||||
});
|
||||
@ -1,11 +0,0 @@
|
||||
import { FieldMetadata } from '@/object-record/record-field/types/FieldMetadata';
|
||||
import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
|
||||
|
||||
import { ColumnDefinition } from '../types/ColumnDefinition';
|
||||
|
||||
export const availableTableColumnsStateScopeMap = createStateScopeMap<
|
||||
ColumnDefinition<FieldMetadata>[]
|
||||
>({
|
||||
key: 'availableTableColumnsStateScopeMap',
|
||||
defaultValue: [],
|
||||
});
|
||||
@ -0,0 +1,12 @@
|
||||
import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
|
||||
|
||||
import { TableCellPosition } from '../types/TableCellPosition';
|
||||
|
||||
export const currentTableCellInEditModePositionComponentState =
|
||||
createComponentState<TableCellPosition>({
|
||||
key: 'currentTableCellInEditModePositionComponentState',
|
||||
defaultValue: {
|
||||
row: 0,
|
||||
column: 1,
|
||||
},
|
||||
});
|
||||
@ -1,12 +0,0 @@
|
||||
import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
|
||||
|
||||
import { TableCellPosition } from '../types/TableCellPosition';
|
||||
|
||||
export const currentTableCellInEditModePositionStateScopeMap =
|
||||
createStateScopeMap<TableCellPosition>({
|
||||
key: 'currentTableCellInEditModePositionStateScopeMap',
|
||||
defaultValue: {
|
||||
row: 0,
|
||||
column: 1,
|
||||
},
|
||||
});
|
||||
@ -0,0 +1,7 @@
|
||||
import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
|
||||
|
||||
export const isRecordTableInitialLoadingComponentState =
|
||||
createComponentState<boolean>({
|
||||
key: 'isRecordTableInitialLoadingComponentState',
|
||||
defaultValue: true,
|
||||
});
|
||||
@ -1,7 +0,0 @@
|
||||
import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
|
||||
|
||||
export const isRecordTableInitialLoadingStateScopeMap =
|
||||
createStateScopeMap<boolean>({
|
||||
key: 'isRecordTableInitialLoadingStateScopeMap',
|
||||
defaultValue: true,
|
||||
});
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user