@ihoomanai/chat-widget 2.5.12 → 2.5.13

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/src/widget.ts CHANGED
@@ -370,9 +370,10 @@ function generateStyles(): string {
370
370
  .ihooman-history-empty { padding: 40px; text-align: center; color: ${mutedColor}; font-size: 14px; }
371
371
  .ihooman-preset-questions { padding: 10px 16px; display: flex; flex-wrap: wrap; gap: 6px; background: ${bgColor}; border-top: 1px solid ${borderColor}; }
372
372
  .ihooman-preset-questions:empty { display: none; }
373
- .ihooman-preset-btn { display: inline-flex; align-items: center; gap: 4px; padding: 6px 12px; border-radius: 6px; border: 1px solid ${borderColor}; background: ${isDark ? 'rgba(255,255,255,0.05)' : 'rgba(0,0,0,0.02)'}; color: ${textColor}; font-size: 12px; font-weight: 500; cursor: pointer; transition: all 0.2s; white-space: nowrap; }
374
- .ihooman-preset-btn:hover { background: ${isDark ? 'rgba(255,255,255,0.1)' : 'rgba(0,0,0,0.05)'}; border-color: ${primaryColor}; }
375
- .ihooman-preset-btn .icon { font-size: 12px; flex-shrink: 0; }
373
+ .ihooman-preset-questions.hidden { display: none !important; }
374
+ .ihooman-widget .ihooman-preset-btn { display: inline-flex !important; align-items: center !important; gap: 4px !important; padding: 6px 12px !important; border-radius: 6px !important; border: 1px solid ${borderColor} !important; background: ${isDark ? 'rgba(255,255,255,0.05)' : 'rgba(0,0,0,0.02)'} !important; color: ${textColor} !important; font-size: 12px !important; font-weight: 500 !important; cursor: pointer !important; transition: all 0.2s !important; white-space: nowrap !important; width: auto !important; height: auto !important; min-width: 0 !important; aspect-ratio: auto !important; }
375
+ .ihooman-widget .ihooman-preset-btn:hover { background: ${isDark ? 'rgba(255,255,255,0.1)' : 'rgba(0,0,0,0.05)'} !important; border-color: ${primaryColor} !important; }
376
+ .ihooman-widget .ihooman-preset-btn .icon { font-size: 12px !important; flex-shrink: 0 !important; }
376
377
  @media (max-width: 480px) { .ihooman-window { width: calc(100vw - 20px); height: calc(100vh - 100px); left: 10px; right: 10px; bottom: 80px; max-height: none; } .ihooman-toggle { ${positionRight ? 'right: 16px' : 'left: 16px'}; bottom: 16px; } }
377
378
  `;
378
379
  }
@@ -660,6 +661,9 @@ function renderPresetQuestions(): void {
660
661
  * Handle preset question click - send the question as a message
661
662
  */
662
663
  function handlePresetQuestionClick(questionText: string): void {
664
+ // Hide preset questions immediately
665
+ hidePresetQuestions();
666
+
663
667
  // Add the question as a user message
664
668
  addMessage(questionText, 'user');
665
669
 
@@ -668,11 +672,6 @@ function handlePresetQuestionClick(questionText: string): void {
668
672
 
669
673
  // Send to server
670
674
  sendMessageToServer(questionText);
671
-
672
- // Hide preset questions after first use (optional - can be removed if you want them to persist)
673
- if (elements.presetQuestions) {
674
- elements.presetQuestions.style.display = 'none';
675
- }
676
675
  }
677
676
 
678
677
  /**
@@ -1112,6 +1111,9 @@ function handleSendClick(): void {
1112
1111
  const content = elements.input?.value.trim();
1113
1112
  if (!content) return;
1114
1113
 
1114
+ // Hide preset questions after user sends any message
1115
+ hidePresetQuestions();
1116
+
1115
1117
  if (elements.input) {
1116
1118
  elements.input.value = '';
1117
1119
  elements.input.style.height = 'auto';
@@ -1125,6 +1127,15 @@ function handleSendClick(): void {
1125
1127
  sendMessageToServer(content);
1126
1128
  }
1127
1129
 
1130
+ /**
1131
+ * Hide preset questions
1132
+ */
1133
+ function hidePresetQuestions(): void {
1134
+ if (elements.presetQuestions) {
1135
+ elements.presetQuestions.classList.add('hidden');
1136
+ }
1137
+ }
1138
+
1128
1139
  /**
1129
1140
  * Send message to the server
1130
1141
  * Uses WebSocket if connected, otherwise falls back to REST API