ai-design-system 0.1.2 → 0.1.3

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.
@@ -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
@@ -8108,13 +8108,23 @@ function WorkflowBuilder({
8108
8108
  canUndo = false,
8109
8109
  canRedo = false,
8110
8110
  onSave,
8111
- onCancel,
8112
8111
  onUndo,
8113
8112
  onRedo,
8113
+ extraActions,
8114
8114
  showMinimap,
8115
8115
  interactive = false,
8116
8116
  className
8117
8117
  }) {
8118
+ const defaultActionGroups = [
8119
+ [
8120
+ { id: "undo", icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Undo2, { className: "size-4" }), title: "Undo", onClick: onUndo, disabled: !canUndo },
8121
+ { id: "redo", icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Redo2, { className: "size-4" }), title: "Redo", onClick: onRedo, disabled: !canRedo }
8122
+ ],
8123
+ [
8124
+ { id: "save", icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Save, { className: "size-4" }), title: "Save", onClick: onSave, loading: isSaving, indicator: hasUnsavedChanges }
8125
+ ]
8126
+ ];
8127
+ const allActionGroups = extraActions ? [...extraActions, ...defaultActionGroups] : defaultActionGroups;
8118
8128
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative h-full w-full", "data-testid": "workflow-builder", children: /* @__PURE__ */ jsxRuntime.jsx(
8119
8129
  WorkflowCanvas,
8120
8130
  {
@@ -8132,21 +8142,7 @@ function WorkflowBuilder({
8132
8142
  onVersionSelect
8133
8143
  }
8134
8144
  ),
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
- ),
8145
+ topRight: /* @__PURE__ */ jsxRuntime.jsx(WorkflowToolbarActions, { actionGroups: allActionGroups }),
8150
8146
  onConnect,
8151
8147
  onEdgesChange,
8152
8148
  onNodesChange