@liveblocks/react-ui 3.2.0 → 3.3.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/_private/index.cjs +4 -2
- package/dist/_private/index.cjs.map +1 -1
- package/dist/_private/index.d.cts +111 -38
- package/dist/_private/index.d.ts +111 -38
- package/dist/_private/index.js +3 -2
- package/dist/_private/index.js.map +1 -1
- package/dist/components/AiChat.cjs +11 -9
- package/dist/components/AiChat.cjs.map +1 -1
- package/dist/components/AiChat.js +12 -10
- package/dist/components/AiChat.js.map +1 -1
- package/dist/components/Thread.cjs +58 -0
- package/dist/components/Thread.cjs.map +1 -1
- package/dist/components/Thread.js +59 -1
- package/dist/components/Thread.js.map +1 -1
- package/dist/components/internal/AiComposer.cjs +132 -0
- package/dist/components/internal/AiComposer.cjs.map +1 -0
- package/dist/components/internal/AiComposer.js +130 -0
- package/dist/components/internal/AiComposer.js.map +1 -0
- package/dist/components/internal/Button.cjs.map +1 -1
- package/dist/components/internal/Button.js.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +123 -15
- package/dist/index.d.ts +123 -15
- package/dist/index.js.map +1 -1
- package/dist/overrides.cjs +4 -3
- package/dist/overrides.cjs.map +1 -1
- package/dist/overrides.js +4 -3
- package/dist/overrides.js.map +1 -1
- package/dist/primitives/AiComposer/contexts.cjs +24 -0
- package/dist/primitives/AiComposer/contexts.cjs.map +1 -0
- package/dist/primitives/AiComposer/contexts.js +19 -0
- package/dist/primitives/AiComposer/contexts.js.map +1 -0
- package/dist/primitives/AiComposer/index.cjs +348 -0
- package/dist/primitives/AiComposer/index.cjs.map +1 -0
- package/dist/primitives/AiComposer/index.js +340 -0
- package/dist/primitives/AiComposer/index.js.map +1 -0
- package/dist/primitives/Markdown.cjs +4 -3
- package/dist/primitives/Markdown.cjs.map +1 -1
- package/dist/primitives/Markdown.js +4 -3
- package/dist/primitives/Markdown.js.map +1 -1
- package/dist/primitives/index.d.cts +8 -1
- package/dist/primitives/index.d.ts +8 -1
- package/dist/version.cjs +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -4
- package/src/styles/index.css +37 -11
- package/styles.css +1 -1
- package/styles.css.map +1 -1
- package/dist/components/internal/AiChatComposer.cjs +0 -161
- package/dist/components/internal/AiChatComposer.cjs.map +0 -1
- package/dist/components/internal/AiChatComposer.js +0 -159
- package/dist/components/internal/AiChatComposer.js.map +0 -1
- package/dist/primitives/AiChatComposer/index.cjs +0 -202
- package/dist/primitives/AiChatComposer/index.cjs.map +0 -1
- package/dist/primitives/AiChatComposer/index.js +0 -195
- package/dist/primitives/AiChatComposer/index.js.map +0 -1
package/dist/_private/index.cjs
CHANGED
|
@@ -11,7 +11,8 @@ var capitalize = require('../utils/capitalize.cjs');
|
|
|
11
11
|
var cn = require('../utils/cn.cjs');
|
|
12
12
|
var useInitial = require('../utils/use-initial.cjs');
|
|
13
13
|
var useRefs = require('../utils/use-refs.cjs');
|
|
14
|
-
var index = require('../primitives/
|
|
14
|
+
var index = require('../primitives/AiComposer/index.cjs');
|
|
15
|
+
var contexts = require('../primitives/AiComposer/contexts.cjs');
|
|
15
16
|
var index$1 = require('../primitives/AiMessage/index.cjs');
|
|
16
17
|
var index$2 = require('../primitives/Collapsible/index.cjs');
|
|
17
18
|
var Markdown = require('../primitives/Markdown.cjs');
|
|
@@ -83,7 +84,8 @@ exports.capitalize = capitalize.capitalize;
|
|
|
83
84
|
exports.cn = cn.cn;
|
|
84
85
|
exports.useInitial = useInitial.useInitial;
|
|
85
86
|
exports.useRefs = useRefs.useRefs;
|
|
86
|
-
exports.
|
|
87
|
+
exports.AiComposer = index;
|
|
88
|
+
exports.useAiComposer = contexts.useAiComposer;
|
|
87
89
|
exports.AiMessage = index$1;
|
|
88
90
|
exports.Collapsible = index$2;
|
|
89
91
|
exports.Markdown = Markdown.Markdown;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as react from 'react';
|
|
3
3
|
import { ComponentProps, ReactNode, ElementType, ComponentPropsWithoutRef, ComponentType, Ref, RefCallback, FormEvent } from 'react';
|
|
4
|
+
import { Relax, AiTextPart, AiReasoningPart, AiChatMessage } from '@liveblocks/core';
|
|
4
5
|
import * as TooltipPrimitive from '@radix-ui/react-tooltip';
|
|
5
6
|
export { TooltipProvider } from '@radix-ui/react-tooltip';
|
|
6
|
-
import { AiTextPart, AiReasoningPart, AiChatMessage } from '@liveblocks/core';
|
|
7
7
|
|
|
8
8
|
interface AvatarProps extends ComponentProps<"div"> {
|
|
9
9
|
/**
|
|
@@ -14,7 +14,7 @@ interface AvatarProps extends ComponentProps<"div"> {
|
|
|
14
14
|
declare function Avatar({ userId, className, ...props }: AvatarProps): react_jsx_runtime.JSX.Element;
|
|
15
15
|
|
|
16
16
|
interface ButtonProps extends ComponentProps<"button"> {
|
|
17
|
-
variant?: "default" | "toolbar" | "outline" | "primary" | "secondary" | "destructive";
|
|
17
|
+
variant?: "default" | "toolbar" | "outline" | "ghost" | "primary" | "secondary" | "destructive";
|
|
18
18
|
size?: "default" | "large";
|
|
19
19
|
disableable?: boolean;
|
|
20
20
|
icon?: ReactNode;
|
|
@@ -22,6 +22,7 @@ interface ButtonProps extends ComponentProps<"button"> {
|
|
|
22
22
|
declare const Button: react.ForwardRefExoticComponent<Omit<ButtonProps, "ref"> & react.RefAttributes<HTMLButtonElement>>;
|
|
23
23
|
declare const SelectButton: react.ForwardRefExoticComponent<Omit<ButtonProps, "ref"> & react.RefAttributes<HTMLButtonElement>>;
|
|
24
24
|
|
|
25
|
+
type Direction = "ltr" | "rtl";
|
|
25
26
|
type SlotProp = {
|
|
26
27
|
/**
|
|
27
28
|
* Replace the rendered element by the one passed as a child.
|
|
@@ -183,10 +184,10 @@ type MarkdownComponents = {
|
|
|
183
184
|
* ```tsx
|
|
184
185
|
* <Markdown
|
|
185
186
|
* components={{
|
|
186
|
-
* List: ({ type, items }) => {
|
|
187
|
+
* List: ({ type, items, start }) => {
|
|
187
188
|
* const List = type === "ordered" ? "ol" : "ul";
|
|
188
189
|
* return (
|
|
189
|
-
* <List>
|
|
190
|
+
* <List start={start}>
|
|
190
191
|
* {items.map((item, index) => (
|
|
191
192
|
* <li key={index}>
|
|
192
193
|
* {item.checked !== undefined && (
|
|
@@ -273,8 +274,14 @@ interface MarkdownComponentsListItem {
|
|
|
273
274
|
checked?: boolean;
|
|
274
275
|
children: ReactNode;
|
|
275
276
|
}
|
|
276
|
-
|
|
277
|
-
|
|
277
|
+
type MarkdownComponentsListProps = Relax<MarkdownComponentsOrderedListProps | MarkdownComponentsUnorderedListProps>;
|
|
278
|
+
interface MarkdownComponentsOrderedListProps {
|
|
279
|
+
type: "ordered";
|
|
280
|
+
items: MarkdownComponentsListItem[];
|
|
281
|
+
start: number;
|
|
282
|
+
}
|
|
283
|
+
interface MarkdownComponentsUnorderedListProps {
|
|
284
|
+
type: "unordered";
|
|
278
285
|
items: MarkdownComponentsListItem[];
|
|
279
286
|
}
|
|
280
287
|
interface MarkdownComponentsBlockquoteProps {
|
|
@@ -459,22 +466,31 @@ declare function useInitial<T>(value: T | (() => T)): T;
|
|
|
459
466
|
|
|
460
467
|
declare function useRefs<T>(...refs: Ref<T>[]): RefCallback<T>;
|
|
461
468
|
|
|
462
|
-
interface
|
|
469
|
+
interface AiComposerSubmitMessage {
|
|
470
|
+
/**
|
|
471
|
+
* The submitted message text.
|
|
472
|
+
*/
|
|
473
|
+
text: string;
|
|
474
|
+
}
|
|
475
|
+
interface AiComposerFormProps extends ComponentPropsWithSlot<"form"> {
|
|
463
476
|
/**
|
|
464
|
-
* The
|
|
477
|
+
* The ID of the chat the composer belongs to.
|
|
465
478
|
*/
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
}, event: FormEvent<HTMLFormElement>) => void;
|
|
479
|
+
chatId?: string;
|
|
480
|
+
/**
|
|
481
|
+
* The event handler called when the composer is submitted.
|
|
482
|
+
*/
|
|
483
|
+
onComposerSubmit?: (message: AiComposerSubmitMessage, event: FormEvent<HTMLFormElement>) => Promise<void> | void;
|
|
472
484
|
/**
|
|
473
485
|
* Whether the composer is disabled.
|
|
474
486
|
*/
|
|
475
487
|
disabled?: boolean;
|
|
476
488
|
}
|
|
477
|
-
interface
|
|
489
|
+
interface AiComposerEditorProps extends Omit<ComponentPropsWithoutRef<"div">, "defaultValue" | "children"> {
|
|
490
|
+
/**
|
|
491
|
+
* The reading direction of the editor and related elements.
|
|
492
|
+
*/
|
|
493
|
+
dir?: Direction;
|
|
478
494
|
/**
|
|
479
495
|
* The editor's initial value.
|
|
480
496
|
*/
|
|
@@ -492,47 +508,104 @@ interface AiChatComposerEditorProps extends Omit<ComponentPropsWithoutRef<"div">
|
|
|
492
508
|
*/
|
|
493
509
|
autoFocus?: boolean;
|
|
494
510
|
}
|
|
495
|
-
type
|
|
511
|
+
type AiComposerSubmitProps = ComponentPropsWithSlot<"button">;
|
|
496
512
|
|
|
497
513
|
/**
|
|
498
|
-
* Surrounds the
|
|
514
|
+
* Surrounds the AI composer's content and handles submissions.
|
|
499
515
|
*
|
|
500
516
|
* @example
|
|
501
|
-
* <
|
|
502
|
-
* <
|
|
503
|
-
* <
|
|
504
|
-
* </
|
|
517
|
+
* <AiComposer.Form onComposerSubmit={({ text }) => {}}>
|
|
518
|
+
* <AiComposer.Editor />
|
|
519
|
+
* <AiComposer.Submit />
|
|
520
|
+
* </AiComposer.Form>
|
|
505
521
|
*/
|
|
506
|
-
declare const
|
|
522
|
+
declare const AiComposerForm: react.ForwardRefExoticComponent<AiComposerFormProps & react.RefAttributes<HTMLFormElement>>;
|
|
507
523
|
/**
|
|
508
|
-
* Displays the
|
|
524
|
+
* Displays the AI composer's editor.
|
|
509
525
|
*
|
|
510
526
|
* @example
|
|
511
|
-
* <
|
|
527
|
+
* <AiComposer.Editor placeholder="Write a message…" />
|
|
512
528
|
*/
|
|
513
|
-
declare const
|
|
529
|
+
declare const AiComposerEditor: react.ForwardRefExoticComponent<AiComposerEditorProps & react.RefAttributes<HTMLDivElement>>;
|
|
514
530
|
/**
|
|
515
|
-
* A button to submit
|
|
531
|
+
* A button to submit the AI composer's content.
|
|
516
532
|
*
|
|
517
533
|
* @example
|
|
518
|
-
* <
|
|
534
|
+
* <AiComposer.Submit>Send</AiComposer.Submit>
|
|
519
535
|
*/
|
|
520
|
-
declare const
|
|
536
|
+
declare const AiComposerSubmit: react.ForwardRefExoticComponent<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & SlotProp & react.RefAttributes<HTMLButtonElement>>;
|
|
537
|
+
/**
|
|
538
|
+
* A button to abort a response related to the AI composer.
|
|
539
|
+
*
|
|
540
|
+
* @example
|
|
541
|
+
* <AiComposer.Abort>Cancel</AiComposer.Abort>
|
|
542
|
+
*/
|
|
543
|
+
declare const AiComposerAbort: react.ForwardRefExoticComponent<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & SlotProp & react.RefAttributes<HTMLButtonElement>>;
|
|
521
544
|
|
|
522
|
-
declare const index$
|
|
523
|
-
declare const index$
|
|
524
|
-
declare const index$
|
|
545
|
+
declare const index$2_AiComposerAbort: typeof AiComposerAbort;
|
|
546
|
+
declare const index$2_AiComposerForm: typeof AiComposerForm;
|
|
547
|
+
declare const index$2_AiComposerSubmit: typeof AiComposerSubmit;
|
|
525
548
|
declare namespace index$2 {
|
|
526
549
|
export {
|
|
527
|
-
|
|
528
|
-
index$
|
|
529
|
-
index$
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
550
|
+
AiComposerAbort as Abort,
|
|
551
|
+
index$2_AiComposerAbort as AiComposerAbort,
|
|
552
|
+
index$2_AiComposerForm as AiComposerForm,
|
|
553
|
+
index$2_AiComposerSubmit as AiComposerSubmit,
|
|
554
|
+
AiComposerEditor as Editor,
|
|
555
|
+
AiComposerForm as Form,
|
|
556
|
+
AiComposerSubmit as Submit,
|
|
533
557
|
};
|
|
534
558
|
}
|
|
535
559
|
|
|
560
|
+
type AiComposerContext = {
|
|
561
|
+
/**
|
|
562
|
+
* Whether the composer is currently disabled.
|
|
563
|
+
*/
|
|
564
|
+
isDisabled: boolean;
|
|
565
|
+
/**
|
|
566
|
+
* Whether the composer can currently be submitted.
|
|
567
|
+
*/
|
|
568
|
+
canSubmit: boolean;
|
|
569
|
+
/**
|
|
570
|
+
* Whether the composer can currently abort a response in its related chat.
|
|
571
|
+
*/
|
|
572
|
+
canAbort: boolean;
|
|
573
|
+
/**
|
|
574
|
+
* Whether the editor is currently focused.
|
|
575
|
+
*/
|
|
576
|
+
isFocused: boolean;
|
|
577
|
+
/**
|
|
578
|
+
* Whether the editor is currently empty.
|
|
579
|
+
*/
|
|
580
|
+
isEmpty: boolean;
|
|
581
|
+
/**
|
|
582
|
+
* Submit the composer programmatically.
|
|
583
|
+
*/
|
|
584
|
+
submit: () => void;
|
|
585
|
+
/**
|
|
586
|
+
* Abort the composer's related response programmatically.
|
|
587
|
+
*/
|
|
588
|
+
abort: () => void;
|
|
589
|
+
/**
|
|
590
|
+
* Clear the composer programmatically.
|
|
591
|
+
*/
|
|
592
|
+
clear: () => void;
|
|
593
|
+
/**
|
|
594
|
+
* Select the editor programmatically.
|
|
595
|
+
*/
|
|
596
|
+
select: () => void;
|
|
597
|
+
/**
|
|
598
|
+
* Focus the editor programmatically.
|
|
599
|
+
*/
|
|
600
|
+
focus: () => void;
|
|
601
|
+
/**
|
|
602
|
+
* Blur the editor programmatically.
|
|
603
|
+
*/
|
|
604
|
+
blur: () => void;
|
|
605
|
+
};
|
|
606
|
+
declare const AiComposerContext: react.Context<AiComposerContext | null>;
|
|
607
|
+
declare function useAiComposer(): AiComposerContext;
|
|
608
|
+
|
|
536
609
|
type AiMessageContentTextPartProps = {
|
|
537
610
|
part: AiTextPart;
|
|
538
611
|
};
|
|
@@ -599,4 +672,4 @@ declare namespace index {
|
|
|
599
672
|
};
|
|
600
673
|
}
|
|
601
674
|
|
|
602
|
-
export { index$2 as
|
|
675
|
+
export { index$2 as AiComposer, AiComposerEditorProps, AiComposerFormProps, AiComposerSubmitProps, index$1 as AiMessage, AiMessageContentComponents, AiMessageContentProps, AiMessageContentReasoningPartProps, AiMessageContentTextPartProps, ArrowCornerDownRightIcon, ArrowCornerUpRightIcon, ArrowDownIcon, ArrowUpIcon, AttachmentIcon, Avatar, BellCrossedIcon, BellIcon, BlockquoteIcon, BoldIcon, Button, CheckCircleFillIcon, CheckCircleIcon, CheckIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ChevronUpIcon, CodeIcon, index as Collapsible, CommentIcon, CopyIcon, CrossCircleFillIcon, CrossIcon, DeleteIcon, EditIcon, EllipsisIcon, EmojiIcon, EmojiPlusIcon, H1Icon, H2Icon, H3Icon, ItalicIcon, LengthenIcon, List, ListOrderedIcon, ListUnorderedIcon, Markdown, MarkdownComponents, MarkdownComponentsBlockquoteProps, MarkdownComponentsCodeBlockProps, MarkdownComponentsHeadingProps, MarkdownComponentsImageProps, MarkdownComponentsInlineProps, MarkdownComponentsLinkProps, MarkdownComponentsListProps, MarkdownComponentsParagraphProps, MarkdownComponentsTableProps, MarkdownProps, MentionIcon, MinusCircleIcon, Prose, QuestionMarkIcon, RedoIcon, RestoreIcon, RetryIcon, SearchIcon, SelectButton, SendIcon, ShortcutTooltip, ShortenIcon, SparklesIcon, SparklesTextIcon, SpinnerIcon, StopIcon, StrikethroughIcon, TextIcon, Tooltip, TranslateIcon, UnderlineIcon, UndoIcon, User, WarningIcon, capitalize, cn, useAiComposer, useInitial, useRefs };
|
package/dist/_private/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as react from 'react';
|
|
3
3
|
import { ComponentProps, ReactNode, ElementType, ComponentPropsWithoutRef, ComponentType, Ref, RefCallback, FormEvent } from 'react';
|
|
4
|
+
import { Relax, AiTextPart, AiReasoningPart, AiChatMessage } from '@liveblocks/core';
|
|
4
5
|
import * as TooltipPrimitive from '@radix-ui/react-tooltip';
|
|
5
6
|
export { TooltipProvider } from '@radix-ui/react-tooltip';
|
|
6
|
-
import { AiTextPart, AiReasoningPart, AiChatMessage } from '@liveblocks/core';
|
|
7
7
|
|
|
8
8
|
interface AvatarProps extends ComponentProps<"div"> {
|
|
9
9
|
/**
|
|
@@ -14,7 +14,7 @@ interface AvatarProps extends ComponentProps<"div"> {
|
|
|
14
14
|
declare function Avatar({ userId, className, ...props }: AvatarProps): react_jsx_runtime.JSX.Element;
|
|
15
15
|
|
|
16
16
|
interface ButtonProps extends ComponentProps<"button"> {
|
|
17
|
-
variant?: "default" | "toolbar" | "outline" | "primary" | "secondary" | "destructive";
|
|
17
|
+
variant?: "default" | "toolbar" | "outline" | "ghost" | "primary" | "secondary" | "destructive";
|
|
18
18
|
size?: "default" | "large";
|
|
19
19
|
disableable?: boolean;
|
|
20
20
|
icon?: ReactNode;
|
|
@@ -22,6 +22,7 @@ interface ButtonProps extends ComponentProps<"button"> {
|
|
|
22
22
|
declare const Button: react.ForwardRefExoticComponent<Omit<ButtonProps, "ref"> & react.RefAttributes<HTMLButtonElement>>;
|
|
23
23
|
declare const SelectButton: react.ForwardRefExoticComponent<Omit<ButtonProps, "ref"> & react.RefAttributes<HTMLButtonElement>>;
|
|
24
24
|
|
|
25
|
+
type Direction = "ltr" | "rtl";
|
|
25
26
|
type SlotProp = {
|
|
26
27
|
/**
|
|
27
28
|
* Replace the rendered element by the one passed as a child.
|
|
@@ -183,10 +184,10 @@ type MarkdownComponents = {
|
|
|
183
184
|
* ```tsx
|
|
184
185
|
* <Markdown
|
|
185
186
|
* components={{
|
|
186
|
-
* List: ({ type, items }) => {
|
|
187
|
+
* List: ({ type, items, start }) => {
|
|
187
188
|
* const List = type === "ordered" ? "ol" : "ul";
|
|
188
189
|
* return (
|
|
189
|
-
* <List>
|
|
190
|
+
* <List start={start}>
|
|
190
191
|
* {items.map((item, index) => (
|
|
191
192
|
* <li key={index}>
|
|
192
193
|
* {item.checked !== undefined && (
|
|
@@ -273,8 +274,14 @@ interface MarkdownComponentsListItem {
|
|
|
273
274
|
checked?: boolean;
|
|
274
275
|
children: ReactNode;
|
|
275
276
|
}
|
|
276
|
-
|
|
277
|
-
|
|
277
|
+
type MarkdownComponentsListProps = Relax<MarkdownComponentsOrderedListProps | MarkdownComponentsUnorderedListProps>;
|
|
278
|
+
interface MarkdownComponentsOrderedListProps {
|
|
279
|
+
type: "ordered";
|
|
280
|
+
items: MarkdownComponentsListItem[];
|
|
281
|
+
start: number;
|
|
282
|
+
}
|
|
283
|
+
interface MarkdownComponentsUnorderedListProps {
|
|
284
|
+
type: "unordered";
|
|
278
285
|
items: MarkdownComponentsListItem[];
|
|
279
286
|
}
|
|
280
287
|
interface MarkdownComponentsBlockquoteProps {
|
|
@@ -459,22 +466,31 @@ declare function useInitial<T>(value: T | (() => T)): T;
|
|
|
459
466
|
|
|
460
467
|
declare function useRefs<T>(...refs: Ref<T>[]): RefCallback<T>;
|
|
461
468
|
|
|
462
|
-
interface
|
|
469
|
+
interface AiComposerSubmitMessage {
|
|
470
|
+
/**
|
|
471
|
+
* The submitted message text.
|
|
472
|
+
*/
|
|
473
|
+
text: string;
|
|
474
|
+
}
|
|
475
|
+
interface AiComposerFormProps extends ComponentPropsWithSlot<"form"> {
|
|
463
476
|
/**
|
|
464
|
-
* The
|
|
477
|
+
* The ID of the chat the composer belongs to.
|
|
465
478
|
*/
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
}, event: FormEvent<HTMLFormElement>) => void;
|
|
479
|
+
chatId?: string;
|
|
480
|
+
/**
|
|
481
|
+
* The event handler called when the composer is submitted.
|
|
482
|
+
*/
|
|
483
|
+
onComposerSubmit?: (message: AiComposerSubmitMessage, event: FormEvent<HTMLFormElement>) => Promise<void> | void;
|
|
472
484
|
/**
|
|
473
485
|
* Whether the composer is disabled.
|
|
474
486
|
*/
|
|
475
487
|
disabled?: boolean;
|
|
476
488
|
}
|
|
477
|
-
interface
|
|
489
|
+
interface AiComposerEditorProps extends Omit<ComponentPropsWithoutRef<"div">, "defaultValue" | "children"> {
|
|
490
|
+
/**
|
|
491
|
+
* The reading direction of the editor and related elements.
|
|
492
|
+
*/
|
|
493
|
+
dir?: Direction;
|
|
478
494
|
/**
|
|
479
495
|
* The editor's initial value.
|
|
480
496
|
*/
|
|
@@ -492,47 +508,104 @@ interface AiChatComposerEditorProps extends Omit<ComponentPropsWithoutRef<"div">
|
|
|
492
508
|
*/
|
|
493
509
|
autoFocus?: boolean;
|
|
494
510
|
}
|
|
495
|
-
type
|
|
511
|
+
type AiComposerSubmitProps = ComponentPropsWithSlot<"button">;
|
|
496
512
|
|
|
497
513
|
/**
|
|
498
|
-
* Surrounds the
|
|
514
|
+
* Surrounds the AI composer's content and handles submissions.
|
|
499
515
|
*
|
|
500
516
|
* @example
|
|
501
|
-
* <
|
|
502
|
-
* <
|
|
503
|
-
* <
|
|
504
|
-
* </
|
|
517
|
+
* <AiComposer.Form onComposerSubmit={({ text }) => {}}>
|
|
518
|
+
* <AiComposer.Editor />
|
|
519
|
+
* <AiComposer.Submit />
|
|
520
|
+
* </AiComposer.Form>
|
|
505
521
|
*/
|
|
506
|
-
declare const
|
|
522
|
+
declare const AiComposerForm: react.ForwardRefExoticComponent<AiComposerFormProps & react.RefAttributes<HTMLFormElement>>;
|
|
507
523
|
/**
|
|
508
|
-
* Displays the
|
|
524
|
+
* Displays the AI composer's editor.
|
|
509
525
|
*
|
|
510
526
|
* @example
|
|
511
|
-
* <
|
|
527
|
+
* <AiComposer.Editor placeholder="Write a message…" />
|
|
512
528
|
*/
|
|
513
|
-
declare const
|
|
529
|
+
declare const AiComposerEditor: react.ForwardRefExoticComponent<AiComposerEditorProps & react.RefAttributes<HTMLDivElement>>;
|
|
514
530
|
/**
|
|
515
|
-
* A button to submit
|
|
531
|
+
* A button to submit the AI composer's content.
|
|
516
532
|
*
|
|
517
533
|
* @example
|
|
518
|
-
* <
|
|
534
|
+
* <AiComposer.Submit>Send</AiComposer.Submit>
|
|
519
535
|
*/
|
|
520
|
-
declare const
|
|
536
|
+
declare const AiComposerSubmit: react.ForwardRefExoticComponent<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & SlotProp & react.RefAttributes<HTMLButtonElement>>;
|
|
537
|
+
/**
|
|
538
|
+
* A button to abort a response related to the AI composer.
|
|
539
|
+
*
|
|
540
|
+
* @example
|
|
541
|
+
* <AiComposer.Abort>Cancel</AiComposer.Abort>
|
|
542
|
+
*/
|
|
543
|
+
declare const AiComposerAbort: react.ForwardRefExoticComponent<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & SlotProp & react.RefAttributes<HTMLButtonElement>>;
|
|
521
544
|
|
|
522
|
-
declare const index$
|
|
523
|
-
declare const index$
|
|
524
|
-
declare const index$
|
|
545
|
+
declare const index$2_AiComposerAbort: typeof AiComposerAbort;
|
|
546
|
+
declare const index$2_AiComposerForm: typeof AiComposerForm;
|
|
547
|
+
declare const index$2_AiComposerSubmit: typeof AiComposerSubmit;
|
|
525
548
|
declare namespace index$2 {
|
|
526
549
|
export {
|
|
527
|
-
|
|
528
|
-
index$
|
|
529
|
-
index$
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
550
|
+
AiComposerAbort as Abort,
|
|
551
|
+
index$2_AiComposerAbort as AiComposerAbort,
|
|
552
|
+
index$2_AiComposerForm as AiComposerForm,
|
|
553
|
+
index$2_AiComposerSubmit as AiComposerSubmit,
|
|
554
|
+
AiComposerEditor as Editor,
|
|
555
|
+
AiComposerForm as Form,
|
|
556
|
+
AiComposerSubmit as Submit,
|
|
533
557
|
};
|
|
534
558
|
}
|
|
535
559
|
|
|
560
|
+
type AiComposerContext = {
|
|
561
|
+
/**
|
|
562
|
+
* Whether the composer is currently disabled.
|
|
563
|
+
*/
|
|
564
|
+
isDisabled: boolean;
|
|
565
|
+
/**
|
|
566
|
+
* Whether the composer can currently be submitted.
|
|
567
|
+
*/
|
|
568
|
+
canSubmit: boolean;
|
|
569
|
+
/**
|
|
570
|
+
* Whether the composer can currently abort a response in its related chat.
|
|
571
|
+
*/
|
|
572
|
+
canAbort: boolean;
|
|
573
|
+
/**
|
|
574
|
+
* Whether the editor is currently focused.
|
|
575
|
+
*/
|
|
576
|
+
isFocused: boolean;
|
|
577
|
+
/**
|
|
578
|
+
* Whether the editor is currently empty.
|
|
579
|
+
*/
|
|
580
|
+
isEmpty: boolean;
|
|
581
|
+
/**
|
|
582
|
+
* Submit the composer programmatically.
|
|
583
|
+
*/
|
|
584
|
+
submit: () => void;
|
|
585
|
+
/**
|
|
586
|
+
* Abort the composer's related response programmatically.
|
|
587
|
+
*/
|
|
588
|
+
abort: () => void;
|
|
589
|
+
/**
|
|
590
|
+
* Clear the composer programmatically.
|
|
591
|
+
*/
|
|
592
|
+
clear: () => void;
|
|
593
|
+
/**
|
|
594
|
+
* Select the editor programmatically.
|
|
595
|
+
*/
|
|
596
|
+
select: () => void;
|
|
597
|
+
/**
|
|
598
|
+
* Focus the editor programmatically.
|
|
599
|
+
*/
|
|
600
|
+
focus: () => void;
|
|
601
|
+
/**
|
|
602
|
+
* Blur the editor programmatically.
|
|
603
|
+
*/
|
|
604
|
+
blur: () => void;
|
|
605
|
+
};
|
|
606
|
+
declare const AiComposerContext: react.Context<AiComposerContext | null>;
|
|
607
|
+
declare function useAiComposer(): AiComposerContext;
|
|
608
|
+
|
|
536
609
|
type AiMessageContentTextPartProps = {
|
|
537
610
|
part: AiTextPart;
|
|
538
611
|
};
|
|
@@ -599,4 +672,4 @@ declare namespace index {
|
|
|
599
672
|
};
|
|
600
673
|
}
|
|
601
674
|
|
|
602
|
-
export { index$2 as
|
|
675
|
+
export { index$2 as AiComposer, AiComposerEditorProps, AiComposerFormProps, AiComposerSubmitProps, index$1 as AiMessage, AiMessageContentComponents, AiMessageContentProps, AiMessageContentReasoningPartProps, AiMessageContentTextPartProps, ArrowCornerDownRightIcon, ArrowCornerUpRightIcon, ArrowDownIcon, ArrowUpIcon, AttachmentIcon, Avatar, BellCrossedIcon, BellIcon, BlockquoteIcon, BoldIcon, Button, CheckCircleFillIcon, CheckCircleIcon, CheckIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ChevronUpIcon, CodeIcon, index as Collapsible, CommentIcon, CopyIcon, CrossCircleFillIcon, CrossIcon, DeleteIcon, EditIcon, EllipsisIcon, EmojiIcon, EmojiPlusIcon, H1Icon, H2Icon, H3Icon, ItalicIcon, LengthenIcon, List, ListOrderedIcon, ListUnorderedIcon, Markdown, MarkdownComponents, MarkdownComponentsBlockquoteProps, MarkdownComponentsCodeBlockProps, MarkdownComponentsHeadingProps, MarkdownComponentsImageProps, MarkdownComponentsInlineProps, MarkdownComponentsLinkProps, MarkdownComponentsListProps, MarkdownComponentsParagraphProps, MarkdownComponentsTableProps, MarkdownProps, MentionIcon, MinusCircleIcon, Prose, QuestionMarkIcon, RedoIcon, RestoreIcon, RetryIcon, SearchIcon, SelectButton, SendIcon, ShortcutTooltip, ShortenIcon, SparklesIcon, SparklesTextIcon, SpinnerIcon, StopIcon, StrikethroughIcon, TextIcon, Tooltip, TranslateIcon, UnderlineIcon, UndoIcon, User, WarningIcon, capitalize, cn, useAiComposer, useInitial, useRefs };
|
package/dist/_private/index.js
CHANGED
|
@@ -9,8 +9,9 @@ export { capitalize } from '../utils/capitalize.js';
|
|
|
9
9
|
export { cn } from '../utils/cn.js';
|
|
10
10
|
export { useInitial } from '../utils/use-initial.js';
|
|
11
11
|
export { useRefs } from '../utils/use-refs.js';
|
|
12
|
-
import * as index from '../primitives/
|
|
13
|
-
export { index as
|
|
12
|
+
import * as index from '../primitives/AiComposer/index.js';
|
|
13
|
+
export { index as AiComposer };
|
|
14
|
+
export { useAiComposer } from '../primitives/AiComposer/contexts.js';
|
|
14
15
|
import * as index$1 from '../primitives/AiMessage/index.js';
|
|
15
16
|
export { index$1 as AiMessage };
|
|
16
17
|
import * as index$2 from '../primitives/Collapsible/index.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -10,8 +10,8 @@ var overrides = require('../overrides.cjs');
|
|
|
10
10
|
var cn = require('../utils/cn.cjs');
|
|
11
11
|
var useVisible = require('../utils/use-visible.cjs');
|
|
12
12
|
var AiChatAssistantMessage = require('./internal/AiChatAssistantMessage.cjs');
|
|
13
|
-
var AiChatComposer = require('./internal/AiChatComposer.cjs');
|
|
14
13
|
var AiChatUserMessage = require('./internal/AiChatUserMessage.cjs');
|
|
14
|
+
var AiComposer = require('./internal/AiComposer.cjs');
|
|
15
15
|
|
|
16
16
|
const MIN_DISTANCE_BOTTOM_SCROLL_INDICATOR = 60;
|
|
17
17
|
const defaultComponents = {
|
|
@@ -177,8 +177,9 @@ const AiChat = react.forwardRef(
|
|
|
177
177
|
copilotId,
|
|
178
178
|
autoFocus,
|
|
179
179
|
overrides: overrides$1,
|
|
180
|
-
knowledge,
|
|
180
|
+
knowledge: localKnowledge,
|
|
181
181
|
tools = {},
|
|
182
|
+
onComposerSubmit,
|
|
182
183
|
layout = "inset",
|
|
183
184
|
components,
|
|
184
185
|
className,
|
|
@@ -231,10 +232,6 @@ const AiChat = react.forwardRef(
|
|
|
231
232
|
className
|
|
232
233
|
),
|
|
233
234
|
children: [
|
|
234
|
-
knowledge ? knowledge.map((source, index) => /* @__PURE__ */ jsxRuntime.jsx(react$1.RegisterAiKnowledge, {
|
|
235
|
-
description: source.description,
|
|
236
|
-
value: source.value
|
|
237
|
-
}, index)) : null,
|
|
238
235
|
Object.entries(tools).map(([name, tool]) => /* @__PURE__ */ jsxRuntime.jsx(react$1.RegisterAiTool, {
|
|
239
236
|
chatId,
|
|
240
237
|
name,
|
|
@@ -297,13 +294,18 @@ const AiChat = react.forwardRef(
|
|
|
297
294
|
})
|
|
298
295
|
})
|
|
299
296
|
}),
|
|
300
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
297
|
+
/* @__PURE__ */ jsxRuntime.jsx(AiComposer.AiComposer, {
|
|
301
298
|
chatId,
|
|
302
299
|
copilotId,
|
|
303
300
|
overrides: overrides$1,
|
|
304
301
|
autoFocus,
|
|
305
|
-
|
|
306
|
-
|
|
302
|
+
knowledge: localKnowledge,
|
|
303
|
+
onComposerSubmit,
|
|
304
|
+
onComposerSubmitted: ({ id }) => setLastSentMessageId(id),
|
|
305
|
+
className: cn.cn(
|
|
306
|
+
"lb-ai-chat-composer",
|
|
307
|
+
layout === "inset" ? "lb-elevation lb-elevation-moderate" : void 0
|
|
308
|
+
)
|
|
307
309
|
}, chatId)
|
|
308
310
|
]
|
|
309
311
|
}),
|