@genfeedai/workflow-ui 0.2.3 → 0.2.5

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 (45) hide show
  1. package/dist/canvas.d.ts +22 -22
  2. package/dist/canvas.mjs +16 -16
  3. package/dist/{chunk-XPZAHIWY.mjs → chunk-2FUPL67V.mjs} +1592 -1044
  4. package/dist/{chunk-HWVTD2LC.mjs → chunk-53XDE62A.mjs} +818 -623
  5. package/dist/{chunk-PCIWWD37.mjs → chunk-7LV4UAUS.mjs} +19 -19
  6. package/dist/{chunk-7SKSRSS7.mjs → chunk-B4EAAKYF.mjs} +16 -16
  7. package/dist/{chunk-ZJD5WMR3.mjs → chunk-C6MQBJFC.mjs} +45 -13
  8. package/dist/{chunk-7H3WJJYS.mjs → chunk-ESVULCFY.mjs} +12 -6
  9. package/dist/{chunk-GWBGK3KL.mjs → chunk-FWJIAW2E.mjs} +82 -47
  10. package/dist/{chunk-R727OFBR.mjs → chunk-GPYIIWD5.mjs} +404 -350
  11. package/dist/{chunk-OQREHJXK.mjs → chunk-IYFWAJBB.mjs} +208 -203
  12. package/dist/{chunk-N5NJZTK4.mjs → chunk-MGLAKMDP.mjs} +23 -21
  13. package/dist/{chunk-LT3ZJJL6.mjs → chunk-OJWVEEMM.mjs} +497 -399
  14. package/dist/{chunk-ZD2BADZO.mjs → chunk-ORVDYXDP.mjs} +221 -175
  15. package/dist/{chunk-CV4M7CNU.mjs → chunk-QQVHGJ2G.mjs} +149 -142
  16. package/dist/{chunk-6PSJTBNV.mjs → chunk-U4QPE4CY.mjs} +387 -347
  17. package/dist/{chunk-EFXQT23N.mjs → chunk-VVQ4CH77.mjs} +5 -5
  18. package/dist/{chunk-VRN3UWE5.mjs → chunk-XRC3O5GK.mjs} +73 -73
  19. package/dist/{chunk-FT33LFII.mjs → chunk-YUIK4AHM.mjs} +1 -1
  20. package/dist/{chunk-FMJPFB6W.mjs → chunk-ZSITTZ4S.mjs} +630 -569
  21. package/dist/hooks.d.ts +37 -37
  22. package/dist/hooks.mjs +10 -10
  23. package/dist/index.d.ts +26 -11
  24. package/dist/index.mjs +105 -19
  25. package/dist/lib.d.ts +203 -203
  26. package/dist/lib.mjs +228 -198
  27. package/dist/nodes.d.ts +2 -2
  28. package/dist/nodes.mjs +12 -12
  29. package/dist/panels.d.ts +2 -3
  30. package/dist/panels.mjs +3 -3
  31. package/dist/provider.d.ts +2 -2
  32. package/dist/provider.mjs +2 -2
  33. package/dist/stores.d.ts +5 -5
  34. package/dist/stores.mjs +5 -5
  35. package/dist/toolbar.d.ts +42 -24
  36. package/dist/toolbar.mjs +4 -4
  37. package/dist/ui.d.ts +2 -2
  38. package/dist/ui.mjs +2 -2
  39. package/dist/{useCommentNavigation-BakbiiIc.d.ts → useRequiredInputs-ByoIS-fT.d.ts} +160 -160
  40. package/dist/{promptLibraryStore-Dl3Q3cP6.d.ts → workflowStore-Bsz0nd5c.d.ts} +368 -368
  41. package/dist/workflowStore-N2F7WIG3.mjs +2 -0
  42. package/package.json +77 -75
  43. package/src/styles/workflow-ui.css +56 -19
  44. package/dist/workflowStore-UAAKOOIK.mjs +0 -2
  45. package/dist/{types-IEKYuYhu.d.ts → types-CRXJnajq.d.ts} +1 -1
@@ -1,10 +1,16 @@
1
1
  import { create } from 'zustand';
2
2
 
