UNPKG

mongodb-chatbot-ui

Version:

UI React components for the MongoDB Assistant

57 lines (56 loc) 1.81 kB
import { jsxs as g, Fragment as h, jsx as m } from "react/jsx-runtime"; import { U as f, r as v } from "./index13.js"; import { useState as C } from "react"; import "./index2.js"; import "./glyphCommon-cTThlth0.js"; import "./index6.js"; import "./index7.js"; import "./polished.esm.js"; import "./index12.js"; import "./index5.js"; import "react-dom"; import "./index4.js"; import "./index9.js"; import "./X.js"; import "./CheckmarkWithCircle.js"; function T(u) { const { submit: c, status: s, errorMessage: d, maxCommentCharacterCount: e, messageRatingProps: t } = u, p = t.value !== void 0, [l, b] = C(0), i = e ? l > e : !1, r = ( // If we have an error message from the props, use it d ?? // Otherwise, if the character count is exceeded, show an error message (i ? `Message must contain ${e} characters or fewer` : void 0) ); return /* @__PURE__ */ g(h, { children: [ /* @__PURE__ */ m(f, { ...t }), p && s !== "abandoned" ? /* @__PURE__ */ m( v, { state: s === "submitted" ? "submitted" : r ? "error" : "unset", submitButtonProps: { disabled: r !== void 0 }, onSubmit: async (o) => { const a = o.target.querySelector("textarea"); i || await c((a == null ? void 0 : a.value) ?? ""); }, submittedMessage: "Submitted! Thank you for your feedback.", errorMessage: r, textareaProps: { onChange: (o) => { const n = o.target; b(n.value.length); } }, label: t.value === "liked" ? "Provide additional feedback here. What did you like about this response?" : "Provide additional feedback here. How can we improve?" } ) : null ] }); } export { T as MessageRatingWithFeedbackComment };