1
1
import { IsEqual } from 'type-fest' ;
2
- import { CollectionKeyBase , KeyValueMapping , OnyxCollection , OnyxEntry , OnyxKey , Selector } from './types' ;
2
+ import { CollectionKeyBase , ComputedKey , KeyValueMapping , OnyxCollection , OnyxEntry , OnyxKey , Selector } from './types' ;
3
3
4
4
/**
5
5
* Represents the base mapping options between an Onyx key and the component's prop.
@@ -86,6 +86,25 @@ type BaseMappingFunctionKeyAndSelector<TComponentProps, TOnyxProps, TOnyxProp ex
86
86
selector : Selector < TOnyxKey , TOnyxProps , TOnyxProps [ TOnyxProp ] > ;
87
87
} ;
88
88
89
+ /**
90
+ * TODO
91
+ *
92
+ * @example
93
+ * ```ts
94
+ * // Onyx prop with computed key.
95
+ * accountName: {
96
+ * key: {
97
+ * cacheKey: ONYXKEYS.COMPUTED.ACCOUNT_NAME,
98
+ * dependencies: {account: ONYXKEYS.ACCOUNT},
99
+ * compute: ({account}) => account.name,
100
+ * },
101
+ * },
102
+ * ```
103
+ */
104
+ type BaseMappingComputedKey < TComponentProps , TOnyxProps , TOnyxProp extends keyof TOnyxProps > = {
105
+ key : ComputedKey < any , TOnyxProps [ TOnyxProp ] > | ( ( props : Omit < TComponentProps , keyof TOnyxProps > & Partial < TOnyxProps > ) => ComputedKey < any , TOnyxProps [ TOnyxProp ] > ) ;
106
+ } ;
107
+
89
108
/**
90
109
* Represents the mapping options between an Onyx key and the component's prop with all its possibilities.
91
110
*/
@@ -95,6 +114,7 @@ type Mapping<TComponentProps, TOnyxProps, TOnyxProp extends keyof TOnyxProps, TO
95
114
| BaseMappingKey < TComponentProps , TOnyxProps , TOnyxProp , TOnyxKey , OnyxEntry < KeyValueMapping [ TOnyxKey ] > >
96
115
| BaseMappingStringKeyAndSelector < TComponentProps , TOnyxProps , TOnyxProp , TOnyxKey >
97
116
| BaseMappingFunctionKeyAndSelector < TComponentProps , TOnyxProps , TOnyxProp , TOnyxKey >
117
+ | BaseMappingComputedKey < TComponentProps , TOnyxProps , TOnyxProp >
98
118
) ;
99
119
100
120
/**
@@ -106,6 +126,7 @@ type CollectionMapping<TComponentProps, TOnyxProps, TOnyxProp extends keyof TOny
106
126
| BaseMappingKey < TComponentProps , TOnyxProps , TOnyxProp , TOnyxKey , OnyxCollection < KeyValueMapping [ TOnyxKey ] > >
107
127
| BaseMappingStringKeyAndSelector < TComponentProps , TOnyxProps , TOnyxProp , TOnyxKey >
108
128
| BaseMappingFunctionKeyAndSelector < TComponentProps , TOnyxProps , TOnyxProp , TOnyxKey >
129
+ | BaseMappingComputedKey < TComponentProps , TOnyxProps , TOnyxProp >
109
130
) ;
110
131
111
132
/**
0 commit comments