lowcoder-comps 0.0.8 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,266 +0,0 @@
1
- import { p as R, d as N, s as W } from "./37590a81.js";
2
- import { c as t, h as H, l as b, i as v, k as L, a2 as U, y as C } from "./2b3ab1e4.js";
3
- import { G as A, l as F } from "./945eefb3.js";
4
- import { l as O } from "./012a06bb.js";
5
- import "./0c8b29d5.js";
6
- import "./e0f479f3.js";
7
- const X = (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), J = (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), Y = (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
- }, $ = (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
- }, Z = (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
- }, D = (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 } = Z(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" && X(s), i.type === "end" && _(s), (i.type === "fork" || i.type === "join") && q(s, i), i.type === "note" && D(i.note.text, s), i.type === "divider" && J(s), i.type === "default" && i.descriptions.length === 0 && Y(s, i), i.type === "default" && i.descriptions.length > 0 && $(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 K = 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 = O().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 = {}, Q = function() {
135
- }, V = 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
- }, j = 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
- V(r), new A({
146
- multigraph: !0,
147
- compound: !0,
148
- rankdir: "RL"
149
- }).setDefaultEdgeLabel(function() {
150
- return {};
151
- });
152
- const x = c.db.getRootDoc();
153
- P(x, r, void 0, !1, p, a, c);
154
- const l = B.padding, d = r.node().getBBox(), m = d.width + l * 2, f = d.height + l * 2, S = m * 1.75;
155
- v(r, f, S, B.useMaxWidth), r.attr(
156
- "viewBox",
157
- `${d.x - B.padding} ${d.y - B.padding} ` + m + " " + f
158
- );
159
- }, tt = (e) => e ? e.length * B.fontSizeFactor : 1, P = (e, i, o, c, s, g, p) => {
160
- const a = new A({
161
- compound: !0,
162
- multigraph: !0
163
- });
164
- let r, w = !0;
165
- for (r = 0; r < e.length; r++)
166
- if (e[r].stmt === "relation") {
167
- w = !1;
168
- break;
169
- }
170
- o ? a.setGraph({
171
- rankdir: "LR",
172
- multigraph: !0,
173
- compound: !0,
174
- ranker: "tight-tree",
175
- ranksep: w ? 1 : B.edgeLengthFactor,
176
- nodeSep: w ? 1 : 50,
177
- isMultiGraph: !0
178
- }) : a.setGraph({
179
- rankdir: "TB",
180
- multigraph: !0,
181
- compound: !0,
182
- ranksep: w ? 1 : B.edgeLengthFactor,
183
- nodeSep: w ? 1 : 50,
184
- ranker: "tight-tree",
185
- isMultiGraph: !0
186
- }), a.setDefaultEdgeLabel(function() {
187
- return {};
188
- }), p.db.extract(e);
189
- const x = p.db.getStates(), l = p.db.getRelations(), d = Object.keys(x);
190
- for (const n of d) {
191
- const u = x[n];
192
- o && (u.parentId = o);
193
- let h;
194
- if (u.doc) {
195
- let y = i.append("g").attr("id", u.id).attr("class", "stateGroup");
196
- h = P(u.doc, y, u.id, !c, s, g, p);
197
- {
198
- y = I(y, u, c);
199
- let E = y.node().getBBox();
200
- h.width = E.width, h.height = E.height + B.padding / 2, z[u.id] = { y: B.compositTitleSize };
201
- }
202
- } else
203
- h = T(i, u);
204
- if (u.note) {
205
- const y = {
206
- descriptions: [],
207
- id: u.id + "-note",
208
- note: u.note,
209
- type: "note"
210
- }, E = T(i, y);
211
- 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");
212
- } else
213
- a.setNode(h.id, h);
214
- }
215
- b.debug("Count=", a.nodeCount(), a);
216
- let m = 0;
217
- l.forEach(function(n) {
218
- m++, b.debug("Setting edge", n), a.setEdge(
219
- n.id1,
220
- n.id2,
221
- {
222
- relation: n,
223
- width: tt(n.title),
224
- height: B.labelHeight * L.getRows(n.title).length,
225
- labelpos: "c"
226
- },
227
- "id" + m
228
- );
229
- }), F(a), b.debug("Graph after layout", a.nodes());
230
- const f = i.node();
231
- a.nodes().forEach(function(n) {
232
- n !== void 0 && a.node(n) !== void 0 ? (b.warn("Node " + n + ": " + JSON.stringify(a.node(n))), s.select("#" + f.id + " #" + n).attr(
233
- "transform",
234
- "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) + " )"
235
- ), 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) => {
236
- const y = h.parentElement;
237
- let E = 0, M = 0;
238
- 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);
239
- })) : b.debug("No Node " + n + ": " + JSON.stringify(a.node(n)));
240
- });
241
- let S = f.getBBox();
242
- a.edges().forEach(function(n) {
243
- n !== void 0 && a.edge(n) !== void 0 && (b.debug("Edge " + n.v + " -> " + n.w + ": " + JSON.stringify(a.edge(n))), K(i, a.edge(n), a.edge(n).relation));
244
- }), S = f.getBBox();
245
- const k = {
246
- id: o || "root",
247
- label: o || "root",
248
- width: 0,
249
- height: 0
250
- };
251
- return k.width = S.width + 2 * B.padding, k.height = S.height + 2 * B.padding, b.debug("Doc rendered", k, a), k;
252
- }, et = {
253
- setConf: Q,
254
- draw: j
255
- }, dt = {
256
- parser: R,
257
- db: N,
258
- renderer: et,
259
- styles: W,
260
- init: (e) => {
261
- e.state || (e.state = {}), e.state.arrowMarkerAbsolute = e.arrowMarkerAbsolute, N.clear();
262
- }
263
- };
264
- export {
265
- dt as diagram
266
- };