3
3
  var usePromptEditorStore = create((set, get) => ({
4
+ closeEditor: () => {
5
+ set({
6
+ isOpen: false,
7
+ nodeId: null,
8
+ prompt: ""
9
+ });
10
+ },
11
+ fontSize: 14,
4
12
  isOpen: false,
5
13
  nodeId: null,
6
- prompt: "",
7
- fontSize: 14,
8
14
  openEditor: (nodeId, prompt) => {
9
15
  set({
10
16
  isOpen: true,
@@ -12,19 +18,7 @@ var usePromptEditorStore = create((set, get) => ({
12
18
  prompt
13
19
  });
14
20
  },
15
- closeEditor: () => {
16
- set({
17
- isOpen: false,
18
- nodeId: null,
19
- prompt: ""
20
- });
21
- },
22
- setPrompt: (prompt) => {
23
- set({ prompt });
24
- },
25
- setFontSize: (fontSize) => {
26
- set({ fontSize });
27
- },
21
+ prompt: "",
28
22
  saveAndClose: () => {
29
23
  const { nodeId, prompt } = get();
30
24
  if (!nodeId) return null;
@@ -35,57 +29,133 @@ var usePromptEditorStore = create((set, get) => ({
35
29
  prompt: ""
36
30
  });
37
31
  return result;
32
+ },
33
+ setFontSize: (fontSize) => {
34
+ set({ fontSize });
35
+ },
36
+ setPrompt: (prompt) => {
37
+ set({ prompt });
38
38
  }
39
39
  }));
40
40
  var DEFAULT_TOOL_OPTIONS = {
41
+ fillColor: null,
42
+ fontSize: 16,
41
43
  strokeColor: "#ef4444",
42
44
  // Red
43
- strokeWidth: 3,
44
- fillColor: null,
45
- fontSize: 16
45
+ strokeWidth: 3
46
46
  };
47
47
  var shapeIdCounter = 0;
48
48
  function generateShapeId() {
49
49
  return `shape-${Date.now()}-${++shapeIdCounter}`;
50
50
  }
51
51
  var useAnnotationStore = create((set, get) => ({
52
- isOpen: false,
53
- nodeId: null,
54
- sourceImage: null,
55
- shapes: [],
56
- selectedShapeId: null,
52
+ addShape: (shape) => {
53
+ set((state) => {
54
+ const newShapes = [...state.shapes, shape];
55
+ const newHistory = [
56
+ ...state.history.slice(0, state.historyIndex + 1),
57
+ newShapes
58
+ ].slice(-50);
59
+ return {
60
+ history: newHistory,
61
+ historyIndex: newHistory.length - 1,
62
+ shapes: newShapes
63
+ };
64
+ });
65
+ },
66
+ cancelDrawing: () => {
67
+ set({ drawingShape: null, isDrawing: false });
68
+ },
69
+ canRedo: () => {
70
+ const { historyIndex, history } = get();
71
+ return historyIndex < history.length - 1;
72
+ },
73
+ canUndo: () => {
74
+ const { historyIndex } = get();
75
+ return historyIndex > 0;
76
+ },
77
+ clearShapes: () => {
78
+ set((state) => {
79
+ const newHistory = [
80
+ ...state.history.slice(0, state.historyIndex + 1),
81
+ []
82
+ ].slice(-50);
83
+ return {
84
+ history: newHistory,
85
+ historyIndex: newHistory.length - 1,
86
+ selectedShapeId: null,
87
+ shapes: []
88
+ };
89
+ });
90
+ },
91
+ closeAnnotation: () => {
92
+ set({
93
+ drawingShape: null,
94
+ history: [],
95
+ historyIndex: -1,
96
+ isDrawing: false,
97
+ isOpen: false,
98
+ nodeId: null,
99
+ selectedShapeId: null,
100
+ shapes: [],
101
+ sourceImage: null
102
+ });
103
+ },
57
104
  currentTool: "rectangle",
58
- toolOptions: DEFAULT_TOOL_OPTIONS,
105
+ deleteShape: (id) => {
106
+ set((state) => {
107
+ const newShapes = state.shapes.filter((s) => s.id !== id);
108
+ const newHistory = [
109
+ ...state.history.slice(0, state.historyIndex + 1),
110
+ newShapes
111
+ ].slice(-50);
112
+ return {
113
+ history: newHistory,
114
+ historyIndex: newHistory.length - 1,
115
+ selectedShapeId: state.selectedShapeId === id ? null : state.selectedShapeId,
116
+ shapes: newShapes
117
+ };
118
+ });
119
+ },
120
+ drawingShape: null,
121
+ finishDrawing: () => {
122
+ const { drawingShape, addShape } = get();
123
+ if (drawingShape && isValidShape(drawingShape)) {
124
+ addShape(drawingShape);
125
+ }
126
+ set({ drawingShape: null, isDrawing: false });
127
+ },
59
128
  history: [],
60
129
  historyIndex: -1,
61
130
  isDrawing: false,
62
- drawingShape: null,
131
+ isOpen: false,
132
+ nodeId: null,
63
133
  openAnnotation: (nodeId, image, existingShapes = []) => {
64
134
  set({
65
- isOpen: true,
66
- nodeId,
67
- sourceImage: image,
68
- shapes: existingShapes,
69
- selectedShapeId: null,
70
135
  currentTool: "rectangle",
71
- toolOptions: DEFAULT_TOOL_OPTIONS,
136
+ drawingShape: null,
72
137
  history: [existingShapes],
73
138
  historyIndex: 0,
74
139
  isDrawing: false,
75
- drawingShape: null
140
+ isOpen: true,
141
+ nodeId,
142
+ selectedShapeId: null,
143
+ shapes: existingShapes,
144
+ sourceImage: image,
145
+ toolOptions: DEFAULT_TOOL_OPTIONS
76
146
  });
77
147
  },
78
- closeAnnotation: () => {
79
- set({
80
- isOpen: false,
81
- nodeId: null,
82
- sourceImage: null,
83
- shapes: [],
84
- selectedShapeId: null,
85
- history: [],
86
- historyIndex: -1,
87
- isDrawing: false,
88
- drawingShape: null
148
+ redo: () => {
149
+ set((state) => {
150
+ if (state.historyIndex < state.history.length - 1) {
151
+ const newIndex = state.historyIndex + 1;
152
+ return {
153
+ historyIndex: newIndex,
154
+ selectedShapeId: null,
155
+ shapes: state.history[newIndex]
156
+ };
157
+ }
158
+ return state;
89
159
  });
90
160
  },
91
161
  saveAndClose: () => {
@@ -93,76 +163,22 @@ var useAnnotationStore = create((set, get) => ({
93
163
  if (!nodeId) return null;
94
164
  const result = { nodeId, shapes: [...shapes] };
95
165
  set({
96
- isOpen: false,
97
- nodeId: null,
98
- sourceImage: null,
99
- shapes: [],
100
- selectedShapeId: null,
166
+ drawingShape: null,
101
167
  history: [],
102
168
  historyIndex: -1,
103
169
  isDrawing: false,
104
- drawingShape: null
170
+ isOpen: false,
171
+ nodeId: null,
172
+ selectedShapeId: null,
173
+ shapes: [],
174
+ sourceImage: null
105
175
  });
106
176
  return result;
107
177
  },
108
- addShape: (shape) => {
109
- set((state) => {
110
- const newShapes = [...state.shapes, shape];
111
- const newHistory = [...state.history.slice(0, state.historyIndex + 1), newShapes].slice(
112
- -50
113
- );
114
- return {
115
- shapes: newShapes,
116
- history: newHistory,
117
- historyIndex: newHistory.length - 1
118
- };
119
- });
120
- },
121
- updateShape: (id, updates) => {
122
- set((state) => {
123
- const newShapes = state.shapes.map(
124
- (s) => s.id === id ? { ...s, ...updates } : s
125
- );
126
- const newHistory = [...state.history.slice(0, state.historyIndex + 1), newShapes].slice(
127
- -50
128
- );
129
- return {
130
- shapes: newShapes,
131
- history: newHistory,
132
- historyIndex: newHistory.length - 1
133
- };
134
- });
135
- },
136
- deleteShape: (id) => {
137
- set((state) => {
138
- const newShapes = state.shapes.filter((s) => s.id !== id);
139
- const newHistory = [...state.history.slice(0, state.historyIndex + 1), newShapes].slice(
140
- -50
141
- );
142
- return {
143
- shapes: newShapes,
144
- selectedShapeId: state.selectedShapeId === id ? null : state.selectedShapeId,
145
- history: newHistory,
146
- historyIndex: newHistory.length - 1
147
- };
148
- });
149
- },
178
+ selectedShapeId: null,
150
179
  selectShape: (id) => {
151
180
  set({ selectedShapeId: id });
152
181
  },
153
- clearShapes: () => {
154
- set((state) => {
155
- const newHistory = [...state.history.slice(0, state.historyIndex + 1), []].slice(
156
- -50
157
- );
158
- return {
159
- shapes: [],
160
- selectedShapeId: null,
161
- history: newHistory,
162
- historyIndex: newHistory.length - 1
163
- };
164
- });
165
- },
166
182
  setTool: (tool) => {
167
183
  set({ currentTool: tool, selectedShapeId: null });
168
184
  },
@@ -171,63 +187,51 @@ var useAnnotationStore = create((set, get) => ({
171
187
  toolOptions: { ...state.toolOptions, ...options }
172
188
  }));
173
189
  },
190
+ shapes: [],
191
+ sourceImage: null,
174
192
  startDrawing: (shape) => {
175
193
  set({
176
- isDrawing: true,
177
194
  drawingShape: {
178
195
  id: generateShapeId(),
179
196
  ...shape
180
- }
197
+ },
198
+ isDrawing: true
181
199
  });
182
200
  },
183
- updateDrawing: (updates) => {
184
- set((state) => ({
185
- drawingShape: state.drawingShape ? { ...state.drawingShape, ...updates } : null
186
- }));
187
- },
188
- finishDrawing: () => {
189
- const { drawingShape, addShape } = get();
190
- if (drawingShape && isValidShape(drawingShape)) {
191
- addShape(drawingShape);
192
- }
193
- set({ isDrawing: false, drawingShape: null });
194
- },
195
- cancelDrawing: () => {
196
- set({ isDrawing: false, drawingShape: null });
197
- },
201
+ toolOptions: DEFAULT_TOOL_OPTIONS,
198
202
  undo: () => {
199
203
  set((state) => {
200
204
  if (state.historyIndex > 0) {
201
205
  const newIndex = state.historyIndex - 1;
202
206
  return {
203
- shapes: state.history[newIndex],
204
207
  historyIndex: newIndex,
205
- selectedShapeId: null
208
+ selectedShapeId: null,
209
+ shapes: state.history[newIndex]
206
210
  };
207
211
  }
208
212
  return state;
209
213
  });
210
214
  },
211
- redo: () => {
215
+ updateDrawing: (updates) => {
216
+ set((state) => ({
217
+ drawingShape: state.drawingShape ? { ...state.drawingShape, ...updates } : null
218
+ }));
219
+ },
220
+ updateShape: (id, updates) => {
212
221
  set((state) => {
213
- if (state.historyIndex < state.history.length - 1) {
214
- const newIndex = state.historyIndex + 1;
215
- return {
216
- shapes: state.history[newIndex],
217
- historyIndex: newIndex,
218
- selectedShapeId: null
219
- };
220
- }
221
- return state;
222
+ const newShapes = state.shapes.map(
223
+ (s) => s.id === id ? { ...s, ...updates } : s
224
+ );
225
+ const newHistory = [
226
+ ...state.history.slice(0, state.historyIndex + 1),
227
+ newShapes
228
+ ].slice(-50);
229
+ return {
230
+ history: newHistory,
231
+ historyIndex: newHistory.length - 1,
232
+ shapes: newShapes
233
+ };
222
234
  });
223
- },
224
- canUndo: () => {
225
- const { historyIndex } = get();
226
- return historyIndex > 0;
227
- },
228
- canRedo: () => {
229
- const { historyIndex, history } = get();
230
- return historyIndex < history.length - 1;
231
235
  }
232
236
  }));
233
237
  function isValidShape(shape) {
@@ -238,7 +242,10 @@ function isValidShape(shape) {
238
242
  case "circle":
239
243
  return typeof shape.x === "number" && typeof shape.y === "number" && typeof shape.radius === "number" && shape.radius > 5;
240
244
  case "arrow":
241
- return Array.isArray(shape.points) && shape.points.length >= 4 && Math.hypot(shape.points[2] - shape.points[0], shape.points[3] - shape.points[1]) > 10;
245
+ return Array.isArray(shape.points) && shape.points.length >= 4 && Math.hypot(
246
+ shape.points[2] - shape.points[0],
247
+ shape.points[3] - shape.points[1]
248
+ ) > 10;
242
249
  case "freehand":
243
250
  return Array.isArray(shape.points) && shape.points.length >= 4;
244
251
  case "text":