@getcatalystiq/agent-plane-ui 0.1.11 → 0.1.13

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.
@@ -0,0 +1,201 @@
1
+ import * as React3 from 'react';
2
+ import { createContext, useRef, useMemo, useContext } from 'react';
3
+ import { jsx } from 'react/jsx-runtime';
4
+ import useSWR from 'swr';
5
+ import { clsx } from 'clsx';
6
+ import { twMerge } from 'tailwind-merge';
7
+ import { cva } from 'class-variance-authority';
8
+
9
+ // src/provider.tsx
10
+ var ClientContext = createContext(null);
11
+ var NavigationContext = createContext(
12
+ null
13
+ );
14
+ function DefaultLink({ href, children, className }) {
15
+ return /* @__PURE__ */ jsx("a", { href, className, children });
16
+ }
17
+ function AgentPlaneProvider({
18
+ client,
19
+ onNavigate,
20
+ LinkComponent = DefaultLink,
21
+ onAuthError,
22
+ basePath = "",
23
+ children
24
+ }) {
25
+ const clientRef = useRef(client);
26
+ clientRef.current = client;
27
+ const onAuthErrorRef = useRef(onAuthError);
28
+ onAuthErrorRef.current = onAuthError;
29
+ const clientValue = useMemo(
30
+ () => ({
31
+ // Expose a stable object whose `.client` always points to the latest ref.
32
+ get client() {
33
+ return clientRef.current;
34
+ },
35
+ get onAuthError() {
36
+ return onAuthErrorRef.current;
37
+ }
38
+ }),
39
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- intentionally stable
40
+ []
41
+ );
42
+ const navigationValue = useMemo(
43
+ () => ({
44
+ onNavigate,
45
+ LinkComponent,
46
+ basePath
47
+ }),
48
+ [onNavigate, LinkComponent, basePath]
49
+ );
50
+ return /* @__PURE__ */ jsx(ClientContext.Provider, { value: clientValue, children: /* @__PURE__ */ jsx(NavigationContext.Provider, { value: navigationValue, children }) });
51
+ }
52
+ function useAgentPlaneClient() {
53
+ const ctx = useContext(ClientContext);
54
+ if (!ctx) {
55
+ throw new Error(
56
+ "useAgentPlaneClient must be used within an <AgentPlaneProvider>"
57
+ );
58
+ }
59
+ return ctx.client;
60
+ }
61
+ function useAuthError() {
62
+ const ctx = useContext(ClientContext);
63
+ if (!ctx) {
64
+ throw new Error(
65
+ "useAuthError must be used within an <AgentPlaneProvider>"
66
+ );
67
+ }
68
+ return ctx.onAuthError;
69
+ }
70
+ function useNavigation() {
71
+ const ctx = useContext(NavigationContext);
72
+ if (!ctx) {
73
+ throw new Error(
74
+ "useNavigation must be used within an <AgentPlaneProvider>"
75
+ );
76
+ }
77
+ return ctx;
78
+ }
79
+ function useApi(key, fetcher, options) {
80
+ const client = useAgentPlaneClient();
81
+ const onAuthError = useAuthError();
82
+ return useSWR(
83
+ key,
84
+ () => fetcher(client),
85
+ {
86
+ revalidateOnFocus: false,
87
+ errorRetryCount: 3,
88
+ onError: (err) => {
89
+ if (onAuthError && err && typeof err === "object" && "status" in err && err.status === 401) {
90
+ onAuthError(err instanceof Error ? err : new Error(String(err)));
91
+ }
92
+ },
93
+ ...options
94
+ }
95
+ );
96
+ }
97
+ function cn(...inputs) {
98
+ return twMerge(clsx(inputs));
99
+ }
100
+ function supportsClaudeRunner(model) {
101
+ return !model.includes("/") || model.startsWith("anthropic/");
102
+ }
103
+ var buttonVariants = cva(
104
+ "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
105
+ {
106
+ variants: {
107
+ variant: {
108
+ default: "bg-primary text-primary-foreground shadow hover:bg-primary/90",
109
+ destructive: "bg-destructive text-white shadow-sm hover:bg-destructive/90",
110
+ outline: "border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",
111
+ secondary: "bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
112
+ ghost: "hover:bg-accent hover:text-accent-foreground",
113
+ link: "text-primary underline-offset-4 hover:underline"
114
+ },
115
+ size: {
116
+ default: "h-9 px-4 py-2",
117
+ sm: "h-8 rounded-md px-3 text-xs",
118
+ lg: "h-10 rounded-md px-8",
119
+ icon: "h-9 w-9"
120
+ }
121
+ },
122
+ defaultVariants: {
123
+ variant: "default",
124
+ size: "default"
125
+ }
126
+ }
127
+ );
128
+ var Button = React3.forwardRef(
129
+ ({ className, variant, size, ...props }, ref) => {
130
+ return /* @__PURE__ */ jsx(
131
+ "button",
132
+ {
133
+ className: cn(buttonVariants({ variant, size, className })),
134
+ ref,
135
+ ...props
136
+ }
137
+ );
138
+ }
139
+ );
140
+ Button.displayName = "Button";
141
+ var Card = React3.forwardRef(
142
+ ({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("rounded-xl border bg-card text-card-foreground shadow", className), ...props })
143
+ );
144
+ Card.displayName = "Card";
145
+ var CardHeader = React3.forwardRef(
146
+ ({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("flex flex-col space-y-1.5 p-6", className), ...props })
147
+ );
148
+ CardHeader.displayName = "CardHeader";
149
+ var CardTitle = React3.forwardRef(
150
+ ({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("font-semibold leading-none tracking-tight", className), ...props })
151
+ );
152
+ CardTitle.displayName = "CardTitle";
153
+ var CardDescription = React3.forwardRef(
154
+ ({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("text-sm text-muted-foreground", className), ...props })
155
+ );
156
+ CardDescription.displayName = "CardDescription";
157
+ var CardContent = React3.forwardRef(
158
+ ({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("p-6 pt-0", className), ...props })
159
+ );
160
+ CardContent.displayName = "CardContent";
161
+ var badgeVariants = cva(
162
+ "inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
163
+ {
164
+ variants: {
165
+ variant: {
166
+ default: "border-transparent bg-primary text-primary-foreground shadow",
167
+ secondary: "border-transparent bg-secondary text-secondary-foreground",
168
+ destructive: "border-transparent bg-destructive text-white shadow",
169
+ outline: "text-foreground"
170
+ }
171
+ },
172
+ defaultVariants: {
173
+ variant: "default"
174
+ }
175
+ }
176
+ );
177
+ function Badge({ className, variant, ...props }) {
178
+ return /* @__PURE__ */ jsx("div", { className: cn(badgeVariants({ variant }), className), ...props });
179
+ }
180
+ var Input = React3.forwardRef(
181
+ ({ className, type, ...props }, ref) => {
182
+ return /* @__PURE__ */ jsx(
183
+ "input",
184
+ {
185
+ type,
186
+ className: cn(
187
+ "flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",
188
+ className
189
+ ),
190
+ ref,
191
+ ...props
192
+ }
193
+ );
194
+ }
195
+ );
196
+ Input.displayName = "Input";
197
+ function Skeleton({ className, ...props }) {
198
+ return /* @__PURE__ */ jsx("div", { className: cn("animate-pulse rounded-md bg-muted/50", className), ...props });
199
+ }
200
+
201
+ export { AgentPlaneProvider, Badge, Button, Card, CardContent, CardDescription, CardHeader, CardTitle, Input, Skeleton, badgeVariants, buttonVariants, cn, supportsClaudeRunner, useAgentPlaneClient, useApi, useAuthError, useNavigation };
@@ -0,0 +1,242 @@
1
+ 'use strict';
2
+
3
+ var React3 = require('react');
4
+ var jsxRuntime = require('react/jsx-runtime');
5
+ var useSWR = require('swr');
6
+ var clsx = require('clsx');
7
+ var tailwindMerge = require('tailwind-merge');
8
+ var classVarianceAuthority = require('class-variance-authority');
9
+
10
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
11
+
12
+ function _interopNamespace(e) {
13
+ if (e && e.__esModule) return e;
14
+ var n = Object.create(null);
15
+ if (e) {
16
+ Object.keys(e).forEach(function (k) {
17
+ if (k !== 'default') {
18
+ var d = Object.getOwnPropertyDescriptor(e, k);
19
+ Object.defineProperty(n, k, d.get ? d : {
20
+ enumerable: true,
21
+ get: function () { return e[k]; }
22
+ });
23
+ }
24
+ });
25
+ }
26
+ n.default = e;
27
+ return Object.freeze(n);
28
+ }
29
+
30
+ var React3__namespace = /*#__PURE__*/_interopNamespace(React3);
31
+ var useSWR__default = /*#__PURE__*/_interopDefault(useSWR);
32
+
33
+ // src/provider.tsx
34
+ var ClientContext = React3.createContext(null);
35
+ var NavigationContext = React3.createContext(
36
+ null
37
+ );
38
+ function DefaultLink({ href, children, className }) {
39
+ return /* @__PURE__ */ jsxRuntime.jsx("a", { href, className, children });
40
+ }
41
+ function AgentPlaneProvider({
42
+ client,
43
+ onNavigate,
44
+ LinkComponent = DefaultLink,
45
+ onAuthError,
46
+ basePath = "",
47
+ children
48
+ }) {
49
+ const clientRef = React3.useRef(client);
50
+ clientRef.current = client;
51
+ const onAuthErrorRef = React3.useRef(onAuthError);
52
+ onAuthErrorRef.current = onAuthError;
53
+ const clientValue = React3.useMemo(
54
+ () => ({
55
+ // Expose a stable object whose `.client` always points to the latest ref.
56
+ get client() {
57
+ return clientRef.current;
58
+ },
59
+ get onAuthError() {
60
+ return onAuthErrorRef.current;
61
+ }
62
+ }),
63
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- intentionally stable
64
+ []
65
+ );
66
+ const navigationValue = React3.useMemo(
67
+ () => ({
68
+ onNavigate,
69
+ LinkComponent,
70
+ basePath
71
+ }),
72
+ [onNavigate, LinkComponent, basePath]
73
+ );
74
+ return /* @__PURE__ */ jsxRuntime.jsx(ClientContext.Provider, { value: clientValue, children: /* @__PURE__ */ jsxRuntime.jsx(NavigationContext.Provider, { value: navigationValue, children }) });
75
+ }
76
+ function useAgentPlaneClient() {
77
+ const ctx = React3.useContext(ClientContext);
78
+ if (!ctx) {
79
+ throw new Error(
80
+ "useAgentPlaneClient must be used within an <AgentPlaneProvider>"
81
+ );
82
+ }
83
+ return ctx.client;
84
+ }
85
+ function useAuthError() {
86
+ const ctx = React3.useContext(ClientContext);
87
+ if (!ctx) {
88
+ throw new Error(
89
+ "useAuthError must be used within an <AgentPlaneProvider>"
90
+ );
91
+ }
92
+ return ctx.onAuthError;
93
+ }
94
+ function useNavigation() {
95
+ const ctx = React3.useContext(NavigationContext);
96
+ if (!ctx) {
97
+ throw new Error(
98
+ "useNavigation must be used within an <AgentPlaneProvider>"
99
+ );
100
+ }
101
+ return ctx;
102
+ }
103
+ function useApi(key, fetcher, options) {
104
+ const client = useAgentPlaneClient();
105
+ const onAuthError = useAuthError();
106
+ return useSWR__default.default(
107
+ key,
108
+ () => fetcher(client),
109
+ {
110
+ revalidateOnFocus: false,
111
+ errorRetryCount: 3,
112
+ onError: (err) => {
113
+ if (onAuthError && err && typeof err === "object" && "status" in err && err.status === 401) {
114
+ onAuthError(err instanceof Error ? err : new Error(String(err)));
115
+ }
116
+ },
117
+ ...options
118
+ }
119
+ );
120
+ }
121
+ function cn(...inputs) {
122
+ return tailwindMerge.twMerge(clsx.clsx(inputs));
123
+ }
124
+ function supportsClaudeRunner(model) {
125
+ return !model.includes("/") || model.startsWith("anthropic/");
126
+ }
127
+ var buttonVariants = classVarianceAuthority.cva(
128
+ "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
129
+ {
130
+ variants: {
131
+ variant: {
132
+ default: "bg-primary text-primary-foreground shadow hover:bg-primary/90",
133
+ destructive: "bg-destructive text-white shadow-sm hover:bg-destructive/90",
134
+ outline: "border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",
135
+ secondary: "bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
136
+ ghost: "hover:bg-accent hover:text-accent-foreground",
137
+ link: "text-primary underline-offset-4 hover:underline"
138
+ },
139
+ size: {
140
+ default: "h-9 px-4 py-2",
141
+ sm: "h-8 rounded-md px-3 text-xs",
142
+ lg: "h-10 rounded-md px-8",
143
+ icon: "h-9 w-9"
144
+ }
145
+ },
146
+ defaultVariants: {
147
+ variant: "default",
148
+ size: "default"
149
+ }
150
+ }
151
+ );
152
+ var Button = React3__namespace.forwardRef(
153
+ ({ className, variant, size, ...props }, ref) => {
154
+ return /* @__PURE__ */ jsxRuntime.jsx(
155
+ "button",
156
+ {
157
+ className: cn(buttonVariants({ variant, size, className })),
158
+ ref,
159
+ ...props
160
+ }
161
+ );
162
+ }
163
+ );
164
+ Button.displayName = "Button";
165
+ var Card = React3__namespace.forwardRef(
166
+ ({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("rounded-xl border bg-card text-card-foreground shadow", className), ...props })
167
+ );
168
+ Card.displayName = "Card";
169
+ var CardHeader = React3__namespace.forwardRef(
170
+ ({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("flex flex-col space-y-1.5 p-6", className), ...props })
171
+ );
172
+ CardHeader.displayName = "CardHeader";
173
+ var CardTitle = React3__namespace.forwardRef(
174
+ ({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("font-semibold leading-none tracking-tight", className), ...props })
175
+ );
176
+ CardTitle.displayName = "CardTitle";
177
+ var CardDescription = React3__namespace.forwardRef(
178
+ ({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("text-sm text-muted-foreground", className), ...props })
179
+ );
180
+ CardDescription.displayName = "CardDescription";
181
+ var CardContent = React3__namespace.forwardRef(
182
+ ({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("p-6 pt-0", className), ...props })
183
+ );
184
+ CardContent.displayName = "CardContent";
185
+ var badgeVariants = classVarianceAuthority.cva(
186
+ "inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
187
+ {
188
+ variants: {
189
+ variant: {
190
+ default: "border-transparent bg-primary text-primary-foreground shadow",
191
+ secondary: "border-transparent bg-secondary text-secondary-foreground",
192
+ destructive: "border-transparent bg-destructive text-white shadow",
193
+ outline: "text-foreground"
194
+ }
195
+ },
196
+ defaultVariants: {
197
+ variant: "default"
198
+ }
199
+ }
200
+ );
201
+ function Badge({ className, variant, ...props }) {
202
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn(badgeVariants({ variant }), className), ...props });
203
+ }
204
+ var Input = React3__namespace.forwardRef(
205
+ ({ className, type, ...props }, ref) => {
206
+ return /* @__PURE__ */ jsxRuntime.jsx(
207
+ "input",
208
+ {
209
+ type,
210
+ className: cn(
211
+ "flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",
212
+ className
213
+ ),
214
+ ref,
215
+ ...props
216
+ }
217
+ );
218
+ }
219
+ );
220
+ Input.displayName = "Input";
221
+ function Skeleton({ className, ...props }) {
222
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("animate-pulse rounded-md bg-muted/50", className), ...props });
223
+ }
224
+
225
+ exports.AgentPlaneProvider = AgentPlaneProvider;
226
+ exports.Badge = Badge;
227
+ exports.Button = Button;
228
+ exports.Card = Card;
229
+ exports.CardContent = CardContent;
230
+ exports.CardDescription = CardDescription;
231
+ exports.CardHeader = CardHeader;
232
+ exports.CardTitle = CardTitle;
233
+ exports.Input = Input;
234
+ exports.Skeleton = Skeleton;
235
+ exports.badgeVariants = badgeVariants;
236
+ exports.buttonVariants = buttonVariants;
237
+ exports.cn = cn;
238
+ exports.supportsClaudeRunner = supportsClaudeRunner;
239
+ exports.useAgentPlaneClient = useAgentPlaneClient;
240
+ exports.useApi = useApi;
241
+ exports.useAuthError = useAuthError;
242
+ exports.useNavigation = useNavigation;