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:
Charles Bochet
2024-03-09 11:31:00 +01:00
committed by GitHub
parent 17511be0cf
commit 86c0f311f5
451 changed files with 1718 additions and 2557 deletions

View File

@ -58,7 +58,7 @@ describe('useMultiObjectRecordsQueryResultFormattedAsObjectRecordForSelectArray'
},
},
),
setObjectMetadata: useSetRecoilState(objectMetadataItemsState),
setObjectMetadata: useSetRecoilState(objectMetadataItemsState()),
};
},
{

View File

@ -102,7 +102,7 @@ describe('useMultiObjectSearch', () => {
},
],
}),
setObjectMetadata: useSetRecoilState(objectMetadataItemsState),
setObjectMetadata: useSetRecoilState(objectMetadataItemsState()),
}),
{
wrapper: Wrapper,

View File

@ -25,7 +25,7 @@ export const useMultiObjectSearchMatchesSearchFilterAndSelectedItemsQuery = ({
searchFilterValue: string;
limit?: number;
}) => {
const objectMetadataItems = useRecoilValue(objectMetadataItemsState);
const objectMetadataItems = useRecoilValue(objectMetadataItemsState());
const { searchFilterPerMetadataItemNameSingular } =
useSearchFilterPerMetadataItem({

View File

@ -28,7 +28,7 @@ export const useMultiObjectSearchMatchesSearchFilterAndToSelectQuery = ({
searchFilterValue: string;
limit?: number;
}) => {
const objectMetadataItems = useRecoilValue(objectMetadataItemsState);
const objectMetadataItems = useRecoilValue(objectMetadataItemsState());
const nonSystemObjectMetadataItems = objectMetadataItems.filter(
({ nameSingular, isSystem }) =>

View File

@ -26,7 +26,7 @@ export const useMultiObjectSearchSelectedItemsQuery = ({
}: {
selectedObjectRecordIds: SelectedObjectRecordId[];
}) => {
const objectMetadataItems = useRecoilValue(objectMetadataItemsState);
const objectMetadataItems = useRecoilValue(objectMetadataItemsState());
const objectMetadataItemsUsedInSelectedIdsQuery = objectMetadataItems.filter(
({ nameSingular }) => {

View File

@ -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 RelationPickerScopeInternalContextProps = StateScopeMapKey;
type RelationPickerScopeInternalContextProps = ComponentStateKey;
export const RelationPickerScopeInternalContext =
createScopeInternalContext<RelationPickerScopeInternalContextProps>();

View File

@ -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 relationPickerPreselectedIdScopedState = createStateScopeMap<
export const relationPickerPreselectedIdScopedState = createComponentState<
string | undefined
>({
key: 'relationPickerPreselectedIdScopedState',

View File

@ -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 relationPickerSearchFilterScopedState =
createStateScopeMap<string>({
createComponentState<string>({
key: 'relationPickerSearchFilterScopedState',
defaultValue: '',
});

View File

@ -1,7 +1,7 @@
import { SearchQuery } from '@/object-record/relation-picker/types/SearchQuery';
import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
export const searchQueryScopedState = createStateScopeMap<SearchQuery | null>({
export const searchQueryScopedState = createComponentState<SearchQuery | null>({
key: 'searchQueryScopedState',
defaultValue: null,
});