@envive-ai/react-toolkit-v3 0.3.12 → 0.3.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.
Files changed (234) hide show
  1. package/dist/AnimatedText/AnimatedText.d.cts +3 -3
  2. package/dist/CSSVariablesEditor/CssVariablesEditorComponent.d.cts +2 -2
  3. package/dist/CSSVariablesEditor/CssVariablesEditorComponent.d.ts +2 -2
  4. package/dist/CSSVariablesEditor/hooks/useGetCssVariablesOptions.cjs +1 -1
  5. package/dist/CSSVariablesEditor/hooks/useGetCssVariablesOptions.js +1 -1
  6. package/dist/CSSVariablesEditor/hooks/useGetCurrentMerchantColors.cjs +1 -1
  7. package/dist/CSSVariablesEditor/hooks/useGetCurrentMerchantColors.js +1 -1
  8. package/dist/CSSVariablesEditor/hooks/useGetDefaultCssVariables.cjs +1 -1
  9. package/dist/CSSVariablesEditor/hooks/useGetDefaultCssVariables.js +1 -1
  10. package/dist/CSSVariablesEditor/hooks/useHandleUpdateCssVars.cjs +1 -1
  11. package/dist/CSSVariablesEditor/hooks/useHandleUpdateCssVars.js +1 -1
  12. package/dist/Carousel/Carousel.d.cts +2 -2
  13. package/dist/Carousel/Carousel.d.ts +2 -2
  14. package/dist/Carousel/components/Badge.cjs +1 -1
  15. package/dist/Carousel/components/Badge.js +1 -1
  16. package/dist/Carousel/components/Container.cjs +1 -1
  17. package/dist/Carousel/components/Container.js +1 -1
  18. package/dist/ChatFooter/ChatFooter.cjs +1 -1
  19. package/dist/ChatFooter/ChatFooter.d.ts +2 -2
  20. package/dist/ChatFooter/ChatFooter.js +1 -1
  21. package/dist/ChatFooter/components/Layout.cjs +1 -1
  22. package/dist/ChatFooter/components/Layout.js +1 -1
  23. package/dist/ChatFooter/components/index.d.cts +5 -5
  24. package/dist/ChatFooter/components/index.d.ts +3 -3
  25. package/dist/ChatHeader/ChatHeader.d.cts +2 -2
  26. package/dist/ChatHeader/ChatHeader.d.ts +2 -2
  27. package/dist/ChatHeader/hooks/useGetLayoutProperties.cjs +1 -1
  28. package/dist/ChatHeader/hooks/useGetLayoutProperties.js +1 -1
  29. package/dist/ChatPreview/ChatPreview.d.cts +2 -2
  30. package/dist/ChatPreview/ChatPreview.d.ts +2 -2
  31. package/dist/ChatPreviewComparison/ChatPreviewComparison.d.cts +2 -2
  32. package/dist/ChatPreviewComparison/ChatPreviewComparison.d.ts +2 -2
  33. package/dist/ChatPreviewComparison/components/Layout.cjs +6 -5
  34. package/dist/ChatPreviewComparison/components/Layout.js +6 -5
  35. package/dist/ChatPreviewLoading/ChatPreviewLoading.d.cts +2 -2
  36. package/dist/ChatPreviewLoading/ChatPreviewLoading.d.ts +2 -2
  37. package/dist/DesignTokens/DesignTokensComponent.d.cts +2 -2
  38. package/dist/DesignTokens/DesignTokensComponent.d.ts +2 -2
  39. package/dist/DesignTokens/components/FontFamily.cjs +1 -1
  40. package/dist/DesignTokens/components/FontFamily.js +1 -1
  41. package/dist/DesignTokens/components/FontSize.cjs +1 -1
  42. package/dist/DesignTokens/components/FontSize.js +1 -1
  43. package/dist/DesignTokens/components/FontWeight.cjs +1 -1
  44. package/dist/DesignTokens/components/FontWeight.js +1 -1
  45. package/dist/DesignTokens/components/LetterSpacing.cjs +1 -1
  46. package/dist/DesignTokens/components/LetterSpacing.js +1 -1
  47. package/dist/DesignTokens/components/LineHeight.cjs +1 -1
  48. package/dist/DesignTokens/components/LineHeight.js +1 -1
  49. package/dist/DesignTokens/components/Typography.cjs +1 -1
  50. package/dist/DesignTokens/components/Typography.js +1 -1
  51. package/dist/Disclaimer/components/Container.cjs +1 -1
  52. package/dist/Disclaimer/components/Container.js +1 -1
  53. package/dist/DocumentRetrievalCard/DocumentRetrievalCard.d.cts +2 -2
  54. package/dist/DocumentRetrievalCard/DocumentRetrievalCard.d.ts +2 -2
  55. package/dist/DocumentRetrievalCard/components/Image.cjs +1 -1
  56. package/dist/DocumentRetrievalCard/components/Image.js +1 -1
  57. package/dist/DocumentRetrievalCard/components/Layout.cjs +1 -1
  58. package/dist/DocumentRetrievalCard/components/Layout.js +1 -1
  59. package/dist/DocumentRetrievalCard/components/ViewArticleButton/components/Icon.cjs +1 -1
  60. package/dist/DocumentRetrievalCard/components/ViewArticleButton/components/Icon.js +1 -1
  61. package/dist/DocumentRetrievalCard/components/ViewArticleButton/components/Label.cjs +1 -1
  62. package/dist/DocumentRetrievalCard/components/ViewArticleButton/components/Label.js +1 -1
  63. package/dist/DocumentRetrievalCard/components/ViewArticleButton/components/Layout.cjs +1 -1
  64. package/dist/DocumentRetrievalCard/components/ViewArticleButton/components/Layout.js +1 -1
  65. package/dist/FloatingButton/FloatingButton.d.cts +2 -2
  66. package/dist/FloatingButton/FloatingButton.d.ts +2 -2
  67. package/dist/FloatingButton/components/Button.cjs +1 -1
  68. package/dist/FloatingButton/components/Button.js +1 -1
  69. package/dist/FloatingButton/components/Container.cjs +1 -1
  70. package/dist/FloatingButton/components/Container.js +1 -1
  71. package/dist/FloatingButton/components/Wrapper.cjs +1 -1
  72. package/dist/FloatingButton/components/Wrapper.js +1 -1
  73. package/dist/FloatingChat/FloatingChat.cjs +5 -2
  74. package/dist/FloatingChat/FloatingChat.d.cts +2 -2
  75. package/dist/FloatingChat/FloatingChat.d.ts +2 -2
  76. package/dist/FloatingChat/FloatingChat.js +5 -2
  77. package/dist/FloatingChat/components/ChatMessages.cjs +1 -1
  78. package/dist/FloatingChat/components/ChatMessages.js +1 -1
  79. package/dist/FloatingChat/components/Layout.cjs +1 -1
  80. package/dist/FloatingChat/components/Layout.js +1 -1
  81. package/dist/FloatingChat/hooks/useSnapSetup.cjs +10 -7
  82. package/dist/FloatingChat/hooks/useSnapSetup.js +10 -7
  83. package/dist/Form/Form.cjs +1 -1
  84. package/dist/Form/Form.js +1 -1
  85. package/dist/Form/components/Layout.cjs +1 -1
  86. package/dist/Form/components/Layout.js +1 -1
  87. package/dist/Form/components/SubmitButtonItem.cjs +1 -1
  88. package/dist/Form/components/SubmitButtonItem.js +1 -1
  89. package/dist/Form/components/TextFieldItem.cjs +1 -1
  90. package/dist/Form/components/TextFieldItem.js +1 -1
  91. package/dist/FullPageSalesAgent/FullPageSalesAgent.d.cts +2 -2
  92. package/dist/FullPageSalesAgent/FullPageSalesAgent.d.ts +2 -2
  93. package/dist/FullPageSalesAgent/components/Layout.cjs +1 -1
  94. package/dist/FullPageSalesAgent/components/Layout.js +1 -1
  95. package/dist/Image/Image.cjs +1 -1
  96. package/dist/Image/Image.d.cts +2 -2
  97. package/dist/Image/Image.d.ts +2 -2
  98. package/dist/Image/Image.js +1 -1
  99. package/dist/ImageGallery/ImageGallery.d.ts +2 -2
  100. package/dist/ImageGallery/components/Layout.cjs +1 -1
  101. package/dist/ImageGallery/components/Layout.js +1 -1
  102. package/dist/ImageGallery/utils/functions.cjs +1 -1
  103. package/dist/ImageGallery/utils/functions.js +1 -1
  104. package/dist/MarkdownProcessor/MarkdownProcessor.cjs +14 -27
  105. package/dist/MarkdownProcessor/MarkdownProcessor.d.cts +3 -5
  106. package/dist/MarkdownProcessor/MarkdownProcessor.d.ts +3 -5
  107. package/dist/MarkdownProcessor/MarkdownProcessor.js +15 -26
  108. package/dist/MarkdownProcessor/components/index.cjs +1 -3
  109. package/dist/MarkdownProcessor/components/index.js +1 -3
  110. package/dist/MarkdownProcessor/utils/functions.cjs +1 -11
  111. package/dist/MarkdownProcessor/utils/functions.js +1 -10
  112. package/dist/Message/components/Layout.cjs +1 -1
  113. package/dist/Message/components/Layout.js +1 -1
  114. package/dist/OrderLookupCard/OrderLookupCard.cjs +1 -1
  115. package/dist/OrderLookupCard/OrderLookupCard.js +1 -1
  116. package/dist/OrderLookupCard/components/Layout.cjs +1 -1
  117. package/dist/OrderLookupCard/components/Layout.js +1 -1
  118. package/dist/OrderLookupCard/components/MoreProductsOverlay.cjs +1 -1
  119. package/dist/OrderLookupCard/components/MoreProductsOverlay.js +1 -1
  120. package/dist/OrderLookupCard/components/ProductImageGridItem.cjs +1 -1
  121. package/dist/OrderLookupCard/components/ProductImageGridItem.js +1 -1
  122. package/dist/OrderLookupCard/components/ProductImageItem.cjs +1 -1
  123. package/dist/OrderLookupCard/components/ProductImageItem.js +1 -1
  124. package/dist/OrderLookupCard/components/ProductImagesGrid.cjs +1 -1
  125. package/dist/OrderLookupCard/components/ProductImagesGrid.js +1 -1
  126. package/dist/OrderLookupCard/components/StatusLabel.cjs +1 -1
  127. package/dist/OrderLookupCard/components/StatusLabel.js +1 -1
  128. package/dist/OrderLookupCard/components/TrackOrderLink.cjs +1 -1
  129. package/dist/OrderLookupCard/components/TrackOrderLink.js +1 -1
  130. package/dist/ProductCard/ProductCard.cjs +1 -1
  131. package/dist/ProductCard/ProductCard.d.cts +2 -2
  132. package/dist/ProductCard/ProductCard.d.ts +2 -2
  133. package/dist/ProductCard/ProductCard.js +1 -1
  134. package/dist/ProductCard/components/Header.cjs +33 -7
  135. package/dist/ProductCard/components/Header.js +34 -8
  136. package/dist/PromptButton/PromptButton.cjs +1 -1
  137. package/dist/PromptButton/PromptButton.d.cts +2 -2
  138. package/dist/PromptButton/PromptButton.d.ts +2 -2
  139. package/dist/PromptButton/PromptButton.js +1 -1
  140. package/dist/PromptButton/components/Layout.cjs +1 -1
  141. package/dist/PromptButton/components/Layout.js +1 -1
  142. package/dist/PromptButton/components/Loading.cjs +1 -1
  143. package/dist/PromptButton/components/Loading.js +1 -1
  144. package/dist/PromptButtonCarouselWithImage/PromptButtonCarouselWithImage.d.cts +2 -2
  145. package/dist/PromptButtonCarouselWithImage/components/Layout.cjs +1 -1
  146. package/dist/PromptButtonCarouselWithImage/components/Layout.js +1 -1
  147. package/dist/PromptButtonCarouselWithImage/components/Skeleton.cjs +1 -1
  148. package/dist/PromptButtonCarouselWithImage/components/Skeleton.js +1 -1
  149. package/dist/PromptCarousel/PromptCarousel.cjs +1 -1
  150. package/dist/PromptCarousel/PromptCarousel.d.cts +2 -2
  151. package/dist/PromptCarousel/PromptCarousel.d.ts +2 -2
  152. package/dist/PromptCarousel/PromptCarousel.js +1 -1
  153. package/dist/ReviewCard/ReviewCard.d.cts +2 -2
  154. package/dist/ReviewCard/ReviewCard.d.ts +2 -2
  155. package/dist/ReviewCard/components/Container.cjs +1 -1
  156. package/dist/ReviewCard/components/Container.js +1 -1
  157. package/dist/ReviewCard/components/Rating.cjs +1 -1
  158. package/dist/ReviewCard/components/Rating.js +1 -1
  159. package/dist/ReviewCard/components/ReadMoreButton.cjs +1 -1
  160. package/dist/ReviewCard/components/ReadMoreButton.js +1 -1
  161. package/dist/ReviewCard/components/index.d.cts +6 -6
  162. package/dist/ReviewCard/components/index.d.ts +6 -6
  163. package/dist/SalesAgentProductCard/SalesAgentProductCard.d.cts +2 -2
  164. package/dist/SalesAgentProductCard/SalesAgentProductCard.d.ts +2 -2
  165. package/dist/SalesAgentProductCard/components/Container.cjs +1 -1
  166. package/dist/SalesAgentProductCard/components/Container.js +1 -1
  167. package/dist/SalesAgentProductCard/components/ProductImage.cjs +1 -1
  168. package/dist/SalesAgentProductCard/components/ProductImage.js +1 -1
  169. package/dist/SalesAgentProductCard/components/ProductName.cjs +1 -1
  170. package/dist/SalesAgentProductCard/components/ProductName.js +1 -1
  171. package/dist/SalesAgentProductCard/components/index.d.cts +8 -8
  172. package/dist/SalesAgentProductCard/components/index.d.ts +8 -8
  173. package/dist/SocialProof/SocialProof.d.cts +2 -2
  174. package/dist/SocialProof/SocialProof.d.ts +2 -2
  175. package/dist/SocialProof/components/Headline.cjs +1 -1
  176. package/dist/SocialProof/components/Headline.js +1 -1
  177. package/dist/SocialProof/components/LayoutFourHorizontal.cjs +1 -1
  178. package/dist/SocialProof/components/LayoutFourHorizontal.js +1 -1
  179. package/dist/Stack/Stack.d.ts +2 -2
  180. package/dist/TextField/TextField.cjs +1 -1
  181. package/dist/TextField/TextField.js +1 -1
  182. package/dist/TextField/components/Input.cjs +1 -1
  183. package/dist/TextField/components/Input.js +1 -1
  184. package/dist/TextField/components/Layout.cjs +1 -1
  185. package/dist/TextField/components/Layout.js +1 -1
  186. package/dist/TextField/components/SendIcon.cjs +1 -1
  187. package/dist/TextField/components/SendIcon.js +1 -1
  188. package/dist/Title/Title.cjs +1 -1
  189. package/dist/Title/Title.js +1 -1
  190. package/dist/Title/components/Layout.cjs +1 -1
  191. package/dist/Title/components/Layout.js +1 -1
  192. package/dist/TitledPromptCarousel/TitledPromptCarousel.cjs +1 -1
  193. package/dist/TitledPromptCarousel/TitledPromptCarousel.d.cts +2 -2
  194. package/dist/TitledPromptCarousel/TitledPromptCarousel.d.ts +2 -2
  195. package/dist/TitledPromptCarousel/TitledPromptCarousel.js +1 -1
  196. package/dist/Tokens/index.cjs +2 -2
  197. package/dist/Tokens/index.js +2 -2
  198. package/dist/TypingAnimation/TypingAnimation.cjs +58 -18
  199. package/dist/TypingAnimation/TypingAnimation.d.cts +2 -2
  200. package/dist/TypingAnimation/TypingAnimation.d.ts +2 -2
  201. package/dist/TypingAnimation/TypingAnimation.js +59 -19
  202. package/dist/Typography/Typography.d.ts +4 -4
  203. package/dist/WelcomeMessage/components/Container.cjs +1 -1
  204. package/dist/WelcomeMessage/components/Container.js +1 -1
  205. package/dist/WidgetTextField/WidgetTextField.d.cts +2 -2
  206. package/dist/WidgetTextField/WidgetTextField.d.ts +2 -2
  207. package/dist/WidgetTextField/components/Container.cjs +1 -1
  208. package/dist/WidgetTextField/components/Container.js +1 -1
  209. package/dist/WidgetTextField/components/Skeleton.cjs +1 -1
  210. package/dist/WidgetTextField/components/Skeleton.js +1 -1
  211. package/dist/WidgetWrapper/WidgetWrapper.cjs +1 -1
  212. package/dist/WidgetWrapper/WidgetWrapper.d.cts +2 -2
  213. package/dist/WidgetWrapper/WidgetWrapper.js +1 -1
  214. package/dist/WidgetWrapperWithTitle/WidgetWrapperWithTitle.d.cts +2 -2
  215. package/dist/WidgetWrapperWithTitle/WidgetWrapperWithTitle.d.ts +2 -2
  216. package/dist/styles.css +1 -1
  217. package/dist/utils/resolveTheme.cjs +1 -1
  218. package/dist/utils/resolveTheme.js +1 -1
  219. package/dist/utils/useAnimatedTextMinHeight.cjs +28 -0
  220. package/dist/utils/useAnimatedTextMinHeight.js +27 -0
  221. package/package.json +1 -3
  222. package/src/components/ChatPreviewComparison/components/Layout.tsx +2 -2
  223. package/src/components/FloatingChat/FloatingChat.tsx +4 -1
  224. package/src/components/FloatingChat/hooks/useSnapSetup.ts +11 -4
  225. package/src/components/MarkdownProcessor/MarkdownProcessor.tsx +3 -19
  226. package/src/components/MarkdownProcessor/__tests__/MarkdownProcessor.test.tsx +1 -39
  227. package/src/components/MarkdownProcessor/components/index.ts +0 -2
  228. package/src/components/MarkdownProcessor/utils/functions.tsx +0 -19
  229. package/src/components/ProductCard/components/Header.tsx +39 -9
  230. package/src/components/TypingAnimation/TypingAnimation.tsx +68 -22
  231. package/src/components/utils/useAnimatedTextMinHeight.ts +29 -0
  232. package/dist/MarkdownProcessor/components/MarkdownSubscript.cjs +0 -15
  233. package/dist/MarkdownProcessor/components/MarkdownSubscript.js +0 -14
  234. package/src/components/MarkdownProcessor/components/MarkdownSubscript.tsx +0 -22
