@nice2dev/ui 1.4.5 → 1.4.7

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 (36) hide show
  1. package/CHANGELOG.md +76 -0
  2. package/dist/{NiceDataGrid-mrnaLHQk.cjs → NiceDataGrid-D3qRQSjy.cjs} +1 -1
  3. package/dist/NiceForm-BWb4LTQJ.cjs +1 -0
  4. package/dist/{NiceHtmlEditor-C1OVtLQ6.cjs → NiceHtmlEditor-BzECmDO3.cjs} +1 -1
  5. package/dist/{NiceMention-tgJKS8PH.cjs → NiceMention-CYRqPKGU.cjs} +19 -19
  6. package/dist/NiceModuleLifecyclePanel-CiYbPcHV.cjs +1 -0
  7. package/dist/{NicePagination-D7XxeNFz.cjs → NicePagination-BAxwqeEd.cjs} +1 -1
  8. package/dist/{NicePivotGrid-Cnkr9WkC.cjs → NicePivotGrid-Cxu5PECg.cjs} +1 -1
  9. package/dist/{NiceSavedQueryPanel-U1-yaw-Q.cjs → NiceSavedQueryPanel-BSZhE-_l.cjs} +6 -6
  10. package/dist/{NiceScheduler-Boo-D1S-.cjs → NiceScheduler-BqYiHPvz.cjs} +1 -1
  11. package/dist/{core-lazy-C_qnVGxE.cjs → core-lazy-BQexApr7.cjs} +1 -1
  12. package/dist/data.cjs +1 -1
  13. package/dist/database/NiceDataSourceEditor.mjs +370 -0
  14. package/dist/database/NiceQueryDesigner.mjs +958 -0
  15. package/dist/database/moduleDataSource.mjs +151 -0
  16. package/dist/database/queryDesign.mjs +396 -0
  17. package/dist/database/queryDesignerPanels.mjs +1214 -0
  18. package/dist/database/querySql.mjs +481 -0
  19. package/dist/editors.cjs +1 -1
  20. package/dist/index.cjs +188 -181
  21. package/dist/index.d.ts +674 -0
  22. package/dist/index.mjs +774 -720
  23. package/dist/lazy.cjs +1 -1
  24. package/dist/navigation.cjs +1 -1
  25. package/dist/no-code/NiceNoCodeScriptEditor.mjs +584 -0
  26. package/dist/no-code/noCodeScript.mjs +326 -0
  27. package/dist/no-code-B1jzfUF5.cjs +331 -0
  28. package/dist/no-code.cjs +1 -1
  29. package/dist/no-code.d.ts +177 -0
  30. package/dist/no-code.mjs +26 -16
  31. package/dist/style.css +2 -2
  32. package/package.json +4 -4
  33. package/dist/NiceForm-O3sv-DNX.cjs +0 -1
  34. package/dist/NiceModuleLifecyclePanel-DKlqKPy2.cjs +0 -1
  35. package/dist/NiceSelect-BNPXs6FQ.cjs +0 -1
  36. package/dist/no-code-B3BHeyG-.cjs +0 -331
