UNPKG

@payfit/unity-components

Version:

41 lines (40 loc) 1.58 kB
import { Checkbox as e } from "../checkbox/Checkbox.js"; import { useUnityFormProvider as t } from "../form/Form.context.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/checkbox-field/CheckboxField.tsx function f({ name: s, children: f, defaultSelected: p, helperText: m, contextualLink: h, isRequired: g, isInvalid: _, isLoading: v, isDisabled: y, isReadOnly: b, requiredVariant: x, ...S }, C) { let { control: w, watch: T } = d(), { schema: E } = t(), D = c(() => r(n(E), s), [E, s]); return /* @__PURE__ */ u(i, { control: w, name: s, className: "uy:flex uy:flex-col uy:gap-100", isInvalid: _, isLoading: v, isDisabled: y, isReadOnly: b, children: [/* @__PURE__ */ l(a, { children: /* @__PURE__ */ l(e, { ref: C, defaultSelected: p, isSelected: T(s), requiredVariant: x, helperText: m, feedbackText: /* @__PURE__ */ l(o, {}), ...S, isRequired: D ?? g, children: f }) }), h] }); } var p = s(function(e, t) { return f(e, t); }); p.displayName = "CheckboxField"; //#endregion export { p as CheckboxField };