@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.esm.js CHANGED
@@ -71244,12 +71244,38 @@ var ChatInput = function ChatInput(_ref) {
71244
71244
  return observer.disconnect();
71245
71245
  };
71246
71246
  }, []);
71247
+
71248
+ // Enter/Send while a reply is still coming in (e.g. the panel's hidden
71249
+ // greeting right after it opens) queues the message instead of dropping
71250
+ // it; it goes out — with any edits made meanwhile — once the reply ends.
71251
+ var _useState3 = useState(false),
71252
+ _useState4 = _slicedToArray(_useState3, 2),
71253
+ queued = _useState4[0],
71254
+ setQueued = _useState4[1];
71247
71255
  var handleSend = function handleSend() {
71248
71256
  var trimmed = input.trim();
71249
- if (!trimmed || isLoading) return;
71257
+ if (!trimmed) return;
71258
+ if (isLoading) {
71259
+ setQueued(true);
71260
+ return;
71261
+ }
71250
71262
  onSend(trimmed);
71251
71263
  setInput("");
71252
71264
  };
71265
+ useEffect(function () {
71266
+ if (!queued || isLoading) return;
71267
+ setQueued(false);
71268
+ var trimmed = input.trim();
71269
+ if (!trimmed) return;
71270
+ onSend(trimmed);
71271
+ setInput("");
71272
+ // eslint-disable-next-line react-hooks/exhaustive-deps
71273
+ }, [isLoading, queued]);
71274
+ var handleChange = function handleChange(e) {
71275
+ setInput(e.target.value);
71276
+ // Clearing the box cancels a queued message.
71277
+ if (!e.target.value.trim()) setQueued(false);
71278
+ };
71253
71279
  var handleKeyDown = function handleKeyDown(e) {
71254
71280
  if (e.key === "Enter" && !e.shiftKey) {
71255
71281
  e.preventDefault();
@@ -71257,27 +71283,31 @@ var ChatInput = function ChatInput(_ref) {
71257
71283
  }
71258
71284
  };
71259
71285
  return /*#__PURE__*/jsxs("div", {
71260
- className: "flex items-end gap-2 px-3 py-2 border-t border-gray-700/50",
71261
- children: [/*#__PURE__*/jsx("textarea", {
71262
- ref: textareaRef,
71263
- value: input,
71264
- onChange: function onChange(e) {
71265
- return setInput(e.target.value);
71266
- },
71267
- onKeyDown: handleKeyDown,
71268
- placeholder: "Type a message...",
71269
- disabled: disabled,
71270
- rows: 1,
71271
- 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"
71272
- }), isLoading ? /*#__PURE__*/jsx("button", {
71273
- onClick: onStop,
71274
- className: "px-3 py-2 rounded-lg bg-red-700 hover:bg-red-600 text-white text-sm font-medium transition-colors shrink-0",
71275
- children: "Stop"
71276
- }) : /*#__PURE__*/jsx("button", {
71277
- onClick: handleSend,
71278
- disabled: !input.trim() || disabled,
71279
- 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",
71280
- children: "Send"
71286
+ className: "flex flex-col gap-1 px-3 py-2 border-t border-gray-700/50",
71287
+ children: [/*#__PURE__*/jsxs("div", {
71288
+ className: "flex items-end gap-2",
71289
+ children: [/*#__PURE__*/jsx("textarea", {
71290
+ ref: textareaRef,
71291
+ value: input,
71292
+ onChange: handleChange,
71293
+ onKeyDown: handleKeyDown,
71294
+ placeholder: "Type a message...",
71295
+ disabled: disabled,
71296
+ rows: 1,
71297
+ 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"
71298
+ }), isLoading ? /*#__PURE__*/jsx("button", {
71299
+ onClick: onStop,
71300
+ className: "px-3 py-2 rounded-lg bg-red-700 hover:bg-red-600 text-white text-sm font-medium transition-colors shrink-0",
71301
+ children: "Stop"
71302
+ }) : /*#__PURE__*/jsx("button", {
71303
+ onClick: handleSend,
71304
+ disabled: !input.trim() || disabled,
71305
+ 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",
71306
+ children: "Send"
71307
+ })]
71308
+ }), queued && /*#__PURE__*/jsx("span", {
71309
+ className: "text-xs text-gray-500",
71310
+ children: "Sends when the current reply finishes"
71281
71311
  })]
71282
71312
  });
71283
71313
  };