@payfit/unity-components
Version:
36 lines (35 loc) • 1.2 kB
JavaScript
import { Checkbox as e } from "./Checkbox.js";
import { useFieldContext as t } from "../../hooks/tanstack-form-context.js";
import { useFieldA11yContext as n } from "../form-field/TanstackFormField.context.js";
import { forwardRef as r } from "react";
import { jsx as i } from "react/jsx-runtime";
//#region src/components/checkbox/TanstackCheckbox.tsx
var a = r(({ children: r, value: a, isIndeterminate: o, onBlur: s, onChange: c, isReadOnly: l, isDisabled: u, isRequired: d, requiredVariant: f, ...p }, m) => {
let h = t(), g = n(), _ = h.state.meta.isTouched && !h.state.meta.isValid, v = [g.helperTextId, g.feedbackTextId].filter(Boolean).join(" ");
return /* @__PURE__ */ i(e, {
...p,
id: g.inputId,
ref: m,
value: a,
isSelected: h.state.value,
isIndeterminate: o,
requiredVariant: f,
isRequired: d,
onChange: (e) => {
h.handleChange(e), c?.(e);
},
onBlur: () => {
h.handleBlur(), s?.();
},
isReadOnly: l,
isDisabled: u,
isInvalid: _,
"aria-labelledby": g.labelId,
"aria-describedby": v.length > 0 ? v : void 0,
"aria-details": g.contextualLinkId,
children: r
});
});
a.displayName = "TanstackCheckbox";
//#endregion
export { a as TanstackCheckbox };