@payfit/unity-components
Version:
27 lines (26 loc) • 1.01 kB
JavaScript
import { AIComposer as e } from "../AIComposer.js";
import { useAIKitFormContext as t } from "../../../hooks/ai-kit-form-context.js";
import { TanstackAIComposerFormLayoutContextProvider as n } from "./TanstackAIComposerForm.context.js";
import { forwardRef as r, useId as i, useMemo as a } from "react";
import { jsx as o } from "react/jsx-runtime";
//#region src/modules/ai-kit/components/ai-composer/form/TanstackAIComposerForm.tsx
var s = (e, t) => `${e}-${t.replace(/[^\\w-]/g, "-")}-alert`, c = r(({ state: r, ...c }, l) => {
let u = t(), d = i(), f = a(() => ({ getAlertId: (e) => s(d, e) }), [d]);
return /* @__PURE__ */ o(u.Subscribe, {
selector: (e) => e.isSubmitting,
children: (t) => /* @__PURE__ */ o(n, {
value: f,
children: /* @__PURE__ */ o(e, {
...c,
ref: l,
state: r ?? (t ? "loading" : "enabled"),
onSubmit: () => {
u.handleSubmit();
}
})
})
});
});
c.displayName = "TanstackAIComposerForm";
//#endregion
export { c as TanstackAIComposerForm };