@alquimia-ai/ui 1.5.0 → 1.5.2

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/index.mjs CHANGED
@@ -1826,12 +1826,14 @@ function SpeechToText({
1826
1826
  IdleAudioIcon,
1827
1827
  handleReplaceInput,
1828
1828
  setIsAudioRecording,
1829
+ onSendAudio,
1829
1830
  ...props
1830
1831
  }) {
1831
1832
  const [isRecording, setIsRecording] = useState4(false);
1832
1833
  const [isLoading, setIsLoading] = useState4(false);
1833
1834
  const [mediaRecorder, setMediaRecorder] = useState4(null);
1834
1835
  const [audioBlob, setAudioBlob] = useState4(null);
1836
+ const [speechResult, setSpeechResult] = useState4(null);
1835
1837
  const startRecording = async () => {
1836
1838
  setIsRecording(true);
1837
1839
  const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
@@ -1855,6 +1857,7 @@ function SpeechToText({
1855
1857
  const transcription = await speechToText(audioBase64);
1856
1858
  if (transcription) {
1857
1859
  handleReplaceInput(transcription);
1860
+ setSpeechResult(transcription);
1858
1861
  setIsLoading(false);
1859
1862
  }
1860
1863
  } catch (error) {
@@ -1872,6 +1875,14 @@ function SpeechToText({
1872
1875
  useEffect4(() => {
1873
1876
  isLoading || isRecording ? setIsAudioRecording(true) : setIsAudioRecording(false);
1874
1877
  }, [isRecording, isLoading]);
1878
+ useEffect4(() => {
1879
+ if (speechResult) {
1880
+ setTimeout(() => {
1881
+ onSendAudio && onSendAudio();
1882
+ setSpeechResult(null);
1883
+ }, 200);
1884
+ }
1885
+ }, [speechResult]);
1875
1886
  const handleRecordButtonClick = () => {
1876
1887
  if (isRecording) {
1877
1888
  stopRecording();
@@ -2944,8 +2955,10 @@ var AssistantInput = React34.forwardRef(
2944
2955
  handleInputChange,
2945
2956
  isMessageStreaming,
2946
2957
  speechToTextComponent,
2958
+ placeholders,
2947
2959
  ...props
2948
2960
  }, ref) => {
2961
+ const placeholder = placeholders ? isMessageStreaming ? placeholders[0] : placeholders[1] : isMessageStreaming ? "Processing..." : "Type your message here...";
2949
2962
  return /* @__PURE__ */ jsxs22(
2950
2963
  "form",
2951
2964
  {
@@ -2961,7 +2974,7 @@ var AssistantInput = React34.forwardRef(
2961
2974
  disabled: isButtonDisabled,
2962
2975
  value: input,
2963
2976
  onChange: handleInputChange,
2964
- placeholder: isMessageStreaming ? "Procesando..." : "Escribe tu mensaje aqu\xED...",
2977
+ placeholder,
2965
2978
  className: cn(
2966
2979
  "flex-1 text-sm p-3 rounded-lg focus:outline-none w-full",
2967
2980
  "border border-input bg-background text-foreground",