@payfit/unity-components
Version:
34 lines (33 loc) • 1.12 kB
JavaScript
import { Input as e } from "./Input.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/input/TanstackInput.tsx
var a = r(({ onClearButtonPress: r, onBlur: a, onChange: o, isReadOnly: s, isDisabled: c, ...l }, u) => {
let d = t(), f = n(), p = d.state.meta.isTouched && !d.state.meta.isValid, m = [f.helperTextId, f.feedbackTextId].filter(Boolean).join(" ");
return /* @__PURE__ */ i(e, {
...l,
ref: u,
id: f.inputId,
value: d.state.value ?? "",
onChange: (e) => {
d.handleChange(e.target.value), o?.(e);
},
onBlur: (e) => {
d.handleBlur(), a?.(e);
},
onClearButtonPress: () => {
d.setValue(""), r?.();
},
isReadOnly: s,
isDisabled: c,
isInvalid: p,
"aria-labelledby": f.labelId,
"aria-describedby": m.length > 0 ? m : void 0,
"aria-details": f.contextualLinkId
});
});
a.displayName = "TanstackInput";
//#endregion
export { a as TanstackInput };