@envive-ai/react-toolkit-v3 0.3.21 → 0.3.23
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/AnimatedText/AnimatedText.d.cts +3 -3
- package/dist/AnimatedText/AnimatedText.d.ts +3 -3
- package/dist/CSSVariablesEditor/CssVariablesEditorComponent.d.cts +2 -2
- package/dist/CSSVariablesEditor/CssVariablesEditorComponent.d.ts +2 -2
- package/dist/Carousel/Carousel.cjs +1 -1
- package/dist/Carousel/Carousel.d.cts +2 -2
- package/dist/Carousel/Carousel.d.ts +2 -2
- package/dist/Carousel/Carousel.js +1 -1
- package/dist/Carousel/components/Container.cjs +2 -2
- package/dist/Carousel/components/Container.js +2 -2
- package/dist/ChatFooter/ChatFooter.cjs +7 -3
- package/dist/ChatFooter/ChatFooter.d.cts +7 -3
- package/dist/ChatFooter/ChatFooter.d.ts +5 -1
- package/dist/ChatFooter/ChatFooter.js +7 -3
- package/dist/ChatFooter/components/Layout.cjs +2 -2
- package/dist/ChatFooter/components/Layout.js +2 -2
- package/dist/ChatFooter/components/index.d.cts +10 -6
- package/dist/ChatFooter/components/index.d.ts +7 -3
- package/dist/ChatFooter/types/types.d.cts +16 -0
- package/dist/ChatFooter/types/types.d.ts +16 -0
- package/dist/ChatHeader/ChatHeader.cjs +2 -1
- package/dist/ChatHeader/ChatHeader.d.cts +2 -2
- package/dist/ChatHeader/ChatHeader.d.ts +2 -2
- package/dist/ChatHeader/ChatHeader.js +2 -1
- package/dist/ChatHeader/components/Handle.cjs +4 -4
- package/dist/ChatHeader/components/Handle.js +4 -4
- package/dist/ChatHeader/components/Toggle.cjs +3 -3
- package/dist/ChatHeader/components/Toggle.js +3 -3
- package/dist/ChatHeader/hooks/useGetHandleProperties.cjs +8 -6
- package/dist/ChatHeader/hooks/useGetHandleProperties.js +8 -6
- package/dist/ChatHeader/hooks/useGetToggleOptionProperties.cjs +1 -1
- package/dist/ChatHeader/hooks/useGetToggleOptionProperties.js +1 -1
- package/dist/ChatPreview/ChatPreview.cjs +7 -4
- package/dist/ChatPreview/ChatPreview.d.cts +2 -2
- package/dist/ChatPreview/ChatPreview.js +7 -4
- package/dist/ChatPreview/index.d.cts +2 -2
- package/dist/ChatPreview/index.d.ts +2 -2
- package/dist/ChatPreview/types/types.d.cts +13 -1
- package/dist/ChatPreview/types/types.d.ts +13 -1
- package/dist/ChatPreviewComparison/ChatPreviewComparison.cjs +7 -4
- package/dist/ChatPreviewComparison/ChatPreviewComparison.d.cts +2 -2
- package/dist/ChatPreviewComparison/ChatPreviewComparison.d.ts +2 -2
- package/dist/ChatPreviewComparison/ChatPreviewComparison.js +7 -4
- package/dist/ChatPreviewComparison/components/Headline.cjs +2 -2
- package/dist/ChatPreviewComparison/components/Headline.js +2 -2
- package/dist/ChatPreviewComparison/components/Layout.cjs +4 -4
- package/dist/ChatPreviewComparison/components/Layout.js +4 -4
- package/dist/ChatPreviewComparison/components/Message.cjs +2 -2
- package/dist/ChatPreviewComparison/components/Message.js +2 -2
- package/dist/ChatPreviewComparison/index.d.cts +2 -2
- package/dist/ChatPreviewComparison/index.d.ts +2 -2
- package/dist/ChatPreviewComparison/types/types.d.cts +13 -1
- package/dist/ChatPreviewComparison/types/types.d.ts +13 -1
- package/dist/ChatPreviewLoading/ChatPreviewLoading.cjs +7 -2
- package/dist/ChatPreviewLoading/ChatPreviewLoading.d.cts +4 -3
- package/dist/ChatPreviewLoading/ChatPreviewLoading.d.ts +4 -3
- package/dist/ChatPreviewLoading/ChatPreviewLoading.js +7 -2
- package/dist/ChatPreviewLoading/types/types.d.cts +4 -0
- package/dist/ChatPreviewLoading/types/types.d.ts +4 -0
- package/dist/Container/Container.d.cts +172 -172
- package/dist/Container/Container.d.ts +172 -172
- package/dist/DesignTokens/DesignTokensComponent.d.cts +2 -2
- package/dist/DesignTokens/DesignTokensComponent.d.ts +2 -2
- package/dist/Disclaimer/components/Container.cjs +2 -2
- package/dist/Disclaimer/components/Container.js +2 -2
- package/dist/DocumentRetrievalCard/DocumentRetrievalCard.d.cts +2 -2
- package/dist/DocumentRetrievalCard/DocumentRetrievalCard.d.ts +2 -2
- package/dist/DocumentRetrievalCard/components/Layout.cjs +2 -2
- package/dist/DocumentRetrievalCard/components/Layout.js +2 -2
- package/dist/DocumentRetrievalCard/components/ViewArticleButton/components/Icon.cjs +1 -1
- package/dist/DocumentRetrievalCard/components/ViewArticleButton/components/Icon.js +1 -1
- package/dist/FloatingButton/FloatingButton.d.cts +2 -2
- package/dist/FloatingButton/FloatingButton.d.ts +2 -2
- package/dist/FloatingChat/FloatingChat.cjs +27 -4
- package/dist/FloatingChat/FloatingChat.d.cts +2 -2
- package/dist/FloatingChat/FloatingChat.d.ts +2 -2
- package/dist/FloatingChat/FloatingChat.js +28 -5
- package/dist/FloatingChat/components/AgentMessage.cjs +2 -2
- package/dist/FloatingChat/components/AgentMessage.js +2 -2
- package/dist/FloatingChat/components/ChatMessages.cjs +1 -1
- package/dist/FloatingChat/components/ChatMessages.js +1 -1
- package/dist/FloatingChat/components/Layout.cjs +3 -3
- package/dist/FloatingChat/components/Layout.js +3 -3
- package/dist/FloatingChat/components/ResultsGridView.cjs +1 -1
- package/dist/FloatingChat/components/ResultsGridView.js +1 -1
- package/dist/FloatingChat/components/SalesAgentBadgeContent.cjs +1 -1
- package/dist/FloatingChat/components/SalesAgentBadgeContent.js +1 -1
- package/dist/FloatingChat/hooks/useChatSuggestions.cjs +3 -5
- package/dist/FloatingChat/hooks/useChatSuggestions.js +4 -6
- package/dist/FullPageSalesAgent/FullPageSalesAgent.cjs +25 -3
- package/dist/FullPageSalesAgent/FullPageSalesAgent.d.cts +5 -3
- package/dist/FullPageSalesAgent/FullPageSalesAgent.d.ts +5 -3
- package/dist/FullPageSalesAgent/FullPageSalesAgent.js +26 -4
- package/dist/Image/Image.d.cts +2 -2
- package/dist/Image/Image.d.ts +2 -2
- package/dist/ImageGallery/ImageGallery.d.cts +2 -2
- package/dist/ImageGallery/ImageGallery.d.ts +2 -2
- package/dist/ImageGallery/components/Layout.cjs +1 -1
- package/dist/ImageGallery/components/Layout.js +1 -1
- package/dist/MarkdownProcessor/MarkdownProcessor.d.cts +2 -2
- package/dist/MarkdownProcessor/MarkdownProcessor.d.ts +2 -2
- package/dist/Message/components/LinkButton.cjs +1 -1
- package/dist/Message/components/LinkButton.js +1 -1
- package/dist/OrderLookupCard/OrderLookupCard.cjs +1 -1
- package/dist/OrderLookupCard/OrderLookupCard.js +1 -1
- package/dist/ProductCard/ProductCard.cjs +7 -3
- package/dist/ProductCard/ProductCard.d.cts +6 -3
- package/dist/ProductCard/ProductCard.d.ts +6 -3
- package/dist/ProductCard/ProductCard.js +7 -3
- package/dist/ProductCard/index.d.cts +2 -2
- package/dist/ProductCard/index.d.ts +2 -2
- package/dist/ProductCard/types/index.d.cts +7 -1
- package/dist/ProductCard/types/index.d.ts +7 -1
- package/dist/PromptButton/PromptButton.d.cts +2 -2
- package/dist/PromptButton/PromptButton.d.ts +2 -2
- package/dist/PromptButtonCarouselWithImage/PromptButtonCarouselWithImage.cjs +5 -2
- package/dist/PromptButtonCarouselWithImage/PromptButtonCarouselWithImage.d.cts +6 -3
- package/dist/PromptButtonCarouselWithImage/PromptButtonCarouselWithImage.d.ts +6 -3
- package/dist/PromptButtonCarouselWithImage/PromptButtonCarouselWithImage.js +5 -2
- package/dist/PromptButtonCarouselWithImage/components/PromptButtonsCarousel.cjs +1 -1
- package/dist/PromptButtonCarouselWithImage/components/PromptButtonsCarousel.js +1 -1
- package/dist/PromptButtonCarouselWithImage/types/types.d.cts +12 -0
- package/dist/PromptButtonCarouselWithImage/types/types.d.ts +12 -0
- package/dist/PromptCarousel/PromptCarousel.cjs +3 -3
- package/dist/PromptCarousel/PromptCarousel.d.cts +2 -2
- package/dist/PromptCarousel/PromptCarousel.d.ts +2 -2
- package/dist/PromptCarousel/PromptCarousel.js +3 -3
- package/dist/ReviewCard/ReviewCard.d.cts +2 -2
- package/dist/ReviewCard/ReviewCard.d.ts +2 -2
- package/dist/ReviewCard/components/Container.cjs +2 -2
- package/dist/ReviewCard/components/Container.js +2 -2
- package/dist/ReviewCard/components/Rating.cjs +0 -1
- package/dist/ReviewCard/components/Rating.js +0 -1
- package/dist/ReviewCard/components/ReadMoreButton.cjs +1 -1
- package/dist/ReviewCard/components/ReadMoreButton.js +1 -1
- package/dist/ReviewCard/components/index.d.cts +4 -4
- package/dist/ReviewCard/components/index.d.ts +6 -6
- package/dist/SalesAgentProductCard/SalesAgentProductCard.d.cts +2 -2
- package/dist/SalesAgentProductCard/SalesAgentProductCard.d.ts +2 -2
- package/dist/SalesAgentProductCard/components/Container.cjs +2 -2
- package/dist/SalesAgentProductCard/components/Container.js +2 -2
- package/dist/SalesAgentProductCard/components/index.d.cts +6 -6
- package/dist/SalesAgentProductCard/components/index.d.ts +8 -8
- package/dist/SocialProof/SocialProof.cjs +7 -4
- package/dist/SocialProof/SocialProof.d.cts +2 -2
- package/dist/SocialProof/SocialProof.js +7 -4
- package/dist/SocialProof/components/Headline.cjs +3 -3
- package/dist/SocialProof/components/Headline.js +3 -3
- package/dist/SocialProof/components/LayoutFourHorizontal.cjs +1 -1
- package/dist/SocialProof/components/LayoutFourHorizontal.js +1 -1
- package/dist/SocialProof/components/Subheadline.cjs +1 -1
- package/dist/SocialProof/components/Subheadline.js +1 -1
- package/dist/SocialProof/components/Textfield.cjs +5 -2
- package/dist/SocialProof/components/Textfield.js +5 -2
- package/dist/SocialProof/index.d.cts +2 -2
- package/dist/SocialProof/index.d.ts +2 -2
- package/dist/SocialProof/types/types.d.cts +13 -1
- package/dist/SocialProof/types/types.d.ts +13 -1
- package/dist/SparkleAnimation/SparkleAnimation.d.cts +2 -2
- package/dist/SparkleAnimation/SparkleAnimation.d.ts +2 -2
- package/dist/Stack/Stack.d.cts +2 -2
- package/dist/Stack/Stack.d.ts +2 -2
- package/dist/TextField/TextField.cjs +34 -2
- package/dist/TextField/TextField.d.cts +5 -1
- package/dist/TextField/TextField.d.ts +5 -1
- package/dist/TextField/TextField.js +34 -2
- package/dist/TextField/components/Layout.cjs +10 -7
- package/dist/TextField/components/Layout.js +10 -7
- package/dist/TextField/components/VoiceInputButton.cjs +45 -0
- package/dist/TextField/components/VoiceInputButton.js +39 -0
- package/dist/TextField/components/index.cjs +3 -1
- package/dist/TextField/components/index.js +3 -1
- package/dist/TextField/hooks/useGetMicButtonContainerProperties.cjs +20 -0
- package/dist/TextField/hooks/useGetMicButtonContainerProperties.js +19 -0
- package/dist/TextField/hooks/useGetSkeletonProperties.cjs +1 -1
- package/dist/TextField/hooks/useGetSkeletonProperties.js +1 -1
- package/dist/TextField/hooks/useVoiceInput.cjs +59 -0
- package/dist/TextField/hooks/useVoiceInput.js +57 -0
- package/dist/TextField/types/index.d.cts +11 -0
- package/dist/TextField/types/index.d.ts +11 -0
- package/dist/TextField/utils/getLayoutStateProperties.cjs +9 -1
- package/dist/TextField/utils/getLayoutStateProperties.js +8 -1
- package/dist/TitledPromptCarousel/TitledPromptCarousel.cjs +1 -1
- package/dist/TitledPromptCarousel/TitledPromptCarousel.d.cts +2 -2
- package/dist/TitledPromptCarousel/TitledPromptCarousel.d.ts +2 -2
- package/dist/TitledPromptCarousel/TitledPromptCarousel.js +1 -1
- package/dist/Tokens/index.cjs +1 -1
- package/dist/Tokens/index.js +1 -1
- package/dist/TypingAnimation/TypingAnimation.cjs +8 -4
- package/dist/TypingAnimation/TypingAnimation.d.cts +2 -2
- package/dist/TypingAnimation/TypingAnimation.js +8 -4
- package/dist/TypingAnimation/hooks/useGetTypographyVariant.cjs +1 -1
- package/dist/TypingAnimation/hooks/useGetTypographyVariant.js +1 -1
- package/dist/TypingAnimation/index.d.cts +2 -2
- package/dist/TypingAnimation/index.d.ts +2 -2
- package/dist/TypingAnimation/types/index.d.cts +13 -1
- package/dist/TypingAnimation/types/index.d.ts +13 -1
- package/dist/Typography/Typography.d.cts +4 -4
- package/dist/Typography/Typography.d.ts +4 -4
- package/dist/WelcomeMessage/components/Container.cjs +2 -2
- package/dist/WelcomeMessage/components/Container.js +2 -2
- package/dist/WidgetTextField/WidgetTextField.cjs +40 -8
- package/dist/WidgetTextField/WidgetTextField.d.cts +7 -3
- package/dist/WidgetTextField/WidgetTextField.d.ts +7 -3
- package/dist/WidgetTextField/WidgetTextField.js +34 -3
- package/dist/WidgetTextField/components/Container.cjs +33 -27
- package/dist/WidgetTextField/components/Container.js +33 -27
- package/dist/WidgetTextField/components/Icon.cjs +1 -1
- package/dist/WidgetTextField/components/Icon.js +1 -1
- package/dist/WidgetTextField/hooks/useGetContainerProperties.cjs +5 -3
- package/dist/WidgetTextField/hooks/useGetContainerProperties.js +5 -3
- package/dist/WidgetTextField/hooks/useGetMicWidgetButtonProperties.cjs +20 -0
- package/dist/WidgetTextField/hooks/useGetMicWidgetButtonProperties.js +19 -0
- package/dist/WidgetTextField/types/types.d.cts +21 -0
- package/dist/WidgetTextField/types/types.d.ts +21 -0
- package/dist/WidgetWrapper/WidgetWrapper.d.cts +2 -2
- package/dist/WidgetWrapper/WidgetWrapper.d.ts +2 -2
- package/dist/WidgetWrapper/hooks/useGetWrapperProperties.cjs +1 -1
- package/dist/WidgetWrapper/hooks/useGetWrapperProperties.js +1 -1
- package/dist/WidgetWrapperWithTitle/WidgetWrapperWithTitle.d.cts +2 -2
- package/dist/node_modules/jotai/esm/react.cjs +87 -0
- package/dist/node_modules/jotai/esm/react.js +88 -2
- package/dist/node_modules/jotai/esm/vanilla/internals.cjs +2 -1
- package/dist/node_modules/jotai/esm/vanilla/internals.js +1 -1
- package/dist/styles.css +1 -1
- package/package.json +2 -1
- package/src/components/ChatFooter/ChatFooter.tsx +8 -0
- package/src/components/ChatFooter/__tests__/ChatFooter.test.tsx +43 -0
- package/src/components/ChatFooter/components/TextField.tsx +12 -0
- package/src/components/ChatFooter/types/types.ts +17 -0
- package/src/components/ChatHeader/ChatHeader.tsx +1 -0
- package/src/components/ChatHeader/components/Handle.tsx +7 -2
- package/src/components/ChatHeader/hooks/useGetHandleProperties.ts +9 -5
- package/src/components/ChatHeader/hooks/useGetToggleOptionProperties.ts +1 -1
- package/src/components/ChatHeader/types/index.ts +1 -0
- package/src/components/ChatPreview/ChatPreview.tsx +13 -2
- package/src/components/ChatPreview/__tests__/ChatPreview.test.tsx +44 -0
- package/src/components/ChatPreview/index.ts +1 -1
- package/src/components/ChatPreview/types/types.ts +13 -0
- package/src/components/ChatPreviewComparison/ChatPreviewComparison.tsx +6 -0
- package/src/components/ChatPreviewComparison/__tests__/ChatPreviewComparison.test.tsx +44 -0
- package/src/components/ChatPreviewComparison/index.ts +1 -1
- package/src/components/ChatPreviewComparison/types/types.ts +13 -0
- package/src/components/ChatPreviewLoading/ChatPreviewLoading.tsx +5 -3
- package/src/components/ChatPreviewLoading/__tests__/ChatPreviewLoading.test.tsx +40 -0
- package/src/components/ChatPreviewLoading/types/types.ts +5 -0
- package/src/components/FloatingChat/FloatingChat.tsx +38 -7
- package/src/components/FloatingChat/hooks/useChatSuggestions.ts +8 -12
- package/src/components/FullPageSalesAgent/FullPageSalesAgent.tsx +32 -1
- package/src/components/ProductCard/ProductCard.tsx +7 -0
- package/src/components/ProductCard/__tests__/ProductCard.test.tsx +33 -0
- package/src/components/ProductCard/index.ts +1 -1
- package/src/components/ProductCard/types/index.ts +6 -0
- package/src/components/PromptButtonCarouselWithImage/PromptButtonCarouselWithImage.tsx +6 -0
- package/src/components/PromptButtonCarouselWithImage/__tests__/PromptButtonCarouselWithImage.test.tsx +34 -0
- package/src/components/PromptButtonCarouselWithImage/types/types.ts +12 -0
- package/src/components/ReviewCard/components/Rating.tsx +0 -1
- package/src/components/SocialProof/SocialProof.tsx +6 -0
- package/src/components/SocialProof/__tests__/SocialProof.test.tsx +58 -0
- package/src/components/SocialProof/components/Textfield.tsx +9 -0
- package/src/components/SocialProof/index.ts +1 -1
- package/src/components/SocialProof/types/types.ts +13 -0
- package/src/components/TextField/TextField.tsx +49 -0
- package/src/components/TextField/__tests__/TextField.test.tsx +3 -3
- package/src/components/TextField/__tests__/VoiceInputButton.test.tsx +175 -0
- package/src/components/TextField/components/Layout.tsx +24 -17
- package/src/components/TextField/components/VoiceInputButton.tsx +69 -0
- package/src/components/TextField/components/index.ts +2 -0
- package/src/components/TextField/hooks/useGetMicButtonContainerProperties.ts +38 -0
- package/src/components/TextField/hooks/useGetSkeletonProperties.ts +1 -1
- package/src/components/TextField/hooks/useVoiceInput.ts +77 -0
- package/src/components/TextField/types/index.ts +11 -0
- package/src/components/TextField/utils/getLayoutStateProperties.ts +8 -0
- package/src/components/TypingAnimation/TypingAnimation.tsx +7 -0
- package/src/components/TypingAnimation/__tests__/TypingAnimation.test.tsx +47 -0
- package/src/components/TypingAnimation/index.ts +1 -1
- package/src/components/TypingAnimation/types/index.ts +14 -1
- package/src/components/WidgetTextField/WidgetTextField.tsx +47 -0
- package/src/components/WidgetTextField/__tests__/WidgetTextField.test.tsx +119 -4
- package/src/components/WidgetTextField/components/Container.tsx +40 -27
- package/src/components/WidgetTextField/hooks/useGetContainerProperties.ts +16 -4
- package/src/components/WidgetTextField/hooks/useGetMicWidgetButtonProperties.ts +38 -0
- package/src/components/WidgetTextField/types/types.ts +21 -0
- package/src/components/WidgetWrapper/hooks/useGetWrapperProperties.ts +1 -1
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { Theme } from "../packages/components-v3/tokens/theme/theme.js";
|
|
2
2
|
import { resolveTheme } from "../utils/resolveTheme.js";
|
|
3
3
|
import { TextFieldComponents } from "./components/index.js";
|
|
4
|
+
import { useGetMicButtonContainerProperties } from "./hooks/useGetMicButtonContainerProperties.js";
|
|
4
5
|
import { useGetSkeletonProperties } from "./hooks/useGetSkeletonProperties.js";
|
|
5
6
|
import { useTextFieldFocus } from "./hooks/useTextFieldFocus.js";
|
|
6
7
|
import { useTextFieldSubmit } from "./hooks/useTextFieldSubmit.js";
|
|
7
8
|
import { useTextFieldValue } from "./hooks/useTextFieldValue.js";
|
|
9
|
+
import { useVoiceInput } from "./hooks/useVoiceInput.js";
|
|
10
|
+
import { useCallback } from "react";
|
|
8
11
|
import { jsx } from "react/jsx-runtime";
|
|
9
12
|
import classNames from "classnames";
|
|
10
13
|
|
|
@@ -13,13 +16,27 @@ import classNames from "classnames";
|
|
|
13
16
|
* Renders a text input field with a send icon.
|
|
14
17
|
* Supports three visual themes: Standard, Modern, and Minimal.
|
|
15
18
|
*/
|
|
16
|
-
const TextField = ({ theme = Theme.GLOBAL_CUSTOM, placeholder, value: controlledValue, onChange, onSubmit, onFocus, disabled = false, id, testId, className, style, ariaLabel, isLoading = false }) => {
|
|
19
|
+
const TextField = ({ theme = Theme.GLOBAL_CUSTOM, placeholder, value: controlledValue, onChange, onSubmit, onFocus, disabled = false, id, testId, className, inputClassName, style, ariaLabel, isLoading = false, enableVoiceInput = false, onTranscriptionStarted, onTranscriptionCompleted }) => {
|
|
17
20
|
const { currentValue, hasValue, handleChange, resetValue } = useTextFieldValue(controlledValue, onChange);
|
|
18
21
|
const { isFocused, handleFocus, handleBlur } = useTextFieldFocus();
|
|
19
22
|
const { handleSubmit, handleKeyDown } = useTextFieldSubmit(onSubmit, hasValue, disabled, isLoading, currentValue, resetValue);
|
|
23
|
+
const { isListening, handleToggleListening, handleAbortListening, browserSupportsSpeechRecognition } = useVoiceInput({
|
|
24
|
+
onTranscriptionStarted,
|
|
25
|
+
onTranscriptionCompleted: useCallback((transcript) => {
|
|
26
|
+
resetValue();
|
|
27
|
+
handleChange(transcript);
|
|
28
|
+
onTranscriptionCompleted?.(transcript);
|
|
29
|
+
}, [
|
|
30
|
+
handleChange,
|
|
31
|
+
resetValue,
|
|
32
|
+
onTranscriptionCompleted
|
|
33
|
+
]),
|
|
34
|
+
disabled
|
|
35
|
+
});
|
|
20
36
|
const handleInternalFocus = () => {
|
|
21
37
|
handleFocus();
|
|
22
38
|
onFocus?.();
|
|
39
|
+
handleAbortListening();
|
|
23
40
|
};
|
|
24
41
|
const { skeletonClass } = useGetSkeletonProperties(isLoading);
|
|
25
42
|
const resolvedTheme = resolveTheme(theme);
|
|
@@ -32,7 +49,8 @@ const TextField = ({ theme = Theme.GLOBAL_CUSTOM, placeholder, value: controlled
|
|
|
32
49
|
onFocus: handleInternalFocus,
|
|
33
50
|
onBlur: handleBlur,
|
|
34
51
|
disabled: disabled || isLoading,
|
|
35
|
-
ariaLabel
|
|
52
|
+
ariaLabel,
|
|
53
|
+
className: inputClassName
|
|
36
54
|
});
|
|
37
55
|
const sendIcon = !isLoading ? /* @__PURE__ */ jsx(TextFieldComponents.SendIcon, {
|
|
38
56
|
theme: resolvedTheme,
|
|
@@ -41,10 +59,24 @@ const TextField = ({ theme = Theme.GLOBAL_CUSTOM, placeholder, value: controlled
|
|
|
41
59
|
onClick: handleSubmit,
|
|
42
60
|
ariaLabel
|
|
43
61
|
}) : null;
|
|
62
|
+
const { micButtonContainerClasses } = useGetMicButtonContainerProperties({
|
|
63
|
+
theme: resolvedTheme,
|
|
64
|
+
isListening
|
|
65
|
+
});
|
|
66
|
+
const voiceInputButtonClassName = classNames(micButtonContainerClasses, skeletonClass);
|
|
67
|
+
const voiceInputButton = enableVoiceInput && browserSupportsSpeechRecognition ? /* @__PURE__ */ jsx(TextFieldComponents.VoiceInputButton, {
|
|
68
|
+
theme: resolvedTheme,
|
|
69
|
+
isListening,
|
|
70
|
+
onToggleListening: handleToggleListening,
|
|
71
|
+
ariaLabel,
|
|
72
|
+
isLoading,
|
|
73
|
+
className: voiceInputButtonClassName
|
|
74
|
+
}) : null;
|
|
44
75
|
return /* @__PURE__ */ jsx(TextFieldComponents.Layout, {
|
|
45
76
|
theme: resolvedTheme,
|
|
46
77
|
input,
|
|
47
78
|
sendIcon,
|
|
79
|
+
voiceInputButton,
|
|
48
80
|
isFocused,
|
|
49
81
|
hasValue,
|
|
50
82
|
disabled,
|
|
@@ -6,15 +6,18 @@ let classnames = require("classnames");
|
|
|
6
6
|
classnames = require_rolldown_runtime.__toESM(classnames);
|
|
7
7
|
|
|
8
8
|
//#region src/components/TextField/components/Layout.tsx
|
|
9
|
-
const Layout = ({ theme, input, sendIcon, isFocused, hasValue, disabled = false, id, testId, className, style }) => {
|
|
9
|
+
const Layout = ({ theme, input, sendIcon, voiceInputButton, isFocused, hasValue, disabled = false, id, testId, className, style }) => {
|
|
10
10
|
const { containerLayoutClasses, containerDefaultClasses, containerBorderClasses, containerBorderActiveClasses, containerFocusClasses, containerHoverClasses, containerDisabledClasses } = require_useGetContainerProperties.useGetContainerProperties({ theme });
|
|
11
|
-
const { isActive, shouldShowFocus, shouldShowHover } = require_getLayoutStateProperties.getLayoutStateProperties(hasValue, isFocused, disabled);
|
|
11
|
+
const { isActive, shouldShowFocus, shouldShowHover, containerClasses } = require_getLayoutStateProperties.getLayoutStateProperties(theme, hasValue, isFocused, disabled);
|
|
12
12
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
13
|
-
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
className: containerClasses,
|
|
14
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
15
|
+
id,
|
|
16
|
+
"data-testid": testId,
|
|
17
|
+
className: (0, classnames.default)("envive-tw-flex-1", containerLayoutClasses, containerDefaultClasses, isActive ? containerBorderActiveClasses : containerBorderClasses, shouldShowFocus && containerFocusClasses, shouldShowHover && containerHoverClasses, disabled && containerDisabledClasses, className),
|
|
18
|
+
style,
|
|
19
|
+
children: [input, sendIcon]
|
|
20
|
+
}), voiceInputButton]
|
|
18
21
|
});
|
|
19
22
|
};
|
|
20
23
|
|
|
@@ -4,15 +4,18 @@ import { jsxs } from "react/jsx-runtime";
|
|
|
4
4
|
import classNames from "classnames";
|
|
5
5
|
|
|
6
6
|
//#region src/components/TextField/components/Layout.tsx
|
|
7
|
-
const Layout = ({ theme, input, sendIcon, isFocused, hasValue, disabled = false, id, testId, className, style }) => {
|
|
7
|
+
const Layout = ({ theme, input, sendIcon, voiceInputButton, isFocused, hasValue, disabled = false, id, testId, className, style }) => {
|
|
8
8
|
const { containerLayoutClasses, containerDefaultClasses, containerBorderClasses, containerBorderActiveClasses, containerFocusClasses, containerHoverClasses, containerDisabledClasses } = useGetContainerProperties({ theme });
|
|
9
|
-
const { isActive, shouldShowFocus, shouldShowHover } = getLayoutStateProperties(hasValue, isFocused, disabled);
|
|
9
|
+
const { isActive, shouldShowFocus, shouldShowHover, containerClasses } = getLayoutStateProperties(theme, hasValue, isFocused, disabled);
|
|
10
10
|
return /* @__PURE__ */ jsxs("div", {
|
|
11
|
-
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
className: containerClasses,
|
|
12
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
13
|
+
id,
|
|
14
|
+
"data-testid": testId,
|
|
15
|
+
className: classNames("envive-tw-flex-1", containerLayoutClasses, containerDefaultClasses, isActive ? containerBorderActiveClasses : containerBorderClasses, shouldShowFocus && containerFocusClasses, shouldShowHover && containerHoverClasses, disabled && containerDisabledClasses, className),
|
|
16
|
+
style,
|
|
17
|
+
children: [input, sendIcon]
|
|
18
|
+
}), voiceInputButton]
|
|
16
19
|
});
|
|
17
20
|
};
|
|
18
21
|
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_theme = require('../../packages/components-v3/tokens/theme/theme.cjs');
|
|
3
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
4
|
+
let __envive_ai_react_icons_Mic = require("@envive-ai/react-icons/Mic");
|
|
5
|
+
__envive_ai_react_icons_Mic = require_rolldown_runtime.__toESM(__envive_ai_react_icons_Mic);
|
|
6
|
+
let __envive_ai_react_icons_MicThin = require("@envive-ai/react-icons/MicThin");
|
|
7
|
+
__envive_ai_react_icons_MicThin = require_rolldown_runtime.__toESM(__envive_ai_react_icons_MicThin);
|
|
8
|
+
let __envive_ai_react_icons_Stop = require("@envive-ai/react-icons/Stop");
|
|
9
|
+
__envive_ai_react_icons_Stop = require_rolldown_runtime.__toESM(__envive_ai_react_icons_Stop);
|
|
10
|
+
let __envive_ai_react_icons_StopSharp = require("@envive-ai/react-icons/StopSharp");
|
|
11
|
+
__envive_ai_react_icons_StopSharp = require_rolldown_runtime.__toESM(__envive_ai_react_icons_StopSharp);
|
|
12
|
+
let __envive_ai_react_icons_StopThin = require("@envive-ai/react-icons/StopThin");
|
|
13
|
+
__envive_ai_react_icons_StopThin = require_rolldown_runtime.__toESM(__envive_ai_react_icons_StopThin);
|
|
14
|
+
|
|
15
|
+
//#region src/components/TextField/components/VoiceInputButton.tsx
|
|
16
|
+
const VoiceInputButton = ({ theme, isListening, onToggleListening, disabled = false, className, style, ariaLabel, isLoading = false }) => {
|
|
17
|
+
const getMicIcon = (iconTheme) => {
|
|
18
|
+
switch (iconTheme) {
|
|
19
|
+
case require_theme.Theme.MODERN: return __envive_ai_react_icons_MicThin.default;
|
|
20
|
+
default: return __envive_ai_react_icons_Mic.default;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const getStopIcon = (iconTheme) => {
|
|
24
|
+
switch (iconTheme) {
|
|
25
|
+
case require_theme.Theme.MODERN: return __envive_ai_react_icons_StopThin.default;
|
|
26
|
+
case require_theme.Theme.MINIMAL: return __envive_ai_react_icons_StopSharp.default;
|
|
27
|
+
default: return __envive_ai_react_icons_Stop.default;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const MicIcon = getMicIcon(theme);
|
|
31
|
+
const StopIcon = getStopIcon(theme);
|
|
32
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
33
|
+
type: "button",
|
|
34
|
+
onClick: onToggleListening,
|
|
35
|
+
disabled: disabled || isLoading,
|
|
36
|
+
className,
|
|
37
|
+
style,
|
|
38
|
+
"aria-label": ariaLabel,
|
|
39
|
+
tabIndex: disabled || isLoading ? -1 : 0,
|
|
40
|
+
children: isListening ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StopIcon, { className: "envive-tw-h-[24px]" }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MicIcon, { className: "envive-tw-h-[24px]" })
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
//#endregion
|
|
45
|
+
exports.VoiceInputButton = VoiceInputButton;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Theme } from "../../packages/components-v3/tokens/theme/theme.js";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import Mic from "@envive-ai/react-icons/Mic";
|
|
4
|
+
import MicThin from "@envive-ai/react-icons/MicThin";
|
|
5
|
+
import Stop from "@envive-ai/react-icons/Stop";
|
|
6
|
+
import StopSharp from "@envive-ai/react-icons/StopSharp";
|
|
7
|
+
import StopThin from "@envive-ai/react-icons/StopThin";
|
|
8
|
+
|
|
9
|
+
//#region src/components/TextField/components/VoiceInputButton.tsx
|
|
10
|
+
const VoiceInputButton = ({ theme, isListening, onToggleListening, disabled = false, className, style, ariaLabel, isLoading = false }) => {
|
|
11
|
+
const getMicIcon = (iconTheme) => {
|
|
12
|
+
switch (iconTheme) {
|
|
13
|
+
case Theme.MODERN: return MicThin;
|
|
14
|
+
default: return Mic;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
const getStopIcon = (iconTheme) => {
|
|
18
|
+
switch (iconTheme) {
|
|
19
|
+
case Theme.MODERN: return StopThin;
|
|
20
|
+
case Theme.MINIMAL: return StopSharp;
|
|
21
|
+
default: return Stop;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
const MicIcon = getMicIcon(theme);
|
|
25
|
+
const StopIcon = getStopIcon(theme);
|
|
26
|
+
return /* @__PURE__ */ jsx("button", {
|
|
27
|
+
type: "button",
|
|
28
|
+
onClick: onToggleListening,
|
|
29
|
+
disabled: disabled || isLoading,
|
|
30
|
+
className,
|
|
31
|
+
style,
|
|
32
|
+
"aria-label": ariaLabel,
|
|
33
|
+
tabIndex: disabled || isLoading ? -1 : 0,
|
|
34
|
+
children: isListening ? /* @__PURE__ */ jsx(StopIcon, { className: "envive-tw-h-[24px]" }) : /* @__PURE__ */ jsx(MicIcon, { className: "envive-tw-h-[24px]" })
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
//#endregion
|
|
39
|
+
export { VoiceInputButton };
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
const require_Layout = require('./Layout.cjs');
|
|
2
2
|
const require_Input = require('./Input.cjs');
|
|
3
3
|
const require_SendIcon = require('./SendIcon.cjs');
|
|
4
|
+
const require_VoiceInputButton = require('./VoiceInputButton.cjs');
|
|
4
5
|
|
|
5
6
|
//#region src/components/TextField/components/index.ts
|
|
6
7
|
const TextFieldComponents = {
|
|
7
8
|
Layout: require_Layout.Layout,
|
|
8
9
|
Input: require_Input.Input,
|
|
9
|
-
SendIcon: require_SendIcon.SendIcon
|
|
10
|
+
SendIcon: require_SendIcon.SendIcon,
|
|
11
|
+
VoiceInputButton: require_VoiceInputButton.VoiceInputButton
|
|
10
12
|
};
|
|
11
13
|
|
|
12
14
|
//#endregion
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { Layout } from "./Layout.js";
|
|
2
2
|
import { Input } from "./Input.js";
|
|
3
3
|
import { SendIcon } from "./SendIcon.js";
|
|
4
|
+
import { VoiceInputButton } from "./VoiceInputButton.js";
|
|
4
5
|
|
|
5
6
|
//#region src/components/TextField/components/index.ts
|
|
6
7
|
const TextFieldComponents = {
|
|
7
8
|
Layout,
|
|
8
9
|
Input,
|
|
9
|
-
SendIcon
|
|
10
|
+
SendIcon,
|
|
11
|
+
VoiceInputButton
|
|
10
12
|
};
|
|
11
13
|
|
|
12
14
|
//#endregion
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_theme = require('../../packages/components-v3/tokens/theme/theme.cjs');
|
|
3
|
+
let react = require("react");
|
|
4
|
+
|
|
5
|
+
//#region src/components/TextField/hooks/useGetMicButtonContainerProperties.ts
|
|
6
|
+
const useGetMicButtonContainerProperties = ({ theme, isListening = false }) => {
|
|
7
|
+
return { micButtonContainerClasses: (0, react.useMemo)(() => {
|
|
8
|
+
const micButtonContainerClassesMap = {
|
|
9
|
+
[require_theme.Theme.STANDARD]: "envive-tw-flex envive-tw-h-[40px] envive-tw-w-[40px] envive-tw-py-2 envive-tw-px-2 envive-tw-justify-center envive-tw-items-center envive-tw-flex-shrink-0 envive-tw-border envive-tw-border-solid envive-tw-rounded-global-custom envive-tw-border-border-light hover:envive-tw-border-border-dark",
|
|
10
|
+
[require_theme.Theme.MODERN]: "envive-tw-flex envive-tw-h-[40px] envive-tw-w-[40px] envive-tw-py-2 envive-tw-px-2 envive-tw-justify-center envive-tw-items-center envive-tw-flex-shrink-0 envive-tw-border envive-tw-border-solid envive-tw-rounded-[4px] envive-tw-border-border-light hover:envive-tw-border-border-dark",
|
|
11
|
+
[require_theme.Theme.MINIMAL]: "envive-tw-flex envive-tw-h-[40px] envive-tw-w-[40px] envive-tw-justify-center envive-tw-items-center envive-tw-flex-shrink-0 envive-tw-border-b envive-tw-border-solid envive-tw-border-b-border-medium hover:envive-tw-border-b-border-dark",
|
|
12
|
+
[require_theme.Theme.GLOBAL_CUSTOM]: "envive-tw-flex envive-tw-h-[40px] envive-tw-w-[40px] envive-tw-py-2 envive-tw-px-2 envive-tw-justify-center envive-tw-items-center envive-tw-flex-shrink-0 envive-tw-border envive-tw-border-solid envive-tw-rounded-global-custom envive-tw-border-border-light hover:envive-tw-border-border-dark"
|
|
13
|
+
};
|
|
14
|
+
const baseClasses = micButtonContainerClassesMap[theme] ?? micButtonContainerClassesMap[require_theme.Theme.STANDARD];
|
|
15
|
+
return isListening ? `${baseClasses} envive-tw-bg-[--envive-colors-text-accent]` : `${baseClasses} envive-tw-bg-background-light`;
|
|
16
|
+
}, [theme, isListening]) };
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
exports.useGetMicButtonContainerProperties = useGetMicButtonContainerProperties;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Theme } from "../../packages/components-v3/tokens/theme/theme.js";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/components/TextField/hooks/useGetMicButtonContainerProperties.ts
|
|
5
|
+
const useGetMicButtonContainerProperties = ({ theme, isListening = false }) => {
|
|
6
|
+
return { micButtonContainerClasses: useMemo(() => {
|
|
7
|
+
const micButtonContainerClassesMap = {
|
|
8
|
+
[Theme.STANDARD]: "envive-tw-flex envive-tw-h-[40px] envive-tw-w-[40px] envive-tw-py-2 envive-tw-px-2 envive-tw-justify-center envive-tw-items-center envive-tw-flex-shrink-0 envive-tw-border envive-tw-border-solid envive-tw-rounded-global-custom envive-tw-border-border-light hover:envive-tw-border-border-dark",
|
|
9
|
+
[Theme.MODERN]: "envive-tw-flex envive-tw-h-[40px] envive-tw-w-[40px] envive-tw-py-2 envive-tw-px-2 envive-tw-justify-center envive-tw-items-center envive-tw-flex-shrink-0 envive-tw-border envive-tw-border-solid envive-tw-rounded-[4px] envive-tw-border-border-light hover:envive-tw-border-border-dark",
|
|
10
|
+
[Theme.MINIMAL]: "envive-tw-flex envive-tw-h-[40px] envive-tw-w-[40px] envive-tw-justify-center envive-tw-items-center envive-tw-flex-shrink-0 envive-tw-border-b envive-tw-border-solid envive-tw-border-b-border-medium hover:envive-tw-border-b-border-dark",
|
|
11
|
+
[Theme.GLOBAL_CUSTOM]: "envive-tw-flex envive-tw-h-[40px] envive-tw-w-[40px] envive-tw-py-2 envive-tw-px-2 envive-tw-justify-center envive-tw-items-center envive-tw-flex-shrink-0 envive-tw-border envive-tw-border-solid envive-tw-rounded-global-custom envive-tw-border-border-light hover:envive-tw-border-border-dark"
|
|
12
|
+
};
|
|
13
|
+
const baseClasses = micButtonContainerClassesMap[theme] ?? micButtonContainerClassesMap[Theme.STANDARD];
|
|
14
|
+
return isListening ? `${baseClasses} envive-tw-bg-[--envive-colors-text-accent]` : `${baseClasses} envive-tw-bg-background-light`;
|
|
15
|
+
}, [theme, isListening]) };
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
export { useGetMicButtonContainerProperties };
|
|
@@ -5,7 +5,7 @@ let react = require("react");
|
|
|
5
5
|
const useGetSkeletonProperties = (isLoading) => {
|
|
6
6
|
return { skeletonClass: (0, react.useMemo)(() => {
|
|
7
7
|
if (!isLoading) return void 0;
|
|
8
|
-
return "envive-tw-animate-pulse";
|
|
8
|
+
return "envive-tw-animate-pulse envive-tw-h-[40px]";
|
|
9
9
|
}, [isLoading]) };
|
|
10
10
|
};
|
|
11
11
|
|
|
@@ -4,7 +4,7 @@ import { useMemo } from "react";
|
|
|
4
4
|
const useGetSkeletonProperties = (isLoading) => {
|
|
5
5
|
return { skeletonClass: useMemo(() => {
|
|
6
6
|
if (!isLoading) return void 0;
|
|
7
|
-
return "envive-tw-animate-pulse";
|
|
7
|
+
return "envive-tw-animate-pulse envive-tw-h-[40px]";
|
|
8
8
|
}, [isLoading]) };
|
|
9
9
|
};
|
|
10
10
|
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_react = require('../../node_modules/jotai/esm/react.cjs');
|
|
3
|
+
let react = require("react");
|
|
4
|
+
let __envive_ai_react_hooks_atoms_chat = require("@envive-ai/react-hooks/atoms/chat");
|
|
5
|
+
let react_speech_recognition = require("react-speech-recognition");
|
|
6
|
+
react_speech_recognition = require_rolldown_runtime.__toESM(react_speech_recognition);
|
|
7
|
+
|
|
8
|
+
//#region src/components/TextField/hooks/useVoiceInput.ts
|
|
9
|
+
const useVoiceInput = ({ onTranscriptionCompleted, onTranscriptionStarted, disabled = false }) => {
|
|
10
|
+
const [listeningToSpeech, setListeningToSpeech] = require_react.useAtom(__envive_ai_react_hooks_atoms_chat.listeningToSpeechAtom);
|
|
11
|
+
const { transcript, browserSupportsSpeechRecognition, resetTranscript, isMicrophoneAvailable } = (0, react_speech_recognition.useSpeechRecognition)();
|
|
12
|
+
const handleStartListening = async () => {
|
|
13
|
+
try {
|
|
14
|
+
resetTranscript();
|
|
15
|
+
await react_speech_recognition.default.startListening({
|
|
16
|
+
continuous: true,
|
|
17
|
+
language: "en-US"
|
|
18
|
+
});
|
|
19
|
+
onTranscriptionStarted?.();
|
|
20
|
+
} catch (error) {
|
|
21
|
+
console.log("Microphone permission denied or error:", error);
|
|
22
|
+
setListeningToSpeech(false);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
const handleStopListening = async () => {
|
|
26
|
+
await react_speech_recognition.default.stopListening();
|
|
27
|
+
onTranscriptionCompleted?.(transcript);
|
|
28
|
+
};
|
|
29
|
+
const handleAbortListening = async () => {
|
|
30
|
+
await react_speech_recognition.default.abortListening();
|
|
31
|
+
resetTranscript();
|
|
32
|
+
};
|
|
33
|
+
const handleToggleListening = () => {
|
|
34
|
+
if (disabled || !isMicrophoneAvailable || !browserSupportsSpeechRecognition) return;
|
|
35
|
+
if (!listeningToSpeech) {
|
|
36
|
+
handleStartListening();
|
|
37
|
+
setListeningToSpeech(true);
|
|
38
|
+
} else {
|
|
39
|
+
handleStopListening();
|
|
40
|
+
setListeningToSpeech(false);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
(0, react.useEffect)(() => {
|
|
44
|
+
if (listeningToSpeech) handleStartListening();
|
|
45
|
+
return () => {
|
|
46
|
+
resetTranscript();
|
|
47
|
+
setListeningToSpeech(false);
|
|
48
|
+
};
|
|
49
|
+
}, []);
|
|
50
|
+
return {
|
|
51
|
+
isListening: listeningToSpeech,
|
|
52
|
+
handleToggleListening,
|
|
53
|
+
handleAbortListening,
|
|
54
|
+
browserSupportsSpeechRecognition
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
//#endregion
|
|
59
|
+
exports.useVoiceInput = useVoiceInput;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { useAtom } from "../../node_modules/jotai/esm/react.js";
|
|
2
|
+
import { useEffect } from "react";
|
|
3
|
+
import { listeningToSpeechAtom } from "@envive-ai/react-hooks/atoms/chat";
|
|
4
|
+
import SpeechRecognition, { useSpeechRecognition } from "react-speech-recognition";
|
|
5
|
+
|
|
6
|
+
//#region src/components/TextField/hooks/useVoiceInput.ts
|
|
7
|
+
const useVoiceInput = ({ onTranscriptionCompleted, onTranscriptionStarted, disabled = false }) => {
|
|
8
|
+
const [listeningToSpeech, setListeningToSpeech] = useAtom(listeningToSpeechAtom);
|
|
9
|
+
const { transcript, browserSupportsSpeechRecognition, resetTranscript, isMicrophoneAvailable } = useSpeechRecognition();
|
|
10
|
+
const handleStartListening = async () => {
|
|
11
|
+
try {
|
|
12
|
+
resetTranscript();
|
|
13
|
+
await SpeechRecognition.startListening({
|
|
14
|
+
continuous: true,
|
|
15
|
+
language: "en-US"
|
|
16
|
+
});
|
|
17
|
+
onTranscriptionStarted?.();
|
|
18
|
+
} catch (error) {
|
|
19
|
+
console.log("Microphone permission denied or error:", error);
|
|
20
|
+
setListeningToSpeech(false);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const handleStopListening = async () => {
|
|
24
|
+
await SpeechRecognition.stopListening();
|
|
25
|
+
onTranscriptionCompleted?.(transcript);
|
|
26
|
+
};
|
|
27
|
+
const handleAbortListening = async () => {
|
|
28
|
+
await SpeechRecognition.abortListening();
|
|
29
|
+
resetTranscript();
|
|
30
|
+
};
|
|
31
|
+
const handleToggleListening = () => {
|
|
32
|
+
if (disabled || !isMicrophoneAvailable || !browserSupportsSpeechRecognition) return;
|
|
33
|
+
if (!listeningToSpeech) {
|
|
34
|
+
handleStartListening();
|
|
35
|
+
setListeningToSpeech(true);
|
|
36
|
+
} else {
|
|
37
|
+
handleStopListening();
|
|
38
|
+
setListeningToSpeech(false);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
if (listeningToSpeech) handleStartListening();
|
|
43
|
+
return () => {
|
|
44
|
+
resetTranscript();
|
|
45
|
+
setListeningToSpeech(false);
|
|
46
|
+
};
|
|
47
|
+
}, []);
|
|
48
|
+
return {
|
|
49
|
+
isListening: listeningToSpeech,
|
|
50
|
+
handleToggleListening,
|
|
51
|
+
handleAbortListening,
|
|
52
|
+
browserSupportsSpeechRecognition
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
//#endregion
|
|
57
|
+
export { useVoiceInput };
|
|
@@ -35,6 +35,10 @@ type TextFieldProps = {
|
|
|
35
35
|
* Additional class names appended to the computed classes.
|
|
36
36
|
*/
|
|
37
37
|
className?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Additional class names applied directly to the input element (e.g. placeholder styling).
|
|
40
|
+
*/
|
|
41
|
+
inputClassName?: string;
|
|
38
42
|
/**
|
|
39
43
|
* Inline styles forwarded to the rendered element.
|
|
40
44
|
*/
|
|
@@ -44,6 +48,13 @@ type TextFieldProps = {
|
|
|
44
48
|
* @default false
|
|
45
49
|
*/
|
|
46
50
|
isLoading?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Enable voice input button
|
|
53
|
+
* @default false
|
|
54
|
+
*/
|
|
55
|
+
enableVoiceInput?: boolean;
|
|
56
|
+
onTranscriptionStarted?: () => void;
|
|
57
|
+
onTranscriptionCompleted?: (transcript: string) => void;
|
|
47
58
|
};
|
|
48
59
|
//#endregion
|
|
49
60
|
export { TextFieldProps };
|
|
@@ -35,6 +35,10 @@ type TextFieldProps = {
|
|
|
35
35
|
* Additional class names appended to the computed classes.
|
|
36
36
|
*/
|
|
37
37
|
className?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Additional class names applied directly to the input element (e.g. placeholder styling).
|
|
40
|
+
*/
|
|
41
|
+
inputClassName?: string;
|
|
38
42
|
/**
|
|
39
43
|
* Inline styles forwarded to the rendered element.
|
|
40
44
|
*/
|
|
@@ -44,6 +48,13 @@ type TextFieldProps = {
|
|
|
44
48
|
* @default false
|
|
45
49
|
*/
|
|
46
50
|
isLoading?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Enable voice input button
|
|
53
|
+
* @default false
|
|
54
|
+
*/
|
|
55
|
+
enableVoiceInput?: boolean;
|
|
56
|
+
onTranscriptionStarted?: () => void;
|
|
57
|
+
onTranscriptionCompleted?: (transcript: string) => void;
|
|
47
58
|
};
|
|
48
59
|
//#endregion
|
|
49
60
|
export { TextFieldProps };
|
|
@@ -1,10 +1,18 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_theme = require('../../packages/components-v3/tokens/theme/theme.cjs');
|
|
3
|
+
let classnames = require("classnames");
|
|
4
|
+
classnames = require_rolldown_runtime.__toESM(classnames);
|
|
1
5
|
|
|
2
6
|
//#region src/components/TextField/utils/getLayoutStateProperties.ts
|
|
3
7
|
/**
|
|
4
8
|
* Calculates state properties based on the layout state.
|
|
5
9
|
*/
|
|
6
|
-
const getLayoutStateProperties = (hasValue, isFocused, disabled) => {
|
|
10
|
+
const getLayoutStateProperties = (theme, hasValue, isFocused, disabled) => {
|
|
7
11
|
return {
|
|
12
|
+
containerClasses: (0, classnames.default)({
|
|
13
|
+
"envive-tw-gap-4": theme !== require_theme.Theme.MINIMAL,
|
|
14
|
+
"envive-tw-flex": true
|
|
15
|
+
}),
|
|
8
16
|
isActive: (hasValue || isFocused) && !disabled,
|
|
9
17
|
shouldShowFocus: isFocused && !disabled,
|
|
10
18
|
shouldShowHover: !disabled
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
+
import { Theme } from "../../packages/components-v3/tokens/theme/theme.js";
|
|
2
|
+
import classNames from "classnames";
|
|
3
|
+
|
|
1
4
|
//#region src/components/TextField/utils/getLayoutStateProperties.ts
|
|
2
5
|
/**
|
|
3
6
|
* Calculates state properties based on the layout state.
|
|
4
7
|
*/
|
|
5
|
-
const getLayoutStateProperties = (hasValue, isFocused, disabled) => {
|
|
8
|
+
const getLayoutStateProperties = (theme, hasValue, isFocused, disabled) => {
|
|
6
9
|
return {
|
|
10
|
+
containerClasses: classNames({
|
|
11
|
+
"envive-tw-gap-4": theme !== Theme.MINIMAL,
|
|
12
|
+
"envive-tw-flex": true
|
|
13
|
+
}),
|
|
7
14
|
isActive: (hasValue || isFocused) && !disabled,
|
|
8
15
|
shouldShowFocus: isFocused && !disabled,
|
|
9
16
|
shouldShowHover: !disabled
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
2
|
const require_theme = require('../packages/components-v3/tokens/theme/theme.cjs');
|
|
3
|
-
require('../Tokens/index.cjs');
|
|
4
3
|
const require_Stack = require('../Stack/Stack.cjs');
|
|
5
4
|
require('../Stack/index.cjs');
|
|
6
5
|
const require_index = require('../Typography/types/index.cjs');
|
|
7
6
|
const require_Typography = require('../Typography/Typography.cjs');
|
|
8
7
|
require('../Typography/index.cjs');
|
|
8
|
+
require('../Tokens/index.cjs');
|
|
9
9
|
const require_PromptButton_types_index = require('../PromptButton/types/index.cjs');
|
|
10
10
|
require('../PromptButton/index.cjs');
|
|
11
11
|
const require_PromptCarousel_types_types = require('../PromptCarousel/types/types.cjs');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TitledPromptCarouselProps } from "./types/index.cjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime2 from "react/jsx-runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/components/TitledPromptCarousel/TitledPromptCarousel.d.ts
|
|
5
5
|
declare const TitledPromptCarousel: ({
|
|
@@ -21,6 +21,6 @@ declare const TitledPromptCarousel: ({
|
|
|
21
21
|
handleButtonTouchEnd,
|
|
22
22
|
promptButtonTexts,
|
|
23
23
|
promptCarouselAriaLabel
|
|
24
|
-
}: TitledPromptCarouselProps) =>
|
|
24
|
+
}: TitledPromptCarouselProps) => react_jsx_runtime2.JSX.Element;
|
|
25
25
|
//#endregion
|
|
26
26
|
export { TitledPromptCarousel };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TitledPromptCarouselProps } from "./types/index.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime5 from "react/jsx-runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/components/TitledPromptCarousel/TitledPromptCarousel.d.ts
|
|
5
5
|
declare const TitledPromptCarousel: ({
|
|
@@ -21,6 +21,6 @@ declare const TitledPromptCarousel: ({
|
|
|
21
21
|
handleButtonTouchEnd,
|
|
22
22
|
promptButtonTexts,
|
|
23
23
|
promptCarouselAriaLabel
|
|
24
|
-
}: TitledPromptCarouselProps) =>
|
|
24
|
+
}: TitledPromptCarouselProps) => react_jsx_runtime5.JSX.Element;
|
|
25
25
|
//#endregion
|
|
26
26
|
export { TitledPromptCarousel };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Theme } from "../packages/components-v3/tokens/theme/theme.js";
|
|
2
|
-
import "../Tokens/index.js";
|
|
3
2
|
import { Stack } from "../Stack/Stack.js";
|
|
4
3
|
import "../Stack/index.js";
|
|
5
4
|
import { TypographyVariant } from "../Typography/types/index.js";
|
|
6
5
|
import { Typography } from "../Typography/Typography.js";
|
|
7
6
|
import "../Typography/index.js";
|
|
7
|
+
import "../Tokens/index.js";
|
|
8
8
|
import { PromptButtonVariant } from "../PromptButton/types/index.js";
|
|
9
9
|
import "../PromptButton/index.js";
|
|
10
10
|
import { AnimationSpeed, PromptCarouselRows } from "../PromptCarousel/types/types.js";
|
package/dist/Tokens/index.cjs
CHANGED
|
@@ -7,8 +7,8 @@ const require_fontFamily = require('../packages/components-v3/tokens/typography/
|
|
|
7
7
|
const require_radius = require('../packages/components-v3/tokens/radius/radius.cjs');
|
|
8
8
|
const require_aspectRatio = require('../packages/components-v3/tokens/aspectRatio/aspectRatio.cjs');
|
|
9
9
|
const require_theme = require('../packages/components-v3/tokens/theme/theme.cjs');
|
|
10
|
-
const require_typography = require('../packages/components-v3/tokens/typography/typography.cjs');
|
|
11
10
|
const require_breakpoints = require('../packages/components-v3/tokens/breakpoints/breakpoints.cjs');
|
|
11
|
+
const require_typography = require('../packages/components-v3/tokens/typography/typography.cjs');
|
|
12
12
|
const require_spacing = require('../packages/components-v3/tokens/spacing/spacing.cjs');
|
|
13
13
|
const require_motion = require('../packages/components-v3/tokens/montion/motion.cjs');
|
|
14
14
|
|
package/dist/Tokens/index.js
CHANGED
|
@@ -7,8 +7,8 @@ import { FontFamily, fontFamilyVariables } from "../packages/components-v3/token
|
|
|
7
7
|
import { borderRadiusVariables } from "../packages/components-v3/tokens/radius/radius.js";
|
|
8
8
|
import { aspectRatioVariables } from "../packages/components-v3/tokens/aspectRatio/aspectRatio.js";
|
|
9
9
|
import { Theme } from "../packages/components-v3/tokens/theme/theme.js";
|
|
10
|
-
import { createTypographyComponents } from "../packages/components-v3/tokens/typography/typography.js";
|
|
11
10
|
import { screensBreakpointsVariables, tailwindScreens } from "../packages/components-v3/tokens/breakpoints/breakpoints.js";
|
|
11
|
+
import { createTypographyComponents } from "../packages/components-v3/tokens/typography/typography.js";
|
|
12
12
|
import { spacingVariables } from "../packages/components-v3/tokens/spacing/spacing.js";
|
|
13
13
|
import { animationsVariables, keyFramesVariables } from "../packages/components-v3/tokens/montion/motion.js";
|
|
14
14
|
|
|
@@ -2,12 +2,12 @@ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
|
2
2
|
const require_AnimatedText = require('../AnimatedText/AnimatedText.cjs');
|
|
3
3
|
require('../AnimatedText/index.cjs');
|
|
4
4
|
const require_theme = require('../packages/components-v3/tokens/theme/theme.cjs');
|
|
5
|
-
require('../Tokens/index.cjs');
|
|
6
5
|
const require_Stack = require('../Stack/Stack.cjs');
|
|
7
6
|
require('../Stack/index.cjs');
|
|
8
7
|
const require_index = require('../Typography/types/index.cjs');
|
|
9
8
|
const require_Typography = require('../Typography/Typography.cjs');
|
|
10
9
|
require('../Typography/index.cjs');
|
|
10
|
+
require('../Tokens/index.cjs');
|
|
11
11
|
const require_PromptButton_types_index = require('../PromptButton/types/index.cjs');
|
|
12
12
|
const require_PromptCarousel_types_types = require('../PromptCarousel/types/types.cjs');
|
|
13
13
|
const require_PromptCarousel = require('../PromptCarousel/PromptCarousel.cjs');
|
|
@@ -26,9 +26,9 @@ let react_jsx_runtime = require("react/jsx-runtime");
|
|
|
26
26
|
//#region src/components/TypingAnimation/TypingAnimation.tsx
|
|
27
27
|
const TypingAnimation = ({ baseProps, widgetContentProps, widgetStyleProps, widgetEventProps }) => {
|
|
28
28
|
const { id, testId, className, style } = baseProps || {};
|
|
29
|
-
const { titleLabel, headlineText, animatedTextSequence, promptButtonTexts, hintText, textFieldAriaLabel, logoSrc, hideLogo } = widgetContentProps || {};
|
|
29
|
+
const { titleLabel, headlineText, animatedTextSequence, promptButtonTexts, hintText, textFieldAriaLabel, logoSrc, hideLogo, voiceInputEnabled } = widgetContentProps || {};
|
|
30
30
|
const { widgetVariant = require_types.WidgetWrapperVariant.CARD_WITH_BORDER, cardColor, promptButtonType = require_PromptButton_types_index.PromptButtonVariant.LIGHT, promptCarouselRows = require_PromptCarousel_types_types.PromptCarouselRows.ALWAYS_ONE, showTextField = true, theme = require_theme.Theme.GLOBAL_CUSTOM, isLoading = false } = widgetStyleProps || {};
|
|
31
|
-
const { handleButtonClick, handleButtonDrag, handleButtonHover, handleButtonMouseDown, handleButtonMouseUp, handleButtonTouchStart, handleButtonTouchEnd, handleTextFieldClick } = widgetEventProps || {};
|
|
31
|
+
const { handleButtonClick, handleButtonDrag, handleButtonHover, handleButtonMouseDown, handleButtonMouseUp, handleButtonTouchStart, handleButtonTouchEnd, handleTextFieldClick, onTranscriptionStarted, onTranscriptionCompleted } = widgetEventProps || {};
|
|
32
32
|
const typographyVariant = require_useGetTypographyVariant.useGetTypographyVariant(theme);
|
|
33
33
|
const { measuringRef, minHeight } = require_useAnimatedTextMinHeight.useAnimatedTextMinHeight(animatedTextSequence ?? []);
|
|
34
34
|
const biggestAnimatedText = (0, react.useMemo)(() => {
|
|
@@ -131,7 +131,11 @@ const TypingAnimation = ({ baseProps, widgetContentProps, widgetStyleProps, widg
|
|
|
131
131
|
ariaLabel: textFieldAriaLabel,
|
|
132
132
|
theme,
|
|
133
133
|
isLoading,
|
|
134
|
-
className: "envive-tw-mt-2 envive-tw-overflow-hidden envive-tw-text-ellipsis envive-tw-whitespace-nowrap"
|
|
134
|
+
className: "envive-tw-mt-2 envive-tw-overflow-hidden envive-tw-text-ellipsis envive-tw-whitespace-nowrap",
|
|
135
|
+
voiceInputClassName: "envive-tw-mt-2",
|
|
136
|
+
enableVoiceInput: voiceInputEnabled,
|
|
137
|
+
onTranscriptionStarted,
|
|
138
|
+
onTranscriptionCompleted
|
|
135
139
|
})
|
|
136
140
|
]
|
|
137
141
|
})
|