@bdocs/plugin-ask-ai 0.3.0 → 0.3.1

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.
@@ -1,9 +1,10 @@
1
1
  import * as _$react from "react";
2
- import * as _$react_jsx_runtime0 from "react/jsx-runtime";
2
+ import { Ref } from "react";
3
3
 
4
4
  //#region src/client/use-ask-ai.d.ts
5
- type MessageStatus = 'reading' | 'streaming' | 'done' | 'error';
5
+ type MessageStatus = 'reading' | 'streaming' | 'done' | 'cancelled' | 'error';
6
6
  interface Message {
7
+ id?: string;
7
8
  role: 'user' | 'assistant';
8
9
  content: string;
9
10
  status?: MessageStatus;
@@ -23,9 +24,39 @@ interface Message {
23
24
  };
24
25
  errorMessage?: string;
25
26
  }
27
+ interface AskAiClassNames {
28
+ root?: string;
29
+ panel?: string;
30
+ trigger?: string;
31
+ header?: string;
32
+ messages?: string;
33
+ message?: string;
34
+ userMessage?: string;
35
+ assistantMessage?: string;
36
+ emptyState?: string;
37
+ composer?: string;
38
+ input?: string;
39
+ markdown?: string;
40
+ }
41
+ interface AskAiPageContext {
42
+ page: string;
43
+ content: string;
44
+ }
26
45
  interface UseAskAiOptions {
27
46
  endpoint?: string;
28
47
  currentPage?: string;
48
+ context?: AskAiPageContext;
49
+ getContext?: () => AskAiPageContext | null;
50
+ classNames?: Partial<AskAiClassNames>;
51
+ }
52
+ /** User-facing copy for the widget, configurable via plugin options. */
53
+ interface AskAiUiCopy {
54
+ title: string;
55
+ placeholder: string;
56
+ emptyTitle: string;
57
+ emptyDescription: string;
58
+ buttonTooltip: string;
59
+ composerHint: string;
29
60
  }
