@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/README.md +8 -7
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -12
- package/dist/index.d.ts +12 -12
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
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 **
|
|
206
|
-
*
|
|
207
|
-
*
|
|
208
|
-
*
|
|
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
|
|
228
|
-
*
|
|
229
|
-
*
|
|
230
|
-
*
|
|
231
|
-
*
|
|
232
|
-
*
|
|
233
|
-
*
|
|
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 **
|
|
206
|
-
*
|
|
207
|
-
*
|
|
208
|
-
*
|
|
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
|
|
228
|
-
*
|
|
229
|
-
*
|
|
230
|
-
*
|
|
231
|
-
*
|
|
232
|
-
*
|
|
233
|
-
*
|
|
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
|
-
|
|
1118
|
+
forwardRef: field.ref
|
|
1119
1119
|
}
|
|
1120
1120
|
});
|
|
1121
1121
|
const Component = inputConfig.component;
|