lowcoder-comps 0.0.14 → 0.0.16

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/17e7d0bf.js ADDED
@@ -0,0 +1,365 @@
1
+ var b = (n, t, e) => new Promise((r, s) => {
2
+ var a = (f) => {
3
+ try {
4
+ l(e.next(f));
5
+ } catch (u) {
6
+ s(u);
7
+ }
8
+ }, h = (f) => {
9
+ try {
10
+ l(e.throw(f));
11
+ } catch (u) {
12
+ s(u);
13
+ }
14
+ }, l = (f) => f.done ? r(f.value) : Promise.resolve(f.value).then(a, h);
15
+ l((e = e.apply(n, t)).next());
16
+ });
17
+ import { b as G, a as v, m as O, G as j, l as A } from "./86704c08.js";
18
+ import { i as M, u as _, s as H, a as V, b as q, p as D, c as U, d as W, e as Y, f as z, g as L, h as C } from "./23763b0f.js";
19
+ import { l as i, q as E, c as S, h as T } from "./c7fbe06d.js";
20
+ import { c as K } from "./38d6cf93.js";
21
+ var Q = 4;
22
+ function Z(n) {
23
+ return G(n, Q);
24
+ }
25
+ function y(n) {
26
+ var t = {
27
+ options: {
28
+ directed: n.isDirected(),
29
+ multigraph: n.isMultigraph(),
30
+ compound: n.isCompound()
31
+ },
32
+ nodes: I(n),
33
+ edges: tt(n)
34
+ };
35
+ return v(n.graph()) || (t.value = Z(n.graph())), t;
36
+ }
37
+ function I(n) {
38
+ return O(n.nodes(), function(t) {
39
+ var e = n.node(t), r = n.parent(t), s = { v: t };
40
+ return v(e) || (s.value = e), v(r) || (s.parent = r), s;
41
+ });
42
+ }
43
+ function tt(n) {
44
+ return O(n.edges(), function(t) {
45
+ var e = n.edge(t), r = { v: t.v, w: t.w };
46
+ return v(t.name) || (r.name = t.name), v(e) || (r.value = e), r;
47
+ });
48
+ }
49
+ let d = {}, x = {}, J = {};
50
+ const et = () => {
51
+ x = {}, J = {}, d = {};
52
+ }, X = (n, t) => (i.trace("In isDecendant", t, " ", n, " = ", x[t].includes(n)), !!x[t].includes(n)), nt = (n, t) => (i.info("Decendants of ", t, " is ", x[t]), i.info("Edge is ", n), n.v === t || n.w === t ? !1 : x[t] ? x[t].includes(n.v) || X(n.v, t) || X(n.w, t) || x[t].includes(n.w) : (i.debug("Tilt, ", t, ",not in decendants"), !1)), p = (n, t, e, r) => {
53
+ i.warn(
54
+ "Copying children of ",
55
+ n,
56
+ "root",
57
+ r,
58
+ "data",
59
+ t.node(n),
60
+ r
61
+ );
62
+ const s = t.children(n) || [];
63
+ n !== r && s.push(n), i.warn("Copying (nodes) clusterId", n, "nodes", s), s.forEach((a) => {
64
+ if (t.children(a).length > 0)
65
+ p(a, t, e, r);
66
+ else {
67
+ const h = t.node(a);
68
+ i.info("cp ", a, " to ", r, " with parent ", n), e.setNode(a, h), r !== t.parent(a) && (i.warn("Setting parent", a, t.parent(a)), e.setParent(a, t.parent(a))), n !== r && a !== n ? (i.debug("Setting parent", a, n), e.setParent(a, n)) : (i.info("In copy ", n, "root", r, "data", t.node(n), r), i.debug(
69
+ "Not Setting parent for node=",
70
+ a,
71
+ "cluster!==rootId",
72
+ n !== r,
73
+ "node!==clusterId",
74
+ a !== n
75
+ ));
76
+ const l = t.edges(a);
77
+ i.debug("Copying Edges", l), l.forEach((f) => {
78
+ i.info("Edge", f);
79
+ const u = t.edge(f.v, f.w, f.name);
80
+ i.info("Edge data", u, r);
81
+ try {
82
+ nt(f, r) ? (i.info("Copying as ", f.v, f.w, u, f.name), e.setEdge(f.v, f.w, u, f.name), i.info("newGraph edges ", e.edges(), e.edge(e.edges()[0]))) : i.info(
83
+ "Skipping copy of edge ",
84
+ f.v,
85
+ "-->",
86
+ f.w,
87
+ " rootId: ",
88
+ r,
89
+ " clusterId:",
90
+ n
91
+ );
92
+ } catch (g) {
93
+ i.error(g);
94
+ }
95
+ });
96
+ }
97
+ i.debug("Removing node", a), t.removeNode(a);
98
+ });
99
+ }, R = (n, t) => {
100
+ const e = t.children(n);
101
+ let r = [...e];
102
+ for (const s of e)
103
+ J[s] = n, r = [...r, ...R(s, t)];
104
+ return r;
105
+ }, m = (n, t) => {
106
+ i.trace("Searching", n);
107
+ const e = t.children(n);
108
+ if (i.trace("Searching children of id ", n, e), e.length < 1)
109
+ return i.trace("This is a valid node", n), n;
110
+ for (const r of e) {
111
+ const s = m(r, t);
112
+ if (s)
113
+ return i.trace("Found replacement for", n, " => ", s), s;
114
+ }
115
+ }, N = (n) => !d[n] || !d[n].externalConnections ? n : d[n] ? d[n].id : n, it = (n, t) => {
116
+ if (!n || t > 10) {
117
+ i.debug("Opting out, no graph ");
118
+ return;
119
+ } else
120
+ i.debug("Opting in, graph ");
121
+ n.nodes().forEach(function(e) {
122
+ n.children(e).length > 0 && (i.warn(
123
+ "Cluster identified",
124
+ e,
125
+ " Replacement id in edges: ",
126
+ m(e, n)
127
+ ), x[e] = R(e, n), d[e] = { id: m(e, n), clusterData: n.node(e) });
128
+ }), n.nodes().forEach(function(e) {
129
+ const r = n.children(e), s = n.edges();
130
+ r.length > 0 ? (i.debug("Cluster identified", e, x), s.forEach((a) => {
131
+ if (a.v !== e && a.w !== e) {
132
+ const h = X(a.v, e), l = X(a.w, e);
133
+ h ^ l && (i.warn("Edge: ", a, " leaves cluster ", e), i.warn("Decendants of XXX ", e, ": ", x[e]), d[e].externalConnections = !0);
134
+ }
135
+ })) : i.debug("Not a cluster ", e, x);
136
+ }), n.edges().forEach(function(e) {
137
+ const r = n.edge(e);
138
+ i.warn("Edge " + e.v + " -> " + e.w + ": " + JSON.stringify(e)), i.warn("Edge " + e.v + " -> " + e.w + ": " + JSON.stringify(n.edge(e)));
139
+ let s = e.v, a = e.w;
140
+ if (i.warn(
141
+ "Fix XXX",
142
+ d,
143
+ "ids:",
144
+ e.v,
145
+ e.w,
146
+ "Translating: ",
147
+ d[e.v],
148
+ " --- ",
149
+ d[e.w]
150
+ ), d[e.v] && d[e.w] && d[e.v] === d[e.w]) {
151
+ i.warn("Fixing and trixing link to self - removing XXX", e.v, e.w, e.name), i.warn("Fixing and trixing - removing XXX", e.v, e.w, e.name), s = N(e.v), a = N(e.w), n.removeEdge(e.v, e.w, e.name);
152
+ const h = e.w + "---" + e.v;
153
+ n.setNode(h, {
154
+ domId: h,
155
+ id: h,
156
+ labelStyle: "",
157
+ labelText: r.label,
158
+ padding: 0,
159
+ shape: "labelRect",
160
+ style: ""
161
+ });
162
+ const l = JSON.parse(JSON.stringify(r)), f = JSON.parse(JSON.stringify(r));
163
+ l.label = "", l.arrowTypeEnd = "none", f.label = "", l.fromCluster = e.v, f.toCluster = e.v, n.setEdge(s, h, l, e.name + "-cyclic-special"), n.setEdge(h, a, f, e.name + "-cyclic-special");
164
+ } else
165
+ (d[e.v] || d[e.w]) && (i.warn("Fixing and trixing - removing XXX", e.v, e.w, e.name), s = N(e.v), a = N(e.w), n.removeEdge(e.v, e.w, e.name), s !== e.v && (r.fromCluster = e.v), a !== e.w && (r.toCluster = e.w), i.warn("Fix Replacing with XXX", s, a, e.name), n.setEdge(s, a, r, e.name));
166
+ }), i.warn("Adjusted Graph", y(n)), P(n, 0), i.trace(d);
167
+ }, P = (n, t) => {
168
+ if (i.warn("extractor - ", t, y(n), n.children("D")), t > 10) {
169
+ i.error("Bailing out");
170
+ return;
171
+ }
172
+ let e = n.nodes(), r = !1;
173
+ for (const s of e) {
174
+ const a = n.children(s);
175
+ r = r || a.length > 0;
176
+ }
177
+ if (!r) {
178
+ i.debug("Done, no node has children", n.nodes());
179
+ return;
180
+ }
181
+ i.debug("Nodes = ", e, t);
182
+ for (const s of e)
183
+ if (i.debug(
184
+ "Extracting node",
185
+ s,
186
+ d,
187
+ d[s] && !d[s].externalConnections,
188
+ !n.parent(s),
189
+ n.node(s),
190
+ n.children("D"),
191
+ " Depth ",
192
+ t
193
+ ), !d[s])
194
+ i.debug("Not a cluster", s, t);
195
+ else if (!d[s].externalConnections && // !graph.parent(node) &&
196
+ n.children(s) && n.children(s).length > 0) {
197
+ i.warn(
198
+ "Cluster without external connections, without a parent and with children",
199
+ s,
200
+ t
201
+ );
202
+ let h = n.graph().rankdir === "TB" ? "LR" : "TB";
203
+ d[s] && d[s].clusterData && d[s].clusterData.dir && (h = d[s].clusterData.dir, i.warn("Fixing dir", d[s].clusterData.dir, h));
204
+ const l = new j({
205
+ multigraph: !0,
206
+ compound: !0
207
+ }).setGraph({
208
+ rankdir: h,
209
+ // Todo: set proper spacing
210
+ nodesep: 50,
211
+ ranksep: 50,
212
+ marginx: 8,
213
+ marginy: 8
214
+ }).setDefaultEdgeLabel(function() {
215
+ return {};
216
+ });
217
+ i.warn("Old graph before copy", y(n)), p(s, n, l, s), n.setNode(s, {
218
+ clusterNode: !0,
219
+ id: s,
220
+ clusterData: d[s].clusterData,
221
+ labelText: d[s].labelText,
222
+ graph: l
223
+ }), i.warn("New graph after copy node: (", s, ")", y(l)), i.debug("Old graph after copy", y(n));
224
+ } else
225
+ i.warn(
226
+ "Cluster ** ",
227
+ s,
228
+ " **not meeting the criteria !externalConnections:",
229
+ !d[s].externalConnections,
230
+ " no parent: ",
231
+ !n.parent(s),
232
+ " children ",
233
+ n.children(s) && n.children(s).length > 0,
234
+ n.children("D"),
235
+ t
236
+ ), i.debug(d);
237
+ e = n.nodes(), i.warn("New list of nodes", e);
238
+ for (const s of e) {
239
+ const a = n.node(s);
240
+ i.warn(" Now next level", s, a), a.clusterNode && P(a.graph, t + 1);
241
+ }
242
+ }, F = (n, t) => {
243
+ if (t.length === 0)
244
+ return [];
245
+ let e = Object.assign(t);
246
+ return t.forEach((r) => {
247
+ const s = n.children(r), a = F(n, s);
248
+ e = [...e, ...a];
249
+ }), e;
250
+ }, st = (n) => F(n, n.children()), rt = (n, t) => {
251
+ i.info("Creating subgraph rect for ", t.id, t);
252
+ const e = n.insert("g").attr("class", "cluster" + (t.class ? " " + t.class : "")).attr("id", t.id), r = e.insert("rect", ":first-child"), s = E(S().flowchart.htmlLabels), a = e.insert("g").attr("class", "cluster-label"), h = t.labelType === "markdown" ? K(a, t.labelText, { style: t.labelStyle, useHtmlLabels: s }) : a.node().appendChild(L(t.labelText, t.labelStyle, void 0, !0));
253
+ let l = h.getBBox();
254
+ if (E(S().flowchart.htmlLabels)) {
255
+ const o = h.children[0], w = T(h);
256
+ l = o.getBoundingClientRect(), w.attr("width", l.width), w.attr("height", l.height);
257
+ }
258
+ const f = 0 * t.padding, u = f / 2, g = t.width <= l.width + f ? l.width + f : t.width;
259
+ t.width <= l.width + f ? t.diff = (l.width - t.width) / 2 - t.padding / 2 : t.diff = -t.padding / 2, i.trace("Data ", t, JSON.stringify(t)), r.attr("style", t.style).attr("rx", t.rx).attr("ry", t.ry).attr("x", t.x - g / 2).attr("y", t.y - t.height / 2 - u).attr("width", g).attr("height", t.height + f), s ? a.attr(
260
+ "transform",
261
+ // This puts the labal on top of the box instead of inside it
262
+ "translate(" + (t.x - l.width / 2) + ", " + (t.y - t.height / 2) + ")"
263
+ ) : a.attr(
264
+ "transform",
265
+ // This puts the labal on top of the box instead of inside it
266
+ "translate(" + t.x + ", " + (t.y - t.height / 2) + ")"
267
+ );
268
+ const c = r.node().getBBox();
269
+ return t.width = c.width, t.height = c.height, t.intersect = function(o) {
270
+ return C(t, o);
271
+ }, e;
272
+ }, at = (n, t) => {
273
+ const e = n.insert("g").attr("class", "note-cluster").attr("id", t.id), r = e.insert("rect", ":first-child"), s = 0 * t.padding, a = s / 2;
274
+ r.attr("rx", t.rx).attr("ry", t.ry).attr("x", t.x - t.width / 2 - a).attr("y", t.y - t.height / 2 - a).attr("width", t.width + s).attr("height", t.height + s).attr("fill", "none");
275
+ const h = r.node().getBBox();
276
+ return t.width = h.width, t.height = h.height, t.intersect = function(l) {
277
+ return C(t, l);
278
+ }, e;
279
+ }, ct = (n, t) => {
280
+ const e = n.insert("g").attr("class", t.classes).attr("id", t.id), r = e.insert("rect", ":first-child"), s = e.insert("g").attr("class", "cluster-label"), a = e.append("rect"), h = s.node().appendChild(L(t.labelText, t.labelStyle, void 0, !0));
281
+ let l = h.getBBox();
282
+ if (E(S().flowchart.htmlLabels)) {
283
+ const o = h.children[0], w = T(h);
284
+ l = o.getBoundingClientRect(), w.attr("width", l.width), w.attr("height", l.height);
285
+ }
286
+ l = h.getBBox();
287
+ const f = 0 * t.padding, u = f / 2, g = t.width <= l.width + t.padding ? l.width + t.padding : t.width;
288
+ t.width <= l.width + t.padding ? t.diff = (l.width + t.padding * 0 - t.width) / 2 : t.diff = -t.padding / 2, r.attr("class", "outer").attr("x", t.x - g / 2 - u).attr("y", t.y - t.height / 2 - u).attr("width", g + f).attr("height", t.height + f), a.attr("class", "inner").attr("x", t.x - g / 2 - u).attr("y", t.y - t.height / 2 - u + l.height - 1).attr("width", g + f).attr("height", t.height + f - l.height - 3), s.attr(
289
+ "transform",
290
+ "translate(" + (t.x - l.width / 2) + ", " + (t.y - t.height / 2 - t.padding / 3 + (E(S().flowchart.htmlLabels) ? 5 : 3)) + ")"
291
+ );
292
+ const c = r.node().getBBox();
293
+ return t.height = c.height, t.intersect = function(o) {
294
+ return C(t, o);
295
+ }, e;
296
+ }, ot = (n, t) => {
297
+ const e = n.insert("g").attr("class", t.classes).attr("id", t.id), r = e.insert("rect", ":first-child"), s = 0 * t.padding, a = s / 2;
298
+ r.attr("class", "divider").attr("x", t.x - t.width / 2 - a).attr("y", t.y - t.height / 2).attr("width", t.width + s).attr("height", t.height + s);
299
+ const h = r.node().getBBox();
300
+ return t.width = h.width, t.height = h.height, t.diff = -t.padding / 2, t.intersect = function(l) {
301
+ return C(t, l);
302
+ }, e;
303
+ }, lt = { rect: rt, roundedWithTitle: ct, noteGroup: at, divider: ot };
304
+ let $ = {};
305
+ const ft = (n, t) => {
306
+ i.trace("Inserting cluster");
307
+ const e = t.shape || "rect";
308
+ $[t.id] = lt[e](n, t);
309
+ }, dt = () => {
310
+ $ = {};
311
+ }, k = (n, t, e, r) => b(void 0, null, function* () {
312
+ i.info("Graph in recursive render: XXX", y(t), r);
313
+ const s = t.graph().rankdir;
314
+ i.trace("Dir in recursive render - dir:", s);
315
+ const a = n.insert("g").attr("class", "root");
316
+ t.nodes() ? i.info("Recursive render XXX", t.nodes()) : i.info("No nodes found for", t), t.edges().length > 0 && i.trace("Recursive edges", t.edge(t.edges()[0]));
317
+ const h = a.insert("g").attr("class", "clusters"), l = a.insert("g").attr("class", "edgePaths"), f = a.insert("g").attr("class", "edgeLabels"), u = a.insert("g").attr("class", "nodes");
318
+ yield Promise.all(
319
+ t.nodes().map(function(c) {
320
+ return b(this, null, function* () {
321
+ const o = t.node(c);
322
+ if (r !== void 0) {
323
+ const w = JSON.parse(JSON.stringify(r.clusterData));
324
+ i.info("Setting data for cluster XXX (", c, ") ", w, r), t.setNode(r.id, w), t.parent(c) || (i.trace("Setting parent", c, r.id), t.setParent(c, r.id, w));
325
+ }
326
+ if (i.info("(Insert) Node XXX" + c + ": " + JSON.stringify(t.node(c))), o && o.clusterNode) {
327
+ i.info("Cluster identified", c, o.width, t.node(c));
328
+ const w = yield k(u, o.graph, e, t.node(c)), B = w.elem;
329
+ _(o, B), o.diff = w.diff || 0, i.info("Node bounds (abc123)", c, o, o.width, o.x, o.y), H(B, o), i.warn("Recursive render complete ", B, o);
330
+ } else
331
+ t.children(c).length > 0 ? (i.info("Cluster - the non recursive path XXX", c, o.id, o, t), i.info(m(o.id, t)), d[o.id] = { id: m(o.id, t), node: o }) : (i.info("Node - the non recursive path", c, o.id, o), yield V(u, t.node(c), s));
332
+ });
333
+ })
334
+ ), t.edges().forEach(function(c) {
335
+ const o = t.edge(c.v, c.w, c.name);
336
+ i.info("Edge " + c.v + " -> " + c.w + ": " + JSON.stringify(c)), i.info("Edge " + c.v + " -> " + c.w + ": ", c, " ", JSON.stringify(t.edge(c))), i.info("Fix", d, "ids:", c.v, c.w, "Translateing: ", d[c.v], d[c.w]), q(f, o);
337
+ }), t.edges().forEach(function(c) {
338
+ i.info("Edge " + c.v + " -> " + c.w + ": " + JSON.stringify(c));
339
+ }), i.info("#############################################"), i.info("### Layout ###"), i.info("#############################################"), i.info(t), A(t), i.info("Graph after layout:", y(t));
340
+ let g = 0;
341
+ return st(t).forEach(function(c) {
342
+ const o = t.node(c);
343
+ i.info("Position " + c + ": " + JSON.stringify(t.node(c))), i.info(
344
+ "Position " + c + ": (" + o.x,
345
+ "," + o.y,
346
+ ") width: ",
347
+ o.width,
348
+ " height: ",
349
+ o.height
350
+ ), o && o.clusterNode ? D(o) : t.children(c).length > 0 ? (ft(h, o), d[o.id].node = o) : D(o);
351
+ }), t.edges().forEach(function(c) {
352
+ const o = t.edge(c);
353
+ i.info("Edge " + c.v + " -> " + c.w + ": " + JSON.stringify(o), o);
354
+ const w = U(l, c, o, d, e, t);
355
+ W(o, w);
356
+ }), t.nodes().forEach(function(c) {
357
+ const o = t.node(c);
358
+ i.info(c, o.type, o.diff), o.type === "group" && (g = o.diff);
359
+ }), { elem: a, diff: g };
360
+ }), yt = (n, t, e, r, s) => b(void 0, null, function* () {
361
+ M(n, e, r, s), Y(), z(), dt(), et(), i.warn("Graph at first:", y(t)), it(t), i.warn("Graph after:", y(t)), yield k(n, t, r);
362
+ });
363
+ export {
364
+ yt as r
365
+ };