@assistant-ui/react
Version:
Typescript/React library for AI Chat
69 lines (68 loc) • 2.7 kB
JavaScript
"use client";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/primitives/actionBar/ActionBarStopSpeaking.tsx
var ActionBarStopSpeaking_exports = {};
__export(ActionBarStopSpeaking_exports, {
ActionBarPrimitiveStopSpeaking: () => ActionBarPrimitiveStopSpeaking
});
module.exports = __toCommonJS(ActionBarStopSpeaking_exports);
var import_react = require("react");
var import_react_use_escape_keydown = require("@radix-ui/react-use-escape-keydown");
var import_react_primitive = require("@radix-ui/react-primitive");
var import_primitive = require("@radix-ui/primitive");
var import_react2 = require("react");
var import_MessageContext = require("../../context/react/MessageContext.js");
var import_jsx_runtime = require("react/jsx-runtime");
var useActionBarStopSpeaking = () => {
const messageRuntime = (0, import_MessageContext.useMessageRuntime)();
const isSpeaking = (0, import_MessageContext.useMessage)((u) => u.speech != null);
const callback = (0, import_react2.useCallback)(() => {
messageRuntime.stopSpeaking();
}, [messageRuntime]);
if (!isSpeaking) return null;
return callback;
};
var ActionBarPrimitiveStopSpeaking = (0, import_react.forwardRef)((props, ref) => {
const callback = useActionBarStopSpeaking();
(0, import_react_use_escape_keydown.useEscapeKeydown)((e) => {
if (callback) {
e.preventDefault();
callback();
}
});
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
import_react_primitive.Primitive.button,
{
type: "button",
disabled: !callback,
...props,
ref,
onClick: (0, import_primitive.composeEventHandlers)(props.onClick, () => {
callback?.();
})
}
);
});
ActionBarPrimitiveStopSpeaking.displayName = "ActionBarPrimitive.StopSpeaking";
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
ActionBarPrimitiveStopSpeaking
});
//# sourceMappingURL=ActionBarStopSpeaking.js.map
;