@checkstack/ui 1.9.0 → 1.11.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.
Files changed (52) hide show
  1. package/CHANGELOG.md +417 -0
  2. package/package.json +15 -7
  3. package/scripts/generate-stdlib-types.ts +2 -2
  4. package/src/components/ActionCard.tsx +221 -0
  5. package/src/components/CodeEditor/CodeEditor.tsx +51 -9
  6. package/src/components/CodeEditor/TypefoxEditor.tsx +868 -0
  7. package/src/components/CodeEditor/bracketKeyGroups.test.ts +120 -0
  8. package/src/components/CodeEditor/bracketKeyGroups.ts +205 -0
  9. package/src/components/CodeEditor/generateTypeDefinitions.ts +4 -4
  10. package/src/components/CodeEditor/index.ts +2 -0
  11. package/src/components/CodeEditor/scriptContext.test.ts +41 -0
  12. package/src/components/CodeEditor/scriptContext.ts +76 -1
  13. package/src/components/CodeEditor/templateValidation.ts +51 -0
  14. package/src/components/CodeEditor/types.ts +109 -0
  15. package/src/components/CodeEditor/validateJsonTemplate.test.ts +61 -0
  16. package/src/components/CodeEditor/validateJsonTemplate.ts +26 -0
  17. package/src/components/CodeEditor/validateXmlTemplate.test.ts +34 -0
  18. package/src/components/CodeEditor/validateXmlTemplate.ts +35 -0
  19. package/src/components/CodeEditor/validateYamlTemplate.test.ts +39 -0
  20. package/src/components/CodeEditor/validateYamlTemplate.ts +28 -0
  21. package/src/components/DynamicForm/DynamicForm.tsx +2 -0
  22. package/src/components/DynamicForm/FormField.tsx +29 -9
  23. package/src/components/DynamicForm/KeyValueEditor.tsx +2 -169
  24. package/src/components/DynamicForm/MultiTypeEditorField.tsx +16 -7
  25. package/src/components/DynamicForm/types.ts +11 -0
  26. package/src/components/ListEmptyState.tsx +51 -0
  27. package/src/components/QueryErrorState.tsx +64 -0
  28. package/src/components/ResponsiveTable.tsx +92 -0
  29. package/src/components/Skeleton.tsx +39 -0
  30. package/src/components/TemplateInput.tsx +104 -0
  31. package/src/components/TemplateInputToggle.tsx +111 -0
  32. package/src/components/TemplateValueInput.test.ts +98 -0
  33. package/src/components/TemplateValueInput.tsx +470 -0
  34. package/src/components/VariablePicker.tsx +271 -0
  35. package/src/hooks/useInitOnceForKey.test.ts +27 -0
  36. package/src/hooks/useInitOnceForKey.ts +21 -18
  37. package/src/index.ts +10 -0
  38. package/src/utils/toastTemplates.test.ts +82 -0
  39. package/src/utils/toastTemplates.ts +47 -0
  40. package/stories/ActionCard.stories.tsx +62 -0
  41. package/stories/Alert.stories.tsx +5 -5
  42. package/stories/ListEmptyState.stories.tsx +48 -0
  43. package/stories/QueryErrorState.stories.tsx +40 -0
  44. package/stories/ResponsiveTable.stories.tsx +93 -0
  45. package/stories/Skeleton.stories.tsx +53 -0
  46. package/stories/TemplateInputToggle.stories.tsx +77 -0
  47. package/stories/TemplateValueInput.stories.tsx +65 -0
  48. package/stories/VariablePicker.stories.tsx +109 -0
  49. package/stories/toastTemplates.stories.tsx +60 -0
  50. package/src/components/CodeEditor/MonacoEditor.tsx +0 -616
  51. package/src/components/CodeEditor/monacoStdlib.ts +0 -62
  52. package/src/components/CodeEditor/monacoWorkers.ts +0 -118
