@pmate/chat-sdk 0.1.17 → 0.1.18

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.
@@ -13,6 +13,7 @@ import { EmojiPicker } from "./EmojiPicker";
13
13
  import { EmojiTrigger } from "./EmojiTrigger";
14
14
  import { MoreTrigger } from "./ImageTrigger";
15
15
  import { InputSurface } from "./InputSurface";
16
+ import { SendAction } from "./SendAction";
16
17
  import { StatusHint } from "./StatusHint";
17
18
  import { TextComposer } from "./TextComposer";
18
19
  import { WaveformFeedback } from "./WaveformFeedback";
@@ -182,7 +183,7 @@ function DesktopInner(props) {
182
183
  position: "absolute",
183
184
  left: 0,
184
185
  right: 0,
185
- bottom: 66,
186
+ bottom: props.multiline ? 154 : 66,
186
187
  padding: "12px 14px",
187
188
  borderRadius: 24,
188
189
  background: `color-mix(in srgb, ${tokens.color.surfaceInputFocus} 94%, transparent)`,
@@ -192,7 +193,46 @@ function DesktopInner(props) {
192
193
  boxShadow: "0 18px 50px rgba(0, 0, 0, 0.16)",
193
194
  backdropFilter: "blur(18px)",
194
195
  zIndex: 3,
195
- }, children: [_jsxs("button", { type: "button", style: attachmentActionStyle, disabled: props.disabled || isUploadingImage, onClick: () => imageInputRef.current?.click(), children: [_jsx("span", { style: attachmentIconStyle, children: _jsx(ImageOutlineIcon, { size: 24 }) }), "\u56FE\u7247"] }), _jsxs("button", { type: "button", style: attachmentActionStyle, disabled: props.disabled, onClick: () => fileInputRef.current?.click(), children: [_jsx("span", { style: attachmentIconStyle, children: _jsx(FileOutlineIcon, { size: 24 }) }), "\u6587\u4EF6"] })] })) : null, voice.status === "recording" ? (_jsxs("div", { className: "flex items-center gap-3", children: [_jsx(WaveformFeedback, { levels: voice.waveformLevels, tokens: tokens, compact: true }), _jsxs("span", { style: { color: tokens.color.textSecondary, fontSize: 12 }, children: [Math.max(1, Math.round(voice.durationMs / 1000)), "s"] })] })) : null, _jsxs("div", { style: {
196
+ }, children: [_jsxs("button", { type: "button", style: attachmentActionStyle, disabled: props.disabled || isUploadingImage, onClick: () => imageInputRef.current?.click(), children: [_jsx("span", { style: attachmentIconStyle, children: _jsx(ImageOutlineIcon, { size: 24 }) }), "\u56FE\u7247"] }), _jsxs("button", { type: "button", style: attachmentActionStyle, disabled: props.disabled, onClick: () => fileInputRef.current?.click(), children: [_jsx("span", { style: attachmentIconStyle, children: _jsx(FileOutlineIcon, { size: 24 }) }), "\u6587\u4EF6"] })] })) : null, voice.status === "recording" ? (_jsxs("div", { className: "flex items-center gap-3", children: [_jsx(WaveformFeedback, { levels: voice.waveformLevels, tokens: tokens, compact: true }), _jsxs("span", { style: { color: tokens.color.textSecondary, fontSize: 12 }, children: [Math.max(1, Math.round(voice.durationMs / 1000)), "s"] })] })) : null, props.multiline ? (_jsxs(InputSurface, { tokens: tokens, status: state.status, styleOverride: {
197
+ minHeight: 144,
198
+ padding: "16px 18px 12px",
199
+ display: "flex",
200
+ flexDirection: "column",
201
+ gap: 12,
202
+ }, children: [_jsx(TextComposer, { ref: textComposerRef, tokens: tokens, value: state.text, rows: 3, placeholder: "Message PMate", onKeyDown: (event) => {
203
+ if (event.key === "Enter" && (event.metaKey || event.ctrlKey)) {
204
+ event.preventDefault();
205
+ if (state.text.trim() || state.attachments.length > 0)
206
+ void onSend();
207
+ }
208
+ }, onChange: (event) => {
209
+ state.setText(event.target.value);
210
+ state.setStatus(event.target.value.trim() ? "typing" : "idle");
211
+ props.onChange?.(event.target.value);
212
+ }, style: {
213
+ flex: 1,
214
+ minHeight: 64,
215
+ maxHeight: 180,
216
+ padding: 0,
217
+ overflowY: "auto",
218
+ caretColor: tokens.color.brandPrimary,
219
+ } }), _jsxs("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 12 }, children: [_jsx(MoreTrigger, { "data-icon-size": 24, onClick: () => { setIsEmojiOpen(false); setIsMoreOpen((prev) => !prev); }, disabled: props.disabled, style: { ...sideActionStyle, color: isMoreOpen ? tokens.color.iconActive : tokens.color.iconDefault, opacity: props.disabled ? 0.4 : 1 } }), _jsxs("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [_jsx("button", { type: "button", onClick: () => {
220
+ if (props.disabled || props.enableVoice === false)
221
+ return;
222
+ if (voice.status === "recording") {
223
+ voice.stopRecording("transcribe");
224
+ return;
225
+ }
226
+ if (voice.status === "transcribing")
227
+ return;
228
+ voice.beginVoiceMode();
229
+ voice.startRecording();
230
+ }, style: {
231
+ ...sideActionStyle,
232
+ color: voice.status === "recording" || voice.status === "transcribing" ? tokens.color.iconActive : tokens.color.iconDefault,
233
+ cursor: props.disabled || props.enableVoice === false ? "not-allowed" : "pointer",
234
+ opacity: props.disabled || props.enableVoice === false ? 0.4 : 1,
235
+ }, "aria-label": voice.status === "recording" ? "停止录音并转文字" : voice.status === "transcribing" ? "正在转写语音" : "开始语音输入", children: voice.status === "recording" ? _jsx(StopCircleOutlineIcon, { size: 27 }) : _jsx(MicOutlineIcon, { size: 24, strokeWidth: 2 }) }), _jsx(EmojiTrigger, { ref: emojiAnchorRef, "data-icon-size": 24, style: sideActionStyle, onClick: () => { setIsMoreOpen(false); setIsEmojiOpen((prev) => !prev); } }), _jsx(SendAction, { tokens: tokens, disabled: props.disabled || state.status === "sending" || (!state.text.trim() && state.attachments.length === 0), "aria-label": "\u53D1\u9001\u6D88\u606F", onClick: () => void onSend(), style: { width: 40, height: 40, padding: 0, borderRadius: 999, fontSize: 24, lineHeight: "40px" }, children: "\u2191" })] })] })] })) : _jsxs("div", { style: {
196
236
  display: "grid",
197
237
  gridTemplateColumns: "32px minmax(0, 1fr) 32px 32px",
198
238
  alignItems: "center",
@@ -110,6 +110,8 @@ export type ChatImageConfig = {
110
110
  uploadImage?: (file: File) => Promise<ChatImageUploadResult>;
111
111
  };
112
112
  export type ChatInputBaseProps = {
113
+ /** Use a taller composer with actions in a bottom toolbar. */
114
+ multiline?: boolean;
113
115
  value?: string;
114
116
  defaultValue?: string;
115
117
  onChange?: (value: string) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pmate/chat-sdk",
3
- "version": "0.1.17",
3
+ "version": "0.1.18",
4
4
  "description": "Cross-platform PMate chat input components, voice input primitives, and ASR helpers",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",
@@ -29,14 +29,6 @@
29
29
  "publishConfig": {
30
30
  "access": "public"
31
31
  },
32
- "scripts": {
33
- "build": "tsc -p tsconfig.build.json && cp src/voice/recorder-processor.js lib/voice/recorder-processor.js",
34
- "prepack": "pnpm run build",
35
- "npm:publish": "pnpm run build && npm publish --access public --registry https://registry.npmjs.org/",
36
- "test": "vitest run",
37
- "storybook": "storybook dev -p 6009",
38
- "build-storybook": "storybook build --output-dir dist"
39
- },
40
32
  "dependencies": {
41
33
  "@emoji-mart/data": "^1.2.1",
42
34
  "@emoji-mart/react": "^1.1.1",
@@ -51,14 +43,21 @@
51
43
  "devDependencies": {
52
44
  "@storybook/addon-docs": "^9.0.17",
53
45
  "@storybook/react-vite": "9.0.17",
54
- "@tailwindcss/vite": "catalog:",
55
- "@types/react": "catalog:",
56
- "@types/react-dom": "catalog:",
57
- "react": "catalog:",
58
- "react-dom": "catalog:",
46
+ "@tailwindcss/vite": "^4.1.3",
47
+ "@types/react": "^19.2.7",
48
+ "@types/react-dom": "^19.2.3",
49
+ "react": "^19.1.1",
50
+ "react-dom": "^19.1.1",
59
51
  "storybook": "^9.0.17",
60
- "tailwindcss": "catalog:",
52
+ "tailwindcss": "^4.0.14",
61
53
  "typescript": "5.9.2",
62
54
  "vitest": "^4.0.17"
55
+ },
56
+ "scripts": {
57
+ "build": "tsc -p tsconfig.build.json && cp src/voice/recorder-processor.js lib/voice/recorder-processor.js",
58
+ "npm:publish": "pnpm run build && npm publish --access public --registry https://registry.npmjs.org/",
59
+ "test": "vitest run",
60
+ "storybook": "storybook dev -p 6009",
61
+ "build-storybook": "storybook build --output-dir dist"
63
62
  }
64
- }
63
+ }