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/256b619e.js ADDED
@@ -0,0 +1,92 @@
1
+ var E = Math.pow;
2
+ const c = Math.PI, x = 2 * c, u = 1e-6, A = x - u;
3
+ function T(e) {
4
+ this._ += e[0];
5
+ for (let t = 1, h = e.length; t < h; ++t)
6
+ this._ += arguments[t] + e[t];
7
+ }
8
+ function L(e) {
9
+ let t = Math.floor(e);
10
+ if (!(t >= 0))
11
+ throw new Error(`invalid digits: ${e}`);
12
+ if (t > 15)
13
+ return T;
14
+ const h = E(10, t);
15
+ return function(i) {
16
+ this._ += i[0];
17
+ for (let s = 1, n = i.length; s < n; ++s)
18
+ this._ += Math.round(arguments[s] * h) / h + i[s];
19
+ };
20
+ }
21
+ class P {
22
+ constructor(t) {
23
+ this._x0 = this._y0 = // start of current subpath
24
+ this._x1 = this._y1 = null, this._ = "", this._append = t == null ? T : L(t);
25
+ }
26
+ moveTo(t, h) {
27
+ this._append`M${this._x0 = this._x1 = +t},${this._y0 = this._y1 = +h}`;
28
+ }
29
+ closePath() {
30
+ this._x1 !== null && (this._x1 = this._x0, this._y1 = this._y0, this._append`Z`);
31
+ }
32
+ lineTo(t, h) {
33
+ this._append`L${this._x1 = +t},${this._y1 = +h}`;
34
+ }
35
+ quadraticCurveTo(t, h, i, s) {
36
+ this._append`Q${+t},${+h},${this._x1 = +i},${this._y1 = +s}`;
37
+ }
38
+ bezierCurveTo(t, h, i, s, n, $) {
39
+ this._append`C${+t},${+h},${+i},${+s},${this._x1 = +n},${this._y1 = +$}`;
40
+ }
41
+ arcTo(t, h, i, s, n) {
42
+ if (t = +t, h = +h, i = +i, s = +s, n = +n, n < 0)
43
+ throw new Error(`negative radius: ${n}`);
44
+ let $ = this._x1, r = this._y1, p = i - t, l = s - h, _ = $ - t, o = r - h, a = _ * _ + o * o;
45
+ if (this._x1 === null)
46
+ this._append`M${this._x1 = t},${this._y1 = h}`;
47
+ else if (a > u)
48
+ if (!(Math.abs(o * p - l * _) > u) || !n)
49
+ this._append`L${this._x1 = t},${this._y1 = h}`;
50
+ else {
51
+ let d = i - $, f = s - r, y = p * p + l * l, m = d * d + f * f, g = Math.sqrt(y), v = Math.sqrt(a), w = n * Math.tan((c - Math.acos((y + a - m) / (2 * g * v))) / 2), M = w / v, b = w / g;
52
+ Math.abs(M - 1) > u && this._append`L${t + M * _},${h + M * o}`, this._append`A${n},${n},0,0,${+(o * d > _ * f)},${this._x1 = t + b * p},${this._y1 = h + b * l}`;
53
+ }
54
+ }
55
+ arc(t, h, i, s, n, $) {
56
+ if (t = +t, h = +h, i = +i, $ = !!$, i < 0)
57
+ throw new Error(`negative radius: ${i}`);
58
+ let r = i * Math.cos(s), p = i * Math.sin(s), l = t + r, _ = h + p, o = 1 ^ $, a = $ ? s - n : n - s;
59
+ this._x1 === null ? this._append`M${l},${_}` : (Math.abs(this._x1 - l) > u || Math.abs(this._y1 - _) > u) && this._append`L${l},${_}`, i && (a < 0 && (a = a % x + x), a > A ? this._append`A${i},${i},0,1,${o},${t - r},${h - p}A${i},${i},0,1,${o},${this._x1 = l},${this._y1 = _}` : a > u && this._append`A${i},${i},0,${+(a >= c)},${o},${this._x1 = t + i * Math.cos(n)},${this._y1 = h + i * Math.sin(n)}`);
60
+ }
61
+ rect(t, h, i, s) {
62
+ this._append`M${this._x0 = this._x1 = +t},${this._y0 = this._y1 = +h}h${i = +i}v${+s}h${-i}Z`;
63
+ }
64
+ toString() {
65
+ return this._;
66
+ }
67
+ }
68
+ function C(e) {
69
+ return function() {
70
+ return e;
71
+ };
72
+ }
73
+ function R(e) {
74
+ let t = 3;
75
+ return e.digits = function(h) {
76
+ if (!arguments.length)
77
+ return t;
78
+ if (h == null)
79
+ t = null;
80
+ else {
81
+ const i = Math.floor(h);
82
+ if (!(i >= 0))
83
+ throw new RangeError(`invalid digits: ${h}`);
84
+ t = i;
85
+ }
86
+ return e;
87
+ }, () => new P(t);
88
+ }
89
+ export {
90
+ C as c,
91
+ R as w
92
+ };
package/2ff2c7a6.js ADDED
@@ -0,0 +1,6 @@
1
+ function t(r) {
2
+ return typeof r == "object" && "length" in r ? r : Array.from(r);
3
+ }
4
+ export {
5
+ t as a
6
+ };
package/382c4fc4.js ADDED
@@ -0,0 +1,275 @@
1
+ import { p as R, d as N, s as W } from "./623efbe6.js";
2
+ import { c as t, h as H, l as b, i as v, j as L, D as U, x as C } from "./c7fbe06d.js";
3
+ import { G as A, l as F } from "./86704c08.js";
4
+ import { l as $ } from "./1f647469.js";
5
+ import "./2ff2c7a6.js";
6
+ import "./256b619e.js";
7
+ const O = (e) => e.append("circle").attr("class", "start-state").attr("r", t().state.sizeUnit).attr("cx", t().state.padding + t().state.sizeUnit).attr("cy", t().state.padding + t().state.sizeUnit), X = (e) => e.append("line").style("stroke", "grey").style("stroke-dasharray", "3").attr("x1", t().state.textHeight).attr("class", "divider").attr("x2", t().state.textHeight * 2).attr("y1", 0).attr("y2", 0), J = (e, i) => {
8
+ const o = e.append("text").attr("x", 2 * t().state.padding).attr("y", t().state.textHeight + 2 * t().state.padding).attr("font-size", t().state.fontSize).attr("class", "state-title").text(i.id), c = o.node().getBBox();
9
+ return e.insert("rect", ":first-child").attr("x", t().state.padding).attr("y", t().state.padding).attr("width", c.width + 2 * t().state.padding).attr("height", c.height + 2 * t().state.padding).attr("rx", t().state.radius), o;
10
+ }, Y = (e, i) => {
11
+ const o = function(d, m, f) {
12
+ const S = d.append("tspan").attr("x", 2 * t().state.padding).text(m);
13
+ f || S.attr("dy", t().state.textHeight);
14
+ }, s = e.append("text").attr("x", 2 * t().state.padding).attr("y", t().state.textHeight + 1.3 * t().state.padding).attr("font-size", t().state.fontSize).attr("class", "state-title").text(i.descriptions[0]).node().getBBox(), g = s.height, p = e.append("text").attr("x", t().state.padding).attr(
15
+ "y",
16
+ g + t().state.padding * 0.4 + t().state.dividerMargin + t().state.textHeight
17
+ ).attr("class", "state-description");
18
+ let a = !0, r = !0;
19
+ i.descriptions.forEach(function(d) {
20
+ a || (o(p, d, r), r = !1), a = !1;
21
+ });
22
+ const w = e.append("line").attr("x1", t().state.padding).attr("y1", t().state.padding + g + t().state.dividerMargin / 2).attr("y2", t().state.padding + g + t().state.dividerMargin / 2).attr("class", "descr-divider"), x = p.node().getBBox(), l = Math.max(x.width, s.width);
23
+ return w.attr("x2", l + 3 * t().state.padding), e.insert("rect", ":first-child").attr("x", t().state.padding).attr("y", t().state.padding).attr("width", l + 2 * t().state.padding).attr("height", x.height + g + 2 * t().state.padding).attr("rx", t().state.radius), e;
24
+ }, I = (e, i, o) => {
25
+ const c = t().state.padding, s = 2 * t().state.padding, g = e.node().getBBox(), p = g.width, a = g.x, r = e.append("text").attr("x", 0).attr("y", t().state.titleShift).attr("font-size", t().state.fontSize).attr("class", "state-title").text(i.id), x = r.node().getBBox().width + s;
26
+ let l = Math.max(x, p);
27
+ l === p && (l = l + s);
28
+ let d;
29
+ const m = e.node().getBBox();
30
+ i.doc, d = a - c, x > p && (d = (p - l) / 2 + c), Math.abs(a - m.x) < c && x > p && (d = a - (x - p) / 2);
31
+ const f = 1 - t().state.textHeight;
32
+ return e.insert("rect", ":first-child").attr("x", d).attr("y", f).attr("class", o ? "alt-composit" : "composit").attr("width", l).attr(
33
+ "height",
34
+ m.height + t().state.textHeight + t().state.titleShift + 1
35
+ ).attr("rx", "0"), r.attr("x", d + c), x <= p && r.attr("x", a + (l - s) / 2 - x / 2 + c), e.insert("rect", ":first-child").attr("x", d).attr(
36
+ "y",
37
+ t().state.titleShift - t().state.textHeight - t().state.padding
38
+ ).attr("width", l).attr("height", t().state.textHeight * 3).attr("rx", t().state.radius), e.insert("rect", ":first-child").attr("x", d).attr(
39
+ "y",
40
+ t().state.titleShift - t().state.textHeight - t().state.padding
41
+ ).attr("width", l).attr("height", m.height + 3 + 2 * t().state.textHeight).attr("rx", t().state.radius), e;
42
+ }, _ = (e) => (e.append("circle").attr("class", "end-state-outer").attr("r", t().state.sizeUnit + t().state.miniPadding).attr(
43
+ "cx",
44
+ t().state.padding + t().state.sizeUnit + t().state.miniPadding
45
+ ).attr(
46
+ "cy",
47
+ t().state.padding + t().state.sizeUnit + t().state.miniPadding
48
+ ), e.append("circle").attr("class", "end-state-inner").attr("r", t().state.sizeUnit).attr("cx", t().state.padding + t().state.sizeUnit + 2).attr("cy", t().state.padding + t().state.sizeUnit + 2)), q = (e, i) => {
49
+ let o = t().state.forkWidth, c = t().state.forkHeight;
50
+ if (i.parentId) {
51
+ let s = o;
52
+ o = c, c = s;
53
+ }
54
+ return e.append("rect").style("stroke", "black").style("fill", "black").attr("width", o).attr("height", c).attr("x", t().state.padding).attr("y", t().state.padding);
55
+ }, D = (e, i, o, c) => {
56
+ let s = 0;
57
+ const g = c.append("text");
58
+ g.style("text-anchor", "start"), g.attr("class", "noteText");
59
+ let p = e.replace(/\r\n/g, "<br/>");
60
+ p = p.replace(/\n/g, "<br/>");
61
+ const a = p.split(L.lineBreakRegex);
62
+ let r = 1.25 * t().state.noteMargin;
63
+ for (const w of a) {
64
+ const x = w.trim();
65
+ if (x.length > 0) {
66
+ const l = g.append("tspan");
67
+ if (l.text(x), r === 0) {
68
+ const d = l.node().getBBox();
69
+ r += d.height;
70
+ }
71
+ s += r, l.attr("x", i + t().state.noteMargin), l.attr("y", o + s + 1.25 * t().state.noteMargin);
72
+ }
73
+ }
74
+ return { textWidth: g.node().getBBox().width, textHeight: s };
75
+ }, Z = (e, i) => {
76
+ i.attr("class", "state-note");
77
+ const o = i.append("rect").attr("x", 0).attr("y", t().state.padding), c = i.append("g"), { textWidth: s, textHeight: g } = D(e, 0, 0, c);
78
+ return o.attr("height", g + 2 * t().state.noteMargin), o.attr("width", s + t().state.noteMargin * 2), o;
79
+ }, T = function(e, i) {
80
+ const o = i.id, c = {
81
+ id: o,
82
+ label: i.id,
83
+ width: 0,
84
+ height: 0
85
+ }, s = e.append("g").attr("id", o).attr("class", "stateGroup");
86
+ i.type === "start" && O(s), i.type === "end" && _(s), (i.type === "fork" || i.type === "join") && q(s, i), i.type === "note" && Z(i.note.text, s), i.type === "divider" && X(s), i.type === "default" && i.descriptions.length === 0 && J(s, i), i.type === "default" && i.descriptions.length > 0 && Y(s, i);
87
+ const g = s.node().getBBox();
88
+ return c.width = g.width + 2 * t().state.padding, c.height = g.height + 2 * t().state.padding, c;
89
+ };
90
+ let G = 0;
91
+ const j = function(e, i, o) {
92
+ const c = function(r) {
93
+ switch (r) {
94
+ case N.relationType.AGGREGATION:
95
+ return "aggregation";
96
+ case N.relationType.EXTENSION:
97
+ return "extension";
98
+ case N.relationType.COMPOSITION:
99
+ return "composition";
100
+ case N.relationType.DEPENDENCY:
101
+ return "dependency";
102
+ }
103
+ };
104
+ i.points = i.points.filter((r) => !Number.isNaN(r.y));
105
+ const s = i.points, g = $().x(function(r) {
106
+ return r.x;
107
+ }).y(function(r) {
108
+ return r.y;
109
+ }).curve(U), p = e.append("path").attr("d", g(s)).attr("id", "edge" + G).attr("class", "transition");
110
+ let a = "";
111
+ if (t().state.arrowMarkerAbsolute && (a = window.location.protocol + "//" + window.location.host + window.location.pathname + window.location.search, a = a.replace(/\(/g, "\\("), a = a.replace(/\)/g, "\\)")), p.attr(
112
+ "marker-end",
113
+ "url(" + a + "#" + c(N.relationType.DEPENDENCY) + "End)"
114
+ ), o.title !== void 0) {
115
+ const r = e.append("g").attr("class", "stateLabel"), { x: w, y: x } = C.calcLabelPosition(i.points), l = L.getRows(o.title);
116
+ let d = 0;
117
+ const m = [];
118
+ let f = 0, S = 0;
119
+ for (let u = 0; u <= l.length; u++) {
120
+ const h = r.append("text").attr("text-anchor", "middle").text(l[u]).attr("x", w).attr("y", x + d), y = h.node().getBBox();
121
+ f = Math.max(f, y.width), S = Math.min(S, y.x), b.info(y.x, w, x + d), d === 0 && (d = h.node().getBBox().height, b.info("Title height", d, x)), m.push(h);
122
+ }
123
+ let k = d * l.length;
124
+ if (l.length > 1) {
125
+ const u = (l.length - 1) * d * 0.5;
126
+ m.forEach((h, y) => h.attr("y", x + y * d - u)), k = d * l.length;
127
+ }
128
+ const n = r.node().getBBox();
129
+ r.insert("rect", ":first-child").attr("class", "box").attr("x", w - f / 2 - t().state.padding / 2).attr("y", x - k / 2 - t().state.padding / 2 - 3.5).attr("width", f + t().state.padding).attr("height", k + t().state.padding), b.info(n);
130
+ }
131
+ G++;
132
+ };
133
+ let B;
134
+ const z = {}, K = function() {
135
+ }, Q = function(e) {
136
+ e.append("defs").append("marker").attr("id", "dependencyEnd").attr("refX", 19).attr("refY", 7).attr("markerWidth", 20).attr("markerHeight", 28).attr("orient", "auto").append("path").attr("d", "M 19,7 L9,13 L14,7 L9,1 Z");
137
+ }, V = function(e, i, o, c) {
138
+ B = t().state;
139
+ const s = t().securityLevel;
140
+ let g;
141
+ s === "sandbox" && (g = H("#i" + i));
142
+ const p = s === "sandbox" ? H(g.nodes()[0].contentDocument.body) : H("body"), a = s === "sandbox" ? g.nodes()[0].contentDocument : document;
143
+ b.debug("Rendering diagram " + e);
144
+ const r = p.select(`[id='${i}']`);
145
+ Q(r), new A({
146
+ multigraph: !0,
147
+ compound: !0,
148
+ // acyclicer: 'greedy',
149
+ rankdir: "RL"
150
+ // ranksep: '20'
151
+ }).setDefaultEdgeLabel(function() {
152
+ return {};
153
+ });
154
+ const x = c.db.getRootDoc();
155
+ P(x, r, void 0, !1, p, a, c);
156
+ const l = B.padding, d = r.node().getBBox(), m = d.width + l * 2, f = d.height + l * 2, S = m * 1.75;
157
+ v(r, f, S, B.useMaxWidth), r.attr(
158
+ "viewBox",
159
+ `${d.x - B.padding} ${d.y - B.padding} ` + m + " " + f
160
+ );
161
+ }, tt = (e) => e ? e.length * B.fontSizeFactor : 1, P = (e, i, o, c, s, g, p) => {
162
+ const a = new A({
163
+ compound: !0,
164
+ multigraph: !0
165
+ });
166
+ let r, w = !0;
167
+ for (r = 0; r < e.length; r++)
168
+ if (e[r].stmt === "relation") {
169
+ w = !1;
170
+ break;
171
+ }
172
+ o ? a.setGraph({
173
+ rankdir: "LR",
174
+ multigraph: !0,
175
+ compound: !0,
176
+ // acyclicer: 'greedy',
177
+ ranker: "tight-tree",
178
+ ranksep: w ? 1 : B.edgeLengthFactor,
179
+ nodeSep: w ? 1 : 50,
180
+ isMultiGraph: !0
181
+ // ranksep: 5,
182
+ // nodesep: 1
183
+ }) : a.setGraph({
184
+ rankdir: "TB",
185
+ multigraph: !0,
186
+ compound: !0,
187
+ // isCompound: true,
188
+ // acyclicer: 'greedy',
189
+ // ranker: 'longest-path'
190
+ ranksep: w ? 1 : B.edgeLengthFactor,
191
+ nodeSep: w ? 1 : 50,
192
+ ranker: "tight-tree",
193
+ // ranker: 'network-simplex'
194
+ isMultiGraph: !0
195
+ }), a.setDefaultEdgeLabel(function() {
196
+ return {};
197
+ }), p.db.extract(e);
198
+ const x = p.db.getStates(), l = p.db.getRelations(), d = Object.keys(x);
199
+ for (const n of d) {
200
+ const u = x[n];
201
+ o && (u.parentId = o);
202
+ let h;
203
+ if (u.doc) {
204
+ let y = i.append("g").attr("id", u.id).attr("class", "stateGroup");
205
+ h = P(u.doc, y, u.id, !c, s, g, p);
206
+ {
207
+ y = I(y, u, c);
208
+ let E = y.node().getBBox();
209
+ h.width = E.width, h.height = E.height + B.padding / 2, z[u.id] = { y: B.compositTitleSize };
210
+ }
211
+ } else
212
+ h = T(i, u);
213
+ if (u.note) {
214
+ const y = {
215
+ descriptions: [],
216
+ id: u.id + "-note",
217
+ note: u.note,
218
+ type: "note"
219
+ }, E = T(i, y);
220
+ u.note.position === "left of" ? (a.setNode(h.id + "-note", E), a.setNode(h.id, h)) : (a.setNode(h.id, h), a.setNode(h.id + "-note", E)), a.setParent(h.id, h.id + "-group"), a.setParent(h.id + "-note", h.id + "-group");
221
+ } else
222
+ a.setNode(h.id, h);
223
+ }
224
+ b.debug("Count=", a.nodeCount(), a);
225
+ let m = 0;
226
+ l.forEach(function(n) {
227
+ m++, b.debug("Setting edge", n), a.setEdge(
228
+ n.id1,
229
+ n.id2,
230
+ {
231
+ relation: n,
232
+ width: tt(n.title),
233
+ height: B.labelHeight * L.getRows(n.title).length,
234
+ labelpos: "c"
235
+ },
236
+ "id" + m
237
+ );
238
+ }), F(a), b.debug("Graph after layout", a.nodes());
239
+ const f = i.node();
240
+ a.nodes().forEach(function(n) {
241
+ n !== void 0 && a.node(n) !== void 0 ? (b.warn("Node " + n + ": " + JSON.stringify(a.node(n))), s.select("#" + f.id + " #" + n).attr(
242
+ "transform",
243
+ "translate(" + (a.node(n).x - a.node(n).width / 2) + "," + (a.node(n).y + (z[n] ? z[n].y : 0) - a.node(n).height / 2) + " )"
244
+ ), s.select("#" + f.id + " #" + n).attr("data-x-shift", a.node(n).x - a.node(n).width / 2), g.querySelectorAll("#" + f.id + " #" + n + " .divider").forEach((h) => {
245
+ const y = h.parentElement;
246
+ let E = 0, M = 0;
247
+ y && (y.parentElement && (E = y.parentElement.getBBox().width), M = parseInt(y.getAttribute("data-x-shift"), 10), Number.isNaN(M) && (M = 0)), h.setAttribute("x1", 0 - M + 8), h.setAttribute("x2", E - M - 8);
248
+ })) : b.debug("No Node " + n + ": " + JSON.stringify(a.node(n)));
249
+ });
250
+ let S = f.getBBox();
251
+ a.edges().forEach(function(n) {
252
+ n !== void 0 && a.edge(n) !== void 0 && (b.debug("Edge " + n.v + " -> " + n.w + ": " + JSON.stringify(a.edge(n))), j(i, a.edge(n), a.edge(n).relation));
253
+ }), S = f.getBBox();
254
+ const k = {
255
+ id: o || "root",
256
+ label: o || "root",
257
+ width: 0,
258
+ height: 0
259
+ };
260
+ return k.width = S.width + 2 * B.padding, k.height = S.height + 2 * B.padding, b.debug("Doc rendered", k, a), k;
261
+ }, et = {
262
+ setConf: K,
263
+ draw: V
264
+ }, dt = {
265
+ parser: R,
266
+ db: N,
267
+ renderer: et,
268
+ styles: W,
269
+ init: (e) => {
270
+ e.state || (e.state = {}), e.state.arrowMarkerAbsolute = e.arrowMarkerAbsolute, N.clear();
271
+ }
272
+ };
273
+ export {
274
+ dt as diagram
275
+ };