@payfit/unity-components
Version:
48 lines (47 loc) • 2.32 kB
JavaScript
import { CircularIconButton as e } from "../../../../../core/components/icon-button/CircularIconButton.js";
import { useAIComposerContext as t } from "../AIComposer.context.js";
import { getActionTitle as n } from "./AIComposerAction.js";
import { forwardRef as r } from "react";
import { uyTv as i } from "@payfit/unity-themes";
import { jsx as a } from "react/jsx-runtime";
import { useTranslation as o } from "react-i18next";
//#region src/modules/ai-kit/components/ai-composer/parts/AIComposerSubmitAction.tsx
var s = i({ base: [
"uy:text-content-neutral-enabled uy:bg-surface-neutral-low-enabled",
"uy:data-[hovered=\"true\"]:text-content-neutral-hovered uy:data-[hovered=\"true\"]:bg-surface-neutral-low-hovered",
"uy:active:text-content-inverted-enabled uy:active:bg-surface-inverted",
"uy:data-[active=\"true\"]:text-content-inverted-enabled uy:data-[active=\"true\"]:bg-surface-inverted",
"uy:data-[pressed=\"true\"]:text-content-neutral-enabled uy:data-[pressed=\"true\"]:bg-surface-neutral-low-pressed",
"uy:data-[focus-visible=\"true\"]:text-content-neutral-enabled uy:data-[focus-visible=\"true\"]:bg-surface-neutral-low-focus",
"uy:data-[disabled=\"true\"]:text-content-neutral-disabled uy:data-[disabled=\"true\"]:bg-surface-neutral-low-disabled",
"uy:data-[pending=\"true\"]:bg-transparent"
] }), c = r(({ title: r, "aria-label": i, isDisabled: c, loadingAriaLabel: l, onPress: u, sendAriaLabel: d, stopAriaLabel: f, ...p }, m) => {
let { t: h } = o("unity"), { state: g, hasValue: _, onStop: v, requestSubmit: y } = t(), b = h((e) => e.unity.module.aiKit.composer.submitAction.send), x = h((e) => e.unity.module.aiKit.composer.submitAction.loading), S = h((e) => e.unity.module.aiKit.composer.submitAction.stop), C = g === "streaming" ? f ?? S : g === "loading" ? l ?? x : i ?? d ?? b, w = n(r, C, b), T = s();
return /* @__PURE__ */ a(e, {
...p,
ref: m,
asElement: "button",
type: "button",
icon: "ArrowUpOutlined",
title: w,
"aria-label": C,
isDisabled: c || g === "disabled",
className: T,
isLoading: g === "loading",
"data-active": _,
onPress: (e) => {
if (g === "streaming") {
v?.();
return;
}
if (u) {
u(e);
return;
}
y();
}
});
});
c.displayName = "AIComposerSubmitAction";
//#endregion
export { c as AIComposerSubmitAction };