react-native-onyx 2.0.9 → 2.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/types.d.ts +18 -1
- package/dist/withOnyx.d.ts +9 -9
- package/package.json +1 -1
package/dist/types.d.ts
CHANGED
|
@@ -183,6 +183,9 @@ type OnyxEntry<TOnyxValue> = TOnyxValue | null;
|
|
|
183
183
|
*/
|
|
184
184
|
type OnyxCollection<TOnyxValue> = OnyxEntry<Record<string, TOnyxValue | null>>;
|
|
185
185
|
|
|
186
|
+
/** Utility type to extract `TOnyxValue` from `OnyxCollection<TOnyxValue>` */
|
|
187
|
+
type ExtractOnyxCollectionValue<TOnyxCollection> = TOnyxCollection extends NonNullable<OnyxCollection<infer U>> ? U : never;
|
|
188
|
+
|
|
186
189
|
type NonTransformableTypes =
|
|
187
190
|
| BuiltIns
|
|
188
191
|
| ((...args: any[]) => unknown)
|
|
@@ -226,4 +229,18 @@ type NullishObjectDeep<ObjectType extends object> = {
|
|
|
226
229
|
*/
|
|
227
230
|
type WithOnyxInstanceState<TOnyxProps> = (TOnyxProps & {loading: boolean}) | undefined;
|
|
228
231
|
|
|
229
|
-
export {
|
|
232
|
+
export {
|
|
233
|
+
CollectionKey,
|
|
234
|
+
CollectionKeyBase,
|
|
235
|
+
CustomTypeOptions,
|
|
236
|
+
DeepRecord,
|
|
237
|
+
Key,
|
|
238
|
+
KeyValueMapping,
|
|
239
|
+
OnyxCollection,
|
|
240
|
+
OnyxEntry,
|
|
241
|
+
OnyxKey,
|
|
242
|
+
Selector,
|
|
243
|
+
NullishDeep,
|
|
244
|
+
WithOnyxInstanceState,
|
|
245
|
+
ExtractOnyxCollectionValue,
|
|
246
|
+
};
|
package/dist/withOnyx.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {IsEqual} from 'type-fest';
|
|
2
|
-
import {CollectionKeyBase, KeyValueMapping, OnyxCollection, OnyxEntry, OnyxKey, Selector} from './types';
|
|
2
|
+
import {CollectionKeyBase, ExtractOnyxCollectionValue, 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.
|
|
@@ -61,9 +61,9 @@ type BaseMappingKey<TComponentProps, TOnyxProps, TOnyxProp extends keyof TOnyxPr
|
|
|
61
61
|
* },
|
|
62
62
|
* ```
|
|
63
63
|
*/
|
|
64
|
-
type BaseMappingStringKeyAndSelector<TComponentProps, TOnyxProps,
|
|
64
|
+
type BaseMappingStringKeyAndSelector<TComponentProps, TOnyxProps, TReturnType, TOnyxKey extends OnyxKey> = {
|
|
65
65
|
key: TOnyxKey;
|
|
66
|
-
selector: Selector<TOnyxKey, TOnyxProps,
|
|
66
|
+
selector: Selector<TOnyxKey, TOnyxProps, TReturnType>;
|
|
67
67
|
};
|
|
68
68
|
|
|
69
69
|
/**
|
|
@@ -81,9 +81,9 @@ type BaseMappingStringKeyAndSelector<TComponentProps, TOnyxProps, TOnyxProp exte
|
|
|
81
81
|
* },
|
|
82
82
|
* ```
|
|
83
83
|
*/
|
|
84
|
-
type BaseMappingFunctionKeyAndSelector<TComponentProps, TOnyxProps,
|
|
84
|
+
type BaseMappingFunctionKeyAndSelector<TComponentProps, TOnyxProps, TReturnType, TOnyxKey extends OnyxKey> = {
|
|
85
85
|
key: (props: Omit<TComponentProps, keyof TOnyxProps> & Partial<TOnyxProps>) => TOnyxKey;
|
|
86
|
-
selector: Selector<TOnyxKey, TOnyxProps,
|
|
86
|
+
selector: Selector<TOnyxKey, TOnyxProps, TReturnType>;
|
|
87
87
|
};
|
|
88
88
|
|
|
89
89
|
/**
|
|
@@ -93,8 +93,8 @@ type Mapping<TComponentProps, TOnyxProps, TOnyxProp extends keyof TOnyxProps, TO
|
|
|
93
93
|
EntryBaseMapping<TOnyxKey> &
|
|
94
94
|
(
|
|
95
95
|
| BaseMappingKey<TComponentProps, TOnyxProps, TOnyxProp, TOnyxKey, OnyxEntry<KeyValueMapping[TOnyxKey]>>
|
|
96
|
-
| BaseMappingStringKeyAndSelector<TComponentProps, TOnyxProps, TOnyxProp, TOnyxKey>
|
|
97
|
-
| BaseMappingFunctionKeyAndSelector<TComponentProps, TOnyxProps, TOnyxProp, TOnyxKey>
|
|
96
|
+
| BaseMappingStringKeyAndSelector<TComponentProps, TOnyxProps, TOnyxProps[TOnyxProp], TOnyxKey>
|
|
97
|
+
| BaseMappingFunctionKeyAndSelector<TComponentProps, TOnyxProps, TOnyxProps[TOnyxProp], TOnyxKey>
|
|
98
98
|
);
|
|
99
99
|
|
|
100
100
|
/**
|
|
@@ -104,8 +104,8 @@ type CollectionMapping<TComponentProps, TOnyxProps, TOnyxProp extends keyof TOny
|
|
|
104
104
|
CollectionBaseMapping<TOnyxKey> &
|
|
105
105
|
(
|
|
106
106
|
| BaseMappingKey<TComponentProps, TOnyxProps, TOnyxProp, TOnyxKey, OnyxCollection<KeyValueMapping[TOnyxKey]>>
|
|
107
|
-
| BaseMappingStringKeyAndSelector<TComponentProps, TOnyxProps, TOnyxProp
|
|
108
|
-
| BaseMappingFunctionKeyAndSelector<TComponentProps, TOnyxProps, TOnyxProp
|
|
107
|
+
| BaseMappingStringKeyAndSelector<TComponentProps, TOnyxProps, ExtractOnyxCollectionValue<TOnyxProps[TOnyxProp]>, TOnyxKey>
|
|
108
|
+
| BaseMappingFunctionKeyAndSelector<TComponentProps, TOnyxProps, ExtractOnyxCollectionValue<TOnyxProps[TOnyxProp]>, TOnyxKey>
|
|
109
109
|
);
|
|
110
110
|
|
|
111
111
|
/**
|