@@ -0,0 +1,326 @@
1
+ const O = [
2
+ "read",
3
+ "filter",
4
+ "map",
5
+ "aggregate",
6
+ "set",
7
+ "if",
8
+ "forEach",
9
+ "write",
10
+ "callScript",
11
+ "return"
12
+ ], $ = ["&&", "||", "==", "!=", ">=", "<=", ">", "<", "+", "-", "*", "/", "!", "(", ")"];
13
+ function N(i) {
14
+ const s = [];
15
+ let o = 0;
16
+ for (; o < i.length; ) {
17
+ const u = i[o];
18
+ if (/\s/.test(u)) {
19
+ o++;
20
+ continue;
21
+ }
22
+ if (/[0-9]/.test(u) || u === "." && /[0-9]/.test(i[o + 1] ?? "")) {
23
+ let r = o;
24
+ for (; r < i.length && /[0-9.]/.test(i[r]); )
25
+ r++;
26
+ s.push({ t: "num", v: Number(i.slice(o, r)) }), o = r;
27
+ continue;
28
+ }
29
+ if (u === "'" || u === '"') {
30
+ let r = o + 1, c = "";
31
+ for (; r < i.length && i[r] !== u; )
32
+ c += i[r] === "\\" && r + 1 < i.length ? i[++r] : i[r], r++;
33
+ if (r >= i.length)
34
+ throw new Error("unterminated string");
35
+ s.push({ t: "str", v: c }), o = r + 1;
36
+ continue;
37
+ }
38
+ if (/[A-Za-z_$]/.test(u)) {
39
+ let r = o;
40
+ for (; r < i.length && /[A-Za-z0-9_$.]/.test(i[r]); )
41
+ r++;
42
+ s.push({ t: "id", v: i.slice(o, r) }), o = r;
43
+ continue;
44
+ }
45
+ const t = $.find((r) => i.startsWith(r, o));
46
+ if (!t)
47
+ throw new Error(`unexpected "${u}"`);
48
+ s.push({ t: "op", v: t }), o += t.length;
49
+ }
50
+ return s;
51
+ }
52
+ function k(i, s) {
53
+ let o = i;
54
+ for (const u of s.split(".")) {
55
+ if (o == null)
56
+ return;
57
+ o = o[u];
58
+ }
59
+ return o;
60
+ }
61
+ const d = (i) => typeof i == "number" ? i : Number(i);
62
+ function b(i, s) {
63
+ const o = N(i);
64
+ let u = 0;
65
+ const t = () => o[u], r = (n) => {
66
+ const p = o[u];
67
+ if (!p || n !== void 0 && !(p.t === "op" && p.v === n))
68
+ throw new Error(n ? `expected "${n}"` : "unexpected end");
69
+ return u++, p;
70
+ }, c = (n) => t()?.t === "op" && t()?.v === n, e = () => {
71
+ const n = r();
72
+ if (n.t === "num")
73
+ return n.v;
74
+ if (n.t === "str")
75
+ return n.v.includes("{{") ? n.v.replace(/\{\{\s*([A-Za-z0-9_$.]+)\s*\}\}/g, (p, m) => {
76
+ const y = k(s, m);
77
+ return y == null ? "" : String(y);
78
+ }) : n.v;
79
+ if (n.t === "id")
80
+ return n.v === "true" ? !0 : n.v === "false" ? !1 : n.v === "null" ? null : k(s, n.v);
81
+ if (n.v === "(") {
82
+ const p = h();
83
+ return r(")"), p;
84
+ }
85
+ if (n.v === "-")
86
+ return -d(e());
87
+ if (n.v === "!")
88
+ return !e();
89
+ throw new Error(`unexpected "${n.v}"`);
90
+ }, l = () => {
91
+ let n = e();
92
+ for (; c("*") || c("/"); ) {
93
+ const p = r().v, m = e();
94
+ n = p === "*" ? d(n) * d(m) : d(n) / d(m);
95
+ }
96
+ return n;
97
+ }, f = () => {
98
+ let n = l();
99
+ for (; c("+") || c("-"); ) {
100
+ const p = r().v, m = l();
101
+ n = p === "+" ? typeof n == "string" || typeof m == "string" ? `${n ?? ""}${m ?? ""}` : d(n) + d(m) : d(n) - d(m);
102
+ }
103
+ return n;
104
+ }, v = () => {
105
+ let n = f();
106
+ for (; ["==", "!=", ">=", "<=", ">", "<"].some(c); ) {
107
+ const p = String(r().v), m = f();
108
+ n = w(n, p, m);
109
+ }
110
+ return n;
111
+ }, a = () => {
112
+ let n = v();
113
+ for (; c("&&"); ) {
114
+ r();
115
+ const p = v();
116
+ n = !!n && !!p;
117
+ }
118
+ return n;
119
+ };
120
+ function h() {
121
+ let n = a();
122
+ for (; c("||"); ) {
123
+ r();
124
+ const p = a();
125
+ n = !!n || !!p;
126
+ }
127
+ return n;
128
+ }
129
+ if (o.length === 0)
130
+ return;
131
+ const g = h();
132
+ if (u < o.length)
133
+ throw new Error(`unexpected "${String(o[u].v)}"`);
134
+ return g;
135
+ }
136
+ function x(i, s) {
137
+ return i == null || s === null || s === void 0 ? i == null && s == null : typeof i == typeof s ? i === s : typeof i == "number" || typeof s == "number" ? d(i) === d(s) : String(i) === String(s);
138
+ }
139
+ function w(i, s, o) {
140
+ switch (s) {
141
+ case "==":
142
+ return x(i, o);
143
+ case "!=":
144
+ return !x(i, o);
145
+ case ">":
146
+ return d(i) > d(o);
147
+ case ">=":
148
+ return d(i) >= d(o);
149
+ case "<":
150
+ return d(i) < d(o);
151
+ default:
152
+ return d(i) <= d(o);
153
+ }
154
+ }
155
+ function S(i, s, o) {
156
+ return (i ?? []).every((u) => {
157
+ const t = k(s, u.field);
158
+ if (u.op === "empty")
159
+ return t == null || t === "";
160
+ if (u.op === "notEmpty")
161
+ return !(t == null || t === "");
162
+ const r = b(u.value ?? "", { ...o, ...s });
163
+ switch (u.op) {
164
+ case "eq":
165
+ return w(t, "==", r);
166
+ case "neq":
167
+ return w(t, "!=", r);
168
+ case "gt":
169
+ return w(t, ">", r);
170
+ case "gte":
171
+ return w(t, ">=", r);
172
+ case "lt":
173
+ return w(t, "<", r);
174
+ case "lte":
175
+ return w(t, "<=", r);
176
+ case "contains":
177
+ return String(t ?? "").toLowerCase().includes(String(r ?? "").toLowerCase());
178
+ }
179
+ return !1;
180
+ });
181
+ }
182
+ function _(i) {
183
+ const s = [], o = /* @__PURE__ */ new Set(), u = (c, e, l) => {
184
+ if (!(e === void 0 || e.trim() === ""))
185
+ try {
186
+ b(e, {});
187
+ } catch (f) {
188
+ s.push({ stepId: c, message: `${l}: ${f.message}` });
189
+ }
190
+ }, t = (c, e, l) => {
191
+ (!e || !e.trim()) && s.push({ stepId: c, message: `${l} is required` });
192
+ }, r = (c) => {
193
+ for (const e of c) {
194
+ o.has(e.id) && s.push({ stepId: e.id, message: `duplicate step id ${e.id}` }), o.add(e.id);
195
+ const l = (f) => f?.forEach((v) => {
196
+ t(e.id, v.field, "condition field"), u(e.id, v.value, "condition value");
197
+ });
198
+ switch (e.type) {
199
+ case "read":
200
+ t(e.id, e.source, "source"), t(e.id, e.into, "variable"), l(e.where);
201
+ break;
202
+ case "filter":
203
+ t(e.id, e.from, "input"), t(e.id, e.into, "variable"), l(e.where);
204
+ break;
205
+ case "map":
206
+ t(e.id, e.from, "input"), t(e.id, e.into, "variable"), e.fields.forEach((f) => {
207
+ t(e.id, f.target, "target field"), u(e.id, f.expression, `field ${f.target}`);
208
+ });
209
+ break;
210
+ case "aggregate":
211
+ t(e.id, e.from, "input"), t(e.id, e.into, "variable"), e.measures.forEach((f) => t(e.id, f.name, "measure name"));
212
+ break;
213
+ case "set":
214
+ t(e.id, e.variable, "variable"), u(e.id, e.expression, "value");
215
+ break;
216
+ case "if":
217
+ l(e.when), r(e.then), r(e.else ?? []);
218
+ break;
219
+ case "forEach":
220
+ t(e.id, e.from, "input"), t(e.id, e.as, "item variable"), r(e.steps);
221
+ break;
222
+ case "write":
223
+ t(e.id, e.target, "target"), t(e.id, e.from, "input");
224
+ break;
225
+ case "callScript":
226
+ t(e.id, e.script, "script"), Object.entries(e.args ?? {}).forEach(([f, v]) => u(e.id, v, `argument ${f}`));
227
+ break;
228
+ case "return":
229
+ u(e.id, e.expression, "value");
230
+ break;
231
+ }
232
+ }
233
+ };
234
+ return r(i.steps), s;
235
+ }
236
+ const E = Symbol("returned");
237
+ async function A(i, s, o = {}, u = {}) {
238
+ const t = { ...o }, r = [], c = u.maxSteps ?? 1e4;
239
+ let e;
240
+ const l = (v) => {
241
+ const a = k(t, v);
242
+ return Array.isArray(a) ? a : [];
243
+ }, f = async (v) => {
244
+ for (const a of v) {
245
+ if (r.length >= c)
246
+ throw new Error(`more than ${c} steps — stopped`);
247
+ switch (r.push(a.id), a.type) {
248
+ case "read": {
249
+ const h = await s.read(a.source);
250
+ t[a.into] = h.filter((g) => S(a.where, g, t));
251
+ break;
252
+ }
253
+ case "filter":
254
+ t[a.into] = l(a.from).filter(
255
+ (h) => S(a.where, h, t)
256
+ );
257
+ break;
258
+ case "map":
259
+ t[a.into] = l(a.from).map((h) => {
260
+ const g = {};
261
+ for (const n of a.fields)
262
+ g[n.target] = b(n.expression, { ...t, ...h });
263
+ return g;
264
+ });
265
+ break;
266
+ case "aggregate":
267
+ t[a.into] = C(l(a.from), a.groupBy ?? [], a.measures);
268
+ break;
269
+ case "set":
270
+ t[a.variable] = b(a.expression, t);
271
+ break;
272
+ case "if": {
273
+ const h = S(a.when, t, t) ? a.then : a.else ?? [];
274
+ if (await f(h) === E)
275
+ return E;
276
+ break;
277
+ }
278
+ case "forEach":
279
+ for (const h of l(a.from))
280
+ if (t[a.as] = h, await f(a.steps) === E)
281
+ return E;
282
+ break;
283
+ case "write":
284
+ await s.write?.(a.target, l(a.from), a.mode ?? "insert");
285
+ break;
286
+ case "callScript": {
287
+ const h = {};
288
+ for (const [n, p] of Object.entries(a.args ?? {}))
289
+ h[n] = b(p, t);
290
+ const g = await s.callScript?.(a.script, h);
291
+ a.into && (t[a.into] = g);
292
+ break;
293
+ }
294
+ case "return":
295
+ return e = b(a.expression, t), E;
296
+ }
297
+ }
298
+ };
299
+ return await f(i.steps), { value: e, variables: t, trace: r };
300
+ }
301
+ function C(i, s, o) {
302
+ const u = /* @__PURE__ */ new Map();
303
+ for (const t of i) {
304
+ const r = JSON.stringify(s.map((c) => k(t, c)));
305
+ u.set(r, [...u.get(r) ?? [], t]);
306
+ }
307
+ return u.size === 0 && s.length === 0 && u.set("[]", []), [...u.values()].map((t) => {
308
+ const r = {};
309
+ s.forEach((c) => {
310
+ r[c] = k(t[0] ?? {}, c);
311
+ });
312
+ for (const c of o) {
313
+ const e = t.map((l) => d(k(l, c.field ?? ""))).filter((l) => !Number.isNaN(l));
314
+ r[c.name] = c.op === "count" ? t.length : c.op === "sum" ? e.reduce((l, f) => l + f, 0) : c.op === "avg" ? e.length ? e.reduce((l, f) => l + f, 0) / e.length : 0 : c.op === "min" ? e.length ? Math.min(...e) : void 0 : e.length ? Math.max(...e) : void 0;
315
+ }
316
+ return r;
317
+ });
318
+ }
319
+ export {
320
+ O as NICE_NO_CODE_STEP_TYPES,
321
+ b as evaluateNoCodeExpression,
322
+ S as noCodeConditionsHold,
323
+ k as noCodePath,
324
+ A as runNoCodeScript,
325
+ _ as validateNoCodeScript
326
+ };