feat: default record group table (#8397)
This PR is preparing states to we'll be able to handle view groups correctly with table data. RowIds are now stores in 2 component states, one storing ids by view group and another storing all the rowIds. We're doing that because some other state like focus, or select must not be scoped by view group id.
This commit is contained in:
@ -1,3 +1,5 @@
|
||||
/* eslint-disable no-redeclare */
|
||||
/* eslint-disable prefer-arrow/prefer-arrow-functions */
|
||||
import { selectorFamily, SerializableParam } from 'recoil';
|
||||
|
||||
import { ComponentFamilyReadOnlySelectorV2 } from '@/ui/utilities/state/component-state/types/ComponentFamilyReadOnlySelectorV2';
|
||||
@ -9,7 +11,26 @@ import { SelectorGetter } from '@/ui/utilities/state/types/SelectorGetter';
|
||||
import { SelectorSetter } from '@/ui/utilities/state/types/SelectorSetter';
|
||||
import { isDefined } from 'twenty-ui';
|
||||
|
||||
export const createComponentFamilySelectorV2 = <
|
||||
export function createComponentFamilySelectorV2<
|
||||
ValueType,
|
||||
FamilyKey extends SerializableParam,
|
||||
>(options: {
|
||||
key: string;
|
||||
get: SelectorGetter<ValueType, ComponentFamilyStateKeyV2<FamilyKey>>;
|
||||
componentInstanceContext: ComponentInstanceStateContext<any> | null;
|
||||
}): ComponentFamilySelectorV2<ValueType, FamilyKey>;
|
||||
|
||||
export function createComponentFamilySelectorV2<
|
||||
ValueType,
|
||||
FamilyKey extends SerializableParam,
|
||||
>(options: {
|
||||
key: string;
|
||||
get: SelectorGetter<ValueType, ComponentFamilyStateKeyV2<FamilyKey>>;
|
||||
set: SelectorSetter<ValueType, ComponentFamilyStateKeyV2<FamilyKey>>;
|
||||
componentInstanceContext: ComponentInstanceStateContext<any> | null;
|
||||
}): ComponentFamilyReadOnlySelectorV2<ValueType, FamilyKey>;
|
||||
|
||||
export function createComponentFamilySelectorV2<
|
||||
ValueType,
|
||||
FamilyKey extends SerializableParam,
|
||||
>({
|
||||
@ -24,7 +45,7 @@ export const createComponentFamilySelectorV2 = <
|
||||
componentInstanceContext: ComponentInstanceStateContext<any> | null;
|
||||
}):
|
||||
| ComponentFamilySelectorV2<ValueType, FamilyKey>
|
||||
| ComponentFamilyReadOnlySelectorV2<ValueType, FamilyKey> => {
|
||||
| ComponentFamilyReadOnlySelectorV2<ValueType, FamilyKey> {
|
||||
if (isDefined(componentInstanceContext)) {
|
||||
globalComponentInstanceContextMap.set(key, componentInstanceContext);
|
||||
}
|
||||
@ -55,4 +76,4 @@ export const createComponentFamilySelectorV2 = <
|
||||
}),
|
||||
} satisfies ComponentFamilyReadOnlySelectorV2<ValueType, FamilyKey>;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -6,11 +6,18 @@ import { AtomEffect, atomFamily, SerializableParam } from 'recoil';
|
||||
|
||||
import { isDefined } from 'twenty-ui';
|
||||
|
||||
type CreateComponentFamilyStateArgs<ValueType> = {
|
||||
type CreateComponentFamilyStateArgs<
|
||||
ValueType,
|
||||
FamilyKey extends SerializableParam,
|
||||
> = {
|
||||
key: string;
|
||||
defaultValue: ValueType;
|
||||
componentInstanceContext: ComponentInstanceStateContext<any> | null;
|
||||
effects?: AtomEffect<ValueType>[];
|
||||
effects?:
|
||||
| AtomEffect<ValueType>[]
|
||||
| ((
|
||||
param: ComponentFamilyStateKeyV2<FamilyKey>,
|
||||
) => ReadonlyArray<AtomEffect<ValueType>>);
|
||||
};
|
||||
|
||||
export const createComponentFamilyStateV2 = <
|
||||
@ -21,10 +28,10 @@ export const createComponentFamilyStateV2 = <
|
||||
effects,
|
||||
defaultValue,
|
||||
componentInstanceContext,
|
||||
}: CreateComponentFamilyStateArgs<ValueType>): ComponentFamilyStateV2<
|
||||
}: CreateComponentFamilyStateArgs<
|
||||
ValueType,
|
||||
FamilyKey
|
||||
> => {
|
||||
>): ComponentFamilyStateV2<ValueType, FamilyKey> => {
|
||||
if (isDefined(componentInstanceContext)) {
|
||||
globalComponentInstanceContextMap.set(key, componentInstanceContext);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user