@molecule/app-chatbot-tester-react 1.0.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/LICENSE +115 -0
- package/dist/ChatbotTester.d.ts +36 -0
- package/dist/ChatbotTester.d.ts.map +1 -0
- package/dist/ChatbotTester.js +30 -0
- package/dist/ChatbotTesterInput.d.ts +20 -0
- package/dist/ChatbotTesterInput.d.ts.map +1 -0
- package/dist/ChatbotTesterInput.js +13 -0
- package/dist/ChatbotTesterMessages.d.ts +18 -0
- package/dist/ChatbotTesterMessages.d.ts.map +1 -0
- package/dist/ChatbotTesterMessages.js +27 -0
- package/dist/index.d.ts +52 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +51 -0
- package/dist/types.d.ts +18 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/package.json +47 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work.
|
|
38
|
+
|
|
39
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
40
|
+
form, that is based on (or derived from) the Work and for which the
|
|
41
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
42
|
+
represent, as a whole, an original work of authorship.
|
|
43
|
+
|
|
44
|
+
"Contribution" shall mean any work of authorship, including the
|
|
45
|
+
original version of the Work and any modifications or additions
|
|
46
|
+
to that Work, that is intentionally submitted to the Licensor for
|
|
47
|
+
inclusion in the Work by the copyright owner or by an individual or
|
|
48
|
+
Legal Entity authorized to submit on behalf of the copyright owner.
|
|
49
|
+
|
|
50
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
51
|
+
on behalf of whom a Contribution has been received by the Licensor and
|
|
52
|
+
subsequently incorporated within the Work.
|
|
53
|
+
|
|
54
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
55
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
56
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
57
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
58
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
59
|
+
Work and such Derivative Works in Source or Object form.
|
|
60
|
+
|
|
61
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
62
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
63
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
64
|
+
patent license to make, have made, use, offer to sell, sell, import,
|
|
65
|
+
and otherwise transfer the Work.
|
|
66
|
+
|
|
67
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
68
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
69
|
+
modifications, and in Source or Object form, provided that You
|
|
70
|
+
meet the following conditions:
|
|
71
|
+
|
|
72
|
+
(a) You must give any other recipients of the Work or
|
|
73
|
+
Derivative Works a copy of this License; and
|
|
74
|
+
|
|
75
|
+
(b) You must cause any modified files to carry prominent notices
|
|
76
|
+
stating that You changed the files; and
|
|
77
|
+
|
|
78
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
79
|
+
that You distribute, all copyright, patent, trademark, and
|
|
80
|
+
attribution notices from the Source form of the Work,
|
|
81
|
+
excluding those notices that do not pertain to any part of
|
|
82
|
+
the Derivative Works; and
|
|
83
|
+
|
|
84
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
85
|
+
distribution, then any Derivative Works that You distribute must
|
|
86
|
+
include a readable copy of the attribution notices contained
|
|
87
|
+
within such NOTICE file.
|
|
88
|
+
|
|
89
|
+
5. Submission of Contributions.
|
|
90
|
+
|
|
91
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
92
|
+
names, trademarks, service marks, or product names of the Licensor.
|
|
93
|
+
|
|
94
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
95
|
+
agreed to in writing, Licensor provides the Work on an "AS IS" BASIS,
|
|
96
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND.
|
|
97
|
+
|
|
98
|
+
8. Limitation of Liability. In no event and under no legal theory shall
|
|
99
|
+
any Contributor be liable to You for damages.
|
|
100
|
+
|
|
101
|
+
9. Accepting Warranty or Additional Liability.
|
|
102
|
+
|
|
103
|
+
Copyright 2026 Molecule Dev, Inc.
|
|
104
|
+
|
|
105
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
106
|
+
you may not use this file except in compliance with the License.
|
|
107
|
+
You may obtain a copy of the License at
|
|
108
|
+
|
|
109
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
110
|
+
|
|
111
|
+
Unless required by applicable law or agreed to in writing, software
|
|
112
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
113
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
114
|
+
See the License for the specific language governing permissions and
|
|
115
|
+
limitations under the License.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Composed sandbox UI: optional bot picker + messages thread + input
|
|
3
|
+
* row + error region.
|
|
4
|
+
*
|
|
5
|
+
* Stateless about transport: the consumer owns the message array, the
|
|
6
|
+
* send handler, and (optionally) the bot list + current bot id. Pass
|
|
7
|
+
* the side-effects (creating a test conversation, sending messages
|
|
8
|
+
* upstream, etc.) as `onSend` / `onBotChange`.
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
import { type JSX, type ReactNode } from 'react';
|
|
13
|
+
import type { TesterBotOption, TesterMessage } from './types.js';
|
|
14
|
+
/** Props for {@link ChatbotTester}. */
|
|
15
|
+
export interface ChatbotTesterProps {
|
|
16
|
+
messages: TesterMessage[];
|
|
17
|
+
loading?: boolean;
|
|
18
|
+
/** When provided, send invokes this with the composer text. */
|
|
19
|
+
onSend: (text: string) => void | Promise<void>;
|
|
20
|
+
/** Optional bot list — when length >= 2, a picker is rendered. */
|
|
21
|
+
bots?: TesterBotOption[];
|
|
22
|
+
botId?: string;
|
|
23
|
+
onBotChange?: (id: string) => void;
|
|
24
|
+
/** Last error message — rendered in a `role="alert"` paragraph. */
|
|
25
|
+
error?: ReactNode;
|
|
26
|
+
/** Empty-state slot when there are no messages yet. */
|
|
27
|
+
emptyState?: ReactNode;
|
|
28
|
+
botPickerLabel?: ReactNode;
|
|
29
|
+
inputPlaceholder?: string;
|
|
30
|
+
sendLabel?: string;
|
|
31
|
+
className?: string;
|
|
32
|
+
}
|
|
33
|
+
/** Full chatbot tester sandbox. */
|
|
34
|
+
export declare function ChatbotTester({ messages, loading, onSend, bots, botId, onBotChange, error, emptyState, botPickerLabel, inputPlaceholder, sendLabel, className, }: ChatbotTesterProps): JSX.Element;
|
|
35
|
+
export default ChatbotTester;
|
|
36
|
+
//# sourceMappingURL=ChatbotTester.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatbotTester.d.ts","sourceRoot":"","sources":["../src/ChatbotTester.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK,SAAS,EAAY,MAAM,OAAO,CAAA;AAM1D,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAEhE,uCAAuC;AACvC,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,aAAa,EAAE,CAAA;IACzB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,+DAA+D;IAC/D,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC9C,kEAAkE;IAClE,IAAI,CAAC,EAAE,eAAe,EAAE,CAAA;IACxB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAA;IAClC,mEAAmE;IACnE,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,uDAAuD;IACvD,UAAU,CAAC,EAAE,SAAS,CAAA;IACtB,cAAc,CAAC,EAAE,SAAS,CAAA;IAC1B,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,mCAAmC;AACnC,wBAAgB,aAAa,CAAC,EAC5B,QAAQ,EACR,OAAO,EACP,MAAM,EACN,IAAI,EACJ,KAAK,EACL,WAAW,EACX,KAAK,EACL,UAAU,EACV,cAA2B,EAC3B,gBAAgB,EAChB,SAAS,EACT,SAAS,GACV,EAAE,kBAAkB,GAAG,GAAG,CAAC,OAAO,CA+DlC;AAED,eAAe,aAAa,CAAA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Composed sandbox UI: optional bot picker + messages thread + input
|
|
4
|
+
* row + error region.
|
|
5
|
+
*
|
|
6
|
+
* Stateless about transport: the consumer owns the message array, the
|
|
7
|
+
* send handler, and (optionally) the bot list + current bot id. Pass
|
|
8
|
+
* the side-effects (creating a test conversation, sending messages
|
|
9
|
+
* upstream, etc.) as `onSend` / `onBotChange`.
|
|
10
|
+
*
|
|
11
|
+
* @module
|
|
12
|
+
*/
|
|
13
|
+
import { useState } from 'react';
|
|
14
|
+
import { getClassMap } from '@molecule/app-ui';
|
|
15
|
+
import { ChatbotTesterInput } from './ChatbotTesterInput.js';
|
|
16
|
+
import { ChatbotTesterMessages } from './ChatbotTesterMessages.js';
|
|
17
|
+
/** Full chatbot tester sandbox. */
|
|
18
|
+
export function ChatbotTester({ messages, loading, onSend, bots, botId, onBotChange, error, emptyState, botPickerLabel = 'Test bot', inputPlaceholder, sendLabel, className, }) {
|
|
19
|
+
const cm = getClassMap();
|
|
20
|
+
const [input, setInput] = useState('');
|
|
21
|
+
const handleSend = async () => {
|
|
22
|
+
const text = input.trim();
|
|
23
|
+
if (!text)
|
|
24
|
+
return;
|
|
25
|
+
setInput('');
|
|
26
|
+
await onSend(text);
|
|
27
|
+
};
|
|
28
|
+
return (_jsxs("div", { className: cm.cn(cm.flex({ direction: 'col' }), cm.flex1, 'min-w-0', className), children: [bots && bots.length > 1 ? (_jsxs("div", { className: cm.cn(cm.flex({ align: 'center' }), cm.sp('px', 6), cm.sp('py', 3), 'gap-3 border-b border-outline-variant/20'), children: [_jsx("label", { htmlFor: "chatbot-tester-bot-select", className: cm.cn(cm.textSize('xs'), cm.fontWeight('bold')), children: botPickerLabel }), _jsx("select", { id: "chatbot-tester-bot-select", value: botId ?? '', onChange: (e) => onBotChange?.(e.target.value), className: cm.cn(cm.textSize('sm'), 'bg-surface-container-high border-none rounded-xl px-3 py-2 focus:ring-2 focus:ring-primary/40'), children: bots.map((b) => (_jsx("option", { value: b.id, children: b.name || b.id }, b.id))) })] })) : null, _jsx(ChatbotTesterMessages, { messages: messages, loading: loading, emptyState: emptyState }), error ? (_jsx("p", { role: "alert", className: cm.cn(cm.textSize('sm'), cm.sp('px', 6), cm.sp('py', 2), 'text-error'), children: error })) : null, _jsx(ChatbotTesterInput, { value: input, onChange: setInput, onSend: handleSend, loading: loading, placeholder: inputPlaceholder, sendLabel: sendLabel })] }));
|
|
29
|
+
}
|
|
30
|
+
export default ChatbotTester;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Composer input row with send button. Enter sends; shift+enter inserts
|
|
3
|
+
* a newline. Disables the send action while a reply is in flight.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import type { JSX } from 'react';
|
|
8
|
+
/** Props for {@link ChatbotTesterInput}. */
|
|
9
|
+
export interface ChatbotTesterInputProps {
|
|
10
|
+
value: string;
|
|
11
|
+
onChange: (next: string) => void;
|
|
12
|
+
onSend: () => void;
|
|
13
|
+
loading?: boolean;
|
|
14
|
+
placeholder?: string;
|
|
15
|
+
sendLabel?: string;
|
|
16
|
+
}
|
|
17
|
+
/** Message composer + send button. */
|
|
18
|
+
export declare function ChatbotTesterInput({ value, onChange, onSend, loading, placeholder, sendLabel, }: ChatbotTesterInputProps): JSX.Element;
|
|
19
|
+
export default ChatbotTesterInput;
|
|
20
|
+
//# sourceMappingURL=ChatbotTesterInput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatbotTesterInput.d.ts","sourceRoot":"","sources":["../src/ChatbotTesterInput.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAIhC,4CAA4C;AAC5C,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IAChC,MAAM,EAAE,MAAM,IAAI,CAAA;IAClB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,sCAAsC;AACtC,wBAAgB,kBAAkB,CAAC,EACjC,KAAK,EACL,QAAQ,EACR,MAAM,EACN,OAAO,EACP,WAA+B,EAC/B,SAAkB,GACnB,EAAE,uBAAuB,GAAG,GAAG,CAAC,OAAO,CA+CvC;AAED,eAAe,kBAAkB,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { getClassMap } from '@molecule/app-ui';
|
|
3
|
+
/** Message composer + send button. */
|
|
4
|
+
export function ChatbotTesterInput({ value, onChange, onSend, loading, placeholder = 'Type a message…', sendLabel = 'Send', }) {
|
|
5
|
+
const cm = getClassMap();
|
|
6
|
+
return (_jsxs("div", { className: cm.cn(cm.flex({ align: 'end', gap: 2 }), cm.sp('px', 6), cm.sp('py', 4), 'border-t border-outline-variant/20'), children: [_jsx("textarea", { value: value, onChange: (e) => onChange(e.target.value), onKeyDown: (e) => {
|
|
7
|
+
if (e.key === 'Enter' && !e.shiftKey) {
|
|
8
|
+
e.preventDefault();
|
|
9
|
+
onSend();
|
|
10
|
+
}
|
|
11
|
+
}, rows: 1, placeholder: placeholder, disabled: loading, className: cm.cn(cm.flex1, cm.sp('px', 4), cm.sp('py', 2), cm.textSize('sm'), cm.surface, 'border border-outline-variant rounded-xl focus:ring-2 focus:ring-primary/40 resize-none disabled:opacity-60') }), _jsx("button", { onClick: onSend, disabled: loading || !value.trim(), className: cm.cn(cm.sp('px', 4), cm.sp('py', 2), cm.textSize('sm'), cm.fontWeight('semibold'), 'bg-primary text-on-primary rounded-xl disabled:opacity-50'), children: sendLabel })] }));
|
|
12
|
+
}
|
|
13
|
+
export default ChatbotTesterInput;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scrollable message list for the chatbot sandbox. Each row is a
|
|
3
|
+
* left-aligned (assistant) or right-aligned (user) bubble.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import { type JSX } from 'react';
|
|
8
|
+
import type { TesterMessage } from './types.js';
|
|
9
|
+
/** Props for {@link ChatbotTesterMessages}. */
|
|
10
|
+
export interface ChatbotTesterMessagesProps {
|
|
11
|
+
messages: TesterMessage[];
|
|
12
|
+
loading?: boolean;
|
|
13
|
+
emptyState?: React.ReactNode;
|
|
14
|
+
}
|
|
15
|
+
/** Scrollable transcript pane. */
|
|
16
|
+
export declare function ChatbotTesterMessages({ messages, loading, emptyState, }: ChatbotTesterMessagesProps): JSX.Element;
|
|
17
|
+
export default ChatbotTesterMessages;
|
|
18
|
+
//# sourceMappingURL=ChatbotTesterMessages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatbotTesterMessages.d.ts","sourceRoot":"","sources":["../src/ChatbotTesterMessages.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,KAAK,GAAG,EAAqB,MAAM,OAAO,CAAA;AAInD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAE/C,+CAA+C;AAC/C,MAAM,WAAW,0BAA0B;IACzC,QAAQ,EAAE,aAAa,EAAE,CAAA;IACzB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAC7B;AAED,kCAAkC;AAClC,wBAAgB,qBAAqB,CAAC,EACpC,QAAQ,EACR,OAAO,EACP,UAAU,GACX,EAAE,0BAA0B,GAAG,GAAG,CAAC,OAAO,CAyD1C;AAED,eAAe,qBAAqB,CAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Scrollable message list for the chatbot sandbox. Each row is a
|
|
4
|
+
* left-aligned (assistant) or right-aligned (user) bubble.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
import { useEffect, useRef } from 'react';
|
|
9
|
+
import { getClassMap } from '@molecule/app-ui';
|
|
10
|
+
/** Scrollable transcript pane. */
|
|
11
|
+
export function ChatbotTesterMessages({ messages, loading, emptyState, }) {
|
|
12
|
+
const cm = getClassMap();
|
|
13
|
+
const endRef = useRef(null);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
endRef.current?.scrollIntoView({ behavior: 'smooth', block: 'end' });
|
|
16
|
+
}, [messages.length, loading]);
|
|
17
|
+
if (!loading && messages.length === 0 && emptyState) {
|
|
18
|
+
return (_jsx("div", { className: cm.cn(cm.flex1, cm.flex({ align: 'center', justify: 'center' })), children: emptyState }));
|
|
19
|
+
}
|
|
20
|
+
return (_jsx("div", { className: cm.cn(cm.flex1, cm.sp('px', 6), cm.sp('py', 4), 'overflow-y-auto'), children: _jsxs("div", { className: cm.stack(3), children: [messages.map((msg) => {
|
|
21
|
+
const isUser = msg.role === 'user';
|
|
22
|
+
return (_jsx("div", { className: cm.cn(cm.flex({ justify: isUser ? 'end' : 'start' })), children: _jsxs("div", { className: cm.cn(cm.sp('px', 4), cm.sp('py', 2), cm.textSize('sm'), 'rounded-2xl max-w-[80%] whitespace-pre-wrap', isUser
|
|
23
|
+
? 'bg-primary text-on-primary'
|
|
24
|
+
: 'bg-surface-container-high text-on-surface'), children: [msg.content, msg.timestamp ? (_jsx("div", { className: cm.cn(cm.textSize('xs'), cm.sp('mt', 1), isUser ? 'text-on-primary/70' : 'text-on-surface-variant'), children: msg.timestamp })) : null] }) }, msg.id));
|
|
25
|
+
}), loading ? (_jsx("div", { className: cm.cn(cm.textSize('xs'), 'text-on-surface-variant animate-pulse'), children: "..." })) : null, _jsx("div", { ref: endRef })] }) }));
|
|
26
|
+
}
|
|
27
|
+
export default ChatbotTesterMessages;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@molecule/app-chatbot-tester-react` — sandbox UI shell for live-testing
|
|
3
|
+
* conversational AI: optional bot picker, message transcript, input row,
|
|
4
|
+
* error display.
|
|
5
|
+
*
|
|
6
|
+
* Stateless about transport. The consumer owns the message array, send
|
|
7
|
+
* handler, and bot list; the package handles the layout and composition.
|
|
8
|
+
*
|
|
9
|
+
* Extracted from the ai-chatbot-builder TestChat page; usable for any
|
|
10
|
+
* "preview your bot live" UI.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* import { ChatbotTester, type TesterMessage } from '@molecule/app-chatbot-tester-react'
|
|
15
|
+
*
|
|
16
|
+
* const [messages, setMessages] = useState<TesterMessage[]>([])
|
|
17
|
+
* const handleSend = async (text: string) => {
|
|
18
|
+
* setMessages((prev) => [...prev, { id: Date.now(), role: 'user', content: text }])
|
|
19
|
+
* const reply = await http.post(`/api/conversations/${conversationId}/messages`, { content: text })
|
|
20
|
+
* setMessages((prev) => [...prev, { id: reply.id, role: 'assistant', content: reply.content }])
|
|
21
|
+
* }
|
|
22
|
+
*
|
|
23
|
+
* <ChatbotTester
|
|
24
|
+
* messages={messages}
|
|
25
|
+
* onSend={handleSend}
|
|
26
|
+
* loading={sending}
|
|
27
|
+
* bots={bots}
|
|
28
|
+
* botId={botId}
|
|
29
|
+
* onBotChange={setBotId}
|
|
30
|
+
* error={error}
|
|
31
|
+
* />
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* @remarks
|
|
35
|
+
* Built-in labels (`botPickerLabel` default "Test bot", `inputPlaceholder`
|
|
36
|
+
* default "Type a message…", `sendLabel` default "Send") are hardcoded
|
|
37
|
+
* English — there is no companion locale bond. For localized apps, pass all
|
|
38
|
+
* three props with `t('key', {}, { defaultValue: '…' })` values.
|
|
39
|
+
* Enter sends; Shift+Enter inserts a newline. The bot picker renders only
|
|
40
|
+
* when `bots` has 2+ entries. Styling includes Tailwind classes with
|
|
41
|
+
* Material-3 tokens (`bg-surface-container-high`, `border-outline-variant`,
|
|
42
|
+
* `text-on-primary`, …) — the app's Tailwind theme must define those tokens
|
|
43
|
+
* (the default molecule Tailwind ClassMap bond does); with a non-Tailwind
|
|
44
|
+
* ClassMap the bubbles/borders lose their styling.
|
|
45
|
+
*
|
|
46
|
+
* @module
|
|
47
|
+
*/
|
|
48
|
+
export * from './ChatbotTester.js';
|
|
49
|
+
export * from './ChatbotTesterInput.js';
|
|
50
|
+
export * from './ChatbotTesterMessages.js';
|
|
51
|
+
export * from './types.js';
|
|
52
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AAEH,cAAc,oBAAoB,CAAA;AAClC,cAAc,yBAAyB,CAAA;AACvC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,YAAY,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@molecule/app-chatbot-tester-react` — sandbox UI shell for live-testing
|
|
3
|
+
* conversational AI: optional bot picker, message transcript, input row,
|
|
4
|
+
* error display.
|
|
5
|
+
*
|
|
6
|
+
* Stateless about transport. The consumer owns the message array, send
|
|
7
|
+
* handler, and bot list; the package handles the layout and composition.
|
|
8
|
+
*
|
|
9
|
+
* Extracted from the ai-chatbot-builder TestChat page; usable for any
|
|
10
|
+
* "preview your bot live" UI.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* import { ChatbotTester, type TesterMessage } from '@molecule/app-chatbot-tester-react'
|
|
15
|
+
*
|
|
16
|
+
* const [messages, setMessages] = useState<TesterMessage[]>([])
|
|
17
|
+
* const handleSend = async (text: string) => {
|
|
18
|
+
* setMessages((prev) => [...prev, { id: Date.now(), role: 'user', content: text }])
|
|
19
|
+
* const reply = await http.post(`/api/conversations/${conversationId}/messages`, { content: text })
|
|
20
|
+
* setMessages((prev) => [...prev, { id: reply.id, role: 'assistant', content: reply.content }])
|
|
21
|
+
* }
|
|
22
|
+
*
|
|
23
|
+
* <ChatbotTester
|
|
24
|
+
* messages={messages}
|
|
25
|
+
* onSend={handleSend}
|
|
26
|
+
* loading={sending}
|
|
27
|
+
* bots={bots}
|
|
28
|
+
* botId={botId}
|
|
29
|
+
* onBotChange={setBotId}
|
|
30
|
+
* error={error}
|
|
31
|
+
* />
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* @remarks
|
|
35
|
+
* Built-in labels (`botPickerLabel` default "Test bot", `inputPlaceholder`
|
|
36
|
+
* default "Type a message…", `sendLabel` default "Send") are hardcoded
|
|
37
|
+
* English — there is no companion locale bond. For localized apps, pass all
|
|
38
|
+
* three props with `t('key', {}, { defaultValue: '…' })` values.
|
|
39
|
+
* Enter sends; Shift+Enter inserts a newline. The bot picker renders only
|
|
40
|
+
* when `bots` has 2+ entries. Styling includes Tailwind classes with
|
|
41
|
+
* Material-3 tokens (`bg-surface-container-high`, `border-outline-variant`,
|
|
42
|
+
* `text-on-primary`, …) — the app's Tailwind theme must define those tokens
|
|
43
|
+
* (the default molecule Tailwind ClassMap bond does); with a non-Tailwind
|
|
44
|
+
* ClassMap the bubbles/borders lose their styling.
|
|
45
|
+
*
|
|
46
|
+
* @module
|
|
47
|
+
*/
|
|
48
|
+
export * from './ChatbotTester.js';
|
|
49
|
+
export * from './ChatbotTesterInput.js';
|
|
50
|
+
export * from './ChatbotTesterMessages.js';
|
|
51
|
+
export * from './types.js';
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for the chatbot-tester sandbox UI.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
/** A single chat message displayed in the chatbot tester sandbox UI. */
|
|
7
|
+
export interface TesterMessage {
|
|
8
|
+
id: string | number;
|
|
9
|
+
role: 'user' | 'assistant' | 'system';
|
|
10
|
+
content: string;
|
|
11
|
+
timestamp?: string;
|
|
12
|
+
}
|
|
13
|
+
/** A selectable bot/agent option shown in the chatbot tester sandbox UI. */
|
|
14
|
+
export interface TesterBotOption {
|
|
15
|
+
id: string;
|
|
16
|
+
name?: string;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,wEAAwE;AACxE,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;IACnB,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,QAAQ,CAAA;IACrC,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,4EAA4E;AAC5E,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,CAAC,EAAE,MAAM,CAAA;CACd"}
|
package/dist/types.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@molecule/app-chatbot-tester-react",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Sandbox UI for live-testing chatbots: bot picker, message thread, input area, error region. Extracted from ai-chatbot-builder TestChat.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "tsc",
|
|
10
|
+
"test": "vitest run",
|
|
11
|
+
"test:watch": "vitest"
|
|
12
|
+
},
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"import": "./dist/index.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist"
|
|
21
|
+
],
|
|
22
|
+
"keywords": [
|
|
23
|
+
"molecule",
|
|
24
|
+
"chatbot",
|
|
25
|
+
"playground",
|
|
26
|
+
"tester",
|
|
27
|
+
"ai",
|
|
28
|
+
"react"
|
|
29
|
+
],
|
|
30
|
+
"license": "Apache-2.0",
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"@molecule/app-react": "^1.0.0",
|
|
33
|
+
"@molecule/app-ui": "^1.0.0",
|
|
34
|
+
"@molecule/app-ui-react": "^1.0.0",
|
|
35
|
+
"react": "^18.0.0 || ^19.0.0"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@molecule/app-react": "1.0.0",
|
|
39
|
+
"@molecule/app-ui": "1.0.0",
|
|
40
|
+
"@molecule/app-ui-react": "1.0.0",
|
|
41
|
+
"@types/node": "26.1.2",
|
|
42
|
+
"@types/react": "19.2.17",
|
|
43
|
+
"react": "19.2.8",
|
|
44
|
+
"typescript": "6.0.3",
|
|
45
|
+
"vitest": "4.1.10"
|
|
46
|
+
}
|
|
47
|
+
}
|