@payfit/unity-components
Version:
35 lines (34 loc) • 1.2 kB
JavaScript
import { AIComposerTextArea as e } from "../parts/AIComposerTextArea.js";
import { useAIKitFieldContext as t, useAIKitFormContext as n } from "../../../hooks/ai-kit-form-context.js";
import { useTanstackAIComposerFormLayoutContext as r } from "./TanstackAIComposerForm.context.js";
import { forwardRef as i } from "react";
import { jsx as a } from "react/jsx-runtime";
//#region src/modules/ai-kit/components/ai-composer/form/TanstackAIComposerTextArea.tsx
var o = i((i, o) => {
let s = t(), c = n(), { getAlertId: l } = r();
return /* @__PURE__ */ a(c.Subscribe, {
selector: (e) => ({
fieldMeta: e.fieldMeta[s.name],
submissionAttempts: e.submissionAttempts
}),
children: ({ fieldMeta: t, submissionAttempts: n }) => {
let r = t !== void 0 && !t.isValid && (t.isTouched || n > 0);
return /* @__PURE__ */ a(e, {
...i,
ref: o,
value: s.state.value,
"aria-invalid": r || void 0,
"aria-describedby": r ? l(s.name) : void 0,
onChange: (e) => {
s.handleChange(e.target.value);
},
onBlur: () => {
s.handleBlur();
}
});
}
});
});
o.displayName = "TanstackAIComposerTextArea";
//#endregion
export { o as TanstackAIComposerTextArea };