@@ -0,0 +1,271 @@
1
+ import React from "react";
2
+ import { ChevronRight, Code2, Search } from "lucide-react";
3
+ import { Input } from "./Input";
4
+ import { Popover, PopoverContent, PopoverTrigger } from "./Popover";
5
+
6
+ /**
7
+ * One node in the variable scope tree.
8
+ *
9
+ * Mirrors `VariableEntry` from `@checkstack/automation-common` — but this
10
+ * package can't depend on automation-common (UI primitives live below the
11
+ * automation layer), so the shape is duplicated here. The automation
12
+ * editor adapts `VariableScope.entries` → `VariableNode[]` at the call
13
+ * site.
14
+ */
15
+ export interface VariableNode {
16
+ /** Canonical dot-separated path, e.g. `artifact.integration-jira.issue.key`. */
17
+ path: string;
18
+ /**
19
+ * Runtime-parseable `{{ }}` insertion form, e.g.
20
+ * `artifacts["integration-jira.issue"].key`. Inserted in preference to
21
+ * `path`; callers that don't supply it fall back to `path`.
22
+ */
23
+ templateRef?: string;
24
+ /** Human-readable type label rendered next to the name. */
25
+ type: string;
26
+ description?: string;
27
+ /** Nested entries for object types. */
28
+ children?: VariableNode[];
29
+ /**
30
+ * When set, the entry only exists when one of these triggers fired —
31
+ * picker renders an "Only when …" hint so the operator knows it might
32
+ * be undefined at runtime.
33
+ */
34
+ conditionalOnTriggers?: string[];
35
+ }
36
+
37
+ export interface VariablePickerProps {
38
+ /** Tree of in-scope variables. */
39
+ scope: VariableNode[];
40
+ /**
41
+ * Called with the runtime-parseable text to insert (the node's
42
+ * `templateRef`, falling back to `path`), e.g.
43
+ * `trigger.payload.systemId` or `artifacts["integration-jira.issue"].key`.
44
+ */
45
+ onSelect: (templateRef: string) => void;
46
+ /** Optional element rendered as the popover trigger. Defaults to a small "Insert variable" button. */
47
+ trigger?: React.ReactNode;
48
+ /** Controls open state; defaults to uncontrolled. */
49
+ open?: boolean;
50
+ onOpenChange?: (open: boolean) => void;
51
+ /** Optional class on the popover content. */
52
+ contentClassName?: string;
53
+ }
54
+
55
+ /**
56
+ * Hierarchical variable picker. Click the trigger button → a popover
57
+ * opens with the tree of in-scope paths grouped under their parents
58
+ * (`trigger`, `var`, `artifact`, `repeat`). Each row inserts
59
+ * `{{ path }}` when clicked. A search input at the top filters across
60
+ * the whole tree (matches against the dot-path), and matched ancestors
61
+ * stay expanded so context is preserved.
62
+ *
63
+ * Designed for the explicit "fx" / "Insert variable" workflow inside the
64
+ * automation editor. For inline `{{` autocomplete inside a text field,
65
+ * use `TemplateValueInput`; for code editors, the `CodeEditor` already
66
+ * pops the same dropdown through Monaco's completion provider.
67
+ */
68
+ export const VariablePicker: React.FC<VariablePickerProps> = ({
69
+ scope,
70
+ onSelect,
71
+ trigger,
72
+ open,
73
+ onOpenChange,
74
+ contentClassName,
75
+ }) => {
76
+ const [query, setQuery] = React.useState("");
77
+ const [internalOpen, setInternalOpen] = React.useState(false);
78
+ const isOpen = open ?? internalOpen;
79
+ const setOpen = (next: boolean) => {
80
+ if (open === undefined) setInternalOpen(next);
81
+ onOpenChange?.(next);
82
+ };
83
+
84
+ const filtered = React.useMemo(
85
+ () => (query.trim() ? filterTree(scope, query.trim().toLowerCase()) : scope),
86
+ [scope, query],
87
+ );
88
+
89
+ const handleSelect = (path: string) => {
90
+ onSelect(path);
91
+ setOpen(false);
92
+ setQuery("");
93
+ };
94
+
95
+ const handleKeyDownOnInput = (e: React.KeyboardEvent<HTMLInputElement>) => {
96
+ if (e.key === "Escape") {
97
+ e.preventDefault();
98
+ setOpen(false);
99
+ }
100
+ };
101
+
102
+ return (
103
+ <Popover open={isOpen} onOpenChange={setOpen}>
104
+ <PopoverTrigger asChild>
105
+ {trigger ?? (
106
+ <button
107
+ type="button"
108
+ className="inline-flex items-center gap-1 rounded border border-border bg-card px-2 py-1 text-xs font-mono text-muted-foreground hover:bg-accent hover:text-accent-foreground"
109
+ aria-label="Insert variable"
110
+ >
111
+ <Code2 className="h-3 w-3" />
112
+ <span>fx</span>
113
+ </button>
114
+ )}
115
+ </PopoverTrigger>
116
+ <PopoverContent
117
+ className={`w-80 p-0 ${contentClassName ?? ""}`.trim()}
118
+ align="start"
119
+ >
120
+ <div className="border-b border-border px-2 py-2">
121
+ <div className="relative">
122
+ <Search className="absolute left-2 top-1/2 h-3 w-3 -translate-y-1/2 text-muted-foreground" />
123
+ <Input
124
+ autoFocus
125
+ value={query}
126
+ onChange={(e) => setQuery(e.target.value)}
127
+ onKeyDown={handleKeyDownOnInput}
128
+ placeholder="Filter variables…"
129
+ className="h-7 pl-7 font-mono text-xs"
130
+ />
131
+ </div>
132
+ </div>
133
+ <div className="max-h-80 overflow-y-auto py-1">
134
+ {filtered.length === 0 ? (
135
+ <p className="px-3 py-4 text-center text-xs text-muted-foreground italic">
136
+ No matching variables.
137
+ </p>
138
+ ) : (
139
+ filtered.map((node) => (
140
+ <VariableTreeNode
141
+ key={node.path}
142
+ node={node}
143
+ depth={0}
144
+ onSelect={handleSelect}
145
+ forceExpand={query.trim().length > 0}
146
+ />
147
+ ))
148
+ )}
149
+ </div>
150
+ </PopoverContent>
151
+ </Popover>
152
+ );
153
+ };
154
+
155
+ interface VariableTreeNodeProps {
156
+ node: VariableNode;
157
+ depth: number;
158
+ onSelect: (path: string) => void;
159
+ forceExpand: boolean;
160
+ }
161
+
162
+ const VariableTreeNode: React.FC<VariableTreeNodeProps> = ({
163
+ node,
164
+ depth,
165
+ onSelect,
166
+ forceExpand,
167
+ }) => {
168
+ const [expanded, setExpanded] = React.useState(depth === 0);
169
+ const isExpanded = forceExpand || expanded;
170
+ const hasChildren = node.children && node.children.length > 0;
171
+
172
+ return (
173
+ <div>
174
+ <div
175
+ className="group flex w-full items-center gap-1 text-xs hover:bg-accent/50"
176
+ style={{ paddingLeft: `${depth * 12 + 8}px` }}
177
+ >
178
+ {hasChildren ? (
179
+ <button
180
+ type="button"
181
+ onClick={(event) => {
182
+ event.stopPropagation();
183
+ setExpanded((v) => !v);
184
+ }}
185
+ className="flex h-6 w-4 shrink-0 items-center justify-center rounded hover:bg-accent hover:text-accent-foreground"
186
+ aria-label={isExpanded ? "Collapse" : "Expand"}
187
+ aria-expanded={isExpanded}
188
+ >
189
+ <ChevronRight
190
+ className={`h-3 w-3 transition-transform ${
191
+ isExpanded ? "rotate-90" : ""
192
+ }`}
193
+ />
194
+ </button>
195
+ ) : (
196
+ <span className="h-6 w-4 shrink-0" />
197
+ )}
198
+ <button
199
+ type="button"
200
+ onClick={() => onSelect(node.templateRef ?? node.path)}
201
+ className="flex flex-1 items-center gap-2 py-1 pr-2 text-left hover:bg-accent hover:text-accent-foreground"
202
+ title={`Insert {{${node.templateRef ?? node.path}}}`}
203
+ >
204
+ <code className="flex-1 truncate font-mono">{leafName(node.path)}</code>
205
+ <span className="shrink-0 font-mono text-[10px] text-muted-foreground">
206
+ {node.type}
207
+ </span>
208
+ </button>
209
+ </div>
210
+ {node.conditionalOnTriggers && node.conditionalOnTriggers.length > 0 && (
211
+ <p
212
+ className="px-2 text-[10px] italic text-muted-foreground"
213
+ style={{ paddingLeft: `${depth * 12 + 24}px` }}
214
+ >
215
+ Only when {node.conditionalOnTriggers.join(", ")}
216
+ </p>
217
+ )}
218
+ {node.description && (
219
+ <p
220
+ className="px-2 pb-1 text-[10px] text-muted-foreground"
221
+ style={{ paddingLeft: `${depth * 12 + 24}px` }}
222
+ >
223
+ {node.description}
224
+ </p>
225
+ )}
226
+ {hasChildren && isExpanded && (
227
+ <div>
228
+ {node.children!.map((child) => (
229
+ <VariableTreeNode
230
+ key={child.path}
231
+ node={child}
232
+ depth={depth + 1}
233
+ onSelect={onSelect}
234
+ forceExpand={forceExpand}
235
+ />
236
+ ))}
237
+ </div>
238
+ )}
239
+ </div>
240
+ );
241
+ };
242
+
243
+ function leafName(path: string): string {
244
+ const idx = path.lastIndexOf(".");
245
+ return idx === -1 ? path : path.slice(idx + 1);
246
+ }
247
+
248
+ /**
249
+ * Walk the tree and return a copy that only includes nodes whose path
250
+ * (or any descendant's path) contains the query. Matched ancestors are
251
+ * kept so the tree structure is preserved.
252
+ */
253
+ function filterTree(
254
+ nodes: VariableNode[],
255
+ query: string,
256
+ ): VariableNode[] {
257
+ const out: VariableNode[] = [];
258
+ for (const node of nodes) {
259
+ const selfMatch = node.path.toLowerCase().includes(query);
260
+ const childMatches = node.children
261
+ ? filterTree(node.children, query)
262
+ : undefined;
263
+ if (selfMatch || (childMatches && childMatches.length > 0)) {
264
+ out.push({
265
+ ...node,
266
+ children: childMatches,
267
+ });
268
+ }
269
+ }
270
+ return out;
271
+ }
@@ -124,4 +124,31 @@ describe("shouldInitForKey", () => {
124
124
  shouldInitForKey({ value: "any", key: "1", initialisedKey: 1 }),
125
125
  ).toBe(true);
126
126
  });
