@object-ui/plugin-workflow 0.1.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 ObjectQL
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,2 @@
1
+ export * from './src/index'
2
+ export {}
package/dist/index.js ADDED
@@ -0,0 +1,758 @@
1
+ import { ComponentRegistry as ie } from "@object-ui/core";
2
+ import ge, { useState as $, useMemo as je, useCallback as P } from "react";
3
+ import { Input as C, Badge as N, Button as R, Card as S, CardHeader as Y, CardTitle as W, CardContent as A, Label as b } from "@object-ui/components";
4
+ import { Save as ve, Play as ce, GitBranch as de, Trash2 as ae, ArrowRight as ue, Plus as be, Settings as Ne, Code as ye, Bell as we, Clock as me, Users as Ee, Circle as ke, CheckCircle as Re, MessageSquare as _e, Check as Te, X as Ce, RefreshCw as Se, User as Ae } from "lucide-react";
5
+ var z = { exports: {} }, I = {};
6
+ var le;
7
+ function Oe() {
8
+ if (le) return I;
9
+ le = 1;
10
+ var f = /* @__PURE__ */ Symbol.for("react.transitional.element"), y = /* @__PURE__ */ Symbol.for("react.fragment");
11
+ function l(j, a, d) {
12
+ var h = null;
13
+ if (d !== void 0 && (h = "" + d), a.key !== void 0 && (h = "" + a.key), "key" in a) {
14
+ d = {};
15
+ for (var g in a)
16
+ g !== "key" && (d[g] = a[g]);
17
+ } else d = a;
18
+ return a = d.ref, {
19
+ $$typeof: f,
20
+ type: j,
21
+ key: h,
22
+ ref: a !== void 0 ? a : null,
23
+ props: d
24
+ };
25
+ }
26
+ return I.Fragment = y, I.jsx = l, I.jsxs = l, I;
27
+ }
28
+ var D = {};
29
+ var ne;
30
+ function Pe() {
31
+ return ne || (ne = 1, process.env.NODE_ENV !== "production" && (function() {
32
+ function f(s) {
33
+ if (s == null) return null;
34
+ if (typeof s == "function")
35
+ return s.$$typeof === pe ? null : s.displayName || s.name || null;
36
+ if (typeof s == "string") return s;
37
+ switch (s) {
38
+ case O:
39
+ return "Fragment";
40
+ case F:
41
+ return "Profiler";
42
+ case V:
43
+ return "StrictMode";
44
+ case x:
45
+ return "Suspense";
46
+ case p:
47
+ return "SuspenseList";
48
+ case xe:
49
+ return "Activity";
50
+ }
51
+ if (typeof s == "object")
52
+ switch (typeof s.tag == "number" && console.error(
53
+ "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
54
+ ), s.$$typeof) {
55
+ case L:
56
+ return "Portal";
57
+ case r:
58
+ return s.displayName || "Context";
59
+ case q:
60
+ return (s._context.displayName || "Context") + ".Consumer";
61
+ case n:
62
+ var t = s.render;
63
+ return s = s.displayName, s || (s = t.displayName || t.name || "", s = s !== "" ? "ForwardRef(" + s + ")" : "ForwardRef"), s;
64
+ case M:
65
+ return t = s.displayName || null, t !== null ? t : f(s.type) || "Memo";
66
+ case B:
67
+ t = s._payload, s = s._init;
68
+ try {
69
+ return f(s(t));
70
+ } catch {
71
+ }
72
+ }
73
+ return null;
74
+ }
75
+ function y(s) {
76
+ return "" + s;
77
+ }
78
+ function l(s) {
79
+ try {
80
+ y(s);
81
+ var t = !1;
82
+ } catch {
83
+ t = !0;
84
+ }
85
+ if (t) {
86
+ t = console;
87
+ var c = t.error, u = typeof Symbol == "function" && Symbol.toStringTag && s[Symbol.toStringTag] || s.constructor.name || "Object";
88
+ return c.call(
89
+ t,
90
+ "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
91
+ u
92
+ ), y(s);
93
+ }
94
+ }
95
+ function j(s) {
96
+ if (s === O) return "<>";
97
+ if (typeof s == "object" && s !== null && s.$$typeof === B)
98
+ return "<...>";
99
+ try {
100
+ var t = f(s);
101
+ return t ? "<" + t + ">" : "<...>";
102
+ } catch {
103
+ return "<...>";
104
+ }
105
+ }
106
+ function a() {
107
+ var s = G.A;
108
+ return s === null ? null : s.getOwner();
109
+ }
110
+ function d() {
111
+ return Error("react-stack-top-frame");
112
+ }
113
+ function h(s) {
114
+ if (Z.call(s, "key")) {
115
+ var t = Object.getOwnPropertyDescriptor(s, "key").get;
116
+ if (t && t.isReactWarning) return !1;
117
+ }
118
+ return s.key !== void 0;
119
+ }
120
+ function g(s, t) {
121
+ function c() {
122
+ K || (K = !0, console.error(
123
+ "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
124
+ t
125
+ ));
126
+ }
127
+ c.isReactWarning = !0, Object.defineProperty(s, "key", {
128
+ get: c,
129
+ configurable: !0
130
+ });
131
+ }
132
+ function _() {
133
+ var s = f(this.type);
134
+ return ee[s] || (ee[s] = !0, console.error(
135
+ "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
136
+ )), s = this.props.ref, s !== void 0 ? s : null;
137
+ }
138
+ function w(s, t, c, u, U, J) {
139
+ var m = c.ref;
140
+ return s = {
141
+ $$typeof: k,
142
+ type: s,
143
+ key: t,
144
+ props: c,
145
+ _owner: u
146
+ }, (m !== void 0 ? m : null) !== null ? Object.defineProperty(s, "ref", {
147
+ enumerable: !1,
148
+ get: _
149
+ }) : Object.defineProperty(s, "ref", { enumerable: !1, value: null }), s._store = {}, Object.defineProperty(s._store, "validated", {
150
+ configurable: !1,
151
+ enumerable: !1,
152
+ writable: !0,
153
+ value: 0
154
+ }), Object.defineProperty(s, "_debugInfo", {
155
+ configurable: !1,
156
+ enumerable: !1,
157
+ writable: !0,
158
+ value: null
159
+ }), Object.defineProperty(s, "_debugStack", {
160
+ configurable: !1,
161
+ enumerable: !1,
162
+ writable: !0,
163
+ value: U
164
+ }), Object.defineProperty(s, "_debugTask", {
165
+ configurable: !1,
166
+ enumerable: !1,
167
+ writable: !0,
168
+ value: J
169
+ }), Object.freeze && (Object.freeze(s.props), Object.freeze(s)), s;
170
+ }
171
+ function o(s, t, c, u, U, J) {
172
+ var m = t.children;
173
+ if (m !== void 0)
174
+ if (u)
175
+ if (fe(m)) {
176
+ for (u = 0; u < m.length; u++)
177
+ E(m[u]);
178
+ Object.freeze && Object.freeze(m);
179
+ } else
180
+ console.error(
181
+ "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
182
+ );
183
+ else E(m);
184
+ if (Z.call(t, "key")) {
185
+ m = f(s);
186
+ var T = Object.keys(t).filter(function(he) {
187
+ return he !== "key";
188
+ });
189
+ u = 0 < T.length ? "{key: someKey, " + T.join(": ..., ") + ": ...}" : "{key: someKey}", te[m + u] || (T = 0 < T.length ? "{" + T.join(": ..., ") + ": ...}" : "{}", console.error(
190
+ `A props object containing a "key" prop is being spread into JSX:
191
+ let props = %s;
192
+ <%s {...props} />
193
+ React keys must be passed directly to JSX without using spread:
194
+ let props = %s;
195
+ <%s key={someKey} {...props} />`,
196
+ u,
197
+ m,
198
+ T,
199
+ m
200
+ ), te[m + u] = !0);
201
+ }
202
+ if (m = null, c !== void 0 && (l(c), m = "" + c), h(t) && (l(t.key), m = "" + t.key), "key" in t) {
203
+ c = {};
204
+ for (var X in t)
205
+ X !== "key" && (c[X] = t[X]);
206
+ } else c = t;
207
+ return m && g(
208
+ c,
209
+ typeof s == "function" ? s.displayName || s.name || "Unknown" : s
210
+ ), w(
211
+ s,
212
+ m,
213
+ c,
214
+ a(),
215
+ U,
216
+ J
217
+ );
218
+ }
219
+ function E(s) {
220
+ v(s) ? s._store && (s._store.validated = 1) : typeof s == "object" && s !== null && s.$$typeof === B && (s._payload.status === "fulfilled" ? v(s._payload.value) && s._payload.value._store && (s._payload.value._store.validated = 1) : s._store && (s._store.validated = 1));
221
+ }
222
+ function v(s) {
223
+ return typeof s == "object" && s !== null && s.$$typeof === k;
224
+ }
225
+ var i = ge, k = /* @__PURE__ */ Symbol.for("react.transitional.element"), L = /* @__PURE__ */ Symbol.for("react.portal"), O = /* @__PURE__ */ Symbol.for("react.fragment"), V = /* @__PURE__ */ Symbol.for("react.strict_mode"), F = /* @__PURE__ */ Symbol.for("react.profiler"), q = /* @__PURE__ */ Symbol.for("react.consumer"), r = /* @__PURE__ */ Symbol.for("react.context"), n = /* @__PURE__ */ Symbol.for("react.forward_ref"), x = /* @__PURE__ */ Symbol.for("react.suspense"), p = /* @__PURE__ */ Symbol.for("react.suspense_list"), M = /* @__PURE__ */ Symbol.for("react.memo"), B = /* @__PURE__ */ Symbol.for("react.lazy"), xe = /* @__PURE__ */ Symbol.for("react.activity"), pe = /* @__PURE__ */ Symbol.for("react.client.reference"), G = i.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, Z = Object.prototype.hasOwnProperty, fe = Array.isArray, H = console.createTask ? console.createTask : function() {
226
+ return null;
227
+ };
228
+ i = {
229
+ react_stack_bottom_frame: function(s) {
230
+ return s();
231
+ }
232
+ };
233
+ var K, ee = {}, se = i.react_stack_bottom_frame.bind(
234
+ i,
235
+ d
236
+ )(), re = H(j(d)), te = {};
237
+ D.Fragment = O, D.jsx = function(s, t, c) {
238
+ var u = 1e4 > G.recentlyCreatedOwnerStacks++;
239
+ return o(
240
+ s,
241
+ t,
242
+ c,
243
+ !1,
244
+ u ? Error("react-stack-top-frame") : se,
245
+ u ? H(j(s)) : re
246
+ );
247
+ }, D.jsxs = function(s, t, c) {
248
+ var u = 1e4 > G.recentlyCreatedOwnerStacks++;
249
+ return o(
250
+ s,
251
+ t,
252
+ c,
253
+ !0,
254
+ u ? Error("react-stack-top-frame") : se,
255
+ u ? H(j(s)) : re
256
+ );
257
+ };
258
+ })()), D;
259
+ }
260
+ var oe;
261
+ function Ie() {
262
+ return oe || (oe = 1, process.env.NODE_ENV === "production" ? z.exports = Oe() : z.exports = Pe()), z.exports;
263
+ }
264
+ var e = Ie();
265
+ const Q = {
266
+ start: /* @__PURE__ */ e.jsx(ce, { className: "h-4 w-4 text-green-500" }),
267
+ end: /* @__PURE__ */ e.jsx(Re, { className: "h-4 w-4 text-red-500" }),
268
+ task: /* @__PURE__ */ e.jsx(ke, { className: "h-4 w-4 text-blue-500" }),
269
+ approval: /* @__PURE__ */ e.jsx(Ee, { className: "h-4 w-4 text-purple-500" }),
270
+ condition: /* @__PURE__ */ e.jsx(de, { className: "h-4 w-4 text-orange-500" }),
271
+ parallel: /* @__PURE__ */ e.jsx(ue, { className: "h-4 w-4 text-teal-500" }),
272
+ delay: /* @__PURE__ */ e.jsx(me, { className: "h-4 w-4 text-gray-500" }),
273
+ notification: /* @__PURE__ */ e.jsx(we, { className: "h-4 w-4 text-yellow-500" }),
274
+ script: /* @__PURE__ */ e.jsx(ye, { className: "h-4 w-4 text-indigo-500" })
275
+ }, De = {
276
+ start: "border-green-300 bg-green-50",
277
+ end: "border-red-300 bg-red-50",
278
+ task: "border-blue-300 bg-blue-50",
279
+ approval: "border-purple-300 bg-purple-50",
280
+ condition: "border-orange-300 bg-orange-50",
281
+ parallel: "border-teal-300 bg-teal-50",
282
+ delay: "border-gray-300 bg-gray-50",
283
+ notification: "border-yellow-300 bg-yellow-50",
284
+ script: "border-indigo-300 bg-indigo-50"
285
+ }, $e = {
286
+ draft: { variant: "secondary", label: "Draft" },
287
+ active: { variant: "default", label: "Active" },
288
+ paused: { variant: "outline", label: "Paused" },
289
+ completed: { variant: "default", label: "Completed" },
290
+ cancelled: { variant: "destructive", label: "Cancelled" }
291
+ }, Ye = ({ schema: f }) => {
292
+ const {
293
+ workflow: y,
294
+ readOnly: l = !1,
295
+ showToolbar: j = !0
296
+ } = f, [a, d] = $(y || {
297
+ type: "workflow",
298
+ title: "New Workflow",
299
+ status: "draft",
300
+ nodes: [
301
+ { id: "start-1", type: "start", label: "Start", position: { x: 100, y: 100 } },
302
+ { id: "end-1", type: "end", label: "End", position: { x: 100, y: 400 } }
303
+ ],
304
+ edges: [],
305
+ variables: []
306
+ }), [h, g] = $(null), [_, w] = $(null), o = je(
307
+ () => a.nodes.find((r) => r.id === h),
308
+ [a.nodes, h]
309
+ ), E = P((r) => {
310
+ if (l) return;
311
+ const n = `${r}-${Date.now()}`, x = {
312
+ id: n,
313
+ type: r,
314
+ label: `New ${r.charAt(0).toUpperCase() + r.slice(1)}`,
315
+ position: { x: 200, y: (a.nodes.length + 1) * 80 }
316
+ };
317
+ d((p) => ({
318
+ ...p,
319
+ nodes: [...p.nodes, x]
320
+ })), g(n);
321
+ }, [l, a.nodes.length]), v = P((r, n) => {
322
+ l || d((x) => ({
323
+ ...x,
324
+ nodes: x.nodes.map((p) => p.id === r ? { ...p, ...n } : p)
325
+ }));
326
+ }, [l]), i = P((r) => {
327
+ l || (d((n) => ({
328
+ ...n,
329
+ nodes: n.nodes.filter((x) => x.id !== r),
330
+ edges: n.edges.filter((x) => x.source !== r && x.target !== r)
331
+ })), h === r && g(null));
332
+ }, [l, h]), k = P((r, n) => {
333
+ if (l) return;
334
+ const p = { id: `edge-${Date.now()}`, source: r, target: n };
335
+ d((M) => ({
336
+ ...M,
337
+ edges: [...M.edges, p]
338
+ }));
339
+ }, [l]), L = P((r) => {
340
+ l || (d((n) => ({
341
+ ...n,
342
+ edges: n.edges.filter((x) => x.id !== r)
343
+ })), _ === r && w(null));
344
+ }, [l, _]), O = () => {
345
+ console.log("Saving workflow:", a), f.onSave;
346
+ }, V = () => {
347
+ d((r) => ({ ...r, status: "active" })), console.log("Publishing workflow"), f.onPublish;
348
+ }, F = $e[a.status || "draft"], q = ["task", "approval", "condition", "parallel", "delay", "notification", "script"];
349
+ return /* @__PURE__ */ e.jsxs("div", { className: "space-y-4", children: [
350
+ j && /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between gap-2 p-4 bg-card rounded-lg border", children: [
351
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-3", children: [
352
+ /* @__PURE__ */ e.jsx("div", { children: /* @__PURE__ */ e.jsx(
353
+ C,
354
+ {
355
+ value: a.title || "",
356
+ onChange: (r) => d((n) => ({ ...n, title: r.target.value })),
357
+ className: "text-lg font-semibold border-none p-0 h-auto focus-visible:ring-0",
358
+ readOnly: l,
359
+ placeholder: "Workflow Title"
360
+ }
361
+ ) }),
362
+ /* @__PURE__ */ e.jsx(N, { variant: F.variant, children: F.label })
363
+ ] }),
364
+ !l && /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2", children: [
365
+ /* @__PURE__ */ e.jsxs(R, { variant: "outline", size: "sm", onClick: O, children: [
366
+ /* @__PURE__ */ e.jsx(ve, { className: "h-4 w-4 mr-2" }),
367
+ "Save"
368
+ ] }),
369
+ /* @__PURE__ */ e.jsxs(R, { size: "sm", onClick: V, disabled: a.status === "active", children: [
370
+ /* @__PURE__ */ e.jsx(ce, { className: "h-4 w-4 mr-2" }),
371
+ "Publish"
372
+ ] })
373
+ ] })
374
+ ] }),
375
+ /* @__PURE__ */ e.jsxs("div", { className: "grid grid-cols-1 lg:grid-cols-4 gap-4", children: [
376
+ !l && /* @__PURE__ */ e.jsxs(S, { className: "lg:col-span-1", children: [
377
+ /* @__PURE__ */ e.jsx(Y, { children: /* @__PURE__ */ e.jsx(W, { className: "text-sm", children: "Add Node" }) }),
378
+ /* @__PURE__ */ e.jsx(A, { className: "space-y-2", children: q.map((r) => /* @__PURE__ */ e.jsxs(
379
+ "button",
380
+ {
381
+ onClick: () => E(r),
382
+ className: "w-full flex items-center gap-2 p-2 rounded-md border hover:bg-muted/50 transition-colors text-sm",
383
+ children: [
384
+ Q[r],
385
+ /* @__PURE__ */ e.jsx("span", { className: "capitalize", children: r })
386
+ ]
387
+ },
388
+ r
389
+ )) })
390
+ ] }),
391
+ /* @__PURE__ */ e.jsxs(S, { className: l ? "lg:col-span-3" : "lg:col-span-2", children: [
392
+ /* @__PURE__ */ e.jsx(Y, { children: /* @__PURE__ */ e.jsxs(W, { className: "text-sm flex items-center gap-2", children: [
393
+ /* @__PURE__ */ e.jsx(de, { className: "h-4 w-4" }),
394
+ "Workflow Flow"
395
+ ] }) }),
396
+ /* @__PURE__ */ e.jsx(A, { children: /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
397
+ a.nodes.map((r) => /* @__PURE__ */ e.jsxs(
398
+ "div",
399
+ {
400
+ onClick: () => {
401
+ g(r.id), w(null);
402
+ },
403
+ className: `flex items-center justify-between p-3 rounded-lg border-2 cursor-pointer transition-all ${De[r.type]} ${h === r.id ? "ring-2 ring-primary shadow-md" : "hover:shadow-sm"}`,
404
+ children: [
405
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2", children: [
406
+ Q[r.type],
407
+ /* @__PURE__ */ e.jsx("span", { className: "font-medium text-sm", children: r.label }),
408
+ /* @__PURE__ */ e.jsxs("span", { className: "text-xs text-muted-foreground capitalize", children: [
409
+ "(",
410
+ r.type,
411
+ ")"
412
+ ] })
413
+ ] }),
414
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-1", children: [
415
+ a.edges.filter((n) => n.source === r.id).length > 0 && /* @__PURE__ */ e.jsxs(N, { variant: "outline", className: "text-xs", children: [
416
+ a.edges.filter((n) => n.source === r.id).length,
417
+ " out"
418
+ ] }),
419
+ !l && r.type !== "start" && r.type !== "end" && /* @__PURE__ */ e.jsx(
420
+ R,
421
+ {
422
+ size: "sm",
423
+ variant: "ghost",
424
+ className: "h-6 w-6 p-0 text-red-500 hover:text-red-700",
425
+ onClick: (n) => {
426
+ n.stopPropagation(), i(r.id);
427
+ },
428
+ children: /* @__PURE__ */ e.jsx(ae, { className: "h-3 w-3" })
429
+ }
430
+ )
431
+ ] })
432
+ ]
433
+ },
434
+ r.id
435
+ )),
436
+ a.edges.length > 0 && /* @__PURE__ */ e.jsxs("div", { className: "mt-4 pt-4 border-t", children: [
437
+ /* @__PURE__ */ e.jsx(b, { className: "text-xs text-muted-foreground mb-2 block", children: "Connections" }),
438
+ a.edges.map((r) => {
439
+ const n = a.nodes.find((p) => p.id === r.source), x = a.nodes.find((p) => p.id === r.target);
440
+ return /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2 p-2 text-sm", children: [
441
+ /* @__PURE__ */ e.jsx("span", { children: n?.label || r.source }),
442
+ /* @__PURE__ */ e.jsx(ue, { className: "h-3 w-3 text-muted-foreground" }),
443
+ /* @__PURE__ */ e.jsx("span", { children: x?.label || r.target }),
444
+ r.label && /* @__PURE__ */ e.jsx(N, { variant: "outline", className: "text-xs", children: r.label }),
445
+ !l && /* @__PURE__ */ e.jsx(
446
+ R,
447
+ {
448
+ size: "sm",
449
+ variant: "ghost",
450
+ className: "h-5 w-5 p-0 ml-auto text-red-500",
451
+ onClick: () => L(r.id),
452
+ children: /* @__PURE__ */ e.jsx(ae, { className: "h-3 w-3" })
453
+ }
454
+ )
455
+ ] }, r.id);
456
+ })
457
+ ] }),
458
+ !l && a.nodes.length >= 2 && /* @__PURE__ */ e.jsxs("div", { className: "mt-4 pt-4 border-t", children: [
459
+ /* @__PURE__ */ e.jsx(b, { className: "text-xs text-muted-foreground mb-2 block", children: "Quick Connect" }),
460
+ /* @__PURE__ */ e.jsxs("div", { className: "grid grid-cols-2 gap-2", children: [
461
+ /* @__PURE__ */ e.jsxs(
462
+ "select",
463
+ {
464
+ id: "edge-source",
465
+ className: "border rounded-md p-1.5 text-sm bg-background",
466
+ children: [
467
+ /* @__PURE__ */ e.jsx("option", { value: "", children: "From..." }),
468
+ a.nodes.filter((r) => r.type !== "end").map((r) => /* @__PURE__ */ e.jsx("option", { value: r.id, children: r.label }, r.id))
469
+ ]
470
+ }
471
+ ),
472
+ /* @__PURE__ */ e.jsxs(
473
+ "select",
474
+ {
475
+ id: "edge-target",
476
+ className: "border rounded-md p-1.5 text-sm bg-background",
477
+ children: [
478
+ /* @__PURE__ */ e.jsx("option", { value: "", children: "To..." }),
479
+ a.nodes.filter((r) => r.type !== "start").map((r) => /* @__PURE__ */ e.jsx("option", { value: r.id, children: r.label }, r.id))
480
+ ]
481
+ }
482
+ )
483
+ ] }),
484
+ /* @__PURE__ */ e.jsxs(
485
+ R,
486
+ {
487
+ size: "sm",
488
+ variant: "outline",
489
+ className: "mt-2 w-full",
490
+ onClick: () => {
491
+ const r = document.getElementById("edge-source")?.value, n = document.getElementById("edge-target")?.value;
492
+ r && n && r !== n && k(r, n);
493
+ },
494
+ children: [
495
+ /* @__PURE__ */ e.jsx(be, { className: "h-3 w-3 mr-1" }),
496
+ "Connect"
497
+ ]
498
+ }
499
+ )
500
+ ] })
501
+ ] }) })
502
+ ] }),
503
+ /* @__PURE__ */ e.jsxs(S, { className: "lg:col-span-1", children: [
504
+ /* @__PURE__ */ e.jsx(Y, { children: /* @__PURE__ */ e.jsxs(W, { className: "text-sm flex items-center gap-2", children: [
505
+ /* @__PURE__ */ e.jsx(Ne, { className: "h-4 w-4" }),
506
+ "Properties"
507
+ ] }) }),
508
+ /* @__PURE__ */ e.jsx(A, { children: o ? /* @__PURE__ */ e.jsxs("div", { className: "space-y-3", children: [
509
+ /* @__PURE__ */ e.jsxs("div", { className: "space-y-1", children: [
510
+ /* @__PURE__ */ e.jsx(b, { className: "text-xs", children: "Label" }),
511
+ /* @__PURE__ */ e.jsx(
512
+ C,
513
+ {
514
+ value: o.label,
515
+ onChange: (r) => v(o.id, { label: r.target.value }),
516
+ className: "h-8 text-sm",
517
+ readOnly: l
518
+ }
519
+ )
520
+ ] }),
521
+ /* @__PURE__ */ e.jsxs("div", { className: "space-y-1", children: [
522
+ /* @__PURE__ */ e.jsx(b, { className: "text-xs", children: "Type" }),
523
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2 p-2 rounded-md bg-muted text-sm", children: [
524
+ Q[o.type],
525
+ /* @__PURE__ */ e.jsx("span", { className: "capitalize", children: o.type })
526
+ ] })
527
+ ] }),
528
+ o.description !== void 0 && /* @__PURE__ */ e.jsxs("div", { className: "space-y-1", children: [
529
+ /* @__PURE__ */ e.jsx(b, { className: "text-xs", children: "Description" }),
530
+ /* @__PURE__ */ e.jsx(
531
+ C,
532
+ {
533
+ value: o.description || "",
534
+ onChange: (r) => v(o.id, { description: r.target.value }),
535
+ className: "h-8 text-sm",
536
+ readOnly: l
537
+ }
538
+ )
539
+ ] }),
540
+ (o.type === "approval" || o.type === "task") && /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
541
+ /* @__PURE__ */ e.jsxs("div", { className: "space-y-1", children: [
542
+ /* @__PURE__ */ e.jsx(b, { className: "text-xs", children: "Assignee" }),
543
+ /* @__PURE__ */ e.jsx(
544
+ C,
545
+ {
546
+ value: o.assignee || "",
547
+ onChange: (r) => v(o.id, { assignee: r.target.value }),
548
+ className: "h-8 text-sm",
549
+ placeholder: "User, role, or expression",
550
+ readOnly: l
551
+ }
552
+ )
553
+ ] }),
554
+ /* @__PURE__ */ e.jsxs("div", { className: "space-y-1", children: [
555
+ /* @__PURE__ */ e.jsx(b, { className: "text-xs", children: "Assignee Type" }),
556
+ /* @__PURE__ */ e.jsxs(
557
+ "select",
558
+ {
559
+ className: "w-full border rounded-md h-8 text-sm px-2 bg-background",
560
+ value: o.assigneeType || "user",
561
+ onChange: (r) => v(o.id, { assigneeType: r.target.value }),
562
+ disabled: l,
563
+ children: [
564
+ /* @__PURE__ */ e.jsx("option", { value: "user", children: "User" }),
565
+ /* @__PURE__ */ e.jsx("option", { value: "role", children: "Role" }),
566
+ /* @__PURE__ */ e.jsx("option", { value: "group", children: "Group" }),
567
+ /* @__PURE__ */ e.jsx("option", { value: "expression", children: "Expression" })
568
+ ]
569
+ }
570
+ )
571
+ ] })
572
+ ] }),
573
+ o.type === "delay" && /* @__PURE__ */ e.jsxs("div", { className: "space-y-1", children: [
574
+ /* @__PURE__ */ e.jsx(b, { className: "text-xs", children: "Timeout (minutes)" }),
575
+ /* @__PURE__ */ e.jsx(
576
+ C,
577
+ {
578
+ type: "number",
579
+ value: o.timeout || 60,
580
+ onChange: (r) => v(o.id, { timeout: Number(r.target.value) }),
581
+ className: "h-8 text-sm",
582
+ readOnly: l
583
+ }
584
+ )
585
+ ] }),
586
+ /* @__PURE__ */ e.jsxs("div", { className: "text-xs text-muted-foreground mt-2", children: [
587
+ "ID: ",
588
+ o.id
589
+ ] })
590
+ ] }) : /* @__PURE__ */ e.jsx("div", { className: "text-sm text-muted-foreground text-center py-8", children: "Select a node to edit its properties" }) })
591
+ ] })
592
+ ] })
593
+ ] });
594
+ }, We = ({ schema: f }) => {
595
+ const {
596
+ currentNodeId: y,
597
+ approvalRule: l,
598
+ history: j = [],
599
+ data: a,
600
+ showHistory: d = !0,
601
+ showComments: h = !0
602
+ } = f, [g, _] = $(""), [w, o] = $(!1), E = (i) => {
603
+ o(!0), console.log(`Approval action: ${i}`, {
604
+ currentNodeId: y,
605
+ comment: g,
606
+ data: a
607
+ }), setTimeout(() => {
608
+ o(!1), _("");
609
+ }, 500);
610
+ }, v = (i) => {
611
+ switch (i) {
612
+ case "approve":
613
+ case "approved":
614
+ return /* @__PURE__ */ e.jsx(N, { variant: "default", className: "bg-green-500", children: "Approved" });
615
+ case "reject":
616
+ case "rejected":
617
+ return /* @__PURE__ */ e.jsx(N, { variant: "destructive", children: "Rejected" });
618
+ case "reassign":
619
+ case "reassigned":
620
+ return /* @__PURE__ */ e.jsx(N, { variant: "secondary", children: "Reassigned" });
621
+ case "comment":
622
+ return /* @__PURE__ */ e.jsx(N, { variant: "outline", children: "Comment" });
623
+ case "escalate":
624
+ case "escalated":
625
+ return /* @__PURE__ */ e.jsx(N, { variant: "secondary", className: "bg-orange-500 text-white", children: "Escalated" });
626
+ default:
627
+ return /* @__PURE__ */ e.jsx(N, { variant: "outline", children: i });
628
+ }
629
+ };
630
+ return /* @__PURE__ */ e.jsxs("div", { className: "space-y-4", children: [
631
+ /* @__PURE__ */ e.jsxs(S, { children: [
632
+ /* @__PURE__ */ e.jsx(Y, { children: /* @__PURE__ */ e.jsxs(W, { className: "flex items-center gap-2", children: [
633
+ /* @__PURE__ */ e.jsx(me, { className: "h-5 w-5" }),
634
+ "Pending Approval",
635
+ l && /* @__PURE__ */ e.jsxs(N, { variant: "outline", className: "ml-2", children: [
636
+ l.type === "any" && "Any approver",
637
+ l.type === "all" && "All must approve",
638
+ l.type === "majority" && "Majority approval",
639
+ l.type === "sequential" && "Sequential"
640
+ ] })
641
+ ] }) }),
642
+ /* @__PURE__ */ e.jsxs(A, { className: "space-y-4", children: [
643
+ a && Object.keys(a).length > 0 && /* @__PURE__ */ e.jsxs("div", { className: "p-3 bg-muted/50 rounded-lg", children: [
644
+ /* @__PURE__ */ e.jsx(b, { className: "text-xs text-muted-foreground mb-2 block", children: "Request Details" }),
645
+ /* @__PURE__ */ e.jsx("div", { className: "grid grid-cols-2 gap-2", children: Object.entries(a).slice(0, 6).map(([i, k]) => /* @__PURE__ */ e.jsxs("div", { className: "text-sm", children: [
646
+ /* @__PURE__ */ e.jsxs("span", { className: "text-muted-foreground", children: [
647
+ i,
648
+ ": "
649
+ ] }),
650
+ /* @__PURE__ */ e.jsx("span", { className: "font-medium", children: String(k) })
651
+ ] }, i)) })
652
+ ] }),
653
+ h && /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
654
+ /* @__PURE__ */ e.jsxs(b, { className: "flex items-center gap-2 text-sm", children: [
655
+ /* @__PURE__ */ e.jsx(_e, { className: "h-4 w-4" }),
656
+ "Comment"
657
+ ] }),
658
+ /* @__PURE__ */ e.jsx(
659
+ C,
660
+ {
661
+ value: g,
662
+ onChange: (i) => _(i.target.value),
663
+ placeholder: "Add a comment (optional)"
664
+ }
665
+ )
666
+ ] }),
667
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2", children: [
668
+ /* @__PURE__ */ e.jsxs(
669
+ R,
670
+ {
671
+ onClick: () => E("approve"),
672
+ disabled: w,
673
+ className: "bg-green-600 hover:bg-green-700",
674
+ children: [
675
+ /* @__PURE__ */ e.jsx(Te, { className: "h-4 w-4 mr-2" }),
676
+ "Approve"
677
+ ]
678
+ }
679
+ ),
680
+ /* @__PURE__ */ e.jsxs(
681
+ R,
682
+ {
683
+ variant: "destructive",
684
+ onClick: () => E("reject"),
685
+ disabled: w,
686
+ children: [
687
+ /* @__PURE__ */ e.jsx(Ce, { className: "h-4 w-4 mr-2" }),
688
+ "Reject"
689
+ ]
690
+ }
691
+ ),
692
+ /* @__PURE__ */ e.jsxs(
693
+ R,
694
+ {
695
+ variant: "outline",
696
+ onClick: () => E("reassign"),
697
+ disabled: w,
698
+ children: [
699
+ /* @__PURE__ */ e.jsx(Se, { className: "h-4 w-4 mr-2" }),
700
+ "Reassign"
701
+ ]
702
+ }
703
+ )
704
+ ] })
705
+ ] })
706
+ ] }),
707
+ d && j.length > 0 && /* @__PURE__ */ e.jsxs(S, { children: [
708
+ /* @__PURE__ */ e.jsx(Y, { children: /* @__PURE__ */ e.jsx(W, { className: "text-sm", children: "Approval History" }) }),
709
+ /* @__PURE__ */ e.jsx(A, { children: /* @__PURE__ */ e.jsx("div", { className: "space-y-3", children: j.map((i, k) => /* @__PURE__ */ e.jsxs("div", { className: "flex items-start gap-3 p-3 rounded-lg border", children: [
710
+ /* @__PURE__ */ e.jsx("div", { className: "mt-0.5", children: /* @__PURE__ */ e.jsx(Ae, { className: "h-4 w-4 text-muted-foreground" }) }),
711
+ /* @__PURE__ */ e.jsxs("div", { className: "flex-1 min-w-0", children: [
712
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2 flex-wrap", children: [
713
+ /* @__PURE__ */ e.jsx("span", { className: "font-medium text-sm", children: i.actorName || i.actor }),
714
+ v(i.action),
715
+ /* @__PURE__ */ e.jsx("span", { className: "text-xs text-muted-foreground", children: new Date(i.timestamp).toLocaleString() })
716
+ ] }),
717
+ i.comment && /* @__PURE__ */ e.jsx("p", { className: "text-sm text-muted-foreground mt-1", children: i.comment })
718
+ ] })
719
+ ] }, k)) }) })
720
+ ] }),
721
+ d && j.length === 0 && /* @__PURE__ */ e.jsx(S, { children: /* @__PURE__ */ e.jsx(A, { className: "p-6 text-center text-muted-foreground text-sm", children: "No approval history yet" }) })
722
+ ] });
723
+ };
724
+ ie.register(
725
+ "workflow-designer",
726
+ Ye,
727
+ {
728
+ label: "Workflow Designer",
729
+ category: "Enterprise",
730
+ inputs: [
731
+ { name: "workflow", type: "code", label: "Initial Workflow Definition" },
732
+ { name: "readOnly", type: "boolean", label: "Read Only", defaultValue: !1 },
733
+ { name: "showToolbar", type: "boolean", label: "Show Toolbar", defaultValue: !0 },
734
+ { name: "showMinimap", type: "boolean", label: "Show Minimap", defaultValue: !1 }
735
+ ]
736
+ }
737
+ );
738
+ ie.register(
739
+ "approval-process",
740
+ We,
741
+ {
742
+ label: "Approval Process",
743
+ category: "Enterprise",
744
+ inputs: [
745
+ { name: "workflowId", type: "string", label: "Workflow ID" },
746
+ { name: "instanceId", type: "string", label: "Instance ID" },
747
+ { name: "currentNodeId", type: "string", label: "Current Node ID" },
748
+ { name: "approvalRule", type: "code", label: "Approval Rule" },
749
+ { name: "history", type: "code", label: "History" },
750
+ { name: "showHistory", type: "boolean", label: "Show History", defaultValue: !0 },
751
+ { name: "showComments", type: "boolean", label: "Show Comments", defaultValue: !0 }
752
+ ]
753
+ }
754
+ );
755
+ export {
756
+ We as ApprovalProcess,
757
+ Ye as WorkflowDesigner
758
+ };
@@ -0,0 +1,6 @@
1
+ (function(N,S){typeof exports=="object"&&typeof module<"u"?S(exports,require("@object-ui/core"),require("react"),require("@object-ui/components"),require("lucide-react")):typeof define=="function"&&define.amd?define(["exports","@object-ui/core","react","@object-ui/components","lucide-react"],S):(N=typeof globalThis<"u"?globalThis:N||self,S(N.ObjectUIPluginWorkflow={},N.ObjectUICore,N.React,N.ObjectUIComponents,N.lucideReact))})(this,(function(N,S,j,a,d){"use strict";var I={exports:{}},R={};var J;function te(){if(J)return R;J=1;var g=Symbol.for("react.transitional.element"),C=Symbol.for("react.fragment");function n(y,l,m){var b=null;if(m!==void 0&&(b=""+m),l.key!==void 0&&(b=""+l.key),"key"in l){m={};for(var v in l)v!=="key"&&(m[v]=l[v])}else m=l;return l=m.ref,{$$typeof:g,type:y,key:b,ref:l!==void 0?l:null,props:m}}return R.Fragment=C,R.jsx=n,R.jsxs=n,R}var O={};var X;function le(){return X||(X=1,process.env.NODE_ENV!=="production"&&(function(){function g(s){if(s==null)return null;if(typeof s=="function")return s.$$typeof===ce?null:s.displayName||s.name||null;if(typeof s=="string")return s;switch(s){case P:return"Fragment";case D:return"Profiler";case U:return"StrictMode";case h:return"Suspense";case p:return"SuspenseList";case de:return"Activity"}if(typeof s=="object")switch(typeof s.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),s.$$typeof){case Y:return"Portal";case r:return s.displayName||"Context";case F:return(s._context.displayName||"Context")+".Consumer";case i:var t=s.render;return s=s.displayName,s||(s=t.displayName||t.name||"",s=s!==""?"ForwardRef("+s+")":"ForwardRef"),s;case B:return t=s.displayName||null,t!==null?t:g(s.type)||"Memo";case M:t=s._payload,s=s._init;try{return g(s(t))}catch{}}return null}function C(s){return""+s}function n(s){try{C(s);var t=!1}catch{t=!0}if(t){t=console;var u=t.error,x=typeof Symbol=="function"&&Symbol.toStringTag&&s[Symbol.toStringTag]||s.constructor.name||"Object";return u.call(t,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",x),C(s)}}function y(s){if(s===P)return"<>";if(typeof s=="object"&&s!==null&&s.$$typeof===M)return"<...>";try{var t=g(s);return t?"<"+t+">":"<...>"}catch{return"<...>"}}function l(){var s=z.A;return s===null?null:s.getOwner()}function m(){return Error("react-stack-top-frame")}function b(s){if($.call(s,"key")){var t=Object.getOwnPropertyDescriptor(s,"key").get;if(t&&t.isReactWarning)return!1}return s.key!==void 0}function v(s,t){function u(){K||(K=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",t))}u.isReactWarning=!0,Object.defineProperty(s,"key",{get:u,configurable:!0})}function _(){var s=g(this.type);return ee[s]||(ee[s]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),s=this.props.ref,s!==void 0?s:null}function k(s,t,u,x,L,H){var f=u.ref;return s={$$typeof:T,type:s,key:t,props:u,_owner:x},(f!==void 0?f:null)!==null?Object.defineProperty(s,"ref",{enumerable:!1,get:_}):Object.defineProperty(s,"ref",{enumerable:!1,value:null}),s._store={},Object.defineProperty(s._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(s,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(s,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:L}),Object.defineProperty(s,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:H}),Object.freeze&&(Object.freeze(s.props),Object.freeze(s)),s}function o(s,t,u,x,L,H){var f=t.children;if(f!==void 0)if(x)if(ue(f)){for(x=0;x<f.length;x++)E(f[x]);Object.freeze&&Object.freeze(f)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else E(f);if($.call(t,"key")){f=g(s);var A=Object.keys(t).filter(function(me){return me!=="key"});x=0<A.length?"{key: someKey, "+A.join(": ..., ")+": ...}":"{key: someKey}",ae[f+x]||(A=0<A.length?"{"+A.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
2
+ let props = %s;
3
+ <%s {...props} />
4
+ React keys must be passed directly to JSX without using spread:
5
+ let props = %s;
6
+ <%s key={someKey} {...props} />`,x,f,A,f),ae[f+x]=!0)}if(f=null,u!==void 0&&(n(u),f=""+u),b(t)&&(n(t.key),f=""+t.key),"key"in t){u={};for(var G in t)G!=="key"&&(u[G]=t[G])}else u=t;return f&&v(u,typeof s=="function"?s.displayName||s.name||"Unknown":s),k(s,f,u,l(),L,H)}function E(s){w(s)?s._store&&(s._store.validated=1):typeof s=="object"&&s!==null&&s.$$typeof===M&&(s._payload.status==="fulfilled"?w(s._payload.value)&&s._payload.value._store&&(s._payload.value._store.validated=1):s._store&&(s._store.validated=1))}function w(s){return typeof s=="object"&&s!==null&&s.$$typeof===T}var c=j,T=Symbol.for("react.transitional.element"),Y=Symbol.for("react.portal"),P=Symbol.for("react.fragment"),U=Symbol.for("react.strict_mode"),D=Symbol.for("react.profiler"),F=Symbol.for("react.consumer"),r=Symbol.for("react.context"),i=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),p=Symbol.for("react.suspense_list"),B=Symbol.for("react.memo"),M=Symbol.for("react.lazy"),de=Symbol.for("react.activity"),ce=Symbol.for("react.client.reference"),z=c.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,$=Object.prototype.hasOwnProperty,ue=Array.isArray,V=console.createTask?console.createTask:function(){return null};c={react_stack_bottom_frame:function(s){return s()}};var K,ee={},se=c.react_stack_bottom_frame.bind(c,m)(),re=V(y(m)),ae={};O.Fragment=P,O.jsx=function(s,t,u){var x=1e4>z.recentlyCreatedOwnerStacks++;return o(s,t,u,!1,x?Error("react-stack-top-frame"):se,x?V(y(s)):re)},O.jsxs=function(s,t,u){var x=1e4>z.recentlyCreatedOwnerStacks++;return o(s,t,u,!0,x?Error("react-stack-top-frame"):se,x?V(y(s)):re)}})()),O}var q;function ne(){return q||(q=1,process.env.NODE_ENV==="production"?I.exports=te():I.exports=le()),I.exports}var e=ne();const W={start:e.jsx(d.Play,{className:"h-4 w-4 text-green-500"}),end:e.jsx(d.CheckCircle,{className:"h-4 w-4 text-red-500"}),task:e.jsx(d.Circle,{className:"h-4 w-4 text-blue-500"}),approval:e.jsx(d.Users,{className:"h-4 w-4 text-purple-500"}),condition:e.jsx(d.GitBranch,{className:"h-4 w-4 text-orange-500"}),parallel:e.jsx(d.ArrowRight,{className:"h-4 w-4 text-teal-500"}),delay:e.jsx(d.Clock,{className:"h-4 w-4 text-gray-500"}),notification:e.jsx(d.Bell,{className:"h-4 w-4 text-yellow-500"}),script:e.jsx(d.Code,{className:"h-4 w-4 text-indigo-500"})},ie={start:"border-green-300 bg-green-50",end:"border-red-300 bg-red-50",task:"border-blue-300 bg-blue-50",approval:"border-purple-300 bg-purple-50",condition:"border-orange-300 bg-orange-50",parallel:"border-teal-300 bg-teal-50",delay:"border-gray-300 bg-gray-50",notification:"border-yellow-300 bg-yellow-50",script:"border-indigo-300 bg-indigo-50"},oe={draft:{variant:"secondary",label:"Draft"},active:{variant:"default",label:"Active"},paused:{variant:"outline",label:"Paused"},completed:{variant:"default",label:"Completed"},cancelled:{variant:"destructive",label:"Cancelled"}},Q=({schema:g})=>{const{workflow:C,readOnly:n=!1,showToolbar:y=!0}=g,[l,m]=j.useState(C||{type:"workflow",title:"New Workflow",status:"draft",nodes:[{id:"start-1",type:"start",label:"Start",position:{x:100,y:100}},{id:"end-1",type:"end",label:"End",position:{x:100,y:400}}],edges:[],variables:[]}),[b,v]=j.useState(null),[_,k]=j.useState(null),o=j.useMemo(()=>l.nodes.find(r=>r.id===b),[l.nodes,b]),E=j.useCallback(r=>{if(n)return;const i=`${r}-${Date.now()}`,h={id:i,type:r,label:`New ${r.charAt(0).toUpperCase()+r.slice(1)}`,position:{x:200,y:(l.nodes.length+1)*80}};m(p=>({...p,nodes:[...p.nodes,h]})),v(i)},[n,l.nodes.length]),w=j.useCallback((r,i)=>{n||m(h=>({...h,nodes:h.nodes.map(p=>p.id===r?{...p,...i}:p)}))},[n]),c=j.useCallback(r=>{n||(m(i=>({...i,nodes:i.nodes.filter(h=>h.id!==r),edges:i.edges.filter(h=>h.source!==r&&h.target!==r)})),b===r&&v(null))},[n,b]),T=j.useCallback((r,i)=>{if(n)return;const p={id:`edge-${Date.now()}`,source:r,target:i};m(B=>({...B,edges:[...B.edges,p]}))},[n]),Y=j.useCallback(r=>{n||(m(i=>({...i,edges:i.edges.filter(h=>h.id!==r)})),_===r&&k(null))},[n,_]),P=()=>{console.log("Saving workflow:",l),g.onSave},U=()=>{m(r=>({...r,status:"active"})),console.log("Publishing workflow"),g.onPublish},D=oe[l.status||"draft"],F=["task","approval","condition","parallel","delay","notification","script"];return e.jsxs("div",{className:"space-y-4",children:[y&&e.jsxs("div",{className:"flex items-center justify-between gap-2 p-4 bg-card rounded-lg border",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{children:e.jsx(a.Input,{value:l.title||"",onChange:r=>m(i=>({...i,title:r.target.value})),className:"text-lg font-semibold border-none p-0 h-auto focus-visible:ring-0",readOnly:n,placeholder:"Workflow Title"})}),e.jsx(a.Badge,{variant:D.variant,children:D.label})]}),!n&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(a.Button,{variant:"outline",size:"sm",onClick:P,children:[e.jsx(d.Save,{className:"h-4 w-4 mr-2"}),"Save"]}),e.jsxs(a.Button,{size:"sm",onClick:U,disabled:l.status==="active",children:[e.jsx(d.Play,{className:"h-4 w-4 mr-2"}),"Publish"]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-4 gap-4",children:[!n&&e.jsxs(a.Card,{className:"lg:col-span-1",children:[e.jsx(a.CardHeader,{children:e.jsx(a.CardTitle,{className:"text-sm",children:"Add Node"})}),e.jsx(a.CardContent,{className:"space-y-2",children:F.map(r=>e.jsxs("button",{onClick:()=>E(r),className:"w-full flex items-center gap-2 p-2 rounded-md border hover:bg-muted/50 transition-colors text-sm",children:[W[r],e.jsx("span",{className:"capitalize",children:r})]},r))})]}),e.jsxs(a.Card,{className:n?"lg:col-span-3":"lg:col-span-2",children:[e.jsx(a.CardHeader,{children:e.jsxs(a.CardTitle,{className:"text-sm flex items-center gap-2",children:[e.jsx(d.GitBranch,{className:"h-4 w-4"}),"Workflow Flow"]})}),e.jsx(a.CardContent,{children:e.jsxs("div",{className:"space-y-2",children:[l.nodes.map(r=>e.jsxs("div",{onClick:()=>{v(r.id),k(null)},className:`flex items-center justify-between p-3 rounded-lg border-2 cursor-pointer transition-all ${ie[r.type]} ${b===r.id?"ring-2 ring-primary shadow-md":"hover:shadow-sm"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[W[r.type],e.jsx("span",{className:"font-medium text-sm",children:r.label}),e.jsxs("span",{className:"text-xs text-muted-foreground capitalize",children:["(",r.type,")"]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[l.edges.filter(i=>i.source===r.id).length>0&&e.jsxs(a.Badge,{variant:"outline",className:"text-xs",children:[l.edges.filter(i=>i.source===r.id).length," out"]}),!n&&r.type!=="start"&&r.type!=="end"&&e.jsx(a.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 text-red-500 hover:text-red-700",onClick:i=>{i.stopPropagation(),c(r.id)},children:e.jsx(d.Trash2,{className:"h-3 w-3"})})]})]},r.id)),l.edges.length>0&&e.jsxs("div",{className:"mt-4 pt-4 border-t",children:[e.jsx(a.Label,{className:"text-xs text-muted-foreground mb-2 block",children:"Connections"}),l.edges.map(r=>{const i=l.nodes.find(p=>p.id===r.source),h=l.nodes.find(p=>p.id===r.target);return e.jsxs("div",{className:"flex items-center gap-2 p-2 text-sm",children:[e.jsx("span",{children:i?.label||r.source}),e.jsx(d.ArrowRight,{className:"h-3 w-3 text-muted-foreground"}),e.jsx("span",{children:h?.label||r.target}),r.label&&e.jsx(a.Badge,{variant:"outline",className:"text-xs",children:r.label}),!n&&e.jsx(a.Button,{size:"sm",variant:"ghost",className:"h-5 w-5 p-0 ml-auto text-red-500",onClick:()=>Y(r.id),children:e.jsx(d.Trash2,{className:"h-3 w-3"})})]},r.id)})]}),!n&&l.nodes.length>=2&&e.jsxs("div",{className:"mt-4 pt-4 border-t",children:[e.jsx(a.Label,{className:"text-xs text-muted-foreground mb-2 block",children:"Quick Connect"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("select",{id:"edge-source",className:"border rounded-md p-1.5 text-sm bg-background",children:[e.jsx("option",{value:"",children:"From..."}),l.nodes.filter(r=>r.type!=="end").map(r=>e.jsx("option",{value:r.id,children:r.label},r.id))]}),e.jsxs("select",{id:"edge-target",className:"border rounded-md p-1.5 text-sm bg-background",children:[e.jsx("option",{value:"",children:"To..."}),l.nodes.filter(r=>r.type!=="start").map(r=>e.jsx("option",{value:r.id,children:r.label},r.id))]})]}),e.jsxs(a.Button,{size:"sm",variant:"outline",className:"mt-2 w-full",onClick:()=>{const r=document.getElementById("edge-source")?.value,i=document.getElementById("edge-target")?.value;r&&i&&r!==i&&T(r,i)},children:[e.jsx(d.Plus,{className:"h-3 w-3 mr-1"}),"Connect"]})]})]})})]}),e.jsxs(a.Card,{className:"lg:col-span-1",children:[e.jsx(a.CardHeader,{children:e.jsxs(a.CardTitle,{className:"text-sm flex items-center gap-2",children:[e.jsx(d.Settings,{className:"h-4 w-4"}),"Properties"]})}),e.jsx(a.CardContent,{children:o?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(a.Label,{className:"text-xs",children:"Label"}),e.jsx(a.Input,{value:o.label,onChange:r=>w(o.id,{label:r.target.value}),className:"h-8 text-sm",readOnly:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(a.Label,{className:"text-xs",children:"Type"}),e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-md bg-muted text-sm",children:[W[o.type],e.jsx("span",{className:"capitalize",children:o.type})]})]}),o.description!==void 0&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(a.Label,{className:"text-xs",children:"Description"}),e.jsx(a.Input,{value:o.description||"",onChange:r=>w(o.id,{description:r.target.value}),className:"h-8 text-sm",readOnly:n})]}),(o.type==="approval"||o.type==="task")&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(a.Label,{className:"text-xs",children:"Assignee"}),e.jsx(a.Input,{value:o.assignee||"",onChange:r=>w(o.id,{assignee:r.target.value}),className:"h-8 text-sm",placeholder:"User, role, or expression",readOnly:n})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(a.Label,{className:"text-xs",children:"Assignee Type"}),e.jsxs("select",{className:"w-full border rounded-md h-8 text-sm px-2 bg-background",value:o.assigneeType||"user",onChange:r=>w(o.id,{assigneeType:r.target.value}),disabled:n,children:[e.jsx("option",{value:"user",children:"User"}),e.jsx("option",{value:"role",children:"Role"}),e.jsx("option",{value:"group",children:"Group"}),e.jsx("option",{value:"expression",children:"Expression"})]})]})]}),o.type==="delay"&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(a.Label,{className:"text-xs",children:"Timeout (minutes)"}),e.jsx(a.Input,{type:"number",value:o.timeout||60,onChange:r=>w(o.id,{timeout:Number(r.target.value)}),className:"h-8 text-sm",readOnly:n})]}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-2",children:["ID: ",o.id]})]}):e.jsx("div",{className:"text-sm text-muted-foreground text-center py-8",children:"Select a node to edit its properties"})})]})]})]})},Z=({schema:g})=>{const{currentNodeId:C,approvalRule:n,history:y=[],data:l,showHistory:m=!0,showComments:b=!0}=g,[v,_]=j.useState(""),[k,o]=j.useState(!1),E=c=>{o(!0),console.log(`Approval action: ${c}`,{currentNodeId:C,comment:v,data:l}),setTimeout(()=>{o(!1),_("")},500)},w=c=>{switch(c){case"approve":case"approved":return e.jsx(a.Badge,{variant:"default",className:"bg-green-500",children:"Approved"});case"reject":case"rejected":return e.jsx(a.Badge,{variant:"destructive",children:"Rejected"});case"reassign":case"reassigned":return e.jsx(a.Badge,{variant:"secondary",children:"Reassigned"});case"comment":return e.jsx(a.Badge,{variant:"outline",children:"Comment"});case"escalate":case"escalated":return e.jsx(a.Badge,{variant:"secondary",className:"bg-orange-500 text-white",children:"Escalated"});default:return e.jsx(a.Badge,{variant:"outline",children:c})}};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs(a.Card,{children:[e.jsx(a.CardHeader,{children:e.jsxs(a.CardTitle,{className:"flex items-center gap-2",children:[e.jsx(d.Clock,{className:"h-5 w-5"}),"Pending Approval",n&&e.jsxs(a.Badge,{variant:"outline",className:"ml-2",children:[n.type==="any"&&"Any approver",n.type==="all"&&"All must approve",n.type==="majority"&&"Majority approval",n.type==="sequential"&&"Sequential"]})]})}),e.jsxs(a.CardContent,{className:"space-y-4",children:[l&&Object.keys(l).length>0&&e.jsxs("div",{className:"p-3 bg-muted/50 rounded-lg",children:[e.jsx(a.Label,{className:"text-xs text-muted-foreground mb-2 block",children:"Request Details"}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:Object.entries(l).slice(0,6).map(([c,T])=>e.jsxs("div",{className:"text-sm",children:[e.jsxs("span",{className:"text-muted-foreground",children:[c,": "]}),e.jsx("span",{className:"font-medium",children:String(T)})]},c))})]}),b&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(a.Label,{className:"flex items-center gap-2 text-sm",children:[e.jsx(d.MessageSquare,{className:"h-4 w-4"}),"Comment"]}),e.jsx(a.Input,{value:v,onChange:c=>_(c.target.value),placeholder:"Add a comment (optional)"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(a.Button,{onClick:()=>E("approve"),disabled:k,className:"bg-green-600 hover:bg-green-700",children:[e.jsx(d.Check,{className:"h-4 w-4 mr-2"}),"Approve"]}),e.jsxs(a.Button,{variant:"destructive",onClick:()=>E("reject"),disabled:k,children:[e.jsx(d.X,{className:"h-4 w-4 mr-2"}),"Reject"]}),e.jsxs(a.Button,{variant:"outline",onClick:()=>E("reassign"),disabled:k,children:[e.jsx(d.RefreshCw,{className:"h-4 w-4 mr-2"}),"Reassign"]})]})]})]}),m&&y.length>0&&e.jsxs(a.Card,{children:[e.jsx(a.CardHeader,{children:e.jsx(a.CardTitle,{className:"text-sm",children:"Approval History"})}),e.jsx(a.CardContent,{children:e.jsx("div",{className:"space-y-3",children:y.map((c,T)=>e.jsxs("div",{className:"flex items-start gap-3 p-3 rounded-lg border",children:[e.jsx("div",{className:"mt-0.5",children:e.jsx(d.User,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-medium text-sm",children:c.actorName||c.actor}),w(c.action),e.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(c.timestamp).toLocaleString()})]}),c.comment&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:c.comment})]})]},T))})})]}),m&&y.length===0&&e.jsx(a.Card,{children:e.jsx(a.CardContent,{className:"p-6 text-center text-muted-foreground text-sm",children:"No approval history yet"})})]})};S.ComponentRegistry.register("workflow-designer",Q,{label:"Workflow Designer",category:"Enterprise",inputs:[{name:"workflow",type:"code",label:"Initial Workflow Definition"},{name:"readOnly",type:"boolean",label:"Read Only",defaultValue:!1},{name:"showToolbar",type:"boolean",label:"Show Toolbar",defaultValue:!0},{name:"showMinimap",type:"boolean",label:"Show Minimap",defaultValue:!1}]}),S.ComponentRegistry.register("approval-process",Z,{label:"Approval Process",category:"Enterprise",inputs:[{name:"workflowId",type:"string",label:"Workflow ID"},{name:"instanceId",type:"string",label:"Instance ID"},{name:"currentNodeId",type:"string",label:"Current Node ID"},{name:"approvalRule",type:"code",label:"Approval Rule"},{name:"history",type:"code",label:"History"},{name:"showHistory",type:"boolean",label:"Show History",defaultValue:!0},{name:"showComments",type:"boolean",label:"Show Comments",defaultValue:!0}]}),N.ApprovalProcess=Z,N.WorkflowDesigner=Q,Object.defineProperty(N,Symbol.toStringTag,{value:"Module"})}));
@@ -0,0 +1,11 @@
1
+ import { default as React } from 'react';
2
+ import { ApprovalProcessSchema } from '../../types/src';
3
+ export interface ApprovalProcessProps {
4
+ schema: ApprovalProcessSchema;
5
+ }
6
+ /**
7
+ * ApprovalProcess - Displays and manages approval workflows
8
+ * Shows current approval status, history, and action buttons for pending approvals.
9
+ */
10
+ export declare const ApprovalProcess: React.FC<ApprovalProcessProps>;
11
+ //# sourceMappingURL=ApprovalProcess.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApprovalProcess.d.ts","sourceRoot":"","sources":["../../src/ApprovalProcess.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,KAAK,EAAE,qBAAqB,EAAuB,MAAM,kBAAkB,CAAC;AAGnF,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,qBAAqB,CAAC;CAC/B;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAyK1D,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { default as React } from 'react';
2
+ import { WorkflowDesignerSchema } from '../../types/src';
3
+ export interface WorkflowDesignerProps {
4
+ schema: WorkflowDesignerSchema;
5
+ }
6
+ /**
7
+ * WorkflowDesigner - Visual workflow builder
8
+ * Provides a visual interface for creating and editing workflow definitions.
9
+ */
10
+ export declare const WorkflowDesigner: React.FC<WorkflowDesignerProps>;
11
+ //# sourceMappingURL=WorkflowDesigner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WorkflowDesigner.d.ts","sourceRoot":"","sources":["../../src/WorkflowDesigner.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAyC,MAAM,OAAO,CAAC;AAE9D,OAAO,KAAK,EACV,sBAAsB,EAEvB,MAAM,kBAAkB,CAAC;AAM1B,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,sBAAsB,CAAC;CAChC;AAkCD;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CA8W5D,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { WorkflowDesigner } from './WorkflowDesigner';
2
+ import { ApprovalProcess } from './ApprovalProcess';
3
+ export { WorkflowDesigner, ApprovalProcess };
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,CAAC"}
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@object-ui/plugin-workflow",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "main": "dist/index.umd.cjs",
6
+ "module": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js",
12
+ "require": "./dist/index.umd.cjs"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "peerDependencies": {
19
+ "react": "^18.0.0 || ^19.0.0",
20
+ "react-dom": "^18.0.0 || ^19.0.0",
21
+ "@object-ui/core": "0.5.0",
22
+ "@object-ui/types": "0.5.0",
23
+ "@object-ui/components": "0.5.0",
24
+ "@object-ui/react": "0.5.0"
25
+ },
26
+ "dependencies": {
27
+ "clsx": "^2.1.0",
28
+ "lucide-react": "^0.344.0",
29
+ "tailwind-merge": "^2.2.1"
30
+ },
31
+ "devDependencies": {
32
+ "@types/node": "^25.2.2",
33
+ "@types/react": "^19.2.13",
34
+ "@types/react-dom": "^19.2.3",
35
+ "@vitejs/plugin-react": "^5.1.3",
36
+ "vite": "^7.3.1",
37
+ "vite-plugin-dts": "^4.5.4",
38
+ "vitest": "^4.0.18"
39
+ },
40
+ "scripts": {
41
+ "build": "vite build",
42
+ "clean": "rm -rf dist",
43
+ "test": "vitest run",
44
+ "lint": "eslint ."
45
+ }
46
+ }