@contentgrowth/llm-service 1.0.8 → 1.1.0
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/ui/react/components/index.cjs +48 -6
- package/dist/ui/react/components/index.cjs.map +1 -1
- package/dist/ui/react/components/index.d.cts +7 -0
- package/dist/ui/react/components/index.d.ts +7 -0
- package/dist/ui/react/components/index.js +48 -6
- package/dist/ui/react/components/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -177,10 +177,17 @@ interface ChatInputAreaProps {
|
|
|
177
177
|
value?: string;
|
|
178
178
|
onChange?: (e: React.ChangeEvent<HTMLTextAreaElement>) => void;
|
|
179
179
|
defaultInputMode?: 'text' | 'voice';
|
|
180
|
+
hideVoiceButton?: boolean;
|
|
181
|
+
inputMode?: 'none' | 'text' | 'search' | 'tel' | 'url' | 'email' | 'numeric' | 'decimal';
|
|
180
182
|
}
|
|
181
183
|
interface ChatInputAreaHandle {
|
|
182
184
|
focus: () => void;
|
|
183
185
|
setValue: (value: string) => void;
|
|
186
|
+
getSelection: () => {
|
|
187
|
+
start: number;
|
|
188
|
+
end: number;
|
|
189
|
+
} | null;
|
|
190
|
+
replaceSelection: (text: string) => void;
|
|
184
191
|
}
|
|
185
192
|
declare const ChatInputArea: React.ForwardRefExoticComponent<ChatInputAreaProps & React.RefAttributes<ChatInputAreaHandle>>;
|
|
186
193
|
|
|
@@ -177,10 +177,17 @@ interface ChatInputAreaProps {
|
|
|
177
177
|
value?: string;
|
|
178
178
|
onChange?: (e: React.ChangeEvent<HTMLTextAreaElement>) => void;
|
|
179
179
|
defaultInputMode?: 'text' | 'voice';
|
|
180
|
+
hideVoiceButton?: boolean;
|
|
181
|
+
inputMode?: 'none' | 'text' | 'search' | 'tel' | 'url' | 'email' | 'numeric' | 'decimal';
|
|
180
182
|
}
|
|
181
183
|
interface ChatInputAreaHandle {
|
|
182
184
|
focus: () => void;
|
|
183
185
|
setValue: (value: string) => void;
|
|
186
|
+
getSelection: () => {
|
|
187
|
+
start: number;
|
|
188
|
+
end: number;
|
|
189
|
+
} | null;
|
|
190
|
+
replaceSelection: (text: string) => void;
|
|
184
191
|
}
|
|
185
192
|
declare const ChatInputArea: React.ForwardRefExoticComponent<ChatInputAreaProps & React.RefAttributes<ChatInputAreaHandle>>;
|
|
186
193
|
|
|
@@ -437,7 +437,9 @@ var ChatInputArea = forwardRef(({
|
|
|
437
437
|
placeholder,
|
|
438
438
|
value,
|
|
439
439
|
onChange,
|
|
440
|
-
defaultInputMode = "text"
|
|
440
|
+
defaultInputMode = "text",
|
|
441
|
+
hideVoiceButton = false,
|
|
442
|
+
inputMode: inputModeProp
|
|
441
443
|
}, ref) => {
|
|
442
444
|
var _a, _b, _c, _d;
|
|
443
445
|
const [internalMessage, setInternalMessage] = useState3("");
|
|
@@ -487,6 +489,7 @@ var ChatInputArea = forwardRef(({
|
|
|
487
489
|
const textareaRef = useRef3(null);
|
|
488
490
|
const measurementRef = useRef3(null);
|
|
489
491
|
const pendingSelectionRef = useRef3(null);
|
|
492
|
+
const lastSelectionRef = useRef3(null);
|
|
490
493
|
const isControlled = value !== void 0;
|
|
491
494
|
const message = isControlled ? value : internalMessage;
|
|
492
495
|
const messageRef = useRef3(message);
|
|
@@ -581,11 +584,40 @@ var ChatInputArea = forwardRef(({
|
|
|
581
584
|
});
|
|
582
585
|
useImperativeHandle(ref, () => ({
|
|
583
586
|
focus: () => {
|
|
584
|
-
|
|
585
|
-
(
|
|
587
|
+
const textarea = textareaRef.current;
|
|
588
|
+
if (textarea) {
|
|
589
|
+
textarea.focus();
|
|
590
|
+
if (lastSelectionRef.current) {
|
|
591
|
+
textarea.setSelectionRange(
|
|
592
|
+
lastSelectionRef.current.start,
|
|
593
|
+
lastSelectionRef.current.end
|
|
594
|
+
);
|
|
595
|
+
}
|
|
596
|
+
}
|
|
586
597
|
},
|
|
587
598
|
setValue: (newValue) => {
|
|
588
599
|
triggerChange(newValue);
|
|
600
|
+
},
|
|
601
|
+
getSelection: () => {
|
|
602
|
+
const textarea = textareaRef.current;
|
|
603
|
+
if (textarea && document.activeElement === textarea) {
|
|
604
|
+
return { start: textarea.selectionStart, end: textarea.selectionEnd };
|
|
605
|
+
}
|
|
606
|
+
return lastSelectionRef.current;
|
|
607
|
+
},
|
|
608
|
+
replaceSelection: (text) => {
|
|
609
|
+
const selection = lastSelectionRef.current;
|
|
610
|
+
const currentVal = messageRef.current || "";
|
|
611
|
+
if (selection && selection.start !== selection.end) {
|
|
612
|
+
const before = currentVal.substring(0, selection.start);
|
|
613
|
+
const after = currentVal.substring(selection.end);
|
|
614
|
+
const newText = before + text + after;
|
|
615
|
+
pendingSelectionRef.current = { start: selection.start, end: selection.start + text.length };
|
|
616
|
+
triggerChange(newText);
|
|
617
|
+
lastSelectionRef.current = null;
|
|
618
|
+
} else {
|
|
619
|
+
insertTextAtCursor(text);
|
|
620
|
+
}
|
|
589
621
|
}
|
|
590
622
|
}));
|
|
591
623
|
const handleSubmit = (e) => {
|
|
@@ -674,7 +706,7 @@ var ChatInputArea = forwardRef(({
|
|
|
674
706
|
logs.length === 0 && /* @__PURE__ */ jsx6("div", { children: "No logs yet..." })
|
|
675
707
|
] }),
|
|
676
708
|
/* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-2", children: [
|
|
677
|
-
voiceConfig && /* @__PURE__ */ jsx6(
|
|
709
|
+
voiceConfig && !hideVoiceButton && /* @__PURE__ */ jsx6(
|
|
678
710
|
VoiceInputButton,
|
|
679
711
|
{
|
|
680
712
|
voiceConfig,
|
|
@@ -719,12 +751,22 @@ var ChatInputArea = forwardRef(({
|
|
|
719
751
|
setIsFocused(true);
|
|
720
752
|
setVoiceError(null);
|
|
721
753
|
},
|
|
722
|
-
onBlur: () =>
|
|
754
|
+
onBlur: () => {
|
|
755
|
+
setIsFocused(false);
|
|
756
|
+
const textarea = textareaRef.current;
|
|
757
|
+
if (textarea) {
|
|
758
|
+
lastSelectionRef.current = {
|
|
759
|
+
start: textarea.selectionStart,
|
|
760
|
+
end: textarea.selectionEnd
|
|
761
|
+
};
|
|
762
|
+
}
|
|
763
|
+
},
|
|
723
764
|
placeholder: getPlaceholder(),
|
|
724
765
|
disabled: isInputDisabled,
|
|
725
766
|
readOnly: !!voiceTrigger || isTranscribing,
|
|
726
767
|
rows: 1,
|
|
727
|
-
className: `flex-grow px-4 py-2 outline-none text-gray-700 placeholder-gray-500 resize-none leading-6 w-full ${isInputDisabled ? "bg-gray-100 cursor-not-allowed" : "bg-transparent"} ${voiceTrigger || isTranscribing ? "cursor-default" : ""}
|
|
768
|
+
className: `flex-grow px-4 py-2 outline-none text-gray-700 placeholder-gray-500 resize-none leading-6 w-full ${isInputDisabled ? "bg-gray-100 cursor-not-allowed" : "bg-transparent"} ${voiceTrigger || isTranscribing ? "cursor-default" : ""}`,
|
|
769
|
+
...inputModeProp ? { inputMode: inputModeProp } : {}
|
|
728
770
|
}
|
|
729
771
|
),
|
|
730
772
|
/* @__PURE__ */ jsxs4("div", { className: "relative mx-2 flex-shrink-0", children: [
|