127
+
128
+ it("does not seed from a stale cache entry served on mount, only from a post-mount fetch", () => {
129
+ // Regression for the automation editor: another page observes the same
130
+ // `getAutomation` cache key without `gcTime: 0`, so a stale (pre-edit)
131
+ // entry can be served instantly on reopen. The call site gates `value` on
132
+ // `isFetchedAfterMount`, so until a fresh fetch lands it passes `undefined`
133
+ // and we must NOT seed the stale value (which would revert edits such as a
134
+ // renamed trigger id back to its auto-generated default).
135
+ const staleCacheBeforeFreshFetch = undefined; // isFetchedAfterMount === false
136
+ expect(
137
+ shouldInitForKey({
138
+ value: staleCacheBeforeFreshFetch,
139
+ key: "auto-1",
140
+ initialisedKey: undefined,
141
+ }),
142
+ ).toBe(false);
143
+
144
+ // Once the post-mount fetch resolves, the caller passes the fresh value and
145
+ // the one-shot init fires with server-truth data.
146
+ expect(
147
+ shouldInitForKey({
148
+ value: { name: "A", definition: { triggers: [{ id: "majors" }] } },
149
+ key: "auto-1",
150
+ initialisedKey: undefined,
151
+ }),
152
+ ).toBe(true);
153
+ });
127
154
  });
