@envive-ai/react-toolkit-v3 0.3.23 → 0.3.24

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.
Files changed (89) hide show
  1. package/dist/AnimatedText/AnimatedText.d.ts +3 -3
  2. package/dist/CSSVariablesEditor/CssVariablesEditorComponent.d.cts +2 -2
  3. package/dist/CSSVariablesEditor/CssVariablesEditorComponent.d.ts +2 -2
  4. package/dist/Carousel/Carousel.d.cts +2 -2
  5. package/dist/Carousel/Carousel.d.ts +2 -2
  6. package/dist/ChatFooter/ChatFooter.d.cts +2 -2
  7. package/dist/ChatFooter/ChatFooter.d.ts +2 -2
  8. package/dist/ChatFooter/components/index.d.cts +5 -5
  9. package/dist/ChatFooter/components/index.d.ts +5 -5
  10. package/dist/ChatHeader/ChatHeader.d.cts +2 -2
  11. package/dist/ChatHeader/ChatHeader.d.ts +2 -2
  12. package/dist/ChatPreview/ChatPreview.d.cts +2 -2
  13. package/dist/ChatPreview/ChatPreview.d.ts +2 -2
  14. package/dist/ChatPreviewComparison/ChatPreviewComparison.d.cts +2 -2
  15. package/dist/ChatPreviewComparison/ChatPreviewComparison.d.ts +2 -2
  16. package/dist/ChatPreviewLoading/ChatPreviewLoading.d.cts +2 -2
  17. package/dist/Container/Container.d.cts +2 -2
  18. package/dist/Container/Container.d.ts +2 -2
  19. package/dist/DesignTokens/DesignTokensComponent.d.cts +2 -2
  20. package/dist/DesignTokens/DesignTokensComponent.d.ts +2 -2
  21. package/dist/Disclaimer/components/Container.cjs +1 -1
  22. package/dist/Disclaimer/components/Container.js +1 -1
  23. package/dist/DocumentRetrievalCard/DocumentRetrievalCard.d.cts +2 -2
  24. package/dist/DocumentRetrievalCard/DocumentRetrievalCard.d.ts +2 -2
  25. package/dist/FloatingButton/FloatingButton.d.cts +2 -2
  26. package/dist/FloatingButton/FloatingButton.d.ts +2 -2
  27. package/dist/FloatingChat/FloatingChat.cjs +5 -0
  28. package/dist/FloatingChat/FloatingChat.d.cts +2 -2
  29. package/dist/FloatingChat/FloatingChat.d.ts +2 -2
  30. package/dist/FloatingChat/FloatingChat.js +5 -0
  31. package/dist/FloatingChat/components/SlideChatContent.cjs +1 -1
  32. package/dist/FloatingChat/components/SlideChatContent.js +1 -1
  33. package/dist/FullPageSalesAgent/FullPageSalesAgent.cjs +5 -0
  34. package/dist/FullPageSalesAgent/FullPageSalesAgent.d.cts +2 -2
  35. package/dist/FullPageSalesAgent/FullPageSalesAgent.d.ts +2 -2
  36. package/dist/FullPageSalesAgent/FullPageSalesAgent.js +5 -0
  37. package/dist/Image/Image.d.cts +2 -2
  38. package/dist/Image/Image.d.ts +2 -2
  39. package/dist/ImageGallery/ImageGallery.d.cts +2 -2
  40. package/dist/ImageGallery/ImageGallery.d.ts +2 -2
  41. package/dist/MarkdownProcessor/MarkdownProcessor.d.cts +2 -2
  42. package/dist/MarkdownProcessor/MarkdownProcessor.d.ts +2 -2
  43. package/dist/ProductCard/ProductCard.d.cts +2 -2
  44. package/dist/ProductCard/ProductCard.d.ts +2 -2
  45. package/dist/PromptButton/PromptButton.d.cts +2 -2
  46. package/dist/PromptButton/PromptButton.d.ts +2 -2
  47. package/dist/PromptButtonCarouselWithImage/PromptButtonCarouselWithImage.d.cts +2 -2
  48. package/dist/PromptButtonCarouselWithImage/PromptButtonCarouselWithImage.d.ts +2 -2
  49. package/dist/PromptCarousel/PromptCarousel.d.cts +2 -2
  50. package/dist/PromptCarousel/PromptCarousel.d.ts +2 -2
  51. package/dist/PromptCarousel/hooks/useCarouselButtons.cjs +3 -2
  52. package/dist/PromptCarousel/hooks/useCarouselButtons.js +3 -2
  53. package/dist/ReviewCard/ReviewCard.d.ts +2 -2
  54. package/dist/ReviewCard/components/index.d.ts +4 -4
  55. package/dist/SalesAgentProductCard/SalesAgentProductCard.d.cts +2 -2
  56. package/dist/SalesAgentProductCard/SalesAgentProductCard.d.ts +2 -2
  57. package/dist/SalesAgentProductCard/components/index.d.cts +8 -8
  58. package/dist/SalesAgentProductCard/components/index.d.ts +8 -8
  59. package/dist/SocialProof/SocialProof.d.cts +2 -2
  60. package/dist/SocialProof/SocialProof.d.ts +2 -2
  61. package/dist/SparkleAnimation/SparkleAnimation.d.cts +2 -2
  62. package/dist/SparkleAnimation/SparkleAnimation.d.ts +2 -2
  63. package/dist/Stack/Stack.d.cts +2 -2
  64. package/dist/Stack/Stack.d.ts +2 -2
  65. package/dist/TextField/hooks/useVoiceInput.cjs +8 -15
  66. package/dist/TextField/hooks/useVoiceInput.js +8 -15
  67. package/dist/TitledPromptCarousel/TitledPromptCarousel.d.cts +2 -2
  68. package/dist/TitledPromptCarousel/TitledPromptCarousel.d.ts +2 -2
  69. package/dist/TypingAnimation/TypingAnimation.d.cts +2 -2
  70. package/dist/Typography/Typography.d.cts +4 -4
  71. package/dist/Typography/Typography.d.ts +4 -4
  72. package/dist/WidgetTextField/WidgetTextField.cjs +1 -1
  73. package/dist/WidgetTextField/WidgetTextField.d.cts +2 -2
  74. package/dist/WidgetTextField/WidgetTextField.d.ts +2 -2
  75. package/dist/WidgetTextField/WidgetTextField.js +1 -1
  76. package/dist/WidgetWrapper/WidgetWrapper.d.cts +2 -2
  77. package/dist/WidgetWrapper/WidgetWrapper.d.ts +2 -2
  78. package/dist/WidgetWrapperWithTitle/WidgetWrapperWithTitle.d.cts +2 -2
  79. package/dist/WidgetWrapperWithTitle/WidgetWrapperWithTitle.d.ts +2 -2
  80. package/dist/styles.css +1 -1
  81. package/package.json +1 -1
  82. package/src/components/Disclaimer/components/Container.tsx +1 -1
  83. package/src/components/FloatingChat/FloatingChat.tsx +5 -0
  84. package/src/components/FloatingChat/components/SlideChatContent.tsx +1 -1
  85. package/src/components/FullPageSalesAgent/FullPageSalesAgent.tsx +11 -6
  86. package/src/components/PromptCarousel/__tests__/PromptCarousel.test.tsx +19 -0
  87. package/src/components/PromptCarousel/hooks/useCarouselButtons.ts +4 -2
  88. package/src/components/TextField/hooks/useVoiceInput.ts +11 -13
  89. package/src/components/WidgetTextField/WidgetTextField.tsx +1 -1
