react-native-onyx 1.0.124 → 1.0.126

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/lib/types.d.ts CHANGED
@@ -115,13 +115,13 @@ type KeyValueMapping = {
115
115
  /**
116
116
  * Represents a selector function type which operates based on the provided `TKey` and `ReturnType`.
117
117
  *
118
- * A `Selector` is a function that accepts a value and returns a processed value.
118
+ * A `Selector` is a function that accepts a value, the withOnyx's internal state and returns a processed value.
119
119
  * This type accepts two type parameters: `TKey` and `TReturnType`.
120
120
  *
121
121
  * The type `TKey` extends `OnyxKey` and it is the key used to access a value in `KeyValueMapping`.
122
122
  * `TReturnType` is the type of the returned value from the selector function.
123
123
  */
124
- type Selector<TKey extends OnyxKey, TReturnType> = (value: OnyxEntry<KeyValueMapping[TKey]>) => TReturnType;
124
+ type Selector<TKey extends OnyxKey, TOnyxProps, TReturnType> = (value: OnyxEntry<KeyValueMapping[TKey]>, state: WithOnyxInstanceState<TOnyxProps>) => TReturnType;
125
125
 
126
126
  /**
127
127
  * Represents a single Onyx entry, that can be either `TOnyxValue` or `null` if it doesn't exist.
@@ -215,10 +215,15 @@ type NonTransformableTypes =
215
215
  type NullishDeep<T> = T extends NonTransformableTypes ? T : T extends object ? NullishObjectDeep<T> : unknown;
216
216
 
217
217
  /**
218
- Same as `NullishDeep`, but accepts only `object`s as inputs. Internal helper for `NullishDeep`.
219
- */
218
+ * Same as `NullishDeep`, but accepts only `object`s as inputs. Internal helper for `NullishDeep`.
219
+ */
220
220
  type NullishObjectDeep<ObjectType extends object> = {
221
221
  [KeyType in keyof ObjectType]?: NullishDeep<ObjectType[KeyType]> | null;
222
222
  };
223
223
 
224
- export {CollectionKey, CollectionKeyBase, CustomTypeOptions, DeepRecord, Key, KeyValueMapping, OnyxCollection, OnyxEntry, OnyxKey, Selector, NullishDeep};
224
+ /**
225
+ * Represents withOnyx's internal state, containing the Onyx props and a `loading` flag.
226
+ */
227
+ type WithOnyxInstanceState<TOnyxProps> = (TOnyxProps & {loading: boolean}) | undefined;
228
+
229
+ export {CollectionKey, CollectionKeyBase, CustomTypeOptions, DeepRecord, Key, KeyValueMapping, OnyxCollection, OnyxEntry, OnyxKey, Selector, NullishDeep, WithOnyxInstanceState};
package/lib/withOnyx.d.ts CHANGED
@@ -42,7 +42,7 @@ type EntryBaseMapping<TOnyxKey extends OnyxKey> = {
42
42
  */
43
43
  type BaseMappingKey<TComponentProps, TOnyxProps, TOnyxProp extends keyof TOnyxProps, TOnyxKey extends OnyxKey, TOnyxValue> = IsEqual<TOnyxValue, TOnyxProps[TOnyxProp]> extends true
44
44
  ? {
45
- key: TOnyxKey | ((props: Omit<TComponentProps, keyof TOnyxProps>) => TOnyxKey);
45
+ key: TOnyxKey | ((props: Omit<TComponentProps, keyof TOnyxProps> & Partial<TOnyxProps>) => TOnyxKey);
46
46
  }
47
47
  : never;
48
48
 
@@ -63,7 +63,7 @@ type BaseMappingKey<TComponentProps, TOnyxProps, TOnyxProp extends keyof TOnyxPr
63
63
  */
64
64
  type BaseMappingStringKeyAndSelector<TComponentProps, TOnyxProps, TOnyxProp extends keyof TOnyxProps, TOnyxKey extends OnyxKey> = {
65
65
  key: TOnyxKey;
66
- selector: Selector<TOnyxKey, TOnyxProps[TOnyxProp]>;
66
+ selector: Selector<TOnyxKey, TOnyxProps, TOnyxProps[TOnyxProp]>;
67
67
  };
68
68
 
69
69
  /**
@@ -82,8 +82,8 @@ type BaseMappingStringKeyAndSelector<TComponentProps, TOnyxProps, TOnyxProp exte
82
82
  * ```
83
83
  */
84
84
  type BaseMappingFunctionKeyAndSelector<TComponentProps, TOnyxProps, TOnyxProp extends keyof TOnyxProps, TOnyxKey extends OnyxKey> = {
85
- key: (props: Omit<TComponentProps, keyof TOnyxProps>) => TOnyxKey;
86
- selector: Selector<TOnyxKey, TOnyxProps[TOnyxProp]>;
85
+ key: (props: Omit<TComponentProps, keyof TOnyxProps> & Partial<TOnyxProps>) => TOnyxKey;
86
+ selector: Selector<TOnyxKey, TOnyxProps, TOnyxProps[TOnyxProp]>;
87
87
  };
88
88
 
89
89
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-onyx",
3
- "version": "1.0.124",
3
+ "version": "1.0.126",
4
4
  "author": "Expensify, Inc.",
5
5
  "homepage": "https://expensify.com",
6
6
  "description": "State management for React Native",
@@ -30,7 +30,7 @@
30
30
  ],
31
31
  "react-native": "native.js",
32
32
  "main": "native.js",
33
- "browser": "lib/index.js",
33
+ "browser": "web.js",
34
34
  "types": "lib/index.d.ts",
35
35
  "scripts": {
36
36
  "lint": "eslint .",