@px-ui/ai 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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 PX-UI
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,13 @@
1
+ # @px-ui/ai
2
+
3
+ AI components built on top of @px-ui/core.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pnpm add @px-ui/ai
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ Components will be added here as they are developed.
@@ -0,0 +1,18 @@
1
+ export function ChatIcon(props: React.ComponentProps<"svg">) {
2
+ return (
3
+ <svg
4
+ width="18"
5
+ height="18"
6
+ viewBox="0 0 24 24"
7
+ fill="none"
8
+ stroke="currentColor"
9
+ strokeWidth="2"
10
+ strokeLinecap="round"
11
+ strokeLinejoin="round"
12
+ {...props}
13
+ >
14
+ <path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" />
15
+ </svg>
16
+ );
17
+ }
18
+
@@ -0,0 +1,18 @@
1
+ export function CheckIcon(props: React.ComponentProps<"svg">) {
2
+ return (
3
+ <svg
4
+ width="16"
5
+ height="16"
6
+ viewBox="0 0 24 24"
7
+ fill="none"
8
+ stroke="currentColor"
9
+ strokeWidth="2"
10
+ strokeLinecap="round"
11
+ strokeLinejoin="round"
12
+ {...props}
13
+ >
14
+ <path d="M20 6 9 17l-5-5" />
15
+ </svg>
16
+ );
17
+ }
18
+
@@ -0,0 +1,19 @@
1
+ export function CloseIcon(props: React.ComponentProps<"svg">) {
2
+ return (
3
+ <svg
4
+ width="20"
5
+ height="20"
6
+ viewBox="0 0 24 24"
7
+ fill="none"
8
+ stroke="currentColor"
9
+ strokeWidth="2"
10
+ strokeLinecap="round"
11
+ strokeLinejoin="round"
12
+ {...props}
13
+ >
14
+ <path d="M18 6 6 18" />
15
+ <path d="m6 6 12 12" />
16
+ </svg>
17
+ );
18
+ }
19
+
@@ -0,0 +1,19 @@
1
+ export function CopyIcon(props: React.ComponentProps<"svg">) {
2
+ return (
3
+ <svg
4
+ width="16"
5
+ height="16"
6
+ viewBox="0 0 24 24"
7
+ fill="none"
8
+ stroke="currentColor"
9
+ strokeWidth="2"
10
+ strokeLinecap="round"
11
+ strokeLinejoin="round"
12
+ {...props}
13
+ >
14
+ <rect width="14" height="14" x="8" y="8" rx="2" ry="2" />
15
+ <path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" />
16
+ </svg>
17
+ );
18
+ }
19
+
@@ -0,0 +1,19 @@
1
+ export function DebugIcon(props: React.ComponentProps<"svg">) {
2
+ return (
3
+ <svg
4
+ width="16"
5
+ height="16"
6
+ viewBox="0 0 24 24"
7
+ fill="none"
8
+ stroke="currentColor"
9
+ strokeWidth="2"
10
+ strokeLinecap="round"
11
+ strokeLinejoin="round"
12
+ {...props}
13
+ >
14
+ <path d="M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1" />
15
+ <path d="M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1" />
16
+ </svg>
17
+ );
18
+ }
19
+
@@ -0,0 +1,11 @@
1
+ export { ChatIcon } from "./chat-icon";
2
+ export { CheckIcon } from "./check-icon";
3
+ export { CloseIcon } from "./close-icon";
4
+ export { CopyIcon } from "./copy-icon";
5
+ export { DebugIcon } from "./debug-icon";
6
+ export { MenuIcon } from "./menu-icon";
7
+ export { NewChatIcon } from "./new-chat-icon";
8
+ export { SparklesIcon } from "./sparkles-icon";
9
+ export { ThumbsDownIcon } from "./thumbs-down-icon";
10
+ export { ThumbsUpIcon } from "./thumbs-up-icon";
11
+
@@ -0,0 +1,20 @@
1
+ export function MenuIcon(props: React.ComponentProps<"svg">) {
2
+ return (
3
+ <svg
4
+ width="20"
5
+ height="20"
6
+ viewBox="0 0 24 24"
7
+ fill="none"
8
+ stroke="currentColor"
9
+ strokeWidth="2"
10
+ strokeLinecap="round"
11
+ strokeLinejoin="round"
12
+ {...props}
13
+ >
14
+ <line x1="4" x2="20" y1="12" y2="12" />
15
+ <line x1="4" x2="20" y1="6" y2="6" />
16
+ <line x1="4" x2="20" y1="18" y2="18" />
17
+ </svg>
18
+ );
19
+ }
20
+
@@ -0,0 +1,19 @@
1
+ export function NewChatIcon(props: React.ComponentProps<"svg">) {
2
+ return (
3
+ <svg
4
+ width="20"
5
+ height="20"
6
+ viewBox="0 0 24 24"
7
+ fill="none"
8
+ stroke="currentColor"
9
+ strokeWidth="2"
10
+ strokeLinecap="round"
11
+ strokeLinejoin="round"
12
+ {...props}
13
+ >
14
+ <path d="M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7" />
15
+ <path d="M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z" />
16
+ </svg>
17
+ );
18
+ }
19
+
@@ -0,0 +1,23 @@
1
+ export function SparklesIcon(props: React.ComponentProps<"svg">) {
2
+ return (
3
+ <svg
4
+ xmlns="http://www.w3.org/2000/svg"
5
+ width="20"
6
+ height="20"
7
+ viewBox="0 0 24 24"
8
+ fill="none"
9
+ stroke="currentColor"
10
+ strokeWidth="2"
11
+ strokeLinecap="round"
12
+ strokeLinejoin="round"
13
+ {...props}
14
+ >
15
+ <path d="M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z" />
16
+ <path d="M20 3v4" />
17
+ <path d="M22 5h-4" />
18
+ <path d="M4 17v2" />
19
+ <path d="M5 18H3" />
20
+ </svg>
21
+ );
22
+ }
23
+
@@ -0,0 +1,19 @@
1
+ export function ThumbsDownIcon(props: React.ComponentProps<"svg">) {
2
+ return (
3
+ <svg
4
+ width="16"
5
+ height="16"
6
+ viewBox="0 0 24 24"
7
+ fill="none"
8
+ stroke="currentColor"
9
+ strokeWidth="2"
10
+ strokeLinecap="round"
11
+ strokeLinejoin="round"
12
+ {...props}
13
+ >
14
+ <path d="M17 14V2" />
15
+ <path d="M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z" />
16
+ </svg>
17
+ );
18
+ }
19
+
@@ -0,0 +1,19 @@
1
+ export function ThumbsUpIcon(props: React.ComponentProps<"svg">) {
2
+ return (
3
+ <svg
4
+ width="16"
5
+ height="16"
6
+ viewBox="0 0 24 24"
7
+ fill="none"
8
+ stroke="currentColor"
9
+ strokeWidth="2"
10
+ strokeLinecap="round"
11
+ strokeLinejoin="round"
12
+ {...props}
13
+ >
14
+ <path d="M7 10v12" />
15
+ <path d="M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z" />
16
+ </svg>
17
+ );
18
+ }
19
+
@@ -0,0 +1,18 @@
1
+ //#region rolldown:runtime
2
+ var __defProp = Object.defineProperty;
3
+ var __export = (all, symbols) => {
4
+ let target = {};
5
+ for (var name in all) {
6
+ __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: true
9
+ });
10
+ }
11
+ if (symbols) {
12
+ __defProp(target, Symbol.toStringTag, { value: "Module" });
13
+ }
14
+ return target;
15
+ };
16
+
17
+ //#endregion
18
+ export { __export as t };
package/dist/index.css ADDED
@@ -0,0 +1,37 @@
1
+ @keyframes popUp {
2
+ from {
3
+ opacity: 0;
4
+ transform: translateY(16px);
5
+ }
6
+ to {
7
+ opacity: 1;
8
+ transform: translateY(0);
9
+ }
10
+ }
11
+
12
+ @keyframes slideIn {
13
+ from {
14
+ opacity: 0;
15
+ transform: translateX(-12px);
16
+ }
17
+ to {
18
+ opacity: 1;
19
+ transform: translateX(0);
20
+ }
21
+ }
22
+
23
+ @keyframes pulse-zoom {
24
+ 0%, 100% {
25
+ transform: scale(1);
26
+ }
27
+ 50% {
28
+ transform: scale(1.15);
29
+ }
30
+ }
31
+
32
+
33
+
34
+ @source "./**/*.{js,jsx,ts,tsx}";
35
+
36
+
37
+ /*# sourceMappingURL=index.css.map*/
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.css","names":[],"sources":["../src/animate.css","../src/index.css"],"sourcesContent":["@keyframes popUp {\n from {\n opacity: 0;\n transform: translateY(16px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n}\n\n@keyframes slideIn {\n from {\n opacity: 0;\n transform: translateX(-12px);\n }\n to {\n opacity: 1;\n transform: translateX(0);\n }\n}\n\n@keyframes pulse-zoom {\n 0%, 100% {\n transform: scale(1);\n }\n 50% {\n transform: scale(1.15);\n }\n}\n\n","@import \"./animate.css\";\n\n@source \"./**/*.{js,jsx,ts,tsx}\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;AC3BA"}
@@ -0,0 +1,143 @@
1
+ import * as react_jsx_runtime0 from "react/jsx-runtime";
2
+
3
+ //#region src/context/xandi-context.d.ts
4
+ type MessageType = "text" | "markdown";
5
+ type FeedbackType = "up" | "down" | null;
6
+ interface Message {
7
+ id: string;
8
+ role: "user" | "assistant";
9
+ content: string;
10
+ type?: MessageType;
11
+ debugTrace?: unknown;
12
+ }
13
+ interface XandiContextValue {
14
+ messages: Message[];
15
+ isLoading: boolean;
16
+ sessionId: string | null;
17
+ sendMessage: (text: string) => void;
18
+ onFeedback?: (messageId: string, feedback: FeedbackType) => void;
19
+ }
20
+ interface XandiProviderProps {
21
+ api: string;
22
+ userId: string;
23
+ orgId: string;
24
+ sessionId?: string;
25
+ onFeedback?: (messageId: string, feedback: FeedbackType) => void;
26
+ children: React.ReactNode;
27
+ }
28
+ declare function XandiProvider({
29
+ api,
30
+ userId,
31
+ orgId,
32
+ sessionId: initialSessionId,
33
+ onFeedback,
34
+ children
35
+ }: XandiProviderProps): react_jsx_runtime0.JSX.Element;
36
+ declare function useXandi(): XandiContextValue;
37
+ //#endregion
38
+ //#region src/components/x-main-intake.d.ts
39
+ interface Suggestion {
40
+ id: string;
41
+ label: string;
42
+ prompt: string;
43
+ }
44
+ //#endregion
45
+ //#region src/components/xandi.d.ts
46
+ interface XandiProps {
47
+ welcomeMessage?: string;
48
+ suggestions?: Suggestion[];
49
+ }
50
+ declare function Xandi({
51
+ welcomeMessage,
52
+ suggestions
53
+ }: XandiProps): react_jsx_runtime0.JSX.Element;
54
+ //#endregion
55
+ //#region src/components/x-header.d.ts
56
+ interface XHeaderProps {
57
+ title?: string;
58
+ onClose?: () => void;
59
+ onNewChat?: () => void;
60
+ onToggleHistory?: () => void;
61
+ }
62
+ declare function XHeader({
63
+ title,
64
+ onClose,
65
+ onNewChat,
66
+ onToggleHistory
67
+ }: XHeaderProps): react_jsx_runtime0.JSX.Element;
68
+ //#endregion
69
+ //#region src/components/x-chat-history.d.ts
70
+ interface ChatHistoryItem {
71
+ id: string;
72
+ title: string;
73
+ timestamp: Date;
74
+ }
75
+ interface ChatHistoryGroup {
76
+ label: string;
77
+ items: ChatHistoryItem[];
78
+ }
79
+ interface XChatHistoryProps {
80
+ groups?: ChatHistoryGroup[];
81
+ activeChatId?: string;
82
+ onSelectChat?: (chatId: string) => void;
83
+ }
84
+ declare function XChatHistory({
85
+ groups,
86
+ activeChatId,
87
+ onSelectChat
88
+ }: XChatHistoryProps): react_jsx_runtime0.JSX.Element;
89
+ //#endregion
90
+ //#region src/components/x-sidebar.d.ts
91
+ interface XSidebarProps {
92
+ isOpen?: boolean;
93
+ chatHistory?: ChatHistoryGroup[];
94
+ activeChatId?: string;
95
+ onClose?: () => void;
96
+ onNewChat?: () => void;
97
+ onSelectChat?: (chatId: string) => void;
98
+ }
99
+ declare function XSidebar({
100
+ isOpen,
101
+ chatHistory,
102
+ activeChatId,
103
+ onClose,
104
+ onNewChat,
105
+ onSelectChat
106
+ }: XSidebarProps): react_jsx_runtime0.JSX.Element | null;
107
+ declare namespace x_message_actions_d_exports {
108
+ export { Copy, CopyProps, Debug, DebugProps, Feedback, FeedbackProps, FeedbackType, Root };
109
+ }
110
+ /**
111
+ * Container for message actions. Use with composable children:
112
+ * - XMessageActions.Feedback
113
+ * - XMessageActions.Copy
114
+ * - XMessageActions.Debug
115
+ */
116
+ declare function Root({
117
+ children
118
+ }: {
119
+ children: React.ReactNode;
120
+ }): react_jsx_runtime0.JSX.Element;
121
+ interface FeedbackProps {
122
+ messageId: string;
123
+ }
124
+ declare function Feedback({
125
+ messageId
126
+ }: FeedbackProps): react_jsx_runtime0.JSX.Element;
127
+ interface CopyProps {
128
+ content: string;
129
+ }
130
+ declare function Copy({
131
+ content
132
+ }: CopyProps): react_jsx_runtime0.JSX.Element;
133
+ interface DebugProps {
134
+ messageId: string;
135
+ debugTrace: unknown;
136
+ }
137
+ declare function Debug({
138
+ messageId,
139
+ debugTrace
140
+ }: DebugProps): react_jsx_runtime0.JSX.Element;
141
+ //#endregion
142
+ export { type ChatHistoryGroup, type ChatHistoryItem, type FeedbackType, type Message, type MessageType, type Suggestion, XChatHistory, type XChatHistoryProps, XHeader, type XHeaderProps, x_message_actions_d_exports as XMessageActions, XSidebar, type XSidebarProps, Xandi, type XandiProps, XandiProvider, type XandiProviderProps, useXandi };
143
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/context/xandi-context.tsx","../src/components/x-main-intake.tsx","../src/components/xandi.tsx","../src/components/x-header.tsx","../src/components/x-chat-history.tsx","../src/components/x-sidebar.tsx","../src/components/x-message-actions.tsx"],"sourcesContent":[],"mappings":";;;KAEY,WAAA;KACA,YAAA;UAEK,OAAA;;EAHL,IAAA,EAAA,MAAA,GAAW,WAAA;EACX,OAAA,EAAA,MAAY;EAEP,IAAA,CAAA,EAIR,WAJe;EAQP,UAAA,CAAA,EAAA,OAAiB;AAUlC;AASgB,UAnBC,iBAAA,CAmBY;EAC3B,QAAA,EAnBU,OAmBV,EAAA;EACA,SAAA,EAAA,OAAA;EACA,SAAA,EAAA,MAAA,GAAA,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