@@ -1,4 +1,4 @@
1
- import { useEffect, useRef } from "react";
1
+ import { useState } from "react";
2
2
 
3
3
  /**
4
4
  * Pure decision function powering {@link useInitOnceForKey}. Extracted so
@@ -52,8 +52,15 @@ export function shouldInitForKey({
52
52
  * - Skips initialisation entirely while either `value` or `key` is
53
53
  * `undefined`/`null`.
54
54
  *
55
- * `onInit` is read from a ref so callers can safely pass a fresh closure
56
- * each render without re-firing the effect.
55
+ * Seeding runs **during render** (not in a `useEffect`). This is deliberate:
56
+ * the app is wrapped in `<StrictMode>`, which double-mounts components and
57
+ * **discards a `setState` scheduled from an effect** when the source query
58
+ * resolves synchronously — e.g. a warm react-query cache on reopen. That made
59
+ * the one-shot init silently no-op, reverting seeded form state (a renamed id
60
+ * snapping back to its default, etc.) while a cold-cache first open worked.
61
+ * Seeding during render with a state guard is React's recommended
62
+ * "adjust state when data changes" pattern and is immune to that race. `onInit`
63
+ * must therefore be pure aside from calling this component's state setters.
57
64
  *
58
65
  * @example
59
66
  * useInitOnceForKey(existingConfig, existingConfig?.id, (config) => {
@@ -68,20 +75,16 @@ export function useInitOnceForKey<T>(
68
75
  key: string | number | null | undefined,
69
76
  onInit: (value: T) => void,
70
77
  ): void {
71
- const initialisedKeyRef = useRef<string | number | null | undefined>(undefined);
72
- const onInitRef = useRef(onInit);
78
+ const [initialisedKey, setInitialisedKey] =
79
+ useState<string | number | null | undefined>();
73
80
 
74
- // Keep the latest callback in a ref so a fresh closure each render doesn't
75
- // re-trigger the effect; only `value` and `key` should drive it.
76
- useEffect(() => {
77
- onInitRef.current = onInit;
78
- });
79
-
80
- useEffect(() => {
81
- if (!shouldInitForKey({ value, key, initialisedKey: initialisedKeyRef.current })) {
82
- return;
83
- }
84
- initialisedKeyRef.current = key;
85
- onInitRef.current(value as T);
86
- }, [value, key]);
81
+ if (shouldInitForKey({ value, key, initialisedKey })) {
82
+ // Setting state + invoking `onInit` (which sets this component's state)
83
+ // during render is the supported "store info from previous renders"
84
+ // pattern: React restarts this component's render with the new state
85
+ // before committing, and the `initialisedKey` guard makes it idempotent
86
+ // (no loop; background refetches of the same key are ignored).
87
+ setInitialisedKey(key);
88
+ onInit(value as T);
89
+ }
87
90
  }
package/src/index.ts CHANGED
@@ -56,6 +56,11 @@ export * from "./components/TerminalFeed";
56
56
  export * from "./components/PerformanceProvider";
57
57
  export * from "./components/AmbientBackground";
58
58
  export * from "./components/CodeEditor";
59
+ export * from "./components/TemplateValueInput";
60
+ export * from "./components/VariablePicker";
61
+ export * from "./components/TemplateInput";
62
+ export * from "./components/TemplateInputToggle";
63
+ export * from "./components/ActionCard";
59
64
  export * from "./components/AnimatedNumber";
60
65
  export * from "./hooks/useAnimatedNumber";
61
66
  export * from "./components/IDELayout";
@@ -64,3 +69,8 @@ export * from "./components/Sheet";
64
69
  export * from "./components/Popover";
65
70
  export * from "./hooks/useIsMobile";
66
71
  export * from "./hooks/useInitOnceForKey";
72
+ export * from "./components/ListEmptyState";
73
+ export * from "./components/QueryErrorState";
74
+ export * from "./components/Skeleton";
75
+ export * from "./components/ResponsiveTable";
76
+ export * from "./utils/toastTemplates";
@@ -0,0 +1,82 @@
1
+ import { describe, expect, it, mock, beforeEach } from "bun:test";
2
+ import {
3
+ toastError,
4
+ toastSuccess,
5
+ type ToastApi,
6
+ } from "./toastTemplates";
7
+
8
+ const makeToastMock = (): ToastApi => ({
9
+ show: mock(),
10
+ success: mock(),
11
+ error: mock(),
12
+ warning: mock(),
13
+ info: mock(),
14
+ });
15
+
16
+ describe("toastSuccess", () => {
17
+ let toast: ToastApi;
18
+
19
+ beforeEach(() => {
20
+ toast = makeToastMock();
21
+ });
22
+
23
+ it("passes the action through to toast.success", () => {
24
+ toastSuccess(toast, "Check created");
25
+
26
+ expect(toast.success).toHaveBeenCalledTimes(1);
27
+ expect(toast.success).toHaveBeenCalledWith("Check created");
28
+ });
29
+ });
30
+
31
+ describe("toastError", () => {
32
+ let toast: ToastApi;
33
+
34
+ beforeEach(() => {
35
+ toast = makeToastMock();
36
+ });
37
+
38
+ it("prefixes the action and includes the extracted error message", () => {
39
+ toastError(toast, "Failed to create check", new Error("Backend unreachable"));
40
+
41
+ expect(toast.error).toHaveBeenCalledTimes(1);
42
+ expect(toast.error).toHaveBeenCalledWith(
43
+ "Failed to create check: Backend unreachable",
44
+ );
45
+ });
46
+
47
+ it("uses the fallback message when error is not an Error or string", () => {
48
+ toastError(toast, "Failed to delete check", null);
49
+
50
+ expect(toast.error).toHaveBeenCalledWith(
51
+ "Failed to delete check: An error occurred",
52
+ );
53
+ });
54
+
55
+ it("accepts a string error and includes it verbatim", () => {
56
+ toastError(toast, "Save failed", "validation: bad payload");
57
+
58
+ expect(toast.error).toHaveBeenCalledWith(
59
+ "Save failed: validation: bad payload",
60
+ );
61
+ });
62
+
63
+ it("truncates the message to 100 characters with an ellipsis", () => {
64
+ const longMessage = "x".repeat(200);
65
+ toastError(toast, "Failed", new Error(longMessage));
66
+
67
+ const mockedError = toast.error as ReturnType<typeof mock>;
68
+ const call = mockedError.mock.calls[0];
69
+ const arg = call[0];
70
+ expect(typeof arg).toBe("string");
71
+ if (typeof arg !== "string") throw new Error("expected string toast message");
72
+ expect(arg.length).toBe(100);
73
+ expect(arg.endsWith("…")).toBe(true);
74
+ });
75
+
76
+ it("leaves messages at or under 100 characters intact", () => {
77
+ const shortMessage = "boom";
78
+ toastError(toast, "Failed", new Error(shortMessage));
79
+
80
+ expect(toast.error).toHaveBeenCalledWith("Failed: boom");
81
+ });
82
+ });
@@ -0,0 +1,47 @@
1
+ import { extractErrorMessage } from "@checkstack/common";
2
+ import type { useToast } from "../components/ToastProvider";
3
+
4
+ /**
5
+ * Shape of the toast API exposed by {@link useToast}. Re-derived from
6
+ * the hook's return type so the helpers stay in lock-step with any
7
+ * future additions to the toast surface.
8
+ */
9
+ export type ToastApi = ReturnType<typeof useToast>;
10
+
11
+ const MAX_TOAST_MESSAGE_LENGTH = 100;
12
+
13
+ /**
14
+ * Truncate `message` to `MAX_TOAST_MESSAGE_LENGTH` characters, replacing
15
+ * the tail with an ellipsis. Used to keep error toasts readable when
16
+ * upstream payloads carry verbose stack traces.
17
+ */
18
+ function truncate(message: string): string {
19
+ if (message.length <= MAX_TOAST_MESSAGE_LENGTH) return message;
20
+ return `${message.slice(0, MAX_TOAST_MESSAGE_LENGTH - 1)}…`;
21
+ }
22
+
23
+ /**
24
+ * toastSuccess - shorthand for `toast.success(action)`.
25
+ *
26
+ * Use a verb-phrase for `action` so the toast reads naturally, e.g.
27
+ * `"Check created"`, `"Configuration saved"`.
28
+ */
29
+ export function toastSuccess(toast: ToastApi, action: string): void {
30
+ toast.success(action);
31
+ }
32
+
33
+ /**
34
+ * toastError - render an error toast in the canonical
35
+ * `"{action}: {message}"` format, truncated to 100 characters.
36
+ *
37
+ * Funnels the unknown `error` through {@link extractErrorMessage} so
38
+ * callers don't have to narrow at every call site.
39
+ */
40
+ export function toastError(
41
+ toast: ToastApi,
42
+ action: string,
43
+ error: unknown,
44
+ ): void {
45
+ const message = extractErrorMessage(error);
46
+ toast.error(truncate(`${action}: ${message}`));
47
+ }
@@ -0,0 +1,62 @@
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
+ import { useState } from "react";
3
+ import { ActionCard } from "../src/components/ActionCard";
4
+
5
+ const meta: Meta<typeof ActionCard> = {
6
+ title: "Components/Automation/ActionCard",
7
+ component: ActionCard,
8
+ tags: ["autodocs"],
9
+ parameters: {
10
+ docs: {
11
+ description: {
12
+ component:
13
+ "Collapsible card that hosts a single action in the visual automation editor.",
14
+ },
15
+ },
16
+ },
17
+ };
18
+
19
+ export default meta;
20
+ type Story = StoryObj<typeof ActionCard>;
21
+
22
+ const FullFeaturedDemo = () => {
23
+ const [enabled, setEnabled] = useState(true);
24
+ return (
25
+ <div className="w-[680px] p-4">
26
+ <ActionCard
27
+ id="notify-1"
28
+ title="Notify User"
29
+ description="Send a transactional notification to a specific operator."
30
+ category="Notification"
31
+ icon="Bell"
32
+ enabled={enabled}
33
+ onEnabledChange={setEnabled}
34
+ onDelete={() => alert("Delete clicked")}
35
+ badges={[{ label: "produces: notify_user_result", variant: "secondary" }]}
36
+ >
37
+ <div className="space-y-2 text-sm">
38
+ <p className="text-muted-foreground">
39
+ (DynamicForm or per-action config UI goes here.)
40
+ </p>
41
+ <code className="block font-mono text-xs">userId, title, body</code>
42
+ </div>
43
+ </ActionCard>
44
+ </div>
45
+ );
46
+ };
47
+
48
+ export const FullFeatured: Story = {
49
+ render: () => <FullFeaturedDemo />,
50
+ };
51
+
52
+ export const MinimalNoToggle: Story = {
53
+ render: () => (
54
+ <div className="w-[680px] p-4">
55
+ <ActionCard id="log-1" title="Log" icon="FileText">
56
+ <p className="text-sm text-muted-foreground">
57
+ Write a single line to the run logger.
58
+ </p>
59
+ </ActionCard>
60
+ </div>
61
+ ),
62
+ };
@@ -1,5 +1,5 @@
1
1
  import type { Meta, StoryObj } from "@storybook/react";
