UNPKG

@nish1896/rhf-mui-components

Version:

A suite of 25+ production-ready react-hook-form components built with material-ui. Fully typed, tree-shakable, and optimized for enterprise-grade forms.

30 lines (29 loc) 1.08 kB
import "react"; //#region src/utils/control.ts function keepLabelAboveFormField(showLabelAboveFormField, allLabelsAboveFields) { return Boolean(showLabelAboveFormField ?? allLabelsAboveFields); } /** * Whether the shared `FormLabel` should render above the control. * For components with **no** built-in label (e.g. `NativeSelect`, `Rating`), the * default is to show the label above unless overridden. * * Precedence: `allLabelsAboveFields` (config) → `showLabelAboveFormField` (prop) → `true`. * * Contrast with `keepLabelAboveFormField`, which defaults to `false` for controls * that already provide a floating/integrated label (e.g. `TextField`). */ function resolveLabelAboveControl(showLabelAboveFormField, allLabelsAboveFields) { return allLabelsAboveFields ?? showLabelAboveFormField ?? true; } function mergeRefs(...refs) { return (value) => { refs.forEach((ref) => { if (!ref) return; if (typeof ref === "function") ref(value); else ref.current = value; }); }; } //#endregion export { keepLabelAboveFormField, mergeRefs, resolveLabelAboveControl };