11import { 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' ;
33
44/**
55 * Represents the base mapping options between an Onyx key and the component's prop.
@@ -86,6 +86,25 @@ type BaseMappingFunctionKeyAndSelector<TComponentProps, TOnyxProps, TOnyxProp ex
8686 selector : Selector < TOnyxKey , TOnyxProps , TOnyxProps [ TOnyxProp ] > ;
8787} ;
8888
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+
89108/**
90109 * Represents the mapping options between an Onyx key and the component's prop with all its possibilities.
91110 */
@@ -95,6 +114,7 @@ type Mapping<TComponentProps, TOnyxProps, TOnyxProp extends keyof TOnyxProps, TO
95114 | BaseMappingKey < TComponentProps , TOnyxProps , TOnyxProp , TOnyxKey , OnyxEntry < KeyValueMapping [ TOnyxKey ] > >
96115 | BaseMappingStringKeyAndSelector < TComponentProps , TOnyxProps , TOnyxProp , TOnyxKey >
97116 | BaseMappingFunctionKeyAndSelector < TComponentProps , TOnyxProps , TOnyxProp , TOnyxKey >
117+ | BaseMappingComputedKey < TComponentProps , TOnyxProps , TOnyxProp >
98118 ) ;
99119
100120/**
@@ -106,6 +126,7 @@ type CollectionMapping<TComponentProps, TOnyxProps, TOnyxProp extends keyof TOny
106126 | BaseMappingKey < TComponentProps , TOnyxProps , TOnyxProp , TOnyxKey , OnyxCollection < KeyValueMapping [ TOnyxKey ] > >
107127 | BaseMappingStringKeyAndSelector < TComponentProps , TOnyxProps , TOnyxProp , TOnyxKey >
108128 | BaseMappingFunctionKeyAndSelector < TComponentProps , TOnyxProps , TOnyxProp , TOnyxKey >
129+ | BaseMappingComputedKey < TComponentProps , TOnyxProps , TOnyxProp >
109130 ) ;
110131
111132/**
0 commit comments