@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.
Files changed (98) hide show
  1. package/README.md +95 -0
  2. package/dist/chunk-2WFDP7G5.js +231 -0
  3. package/dist/chunk-2WFDP7G5.js.map +1 -0
  4. package/dist/chunk-44HBZYKP.js +224 -0
  5. package/dist/chunk-44HBZYKP.js.map +1 -0
  6. package/dist/chunk-5SEVKHS5.cjs +229 -0
  7. package/dist/chunk-5SEVKHS5.cjs.map +1 -0
  8. package/dist/chunk-UIRB6L36.cjs +249 -0
  9. package/dist/chunk-UIRB6L36.cjs.map +1 -0
  10. package/dist/hooks.cjs +251 -0
  11. package/dist/hooks.cjs.map +1 -0
  12. package/dist/hooks.d.cts +132 -0
  13. package/dist/hooks.d.ts +132 -0
  14. package/dist/hooks.js +237 -0
  15. package/dist/hooks.js.map +1 -0
  16. package/dist/index.cjs +2976 -0
  17. package/dist/index.cjs.map +1 -0
  18. package/dist/index.d.cts +69 -0
  19. package/dist/index.d.ts +69 -0
  20. package/dist/index.js +2926 -0
  21. package/dist/index.js.map +1 -0
  22. package/dist/result-chart-NFAJ4IQ5.js +398 -0
  23. package/dist/result-chart-NFAJ4IQ5.js.map +1 -0
  24. package/dist/result-chart-YLCKBNV4.cjs +400 -0
  25. package/dist/result-chart-YLCKBNV4.cjs.map +1 -0
  26. package/dist/styles.css +59 -0
  27. package/dist/use-dark-mode-rFxawUv1.d.cts +123 -0
  28. package/dist/use-dark-mode-rFxawUv1.d.ts +123 -0
  29. package/dist/widget.css +2 -0
  30. package/dist/widget.js +445 -0
  31. package/package.json +113 -0
  32. package/src/components/__tests__/tool-renderers.test.tsx +239 -0
  33. package/src/components/actions/action-approval-card.tsx +296 -0
  34. package/src/components/actions/action-status-badge.tsx +50 -0
  35. package/src/components/admin/change-password-dialog.tsx +128 -0
  36. package/src/components/atlas-chat.tsx +656 -0
  37. package/src/components/chart/chart-detection.ts +318 -0
  38. package/src/components/chart/result-chart.tsx +590 -0
  39. package/src/components/chat/api-key-bar.tsx +66 -0
  40. package/src/components/chat/copy-button.tsx +25 -0
  41. package/src/components/chat/data-table.tsx +104 -0
  42. package/src/components/chat/error-banner.tsx +32 -0
  43. package/src/components/chat/explore-card.tsx +41 -0
  44. package/src/components/chat/follow-up-chips.tsx +29 -0
  45. package/src/components/chat/loading-card.tsx +10 -0
  46. package/src/components/chat/managed-auth-card.tsx +116 -0
  47. package/src/components/chat/markdown.tsx +146 -0
  48. package/src/components/chat/python-result-card.tsx +245 -0
  49. package/src/components/chat/sql-block.tsx +54 -0
  50. package/src/components/chat/sql-result-card.tsx +163 -0
  51. package/src/components/chat/starter-prompts.ts +6 -0
  52. package/src/components/chat/tool-part.tsx +106 -0
  53. package/src/components/chat/typing-indicator.tsx +22 -0
  54. package/src/components/conversations/conversation-item.tsx +135 -0
  55. package/src/components/conversations/conversation-list.tsx +69 -0
  56. package/src/components/conversations/conversation-sidebar.tsx +113 -0
  57. package/src/components/conversations/delete-confirmation.tsx +27 -0
  58. package/src/components/schema-explorer/schema-explorer.tsx +517 -0
  59. package/src/components/ui/alert-dialog.tsx +196 -0
  60. package/src/components/ui/badge.tsx +48 -0
  61. package/src/components/ui/button.tsx +64 -0
  62. package/src/components/ui/card.tsx +92 -0
  63. package/src/components/ui/dialog.tsx +158 -0
  64. package/src/components/ui/dropdown-menu.tsx +257 -0
  65. package/src/components/ui/input.tsx +21 -0
  66. package/src/components/ui/label.tsx +24 -0
  67. package/src/components/ui/scroll-area.tsx +62 -0
  68. package/src/components/ui/separator.tsx +28 -0
  69. package/src/components/ui/sheet.tsx +143 -0
  70. package/src/components/ui/table.tsx +116 -0
  71. package/src/components/ui/toggle-group.tsx +83 -0
  72. package/src/components/ui/toggle.tsx +47 -0
  73. package/src/context.tsx +85 -0
  74. package/src/env.d.ts +9 -0
  75. package/src/hooks/__tests__/provider.test.tsx +83 -0
  76. package/src/hooks/__tests__/use-atlas-auth.test.tsx +283 -0
  77. package/src/hooks/__tests__/use-atlas-chat.test.tsx +157 -0
  78. package/src/hooks/__tests__/use-atlas-conversations.test.tsx +159 -0
  79. package/src/hooks/__tests__/use-atlas-theme.test.tsx +56 -0
  80. package/src/hooks/index.ts +47 -0
  81. package/src/hooks/provider.tsx +77 -0
  82. package/src/hooks/theme-init-script.ts +17 -0
  83. package/src/hooks/use-atlas-auth.ts +131 -0
  84. package/src/hooks/use-atlas-chat.ts +102 -0
  85. package/src/hooks/use-atlas-conversations.ts +61 -0
  86. package/src/hooks/use-atlas-theme.ts +34 -0
  87. package/src/hooks/use-conversations.ts +189 -0
  88. package/src/hooks/use-dark-mode.ts +150 -0
  89. package/src/index.ts +36 -0
  90. package/src/lib/action-types.ts +11 -0
  91. package/src/lib/helpers.ts +198 -0
  92. package/src/lib/tool-renderer-types.ts +76 -0
  93. package/src/lib/types.ts +29 -0
  94. package/src/lib/utils.ts +6 -0
  95. package/src/styles.css +59 -0
  96. package/src/test-setup.ts +55 -0
  97. package/src/widget-entry.ts +20 -0
  98. 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&apos;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
+ }