30
61
  declare function useAskAi(options?: UseAskAiOptions): {
31
62
  messages: Message[];
@@ -38,13 +69,115 @@ declare function useAskAi(options?: UseAskAiOptions): {
38
69
  isOpen: boolean;
39
70
  setIsOpen: _$react.Dispatch<_$react.SetStateAction<boolean>>;
40
71
  devMode: boolean;
72
+ ui: AskAiUiCopy;
73
+ classNames: AskAiClassNames;
41
74
  };
42
75
  //#endregion
43
76
  //#region src/client/components/ask-ai-bubble.d.ts
44
- declare function AskAiBubble(): _$react_jsx_runtime0.JSX.Element;
77
+ interface AskAiBubbleProps extends UseAskAiOptions {}
78
+ declare function AskAiBubble(props?: AskAiBubbleProps): _$react.JSX.Element;
45
79
  //#endregion
46
80
  //#region src/client/components/ask-ai-dialog.d.ts
47
- declare function AskAiDialog(): _$react_jsx_runtime0.JSX.Element | null;
81
+ interface AskAiDialogProps extends UseAskAiOptions {}
82
+ declare function AskAiDialog(props?: AskAiDialogProps): _$react.JSX.Element;
83
+ //#endregion
84
+ //#region src/client/components/chat-header.d.ts
85
+ type ChatVariant = 'bubble' | 'dialog';
86
+ interface ChatHeaderProps {
87
+ title: string;
88
+ variant?: ChatVariant;
89
+ canClear: boolean;
90
+ onClear?: () => void;
91
+ onClose: () => void;
92
+ className?: string;
93
+ titleId?: string;
94
+ }
95
+ declare function ChatHeader({
96
+ title,
97
+ variant,
98
+ canClear,
99
+ onClear,
100
+ onClose,
101
+ className,
102
+ titleId
103
+ }: ChatHeaderProps): _$react.JSX.Element;
104
+ //#endregion
105
+ //#region src/client/components/chat-input.d.ts
106
+ interface ChatInputProps {
107
+ input: string;
108
+ onInputChange: (value: string) => void;
109
+ onSubmit: (value: string) => void;
110
+ onStop: () => void;
111
+ isLoading: boolean;
112
+ placeholder?: string;
113
+ hint?: string;
114
+ variant?: ChatVariant;
115
+ inputRef?: Ref<HTMLTextAreaElement>;
116
+ className?: string;
117
+ inputClassName?: string;
118
+ }
119
+ declare function ChatInput({
120
+ input,
121
+ onInputChange,
122
+ onSubmit,
123
+ onStop,
124
+ isLoading,
125
+ placeholder,
126
+ hint,
127
+ variant,
128
+ inputRef,
129
+ className,
130
+ inputClassName
131
+ }: ChatInputProps): _$react.JSX.Element;
132
+ //#endregion
133
+ //#region src/client/components/chat-message.d.ts
134
+ interface ChatMessageProps {
135
+ message: Message;
136
+ variant?: ChatVariant;
137
+ devMode: boolean;
138
+ className?: string;
139
+ userClassName?: string;
140
+ assistantClassName?: string;
141
+ markdownClassName?: string;
142
+ }
143
+ declare function ChatMessageImpl({
144
+ message: msg,
145
+ variant,
146
+ devMode,
147
+ className,
148
+ userClassName,
149
+ assistantClassName,
150
+ markdownClassName
151
+ }: ChatMessageProps): _$react.JSX.Element;
152
+ /**
153
+ * Memoized so that during streaming only the message whose content actually
154
+ * changed re-renders. The hook structurally shares the array and replaces the
155
+ * final assistant message with a new object, so all older siblings keep their
156
+ * identity and are skipped by the default shallow comparison.
157
+ */
158
+ declare const ChatMessage: _$react.MemoExoticComponent<typeof ChatMessageImpl>;
159
+ //#endregion
160
+ //#region src/client/components/chat-empty-state.d.ts
161
+ interface ChatEmptyStateProps {
162
+ description: string;
163
+ title?: string;
164
+ variant?: ChatVariant;
165
+ className?: string;
166
+ }
167
+ declare function ChatEmptyState({
168
+ description,
169
+ title,
170
+ variant,
171
+ className
172
+ }: ChatEmptyStateProps): _$react.JSX.Element;
173
+ //#endregion
174
+ //#region src/client/components/typing-indicator.d.ts
175
+ interface TypingIndicatorProps {
176
+ label?: string;
177
+ }
178
+ declare function TypingIndicator({
179
+ label
180
+ }: TypingIndicatorProps): _$react.JSX.Element;
48
181
  //#endregion
49
182
  //#region src/client/render-markdown.d.ts
50
183
  interface MarkdownRendererProps {
@@ -52,13 +185,16 @@ interface MarkdownRendererProps {
52
185
  className?: string;
53
186
  parseIncompleteMarkdown?: boolean;
54
187
  }
55
- declare function MarkdownRenderer({
188
+ declare function MarkdownRendererImpl({
56
189
  content,
57
190
  className,
58
191
  parseIncompleteMarkdown
59
- }: MarkdownRendererProps): _$react_jsx_runtime0.JSX.Element | null;
60
- //#endregion
61
- //#region src/client/index.d.ts
62
- declare const _default: any;
192
+ }: MarkdownRendererProps): _$react.JSX.Element;
193
+ /**
194
+ * Memoized: while the message streams the same buffered content can be
195
+ * re-rendered (e.g. a status flip reading → streaming) — this skips the
196
+ * heavy markdown re-parse when nothing changed.
197
+ */
198
+ declare const MarkdownRenderer: _$react.MemoExoticComponent<typeof MarkdownRendererImpl>;
63
199
  //#endregion
64
- export { AskAiBubble, AskAiDialog, MarkdownRenderer, type Message, type MessageStatus, type UseAskAiOptions, _default as default, useAskAi };
200
+ export { AskAiBubble, type AskAiBubbleProps, type AskAiClassNames, AskAiDialog, type AskAiDialogProps, type AskAiUiCopy, ChatEmptyState, ChatHeader, type ChatHeaderProps, ChatInput, ChatMessage, type ChatMessageProps, type ChatVariant, MarkdownRenderer, type Message, type MessageStatus, TypingIndicator, type UseAskAiOptions, useAskAi };