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/d285edec.js ADDED
@@ -0,0 +1,212 @@
1
+ var B = (e, n, t) => new Promise((c, i) => {
2
+ var r = (l) => {
3
+ try {
4
+ a(t.next(l));
5
+ } catch (s) {
6
+ i(s);
7
+ }
8
+ }, o = (l) => {
9
+ try {
10
+ a(t.throw(l));
11
+ } catch (s) {
12
+ i(s);
13
+ }
14
+ }, a = (l) => l.done ? c(l.value) : Promise.resolve(l.value).then(r, o);
15
+ a((t = t.apply(e, n)).next());
16
+ });
17
+ import { p as X, d as M, s as Z, D as U, a as j, S as F, b as I, c as tt } from "./623efbe6.js";
18
+ import { G as et } from "./86704c08.js";
19
+ import { l as d, c as g, h as x, x as ot, i as st, j as w } from "./c7fbe06d.js";
20
+ import { r as nt } from "./17e7d0bf.js";
21
+ import "./23763b0f.js";
22
+ import "./38d6cf93.js";
23
+ import "./4bbdb65b.js";
24
+ import "./1f647469.js";
25
+ import "./2ff2c7a6.js";
26
+ import "./256b619e.js";
27
+ const A = "rect", C = "rectWithTitle", ct = "start", it = "end", rt = "divider", lt = "roundedWithTitle", at = "note", dt = "noteGroup", u = "statediagram", Et = "state", St = `${u}-${Et}`, V = "transition", Tt = "note", pt = "note-edge", _t = `${V} ${pt}`, ut = `${u}-${Tt}`, Dt = "cluster", ft = `${u}-${Dt}`, bt = "cluster-alt", ht = `${u}-${bt}`, Y = "parent", W = "note", At = "state", N = "----", yt = `${N}${W}`, H = `${N}${Y}`, z = "fill:none", m = "fill: #333", q = "c", K = "text", J = "normal";
28
+ let y = {}, T = 0;
29
+ const gt = function(e) {
30
+ const n = Object.keys(e);
31
+ for (const t of n)
32
+ e[t];
33
+ }, $t = function(e, n) {
34
+ d.trace("Extracting classes"), n.db.clear();
35
+ try {
36
+ return n.parser.parse(e), n.db.extract(n.db.getRootDocV2()), n.db.getClasses();
37
+ } catch (t) {
38
+ return t;
39
+ }
40
+ };
41
+ function xt(e) {
42
+ return e == null ? "" : e.classes ? e.classes.join(" ") : "";
43
+ }
44
+ function R(e = "", n = 0, t = "", c = N) {
45
+ const i = t !== null && t.length > 0 ? `${c}${t}` : "";
46
+ return `${At}-${e}${i}-${n}`;
47
+ }
48
+ const h = (e, n, t, c, i, r) => {
49
+ const o = t.id, a = xt(c[o]);
50
+ if (o !== "root") {
51
+ let l = A;
52
+ t.start === !0 && (l = ct), t.start === !1 && (l = it), t.type !== U && (l = t.type), y[o] || (y[o] = {
53
+ id: o,
54
+ shape: l,
55
+ description: w.sanitizeText(o, g()),
56
+ classes: `${a} ${St}`
57
+ });
58
+ const s = y[o];
59
+ t.description && (Array.isArray(s.description) ? (s.shape = C, s.description.push(t.description)) : s.description.length > 0 ? (s.shape = C, s.description === o ? s.description = [t.description] : s.description = [s.description, t.description]) : (s.shape = A, s.description = t.description), s.description = w.sanitizeTextOrArray(s.description, g())), s.description.length === 1 && s.shape === C && (s.shape = A), !s.type && t.doc && (d.info("Setting cluster for ", o, G(t)), s.type = "group", s.dir = G(t), s.shape = t.type === j ? rt : lt, s.classes = s.classes + " " + ft + " " + (r ? ht : ""));
60
+ const _ = {
61
+ labelStyle: "",
62
+ shape: s.shape,
63
+ labelText: s.description,
64
+ // typeof newNode.description === 'object'
65
+ // ? newNode.description[0]
66
+ // : newNode.description,
67
+ classes: s.classes,
68
+ style: "",
69
+ //styles.style,
70
+ id: o,
71
+ dir: s.dir,
72
+ domId: R(o, T),
73
+ type: s.type,
74
+ padding: 15
75
+ //getConfig().flowchart.padding
76
+ };
77
+ if (_.centerLabel = !0, t.note) {
78
+ const E = {
79
+ labelStyle: "",
80
+ shape: at,
81
+ labelText: t.note.text,
82
+ classes: ut,
83
+ // useHtmlLabels: false,
84
+ style: "",
85
+ // styles.style,
86
+ id: o + yt + "-" + T,
87
+ domId: R(o, T, W),
88
+ type: s.type,
89
+ padding: 15
90
+ //getConfig().flowchart.padding
91
+ }, S = {
92
+ labelStyle: "",
93
+ shape: dt,
94
+ labelText: t.note.text,
95
+ classes: s.classes,
96
+ style: "",
97
+ // styles.style,
98
+ id: o + H,
99
+ domId: R(o, T, Y),
100
+ type: "group",
101
+ padding: 0
102
+ //getConfig().flowchart.padding
103
+ };
104
+ T++;
105
+ const D = o + H;
106
+ e.setNode(D, S), e.setNode(E.id, E), e.setNode(o, _), e.setParent(o, D), e.setParent(E.id, D);
107
+ let p = o, f = E.id;
108
+ t.note.position === "left of" && (p = E.id, f = o), e.setEdge(p, f, {
109
+ arrowhead: "none",
110
+ arrowType: "",
111
+ style: z,
112
+ labelStyle: "",
113
+ classes: _t,
114
+ arrowheadStyle: m,
115
+ labelpos: q,
116
+ labelType: K,
117
+ thickness: J
118
+ });
119
+ } else
120
+ e.setNode(o, _);
121
+ }
122
+ n && n.id !== "root" && (d.trace("Setting node ", o, " to be child of its parent ", n.id), e.setParent(o, n.id)), t.doc && (d.trace("Adding nodes children "), Ct(e, t, t.doc, c, i, !r));
123
+ }, Ct = (e, n, t, c, i, r) => {
124
+ d.trace("items", t), t.forEach((o) => {
125
+ switch (o.stmt) {
126
+ case I:
127
+ h(e, n, o, c, i, r);
128
+ break;
129
+ case U:
130
+ h(e, n, o, c, i, r);
131
+ break;
132
+ case F:
133
+ {
134
+ h(e, n, o.state1, c, i, r), h(e, n, o.state2, c, i, r);
135
+ const a = {
136
+ id: "edge" + T,
137
+ arrowhead: "normal",
138
+ arrowTypeEnd: "arrow_barb",
139
+ style: z,
140
+ labelStyle: "",
141
+ label: w.sanitizeText(o.description, g()),
142
+ arrowheadStyle: m,
143
+ labelpos: q,
144
+ labelType: K,
145
+ thickness: J,
146
+ classes: V
147
+ };
148
+ e.setEdge(o.state1.id, o.state2.id, a, T), T++;
149
+ }
150
+ break;
151
+ }
152
+ });
153
+ }, G = (e, n = tt) => {
154
+ let t = n;
155
+ if (e.doc)
156
+ for (let c = 0; c < e.doc.length; c++) {
157
+ const i = e.doc[c];
158
+ i.stmt === "dir" && (t = i.value);
159
+ }
160
+ return t;
161
+ }, Rt = function(e, n, t, c) {
162
+ return B(this, null, function* () {
163
+ d.info("Drawing state diagram (v2)", n), y = {}, c.db.getDirection();
164
+ const { securityLevel: i, state: r } = g(), o = r.nodeSpacing || 50, a = r.rankSpacing || 50;
165
+ d.info(c.db.getRootDocV2()), c.db.extract(c.db.getRootDocV2()), d.info(c.db.getRootDocV2());
166
+ const l = c.db.getStates(), s = new et({
167
+ multigraph: !0,
168
+ compound: !0
169
+ }).setGraph({
170
+ rankdir: G(c.db.getRootDocV2()),
171
+ nodesep: o,
172
+ ranksep: a,
173
+ marginx: 8,
174
+ marginy: 8
175
+ }).setDefaultEdgeLabel(function() {
176
+ return {};
177
+ });
178
+ h(s, void 0, c.db.getRootDocV2(), l, c.db, !0);
179
+ let _;
180
+ i === "sandbox" && (_ = x("#i" + n));
181
+ const E = i === "sandbox" ? x(_.nodes()[0].contentDocument.body) : x("body"), S = E.select(`[id="${n}"]`), D = E.select("#" + n + " g");
182
+ yield nt(D, s, ["barb"], u, n);
183
+ const p = 8;
184
+ ot.insertTitle(S, "statediagramTitleText", r.titleTopMargin, c.db.getDiagramTitle());
185
+ const f = S.node().getBBox(), L = f.width + p * 2, P = f.height + p * 2;
186
+ S.attr("class", u);
187
+ const k = S.node().getBBox();
188
+ st(S, P, L, r.useMaxWidth);
189
+ const v = `${k.x - p} ${k.y - p} ${L} ${P}`;
190
+ d.debug(`viewBox ${v}`), S.attr("viewBox", v);
191
+ const Q = document.querySelectorAll('[id="' + n + '"] .edgeLabel .label');
192
+ for (const $ of Q) {
193
+ const O = $.getBBox(), b = document.createElementNS("http://www.w3.org/2000/svg", A);
194
+ b.setAttribute("rx", 0), b.setAttribute("ry", 0), b.setAttribute("width", O.width), b.setAttribute("height", O.height), $.insertBefore(b, $.firstChild);
195
+ }
196
+ });
197
+ }, wt = {
198
+ setConf: gt,
199
+ getClasses: $t,
200
+ draw: Rt
201
+ }, Vt = {
202
+ parser: X,
203
+ db: M,
204
+ renderer: wt,
205
+ styles: Z,
206
+ init: (e) => {
207
+ e.state || (e.state = {}), e.state.arrowMarkerAbsolute = e.arrowMarkerAbsolute, M.clear();
208
+ }
209
+ };
210
+ export {
211
+ Vt as diagram
212
+ };