@autobe/ui 0.29.2 → 0.30.0-dev.20260315
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 +661 -661
- package/README.md +261 -0
- package/lib/components/AutoBeChatMain.js +5 -5
- package/lib/components/AutoBeChatMain.js.map +1 -1
- package/lib/components/AutoBeConfigModal.js +9 -9
- package/lib/components/AutoBeStatusModal.js +4 -4
- package/lib/components/AutoBeStatusModal.js.map +1 -1
- package/lib/components/AutoBeUserMessageMovie.d.ts +2 -2
- package/lib/components/common/ChatBubble.d.ts +2 -2
- package/lib/components/common/openai/OpenAIContent.d.ts +2 -2
- package/lib/components/common/openai/OpenAIContent.js.map +1 -1
- package/lib/components/common/openai/OpenAIUserAudioContent.js +1 -1
- package/lib/components/common/openai/OpenAIUserAudioContent.js.map +1 -1
- package/lib/components/common/openai/OpenAIUserFileContent.js +1 -1
- package/lib/components/common/openai/OpenAIUserFileContent.js.map +1 -1
- package/lib/components/common/openai/OpenAIUserImageContent.d.ts +2 -2
- package/lib/components/events/AutoBeCompleteEventMovie.d.ts +2 -2
- package/lib/components/events/AutoBeCompleteEventMovie.js +5 -5
- package/lib/components/events/AutoBeCompleteEventMovie.js.map +1 -1
- package/lib/components/events/AutoBeCorrectEventMovie.d.ts +2 -2
- package/lib/components/events/AutoBeCorrectEventMovie.js +4 -4
- package/lib/components/events/AutoBeCorrectEventMovie.js.map +1 -1
- package/lib/components/events/AutoBeEventMovie.js +38 -17
- package/lib/components/events/AutoBeEventMovie.js.map +1 -1
- package/lib/components/events/AutoBeProgressEventMovie.js +73 -13
- package/lib/components/events/AutoBeProgressEventMovie.js.map +1 -1
- package/lib/components/events/AutoBeScenarioEventMovie.d.ts +2 -2
- package/lib/components/events/AutoBeScenarioEventMovie.js +18 -5
- package/lib/components/events/AutoBeScenarioEventMovie.js.map +1 -1
- package/lib/components/events/AutoBeStartEventMovie.d.ts +2 -2
- package/lib/components/events/AutoBeStartEventMovie.js +2 -2
- package/lib/components/events/AutoBeStartEventMovie.js.map +1 -1
- package/lib/components/events/AutoBeValidateEventMovie.d.ts +2 -2
- package/lib/components/events/AutoBeValidateEventMovie.js +3 -11
- package/lib/components/events/AutoBeValidateEventMovie.js.map +1 -1
- package/lib/components/events/groups/CorrectEventGroup.d.ts +2 -2
- package/lib/components/events/groups/CorrectEventGroup.js +1 -1
- package/lib/components/events/groups/CorrectEventGroup.js.map +1 -1
- package/lib/components/events/groups/ValidateEventGroup.d.ts +2 -2
- package/lib/components/events/groups/ValidateEventGroup.js +1 -2
- package/lib/components/events/groups/ValidateEventGroup.js.map +1 -1
- package/lib/components/events/utils/eventGrouper.js +1 -2
- package/lib/components/events/utils/eventGrouper.js.map +1 -1
- package/lib/components/upload/AutoBeChatUploadBox.d.ts +3 -4
- package/lib/components/upload/AutoBeChatUploadBox.js +2 -1
- package/lib/components/upload/AutoBeChatUploadBox.js.map +1 -1
- package/lib/components/upload/AutoBeChatUploadSendButton.js +1 -1
- package/lib/components/upload/AutoBeChatUploadSendButton.js.map +1 -1
- package/lib/context/AutoBeAgentContext.d.ts +1 -3
- package/lib/context/AutoBeAgentContext.js +0 -4
- package/lib/context/AutoBeAgentContext.js.map +1 -1
- package/lib/hooks/useSessionStorage.d.ts +4 -0
- package/lib/hooks/useSessionStorage.js +16 -0
- package/lib/hooks/useSessionStorage.js.map +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/strategy/AutoBeAgentSessionStorageStrategy.d.ts +10 -0
- package/lib/strategy/AutoBeAgentSessionStorageStrategy.js +117 -0
- package/lib/strategy/AutoBeAgentSessionStorageStrategy.js.map +1 -0
- package/lib/structure/AutoBeListener.js +91 -23
- package/lib/structure/AutoBeListener.js.map +1 -1
- package/lib/structure/AutoBeListenerState.d.ts +3 -3
- package/lib/structure/AutoBeListenerState.js +4 -4
- package/lib/structure/AutoBeListenerState.js.map +1 -1
- package/lib/structure/IAutoBeAgentSessionStorageStrategy.js +1 -1
- package/lib/structure/IAutoBeAgentSessionStorageStrategy.js.map +1 -1
- package/lib/utils/AutoBeFileUploader.d.ts +2 -2
- package/lib/utils/AutoBeFileUploader.js.map +1 -1
- package/package.json +3 -4
- package/src/components/AutoBeAssistantMessageMovie.tsx +22 -22
- package/src/components/AutoBeChatMain.tsx +376 -376
- package/src/components/AutoBeChatSidebar.tsx +414 -414
- package/src/components/AutoBeConfigButton.tsx +83 -83
- package/src/components/AutoBeConfigModal.tsx +443 -443
- package/src/components/AutoBeStatusButton.tsx +75 -75
- package/src/components/AutoBeStatusModal.tsx +486 -484
- package/src/components/AutoBeUserMessageMovie.tsx +27 -27
- package/src/components/common/ActionButton.tsx +205 -205
- package/src/components/common/ActionButtonGroup.tsx +80 -80
- package/src/components/common/AutoBeConfigInput.tsx +185 -185
- package/src/components/common/ChatBubble.tsx +119 -119
- package/src/components/common/Collapsible.tsx +95 -95
- package/src/components/common/CompactSessionIndicator.tsx +73 -73
- package/src/components/common/CompactSessionList.tsx +82 -82
- package/src/components/common/index.ts +8 -8
- package/src/components/common/openai/OpenAIContent.tsx +53 -53
- package/src/components/common/openai/OpenAIUserAudioContent.tsx +70 -70
- package/src/components/common/openai/OpenAIUserFileContent.tsx +76 -76
- package/src/components/common/openai/OpenAIUserImageContent.tsx +34 -34
- package/src/components/common/openai/OpenAIUserTextContent.tsx +15 -15
- package/src/components/common/openai/index.ts +5 -5
- package/src/components/events/AutoBeCompleteEventMovie.tsx +402 -402
- package/src/components/events/AutoBeCorrectEventMovie.tsx +354 -368
- package/src/components/events/AutoBeEventGroupMovie.tsx +18 -18
- package/src/components/events/AutoBeEventMovie.tsx +158 -139
- package/src/components/events/AutoBeProgressEventMovie.tsx +217 -157
- package/src/components/events/AutoBeScenarioEventMovie.tsx +135 -95
- package/src/components/events/AutoBeStartEventMovie.tsx +82 -82
- package/src/components/events/AutoBeValidateEventMovie.tsx +249 -286
- package/src/components/events/README.md +300 -300
- package/src/components/events/common/CollapsibleEventGroup.tsx +211 -211
- package/src/components/events/common/EventCard.tsx +61 -61
- package/src/components/events/common/EventContent.tsx +31 -31
- package/src/components/events/common/EventHeader.tsx +85 -85
- package/src/components/events/common/EventIcon.tsx +82 -82
- package/src/components/events/common/ProgressBar.tsx +64 -64
- package/src/components/events/common/index.ts +13 -13
- package/src/components/events/groups/CorrectEventGroup.tsx +183 -183
- package/src/components/events/groups/ValidateEventGroup.tsx +143 -146
- package/src/components/events/groups/index.ts +8 -8
- package/src/components/events/index.ts +16 -16
- package/src/components/events/utils/eventGrouper.tsx +116 -117
- package/src/components/events/utils/index.ts +1 -1
- package/src/components/index.ts +13 -13
- package/src/components/upload/AutoBeChatUploadBox.tsx +425 -424
- package/src/components/upload/AutoBeChatUploadSendButton.tsx +66 -66
- package/src/components/upload/AutoBeFileUploadBox.tsx +123 -123
- package/src/components/upload/AutoBeUploadConfig.ts +5 -5
- package/src/components/upload/AutoBeVoiceRecoderButton.tsx +100 -100
- package/src/components/upload/index.ts +5 -5
- package/src/constant/color.ts +28 -28
- package/src/context/AutoBeAgentContext.tsx +245 -258
- package/src/context/AutoBeAgentSessionList.tsx +58 -58
- package/src/context/SearchParamsContext.tsx +49 -49
- package/src/hooks/index.ts +3 -3
- package/src/hooks/useEscapeKey.ts +24 -24
- package/src/hooks/useIsomorphicLayoutEffect.ts +8 -8
- package/src/hooks/useMediaQuery.ts +73 -73
- package/src/hooks/useSessionStorage.ts +10 -0
- package/src/icons/Receipt.tsx +74 -74
- package/src/index.ts +9 -8
- package/src/strategy/AutoBeAgentSessionStorageStrategy.ts +127 -0
- package/src/structure/AutoBeListener.ts +373 -304
- package/src/structure/AutoBeListenerState.ts +53 -53
- package/src/structure/IAutoBeAgentSessionStorageStrategy.ts +87 -87
- package/src/structure/IAutoBeEventGroup.ts +6 -6
- package/src/structure/index.ts +4 -4
- package/src/types/config.ts +44 -44
- package/src/types/index.ts +1 -1
- package/src/utils/AutoBeFileUploader.ts +279 -279
- package/src/utils/AutoBeVoiceRecorder.ts +95 -95
- package/src/utils/__tests__/crypto.test.ts +286 -286
- package/src/utils/__tests__/storage.test.ts +229 -229
- package/src/utils/crypto.ts +95 -95
- package/src/utils/index.ts +6 -6
- package/src/utils/number.ts +17 -17
- package/src/utils/storage.ts +96 -96
- package/src/utils/time.ts +14 -14
- package/tsconfig.json +9 -9
- package/vitest.config.ts +15 -15
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
/** Props interface for AutoBeChatUploadSendButton component */
|
|
2
|
-
interface IAutoBeChatUploadSendButtonProps {
|
|
3
|
-
/** Function to trigger conversation */
|
|
4
|
-
onClick?: (event: React.MouseEvent<HTMLButtonElement>) => Promise<void>;
|
|
5
|
-
/** Whether the button is enabled */
|
|
6
|
-
enabled: boolean;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Chat upload send button component for triggering conversations
|
|
11
|
-
*
|
|
12
|
-
* @param props - Component props
|
|
13
|
-
* @returns JSX element representing the send button
|
|
14
|
-
*/
|
|
15
|
-
export const AutoBeChatUploadSendButton = (
|
|
16
|
-
props: IAutoBeChatUploadSendButtonProps,
|
|
17
|
-
) => {
|
|
18
|
-
const baseStyles: React.CSSProperties = {
|
|
19
|
-
padding: "6px",
|
|
20
|
-
border: "none",
|
|
21
|
-
borderRadius: "50%",
|
|
22
|
-
backgroundColor: props.enabled ? "#1976d2" : "#e0e0e0",
|
|
23
|
-
color: props.enabled ? "#ffffff" : "#9e9e9e",
|
|
24
|
-
cursor: props.enabled ? "pointer" : "not-allowed",
|
|
25
|
-
display: "inline-flex",
|
|
26
|
-
alignItems: "center",
|
|
27
|
-
justifyContent: "center",
|
|
28
|
-
transition: "background-color 0.3s ease",
|
|
29
|
-
outline: "none",
|
|
30
|
-
width: "32px",
|
|
31
|
-
height: "32px",
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const hoverStyles: React.CSSProperties = {
|
|
35
|
-
...baseStyles,
|
|
36
|
-
backgroundColor: props.enabled ? "#1565c0" : "#e0e0e0",
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
return (
|
|
40
|
-
<button
|
|
41
|
-
style={baseStyles}
|
|
42
|
-
onClick={(e) => void props.onClick?.(e)}
|
|
43
|
-
disabled={!props.enabled}
|
|
44
|
-
onMouseEnter={(e) => {
|
|
45
|
-
if (props.enabled) {
|
|
46
|
-
Object.assign(e.currentTarget.style, hoverStyles);
|
|
47
|
-
}
|
|
48
|
-
}}
|
|
49
|
-
onMouseLeave={(e) => {
|
|
50
|
-
Object.assign(e.currentTarget.style, baseStyles);
|
|
51
|
-
}}
|
|
52
|
-
>
|
|
53
|
-
<svg
|
|
54
|
-
width="16"
|
|
55
|
-
height="16"
|
|
56
|
-
viewBox="0 0 24 24"
|
|
57
|
-
fill="currentColor"
|
|
58
|
-
style={{ display: "block" }}
|
|
59
|
-
>
|
|
60
|
-
<path d="M4 12l1.41 1.41L11 7.83V20h2V7.83l5.59 5.58L20 12l-8-8-8 8z" />
|
|
61
|
-
</svg>
|
|
62
|
-
</button>
|
|
63
|
-
);
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
export default AutoBeChatUploadSendButton;
|
|
1
|
+
/** Props interface for AutoBeChatUploadSendButton component */
|
|
2
|
+
interface IAutoBeChatUploadSendButtonProps {
|
|
3
|
+
/** Function to trigger conversation */
|
|
4
|
+
onClick?: (event: React.MouseEvent<HTMLButtonElement>) => Promise<void>;
|
|
5
|
+
/** Whether the button is enabled */
|
|
6
|
+
enabled: boolean;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Chat upload send button component for triggering conversations
|
|
11
|
+
*
|
|
12
|
+
* @param props - Component props
|
|
13
|
+
* @returns JSX element representing the send button
|
|
14
|
+
*/
|
|
15
|
+
export const AutoBeChatUploadSendButton = (
|
|
16
|
+
props: IAutoBeChatUploadSendButtonProps,
|
|
17
|
+
) => {
|
|
18
|
+
const baseStyles: React.CSSProperties = {
|
|
19
|
+
padding: "6px",
|
|
20
|
+
border: "none",
|
|
21
|
+
borderRadius: "50%",
|
|
22
|
+
backgroundColor: props.enabled ? "#1976d2" : "#e0e0e0",
|
|
23
|
+
color: props.enabled ? "#ffffff" : "#9e9e9e",
|
|
24
|
+
cursor: props.enabled ? "pointer" : "not-allowed",
|
|
25
|
+
display: "inline-flex",
|
|
26
|
+
alignItems: "center",
|
|
27
|
+
justifyContent: "center",
|
|
28
|
+
transition: "background-color 0.3s ease",
|
|
29
|
+
outline: "none",
|
|
30
|
+
width: "32px",
|
|
31
|
+
height: "32px",
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const hoverStyles: React.CSSProperties = {
|
|
35
|
+
...baseStyles,
|
|
36
|
+
backgroundColor: props.enabled ? "#1565c0" : "#e0e0e0",
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<button
|
|
41
|
+
style={baseStyles}
|
|
42
|
+
onClick={(e) => void props.onClick?.(e)}
|
|
43
|
+
disabled={!props.enabled}
|
|
44
|
+
onMouseEnter={(e) => {
|
|
45
|
+
if (props.enabled) {
|
|
46
|
+
Object.assign(e.currentTarget.style, hoverStyles);
|
|
47
|
+
}
|
|
48
|
+
}}
|
|
49
|
+
onMouseLeave={(e) => {
|
|
50
|
+
Object.assign(e.currentTarget.style, baseStyles);
|
|
51
|
+
}}
|
|
52
|
+
>
|
|
53
|
+
<svg
|
|
54
|
+
width="16"
|
|
55
|
+
height="16"
|
|
56
|
+
viewBox="0 0 24 24"
|
|
57
|
+
fill="currentColor"
|
|
58
|
+
style={{ display: "block" }}
|
|
59
|
+
>
|
|
60
|
+
<path d="M4 12l1.41 1.41L11 7.83V20h2V7.83l5.59 5.58L20 12l-8-8-8 8z" />
|
|
61
|
+
</svg>
|
|
62
|
+
</button>
|
|
63
|
+
);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export default AutoBeChatUploadSendButton;
|
|
@@ -1,123 +1,123 @@
|
|
|
1
|
-
import { ReactNode, useState } from "react";
|
|
2
|
-
|
|
3
|
-
export interface IAutoBeFileUploadBoxProps {
|
|
4
|
-
extensionError: ReactNode | null;
|
|
5
|
-
onClick: () => void;
|
|
6
|
-
enabled: boolean;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export const AutoBeFileUploadBox = (props: IAutoBeFileUploadBoxProps) => {
|
|
10
|
-
const [isHovered, setIsHovered] = useState(false);
|
|
11
|
-
|
|
12
|
-
const hasError = !!props.extensionError;
|
|
13
|
-
|
|
14
|
-
const getButtonStyles = () => {
|
|
15
|
-
const baseStyles = {
|
|
16
|
-
display: "inline-flex",
|
|
17
|
-
alignItems: "center",
|
|
18
|
-
justifyContent: "center",
|
|
19
|
-
width: "40px",
|
|
20
|
-
height: "40px",
|
|
21
|
-
padding: "0",
|
|
22
|
-
border: "1px solid",
|
|
23
|
-
borderRadius: "50%",
|
|
24
|
-
cursor: props.enabled ? "pointer" : "not-allowed",
|
|
25
|
-
backgroundColor: hasError ? "#fef2f2" : "transparent",
|
|
26
|
-
borderColor: hasError ? "#f87171" : isHovered ? "#3b82f6" : "#d1d5db",
|
|
27
|
-
opacity: props.enabled ? 1 : 0.5,
|
|
28
|
-
transition: "all 0.3s ease",
|
|
29
|
-
position: "relative" as const,
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
if (isHovered && props.enabled) {
|
|
33
|
-
return {
|
|
34
|
-
...baseStyles,
|
|
35
|
-
backgroundColor: hasError ? "#fef2f2" : "#f3f4f6",
|
|
36
|
-
borderColor: hasError ? "#f87171" : "#3b82f6",
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return baseStyles;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
const iconColor = hasError ? "#ef4444" : "#6b7280";
|
|
44
|
-
|
|
45
|
-
return (
|
|
46
|
-
<div style={{ position: "relative", display: "inline-block" }}>
|
|
47
|
-
<button
|
|
48
|
-
onClick={props.onClick}
|
|
49
|
-
disabled={!props.enabled}
|
|
50
|
-
style={getButtonStyles()}
|
|
51
|
-
onMouseEnter={() => {
|
|
52
|
-
setIsHovered(true);
|
|
53
|
-
}}
|
|
54
|
-
onMouseLeave={() => {
|
|
55
|
-
setIsHovered(false);
|
|
56
|
-
}}
|
|
57
|
-
>
|
|
58
|
-
{hasError ? (
|
|
59
|
-
// Error Icon (SVG)
|
|
60
|
-
<svg
|
|
61
|
-
width="20"
|
|
62
|
-
height="20"
|
|
63
|
-
viewBox="0 0 24 24"
|
|
64
|
-
fill="currentColor"
|
|
65
|
-
style={{ color: iconColor }}
|
|
66
|
-
>
|
|
67
|
-
<path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z" />
|
|
68
|
-
</svg>
|
|
69
|
-
) : (
|
|
70
|
-
// Add Icon (SVG)
|
|
71
|
-
<svg
|
|
72
|
-
width="20"
|
|
73
|
-
height="20"
|
|
74
|
-
viewBox="0 0 24 24"
|
|
75
|
-
fill="currentColor"
|
|
76
|
-
style={{ color: iconColor }}
|
|
77
|
-
>
|
|
78
|
-
<path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" />
|
|
79
|
-
</svg>
|
|
80
|
-
)}
|
|
81
|
-
</button>
|
|
82
|
-
|
|
83
|
-
{/* Custom Tooltip - Always show when there's an error */}
|
|
84
|
-
{hasError && (
|
|
85
|
-
<div
|
|
86
|
-
style={{
|
|
87
|
-
position: "absolute",
|
|
88
|
-
bottom: "100%",
|
|
89
|
-
left: "50%",
|
|
90
|
-
transform: "translateX(-50%)",
|
|
91
|
-
marginBottom: "8px",
|
|
92
|
-
padding: "8px 12px",
|
|
93
|
-
backgroundColor: "#ef4444",
|
|
94
|
-
color: "#ffffff",
|
|
95
|
-
borderRadius: "6px",
|
|
96
|
-
fontSize: "14px",
|
|
97
|
-
whiteSpace: "nowrap",
|
|
98
|
-
zIndex: 1000,
|
|
99
|
-
boxShadow: "0 2px 8px rgba(0, 0, 0, 0.15)",
|
|
100
|
-
}}
|
|
101
|
-
>
|
|
102
|
-
{props.extensionError}
|
|
103
|
-
{/* Tooltip Arrow */}
|
|
104
|
-
<div
|
|
105
|
-
style={{
|
|
106
|
-
position: "absolute",
|
|
107
|
-
top: "100%",
|
|
108
|
-
left: "50%",
|
|
109
|
-
transform: "translateX(-50%)",
|
|
110
|
-
width: 0,
|
|
111
|
-
height: 0,
|
|
112
|
-
borderLeft: "6px solid transparent",
|
|
113
|
-
borderRight: "6px solid transparent",
|
|
114
|
-
borderTop: "6px solid #ef4444",
|
|
115
|
-
}}
|
|
116
|
-
/>
|
|
117
|
-
</div>
|
|
118
|
-
)}
|
|
119
|
-
</div>
|
|
120
|
-
);
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
export default AutoBeFileUploadBox;
|
|
1
|
+
import { ReactNode, useState } from "react";
|
|
2
|
+
|
|
3
|
+
export interface IAutoBeFileUploadBoxProps {
|
|
4
|
+
extensionError: ReactNode | null;
|
|
5
|
+
onClick: () => void;
|
|
6
|
+
enabled: boolean;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const AutoBeFileUploadBox = (props: IAutoBeFileUploadBoxProps) => {
|
|
10
|
+
const [isHovered, setIsHovered] = useState(false);
|
|
11
|
+
|
|
12
|
+
const hasError = !!props.extensionError;
|
|
13
|
+
|
|
14
|
+
const getButtonStyles = () => {
|
|
15
|
+
const baseStyles = {
|
|
16
|
+
display: "inline-flex",
|
|
17
|
+
alignItems: "center",
|
|
18
|
+
justifyContent: "center",
|
|
19
|
+
width: "40px",
|
|
20
|
+
height: "40px",
|
|
21
|
+
padding: "0",
|
|
22
|
+
border: "1px solid",
|
|
23
|
+
borderRadius: "50%",
|
|
24
|
+
cursor: props.enabled ? "pointer" : "not-allowed",
|
|
25
|
+
backgroundColor: hasError ? "#fef2f2" : "transparent",
|
|
26
|
+
borderColor: hasError ? "#f87171" : isHovered ? "#3b82f6" : "#d1d5db",
|
|
27
|
+
opacity: props.enabled ? 1 : 0.5,
|
|
28
|
+
transition: "all 0.3s ease",
|
|
29
|
+
position: "relative" as const,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
if (isHovered && props.enabled) {
|
|
33
|
+
return {
|
|
34
|
+
...baseStyles,
|
|
35
|
+
backgroundColor: hasError ? "#fef2f2" : "#f3f4f6",
|
|
36
|
+
borderColor: hasError ? "#f87171" : "#3b82f6",
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return baseStyles;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const iconColor = hasError ? "#ef4444" : "#6b7280";
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<div style={{ position: "relative", display: "inline-block" }}>
|
|
47
|
+
<button
|
|
48
|
+
onClick={props.onClick}
|
|
49
|
+
disabled={!props.enabled}
|
|
50
|
+
style={getButtonStyles()}
|
|
51
|
+
onMouseEnter={() => {
|
|
52
|
+
setIsHovered(true);
|
|
53
|
+
}}
|
|
54
|
+
onMouseLeave={() => {
|
|
55
|
+
setIsHovered(false);
|
|
56
|
+
}}
|
|
57
|
+
>
|
|
58
|
+
{hasError ? (
|
|
59
|
+
// Error Icon (SVG)
|
|
60
|
+
<svg
|
|
61
|
+
width="20"
|
|
62
|
+
height="20"
|
|
63
|
+
viewBox="0 0 24 24"
|
|
64
|
+
fill="currentColor"
|
|
65
|
+
style={{ color: iconColor }}
|
|
66
|
+
>
|
|
67
|
+
<path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z" />
|
|
68
|
+
</svg>
|
|
69
|
+
) : (
|
|
70
|
+
// Add Icon (SVG)
|
|
71
|
+
<svg
|
|
72
|
+
width="20"
|
|
73
|
+
height="20"
|
|
74
|
+
viewBox="0 0 24 24"
|
|
75
|
+
fill="currentColor"
|
|
76
|
+
style={{ color: iconColor }}
|
|
77
|
+
>
|
|
78
|
+
<path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" />
|
|
79
|
+
</svg>
|
|
80
|
+
)}
|
|
81
|
+
</button>
|
|
82
|
+
|
|
83
|
+
{/* Custom Tooltip - Always show when there's an error */}
|
|
84
|
+
{hasError && (
|
|
85
|
+
<div
|
|
86
|
+
style={{
|
|
87
|
+
position: "absolute",
|
|
88
|
+
bottom: "100%",
|
|
89
|
+
left: "50%",
|
|
90
|
+
transform: "translateX(-50%)",
|
|
91
|
+
marginBottom: "8px",
|
|
92
|
+
padding: "8px 12px",
|
|
93
|
+
backgroundColor: "#ef4444",
|
|
94
|
+
color: "#ffffff",
|
|
95
|
+
borderRadius: "6px",
|
|
96
|
+
fontSize: "14px",
|
|
97
|
+
whiteSpace: "nowrap",
|
|
98
|
+
zIndex: 1000,
|
|
99
|
+
boxShadow: "0 2px 8px rgba(0, 0, 0, 0.15)",
|
|
100
|
+
}}
|
|
101
|
+
>
|
|
102
|
+
{props.extensionError}
|
|
103
|
+
{/* Tooltip Arrow */}
|
|
104
|
+
<div
|
|
105
|
+
style={{
|
|
106
|
+
position: "absolute",
|
|
107
|
+
top: "100%",
|
|
108
|
+
left: "50%",
|
|
109
|
+
transform: "translateX(-50%)",
|
|
110
|
+
width: 0,
|
|
111
|
+
height: 0,
|
|
112
|
+
borderLeft: "6px solid transparent",
|
|
113
|
+
borderRight: "6px solid transparent",
|
|
114
|
+
borderTop: "6px solid #ef4444",
|
|
115
|
+
}}
|
|
116
|
+
/>
|
|
117
|
+
</div>
|
|
118
|
+
)}
|
|
119
|
+
</div>
|
|
120
|
+
);
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
export default AutoBeFileUploadBox;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export interface IAutoBeUploadConfig {
|
|
2
|
-
supportAudio?: boolean;
|
|
3
|
-
file?: (file: File) => Promise<{ id: string }>;
|
|
4
|
-
image?: (file: File) => Promise<{ url: string }>;
|
|
5
|
-
}
|
|
1
|
+
export interface IAutoBeUploadConfig {
|
|
2
|
+
supportAudio?: boolean;
|
|
3
|
+
file?: (file: File) => Promise<{ id: string }>;
|
|
4
|
+
image?: (file: File) => Promise<{ url: string }>;
|
|
5
|
+
}
|
|
@@ -1,100 +1,100 @@
|
|
|
1
|
-
import { AutoBeUserMessageAudioContent } from "@autobe/interface";
|
|
2
|
-
import { useState } from "react";
|
|
3
|
-
|
|
4
|
-
import { AutoBeVoiceRecorder } from "../../utils/AutoBeVoiceRecorder";
|
|
5
|
-
|
|
6
|
-
export const AutoBeVoiceRecoderButton = (
|
|
7
|
-
props: AutoBeVoiceRecoderButton.IProps,
|
|
8
|
-
) => {
|
|
9
|
-
const [isRecording, setIsRecording] = useState(false);
|
|
10
|
-
const [mediaRecorder, setMediaRecorder] = useState<MediaRecorder | null>(
|
|
11
|
-
null,
|
|
12
|
-
);
|
|
13
|
-
|
|
14
|
-
const startRecording = async () => {
|
|
15
|
-
const recorder = await AutoBeVoiceRecorder.start(props.onComplete);
|
|
16
|
-
recorder.start();
|
|
17
|
-
setMediaRecorder(recorder);
|
|
18
|
-
setIsRecording(true);
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const stopRecording = () => {
|
|
22
|
-
if (mediaRecorder && mediaRecorder.state !== "inactive") {
|
|
23
|
-
mediaRecorder.stop();
|
|
24
|
-
setIsRecording(false);
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const baseStyles: React.CSSProperties = {
|
|
29
|
-
padding: "6px",
|
|
30
|
-
border: "1px solid",
|
|
31
|
-
borderColor: isRecording ? "#f44336" : "#e0e0e0",
|
|
32
|
-
borderRadius: "4px",
|
|
33
|
-
backgroundColor: isRecording ? "#ffebee" : "transparent",
|
|
34
|
-
color: isRecording ? "#f44336" : "#1976d2",
|
|
35
|
-
cursor: props.enabled ? "pointer" : "not-allowed",
|
|
36
|
-
display: "inline-flex",
|
|
37
|
-
alignItems: "center",
|
|
38
|
-
justifyContent: "center",
|
|
39
|
-
transition: "all 0.3s ease",
|
|
40
|
-
outline: "none",
|
|
41
|
-
width: "32px",
|
|
42
|
-
height: "32px",
|
|
43
|
-
opacity: props.enabled ? 1 : 0.5,
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const hoverStyles: React.CSSProperties = {
|
|
47
|
-
...baseStyles,
|
|
48
|
-
backgroundColor: isRecording ? "#f44336" : "#f5f5f5",
|
|
49
|
-
borderColor: isRecording ? "#d32f2f" : "#1976d2",
|
|
50
|
-
color: isRecording ? "#ffffff" : "#1976d2",
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
return (
|
|
54
|
-
<button
|
|
55
|
-
style={baseStyles}
|
|
56
|
-
onClick={isRecording ? stopRecording : () => void startRecording()}
|
|
57
|
-
disabled={!props.enabled}
|
|
58
|
-
onMouseEnter={(e) => {
|
|
59
|
-
if (props.enabled) {
|
|
60
|
-
Object.assign(e.currentTarget.style, hoverStyles);
|
|
61
|
-
}
|
|
62
|
-
}}
|
|
63
|
-
onMouseLeave={(e) => {
|
|
64
|
-
Object.assign(e.currentTarget.style, baseStyles);
|
|
65
|
-
}}
|
|
66
|
-
>
|
|
67
|
-
{isRecording ? (
|
|
68
|
-
<svg
|
|
69
|
-
width="16"
|
|
70
|
-
height="16"
|
|
71
|
-
viewBox="0 0 24 24"
|
|
72
|
-
fill="currentColor"
|
|
73
|
-
style={{ display: "block" }}
|
|
74
|
-
>
|
|
75
|
-
<path d="M6 6h12v12H6z" />
|
|
76
|
-
</svg>
|
|
77
|
-
) : (
|
|
78
|
-
<svg
|
|
79
|
-
width="16"
|
|
80
|
-
height="16"
|
|
81
|
-
viewBox="0 0 24 24"
|
|
82
|
-
fill="currentColor"
|
|
83
|
-
style={{ display: "block" }}
|
|
84
|
-
>
|
|
85
|
-
<path d="M12 2C13.1 2 14 2.9 14 4V10C14 11.1 13.1 12 12 12C10.9 12 10 11.1 10 10V4C10 2.9 10.9 2 12 2ZM19 10V12C19 15.866 15.866 19 12 19C8.134 19 5 15.866 5 12V10H7V12C7 14.761 9.239 17 12 17C14.761 17 17 14.761 17 12V10H19ZM11 20V22H13V20H16V22H8V20H11Z" />
|
|
86
|
-
</svg>
|
|
87
|
-
)}
|
|
88
|
-
</button>
|
|
89
|
-
);
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
export namespace AutoBeVoiceRecoderButton {
|
|
93
|
-
export interface IProps {
|
|
94
|
-
enabled: boolean;
|
|
95
|
-
onComplete: (content: {
|
|
96
|
-
file: File;
|
|
97
|
-
content: AutoBeUserMessageAudioContent;
|
|
98
|
-
}) => void;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
1
|
+
import { AutoBeUserMessageAudioContent } from "@autobe/interface";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
|
|
4
|
+
import { AutoBeVoiceRecorder } from "../../utils/AutoBeVoiceRecorder";
|
|
5
|
+
|
|
6
|
+
export const AutoBeVoiceRecoderButton = (
|
|
7
|
+
props: AutoBeVoiceRecoderButton.IProps,
|
|
8
|
+
) => {
|
|
9
|
+
const [isRecording, setIsRecording] = useState(false);
|
|
10
|
+
const [mediaRecorder, setMediaRecorder] = useState<MediaRecorder | null>(
|
|
11
|
+
null,
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
const startRecording = async () => {
|
|
15
|
+
const recorder = await AutoBeVoiceRecorder.start(props.onComplete);
|
|
16
|
+
recorder.start();
|
|
17
|
+
setMediaRecorder(recorder);
|
|
18
|
+
setIsRecording(true);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const stopRecording = () => {
|
|
22
|
+
if (mediaRecorder && mediaRecorder.state !== "inactive") {
|
|
23
|
+
mediaRecorder.stop();
|
|
24
|
+
setIsRecording(false);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const baseStyles: React.CSSProperties = {
|
|
29
|
+
padding: "6px",
|
|
30
|
+
border: "1px solid",
|
|
31
|
+
borderColor: isRecording ? "#f44336" : "#e0e0e0",
|
|
32
|
+
borderRadius: "4px",
|
|
33
|
+
backgroundColor: isRecording ? "#ffebee" : "transparent",
|
|
34
|
+
color: isRecording ? "#f44336" : "#1976d2",
|
|
35
|
+
cursor: props.enabled ? "pointer" : "not-allowed",
|
|
36
|
+
display: "inline-flex",
|
|
37
|
+
alignItems: "center",
|
|
38
|
+
justifyContent: "center",
|
|
39
|
+
transition: "all 0.3s ease",
|
|
40
|
+
outline: "none",
|
|
41
|
+
width: "32px",
|
|
42
|
+
height: "32px",
|
|
43
|
+
opacity: props.enabled ? 1 : 0.5,
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const hoverStyles: React.CSSProperties = {
|
|
47
|
+
...baseStyles,
|
|
48
|
+
backgroundColor: isRecording ? "#f44336" : "#f5f5f5",
|
|
49
|
+
borderColor: isRecording ? "#d32f2f" : "#1976d2",
|
|
50
|
+
color: isRecording ? "#ffffff" : "#1976d2",
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<button
|
|
55
|
+
style={baseStyles}
|
|
56
|
+
onClick={isRecording ? stopRecording : () => void startRecording()}
|
|
57
|
+
disabled={!props.enabled}
|
|
58
|
+
onMouseEnter={(e) => {
|
|
59
|
+
if (props.enabled) {
|
|
60
|
+
Object.assign(e.currentTarget.style, hoverStyles);
|
|
61
|
+
}
|
|
62
|
+
}}
|
|
63
|
+
onMouseLeave={(e) => {
|
|
64
|
+
Object.assign(e.currentTarget.style, baseStyles);
|
|
65
|
+
}}
|
|
66
|
+
>
|
|
67
|
+
{isRecording ? (
|
|
68
|
+
<svg
|
|
69
|
+
width="16"
|
|
70
|
+
height="16"
|
|
71
|
+
viewBox="0 0 24 24"
|
|
72
|
+
fill="currentColor"
|
|
73
|
+
style={{ display: "block" }}
|
|
74
|
+
>
|
|
75
|
+
<path d="M6 6h12v12H6z" />
|
|
76
|
+
</svg>
|
|
77
|
+
) : (
|
|
78
|
+
<svg
|
|
79
|
+
width="16"
|
|
80
|
+
height="16"
|
|
81
|
+
viewBox="0 0 24 24"
|
|
82
|
+
fill="currentColor"
|
|
83
|
+
style={{ display: "block" }}
|
|
84
|
+
>
|
|
85
|
+
<path d="M12 2C13.1 2 14 2.9 14 4V10C14 11.1 13.1 12 12 12C10.9 12 10 11.1 10 10V4C10 2.9 10.9 2 12 2ZM19 10V12C19 15.866 15.866 19 12 19C8.134 19 5 15.866 5 12V10H7V12C7 14.761 9.239 17 12 17C14.761 17 17 14.761 17 12V10H19ZM11 20V22H13V20H16V22H8V20H11Z" />
|
|
86
|
+
</svg>
|
|
87
|
+
)}
|
|
88
|
+
</button>
|
|
89
|
+
);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export namespace AutoBeVoiceRecoderButton {
|
|
93
|
+
export interface IProps {
|
|
94
|
+
enabled: boolean;
|
|
95
|
+
onComplete: (content: {
|
|
96
|
+
file: File;
|
|
97
|
+
content: AutoBeUserMessageAudioContent;
|
|
98
|
+
}) => void;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from "./AutoBeFileUploadBox";
|
|
2
|
-
export * from "./AutoBeVoiceRecoderButton";
|
|
3
|
-
export * from "./AutoBeChatUploadBox";
|
|
4
|
-
export * from "./AutoBeChatUploadSendButton";
|
|
5
|
-
export * from "./AutoBeUploadConfig";
|
|
1
|
+
export * from "./AutoBeFileUploadBox";
|
|
2
|
+
export * from "./AutoBeVoiceRecoderButton";
|
|
3
|
+
export * from "./AutoBeChatUploadBox";
|
|
4
|
+
export * from "./AutoBeChatUploadSendButton";
|
|
5
|
+
export * from "./AutoBeUploadConfig";
|
package/src/constant/color.ts
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
/** Color tokens for consistent styling */
|
|
2
|
-
export const COLORS = {
|
|
3
|
-
// Gray scale
|
|
4
|
-
GRAY_BORDER: "#d1d5db",
|
|
5
|
-
GRAY_BACKGROUND: "#f9fafb",
|
|
6
|
-
GRAY_BORDER_LIGHT: "#e5e7eb",
|
|
7
|
-
GRAY_TEXT_DARK: "#1f2937",
|
|
8
|
-
GRAY_TEXT_MEDIUM: "#4b5563",
|
|
9
|
-
|
|
10
|
-
// Token value colors
|
|
11
|
-
TOKEN_INPUT: "#2563eb", // Blue
|
|
12
|
-
TOKEN_OUTPUT: "#16a34a", // Green
|
|
13
|
-
TOKEN_TOTAL: "#9333ea", // Purple
|
|
14
|
-
|
|
15
|
-
// Table colors
|
|
16
|
-
TABLE_BORDER: "#eee",
|
|
17
|
-
TABLE_BORDER_THICK: "#ddd",
|
|
18
|
-
TABLE_HEADER_BG: "#f5f5f5",
|
|
19
|
-
} as const;
|
|
20
|
-
|
|
21
|
-
/** Shadow styles */
|
|
22
|
-
export const SHADOWS = {
|
|
23
|
-
CARD: "0 1px 2px 0 rgba(0, 0, 0, 0.05)",
|
|
24
|
-
BANNER: "0 1px 2px 0 rgba(0, 0, 0, 0.1)",
|
|
25
|
-
STRONG: "0 4px 12px 0 rgba(0, 0, 0, 0.15)",
|
|
26
|
-
BUTTON: "0 2px 8px 0 rgba(0, 0, 0, 0.12)",
|
|
27
|
-
BUTTON_HOVER: "0 4px 16px 0 rgba(0, 0, 0, 0.2)",
|
|
28
|
-
} as const;
|
|
1
|
+
/** Color tokens for consistent styling */
|
|
2
|
+
export const COLORS = {
|
|
3
|
+
// Gray scale
|
|
4
|
+
GRAY_BORDER: "#d1d5db",
|
|
5
|
+
GRAY_BACKGROUND: "#f9fafb",
|
|
6
|
+
GRAY_BORDER_LIGHT: "#e5e7eb",
|
|
7
|
+
GRAY_TEXT_DARK: "#1f2937",
|
|
8
|
+
GRAY_TEXT_MEDIUM: "#4b5563",
|
|
9
|
+
|
|
10
|
+
// Token value colors
|
|
11
|
+
TOKEN_INPUT: "#2563eb", // Blue
|
|
12
|
+
TOKEN_OUTPUT: "#16a34a", // Green
|
|
13
|
+
TOKEN_TOTAL: "#9333ea", // Purple
|
|
14
|
+
|
|
15
|
+
// Table colors
|
|
16
|
+
TABLE_BORDER: "#eee",
|
|
17
|
+
TABLE_BORDER_THICK: "#ddd",
|
|
18
|
+
TABLE_HEADER_BG: "#f5f5f5",
|
|
19
|
+
} as const;
|
|
20
|
+
|
|
21
|
+
/** Shadow styles */
|
|
22
|
+
export const SHADOWS = {
|
|
23
|
+
CARD: "0 1px 2px 0 rgba(0, 0, 0, 0.05)",
|
|
24
|
+
BANNER: "0 1px 2px 0 rgba(0, 0, 0, 0.1)",
|
|
25
|
+
STRONG: "0 4px 12px 0 rgba(0, 0, 0, 0.15)",
|
|
26
|
+
BUTTON: "0 2px 8px 0 rgba(0, 0, 0, 0.12)",
|
|
27
|
+
BUTTON_HOVER: "0 4px 16px 0 rgba(0, 0, 0, 0.2)",
|
|
28
|
+
} as const;
|