@formality-ui/react 0.1.0 → 0.2.0

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/index.d.cts CHANGED
@@ -202,10 +202,10 @@ declare function defineInputs<T extends Record<string, ReactInputConfig>>(inputs
202
202
  * `<Field>` renders your input component via React Hook Form's `<Controller>`.
203
203
  * At runtime Formality merges a `coreProps` bundle onto the component (name,
204
204
  * value, onChange, onBlur, and — as a React-special key — `ref`). The three
205
- * members below are the **intended injected-props contract**: `formState`
206
- * today reaches templates and render-prop children; `state` (subscribed field
207
- * state) and a top-level `forwardRef` key are part of the contract this type
208
- * codifies ahead of the runtime wiring (see "Runtime caveat" below).
205
+ * members below are the **injected-props contract**: `formState` reaches
206
+ * templates and render-prop children; `state` (subscribed field state) and a
207
+ * top-level `forwardRef` key are delivered at runtime by `<Field>` (see
208
+ * "Runtime delivery" below).
209
209
  *
210
210
  * **Destructure before forwarding.** Component authors MUST destructure
211
211
  * `state`, `formState`, and `forwardRef` OUT of props before spreading the
@@ -224,14 +224,14 @@ declare function defineInputs<T extends Record<string, ReactInputConfig>>(inputs
224
224
  * For MUI v9 components that no longer accept a top-level `inputRef`, wire it
225
225
  * via slots: `slotProps={{ input: { ref: forwardRef } }}` (PRD §5.3.8).
226
226
  *
227
- * **Runtime caveat (important).** Today `Field` delivers the RHF ref via the
228
- * React-special `ref` key (not a top-level `forwardRef` prop). To receive it
229
- * as `forwardRef` on a plain function component WITHOUT a `React.forwardRef`
230
- * wrap, either (a) wrap your component with `React.forwardRef`, or (b) target
231
- * React 19's ref-as-prop. Making Field deliver it as a top-level `forwardRef`
232
- * key for bare components is a FUTURE runtime task (out of scope for this
233
- * type-only change). The type ships the intended contract now so consumers
234
- * stop hand-rolling a lossy `WithFormality<P>`.
227
+ * **Runtime delivery (important).** `<Field>` delivers RHF's ref as a regular,
228
+ * top-level, enumerable prop named `forwardRef` no `React.forwardRef` wrap
229
+ * is required for a plain function component that destructures `forwardRef`
230
+ * and wires it to the inner input (`ref={forwardRef}`). Consumers migrating
231
+ * off the old React-special `ref` key: a `React.forwardRef`-wrapped component
232
+ * should consume `props.forwardRef` (PRD §20.4), and under React 19
233
+ * ref-as-prop use `forwardRef` directly. The type ships the intended contract
234
+ * so consumers stop hand-rolling a lossy `WithFormality<P>`.
235
235
  *
236
236
  * @template P - the field component's own props (e.g. TextFieldProps). Defaults
237
237
  * to `unknown` so existing `ComponentType<any>` casts remain valid.
package/dist/index.d.ts CHANGED
@@ -202,10 +202,10 @@ declare function defineInputs<T extends Record<string, ReactInputConfig>>(inputs
202
202
  * `<Field>` renders your input component via React Hook Form's `<Controller>`.
203
203
  * At runtime Formality merges a `coreProps` bundle onto the component (name,
204
204
  * value, onChange, onBlur, and — as a React-special key — `ref`). The three
205
- * members below are the **intended injected-props contract**: `formState`
206
- * today reaches templates and render-prop children; `state` (subscribed field
207
- * state) and a top-level `forwardRef` key are part of the contract this type
208
- * codifies ahead of the runtime wiring (see "Runtime caveat" below).
205
+ * members below are the **injected-props contract**: `formState` reaches
206
+ * templates and render-prop children; `state` (subscribed field state) and a
207
+ * top-level `forwardRef` key are delivered at runtime by `<Field>` (see
208
+ * "Runtime delivery" below).
209
209
  *
210
210
  * **Destructure before forwarding.** Component authors MUST destructure
211
211
  * `state`, `formState`, and `forwardRef` OUT of props before spreading the
@@ -224,14 +224,14 @@ declare function defineInputs<T extends Record<string, ReactInputConfig>>(inputs
224
224
  * For MUI v9 components that no longer accept a top-level `inputRef`, wire it
225
225
  * via slots: `slotProps={{ input: { ref: forwardRef } }}` (PRD §5.3.8).
226
226
  *
227
- * **Runtime caveat (important).** Today `Field` delivers the RHF ref via the
228
- * React-special `ref` key (not a top-level `forwardRef` prop). To receive it
229
- * as `forwardRef` on a plain function component WITHOUT a `React.forwardRef`
230
- * wrap, either (a) wrap your component with `React.forwardRef`, or (b) target
231
- * React 19's ref-as-prop. Making Field deliver it as a top-level `forwardRef`
232
- * key for bare components is a FUTURE runtime task (out of scope for this
233
- * type-only change). The type ships the intended contract now so consumers
234
- * stop hand-rolling a lossy `WithFormality<P>`.
227
+ * **Runtime delivery (important).** `<Field>` delivers RHF's ref as a regular,
228
+ * top-level, enumerable prop named `forwardRef` no `React.forwardRef` wrap
229
+ * is required for a plain function component that destructures `forwardRef`
230
+ * and wires it to the inner input (`ref={forwardRef}`). Consumers migrating
231
+ * off the old React-special `ref` key: a `React.forwardRef`-wrapped component
232
+ * should consume `props.forwardRef` (PRD §20.4), and under React 19
233
+ * ref-as-prop use `forwardRef` directly. The type ships the intended contract
234
+ * so consumers stop hand-rolling a lossy `WithFormality<P>`.
235
235
  *
236
236
  * @template P - the field component's own props (e.g. TextFieldProps). Defaults
237
237
  * to `unknown` so existing `ComponentType<any>` casts remain valid.
package/dist/index.js CHANGED
@@ -1115,7 +1115,7 @@ function Field({
1115
1115
  [inputConfig.inputFieldProp ?? "value"]: formattedValue,
1116
1116
  onChange: handleChange(field.onChange),
1117
1117
  onBlur: field.onBlur,
1118
- ref: field.ref
1118
+ forwardRef: field.ref
1119
1119
  }
1120
1120
  });
1121
1121
  const Component = inputConfig.component;