@useatlas/react 0.0.1
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/README.md +95 -0
- package/dist/chunk-2WFDP7G5.js +231 -0
- package/dist/chunk-2WFDP7G5.js.map +1 -0
- package/dist/chunk-44HBZYKP.js +224 -0
- package/dist/chunk-44HBZYKP.js.map +1 -0
- package/dist/chunk-5SEVKHS5.cjs +229 -0
- package/dist/chunk-5SEVKHS5.cjs.map +1 -0
- package/dist/chunk-UIRB6L36.cjs +249 -0
- package/dist/chunk-UIRB6L36.cjs.map +1 -0
- package/dist/hooks.cjs +251 -0
- package/dist/hooks.cjs.map +1 -0
- package/dist/hooks.d.cts +132 -0
- package/dist/hooks.d.ts +132 -0
- package/dist/hooks.js +237 -0
- package/dist/hooks.js.map +1 -0
- package/dist/index.cjs +2976 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +69 -0
- package/dist/index.d.ts +69 -0
- package/dist/index.js +2926 -0
- package/dist/index.js.map +1 -0
- package/dist/result-chart-NFAJ4IQ5.js +398 -0
- package/dist/result-chart-NFAJ4IQ5.js.map +1 -0
- package/dist/result-chart-YLCKBNV4.cjs +400 -0
- package/dist/result-chart-YLCKBNV4.cjs.map +1 -0
- package/dist/styles.css +59 -0
- package/dist/use-dark-mode-rFxawUv1.d.cts +123 -0
- package/dist/use-dark-mode-rFxawUv1.d.ts +123 -0
- package/dist/widget.css +2 -0
- package/dist/widget.js +445 -0
- package/package.json +113 -0
- package/src/components/__tests__/tool-renderers.test.tsx +239 -0
- package/src/components/actions/action-approval-card.tsx +296 -0
- package/src/components/actions/action-status-badge.tsx +50 -0
- package/src/components/admin/change-password-dialog.tsx +128 -0
- package/src/components/atlas-chat.tsx +656 -0
- package/src/components/chart/chart-detection.ts +318 -0
- package/src/components/chart/result-chart.tsx +590 -0
- package/src/components/chat/api-key-bar.tsx +66 -0
- package/src/components/chat/copy-button.tsx +25 -0
- package/src/components/chat/data-table.tsx +104 -0
- package/src/components/chat/error-banner.tsx +32 -0
- package/src/components/chat/explore-card.tsx +41 -0
- package/src/components/chat/follow-up-chips.tsx +29 -0
- package/src/components/chat/loading-card.tsx +10 -0
- package/src/components/chat/managed-auth-card.tsx +116 -0
- package/src/components/chat/markdown.tsx +146 -0
- package/src/components/chat/python-result-card.tsx +245 -0
- package/src/components/chat/sql-block.tsx +54 -0
- package/src/components/chat/sql-result-card.tsx +163 -0
- package/src/components/chat/starter-prompts.ts +6 -0
- package/src/components/chat/tool-part.tsx +106 -0
- package/src/components/chat/typing-indicator.tsx +22 -0
- package/src/components/conversations/conversation-item.tsx +135 -0
- package/src/components/conversations/conversation-list.tsx +69 -0
- package/src/components/conversations/conversation-sidebar.tsx +113 -0
- package/src/components/conversations/delete-confirmation.tsx +27 -0
- package/src/components/schema-explorer/schema-explorer.tsx +517 -0
- package/src/components/ui/alert-dialog.tsx +196 -0
- package/src/components/ui/badge.tsx +48 -0
- package/src/components/ui/button.tsx +64 -0
- package/src/components/ui/card.tsx +92 -0
- package/src/components/ui/dialog.tsx +158 -0
- package/src/components/ui/dropdown-menu.tsx +257 -0
- package/src/components/ui/input.tsx +21 -0
- package/src/components/ui/label.tsx +24 -0
- package/src/components/ui/scroll-area.tsx +62 -0
- package/src/components/ui/separator.tsx +28 -0
- package/src/components/ui/sheet.tsx +143 -0
- package/src/components/ui/table.tsx +116 -0
- package/src/components/ui/toggle-group.tsx +83 -0
- package/src/components/ui/toggle.tsx +47 -0
- package/src/context.tsx +85 -0
- package/src/env.d.ts +9 -0
- package/src/hooks/__tests__/provider.test.tsx +83 -0
- package/src/hooks/__tests__/use-atlas-auth.test.tsx +283 -0
- package/src/hooks/__tests__/use-atlas-chat.test.tsx +157 -0
- package/src/hooks/__tests__/use-atlas-conversations.test.tsx +159 -0
- package/src/hooks/__tests__/use-atlas-theme.test.tsx +56 -0
- package/src/hooks/index.ts +47 -0
- package/src/hooks/provider.tsx +77 -0
- package/src/hooks/theme-init-script.ts +17 -0
- package/src/hooks/use-atlas-auth.ts +131 -0
- package/src/hooks/use-atlas-chat.ts +102 -0
- package/src/hooks/use-atlas-conversations.ts +61 -0
- package/src/hooks/use-atlas-theme.ts +34 -0
- package/src/hooks/use-conversations.ts +189 -0
- package/src/hooks/use-dark-mode.ts +150 -0
- package/src/index.ts +36 -0
- package/src/lib/action-types.ts +11 -0
- package/src/lib/helpers.ts +198 -0
- package/src/lib/tool-renderer-types.ts +76 -0
- package/src/lib/types.ts +29 -0
- package/src/lib/utils.ts +6 -0
- package/src/styles.css +59 -0
- package/src/test-setup.ts +55 -0
- package/src/widget-entry.ts +20 -0
- package/src/widget.css +12 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import type { ActionStatus } from "../../lib/action-types";
|
|
4
|
+
|
|
5
|
+
const STATUS_CONFIG: Record<ActionStatus, { label: string; classes: string }> = {
|
|
6
|
+
pending_approval: {
|
|
7
|
+
label: "Pending Approval",
|
|
8
|
+
classes: "bg-yellow-100 text-yellow-700 dark:bg-yellow-600/20 dark:text-yellow-400",
|
|
9
|
+
},
|
|
10
|
+
approved: {
|
|
11
|
+
label: "Approved",
|
|
12
|
+
classes: "bg-green-100 text-green-700 dark:bg-green-600/20 dark:text-green-400",
|
|
13
|
+
},
|
|
14
|
+
executed: {
|
|
15
|
+
label: "Executed",
|
|
16
|
+
classes: "bg-green-100 text-green-700 dark:bg-green-600/20 dark:text-green-400",
|
|
17
|
+
},
|
|
18
|
+
auto_approved: {
|
|
19
|
+
label: "Auto-approved",
|
|
20
|
+
classes: "bg-green-100 text-green-700 dark:bg-green-600/20 dark:text-green-400",
|
|
21
|
+
},
|
|
22
|
+
denied: {
|
|
23
|
+
label: "Denied",
|
|
24
|
+
classes: "bg-red-100 text-red-700 dark:bg-red-600/20 dark:text-red-400",
|
|
25
|
+
},
|
|
26
|
+
failed: {
|
|
27
|
+
label: "Failed",
|
|
28
|
+
classes: "bg-red-100 text-red-700 dark:bg-red-600/20 dark:text-red-400",
|
|
29
|
+
},
|
|
30
|
+
rolled_back: {
|
|
31
|
+
label: "Rolled Back",
|
|
32
|
+
classes: "bg-zinc-100 text-zinc-700 dark:bg-zinc-600/20 dark:text-zinc-400",
|
|
33
|
+
},
|
|
34
|
+
timed_out: {
|
|
35
|
+
label: "Timed Out",
|
|
36
|
+
classes: "bg-zinc-100 text-zinc-700 dark:bg-zinc-600/20 dark:text-zinc-400",
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export function ActionStatusBadge({ status }: { status: ActionStatus }) {
|
|
41
|
+
const config = STATUS_CONFIG[status] ?? {
|
|
42
|
+
label: status.replace(/_/g, " "),
|
|
43
|
+
classes: "bg-zinc-100 text-zinc-700 dark:bg-zinc-600/20 dark:text-zinc-400",
|
|
44
|
+
};
|
|
45
|
+
return (
|
|
46
|
+
<span className={`rounded px-1.5 py-0.5 text-xs font-medium ${config.classes}`}>
|
|
47
|
+
{config.label}
|
|
48
|
+
</span>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import {
|
|
5
|
+
AlertDialog,
|
|
6
|
+
AlertDialogContent,
|
|
7
|
+
AlertDialogDescription,
|
|
8
|
+
AlertDialogFooter,
|
|
9
|
+
AlertDialogHeader,
|
|
10
|
+
AlertDialogTitle,
|
|
11
|
+
} from "../ui/alert-dialog";
|
|
12
|
+
import { Button } from "../ui/button";
|
|
13
|
+
import { Input } from "../ui/input";
|
|
14
|
+
import { useAtlasConfig } from "../../context";
|
|
15
|
+
|
|
16
|
+
export function ChangePasswordDialog({
|
|
17
|
+
open,
|
|
18
|
+
onComplete,
|
|
19
|
+
}: {
|
|
20
|
+
open: boolean;
|
|
21
|
+
onComplete: () => void;
|
|
22
|
+
}) {
|
|
23
|
+
const { apiUrl, isCrossOrigin } = useAtlasConfig();
|
|
24
|
+
const credentials: RequestCredentials = isCrossOrigin ? "include" : "same-origin";
|
|
25
|
+
|
|
26
|
+
const [currentPassword, setCurrentPassword] = useState("atlas-dev");
|
|
27
|
+
const [newPassword, setNewPassword] = useState("");
|
|
28
|
+
const [confirmPassword, setConfirmPassword] = useState("");
|
|
29
|
+
const [error, setError] = useState("");
|
|
30
|
+
const [loading, setLoading] = useState(false);
|
|
31
|
+
|
|
32
|
+
async function handleSubmit(e: React.FormEvent) {
|
|
33
|
+
e.preventDefault();
|
|
34
|
+
setError("");
|
|
35
|
+
|
|
36
|
+
if (newPassword.length < 8) {
|
|
37
|
+
setError("Password must be at least 8 characters.");
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (newPassword !== confirmPassword) {
|
|
41
|
+
setError("Passwords do not match.");
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (newPassword === currentPassword) {
|
|
45
|
+
setError("New password must be different from current password.");
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
setLoading(true);
|
|
50
|
+
try {
|
|
51
|
+
const res = await fetch(`${apiUrl}/api/v1/admin/me/password`, {
|
|
52
|
+
method: "POST",
|
|
53
|
+
credentials,
|
|
54
|
+
headers: { "Content-Type": "application/json" },
|
|
55
|
+
body: JSON.stringify({ currentPassword, newPassword }),
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
if (!res.ok) {
|
|
59
|
+
const data = await res.json().catch(() => ({}));
|
|
60
|
+
setError(data.message ?? `Failed (HTTP ${res.status})`);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
onComplete();
|
|
65
|
+
} catch (err) {
|
|
66
|
+
setError(err instanceof Error ? err.message : "Failed to change password");
|
|
67
|
+
} finally {
|
|
68
|
+
setLoading(false);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<AlertDialog open={open}>
|
|
74
|
+
<AlertDialogContent className="sm:max-w-md" onEscapeKeyDown={(e) => e.preventDefault()}>
|
|
75
|
+
<form onSubmit={handleSubmit}>
|
|
76
|
+
<AlertDialogHeader>
|
|
77
|
+
<AlertDialogTitle>Change your password</AlertDialogTitle>
|
|
78
|
+
<AlertDialogDescription>
|
|
79
|
+
You're using the default dev password. Please set a new password to continue.
|
|
80
|
+
</AlertDialogDescription>
|
|
81
|
+
</AlertDialogHeader>
|
|
82
|
+
|
|
83
|
+
<div className="space-y-3 py-4">
|
|
84
|
+
<div className="space-y-1">
|
|
85
|
+
<label className="text-xs font-medium text-muted-foreground">Current password</label>
|
|
86
|
+
<Input
|
|
87
|
+
type="password"
|
|
88
|
+
value={currentPassword}
|
|
89
|
+
onChange={(e) => setCurrentPassword(e.target.value)}
|
|
90
|
+
required
|
|
91
|
+
/>
|
|
92
|
+
</div>
|
|
93
|
+
<div className="space-y-1">
|
|
94
|
+
<label className="text-xs font-medium text-muted-foreground">New password</label>
|
|
95
|
+
<Input
|
|
96
|
+
type="password"
|
|
97
|
+
value={newPassword}
|
|
98
|
+
onChange={(e) => setNewPassword(e.target.value)}
|
|
99
|
+
required
|
|
100
|
+
minLength={8}
|
|
101
|
+
placeholder="At least 8 characters"
|
|
102
|
+
/>
|
|
103
|
+
</div>
|
|
104
|
+
<div className="space-y-1">
|
|
105
|
+
<label className="text-xs font-medium text-muted-foreground">Confirm new password</label>
|
|
106
|
+
<Input
|
|
107
|
+
type="password"
|
|
108
|
+
value={confirmPassword}
|
|
109
|
+
onChange={(e) => setConfirmPassword(e.target.value)}
|
|
110
|
+
required
|
|
111
|
+
minLength={8}
|
|
112
|
+
/>
|
|
113
|
+
</div>
|
|
114
|
+
{error && (
|
|
115
|
+
<p className="text-xs text-red-600 dark:text-red-400">{error}</p>
|
|
116
|
+
)}
|
|
117
|
+
</div>
|
|
118
|
+
|
|
119
|
+
<AlertDialogFooter>
|
|
120
|
+
<Button type="submit" disabled={loading}>
|
|
121
|
+
{loading ? "Changing..." : "Change password"}
|
|
122
|
+
</Button>
|
|
123
|
+
</AlertDialogFooter>
|
|
124
|
+
</form>
|
|
125
|
+
</AlertDialogContent>
|
|
126
|
+
</AlertDialog>
|
|
127
|
+
);
|
|
128
|
+
}
|