-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8410e3b
commit 8737eb9
Showing
25 changed files
with
354 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
...src/modules/ui/utilities/state/component-state/types/ComponentFamilyReadOnlySelectorV2.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { ComponentFamilyStateKeyV2 } from '@/ui/utilities/state/component-state/types/ComponentFamilyStateKeyV2'; | ||
import { ComponentStateTypeV2 } from '@/ui/utilities/state/component-state/types/ComponentStateTypeV2'; | ||
import { RecoilValueReadOnly, SerializableParam } from 'recoil'; | ||
|
||
export type ComponentFamilyReadOnlySelectorV2< | ||
StateType, | ||
FamilyKey extends SerializableParam, | ||
> = { | ||
type: Extract<ComponentStateTypeV2, 'ComponentFamilyReadOnlySelector'>; | ||
key: string; | ||
selectorFamily: ( | ||
componentFamilyStateKey: ComponentFamilyStateKeyV2<FamilyKey>, | ||
) => RecoilValueReadOnly<StateType>; | ||
}; |
14 changes: 14 additions & 0 deletions
14
...y-front/src/modules/ui/utilities/state/component-state/types/ComponentFamilySelectorV2.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { ComponentFamilyStateKeyV2 } from '@/ui/utilities/state/component-state/types/ComponentFamilyStateKeyV2'; | ||
import { ComponentStateTypeV2 } from '@/ui/utilities/state/component-state/types/ComponentStateTypeV2'; | ||
import { RecoilState, SerializableParam } from 'recoil'; | ||
|
||
export type ComponentFamilySelectorV2< | ||
StateType, | ||
FamilyKey extends SerializableParam, | ||
> = { | ||
type: Extract<ComponentStateTypeV2, 'ComponentFamilySelector'>; | ||
key: string; | ||
selectorFamily: ( | ||
componentFamilyStateKey: ComponentFamilyStateKeyV2<FamilyKey>, | ||
) => RecoilState<StateType>; | ||
}; |
2 changes: 2 additions & 0 deletions
2
...enty-front/src/modules/ui/utilities/state/component-state/types/ComponentFamilyStateV2.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
...front/src/modules/ui/utilities/state/component-state/types/ComponentReadOnlySelectorV2.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
.../twenty-front/src/modules/ui/utilities/state/component-state/types/ComponentSelectorV2.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
...twenty-front/src/modules/ui/utilities/state/component-state/types/ComponentStateTypeV2.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export type ComponentStateTypeV2 = | ||
| 'ComponentState' | ||
| 'ComponentFamilyState' | ||
| 'ComponentSelector' | ||
| 'ComponentReadOnlySelector' | ||
| 'ComponentFamilySelector' | ||
| 'ComponentFamilyReadOnlySelector'; |
2 changes: 2 additions & 0 deletions
2
...ges/twenty-front/src/modules/ui/utilities/state/component-state/types/ComponentStateV2.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
...t/src/modules/ui/utilities/state/component-state/utils/createComponentFamilySelectorV2.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { selectorFamily, SerializableParam } from 'recoil'; | ||
|
||
import { ComponentFamilyReadOnlySelectorV2 } from '@/ui/utilities/state/component-state/types/ComponentFamilyReadOnlySelectorV2'; | ||
import { ComponentFamilySelectorV2 } from '@/ui/utilities/state/component-state/types/ComponentFamilySelectorV2'; | ||
import { ComponentFamilyStateKeyV2 } from '@/ui/utilities/state/component-state/types/ComponentFamilyStateKeyV2'; | ||
import { ComponentInstanceStateContext } from '@/ui/utilities/state/component-state/types/ComponentInstanceStateContext'; | ||
import { globalComponentInstanceContextMap } from '@/ui/utilities/state/component-state/utils/globalComponentInstanceContextMap'; | ||
import { SelectorGetter } from '@/ui/utilities/state/types/SelectorGetter'; | ||
import { SelectorSetter } from '@/ui/utilities/state/types/SelectorSetter'; | ||
import { isDefined } from 'twenty-ui'; | ||
|
||
export const createComponentFamilySelectorV2 = < | ||
ValueType, | ||
FamilyKey extends SerializableParam, | ||
>({ | ||
key, | ||
get, | ||
set, | ||
componentInstanceContext, | ||
}: { | ||
key: string; | ||
get: SelectorGetter<ValueType, ComponentFamilyStateKeyV2<FamilyKey>>; | ||
set?: SelectorSetter<ValueType, ComponentFamilyStateKeyV2<FamilyKey>>; | ||
componentInstanceContext: ComponentInstanceStateContext<any> | null; | ||
}) => { | ||
if (isDefined(componentInstanceContext)) { | ||
globalComponentInstanceContextMap.set(key, componentInstanceContext); | ||
} | ||
|
||
if (isDefined(set)) { | ||
return { | ||
type: 'ComponentFamilySelector', | ||
key, | ||
selectorFamily: selectorFamily< | ||
ValueType, | ||
ComponentFamilyStateKeyV2<FamilyKey> | ||
>({ | ||
key, | ||
get, | ||
set, | ||
}), | ||
} satisfies ComponentFamilySelectorV2<ValueType, FamilyKey>; | ||
} else { | ||
return { | ||
type: 'ComponentFamilyReadOnlySelector', | ||
key, | ||
selectorFamily: selectorFamily< | ||
ValueType, | ||
ComponentFamilyStateKeyV2<FamilyKey> | ||
>({ | ||
key, | ||
get, | ||
}), | ||
} satisfies ComponentFamilyReadOnlySelectorV2<ValueType, FamilyKey>; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.