@envive-ai/react-toolkit-v3 0.3.26 → 0.3.28
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.ts +3 -3
- package/dist/CSSVariablesEditor/CssVariablesEditorComponent.d.cts +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 +3 -1
- package/dist/ChatFooter/ChatFooter.d.cts +2 -2
- package/dist/ChatFooter/ChatFooter.d.ts +2 -2
- package/dist/ChatFooter/ChatFooter.js +3 -1
- package/dist/ChatFooter/components/Layout.cjs +4 -4
- package/dist/ChatFooter/components/Layout.d.cts +1 -0
- package/dist/ChatFooter/components/Layout.d.ts +1 -0
- package/dist/ChatFooter/components/Layout.js +4 -4
- package/dist/ChatFooter/components/index.d.cts +5 -3
- package/dist/ChatFooter/components/index.d.ts +7 -5
- package/dist/ChatFooter/types/types.d.cts +3 -2
- package/dist/ChatFooter/types/types.d.ts +3 -2
- package/dist/ChatHeader/ChatHeader.d.cts +2 -2
- package/dist/ChatHeader/ChatHeader.d.ts +2 -2
- package/dist/ChatHeader/components/Handle.cjs +2 -2
- package/dist/ChatHeader/components/Handle.js +2 -2
- package/dist/ChatHeader/components/Toggle.cjs +3 -3
- package/dist/ChatHeader/components/Toggle.js +3 -3
- package/dist/ChatPreview/ChatPreview.cjs +1 -1
- package/dist/ChatPreview/ChatPreview.d.cts +2 -2
- package/dist/ChatPreview/ChatPreview.d.ts +2 -2
- package/dist/ChatPreview/ChatPreview.js +1 -1
- package/dist/ChatPreviewComparison/ChatPreviewComparison.cjs +1 -1
- package/dist/ChatPreviewComparison/ChatPreviewComparison.d.cts +2 -2
- package/dist/ChatPreviewComparison/ChatPreviewComparison.d.ts +2 -2
- package/dist/ChatPreviewComparison/ChatPreviewComparison.js +1 -1
- 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/ChatPreviewLoading/ChatPreviewLoading.d.cts +2 -2
- package/dist/ChatPreviewLoading/ChatPreviewLoading.d.ts +2 -2
- package/dist/Container/Container.d.cts +56 -56
- package/dist/Container/Container.d.ts +220 -220
- 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.d.cts +2 -2
- package/dist/FloatingChat/FloatingChat.d.ts +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 +6 -2
- package/dist/FloatingChat/components/SalesAgentBadgeContent.js +6 -2
- package/dist/FloatingChat/components/SalesAgentProductCardsCarousel.cjs +2 -1
- package/dist/FloatingChat/components/SalesAgentProductCardsCarousel.js +2 -1
- package/dist/FullPageSalesAgent/FullPageSalesAgent.cjs +126 -27
- package/dist/FullPageSalesAgent/FullPageSalesAgent.d.cts +5 -7
- package/dist/FullPageSalesAgent/FullPageSalesAgent.d.ts +5 -7
- package/dist/FullPageSalesAgent/FullPageSalesAgent.js +127 -28
- package/dist/FullPageSalesAgent/components/Layout.cjs +34 -27
- package/dist/FullPageSalesAgent/components/Layout.js +34 -27
- package/dist/FullPageSalesAgent/components/WelcomeOverlay.cjs +109 -0
- package/dist/FullPageSalesAgent/components/WelcomeOverlay.js +107 -0
- package/dist/FullPageSalesAgent/components/index.cjs +1 -0
- package/dist/FullPageSalesAgent/components/index.js +1 -0
- package/dist/FullPageSalesAgent/hooks/useGetFooterStyles.cjs +16 -6
- package/dist/FullPageSalesAgent/hooks/useGetFooterStyles.js +16 -6
- package/dist/FullPageSalesAgent/hooks/useWelcomeOverlayProducts.cjs +44 -0
- package/dist/FullPageSalesAgent/hooks/useWelcomeOverlayProducts.js +42 -0
- 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 +2 -2
- package/dist/ProductCard/ProductCard.d.cts +2 -2
- package/dist/ProductCard/ProductCard.d.ts +2 -2
- package/dist/ProductCard/ProductCard.js +2 -2
- package/dist/PromptButton/PromptButton.d.cts +2 -2
- package/dist/PromptButton/PromptButton.d.ts +2 -2
- package/dist/PromptButton/hooks/useGetLayoutBaseProperties.cjs +1 -1
- package/dist/PromptButton/hooks/useGetLayoutBaseProperties.js +1 -1
- package/dist/PromptButtonCarouselWithImage/PromptButtonCarouselWithImage.d.cts +2 -2
- package/dist/PromptButtonCarouselWithImage/PromptButtonCarouselWithImage.d.ts +2 -2
- package/dist/PromptButtonCarouselWithImage/components/PromptButtonsCarousel.cjs +1 -1
- package/dist/PromptButtonCarouselWithImage/components/PromptButtonsCarousel.js +1 -1
- 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.ts +2 -2
- package/dist/ReviewCard/components/Container.cjs +2 -2
- package/dist/ReviewCard/components/Container.js +2 -2
- 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/Price.cjs +2 -2
- package/dist/SalesAgentProductCard/components/Price.js +2 -2
- package/dist/SalesAgentProductCard/components/Rate.cjs +1 -1
- package/dist/SalesAgentProductCard/components/Rate.js +1 -1
- package/dist/SalesAgentProductCard/components/index.d.cts +8 -8
- package/dist/SalesAgentProductCard/components/index.d.ts +8 -8
- package/dist/SocialProof/SocialProof.cjs +5 -4
- package/dist/SocialProof/SocialProof.d.cts +2 -2
- package/dist/SocialProof/SocialProof.d.ts +2 -2
- package/dist/SocialProof/SocialProof.js +5 -4
- package/dist/SocialProof/components/Headline.cjs +4 -4
- package/dist/SocialProof/components/Headline.js +4 -4
- package/dist/SocialProof/components/LayoutFourHorizontal.cjs +1 -1
- package/dist/SocialProof/components/LayoutFourHorizontal.js +1 -1
- package/dist/SocialProof/components/LayoutSingle.cjs +3 -4
- package/dist/SocialProof/components/LayoutSingle.js +3 -4
- package/dist/SocialProof/components/Subheadline.cjs +1 -1
- package/dist/SocialProof/components/Subheadline.js +1 -1
- package/dist/SocialProof/hooks/useSocialProofCount.cjs +3 -2
- package/dist/SocialProof/hooks/useSocialProofCount.d.cts +2 -0
- package/dist/SocialProof/hooks/useSocialProofCount.d.ts +2 -0
- package/dist/SocialProof/hooks/useSocialProofCount.js +3 -2
- package/dist/SocialProof/types/types.d.cts +5 -0
- package/dist/SocialProof/types/types.d.ts +5 -0
- 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 +10 -3
- package/dist/TextField/TextField.d.cts +1 -0
- package/dist/TextField/TextField.d.ts +1 -0
- package/dist/TextField/TextField.js +10 -3
- package/dist/TextField/components/Input.cjs +31 -2
- package/dist/TextField/components/Input.js +31 -2
- package/dist/TextField/components/Layout.cjs +7 -2
- package/dist/TextField/components/Layout.js +7 -2
- package/dist/TextField/hooks/useAutoResize.cjs +17 -0
- package/dist/TextField/hooks/useAutoResize.js +16 -0
- package/dist/TextField/hooks/usePlaceholderAnimation.cjs +58 -0
- package/dist/TextField/hooks/usePlaceholderAnimation.js +57 -0
- package/dist/TextField/hooks/useVoiceInput.cjs +9 -1
- package/dist/TextField/hooks/useVoiceInput.js +9 -1
- package/dist/TextField/types/index.d.cts +19 -1
- package/dist/TextField/types/index.d.ts +19 -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 +1 -1
- package/dist/TypingAnimation/TypingAnimation.d.cts +2 -2
- package/dist/TypingAnimation/TypingAnimation.d.ts +2 -2
- package/dist/TypingAnimation/TypingAnimation.js +1 -1
- package/dist/TypingAnimation/hooks/useGetTypographyVariant.cjs +1 -1
- package/dist/TypingAnimation/hooks/useGetTypographyVariant.js +1 -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 +4 -4
- package/dist/WidgetTextField/WidgetTextField.d.cts +2 -2
- package/dist/WidgetTextField/WidgetTextField.d.ts +2 -2
- package/dist/WidgetTextField/WidgetTextField.js +1 -1
- package/dist/WidgetTextField/components/Container.cjs +2 -2
- package/dist/WidgetTextField/components/Container.js +2 -2
- package/dist/WidgetTextField/components/Icon.cjs +1 -1
- package/dist/WidgetTextField/components/Icon.js +1 -1
- package/dist/WidgetWrapper/WidgetWrapper.d.cts +2 -2
- package/dist/WidgetWrapper/WidgetWrapper.d.ts +2 -2
- package/dist/WidgetWrapperWithTitle/WidgetWrapperWithTitle.d.cts +2 -2
- package/dist/WidgetWrapperWithTitle/WidgetWrapperWithTitle.d.ts +2 -2
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/src/components/ChatFooter/ChatFooter.tsx +2 -0
- package/src/components/ChatFooter/components/Layout.tsx +3 -1
- package/src/components/ChatFooter/components/TextField.tsx +4 -1
- package/src/components/ChatFooter/types/types.ts +3 -2
- package/src/components/FloatingChat/components/SalesAgentBadgeContent.tsx +8 -0
- package/src/components/FloatingChat/components/SalesAgentProductCardsCarousel.tsx +3 -0
- package/src/components/FullPageSalesAgent/FullPageSalesAgent.tsx +207 -49
- package/src/components/FullPageSalesAgent/components/Layout.tsx +10 -3
- package/src/components/FullPageSalesAgent/components/WelcomeOverlay.tsx +143 -0
- package/src/components/FullPageSalesAgent/components/index.ts +2 -0
- package/src/components/FullPageSalesAgent/hooks/useGetFooterStyles.ts +15 -5
- package/src/components/FullPageSalesAgent/hooks/useWelcomeOverlayProducts.ts +52 -0
- package/src/components/PromptButton/hooks/useGetLayoutBaseProperties.ts +3 -1
- package/src/components/SalesAgentProductCard/components/Price.tsx +2 -2
- package/src/components/SalesAgentProductCard/components/Rate.tsx +1 -1
- package/src/components/SocialProof/SocialProof.tsx +4 -2
- package/src/components/SocialProof/components/Headline.tsx +1 -1
- package/src/components/SocialProof/components/LayoutSingle.tsx +6 -5
- package/src/components/SocialProof/hooks/useSocialProofCount.ts +8 -1
- package/src/components/SocialProof/types/types.ts +6 -0
- package/src/components/TextField/TextField.tsx +17 -3
- package/src/components/TextField/__tests__/VoiceInputButton.test.tsx +22 -58
- package/src/components/TextField/components/Input.tsx +43 -9
- package/src/components/TextField/components/Layout.tsx +7 -1
- package/src/components/TextField/hooks/useAutoResize.ts +14 -0
- package/src/components/TextField/hooks/usePlaceholderAnimation.ts +67 -0
- package/src/components/TextField/hooks/useTextFieldSubmit.ts +1 -1
- package/src/components/TextField/hooks/useVoiceInput.ts +8 -0
- package/src/components/TextField/types/index.ts +19 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime35 from "react/jsx-runtime";
|
|
2
2
|
|
|
3
3
|
//#region src/components/SparkleAnimation/SparkleAnimation.d.ts
|
|
4
4
|
interface SparkleAnimationProps {
|
|
@@ -10,6 +10,6 @@ declare const SparkleAnimation: ({
|
|
|
10
10
|
color,
|
|
11
11
|
className,
|
|
12
12
|
animate
|
|
13
|
-
}: SparkleAnimationProps) =>
|
|
13
|
+
}: SparkleAnimationProps) => react_jsx_runtime35.JSX.Element;
|
|
14
14
|
//#endregion
|
|
15
15
|
export { SparkleAnimation };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime20 from "react/jsx-runtime";
|
|
2
2
|
|
|
3
3
|
//#region src/components/SparkleAnimation/SparkleAnimation.d.ts
|
|
4
4
|
interface SparkleAnimationProps {
|
|
@@ -10,6 +10,6 @@ declare const SparkleAnimation: ({
|
|
|
10
10
|
color,
|
|
11
11
|
className,
|
|
12
12
|
animate
|
|
13
|
-
}: SparkleAnimationProps) =>
|
|
13
|
+
}: SparkleAnimationProps) => react_jsx_runtime20.JSX.Element;
|
|
14
14
|
//#endregion
|
|
15
15
|
export { SparkleAnimation };
|
package/dist/Stack/Stack.d.cts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { StackProps } from "./types/index.cjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react2 from "react";
|
|
3
3
|
|
|
4
4
|
//#region src/components/Stack/Stack.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* Stack component for laying out children in a flexible container with gap.
|
|
7
7
|
*/
|
|
8
|
-
declare const Stack:
|
|
8
|
+
declare const Stack: react2.ForwardRefExoticComponent<StackProps & react2.RefAttributes<HTMLDivElement>>;
|
|
9
9
|
//#endregion
|
|
10
10
|
export { Stack };
|
package/dist/Stack/Stack.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { StackProps } from "./types/index.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react5 from "react";
|
|
3
3
|
|
|
4
4
|
//#region src/components/Stack/Stack.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* Stack component for laying out children in a flexible container with gap.
|
|
7
7
|
*/
|
|
8
|
-
declare const Stack:
|
|
8
|
+
declare const Stack: react5.ForwardRefExoticComponent<StackProps & react5.RefAttributes<HTMLDivElement>>;
|
|
9
9
|
//#endregion
|
|
10
10
|
export { Stack };
|
|
@@ -7,6 +7,7 @@ const require_useGetSkeletonProperties = require('./hooks/useGetSkeletonProperti
|
|
|
7
7
|
const require_useTextFieldFocus = require('./hooks/useTextFieldFocus.cjs');
|
|
8
8
|
const require_useTextFieldSubmit = require('./hooks/useTextFieldSubmit.cjs');
|
|
9
9
|
const require_useTextFieldValue = require('./hooks/useTextFieldValue.cjs');
|
|
10
|
+
const require_usePlaceholderAnimation = require('./hooks/usePlaceholderAnimation.cjs');
|
|
10
11
|
const require_useVoiceInput = require('./hooks/useVoiceInput.cjs');
|
|
11
12
|
let react = require("react");
|
|
12
13
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -18,7 +19,8 @@ classnames = require_rolldown_runtime.__toESM(classnames);
|
|
|
18
19
|
* Renders a text input field with a send icon.
|
|
19
20
|
* Supports three visual themes: Standard, Modern, and Minimal.
|
|
20
21
|
*/
|
|
21
|
-
const TextField = ({ theme = require_theme.Theme.GLOBAL_CUSTOM, placeholder, value: controlledValue, onChange, onSubmit, onFocus, disabled = false, id, testId, className, inputClassName, style, ariaLabel, isLoading = false, enableVoiceInput = false, onTranscriptionStarted, onTranscriptionCompleted }) => {
|
|
22
|
+
const TextField = ({ theme = require_theme.Theme.GLOBAL_CUSTOM, placeholder, value: controlledValue, onChange, onSubmit, onFocus, disabled = false, id, testId, className, inputClassName, style, ariaLabel, isLoading = false, multiline = false, enableVoiceInput = false, onTranscriptionStarted, onTranscriptionCompleted }) => {
|
|
23
|
+
const resolvedPlaceholder = require_usePlaceholderAnimation.usePlaceholderAnimation(placeholder);
|
|
22
24
|
const { currentValue, hasValue, handleChange, resetValue } = require_useTextFieldValue.useTextFieldValue(controlledValue, onChange);
|
|
23
25
|
const { isFocused, handleFocus, handleBlur } = require_useTextFieldFocus.useTextFieldFocus();
|
|
24
26
|
const { handleSubmit, handleKeyDown } = require_useTextFieldSubmit.useTextFieldSubmit(onSubmit, hasValue, disabled, isLoading, currentValue, resetValue);
|
|
@@ -33,6 +35,9 @@ const TextField = ({ theme = require_theme.Theme.GLOBAL_CUSTOM, placeholder, val
|
|
|
33
35
|
resetValue,
|
|
34
36
|
onTranscriptionCompleted
|
|
35
37
|
]),
|
|
38
|
+
onTranscription: (0, react.useCallback)((transcript) => {
|
|
39
|
+
handleChange(transcript);
|
|
40
|
+
}, [handleChange]),
|
|
36
41
|
disabled
|
|
37
42
|
});
|
|
38
43
|
const handleInternalFocus = () => {
|
|
@@ -44,7 +49,7 @@ const TextField = ({ theme = require_theme.Theme.GLOBAL_CUSTOM, placeholder, val
|
|
|
44
49
|
const resolvedTheme = require_resolveTheme.resolveTheme(theme);
|
|
45
50
|
const input = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_index.TextFieldComponents.Input, {
|
|
46
51
|
theme: resolvedTheme,
|
|
47
|
-
placeholder: isLoading ? "" :
|
|
52
|
+
placeholder: isLoading ? "" : resolvedPlaceholder,
|
|
48
53
|
value: isLoading ? "" : currentValue,
|
|
49
54
|
onChange: handleChange,
|
|
50
55
|
onKeyDown: handleKeyDown,
|
|
@@ -52,7 +57,8 @@ const TextField = ({ theme = require_theme.Theme.GLOBAL_CUSTOM, placeholder, val
|
|
|
52
57
|
onBlur: handleBlur,
|
|
53
58
|
disabled: disabled || isLoading,
|
|
54
59
|
ariaLabel,
|
|
55
|
-
className: inputClassName
|
|
60
|
+
className: inputClassName,
|
|
61
|
+
multiline
|
|
56
62
|
});
|
|
57
63
|
const sendIcon = !isLoading ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_index.TextFieldComponents.SendIcon, {
|
|
58
64
|
theme: resolvedTheme,
|
|
@@ -82,6 +88,7 @@ const TextField = ({ theme = require_theme.Theme.GLOBAL_CUSTOM, placeholder, val
|
|
|
82
88
|
isFocused,
|
|
83
89
|
hasValue,
|
|
84
90
|
disabled,
|
|
91
|
+
multiline,
|
|
85
92
|
id,
|
|
86
93
|
testId,
|
|
87
94
|
className: (0, classnames.default)(className, skeletonClass, disabled && "envive-tw-cursor-not-allowed"),
|
|
@@ -6,6 +6,7 @@ import { useGetSkeletonProperties } from "./hooks/useGetSkeletonProperties.js";
|
|
|
6
6
|
import { useTextFieldFocus } from "./hooks/useTextFieldFocus.js";
|
|
7
7
|
import { useTextFieldSubmit } from "./hooks/useTextFieldSubmit.js";
|
|
8
8
|
import { useTextFieldValue } from "./hooks/useTextFieldValue.js";
|
|
9
|
+
import { usePlaceholderAnimation } from "./hooks/usePlaceholderAnimation.js";
|
|
9
10
|
import { useVoiceInput } from "./hooks/useVoiceInput.js";
|
|
10
11
|
import { useCallback } from "react";
|
|
11
12
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -16,7 +17,8 @@ import classNames from "classnames";
|
|
|
16
17
|
* Renders a text input field with a send icon.
|
|
17
18
|
* Supports three visual themes: Standard, Modern, and Minimal.
|
|
18
19
|
*/
|
|
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 }) => {
|
|
20
|
+
const TextField = ({ theme = Theme.GLOBAL_CUSTOM, placeholder, value: controlledValue, onChange, onSubmit, onFocus, disabled = false, id, testId, className, inputClassName, style, ariaLabel, isLoading = false, multiline = false, enableVoiceInput = false, onTranscriptionStarted, onTranscriptionCompleted }) => {
|
|
21
|
+
const resolvedPlaceholder = usePlaceholderAnimation(placeholder);
|
|
20
22
|
const { currentValue, hasValue, handleChange, resetValue } = useTextFieldValue(controlledValue, onChange);
|
|
21
23
|
const { isFocused, handleFocus, handleBlur } = useTextFieldFocus();
|
|
22
24
|
const { handleSubmit, handleKeyDown } = useTextFieldSubmit(onSubmit, hasValue, disabled, isLoading, currentValue, resetValue);
|
|
@@ -31,6 +33,9 @@ const TextField = ({ theme = Theme.GLOBAL_CUSTOM, placeholder, value: controlled
|
|
|
31
33
|
resetValue,
|
|
32
34
|
onTranscriptionCompleted
|
|
33
35
|
]),
|
|
36
|
+
onTranscription: useCallback((transcript) => {
|
|
37
|
+
handleChange(transcript);
|
|
38
|
+
}, [handleChange]),
|
|
34
39
|
disabled
|
|
35
40
|
});
|
|
36
41
|
const handleInternalFocus = () => {
|
|
@@ -42,7 +47,7 @@ const TextField = ({ theme = Theme.GLOBAL_CUSTOM, placeholder, value: controlled
|
|
|
42
47
|
const resolvedTheme = resolveTheme(theme);
|
|
43
48
|
const input = /* @__PURE__ */ jsx(TextFieldComponents.Input, {
|
|
44
49
|
theme: resolvedTheme,
|
|
45
|
-
placeholder: isLoading ? "" :
|
|
50
|
+
placeholder: isLoading ? "" : resolvedPlaceholder,
|
|
46
51
|
value: isLoading ? "" : currentValue,
|
|
47
52
|
onChange: handleChange,
|
|
48
53
|
onKeyDown: handleKeyDown,
|
|
@@ -50,7 +55,8 @@ const TextField = ({ theme = Theme.GLOBAL_CUSTOM, placeholder, value: controlled
|
|
|
50
55
|
onBlur: handleBlur,
|
|
51
56
|
disabled: disabled || isLoading,
|
|
52
57
|
ariaLabel,
|
|
53
|
-
className: inputClassName
|
|
58
|
+
className: inputClassName,
|
|
59
|
+
multiline
|
|
54
60
|
});
|
|
55
61
|
const sendIcon = !isLoading ? /* @__PURE__ */ jsx(TextFieldComponents.SendIcon, {
|
|
56
62
|
theme: resolvedTheme,
|
|
@@ -80,6 +86,7 @@ const TextField = ({ theme = Theme.GLOBAL_CUSTOM, placeholder, value: controlled
|
|
|
80
86
|
isFocused,
|
|
81
87
|
hasValue,
|
|
82
88
|
disabled,
|
|
89
|
+
multiline,
|
|
83
90
|
id,
|
|
84
91
|
testId,
|
|
85
92
|
className: classNames(className, skeletonClass, disabled && "envive-tw-cursor-not-allowed"),
|
|
@@ -1,14 +1,43 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
2
|
const require_getInputClasses = require('../utils/getInputClasses.cjs');
|
|
3
3
|
const require_createInputChangeHandler = require('../utils/createInputChangeHandler.cjs');
|
|
4
|
+
const require_useAutoResize = require('../hooks/useAutoResize.cjs');
|
|
4
5
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
5
6
|
let classnames = require("classnames");
|
|
6
7
|
classnames = require_rolldown_runtime.__toESM(classnames);
|
|
7
8
|
|
|
8
9
|
//#region src/components/TextField/components/Input.tsx
|
|
9
|
-
const Input = ({ theme, placeholder, value, onChange, onKeyDown, onFocus, onBlur, disabled = false, id, testId, className, style, ariaLabel }) => {
|
|
10
|
+
const Input = ({ theme, placeholder, value, onChange, onKeyDown, onFocus, onBlur, disabled = false, multiline = false, id, testId, className, style, ariaLabel }) => {
|
|
10
11
|
const { inputClasses } = require_getInputClasses.getInputClasses(theme);
|
|
11
12
|
const handleChange = require_createInputChangeHandler.createInputChangeHandler(disabled, onChange);
|
|
13
|
+
const textareaRef = require_useAutoResize.useAutoResize(multiline ? value : void 0);
|
|
14
|
+
const sharedClasses = (0, classnames.default)(inputClasses, "focus-visible:envive-tw-shadow-none focus-visible:envive-tw-outline-none", className, disabled && "envive-tw-cursor-not-allowed");
|
|
15
|
+
if (multiline) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("textarea", {
|
|
16
|
+
ref: textareaRef,
|
|
17
|
+
id,
|
|
18
|
+
"data-testid": testId,
|
|
19
|
+
placeholder,
|
|
20
|
+
value,
|
|
21
|
+
rows: 1,
|
|
22
|
+
onChange: (e) => {
|
|
23
|
+
if (!disabled) onChange?.(e.target.value);
|
|
24
|
+
},
|
|
25
|
+
onKeyDown: (e) => {
|
|
26
|
+
if (e.key === "Enter" && !e.shiftKey) onKeyDown?.(e);
|
|
27
|
+
},
|
|
28
|
+
onFocus,
|
|
29
|
+
onBlur,
|
|
30
|
+
disabled,
|
|
31
|
+
className: sharedClasses,
|
|
32
|
+
style: {
|
|
33
|
+
resize: "none",
|
|
34
|
+
overflow: "hidden",
|
|
35
|
+
padding: 0,
|
|
36
|
+
...style
|
|
37
|
+
},
|
|
38
|
+
"aria-label": ariaLabel,
|
|
39
|
+
"aria-disabled": disabled
|
|
40
|
+
});
|
|
12
41
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
13
42
|
type: "text",
|
|
14
43
|
id,
|
|
@@ -20,7 +49,7 @@ const Input = ({ theme, placeholder, value, onChange, onKeyDown, onFocus, onBlur
|
|
|
20
49
|
onFocus,
|
|
21
50
|
onBlur,
|
|
22
51
|
disabled,
|
|
23
|
-
className:
|
|
52
|
+
className: sharedClasses,
|
|
24
53
|
style,
|
|
25
54
|
"aria-label": ariaLabel,
|
|
26
55
|
"aria-disabled": disabled
|
|
@@ -1,12 +1,41 @@
|
|
|
1
1
|
import { getInputClasses } from "../utils/getInputClasses.js";
|
|
2
2
|
import { createInputChangeHandler } from "../utils/createInputChangeHandler.js";
|
|
3
|
+
import { useAutoResize } from "../hooks/useAutoResize.js";
|
|
3
4
|
import { jsx } from "react/jsx-runtime";
|
|
4
5
|
import classNames from "classnames";
|
|
5
6
|
|
|
6
7
|
//#region src/components/TextField/components/Input.tsx
|
|
7
|
-
const Input = ({ theme, placeholder, value, onChange, onKeyDown, onFocus, onBlur, disabled = false, id, testId, className, style, ariaLabel }) => {
|
|
8
|
+
const Input = ({ theme, placeholder, value, onChange, onKeyDown, onFocus, onBlur, disabled = false, multiline = false, id, testId, className, style, ariaLabel }) => {
|
|
8
9
|
const { inputClasses } = getInputClasses(theme);
|
|
9
10
|
const handleChange = createInputChangeHandler(disabled, onChange);
|
|
11
|
+
const textareaRef = useAutoResize(multiline ? value : void 0);
|
|
12
|
+
const sharedClasses = classNames(inputClasses, "focus-visible:envive-tw-shadow-none focus-visible:envive-tw-outline-none", className, disabled && "envive-tw-cursor-not-allowed");
|
|
13
|
+
if (multiline) return /* @__PURE__ */ jsx("textarea", {
|
|
14
|
+
ref: textareaRef,
|
|
15
|
+
id,
|
|
16
|
+
"data-testid": testId,
|
|
17
|
+
placeholder,
|
|
18
|
+
value,
|
|
19
|
+
rows: 1,
|
|
20
|
+
onChange: (e) => {
|
|
21
|
+
if (!disabled) onChange?.(e.target.value);
|
|
22
|
+
},
|
|
23
|
+
onKeyDown: (e) => {
|
|
24
|
+
if (e.key === "Enter" && !e.shiftKey) onKeyDown?.(e);
|
|
25
|
+
},
|
|
26
|
+
onFocus,
|
|
27
|
+
onBlur,
|
|
28
|
+
disabled,
|
|
29
|
+
className: sharedClasses,
|
|
30
|
+
style: {
|
|
31
|
+
resize: "none",
|
|
32
|
+
overflow: "hidden",
|
|
33
|
+
padding: 0,
|
|
34
|
+
...style
|
|
35
|
+
},
|
|
36
|
+
"aria-label": ariaLabel,
|
|
37
|
+
"aria-disabled": disabled
|
|
38
|
+
});
|
|
10
39
|
return /* @__PURE__ */ jsx("input", {
|
|
11
40
|
type: "text",
|
|
12
41
|
id,
|
|
@@ -18,7 +47,7 @@ const Input = ({ theme, placeholder, value, onChange, onKeyDown, onFocus, onBlur
|
|
|
18
47
|
onFocus,
|
|
19
48
|
onBlur,
|
|
20
49
|
disabled,
|
|
21
|
-
className:
|
|
50
|
+
className: sharedClasses,
|
|
22
51
|
style,
|
|
23
52
|
"aria-label": ariaLabel,
|
|
24
53
|
"aria-disabled": disabled
|
|
@@ -6,7 +6,7 @@ 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, voiceInputButton, isFocused, hasValue, disabled = false, id, testId, className, style }) => {
|
|
9
|
+
const Layout = ({ theme, input, sendIcon, voiceInputButton, isFocused, hasValue, disabled = false, multiline = false, id, testId, className, style }) => {
|
|
10
10
|
const { containerLayoutClasses, containerDefaultClasses, containerBorderClasses, containerBorderActiveClasses, containerFocusClasses, containerHoverClasses, containerDisabledClasses } = require_useGetContainerProperties.useGetContainerProperties({ theme });
|
|
11
11
|
const { isActive, shouldShowFocus, shouldShowHover, containerClasses } = require_getLayoutStateProperties.getLayoutStateProperties(theme, hasValue, isFocused, disabled);
|
|
12
12
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -15,7 +15,12 @@ const Layout = ({ theme, input, sendIcon, voiceInputButton, isFocused, hasValue,
|
|
|
15
15
|
id,
|
|
16
16
|
"data-testid": testId,
|
|
17
17
|
className: (0, classnames.default)("envive-tw-flex-1", containerLayoutClasses, containerDefaultClasses, isActive ? containerBorderActiveClasses : containerBorderClasses, shouldShowFocus && containerFocusClasses, shouldShowHover && containerHoverClasses, disabled && containerDisabledClasses, className),
|
|
18
|
-
style
|
|
18
|
+
style: multiline ? {
|
|
19
|
+
height: "auto",
|
|
20
|
+
minHeight: "40px",
|
|
21
|
+
alignItems: "flex-end",
|
|
22
|
+
...style
|
|
23
|
+
} : style,
|
|
19
24
|
children: [input, sendIcon]
|
|
20
25
|
}), voiceInputButton]
|
|
21
26
|
});
|
|
@@ -4,7 +4,7 @@ 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, voiceInputButton, isFocused, hasValue, disabled = false, id, testId, className, style }) => {
|
|
7
|
+
const Layout = ({ theme, input, sendIcon, voiceInputButton, isFocused, hasValue, disabled = false, multiline = false, id, testId, className, style }) => {
|
|
8
8
|
const { containerLayoutClasses, containerDefaultClasses, containerBorderClasses, containerBorderActiveClasses, containerFocusClasses, containerHoverClasses, containerDisabledClasses } = useGetContainerProperties({ theme });
|
|
9
9
|
const { isActive, shouldShowFocus, shouldShowHover, containerClasses } = getLayoutStateProperties(theme, hasValue, isFocused, disabled);
|
|
10
10
|
return /* @__PURE__ */ jsxs("div", {
|
|
@@ -13,7 +13,12 @@ const Layout = ({ theme, input, sendIcon, voiceInputButton, isFocused, hasValue,
|
|
|
13
13
|
id,
|
|
14
14
|
"data-testid": testId,
|
|
15
15
|
className: classNames("envive-tw-flex-1", containerLayoutClasses, containerDefaultClasses, isActive ? containerBorderActiveClasses : containerBorderClasses, shouldShowFocus && containerFocusClasses, shouldShowHover && containerHoverClasses, disabled && containerDisabledClasses, className),
|
|
16
|
-
style
|
|
16
|
+
style: multiline ? {
|
|
17
|
+
height: "auto",
|
|
18
|
+
minHeight: "40px",
|
|
19
|
+
alignItems: "flex-end",
|
|
20
|
+
...style
|
|
21
|
+
} : style,
|
|
17
22
|
children: [input, sendIcon]
|
|
18
23
|
}), voiceInputButton]
|
|
19
24
|
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let react = require("react");
|
|
3
|
+
|
|
4
|
+
//#region src/components/TextField/hooks/useAutoResize.ts
|
|
5
|
+
const useAutoResize = (value) => {
|
|
6
|
+
const ref = (0, react.useRef)(null);
|
|
7
|
+
(0, react.useEffect)(() => {
|
|
8
|
+
const el = ref.current;
|
|
9
|
+
if (!el) return;
|
|
10
|
+
el.style.height = "auto";
|
|
11
|
+
el.style.height = `${el.scrollHeight}px`;
|
|
12
|
+
}, [value]);
|
|
13
|
+
return ref;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
exports.useAutoResize = useAutoResize;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useEffect, useRef } from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/components/TextField/hooks/useAutoResize.ts
|
|
4
|
+
const useAutoResize = (value) => {
|
|
5
|
+
const ref = useRef(null);
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
const el = ref.current;
|
|
8
|
+
if (!el) return;
|
|
9
|
+
el.style.height = "auto";
|
|
10
|
+
el.style.height = `${el.scrollHeight}px`;
|
|
11
|
+
}, [value]);
|
|
12
|
+
return ref;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
export { useAutoResize };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let react = require("react");
|
|
3
|
+
|
|
4
|
+
//#region src/components/TextField/hooks/usePlaceholderAnimation.ts
|
|
5
|
+
const DEFAULT_TYPING_DURATION = 400;
|
|
6
|
+
const DEFAULT_TRANSITION = 3e3;
|
|
7
|
+
const CLEAR_PAUSE = 200;
|
|
8
|
+
const usePlaceholderAnimation = (placeholder, typingDuration = DEFAULT_TYPING_DURATION, transition = DEFAULT_TRANSITION) => {
|
|
9
|
+
const [current, setCurrent] = (0, react.useState)(() => Array.isArray(placeholder) ? "" : placeholder);
|
|
10
|
+
const timeoutsRef = (0, react.useRef)([]);
|
|
11
|
+
const isMountedRef = (0, react.useRef)(true);
|
|
12
|
+
(0, react.useEffect)(() => {
|
|
13
|
+
if (!Array.isArray(placeholder)) {
|
|
14
|
+
setCurrent(placeholder);
|
|
15
|
+
return () => {};
|
|
16
|
+
}
|
|
17
|
+
if (placeholder.length === 0) {
|
|
18
|
+
setCurrent("");
|
|
19
|
+
return () => {};
|
|
20
|
+
}
|
|
21
|
+
isMountedRef.current = true;
|
|
22
|
+
timeoutsRef.current = [];
|
|
23
|
+
const delay = (ms) => new Promise((resolve) => {
|
|
24
|
+
const id = setTimeout(resolve, ms);
|
|
25
|
+
timeoutsRef.current.push(id);
|
|
26
|
+
});
|
|
27
|
+
const animateChars = async (text) => {
|
|
28
|
+
const charDelay = text.length > 1 ? typingDuration / (text.length - 1) : 0;
|
|
29
|
+
for (let i = 0; i < text.length; i += 1) {
|
|
30
|
+
await delay(charDelay);
|
|
31
|
+
if (isMountedRef.current) setCurrent(text.substring(0, i + 1));
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
const run = async () => {
|
|
35
|
+
while (isMountedRef.current) for (const element of placeholder) {
|
|
36
|
+
if (!isMountedRef.current) return;
|
|
37
|
+
await animateChars(element);
|
|
38
|
+
await delay(transition);
|
|
39
|
+
if (isMountedRef.current) setCurrent("");
|
|
40
|
+
await delay(CLEAR_PAUSE);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
run();
|
|
44
|
+
return () => {
|
|
45
|
+
isMountedRef.current = false;
|
|
46
|
+
timeoutsRef.current.forEach(clearTimeout);
|
|
47
|
+
timeoutsRef.current = [];
|
|
48
|
+
};
|
|
49
|
+
}, [
|
|
50
|
+
placeholder,
|
|
51
|
+
typingDuration,
|
|
52
|
+
transition
|
|
53
|
+
]);
|
|
54
|
+
return current;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
//#endregion
|
|
58
|
+
exports.usePlaceholderAnimation = usePlaceholderAnimation;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/components/TextField/hooks/usePlaceholderAnimation.ts
|
|
4
|
+
const DEFAULT_TYPING_DURATION = 400;
|
|
5
|
+
const DEFAULT_TRANSITION = 3e3;
|
|
6
|
+
const CLEAR_PAUSE = 200;
|
|
7
|
+
const usePlaceholderAnimation = (placeholder, typingDuration = DEFAULT_TYPING_DURATION, transition = DEFAULT_TRANSITION) => {
|
|
8
|
+
const [current, setCurrent] = useState(() => Array.isArray(placeholder) ? "" : placeholder);
|
|
9
|
+
const timeoutsRef = useRef([]);
|
|
10
|
+
const isMountedRef = useRef(true);
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
if (!Array.isArray(placeholder)) {
|
|
13
|
+
setCurrent(placeholder);
|
|
14
|
+
return () => {};
|
|
15
|
+
}
|
|
16
|
+
if (placeholder.length === 0) {
|
|
17
|
+
setCurrent("");
|
|
18
|
+
return () => {};
|
|
19
|
+
}
|
|
20
|
+
isMountedRef.current = true;
|
|
21
|
+
timeoutsRef.current = [];
|
|
22
|
+
const delay = (ms) => new Promise((resolve) => {
|
|
23
|
+
const id = setTimeout(resolve, ms);
|
|
24
|
+
timeoutsRef.current.push(id);
|
|
25
|
+
});
|
|
26
|
+
const animateChars = async (text) => {
|
|
27
|
+
const charDelay = text.length > 1 ? typingDuration / (text.length - 1) : 0;
|
|
28
|
+
for (let i = 0; i < text.length; i += 1) {
|
|
29
|
+
await delay(charDelay);
|
|
30
|
+
if (isMountedRef.current) setCurrent(text.substring(0, i + 1));
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const run = async () => {
|
|
34
|
+
while (isMountedRef.current) for (const element of placeholder) {
|
|
35
|
+
if (!isMountedRef.current) return;
|
|
36
|
+
await animateChars(element);
|
|
37
|
+
await delay(transition);
|
|
38
|
+
if (isMountedRef.current) setCurrent("");
|
|
39
|
+
await delay(CLEAR_PAUSE);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
run();
|
|
43
|
+
return () => {
|
|
44
|
+
isMountedRef.current = false;
|
|
45
|
+
timeoutsRef.current.forEach(clearTimeout);
|
|
46
|
+
timeoutsRef.current = [];
|
|
47
|
+
};
|
|
48
|
+
}, [
|
|
49
|
+
placeholder,
|
|
50
|
+
typingDuration,
|
|
51
|
+
transition
|
|
52
|
+
]);
|
|
53
|
+
return current;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
//#endregion
|
|
57
|
+
export { usePlaceholderAnimation };
|
|
@@ -6,7 +6,7 @@ let react_speech_recognition = require("react-speech-recognition");
|
|
|
6
6
|
react_speech_recognition = require_rolldown_runtime.__toESM(react_speech_recognition);
|
|
7
7
|
|
|
8
8
|
//#region src/components/TextField/hooks/useVoiceInput.ts
|
|
9
|
-
const useVoiceInput = ({ onTranscriptionCompleted, onTranscriptionStarted, disabled = false }) => {
|
|
9
|
+
const useVoiceInput = ({ onTranscriptionCompleted, onTranscriptionStarted, onTranscription, disabled = false }) => {
|
|
10
10
|
const [listeningToSpeech, setListeningToSpeech] = require_react.useAtom(__envive_ai_react_hooks_atoms_chat.listeningToSpeechAtom);
|
|
11
11
|
const { transcript, browserSupportsSpeechRecognition, resetTranscript, isMicrophoneAvailable } = (0, react_speech_recognition.useSpeechRecognition)();
|
|
12
12
|
const handleStartListening = async () => {
|
|
@@ -43,6 +43,14 @@ const useVoiceInput = ({ onTranscriptionCompleted, onTranscriptionStarted, disab
|
|
|
43
43
|
else if (listeningToSpeech === "stop") handleStopListening();
|
|
44
44
|
else if (listeningToSpeech === "abort") handleAbortListening();
|
|
45
45
|
}, [listeningToSpeech]);
|
|
46
|
+
(0, react.useEffect)(() => {
|
|
47
|
+
if (!disabled && listeningToSpeech === "start" && transcript) onTranscription?.(transcript);
|
|
48
|
+
}, [
|
|
49
|
+
transcript,
|
|
50
|
+
listeningToSpeech,
|
|
51
|
+
disabled,
|
|
52
|
+
onTranscription
|
|
53
|
+
]);
|
|
46
54
|
return {
|
|
47
55
|
isListening: listeningToSpeech === "start",
|
|
48
56
|
handleToggleListening,
|
|
@@ -4,7 +4,7 @@ import { listeningToSpeechAtom } from "@envive-ai/react-hooks/atoms/chat";
|
|
|
4
4
|
import SpeechRecognition, { useSpeechRecognition } from "react-speech-recognition";
|
|
5
5
|
|
|
6
6
|
//#region src/components/TextField/hooks/useVoiceInput.ts
|
|
7
|
-
const useVoiceInput = ({ onTranscriptionCompleted, onTranscriptionStarted, disabled = false }) => {
|
|
7
|
+
const useVoiceInput = ({ onTranscriptionCompleted, onTranscriptionStarted, onTranscription, disabled = false }) => {
|
|
8
8
|
const [listeningToSpeech, setListeningToSpeech] = useAtom(listeningToSpeechAtom);
|
|
9
9
|
const { transcript, browserSupportsSpeechRecognition, resetTranscript, isMicrophoneAvailable } = useSpeechRecognition();
|
|
10
10
|
const handleStartListening = async () => {
|
|
@@ -41,6 +41,14 @@ const useVoiceInput = ({ onTranscriptionCompleted, onTranscriptionStarted, disab
|
|
|
41
41
|
else if (listeningToSpeech === "stop") handleStopListening();
|
|
42
42
|
else if (listeningToSpeech === "abort") handleAbortListening();
|
|
43
43
|
}, [listeningToSpeech]);
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
if (!disabled && listeningToSpeech === "start" && transcript) onTranscription?.(transcript);
|
|
46
|
+
}, [
|
|
47
|
+
transcript,
|
|
48
|
+
listeningToSpeech,
|
|
49
|
+
disabled,
|
|
50
|
+
onTranscription
|
|
51
|
+
]);
|
|
44
52
|
return {
|
|
45
53
|
isListening: listeningToSpeech === "start",
|
|
46
54
|
handleToggleListening,
|
|
@@ -9,8 +9,9 @@ type TextFieldProps = {
|
|
|
9
9
|
theme?: Theme;
|
|
10
10
|
/**
|
|
11
11
|
* Placeholder text displayed when the input is empty.
|
|
12
|
+
* Pass an array of strings to cycle through them with a typing animation.
|
|
12
13
|
*/
|
|
13
|
-
placeholder: string;
|
|
14
|
+
placeholder: string | string[];
|
|
14
15
|
/**
|
|
15
16
|
* Controlled value of the input. If not provided, the component manages its own state.
|
|
16
17
|
*/
|
|
@@ -48,13 +49,30 @@ type TextFieldProps = {
|
|
|
48
49
|
* @default false
|
|
49
50
|
*/
|
|
50
51
|
isLoading?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* When true the input expands to multiple lines instead of scrolling horizontally.
|
|
54
|
+
* @default false
|
|
55
|
+
*/
|
|
56
|
+
multiline?: boolean;
|
|
51
57
|
/**
|
|
52
58
|
* Enable voice input button
|
|
53
59
|
* @default false
|
|
54
60
|
*/
|
|
55
61
|
enableVoiceInput?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Callback function invoked when voice transcription begins.
|
|
64
|
+
*/
|
|
56
65
|
onTranscriptionStarted?: () => void;
|
|
66
|
+
/**
|
|
67
|
+
* Callback function invoked when voice transcription completes.
|
|
68
|
+
* @param transcript - The transcribed text from voice input.
|
|
69
|
+
*/
|
|
57
70
|
onTranscriptionCompleted?: (transcript: string) => void;
|
|
71
|
+
/**
|
|
72
|
+
* Callback function invoked during voice transcription as audio is processed.
|
|
73
|
+
* @param transcript - The current transcribed text from voice input.
|
|
74
|
+
*/
|
|
75
|
+
onTranscription?: (transcript: string) => void;
|
|
58
76
|
};
|
|
59
77
|
//#endregion
|
|
60
78
|
export { TextFieldProps };
|
|
@@ -9,8 +9,9 @@ type TextFieldProps = {
|
|
|
9
9
|
theme?: Theme;
|
|
10
10
|
/**
|
|
11
11
|
* Placeholder text displayed when the input is empty.
|
|
12
|
+
* Pass an array of strings to cycle through them with a typing animation.
|
|
12
13
|
*/
|
|
13
|
-
placeholder: string;
|
|
14
|
+
placeholder: string | string[];
|
|
14
15
|
/**
|
|
15
16
|
* Controlled value of the input. If not provided, the component manages its own state.
|
|
16
17
|
*/
|
|
@@ -48,13 +49,30 @@ type TextFieldProps = {
|
|
|
48
49
|
* @default false
|
|
49
50
|
*/
|
|
50
51
|
isLoading?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* When true the input expands to multiple lines instead of scrolling horizontally.
|
|
54
|
+
* @default false
|
|
55
|
+
*/
|
|
56
|
+
multiline?: boolean;
|
|
51
57
|
/**
|
|
52
58
|
* Enable voice input button
|
|
53
59
|
* @default false
|
|
54
60
|
*/
|
|
55
61
|
enableVoiceInput?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Callback function invoked when voice transcription begins.
|
|
64
|
+
*/
|
|
56
65
|
onTranscriptionStarted?: () => void;
|
|
66
|
+
/**
|
|
67
|
+
* Callback function invoked when voice transcription completes.
|
|
68
|
+
* @param transcript - The transcribed text from voice input.
|
|
69
|
+
*/
|
|
57
70
|
onTranscriptionCompleted?: (transcript: string) => void;
|
|
71
|
+
/**
|
|
72
|
+
* Callback function invoked during voice transcription as audio is processed.
|
|
73
|
+
* @param transcript - The current transcribed text from voice input.
|
|
74
|
+
*/
|
|
75
|
+
onTranscription?: (transcript: string) => void;
|
|
58
76
|
};
|
|
59
77
|
//#endregion
|
|
60
78
|
export { TextFieldProps };
|
|
@@ -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');
|
|
3
4
|
const require_Stack = require('../Stack/Stack.cjs');
|
|
4
5
|
require('../Stack/index.cjs');
|
|
5
6
|
const require_index = require('../Typography/types/index.cjs');
|
|
6
7
|
const require_Typography = require('../Typography/Typography.cjs');
|
|
7
8
|
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_runtime13 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_runtime13.JSX.Element;
|
|
25
25
|
//#endregion
|
|
26
26
|
export { TitledPromptCarousel };
|