lowcoder-comps 0.0.7 → 0.0.8

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.
Files changed (79) hide show
  1. package/icons/icon-chart.svg +15 -0
  2. package/icons/icon-comp-calendar.svg +22 -0
  3. package/index.html +26 -0
  4. package/index.tsx +19 -0
  5. package/jest.config.js +5 -0
  6. package/package/012a06bb.js +34 -0
  7. package/package/06481cb7.js +1060 -0
  8. package/package/0c8b29d5.js +6 -0
  9. package/package/114884df.js +805 -0
  10. package/package/1264ddb2.js +194 -0
  11. package/package/1cee31ec.js +1095 -0
  12. package/package/269c3ba3.js +46662 -0
  13. package/package/2a2c2e55.js +799 -0
  14. package/package/2b3ab1e4.js +98763 -0
  15. package/package/37590a81.js +967 -0
  16. package/package/3cd7980e.js +184 -0
  17. package/package/40112498.js +424 -0
  18. package/package/4b6e1d6f.js +24 -0
  19. package/package/4bc1082b.js +86 -0
  20. package/package/53e49f9b.js +1600 -0
  21. package/package/55bd5c26.js +266 -0
  22. package/package/591684c8.js +2071 -0
  23. package/package/6c000872.js +16 -0
  24. package/package/756addec.js +775 -0
  25. package/package/7668124e.js +8 -0
  26. package/package/79e8eeeb.js +949 -0
  27. package/package/926fbfec.js +91 -0
  28. package/package/945eefb3.js +2665 -0
  29. package/package/a35f148e.js +1228 -0
  30. package/package/a4d12a43.js +175 -0
  31. package/package/a60de5d1.js +804 -0
  32. package/package/a8dde1ea.js +589 -0
  33. package/package/b4148642.js +7 -0
  34. package/package/b7dd22a2.js +847 -0
  35. package/package/d4f3a2c4.js +18046 -0
  36. package/package/e0f479f3.js +91 -0
  37. package/package/eaa160c9.js +341 -0
  38. package/package/f1bfd8b5.js +311 -0
  39. package/package/f1f9ba79.js +900 -0
  40. package/package/fba61f63.js +2868 -0
  41. package/package/icons/icon-chart.svg +15 -0
  42. package/package/icons/icon-comp-calendar.svg +22 -0
  43. package/package/index.js +5 -0
  44. package/package/package.json +73 -0
  45. package/package.json +1 -4
  46. package/src/__test__/allComp.test.tsx +61 -0
  47. package/src/app-env.d.ts +3 -0
  48. package/src/comps/calendarComp/calendarComp.tsx +442 -0
  49. package/src/comps/calendarComp/calendarConstants.tsx +897 -0
  50. package/src/comps/chartComp/chartComp.tsx +249 -0
  51. package/src/comps/chartComp/chartConfigs/barChartConfig.tsx +51 -0
  52. package/src/comps/chartComp/chartConfigs/cartesianAxisConfig.tsx +307 -0
  53. package/src/comps/chartComp/chartConfigs/chartUrls.tsx +6 -0
  54. package/src/comps/chartComp/chartConfigs/legendConfig.tsx +55 -0
  55. package/src/comps/chartComp/chartConfigs/lineChartConfig.tsx +96 -0
  56. package/src/comps/chartComp/chartConfigs/pieChartConfig.tsx +83 -0
  57. package/src/comps/chartComp/chartConfigs/scatterChartConfig.tsx +62 -0
  58. package/src/comps/chartComp/chartConstants.tsx +243 -0
  59. package/src/comps/chartComp/chartPropertyView.tsx +161 -0
  60. package/src/comps/chartComp/chartUtils.ts +240 -0
  61. package/src/comps/chartComp/reactEcharts/core.tsx +187 -0
  62. package/src/comps/chartComp/reactEcharts/index.ts +20 -0
  63. package/src/comps/chartComp/reactEcharts/types.ts +70 -0
  64. package/src/comps/chartComp/seriesComp.tsx +119 -0
  65. package/src/comps/imageEditorComp/imageEditorClass.tsx +52 -0
  66. package/src/comps/imageEditorComp/imageEditorConstants.tsx +109 -0
  67. package/src/comps/imageEditorComp/index.tsx +184 -0
  68. package/src/comps/mermaidComp/index.tsx +44 -0
  69. package/src/comps/mermaidComp/mermaid.tsx +29 -0
  70. package/src/global.ts +1 -0
  71. package/src/i18n/comps/index.tsx +29 -0
  72. package/src/i18n/comps/locales/en.ts +142 -0
  73. package/src/i18n/comps/locales/enObj.tsx +120 -0
  74. package/src/i18n/comps/locales/index.ts +7 -0
  75. package/src/i18n/comps/locales/types.tsx +9 -0
  76. package/src/i18n/comps/locales/zh.ts +4 -0
  77. package/src/i18n/comps/locales/zhObj.tsx +4 -0
  78. package/src/index.ts +11 -0
  79. package/vite.config.js +10 -0
@@ -0,0 +1,266 @@
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
+ };