devnonla-ui 0.18.1 → 0.19.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "devnonla-ui",
3
- "version": "0.18.1",
3
+ "version": "0.19.1",
4
4
  "type": "module",
5
5
  "description": "NonlaUI — React controls for Nonla Agents",
6
6
  "author": "devlangla <devlangla0x01@gmail.com>",
@@ -32,7 +32,7 @@
32
32
  ],
33
33
  "scripts": {
34
34
  "typecheck": "tsc --noEmit",
35
- "docs": "bun --cwd docs run dev"
35
+ "docs": "cd docs && bun run dev"
36
36
  },
37
37
  "peerDependencies": {
38
38
  "react": ">=19",
@@ -1,4 +1,4 @@
1
- import { type ReactNode, useEffect, useLayoutEffect } from "react";
1
+ import { type ReactNode, type Ref, useEffect, useLayoutEffect } from "react";
2
2
  import { cn } from "../lib/cn";
3
3
  import { type MarkdownComponents, MarkdownComponentsProvider } from "../markdown-editor/MarkdownViewer";
4
4
  import { OverlayScroll, type OverlayScrollVisibility } from "../scroll/OverlayScroll";
@@ -9,7 +9,8 @@ import {
9
9
  type AgentChatSendRequest,
10
10
  useAgentChatStream,
11
11
  } from "./common/useAgentChatStream";
12
- import { ChatInput } from "./message-ui/ChatInput";
12
+ import { ChatInput, type ChatInputHandle } from "./message-ui/ChatInput";
13
+ import type { ChatTrigger } from "./message-ui/ChatSuggestions";
13
14
  import { ChatWelcome } from "./message-ui/ChatWelcome";
14
15
  import type { AgentToolUI } from "./tool-ui/registry";
15
16
 
@@ -30,6 +31,10 @@ export type AgentChatboxProps = {
30
31
  starters?: string[];
31
32
  placeholder?: string;
32
33
  toolbar?: ReactNode;
34
+ /** Markers that open a composer menu, e.g. `/` and `@`. Each `menu` is a React node. */
35
+ triggers?: ChatTrigger[];
36
+ /** Imperative composer handle, e.g. `insertChip` to add a text selection as context. */
37
+ inputRef?: Ref<ChatInputHandle>;
33
38
  toolUis?: AgentToolUI[];
34
39
  /** Fence language → component for assistant markdown (`step`, `subagent`, `mindmap`). */
35
40
  components?: MarkdownComponents;
@@ -53,6 +58,8 @@ export function AgentChatbox({
53
58
  starters,
54
59
  placeholder = "Message…",
55
60
  toolbar,
61
+ triggers,
62
+ inputRef,
56
63
  toolUis,
57
64
  components,
58
65
  toolHooks,
@@ -109,7 +116,7 @@ export function AgentChatbox({
109
116
  <div className="relative shrink-0">
110
117
  {accessory}
111
118
  <div className="mx-auto w-full max-w-200">
112
- <ChatInput generating={generating} placeholder={placeholder} onSend={sendMessage} onCancel={cancel} toolbar={toolbar} enableTypeToFocus />
119
+ <ChatInput inputRef={inputRef} generating={generating} placeholder={placeholder} onSend={sendMessage} onCancel={cancel} toolbar={toolbar} triggers={triggers} enableTypeToFocus />
113
120
  </div>
114
121
  </div>
115
122
  </div>
@@ -1,11 +1,12 @@
1
- import { type ReactNode, useEffect, useLayoutEffect, useState } from "react";
1
+ import { type ReactNode, type Ref, useEffect, useLayoutEffect, useState } from "react";
2
2
  import { cn } from "../lib/cn";
3
3
  import { type MarkdownComponents, MarkdownComponentsProvider } from "../markdown-editor/MarkdownViewer";
4
4
  import { OverlayScroll, type OverlayScrollVisibility } from "../scroll/OverlayScroll";
5
5
  import { AgentMessageList, activityStatus, useStickToBottom } from "./chatMessageList";
6
6
  import type { AgentMessage, AgentPanelEndpoint, AgentToolHook } from "./common/types";
7
7
  import { useAgentStream } from "./common/useAgentStream";
8
- import { ChatInput } from "./message-ui/ChatInput";
8
+ import { ChatInput, type ChatInputHandle } from "./message-ui/ChatInput";
9
+ import type { ChatTrigger } from "./message-ui/ChatSuggestions";
9
10
  import { ChatWelcome } from "./message-ui/ChatWelcome";
10
11
  import type { AgentToolUI } from "./tool-ui/registry";
11
12
 
@@ -26,6 +27,10 @@ export type AgentPanelProps = {
26
27
  initialMessages?: AgentMessage[];
27
28
  /** Custom node in the composer toolbar (model picker, tools, …). */
28
29
  toolbar?: ReactNode;
30
+ /** Markers that open a composer menu, e.g. `/` and `@`. Each `menu` is a React node. */
31
+ triggers?: ChatTrigger[];
32
+ /** Imperative composer handle, e.g. `insertChip` to add a text selection as context. */
33
+ inputRef?: Ref<ChatInputHandle>;
29
34
  /** Extra tool cards keyed by stream `toolName`. Checked before builtins. */
30
35
  toolUis?: AgentToolUI[];
31
36
  /** Fence language → component for assistant markdown (`step`, `subagent`, `mindmap`). */
@@ -53,6 +58,8 @@ export function AgentPanel({
53
58
  fetcher,
54
59
  initialMessages,
55
60
  toolbar,
61
+ triggers,
62
+ inputRef,
56
63
  toolUis,
57
64
  components,
58
65
  toolHooks,
@@ -116,7 +123,7 @@ export function AgentPanel({
116
123
  <div className="relative shrink-0">
117
124
  {accessory}
118
125
  <div className="mx-auto w-full max-w-200">
119
- <ChatInput generating={generating} placeholder={placeholder} onSend={sendMessage} onCancel={cancel} onClear={handleNewChat} toolbar={toolbar} focusSignal={String(epoch)} enableTypeToFocus />
126
+ <ChatInput inputRef={inputRef} generating={generating} placeholder={placeholder} onSend={sendMessage} onCancel={cancel} onClear={handleNewChat} toolbar={toolbar} triggers={triggers} focusSignal={String(epoch)} enableTypeToFocus />
120
127
  </div>
121
128
  </div>
122
129
  </div>
package/src/chat/index.ts CHANGED
@@ -17,11 +17,13 @@ export type { ChatAgentMessageProps } from "./message-ui/ChatAgentMessage";
17
17
  export { ChatAgentMessage } from "./message-ui/ChatAgentMessage";
18
18
  export type { ChatErrorProps } from "./message-ui/ChatError";
19
19
  export { ChatError } from "./message-ui/ChatError";
20
- export type { ChatInputProps } from "./message-ui/ChatInput";
20
+ export type { ChatChip, ChatInputHandle, ChatInputProps } from "./message-ui/ChatInput";
21
21
  export { ChatInput } from "./message-ui/ChatInput";
22
22
  export type { ChatMarkdownProps } from "./message-ui/ChatMarkdown";
23
23
  export { ChatMarkdown } from "./message-ui/ChatMarkdown";
24
24
  export { ChatSpinner } from "./message-ui/ChatSpinner";
25
+ export type { ChatSuggest, ChatTrigger } from "./message-ui/ChatSuggestions";
26
+ export { ChatSuggestOption, useChatSuggest } from "./message-ui/ChatSuggestions";
25
27
  export type { ChatThinkingProps } from "./message-ui/ChatThinking";
26
28
  export { ChatThinking } from "./message-ui/ChatThinking";
27
29
  export type { ChatUserMessageProps } from "./message-ui/ChatUserMessage";