@@ -395,6 +395,25 @@ describe('PromptCarousel', () => {
395
395
  expect(screen.getByText('Button 4')).toBeInTheDocument();
396
396
  });
397
397
 
398
+ it('should place two buttons per row when four prompts and ALWAYS_TWO', () => {
399
+ const { container } = render(
400
+ <PromptCarousel
401
+ id="test-carousel"
402
+ promptButtonTexts={['Button 1', 'Button 2', 'Button 3', 'Button 4']}
403
+ promptCarouselRows={PromptCarouselRows.ALWAYS_TWO}
404
+ handleButtonClick={vi.fn()}
405
+ />,
406
+ );
407
+
408
+ const rows = container.querySelectorAll('.envive-tw-overflow-x-auto');
409
+ expect(rows).toHaveLength(2);
410
+ expect(rows[0].textContent).toContain('Button 1');
411
+ expect(rows[0].textContent).toContain('Button 2');
412
+ expect(rows[0].textContent).not.toContain('Button 3');
413
+ expect(rows[1].textContent).toContain('Button 3');
414
+ expect(rows[1].textContent).toContain('Button 4');
415
+ });
416
+
398
417
  it('should render two rows on mobile when promptCarouselRows is TWO_ON_MOBILE_ONE_ON_DESKTOP', () => {
399
418
  mockUseCheckIsMobile.mockReturnValue({ isMobile: true, viewportWidth: 400 });
400
419
 
@@ -5,6 +5,8 @@ interface UseCarouselButtonsProps {
5
5
  shouldShowTwoRows: boolean;
6
6
  }
7
7
 
8
+ const getFirstRowCount = (length: number) => Math.ceil(length / 2);
9
+
8
10
  export const useCarouselButtons = ({
9
11
  promptButtonTexts,
10
12
  shouldShowTwoRows,
@@ -14,7 +16,7 @@ export const useCarouselButtons = ({
14
16
  return [];
15
17
  }
16
18
  return shouldShowTwoRows
17
- ? promptButtonTexts.slice(0, Math.ceil((promptButtonTexts.length + 1) / 2))
19
+ ? promptButtonTexts.slice(0, getFirstRowCount(promptButtonTexts.length))
18
20
  : promptButtonTexts;
19
21
  }, [promptButtonTexts, shouldShowTwoRows]);
20
22
 
@@ -23,7 +25,7 @@ export const useCarouselButtons = ({
23
25
  return [];
24
26
  }
25
27
  return promptButtonTexts.slice(
26
- Math.ceil((promptButtonTexts.length + 1) / 2),
28
+ getFirstRowCount(promptButtonTexts.length),
27
29
  promptButtonTexts.length,
28
30
  );
29
31
  }, [promptButtonTexts]);
@@ -32,7 +32,7 @@ export const useVoiceInput = ({
32
32
  onTranscriptionStarted?.();
33
33
  } catch (error) {
34
34
  console.log('Microphone permission denied or error:', error);
35
- setListeningToSpeech(false);
35
+ setListeningToSpeech('abort');
36
36
  }
37
37
  };
38
38
 
@@ -49,27 +49,25 @@ export const useVoiceInput = ({
49
49
  const handleToggleListening = () => {
50
50
  if (disabled || !isMicrophoneAvailable || !browserSupportsSpeechRecognition) return;
51
51
 
52
- if (!listeningToSpeech) {
53
- handleStartListening();
54
- setListeningToSpeech(true);
52
+ if (listeningToSpeech !== 'start') {
53
+ setListeningToSpeech('start');
55
54
  } else {
56
- handleStopListening();
57
- setListeningToSpeech(false);
55
+ setListeningToSpeech('stop');
58
56
  }
59
57
  };
60
58
 
61
59
  useEffect(() => {
62
- if (listeningToSpeech) {
60
+ if (listeningToSpeech === 'start') {
63
61
  handleStartListening();
62
+ } else if (listeningToSpeech === 'stop') {
63
+ handleStopListening();
64
+ } else if (listeningToSpeech === 'abort') {
65
+ handleAbortListening();
64
66
  }
65
- return () => {
66
- resetTranscript();
67
- setListeningToSpeech(false);
68
- };
69
- }, []);
67
+ }, [listeningToSpeech]);
70
68
 
71
69
  return {
72
- isListening: listeningToSpeech,
70
+ isListening: listeningToSpeech === 'start',
73
71
  handleToggleListening,
74
72
  handleAbortListening,
75
73
  browserSupportsSpeechRecognition,
@@ -51,7 +51,7 @@ export const WidgetTextField = ({
51
51
  }
52
52
 
53
53
  const handleToggleListening = () => {
54
- setListeningToSpeech(true);
54
+ setListeningToSpeech('start');
55
55
  onTranscriptionStarted?.();
56
56
  onClick();
57
57
  };