@pmate/chat-sdk 0.1.14 → 0.1.15
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/lib/components/HoldToTalkButton.js +16 -2
- package/package.json +15 -16
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import React from "react";
|
|
3
3
|
export function HoldToTalkButton({ tokens, active, disabled, text = "按住 说话", activeText = "松开 结束", onPressStart, onPressMove, onPressEnd, onPressCancel, }) {
|
|
4
|
-
|
|
4
|
+
const lockPointerGesture = (event) => {
|
|
5
|
+
event.preventDefault();
|
|
6
|
+
};
|
|
7
|
+
return (_jsx("button", { type: "button", "data-pmate-hold-to-talk": "true", disabled: disabled, onContextMenu: (event) => {
|
|
5
8
|
event.preventDefault();
|
|
6
9
|
}, onSelect: (event) => {
|
|
7
10
|
event.preventDefault();
|
|
8
11
|
}, onDragStart: (event) => {
|
|
9
12
|
event.preventDefault();
|
|
10
13
|
}, onPointerDown: (event) => {
|
|
14
|
+
lockPointerGesture(event);
|
|
11
15
|
try {
|
|
12
16
|
event.currentTarget.setPointerCapture(event.pointerId);
|
|
13
17
|
}
|
|
@@ -15,7 +19,16 @@ export function HoldToTalkButton({ tokens, active, disabled, text = "按住 说
|
|
|
15
19
|
// ignore unsupported pointer capture cases in test environments
|
|
16
20
|
}
|
|
17
21
|
onPressStart?.(event);
|
|
18
|
-
}, onPointerMove:
|
|
22
|
+
}, onPointerMove: (event) => {
|
|
23
|
+
lockPointerGesture(event);
|
|
24
|
+
onPressMove?.(event);
|
|
25
|
+
}, onPointerUp: (event) => {
|
|
26
|
+
lockPointerGesture(event);
|
|
27
|
+
onPressEnd?.(event);
|
|
28
|
+
}, onPointerCancel: (event) => {
|
|
29
|
+
lockPointerGesture(event);
|
|
30
|
+
onPressCancel?.(event);
|
|
31
|
+
}, style: {
|
|
19
32
|
width: "100%",
|
|
20
33
|
borderRadius: tokens.radius.mobileHoldToTalk,
|
|
21
34
|
background: active ? tokens.color.surfaceInputRecording : "transparent",
|
|
@@ -37,6 +50,7 @@ export function HoldToTalkButton({ tokens, active, disabled, text = "按住 说
|
|
|
37
50
|
WebkitUserSelect: "none",
|
|
38
51
|
WebkitTouchCallout: "none",
|
|
39
52
|
WebkitTapHighlightColor: "transparent",
|
|
53
|
+
overscrollBehavior: "contain",
|
|
40
54
|
touchAction: "none",
|
|
41
55
|
transition: `all ${tokens.motion.stateTransition}`,
|
|
42
56
|
}, children: active ? activeText : text }));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pmate/chat-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.15",
|
|
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": "
|
|
55
|
-
"@types/react": "
|
|
56
|
-
"@types/react-dom": "
|
|
57
|
-
"react": "
|
|
58
|
-
"react-dom": "
|
|
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": "
|
|
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
|
+
}
|