UNPKG

@payfit/unity-components

Version:

29 lines (28 loc) 1.1 kB
import { SelectableButtonGroup as e } from "./SelectableButtonGroup.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, useCallback as i } from "react"; import { jsx as a } from "react/jsx-runtime"; //#region src/components/selectable-button-group/TanstackSelectableButtonGroup.tsx var o = r(({ onChange: r, ...o }, s) => { let c = t(), l = n(), u = c.state.meta.isTouched && !c.state.meta.isValid, d = i((e) => { let t = e.relatedTarget, n = e.currentTarget; (!t || !n.contains(t)) && c.handleBlur(); }, [c]); return /* @__PURE__ */ a(e, { ...o, ref: s, value: c.state.value, onChange: (e) => { c.handleChange(e), r?.(e); }, onBlur: d, isInvalid: u, "aria-labelledby": l.labelId, "aria-describedby": [l.helperTextId, l.feedbackTextId].filter(Boolean).join(" ") || void 0, "aria-details": l.contextualLinkId }); }); o.displayName = "TanstackSelectableButtonGroup"; //#endregion export { o as TanstackSelectableButtonGroup };