@payfit/unity-components
Version:
36 lines (35 loc) • 1.23 kB
JavaScript
import { ToggleSwitch as e } from "../toggle-switch/ToggleSwitch.js";
import { FormField as t } from "../form-field/FormField.js";
import { FormControl as n } from "../form-field/parts/FormControl.js";
import { FormFeedbackText as r } from "../form-field/parts/FormFeedbackText.js";
import { forwardRef as i } from "react";
import { jsx as a, jsxs as o } from "react/jsx-runtime";
import { useFormContext as s } from "react-hook-form";
//#region src/components/toggle-switch-field/ToggleSwitchField.tsx
function c({ name: i, label: c, defaultSelected: l, switchHelperText: u, isInvalid: d, isLoading: f, isDisabled: p, isReadOnly: m, isLabelSrOnly: h, ...g }, _) {
let { control: v, watch: y } = s();
return /* @__PURE__ */ o(t, {
control: v,
name: i,
className: "uy:flex uy:flex-col uy:gap-100",
isInvalid: d,
isLoading: f,
isDisabled: p,
isReadOnly: m,
children: [/* @__PURE__ */ a(n, { children: /* @__PURE__ */ a(e, {
ref: _,
defaultSelected: l,
isSelected: y(i),
label: c,
isLabelSrOnly: h,
helperText: u,
...g
}) }), /* @__PURE__ */ a(r, {})]
});
}
var l = i(function(e, t) {
return c(e, t);
});
l.displayName = "ToggleSwitchField";
//#endregion
export { l as ToggleSwitchField };