@opengeni/react 2.5.0-canary.0 → 2.5.0-canary.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/{chunk-NVREJA6V.js → chunk-ZUT5QSQB.js} +29 -6
- package/dist/chunk-ZUT5QSQB.js.map +1 -0
- package/dist/components/composer.d.ts +1 -1
- package/dist/composer.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +2 -2
- package/src/components/composer.tsx +29 -5
- package/dist/chunk-NVREJA6V.js.map +0 -1
|
@@ -219,7 +219,7 @@ export declare function useChatComposerController({ delivery, draft, control, ef
|
|
|
219
219
|
handlePaste: (event: ClipboardEvent<HTMLTextAreaElement>) => void;
|
|
220
220
|
handleFileChange: (event: ChangeEvent<HTMLInputElement>) => void;
|
|
221
221
|
focusInput: () => void | undefined;
|
|
222
|
-
setValue: (
|
|
222
|
+
setValue: (next: string) => void;
|
|
223
223
|
value: string;
|
|
224
224
|
};
|
|
225
225
|
export type ChatComposerController = ReturnType<typeof useChatComposerController>;
|
package/dist/composer.js
CHANGED
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opengeni/react",
|
|
3
|
-
"version": "2.5.0-canary.
|
|
3
|
+
"version": "2.5.0-canary.2",
|
|
4
4
|
"description": "React hooks and styled components for OpenGeni: live session streaming, chat composer, message timeline, session status, and fleet views — token-themed (CSS variables), dark-first, built on Tailwind v4 + Radix + Motion.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -116,7 +116,7 @@
|
|
|
116
116
|
"@dnd-kit/utilities": "3.2.2",
|
|
117
117
|
"@fontsource-variable/noto-sans-arabic": "5.2.10",
|
|
118
118
|
"@fontsource-variable/noto-sans-jp": "5.2.10",
|
|
119
|
-
"@opengeni/sdk": "^2.5.0-canary.
|
|
119
|
+
"@opengeni/sdk": "^2.5.0-canary.2",
|
|
120
120
|
"clsx": "^2.1.1",
|
|
121
121
|
"lucide-react": "^1.8.0",
|
|
122
122
|
"motion": "^12.0.0",
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
useContext,
|
|
21
21
|
useEffect,
|
|
22
22
|
useId,
|
|
23
|
+
useLayoutEffect,
|
|
23
24
|
useMemo,
|
|
24
25
|
useRef,
|
|
25
26
|
useState,
|
|
@@ -367,6 +368,29 @@ export function useChatComposerController({
|
|
|
367
368
|
const submittingRef = useRef(false);
|
|
368
369
|
const controlOperationRef = useRef(false);
|
|
369
370
|
const mountedRef = useRef(true);
|
|
371
|
+
const deliveredValueRef = useRef(delivery.value);
|
|
372
|
+
const liveValueRef = useRef(delivery.value);
|
|
373
|
+
const [renderedValue, setRenderedValue] = useState(delivery.value);
|
|
374
|
+
const deliveryChanged = delivery.value !== deliveredValueRef.current;
|
|
375
|
+
if (deliveryChanged) {
|
|
376
|
+
deliveredValueRef.current = delivery.value;
|
|
377
|
+
liveValueRef.current = delivery.value;
|
|
378
|
+
}
|
|
379
|
+
const setComposerValue = useCallback(
|
|
380
|
+
(next: string) => {
|
|
381
|
+
liveValueRef.current = next;
|
|
382
|
+
setRenderedValue(next);
|
|
383
|
+
delivery.setValue(next);
|
|
384
|
+
},
|
|
385
|
+
[delivery.setValue],
|
|
386
|
+
);
|
|
387
|
+
const visibleValue = deliveryChanged ? delivery.value : renderedValue;
|
|
388
|
+
|
|
389
|
+
useLayoutEffect(() => {
|
|
390
|
+
if (renderedValue !== liveValueRef.current) {
|
|
391
|
+
setRenderedValue(liveValueRef.current);
|
|
392
|
+
}
|
|
393
|
+
}, [delivery.value, renderedValue]);
|
|
370
394
|
|
|
371
395
|
useEffect(() => {
|
|
372
396
|
mountedRef.current = true;
|
|
@@ -468,7 +492,7 @@ export function useChatComposerController({
|
|
|
468
492
|
applyComposerTextareaHeight(textarea, 220);
|
|
469
493
|
});
|
|
470
494
|
}, []);
|
|
471
|
-
useEffect(() => resizeInput(), [
|
|
495
|
+
useEffect(() => resizeInput(), [resizeInput, visibleValue]);
|
|
472
496
|
useEffect(
|
|
473
497
|
() => () => {
|
|
474
498
|
if (resizeInputRafRef.current !== null) {
|
|
@@ -505,8 +529,8 @@ export function useChatComposerController({
|
|
|
505
529
|
commands,
|
|
506
530
|
context: commandContext,
|
|
507
531
|
handlers,
|
|
508
|
-
value:
|
|
509
|
-
setValue:
|
|
532
|
+
value: visibleValue,
|
|
533
|
+
setValue: setComposerValue,
|
|
510
534
|
});
|
|
511
535
|
const paletteEnabled = commandContext !== undefined;
|
|
512
536
|
const commandDraftBlocked = paletteEnabled && palette.isCommandDraft;
|
|
@@ -696,8 +720,8 @@ export function useChatComposerController({
|
|
|
696
720
|
handlePaste,
|
|
697
721
|
handleFileChange,
|
|
698
722
|
focusInput: () => textareaRef.current?.focus(),
|
|
699
|
-
setValue:
|
|
700
|
-
value:
|
|
723
|
+
setValue: setComposerValue,
|
|
724
|
+
value: visibleValue,
|
|
701
725
|
};
|
|
702
726
|
}
|
|
703
727
|
|