@@ -55,6 +55,7 @@ export const FloatingChat = ({
55
55
  showEnviveLogo,
56
56
  ignoreFirstModelResponse,
57
57
  neverShowSingleProductCards,
58
+ partialViewConfig,
58
59
  } = floatingChatConfig;
59
60
 
60
61
  const {
@@ -95,6 +96,8 @@ export const FloatingChat = ({
95
96
  }
96
97
  };
97
98
 
99
+ const partialViewDisabled = partialViewConfig?.disabled ?? false;
100
+
98
101
  const {
99
102
  modalSheetControl,
100
103
  maxSwipeableViewHeight,
@@ -110,7 +113,7 @@ export const FloatingChat = ({
110
113
  shouldShowHeader,
111
114
  isFullView,
112
115
  isPartialView,
113
- } = useSnapSetup({ isFloatingChatOpen });
116
+ } = useSnapSetup({ isFloatingChatOpen, partialViewDisabled });
114
117
 
115
118
  const { showScrollButton, scrollToBottom, isFloatingLayout } = useScrollToBottom({
116
119
  messagesRef: chatMessagesRef,
@@ -24,16 +24,19 @@ export interface UseSnapSetupReturn {
24
24
  snap100Percent: number;
25
25
 
26
26
  shouldShowHeader: boolean;
27
- shouldShowScrolled: boolean;
28
27
  isFullView: boolean;
29
28
  isPartialView: boolean;
30
29
  }
31
30
 
32
31
  export interface UseSnapSetupProps {
33
32
  isFloatingChatOpen: boolean;
33
+ partialViewDisabled?: boolean;
34
34
  }
35
35
 
36
- export const useSnapSetup = ({ isFloatingChatOpen }: UseSnapSetupProps): UseSnapSetupReturn => {
36
+ export const useSnapSetup = ({
37
+ isFloatingChatOpen,
38
+ partialViewDisabled,
39
+ }: UseSnapSetupProps): UseSnapSetupReturn => {
37
40
  const maxSwipeableViewHeight = 89;
38
41
  const modalSheetControl = useRef<ModalSheetControl>(null);
39
42
  const { viewportWidth } = useCheckIsMobile();
@@ -46,8 +49,12 @@ export const useSnapSetup = ({ isFloatingChatOpen }: UseSnapSetupProps): UseSnap
46
49
  ?.selectedCustomizeOption,
47
50
  );
48
51
 
49
- const snaps = shouldAutoExpand ? [43, 100] : [0, 43, 100];
50
- const initialSnap = 1;
52
+ const snaps = (() => {
53
+ if (partialViewDisabled) return shouldAutoExpand ? [100] : [0, 100];
54
+ return shouldAutoExpand ? [43, 100] : [0, 43, 100];
55
+ })();
56
+ const partialViewDisabledValue = shouldAutoExpand ? 0 : 1;
57
+ const initialSnap = partialViewDisabled ? partialViewDisabledValue : 1;
51
58
 
52
59
  const [currentSnapPercentage, setCurrentSnapPercentage] = useState<number>(
53
60
  snaps[initialSnap] || 43,
@@ -1,21 +1,14 @@
1
1
  import { useMemo } from 'react';
2
2
  import ReactMarkdown from 'react-markdown';
3
- import remarkGfm from 'remark-gfm';
4
- import rehypeRaw from 'rehype-raw';
5
3
  import { MarkdownProcessorProps } from './types/types';
6
4
  import { MarkdownProcessorComponents } from './components';
7
- import {
8
- createMarkdownParagraphComponent,
9
- createMarkdownSubscriptComponent,
10
- } from './utils/functions';
5
+ import { createMarkdownParagraphComponent } from './utils/functions';
11
6
 
12
7
  export const MarkdownProcessor = ({
13
8
  content,
14
9
  clampParagraphs = undefined,
15
10
  textColor,
16
11
  textVariant,
17
- subTextVariant,
18
- subTextColor,
19
12
  }: MarkdownProcessorProps) => {
20
13
  const processedContent = content.replace(/<br\s*[\\/]?>/gi, '\n\n');
21
14
 
@@ -26,18 +19,9 @@ export const MarkdownProcessor = ({
26
19
  ol: MarkdownProcessorComponents.MarkdownOrderedList,
27
20
  a: MarkdownProcessorComponents.MarkdownLink,
28
21
  p: createMarkdownParagraphComponent({ clampParagraphs, textColor, textVariant }),
29
- sub: createMarkdownSubscriptComponent({ subTextVariant, subTextColor }),
30
22
  }),
31
- [clampParagraphs, textColor, textVariant, subTextVariant, subTextColor],
23
+ [clampParagraphs, textColor, textVariant],
32
24
  );
33
25
 
34
- return (
35
- <ReactMarkdown
36
- remarkPlugins={[remarkGfm]}
37
- rehypePlugins={[rehypeRaw]}
38
- components={components}
39
- >
40
- {processedContent}
41
- </ReactMarkdown>
42
- );
26
+ return <ReactMarkdown components={components}>{processedContent}</ReactMarkdown>;
43
27
  };
@@ -69,22 +69,6 @@ describe('MarkdownProcessor', () => {
69
69
  });
70
70
  });
71
71
 
72
- describe('Subscript', () => {
73
- it('should render subscript text', () => {
74
- const content = 'Regular text<sub>subscript</sub>';
75
- render(<MarkdownProcessor content={content} />);
76
- expect(screen.getByText('Regular text')).toBeInTheDocument();
77
- expect(screen.getByText('subscript')).toBeInTheDocument();
78
- });
79
-
80
- it('should render multiple subscript elements', () => {
81
- const content = 'First<sub>sub1</sub> and second<sub>sub2</sub>';
82
- render(<MarkdownProcessor content={content} />);
83
- expect(screen.getByText('sub1')).toBeInTheDocument();
84
- expect(screen.getByText('sub2')).toBeInTheDocument();
85
- });
86
- });
87
-
88
72
  describe('Paragraph clamping', () => {
89
73
  it('should not clamp paragraphs when clampParagraphs is undefined', () => {
90
74
  const content =
@@ -131,34 +115,12 @@ describe('MarkdownProcessor', () => {
131
115
  );
132
116
  expect(screen.getByText('Custom color text')).toBeInTheDocument();
133
117
  });
134
-
135
- it('should apply custom subTextVariant', () => {
136
- const content = 'Text<sub>subscript</sub>';
137
- render(
138
- <MarkdownProcessor
139
- content={content}
140
- subTextVariant={TypographyVariant.B4_RG}
141
- />,
142
- );
143
- expect(screen.getByText('subscript')).toBeInTheDocument();
144
- });
145
-
146
- it('should apply custom subTextColor', () => {
147
- const content = 'Text<sub>subscript</sub>';
148
- render(
149
- <MarkdownProcessor
150
- content={content}
151
- subTextColor={TypographyColor.TEXT_ACCENT}
152
- />,
153
- );
154
- expect(screen.getByText('subscript')).toBeInTheDocument();
155
- });
156
118
  });
157
119
 
158
120
  describe('Complex content', () => {
159
121
  it('should render complex markdown with multiple elements', () => {
160
122
  const content =
161
- '# Heading\n\nThis is a paragraph with **bold** and *italic*.\n\n- List item 1\n- List item 2\n\n1. Ordered item 1\n2. Ordered item 2\n\n[Link text](https://example.com)\n\nText with<sub>subscript</sub>.';
123
+ '# Heading\n\nThis is a paragraph with **bold** and *italic*.\n\n- List item 1\n- List item 2\n\n1. Ordered item 1\n2. Ordered item 2\n\n[Link text](https://example.com)';
162
124
  render(<MarkdownProcessor content={content} />);
163
125
  expect(screen.getByText(/This is a paragraph/i)).toBeInTheDocument();
164
126
  expect(screen.getByText('List item 1')).toBeInTheDocument();
@@ -3,7 +3,6 @@ import { MarkdownLink } from './MarkdownLink';
3
3
  import { MarkdownOrderedList } from './MarkdownOrderedList';
4
4
  import { MarkdownUnorderedList } from './MarkdownUnorderedList';
5
5
  import { MarkdownParagraph } from './MarkdownParagraph';
6
- import { MarkdownSubscript } from './MarkdownSubscript';
7
6
 
8
7
  export const MarkdownProcessorComponents = {
9
8
  MarkdownListItem,
@@ -11,5 +10,4 @@ export const MarkdownProcessorComponents = {
11
10
  MarkdownOrderedList,
12
11
  MarkdownUnorderedList,
13
12
  MarkdownParagraph,
14
- MarkdownSubscript,
15
13
  };
@@ -22,22 +22,3 @@ export const createMarkdownParagraphComponent = ({
22
22
  Component.displayName = 'MarkdownParagraphComponent';
23
23
  return Component;
24
24
  };
25
-
26
- export const createMarkdownSubscriptComponent = ({
27
- subTextVariant,
28
- subTextColor,
29
- }: {
30
- subTextVariant?: TypographyVariant;
31
- subTextColor?: TypographyColor;
32
- }) => {
33
- const Component = ({ children }: { children?: React.ReactNode }) => (
34
- <MarkdownProcessorComponents.MarkdownSubscript
35
- subTextVariant={subTextVariant}
36
- subTextColor={subTextColor}
37
- >
38
- {children}
39
- </MarkdownProcessorComponents.MarkdownSubscript>
40
- );
41
- Component.displayName = 'MarkdownSubscriptComponent';
42
- return Component;
43
- };
@@ -1,7 +1,8 @@
1
- import { useCallback } from 'react';
1
+ import { useCallback, useMemo } from 'react';
2
2
  import { AnimatedText } from '../../AnimatedText';
3
3
  import { Stack } from '../../Stack';
4
4
  import { Typography, TypographyColor, TypographyVariant } from '../../Typography';
5
+ import { useAnimatedTextMinHeight } from '../../utils/useAnimatedTextMinHeight';
5
6
  import { useGetHeaderProperties } from '../hooks/useGetHeaderProperties';
6
7
  import { HeaderProps } from '../types';
7
8
 
@@ -14,13 +15,19 @@ export const Header = ({
14
15
  loop,
15
16
  }: HeaderProps) => {
16
17
  const { stackClasses, headlineClasses } = useGetHeaderProperties(italicizeHeadline);
18
+ const { measuringRef, minHeight } = useAnimatedTextMinHeight(animatedText);
19
+
20
+ const biggestText = useMemo(() => {
21
+ return animatedText.reduce((maxText, currText) => {
22
+ return currText.length > maxText.length ? currText : maxText;
23
+ }, '');
24
+ }, [animatedText]);
17
25
 
18
26
  const animatedTextWrapper = useCallback(
19
27
  (text: string) => (
20
28
  <Typography
21
29
  variant={TypographyVariant.B3_MD}
22
30
  color={TypographyColor.TEXT_LIGHT}
23
- numberOfLines={2}
24
31
  >
25
32
  {text}
26
33
  </Typography>
@@ -42,13 +49,36 @@ export const Header = ({
42
49
  {headline}
43
50
  </Typography>
44
51
  {animatedText.length > 0 && (
45
- <AnimatedText
46
- sequence={animatedText}
47
- getNodeWrapper={animatedTextWrapper}
48
- typingDuration={textTypingDuration}
49
- transition={textTransition}
50
- loop={loop}
51
- />
52
+ <div style={{ position: 'relative' }}>
53
+ <div
54
+ ref={measuringRef}
55
+ aria-hidden="true"
56
+ style={{
57
+ position: 'absolute',
58
+ visibility: 'hidden',
59
+ pointerEvents: 'none',
60
+ width: '100%',
61
+ }}
62
+ >
63
+ <div>
64
+ <Typography
65
+ variant={TypographyVariant.B3_MD}
66
+ color={TypographyColor.TEXT_LIGHT}
67
+ >
68
+ {biggestText}
69
+ </Typography>
70
+ </div>
71
+ </div>
72
+ <div style={{ minHeight }}>
73
+ <AnimatedText
74
+ sequence={animatedText}
75
+ getNodeWrapper={animatedTextWrapper}
76
+ typingDuration={textTypingDuration}
77
+ transition={textTransition}
78
+ loop={loop}
79
+ />
80
+ </div>
81
+ </div>
52
82
  )}
53
83
  </Stack>
54
84
  );
@@ -1,4 +1,4 @@
1
- import { useCallback } from 'react';
1
+ import { useCallback, useMemo } from 'react';
2
2
  import { AnimatedText } from '../AnimatedText';
3
3
  import { Typography, TypographyColor } from '../Typography';
4
4
  import { PromptCarousel, PromptCarouselRows } from '../PromptCarousel';
@@ -9,6 +9,7 @@ import { Theme } from '../Tokens';
9
9
  import { WidgetWrapperWithTitle } from '../WidgetWrapperWithTitle';
10
10
  import type { TypingAnimationProps } from './types';
11
11
  import { useGetTypographyVariant } from './hooks/useGetTypographyVariant';
12
+ import { useAnimatedTextMinHeight } from '../utils/useAnimatedTextMinHeight';
12
13
  import { Stack } from '../Stack';
13
14
 
14
15
  export const TypingAnimation = ({
@@ -40,6 +41,15 @@ export const TypingAnimation = ({
40
41
 
41
42
  const { handleButtonClick, handleTextFieldClick } = widgetEventProps || {};
42
43
  const typographyVariant = useGetTypographyVariant(theme);
44
+ const { measuringRef, minHeight } = useAnimatedTextMinHeight(animatedTextSequence ?? []);
45
+
46
+ const biggestAnimatedText = useMemo(() => {
47
+ if (!animatedTextSequence || animatedTextSequence.length === 0) return '';
48
+ return animatedTextSequence.reduce(
49
+ (maxText, currText) => (currText.length > maxText.length ? currText : maxText),
50
+ '',
51
+ );
52
+ }, [animatedTextSequence]);
43
53
 
44
54
  const getAnimatedTextWrapper = useCallback(
45
55
  (text: string) => (
@@ -71,28 +81,64 @@ export const TypingAnimation = ({
71
81
  >
72
82
  {(headlineText || (animatedTextSequence && animatedTextSequence.length > 0)) &&
73
83
  !isLoading && (
74
- <p
75
- data-testid="typing-animation-headline-text"
76
- className="envive-tw-max-w-[90ch] envive-tw-overflow-hidden envive-tw-text-ellipsis envive-tw-whitespace-nowrap"
77
- style={{ textAlign: 'left' }}
78
- >
79
- {headlineText && (
80
- <Typography
81
- variant={typographyVariant}
82
- color={TypographyColor.TEXT_PRIMARY}
83
- as="span"
84
+ <div style={{ position: 'relative' }}>
85
+ <div
86
+ ref={measuringRef}
87
+ aria-hidden="true"
88
+ style={{
89
+ position: 'absolute',
90
+ visibility: 'hidden',
91
+ pointerEvents: 'none',
92
+ width: '100%',
93
+ }}
94
+ >
95
+ <p
96
+ className="envive-tw-max-w-[90ch]"
97
+ style={{ textAlign: 'left' }}
98
+ >
99
+ {headlineText && (
100
+ <Typography
101
+ variant={typographyVariant}
102
+ color={TypographyColor.TEXT_PRIMARY}
103
+ as="span"
104
+ >
105
+ {headlineText}
106
+ </Typography>
107
+ )}{' '}
108
+ <Typography
109
+ variant={typographyVariant}
110
+ color={TypographyColor.TEXT_ACCENT}
111
+ as="span"
112
+ >
113
+ {biggestAnimatedText}
114
+ </Typography>
115
+ </p>
116
+ </div>
117
+ <div style={{ minHeight }}>
118
+ <p
119
+ data-testid="typing-animation-headline-text"
120
+ className="envive-tw-max-w-[90ch]"
121
+ style={{ textAlign: 'left' }}
84
122
  >
85
- {headlineText}
86
- </Typography>
87
- )}{' '}
88
- {animatedTextSequence && animatedTextSequence.length > 0 ? (
89
- <AnimatedText
90
- sequence={animatedTextSequence}
91
- loop
92
- getNodeWrapper={getAnimatedTextWrapper}
93
- />
94
- ) : null}
95
- </p>
123
+ {headlineText && (
124
+ <Typography
125
+ variant={typographyVariant}
126
+ color={TypographyColor.TEXT_PRIMARY}
127
+ as="span"
128
+ >
129
+ {headlineText}
130
+ </Typography>
131
+ )}{' '}
132
+ {animatedTextSequence && animatedTextSequence.length > 0 ? (
133
+ <AnimatedText
134
+ sequence={animatedTextSequence}
135
+ loop
136
+ getNodeWrapper={getAnimatedTextWrapper}
137
+ />
138
+ ) : null}
139
+ </p>
140
+ </div>
141
+ </div>
96
142
  )}
97
143
  {promptButtonTexts && promptButtonTexts.length > 0 && handleButtonClick && (
98
144
  <PromptCarousel
@@ -0,0 +1,29 @@
1
+ import { useEffect, useRef, useState } from 'react';
2
+
3
+ export const useAnimatedTextMinHeight = (animatedText: string[]) => {
4
+ const measuringRef = useRef<HTMLDivElement>(null);
5
+ const [minHeight, setMinHeight] = useState(0);
6
+
7
+ useEffect(() => {
8
+ const updateMinHeight = () => {
9
+ if (!measuringRef.current) return;
10
+ let maxHeight = 0;
11
+ const { children } = measuringRef.current;
12
+ for (let i = 0; i < children.length; i += 1) {
13
+ maxHeight = Math.max(maxHeight, (children[i] as HTMLElement).offsetHeight);
14
+ }
15
+ setMinHeight(maxHeight);
16
+ };
17
+
18
+ updateMinHeight();
19
+
20
+ const observer = new ResizeObserver(updateMinHeight);
21
+ if (measuringRef.current) {
22
+ observer.observe(measuringRef.current);
23
+ }
24
+
25
+ return () => observer.disconnect();
26
+ }, [animatedText]);
27
+
28
+ return { measuringRef, minHeight };
29
+ };
@@ -1,15 +0,0 @@
1
- const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
2
- const require_index = require('../../Typography/types/index.cjs');
3
- const require_Typography = require('../../Typography/Typography.cjs');
4
- let react_jsx_runtime = require("react/jsx-runtime");
5
-
6
- //#region src/components/MarkdownProcessor/components/MarkdownSubscript.tsx
7
- const MarkdownSubscript = ({ children, subTextVariant, subTextColor }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Typography.Typography, {
8
- variant: subTextVariant ?? require_index.TypographyVariant.B5_RG,
9
- color: subTextColor ?? require_index.TypographyColor.TEXT_SECONDARY,
10
- className: "envive-tw-inline",
11
- children
12
- });
13
-
14
- //#endregion
15
- exports.MarkdownSubscript = MarkdownSubscript;
@@ -1,14 +0,0 @@
1
- import { TypographyColor, TypographyVariant } from "../../Typography/types/index.js";
2
- import { Typography } from "../../Typography/Typography.js";
3
- import { jsx } from "react/jsx-runtime";
4
-
5
- //#region src/components/MarkdownProcessor/components/MarkdownSubscript.tsx
6
- const MarkdownSubscript = ({ children, subTextVariant, subTextColor }) => /* @__PURE__ */ jsx(Typography, {
7
- variant: subTextVariant ?? TypographyVariant.B5_RG,
8
- color: subTextColor ?? TypographyColor.TEXT_SECONDARY,
9
- className: "envive-tw-inline",
10
- children
11
- });
12
-
13
- //#endregion
14
- export { MarkdownSubscript };
@@ -1,22 +0,0 @@
1
- import { TypographyColor, TypographyVariant } from '../../Typography/types';
2
- import { Typography } from '../../Typography/Typography';
3
-
4
- export type MarkdownSubscriptProps = {
5
- subTextVariant?: TypographyVariant;
6
- subTextColor?: TypographyColor;
7
- children?: React.ReactNode;
8
- };
9
-
10
- export const MarkdownSubscript = ({
11
- children,
12
- subTextVariant,
13
- subTextColor,
14
- }: MarkdownSubscriptProps) => (
15
- <Typography
16
- variant={subTextVariant ?? TypographyVariant.B5_RG}
17
- color={subTextColor ?? TypographyColor.TEXT_SECONDARY}
18
- className="envive-tw-inline"
19
- >
20
- {children}
21
- </Typography>
22
- );