ai-design-system 0.1.2 → 0.1.4

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.
@@ -10,6 +10,7 @@ import {
10
10
  DropdownMenuItem,
11
11
  DropdownMenuTrigger,
12
12
  } from "@/components/primitives/DropdownMenu";
13
+ import { Icon } from "@/components/primitives/Icon";
13
14
  import { cn } from "@/lib/utils";
14
15
 
15
16
  // ---------------------------------------------------------------------------
@@ -23,8 +24,12 @@ export interface WorkflowVersion {
23
24
 
24
25
  export interface ToolbarAction {
25
26
  id: string;
26
- /** Icon element to render inside the button */
27
- icon: ReactNode;
27
+ /**
28
+ * Icon to render inside the button.
29
+ * Pass a string icon name from the icon registry (preferred — no icon package needed in consumer)
30
+ * or a ReactNode for custom icons.
31
+ */
32
+ icon: string | ReactNode;
28
33
  /** Tooltip text */
29
34
  title: string;
30
35
  onClick?: () => void;
@@ -76,6 +81,8 @@ export function WorkflowToolbarActions({
76
81
  >
77
82
  {action.loading ? (
78
83
  <Loader2 className="size-4 animate-spin" />
84
+ ) : typeof action.icon === 'string' ? (
85
+ <Icon name={action.icon} size="sm" />
79
86
  ) : (
80
87
  action.icon
81
88
  )}
@@ -1,10 +1,10 @@
1
1
  "use client";
2
2
 
3
- import { Redo2, Save, Undo2, X } from "lucide-react";
3
+ import { Redo2, Save, Undo2 } from "lucide-react";
4
4
  import { WorkflowToolbar, WorkflowToolbarActions } from "@/components/composites/WorkflowToolbar";
5
5
  import { WorkflowCanvas } from "@/components/blocks/WorkflowCanvas";
6
6
  import type { WorkflowNode, WorkflowEdge } from "@/components/blocks/WorkflowCanvas";
7
- import type { WorkflowVersion } from "@/components/composites/WorkflowToolbar";
7
+ import type { ToolbarAction, WorkflowVersion } from "@/components/composites/WorkflowToolbar";
8
8
  import type { Connection, NodeChange, EdgeChange } from "@xyflow/react";
9
9
 
10
10
  export interface WorkflowBuilderProps {
@@ -27,10 +27,12 @@ export interface WorkflowBuilderProps {
27
27
  canUndo?: boolean;
28
28
  canRedo?: boolean;
29
29
  onSave?: () => void;
30
- onCancel?: () => void;
31
30
  onUndo?: () => void;
32
31
  onRedo?: () => void;
33
32
 
33
+ /** Extra toolbar action groups prepended before the default undo/redo/save buttons. */
34
+ extraActions?: ToolbarAction[][];
35
+
34
36
  showMinimap?: boolean;
35
37
  interactive?: boolean;
36
38
  className?: string;
@@ -51,13 +53,27 @@ export function WorkflowBuilder({
51
53
  canUndo = false,
52
54
  canRedo = false,
53
55
  onSave,
54
- onCancel,
55
56
  onUndo,
56
57
  onRedo,
58
+ extraActions,
57
59
  showMinimap,
58
60
  interactive = false,
59
61
  className,
60
62
  }: WorkflowBuilderProps) {
63
+ const defaultActionGroups: ToolbarAction[][] = [
64
+ [
65
+ { id: "undo", icon: <Undo2 className="size-4" />, title: "Undo", onClick: onUndo, disabled: !canUndo },
66
+ { id: "redo", icon: <Redo2 className="size-4" />, title: "Redo", onClick: onRedo, disabled: !canRedo },
67
+ ],
68
+ [
69
+ { id: "save", icon: <Save className="size-4" />, title: "Save", onClick: onSave, loading: isSaving, indicator: hasUnsavedChanges },
70
+ ],
71
+ ];
72
+
73
+ const allActionGroups = extraActions
74
+ ? [...extraActions, ...defaultActionGroups]
75
+ : defaultActionGroups;
76
+
61
77
  return (
62
78
  <div className="relative h-full w-full" data-testid="workflow-builder">
63
79
  <WorkflowCanvas
@@ -75,18 +91,7 @@ export function WorkflowBuilder({
75
91
  />
76
92
  }
77
93
  topRight={
78
- <WorkflowToolbarActions
79
- actionGroups={[
80
- [
81
- { id: "undo", icon: <Undo2 className="size-4" />, title: "Undo", onClick: onUndo, disabled: !canUndo },
82
- { id: "redo", icon: <Redo2 className="size-4" />, title: "Redo", onClick: onRedo, disabled: !canRedo },
83
- ],
84
- [
85
- { id: "save", icon: <Save className="size-4" />, title: "Save", onClick: onSave, loading: isSaving, indicator: hasUnsavedChanges },
86
- { id: "cancel", icon: <X className="size-4" />, title: "Cancel", onClick: onCancel },
87
- ],
88
- ]}
89
- />
94
+ <WorkflowToolbarActions actionGroups={allActionGroups} />
90
95
  }
91
96
  onConnect={onConnect}
92
97
  onEdgesChange={onEdgesChange}
@@ -1,2 +1,3 @@
1
1
  export { WorkflowBuilder } from "./WorkflowBuilder";
2
2
  export type { WorkflowBuilderProps } from "./WorkflowBuilder";
3
+ export type { ToolbarAction } from "@/components/composites/WorkflowToolbar";
package/dist/index.cjs CHANGED
@@ -2296,6 +2296,11 @@ var defaultIcons = {
2296
2296
  name: "file-text",
2297
2297
  viewBox: "0 0 24 24",
2298
2298
  path: "M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8zM14 2v6h6M16 13H8m8 4H8m8-8H8"
2299
+ },
2300
+ "message-square": {
2301
+ name: "message-square",
2302
+ viewBox: "0 0 24 24",
2303
+ path: "M21 15a2 2 0 01-2 2H7l-4 4V5a2 2 0 012-2h14a2 2 0 012 2z"
2299
2304
  }
2300
2305
  };
2301
2306
  var IconRegistry = class {
@@ -7165,7 +7170,7 @@ function WorkflowToolbarActions({
7165
7170
  title: action.title,
7166
7171
  variant: "secondary",
7167
7172
  children: [
7168
- action.loading ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "size-4 animate-spin" }) : action.icon,
7173
+ action.loading ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "size-4 animate-spin" }) : typeof action.icon === "string" ? /* @__PURE__ */ jsxRuntime.jsx(Icon, { name: action.icon, size: "sm" }) : action.icon,
7169
7174
  action.indicator && !action.loading && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute top-1.5 right-1.5 size-2 rounded-full bg-primary" })
7170
7175
  ]
7171
7176
  },
@@ -8108,13 +8113,23 @@ function WorkflowBuilder({
8108
8113
  canUndo = false,
8109
8114
  canRedo = false,
8110
8115
  onSave,
8111
- onCancel,
8112
8116
  onUndo,
8113
8117
  onRedo,
8118
+ extraActions,
8114
8119
  showMinimap,
8115
8120
  interactive = false,
8116
8121
  className
8117
8122
  }) {
8123
+ const defaultActionGroups = [
8124
+ [
8125
+ { id: "undo", icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Undo2, { className: "size-4" }), title: "Undo", onClick: onUndo, disabled: !canUndo },
8126
+ { id: "redo", icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Redo2, { className: "size-4" }), title: "Redo", onClick: onRedo, disabled: !canRedo }
8127
+ ],
8128
+ [
8129
+ { id: "save", icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Save, { className: "size-4" }), title: "Save", onClick: onSave, loading: isSaving, indicator: hasUnsavedChanges }
8130
+ ]
8131
+ ];
8132
+ const allActionGroups = extraActions ? [...extraActions, ...defaultActionGroups] : defaultActionGroups;
8118
8133
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative h-full w-full", "data-testid": "workflow-builder", children: /* @__PURE__ */ jsxRuntime.jsx(
8119
8134
  WorkflowCanvas,
8120
8135
  {
@@ -8132,21 +8147,7 @@ function WorkflowBuilder({
8132
8147
  onVersionSelect
8133
8148
  }
8134
8149
  ),
8135
- topRight: /* @__PURE__ */ jsxRuntime.jsx(
8136
- WorkflowToolbarActions,
8137
- {
8138
- actionGroups: [
8139
- [
8140
- { id: "undo", icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Undo2, { className: "size-4" }), title: "Undo", onClick: onUndo, disabled: !canUndo },
8141
- { id: "redo", icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Redo2, { className: "size-4" }), title: "Redo", onClick: onRedo, disabled: !canRedo }
8142
- ],
8143
- [
8144
- { id: "save", icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Save, { className: "size-4" }), title: "Save", onClick: onSave, loading: isSaving, indicator: hasUnsavedChanges },
8145
- { id: "cancel", icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "size-4" }), title: "Cancel", onClick: onCancel }
8146
- ]
8147
- ]
8148
- }
8149
- ),
8150
+ topRight: /* @__PURE__ */ jsxRuntime.jsx(WorkflowToolbarActions, { actionGroups: allActionGroups }),
8150
8151
  onConnect,
8151
8152
  onEdgesChange,
8152
8153
  onNodesChange