2
- import { CircleAlert, CircleCheck, Info, TriangleAlert } from "lucide-react";
2
+ import { CircleAlert, CircleCheck, Info, AlertTriangle } from "lucide-react";
3
3
  import {
4
4
  Alert,
5
5
  AlertContent,
@@ -28,7 +28,7 @@ export const Default: Story = {
28
28
  render: (args) => (
29
29
  <Alert {...args}>
30
30
  <AlertIcon>
31
- <Info className="h-4 w-4" />
31
+ <Info className="w-4 h-4" />
32
32
  </AlertIcon>
33
33
  <AlertContent>
34
34
  <AlertTitle>Heads up</AlertTitle>
@@ -45,7 +45,7 @@ export const Success: Story = {
45
45
  render: (args) => (
46
46
  <Alert {...args}>
47
47
  <AlertIcon>
48
- <CircleCheck className="h-4 w-4" />
48
+ <CircleCheck className="w-4 h-4" />
49
49
  </AlertIcon>
50
50
  <AlertContent>
51
51
  <AlertTitle>Saved</AlertTitle>
@@ -60,7 +60,7 @@ export const Warning: Story = {
60
60
  render: (args) => (
61
61
  <Alert {...args}>
62
62
  <AlertIcon>
63
- <TriangleAlert className="h-4 w-4" />
63
+ <AlertTriangle className="w-4 h-4" />
64
64
  </AlertIcon>
65
65
  <AlertContent>
66
66
  <AlertTitle>Heads up</AlertTitle>
@@ -77,7 +77,7 @@ export const Error: Story = {
77
77
  render: (args) => (
78
78
  <Alert {...args}>
79
79
  <AlertIcon>
80
- <CircleAlert className="h-4 w-4" />
80
+ <CircleAlert className="w-4 h-4" />
81
81
  </AlertIcon>
82
82
  <AlertContent>
83
83
  <AlertTitle>Something went wrong</AlertTitle>
@@ -0,0 +1,48 @@
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
+ import { Plus, ServerCog } from "lucide-react";
3
+ import { Button } from "../src/components/Button";
4
+ import { ListEmptyState } from "../src/components/ListEmptyState";
5
+
6
+ const meta: Meta<typeof ListEmptyState> = {
7
+ title: "Components/Feedback/ListEmptyState",
8
+ component: ListEmptyState,
9
+ tags: ["autodocs"],
10
+ args: {
11
+ resource: "checks",
12
+ },
13
+ };
14
+
15
+ export default meta;
16
+ type Story = StoryObj<typeof ListEmptyState>;
17
+
18
+ export const Default: Story = {};
19
+
20
+ export const WithDescription: Story = {
21
+ args: {
22
+ resource: "incidents",
23
+ description:
24
+ "Incidents are reported by operators and tracked through resolution updates.",
25
+ },
26
+ };
27
+
28
+ export const WithAction: Story = {
29
+ args: {
30
+ resource: "checks",
31
+ description:
32
+ "Create a health check to start monitoring an endpoint.",
33
+ actions: (
34
+ <Button>
35
+ <Plus className="h-4 w-4 mr-2" />
36
+ Create your first check
37
+ </Button>
38
+ ),
39
+ },
40
+ };
41
+
42
+ export const CustomIcon: Story = {
43
+ args: {
44
+ resource: "satellites",
45
+ description: "Satellites probe remote networks Checkstack can't reach directly.",
46
+ icon: <ServerCog className="h-10 w-10" />,
47
+ },
48
+ };