@trops/dash-core 0.1.661 → 0.1.662

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -71262,12 +71262,38 @@ var ChatInput = function ChatInput(_ref) {
71262
71262
  return observer.disconnect();
71263
71263
  };
71264
71264
  }, []);
71265
+
71266
+ // Enter/Send while a reply is still coming in (e.g. the panel's hidden
71267
+ // greeting right after it opens) queues the message instead of dropping
71268
+ // it; it goes out — with any edits made meanwhile — once the reply ends.
71269
+ var _useState3 = React.useState(false),
71270
+ _useState4 = _slicedToArray(_useState3, 2),
71271
+ queued = _useState4[0],
71272
+ setQueued = _useState4[1];
71265
71273
  var handleSend = function handleSend() {
71266
71274
  var trimmed = input.trim();
71267
- if (!trimmed || isLoading) return;
71275
+ if (!trimmed) return;
71276
+ if (isLoading) {
71277
+ setQueued(true);
71278
+ return;
71279
+ }
71268
71280
  onSend(trimmed);
71269
71281
  setInput("");
71270
71282
  };
71283
+ React.useEffect(function () {
71284
+ if (!queued || isLoading) return;
71285
+ setQueued(false);
71286
+ var trimmed = input.trim();
71287
+ if (!trimmed) return;
71288
+ onSend(trimmed);
71289
+ setInput("");
71290
+ // eslint-disable-next-line react-hooks/exhaustive-deps
71291
+ }, [isLoading, queued]);
71292
+ var handleChange = function handleChange(e) {
71293
+ setInput(e.target.value);
71294
+ // Clearing the box cancels a queued message.
71295
+ if (!e.target.value.trim()) setQueued(false);
71296
+ };
71271
71297
  var handleKeyDown = function handleKeyDown(e) {
71272
71298
  if (e.key === "Enter" && !e.shiftKey) {
71273
71299
  e.preventDefault();
@@ -71275,27 +71301,31 @@ var ChatInput = function ChatInput(_ref) {
71275
71301
  }
71276
71302
  };
71277
71303
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
71278
- className: "flex items-end gap-2 px-3 py-2 border-t border-gray-700/50",
71279
- children: [/*#__PURE__*/jsxRuntime.jsx("textarea", {
71280
- ref: textareaRef,
71281
- value: input,
71282
- onChange: function onChange(e) {
71283
- return setInput(e.target.value);
71284
- },
71285
- onKeyDown: handleKeyDown,
71286
- placeholder: "Type a message...",
71287
- disabled: disabled,
71288
- rows: 1,
71289
- className: "flex-1 px-3 py-2 bg-gray-800 border border-gray-700 rounded-lg text-sm text-gray-200 placeholder-gray-500 focus:outline-none focus:border-indigo-500 resize-none disabled:opacity-50"
71290
- }), isLoading ? /*#__PURE__*/jsxRuntime.jsx("button", {
71291
- onClick: onStop,
71292
- className: "px-3 py-2 rounded-lg bg-red-700 hover:bg-red-600 text-white text-sm font-medium transition-colors shrink-0",
71293
- children: "Stop"
71294
- }) : /*#__PURE__*/jsxRuntime.jsx("button", {
71295
- onClick: handleSend,
71296
- disabled: !input.trim() || disabled,
71297
- className: "px-3 py-2 rounded-lg bg-indigo-600 hover:bg-indigo-500 disabled:opacity-40 disabled:cursor-not-allowed text-white text-sm font-medium transition-colors shrink-0",
71298
- children: "Send"
71304
+ className: "flex flex-col gap-1 px-3 py-2 border-t border-gray-700/50",
71305
+ children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
71306
+ className: "flex items-end gap-2",
71307
+ children: [/*#__PURE__*/jsxRuntime.jsx("textarea", {
71308
+ ref: textareaRef,
71309
+ value: input,
71310
+ onChange: handleChange,
71311
+ onKeyDown: handleKeyDown,
71312
+ placeholder: "Type a message...",
71313
+ disabled: disabled,
71314
+ rows: 1,
71315
+ className: "flex-1 px-3 py-2 bg-gray-800 border border-gray-700 rounded-lg text-sm text-gray-200 placeholder-gray-500 focus:outline-none focus:border-indigo-500 resize-none disabled:opacity-50"
71316
+ }), isLoading ? /*#__PURE__*/jsxRuntime.jsx("button", {
71317
+ onClick: onStop,
71318
+ className: "px-3 py-2 rounded-lg bg-red-700 hover:bg-red-600 text-white text-sm font-medium transition-colors shrink-0",
71319
+ children: "Stop"
71320
+ }) : /*#__PURE__*/jsxRuntime.jsx("button", {
71321
+ onClick: handleSend,
71322
+ disabled: !input.trim() || disabled,
71323
+ className: "px-3 py-2 rounded-lg bg-indigo-600 hover:bg-indigo-500 disabled:opacity-40 disabled:cursor-not-allowed text-white text-sm font-medium transition-colors shrink-0",
71324
+ children: "Send"
71325
+ })]
71326
+ }), queued && /*#__PURE__*/jsxRuntime.jsx("span", {
71327
+ className: "text-xs text-gray-500",
71328
+ children: "Sends when the current reply finishes"
71299
71329
  })]
71300
71330
  });
71301
71331
  };