@molecule/app-react-native 2.0.1 → 3.0.1

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.
Files changed (2) hide show
  1. package/README.md +92 -12
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -3,7 +3,7 @@ AUTO-GENERATED — DO NOT EDIT THIS FILE.
3
3
  Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
4
4
  Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
5
5
  To change this document, edit the module-level JSDoc in src/index.ts.
6
- Generated: 2026-10-26T04:14:39.672Z
6
+ Generated: 2026-10-28T08:44:21.978Z
7
7
  -->
8
8
 
9
9
  # @molecule/app-react-native
@@ -279,7 +279,7 @@ Form controller interface.
279
279
  All form providers must implement this interface.
280
280
 
281
281
  ```typescript
282
- interface FormController<T extends Record<string, unknown> = Record<string, unknown>> {
282
+ interface FormController<T extends FormValuesConstraint<T> = Record<string, unknown>> {
283
283
  /**
284
284
  * Gets the current form state.
285
285
  */
@@ -387,7 +387,7 @@ interface FormController<T extends Record<string, unknown> = Record<string, unkn
387
387
  Form creation options.
388
388
 
389
389
  ```typescript
390
- interface FormOptions<T extends Record<string, unknown>> {
390
+ interface FormOptions<T extends FormValuesConstraint<T>> {
391
391
  /**
392
392
  * Default values, captured as the form's clean baseline when the controller
393
393
  * is created. Mutating this object afterwards does not change the baseline.
@@ -839,7 +839,7 @@ provider (`createForm` from `@molecule/app-forms`), which uses the built-in
839
839
  native provider until the app bonds its own.
840
840
 
841
841
  ```typescript
842
- interface UseFormOptions<T extends Record<string, unknown>> extends FormOptions<T> {
842
+ interface UseFormOptions<T extends FormValuesConstraint<T>> extends FormOptions<T> {
843
843
  /**
844
844
  * Explicit form factory for this one form. Defaults to the bonded forms
845
845
  * provider; pass it only to pin a specific provider instance.
@@ -853,7 +853,7 @@ interface UseFormOptions<T extends Record<string, unknown>> extends FormOptions<
853
853
  Result of useForm hook.
854
854
 
855
855
  ```typescript
856
- interface UseFormResult<T extends Record<string, unknown>> {
856
+ interface UseFormResult<T extends FormValuesConstraint<T>> {
857
857
  formState: FormState<T>
858
858
  isValid: boolean
859
859
  isDirty: boolean
@@ -1002,8 +1002,11 @@ interface UsePlatformResult {
1002
1002
 
1003
1003
  Configuration for a profile form; transport stays in the auth bond.
1004
1004
 
1005
+ `TValues` is the page's own controlled-values type, named once as an
1006
+ `interface` or a type alias — both satisfy the shared form-values constraint.
1007
+
1005
1008
  ```typescript
1006
- interface UseProfileFormOptions<TUser, TValues extends Record<string, unknown>> extends Omit<
1009
+ interface UseProfileFormOptions<TUser, TValues extends FormValuesConstraint<TValues>> extends Omit<
1007
1010
  UseFormOptions<TValues>,
1008
1011
  'defaultValues'
1009
1012
  > {
@@ -1038,7 +1041,7 @@ interface UseProfileFormOptions<TUser, TValues extends Record<string, unknown>>
1038
1041
  Controlled profile form state and native form bindings.
1039
1042
 
1040
1043
  ```typescript
1041
- interface UseProfileFormResult<TUser, TValues extends Record<string, unknown>> extends Omit<
1044
+ interface UseProfileFormResult<TUser, TValues extends FormValuesConstraint<TValues>> extends Omit<
1042
1045
  UseFormResult<TValues>,
1043
1046
  'register' | 'handleSubmit' | 'reset'
1044
1047
  > {
@@ -1167,6 +1170,43 @@ interface UseStorageValueResult<T> {
1167
1170
  }
1168
1171
  ```
1169
1172
 
1173
+ #### `UseStoragePreferenceOptions`
1174
+
1175
+ Options for {@link useStoragePreference}.
1176
+
1177
+ ```typescript
1178
+ interface UseStoragePreferenceOptions<T> {
1179
+ /**
1180
+ * Value reported until the provider supplies one. It is NEVER written to
1181
+ * storage: a default is a display fallback, not a decision the user made.
1182
+ */
1183
+ defaultValue?: T
1184
+ }
1185
+ ```
1186
+
1187
+ #### `UseStoragePreferenceResult`
1188
+
1189
+ Result of {@link useStoragePreference}.
1190
+
1191
+ ```typescript
1192
+ interface UseStoragePreferenceResult<T> {
1193
+ /** The persisted value, or `defaultValue` while none is known. */
1194
+ value: T | undefined
1195
+ /**
1196
+ * Writes the value through the preference store: subscribers update
1197
+ * immediately and persistence is best-effort.
1198
+ */
1199
+ setValue: (next: T | ((previous: T | undefined) => T)) => void
1200
+ /** Removes the key through the preference store. */
1201
+ removeValue: () => void
1202
+ /**
1203
+ * `true` once the store has a definite answer — the synchronous snapshot on
1204
+ * a synchronous provider, or the hydration result on an asynchronous one.
1205
+ */
1206
+ ready: boolean
1207
+ }
1208
+ ```
1209
+
1170
1210
  #### `UseVerifyPaymentReturnOptions`
1171
1211
 
1172
1212
  Options for {@link useVerifyPaymentReturn}.
@@ -2169,7 +2209,9 @@ wires a form library once (`setProvider` from `@molecule/app-forms`) and
2169
2209
  every form picks it up. Passing `createForm` overrides that for one form.
2170
2210
 
2171
2211
  ```typescript
2172
- function useForm<T extends Record<string, unknown>>(options?: UseFormOptions<T>): UseFormResult<T>
2212
+ function useForm<T extends FormValuesConstraint<T> = Record<string, unknown>>(
2213
+ options?: UseFormOptions<T>,
2214
+ ): UseFormResult<T>
2173
2215
  ```
2174
2216
 
2175
2217
  - `options` — Form options. `defaultValues`, `mode` and the form-level `validate` are forwarded to the provider; omit the options entirely for a form whose fields are registered with their own defaults.
@@ -2181,7 +2223,7 @@ function useForm<T extends Record<string, unknown>>(options?: UseFormOptions<T>)
2181
2223
  Hook to watch a specific field value.
2182
2224
 
2183
2225
  ```typescript
2184
- function useWatch<T extends Record<string, unknown>, K extends keyof T>(
2226
+ function useWatch<T extends FormValuesConstraint<T>, K extends keyof T>(
2185
2227
  form: FormController<T>,
2186
2228
  name: K,
2187
2229
  ): T[K]
@@ -2197,7 +2239,7 @@ function useWatch<T extends Record<string, unknown>, K extends keyof T>(
2197
2239
  Hook to get field-level state.
2198
2240
 
2199
2241
  ```typescript
2200
- function useFieldState<T extends Record<string, unknown>>(
2242
+ function useFieldState<T extends FormValuesConstraint<T>>(
2201
2243
  form: FormController<T>,
2202
2244
  name: keyof T,
2203
2245
  ): FieldState<T[keyof T]>
@@ -2460,7 +2502,7 @@ the clean baseline; edits made while saving remain dirty. No request is made
2460
2502
  for a patch with no fields. A failed request retains the edits and shared user.
2461
2503
 
2462
2504
  ```typescript
2463
- function useProfileForm<TUser, TValues extends Record<string, unknown>>(
2505
+ function useProfileForm<TUser, TValues extends FormValuesConstraint<TValues>>(
2464
2506
  options: UseProfileFormOptions<TUser, TValues>,
2465
2507
  ): UseProfileFormResult<TUser, TValues>
2466
2508
  ```
@@ -2595,6 +2637,33 @@ function useStorageValue<T>(
2595
2637
 
2596
2638
  **Returns:** Storage value state (value, loading, error) and mutators (setValue, removeValue).
2597
2639
 
2640
+ #### `useStoragePreference(key, options)`
2641
+
2642
+ Subscribes React state to ONE persisted preference.
2643
+
2644
+ This is the component-side half of `getPreferenceStore()`: a render-time value
2645
+ is available immediately when the bonded provider can answer synchronously,
2646
+ and an asynchronous provider's hydration CONVERGES onto the same component
2647
+ without a remount. Ordering is the store's: a read that started before a
2648
+ newer write, remove or external change is discarded, so a slow hydration
2649
+ never overwrites an edit the user already made.
2650
+
2651
+ Pass `null` for `key` while the real key is unknown (no project selected
2652
+ yet): the hook then behaves as local state around `defaultValue` and persists
2653
+ nothing.
2654
+
2655
+ ```typescript
2656
+ function useStoragePreference<T = unknown>(
2657
+ key: string | null | undefined,
2658
+ options?: UseStoragePreferenceOptions<T>,
2659
+ ): UseStoragePreferenceResult<T>
2660
+ ```
2661
+
2662
+ - `key` — The storage key, or `null` when there is nothing to persist.
2663
+ - `options` — `defaultValue`, reported until the provider supplies one.
2664
+
2665
+ **Returns:** The current value, its mutators, and whether it is definite yet.
2666
+
2598
2667
  #### `useStorage()`
2599
2668
 
2600
2669
  Hook for simple storage operations without React state sync.
@@ -3192,6 +3261,17 @@ const useAsyncState: <T>(initialState: T) => [T, AsyncSetState<T>, AsyncExtendSt
3192
3261
 
3193
3262
  Hook that wraps an async function with state tracking.
3194
3263
 
3264
+ For one UI action, pass `state.status === 'pending'` to `Button loading`
3265
+ from `@molecule/app-ui-react` (or to a native control's `disabled` prop).
3266
+ The control then refuses input while the request is pending and re-enables
3267
+ when the tracked call settles. Handle the returned promise's rejection;
3268
+ the hook also records the failure in `state.error`.
3269
+
3270
+ This hook tracks the latest call: it does not serialize invocations or
3271
+ cancel their network requests. An explicit reset/cancel changes the tracked
3272
+ state, so it is not proof that an outstanding request has stopped. Use an
3273
+ app-owned queue when every click must be accepted in order.
3274
+
3195
3275
  ```typescript
3196
3276
  const usePromise: <T extends (...args: any[]) => Promise<any>>(
3197
3277
  asyncFn: T,
@@ -3213,7 +3293,7 @@ Peer dependencies:
3213
3293
 
3214
3294
  - `@molecule/app-keyboard` ^1.0.1
3215
3295
  - `@molecule/app-lifecycle` ^1.0.1
3216
- - `@molecule/app-react` ^2.0.0
3296
+ - `@molecule/app-react` ^3.0.0
3217
3297
  - `react` ^18.0.0 || ^19.0.0
3218
3298
  - `react-native` >=0.72.0
3219
3299
  - `react-native-safe-area-context` >=4.0.0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molecule/app-react-native",
3
- "version": "2.0.1",
3
+ "version": "3.0.1",
4
4
  "description": "React Native framework bindings for molecule.dev",
5
5
  "homepage": "https://www.molecule.dev/packages/app-react-native",
6
6
  "type": "module",
@@ -33,7 +33,7 @@
33
33
  "directory": "packages/app/frameworks/react-native"
34
34
  },
35
35
  "devDependencies": {
36
- "@molecule/app-react": "2.0.1",
36
+ "@molecule/app-react": "3.0.1",
37
37
  "@types/node": "26.6.5",
38
38
  "react": "19.3.1",
39
39
  "typescript": "6.0.3",
@@ -42,7 +42,7 @@
42
42
  "peerDependencies": {
43
43
  "@molecule/app-keyboard": "^1.0.1",
44
44
  "@molecule/app-lifecycle": "^1.0.1",
45
- "@molecule/app-react": "^2.0.0",
45
+ "@molecule/app-react": "^3.0.0",
46
46
  "react": "^18.0.0 || ^19.0.0",
47
47
  "react-native": ">=0.72.0",
48
48
  "react-native-safe-area-context": ">=4.0.0"