apteva 0.2.8 → 0.2.10

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.
@@ -14,3 +14,186 @@ export function Modal({ children, onClose }: ModalProps) {
14
14
  </div>
15
15
  );
16
16
  }
17
+
18
+ // Confirmation Modal - replaces browser confirm()
19
+ interface ConfirmModalProps {
20
+ title?: string;
21
+ message: string;
22
+ confirmText?: string;
23
+ cancelText?: string;
24
+ confirmVariant?: "danger" | "primary";
25
+ onConfirm: () => void;
26
+ onCancel: () => void;
27
+ }
28
+
29
+ export function ConfirmModal({
30
+ title,
31
+ message,
32
+ confirmText = "Confirm",
33
+ cancelText = "Cancel",
34
+ confirmVariant = "danger",
35
+ onConfirm,
36
+ onCancel,
37
+ }: ConfirmModalProps) {
38
+ return (
39
+ <div className="fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4">
40
+ <div className="bg-[#111] border border-[#333] rounded-lg p-6 w-full max-w-sm">
41
+ {title && <h3 className="font-medium mb-2">{title}</h3>}
42
+ <p className="text-sm text-[#ccc] mb-4">{message}</p>
43
+ <div className="flex gap-2">
44
+ <button
45
+ onClick={onCancel}
46
+ className="flex-1 text-sm bg-[#1a1a1a] hover:bg-[#222] border border-[#333] px-4 py-2 rounded transition"
47
+ >
48
+ {cancelText}
49
+ </button>
50
+ <button
51
+ onClick={onConfirm}
52
+ className={`flex-1 text-sm text-white px-4 py-2 rounded transition ${
53
+ confirmVariant === "danger"
54
+ ? "bg-red-500 hover:bg-red-600"
55
+ : "bg-[#f97316] hover:bg-[#ea580c]"
56
+ }`}
57
+ >
58
+ {confirmText}
59
+ </button>
60
+ </div>
61
+ </div>
62
+ </div>
63
+ );
64
+ }
65
+
66
+ // Alert Modal - replaces browser alert()
67
+ interface AlertModalProps {
68
+ title?: string;
69
+ message: string;
70
+ buttonText?: string;
71
+ variant?: "error" | "success" | "info";
72
+ onClose: () => void;
73
+ }
74
+
75
+ export function AlertModal({
76
+ title,
77
+ message,
78
+ buttonText = "OK",
79
+ variant = "info",
80
+ onClose,
81
+ }: AlertModalProps) {
82
+ const iconColors = {
83
+ error: "bg-red-500/20 text-red-400",
84
+ success: "bg-green-500/20 text-green-400",
85
+ info: "bg-blue-500/20 text-blue-400",
86
+ };
87
+
88
+ const icons = {
89
+ error: "✕",
90
+ success: "✓",
91
+ info: "ℹ",
92
+ };
93
+
94
+ return (
95
+ <div className="fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4">
96
+ <div className="bg-[#111] border border-[#333] rounded-lg p-6 w-full max-w-sm text-center">
97
+ <div
98
+ className={`w-12 h-12 rounded-full flex items-center justify-center mx-auto mb-3 ${iconColors[variant]}`}
99
+ >
100
+ <span className="text-xl">{icons[variant]}</span>
101
+ </div>
102
+ {title && <h3 className="font-medium mb-2">{title}</h3>}
103
+ <p className="text-sm text-[#ccc] mb-4">{message}</p>
104
+ <button
105
+ onClick={onClose}
106
+ className="w-full text-sm bg-[#1a1a1a] hover:bg-[#222] border border-[#333] px-4 py-2 rounded transition"
107
+ >
108
+ {buttonText}
109
+ </button>
110
+ </div>
111
+ </div>
112
+ );
113
+ }
114
+
115
+ // Hook for using confirmation dialogs
116
+ import { useState, useCallback } from "react";
117
+
118
+ interface UseConfirmOptions {
119
+ title?: string;
120
+ confirmText?: string;
121
+ cancelText?: string;
122
+ confirmVariant?: "danger" | "primary";
123
+ }
124
+
125
+ export function useConfirm() {
126
+ const [state, setState] = useState<{
127
+ message: string;
128
+ options: UseConfirmOptions;
129
+ resolve: (value: boolean) => void;
130
+ } | null>(null);
131
+
132
+ const confirm = useCallback((message: string, options: UseConfirmOptions = {}) => {
133
+ return new Promise<boolean>((resolve) => {
134
+ setState({ message, options, resolve });
135
+ });
136
+ }, []);
137
+
138
+ const handleConfirm = useCallback(() => {
139
+ state?.resolve(true);
140
+ setState(null);
141
+ }, [state]);
142
+
143
+ const handleCancel = useCallback(() => {
144
+ state?.resolve(false);
145
+ setState(null);
146
+ }, [state]);
147
+
148
+ const ConfirmDialog = state ? (
149
+ <ConfirmModal
150
+ title={state.options.title}
151
+ message={state.message}
152
+ confirmText={state.options.confirmText}
153
+ cancelText={state.options.cancelText}
154
+ confirmVariant={state.options.confirmVariant}
155
+ onConfirm={handleConfirm}
156
+ onCancel={handleCancel}
157
+ />
158
+ ) : null;
159
+
160
+ return { confirm, ConfirmDialog };
161
+ }
162
+
163
+ // Hook for using alert dialogs
164
+ interface UseAlertOptions {
165
+ title?: string;
166
+ buttonText?: string;
167
+ variant?: "error" | "success" | "info";
168
+ }
169
+
170
+ export function useAlert() {
171
+ const [state, setState] = useState<{
172
+ message: string;
173
+ options: UseAlertOptions;
174
+ resolve: () => void;
175
+ } | null>(null);
176
+
177
+ const alert = useCallback((message: string, options: UseAlertOptions = {}) => {
178
+ return new Promise<void>((resolve) => {
179
+ setState({ message, options, resolve });
180
+ });
181
+ }, []);
182
+
183
+ const handleClose = useCallback(() => {
184
+ state?.resolve();
185
+ setState(null);
186
+ }, [state]);
187
+
188
+ const AlertDialog = state ? (
189
+ <AlertModal
190
+ title={state.options.title}
191
+ message={state.message}
192
+ buttonText={state.options.buttonText}
193
+ variant={state.options.variant}
194
+ onClose={handleClose}
195
+ />
196
+ ) : null;
197
+
198
+ return { alert, AlertDialog };
199
+ }
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { DashboardIcon, AgentsIcon, TasksIcon, McpIcon, TelemetryIcon, SettingsIcon, CloseIcon } from "../common/Icons";
2
+ import { DashboardIcon, AgentsIcon, TasksIcon, McpIcon, TelemetryIcon, ApiIcon, SettingsIcon, CloseIcon } from "../common/Icons";
3
3
  import type { Route } from "../../types";
4
4
 
5
5
  interface SidebarProps {
@@ -82,6 +82,12 @@ export function Sidebar({ route, agentCount, taskCount, onNavigate, isOpen, onCl
82
82
  active={route === "telemetry"}
83
83
  onClick={() => handleNavigate("telemetry")}
84
84
  />
85
+ <NavButton
86
+ icon={<ApiIcon />}
87
+ label="API"
88
+ active={route === "api"}
89
+ onClick={() => handleNavigate("api")}
90
+ />
85
91
  <NavButton
86
92
  icon={<SettingsIcon />}
87
93
  label="Settings"