@payfit/unity-components
Version:
44 lines (43 loc) • 1.61 kB
JavaScript
import { useUnityFormProvider as e } from "../form/Form.context.js";
import { ToggleSwitchGroup as t } from "../toggle-switch-group/ToggleSwitchGroup.js";
import { createSchemaAdapter as n } from "../../utils/createSchemaAdapter.js";
import { isFieldRequired as r } from "../form-field/utils/isFieldRequired.js";
import { FormField as i } from "../form-field/FormField.js";
import { FormControl as a } from "../form-field/parts/FormControl.js";
import { FormFeedbackText as o } from "../form-field/parts/FormFeedbackText.js";
import { forwardRef as s, useMemo as c } from "react";
import { jsx as l, jsxs as u } from "react/jsx-runtime";
import { useFormContext as d } from "react-hook-form";
//#region src/components/toggle-switch-group-field/ToggleSwitchGroupField.tsx
function f({ name: s, label: f, defaultValue: p, helperText: m, contextualLink: h, isRequired: g, isInvalid: _, isLoading: v, isDisabled: y, isReadOnly: b, requiredVariant: x, children: S, ...C }, w) {
let { control: T, watch: E } = d(), { schema: D } = e(), O = c(() => r(n(D), s), [D, s]);
return /* @__PURE__ */ u(i, {
control: T,
name: s,
isInvalid: _,
isLoading: v,
isDisabled: y,
isReadOnly: b,
children: [
/* @__PURE__ */ l(a, { children: /* @__PURE__ */ l(t, {
ref: w,
label: f,
defaultValue: p,
value: E(s),
helperText: m,
requiredVariant: x,
...C,
isRequired: O ?? g,
children: S
}) }),
/* @__PURE__ */ l(o, {}),
h
]
});
}
var p = s(function(e, t) {
return f(e, t);
});
p.displayName = "ToggleSwitchGroupField";
//#endregion
export { p as ToggleSwitchGroupField };