UNPKG

@payfit/unity-components

Version:

57 lines (56 loc) • 2.46 kB
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 { useIntl as o } from "react-intl"; //#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 h = o(), { state: g, hasValue: _, onStop: v, requestSubmit: y } = t(), b = h.formatMessage({ id: "unity:module:ai-kit:composer:submit-action:send", defaultMessage: "Send message" }), x = h.formatMessage({ id: "unity:module:ai-kit:composer:submit-action:loading", defaultMessage: "Sending message" }), S = h.formatMessage({ id: "unity:module:ai-kit:composer:submit-action:stop", defaultMessage: "Stop generating" }), 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 };