@nice2dev/ui 1.4.4 → 1.4.6
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/CHANGELOG.md +59 -0
- package/dist/{NiceDataGrid-mrnaLHQk.cjs → NiceDataGrid-D3qRQSjy.cjs} +1 -1
- package/dist/NiceForm-BWb4LTQJ.cjs +1 -0
- package/dist/{NiceHtmlEditor-C1OVtLQ6.cjs → NiceHtmlEditor-BzECmDO3.cjs} +1 -1
- package/dist/{NiceMention-tgJKS8PH.cjs → NiceMention-CYRqPKGU.cjs} +19 -19
- package/dist/NiceModuleLifecyclePanel-CiYbPcHV.cjs +1 -0
- package/dist/{NicePagination-D7XxeNFz.cjs → NicePagination-BAxwqeEd.cjs} +1 -1
- package/dist/{NicePivotGrid-Cnkr9WkC.cjs → NicePivotGrid-Cxu5PECg.cjs} +1 -1
- package/dist/NiceSavedQueryPanel-BSZhE-_l.cjs +587 -0
- package/dist/{NiceScheduler-Boo-D1S-.cjs → NiceScheduler-BqYiHPvz.cjs} +1 -1
- package/dist/{core-lazy-C_qnVGxE.cjs → core-lazy-BQexApr7.cjs} +1 -1
- package/dist/data/NiceTreeGrid.mjs +519 -458
- package/dist/data.cjs +1 -1
- package/dist/data.d.ts +20 -1
- package/dist/editors.cjs +1 -1
- package/dist/index.cjs +98 -98
- package/dist/index.d.ts +197 -1
- package/dist/index.mjs +303 -293
- package/dist/lazy.cjs +1 -1
- package/dist/navigation.cjs +1 -1
- package/dist/no-code/NiceNoCodeScriptEditor.mjs +584 -0
- package/dist/no-code/noCodeScript.mjs +326 -0
- package/dist/no-code-B1jzfUF5.cjs +331 -0
- package/dist/no-code.cjs +1 -1
- package/dist/no-code.d.ts +177 -0
- package/dist/no-code.mjs +26 -16
- package/dist/style.css +2 -2
- package/package.json +4 -4
- package/dist/NiceForm-O3sv-DNX.cjs +0 -1
- package/dist/NiceModuleLifecyclePanel-DKlqKPy2.cjs +0 -1
- package/dist/NiceSavedQueryPanel-BPGpKWN2.cjs +0 -587
- package/dist/NiceSelect-BNPXs6FQ.cjs +0 -1
- package/dist/no-code-B3BHeyG-.cjs +0 -331
|
@@ -0,0 +1,584 @@
|
|
|
1
|
+
import { jsxs as c, jsx as o, Fragment as E } from "react/jsx-runtime";
|
|
2
|
+
import { useNiceTranslation as L, useControllableState as H, NiceIcon as $ } from "@nice2dev/ui-core";
|
|
3
|
+
import { useState as j, useMemo as K } from "react";
|
|
4
|
+
import { NiceSelect as M } from "../editors/inputs/NiceSelect.mjs";
|
|
5
|
+
import { NiceTextInput as T } from "../editors/inputs/NiceTextInput.mjs";
|
|
6
|
+
import { validateNoCodeScript as Q, NICE_NO_CODE_STEP_TYPES as W, runNoCodeScript as Z } from "./noCodeScript.mjs";
|
|
7
|
+
/* empty css */
|
|
8
|
+
const O = {
|
|
9
|
+
read: "database",
|
|
10
|
+
filter: "filter",
|
|
11
|
+
map: "shuffle",
|
|
12
|
+
aggregate: "bar-chart",
|
|
13
|
+
set: "edit",
|
|
14
|
+
if: "git-branch",
|
|
15
|
+
forEach: "repeat",
|
|
16
|
+
write: "save",
|
|
17
|
+
callScript: "code",
|
|
18
|
+
return: "arrow-left"
|
|
19
|
+
}, ee = [
|
|
20
|
+
"eq",
|
|
21
|
+
"neq",
|
|
22
|
+
"gt",
|
|
23
|
+
"gte",
|
|
24
|
+
"lt",
|
|
25
|
+
"lte",
|
|
26
|
+
"contains",
|
|
27
|
+
"empty",
|
|
28
|
+
"notEmpty"
|
|
29
|
+
], G = {
|
|
30
|
+
eq: "=",
|
|
31
|
+
neq: "≠",
|
|
32
|
+
gt: ">",
|
|
33
|
+
gte: "≥",
|
|
34
|
+
lt: "<",
|
|
35
|
+
lte: "≤",
|
|
36
|
+
contains: "∋",
|
|
37
|
+
empty: "∅",
|
|
38
|
+
notEmpty: "≠ ∅"
|
|
39
|
+
};
|
|
40
|
+
let ne = 0;
|
|
41
|
+
const oe = (e) => `${e}-${Date.now().toString(36)}-${(ne++).toString(36)}`;
|
|
42
|
+
function te(e) {
|
|
43
|
+
const t = oe(e);
|
|
44
|
+
switch (e) {
|
|
45
|
+
case "read":
|
|
46
|
+
return { id: t, type: e, source: "", into: "rows" };
|
|
47
|
+
case "filter":
|
|
48
|
+
return { id: t, type: e, from: "rows", where: [], into: "rows" };
|
|
49
|
+
case "map":
|
|
50
|
+
return { id: t, type: e, from: "rows", fields: [], into: "rows" };
|
|
51
|
+
case "aggregate":
|
|
52
|
+
return { id: t, type: e, from: "rows", groupBy: [], measures: [], into: "totals" };
|
|
53
|
+
case "set":
|
|
54
|
+
return { id: t, type: e, variable: "", expression: "" };
|
|
55
|
+
case "if":
|
|
56
|
+
return { id: t, type: e, when: [], then: [], else: [] };
|
|
57
|
+
case "forEach":
|
|
58
|
+
return { id: t, type: e, from: "rows", as: "row", steps: [] };
|
|
59
|
+
case "write":
|
|
60
|
+
return { id: t, type: e, target: "", from: "rows", mode: "insert" };
|
|
61
|
+
case "callScript":
|
|
62
|
+
return { id: t, type: e, script: "", args: {} };
|
|
63
|
+
case "return":
|
|
64
|
+
return { id: t, type: e, expression: "" };
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
const P = (e) => e.type === "if" ? ["then", "else"] : e.type === "forEach" ? ["steps"] : [];
|
|
68
|
+
function q(e, t, l) {
|
|
69
|
+
const u = [];
|
|
70
|
+
for (const s of e) {
|
|
71
|
+
if (s.id === t) {
|
|
72
|
+
l && u.push(l);
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
let p = s;
|
|
76
|
+
for (const a of P(s)) {
|
|
77
|
+
const n = s[a];
|
|
78
|
+
n && (p = { ...p, [a]: q(n, t, l) });
|
|
79
|
+
}
|
|
80
|
+
u.push(p);
|
|
81
|
+
}
|
|
82
|
+
return u;
|
|
83
|
+
}
|
|
84
|
+
function J(e, t, l) {
|
|
85
|
+
if (!l.afterId && !l.parentId)
|
|
86
|
+
return [...e, t];
|
|
87
|
+
const u = [];
|
|
88
|
+
for (const s of e) {
|
|
89
|
+
let p = s;
|
|
90
|
+
if (s.id === l.parentId && l.branch) {
|
|
91
|
+
const a = s[l.branch] ?? [];
|
|
92
|
+
p = { ...p, [l.branch]: [...a, t] };
|
|
93
|
+
} else
|
|
94
|
+
for (const a of P(s)) {
|
|
95
|
+
const n = s[a];
|
|
96
|
+
n && (p = { ...p, [a]: J(n, t, l) });
|
|
97
|
+
}
|
|
98
|
+
u.push(p), s.id === l.afterId && u.push(t);
|
|
99
|
+
}
|
|
100
|
+
return u;
|
|
101
|
+
}
|
|
102
|
+
function U(e, t, l) {
|
|
103
|
+
const u = e.findIndex((s) => s.id === t);
|
|
104
|
+
if (u >= 0) {
|
|
105
|
+
const s = u + l;
|
|
106
|
+
if (s < 0 || s >= e.length)
|
|
107
|
+
return [...e];
|
|
108
|
+
const p = [...e];
|
|
109
|
+
return [p[u], p[s]] = [p[s], p[u]], p;
|
|
110
|
+
}
|
|
111
|
+
return e.map((s) => {
|
|
112
|
+
let p = s;
|
|
113
|
+
for (const a of P(s)) {
|
|
114
|
+
const n = s[a];
|
|
115
|
+
n && (p = { ...p, [a]: U(n, t, l) });
|
|
116
|
+
}
|
|
117
|
+
return p;
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
function X(e, t) {
|
|
121
|
+
for (const l of e) {
|
|
122
|
+
if (l.id === t)
|
|
123
|
+
return l;
|
|
124
|
+
for (const u of P(l)) {
|
|
125
|
+
const s = X(l[u] ?? [], t);
|
|
126
|
+
if (s)
|
|
127
|
+
return s;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
function ie(e) {
|
|
132
|
+
switch (e.type) {
|
|
133
|
+
case "read":
|
|
134
|
+
return `${e.source || "?"} → ${e.into}`;
|
|
135
|
+
case "filter":
|
|
136
|
+
return `${e.from} (${e.where.length}) → ${e.into}`;
|
|
137
|
+
case "map":
|
|
138
|
+
return `${e.from} → ${e.into} (${e.fields.length})`;
|
|
139
|
+
case "aggregate":
|
|
140
|
+
return `${e.from} → ${e.into}`;
|
|
141
|
+
case "set":
|
|
142
|
+
return `${e.variable || "?"} = ${e.expression}`;
|
|
143
|
+
case "if":
|
|
144
|
+
return `${e.when.map((t) => `${t.field} ${G[t.op]} ${t.value ?? ""}`).join(", ")}`;
|
|
145
|
+
case "forEach":
|
|
146
|
+
return `${e.as} ∈ ${e.from}`;
|
|
147
|
+
case "write":
|
|
148
|
+
return `${e.from} → ${e.target || "?"} (${e.mode ?? "insert"})`;
|
|
149
|
+
case "callScript":
|
|
150
|
+
return `${e.script || "?"}${e.into ? ` → ${e.into}` : ""}`;
|
|
151
|
+
case "return":
|
|
152
|
+
return e.expression;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
const ue = ({
|
|
156
|
+
value: e,
|
|
157
|
+
defaultValue: t,
|
|
158
|
+
onChange: l,
|
|
159
|
+
dataSources: u = [],
|
|
160
|
+
scripts: s = [],
|
|
161
|
+
io: p,
|
|
162
|
+
readOnly: a = !1,
|
|
163
|
+
className: n,
|
|
164
|
+
style: z,
|
|
165
|
+
id: f,
|
|
166
|
+
"data-testid": R
|
|
167
|
+
}) => {
|
|
168
|
+
const { t: g } = L(), [N, I] = H({
|
|
169
|
+
value: e,
|
|
170
|
+
defaultValue: t,
|
|
171
|
+
fallbackValue: { steps: [] },
|
|
172
|
+
onChange: l,
|
|
173
|
+
componentName: "NiceNoCodeScriptEditor"
|
|
174
|
+
}), [v, r] = j(null), [d, _] = j("read"), [h, w] = j(null), m = K(() => Q(N), [N]), C = new Set(m.map((i) => i.stepId)), b = v ? X(N.steps, v) : void 0, y = (i) => g(`noCode.step.${i}`, i), k = N.steps, V = (i) => I({ ...N, steps: i }), Y = (i) => V(q(k, i.id, i)), B = (i) => {
|
|
175
|
+
const x = te(d);
|
|
176
|
+
V(J(k, x, i)), r(x.id);
|
|
177
|
+
}, D = (i, x) => /* @__PURE__ */ o("ol", { className: "nice-nocode-script__list", style: { paddingLeft: x ? 16 : 0 }, children: i.map((S) => /* @__PURE__ */ c("li", { className: "nice-nocode-script__item", children: [
|
|
178
|
+
/* @__PURE__ */ c(
|
|
179
|
+
"button",
|
|
180
|
+
{
|
|
181
|
+
type: "button",
|
|
182
|
+
className: `nice-nocode-script__step${v === S.id ? " nice-nocode-script__step--selected" : ""}${C.has(S.id) ? " nice-nocode-script__step--issue" : ""}`,
|
|
183
|
+
"aria-pressed": v === S.id,
|
|
184
|
+
onClick: () => r(S.id),
|
|
185
|
+
children: [
|
|
186
|
+
/* @__PURE__ */ o($, { name: O[S.type], size: 14 }),
|
|
187
|
+
/* @__PURE__ */ o("span", { className: "nice-nocode-script__type", children: y(S.type) }),
|
|
188
|
+
/* @__PURE__ */ o("span", { className: "nice-nocode-script__summary", children: ie(S) }),
|
|
189
|
+
C.has(S.id) && /* @__PURE__ */ o($, { name: "warning", size: 12 })
|
|
190
|
+
]
|
|
191
|
+
}
|
|
192
|
+
),
|
|
193
|
+
P(S).map((A) => {
|
|
194
|
+
const F = S[A] ?? [];
|
|
195
|
+
return /* @__PURE__ */ c("div", { className: "nice-nocode-script__branch", children: [
|
|
196
|
+
/* @__PURE__ */ o("span", { className: "nice-nocode-script__branch-label", children: g(`noCode.branch.${A}`, A === "then" ? "Then" : A === "else" ? "Else" : "Steps") }),
|
|
197
|
+
F.length > 0 && D(F, x + 1)
|
|
198
|
+
] }, A);
|
|
199
|
+
})
|
|
200
|
+
] }, S.id)) });
|
|
201
|
+
return /* @__PURE__ */ c(
|
|
202
|
+
"div",
|
|
203
|
+
{
|
|
204
|
+
id: f,
|
|
205
|
+
className: `nice-nocode-script${n ? ` ${n}` : ""}`,
|
|
206
|
+
style: z,
|
|
207
|
+
"data-testid": R,
|
|
208
|
+
children: [
|
|
209
|
+
/* @__PURE__ */ c("div", { className: "nice-nocode-script__steps", children: [
|
|
210
|
+
!a && /* @__PURE__ */ c("div", { className: "nice-nocode-script__toolbar", children: [
|
|
211
|
+
/* @__PURE__ */ o(
|
|
212
|
+
M,
|
|
213
|
+
{
|
|
214
|
+
"aria-label": g("noCode.addStep", "Add step"),
|
|
215
|
+
value: d,
|
|
216
|
+
options: W.map((i) => ({
|
|
217
|
+
value: i,
|
|
218
|
+
label: y(i)
|
|
219
|
+
})),
|
|
220
|
+
onChange: (i) => _(String(i)),
|
|
221
|
+
size: "sm"
|
|
222
|
+
}
|
|
223
|
+
),
|
|
224
|
+
/* @__PURE__ */ c(
|
|
225
|
+
"button",
|
|
226
|
+
{
|
|
227
|
+
type: "button",
|
|
228
|
+
className: "nice-nocode-script__btn",
|
|
229
|
+
onClick: () => B({ afterId: b?.id }),
|
|
230
|
+
children: [
|
|
231
|
+
/* @__PURE__ */ o($, { name: "plus", size: 14 }),
|
|
232
|
+
" ",
|
|
233
|
+
g("noCode.addStep", "Add step")
|
|
234
|
+
]
|
|
235
|
+
}
|
|
236
|
+
),
|
|
237
|
+
b && P(b).map((i) => /* @__PURE__ */ c(
|
|
238
|
+
"button",
|
|
239
|
+
{
|
|
240
|
+
type: "button",
|
|
241
|
+
className: "nice-nocode-script__btn",
|
|
242
|
+
onClick: () => B({ parentId: b.id, branch: i }),
|
|
243
|
+
children: [
|
|
244
|
+
/* @__PURE__ */ o($, { name: "plus", size: 14 }),
|
|
245
|
+
" ",
|
|
246
|
+
i === "else" ? g("noCode.addElse", "Add to else") : g("noCode.addInside", "Add inside")
|
|
247
|
+
]
|
|
248
|
+
},
|
|
249
|
+
i
|
|
250
|
+
)),
|
|
251
|
+
p && /* @__PURE__ */ c(
|
|
252
|
+
"button",
|
|
253
|
+
{
|
|
254
|
+
type: "button",
|
|
255
|
+
className: "nice-nocode-script__btn",
|
|
256
|
+
onClick: async () => {
|
|
257
|
+
try {
|
|
258
|
+
const i = await Z(N, p);
|
|
259
|
+
w(JSON.stringify(i.value ?? i.variables, null, 2));
|
|
260
|
+
} catch (i) {
|
|
261
|
+
w(`${g("noCode.error", "Error")}: ${i.message}`);
|
|
262
|
+
}
|
|
263
|
+
},
|
|
264
|
+
children: [
|
|
265
|
+
/* @__PURE__ */ o($, { name: "play", size: 14 }),
|
|
266
|
+
" ",
|
|
267
|
+
g("noCode.run", "Run")
|
|
268
|
+
]
|
|
269
|
+
}
|
|
270
|
+
)
|
|
271
|
+
] }),
|
|
272
|
+
k.length === 0 ? /* @__PURE__ */ o("p", { className: "nice-nocode-script__empty", children: g("noCode.noSteps", "No steps yet — add the first one.") }) : D(k, 0),
|
|
273
|
+
m.length > 0 && /* @__PURE__ */ c("div", { className: "nice-nocode-script__issues", role: "status", children: [
|
|
274
|
+
/* @__PURE__ */ o("strong", { children: g("noCode.issues", "Problems") }),
|
|
275
|
+
/* @__PURE__ */ o("ul", { children: m.map((i, x) => /* @__PURE__ */ o("li", { children: i.message }, x)) })
|
|
276
|
+
] }),
|
|
277
|
+
h !== null && /* @__PURE__ */ o("pre", { className: "nice-nocode-script__result", "aria-label": g("noCode.result", "Result"), children: h })
|
|
278
|
+
] }),
|
|
279
|
+
/* @__PURE__ */ o("div", { className: "nice-nocode-script__inspector", children: b ? /* @__PURE__ */ o(
|
|
280
|
+
re,
|
|
281
|
+
{
|
|
282
|
+
step: b,
|
|
283
|
+
onChange: Y,
|
|
284
|
+
onRemove: () => {
|
|
285
|
+
V(q(k, b.id, null)), r(null);
|
|
286
|
+
},
|
|
287
|
+
onMove: (i) => V(U(k, b.id, i)),
|
|
288
|
+
dataSources: u,
|
|
289
|
+
scripts: s,
|
|
290
|
+
readOnly: a
|
|
291
|
+
}
|
|
292
|
+
) : /* @__PURE__ */ o("p", { className: "nice-nocode-script__empty", children: g("noCode.pickStep", "Pick a step to set it up.") }) })
|
|
293
|
+
]
|
|
294
|
+
}
|
|
295
|
+
);
|
|
296
|
+
};
|
|
297
|
+
function re({
|
|
298
|
+
step: e,
|
|
299
|
+
onChange: t,
|
|
300
|
+
onRemove: l,
|
|
301
|
+
onMove: u,
|
|
302
|
+
dataSources: s,
|
|
303
|
+
scripts: p,
|
|
304
|
+
readOnly: a
|
|
305
|
+
}) {
|
|
306
|
+
const { t: n } = L(), z = (r) => t({ ...e, ...r }), f = (r, d, _) => /* @__PURE__ */ o(
|
|
307
|
+
T,
|
|
308
|
+
{
|
|
309
|
+
label: r,
|
|
310
|
+
value: String(e[d] ?? ""),
|
|
311
|
+
onChange: (h) => z({ [d]: h }),
|
|
312
|
+
readOnly: a,
|
|
313
|
+
size: "sm"
|
|
314
|
+
}
|
|
315
|
+
), R = (r) => {
|
|
316
|
+
const d = e[r] ?? [], _ = (h) => z({ [r]: h });
|
|
317
|
+
return /* @__PURE__ */ c("fieldset", { className: "nice-nocode-script__rows", children: [
|
|
318
|
+
/* @__PURE__ */ o("legend", { children: n("noCode.field.where", "Conditions") }),
|
|
319
|
+
d.map((h, w) => /* @__PURE__ */ c("div", { className: "nice-nocode-script__row", children: [
|
|
320
|
+
/* @__PURE__ */ o(
|
|
321
|
+
T,
|
|
322
|
+
{
|
|
323
|
+
label: n("noCode.field.field", "Field"),
|
|
324
|
+
labelPlacement: "inside",
|
|
325
|
+
value: h.field,
|
|
326
|
+
onChange: (m) => _(d.map((C, b) => b === w ? { ...C, field: m } : C)),
|
|
327
|
+
readOnly: a,
|
|
328
|
+
size: "sm"
|
|
329
|
+
}
|
|
330
|
+
),
|
|
331
|
+
/* @__PURE__ */ o(
|
|
332
|
+
M,
|
|
333
|
+
{
|
|
334
|
+
"aria-label": n("noCode.field.op", "Operator"),
|
|
335
|
+
value: h.op,
|
|
336
|
+
options: ee.map((m) => ({
|
|
337
|
+
value: m,
|
|
338
|
+
label: m === "contains" || m === "empty" || m === "notEmpty" ? n(`noCode.op.${m}`, m) : G[m]
|
|
339
|
+
})),
|
|
340
|
+
onChange: (m) => _(
|
|
341
|
+
d.map(
|
|
342
|
+
(C, b) => b === w ? { ...C, op: String(m) } : C
|
|
343
|
+
)
|
|
344
|
+
),
|
|
345
|
+
size: "sm"
|
|
346
|
+
}
|
|
347
|
+
),
|
|
348
|
+
h.op !== "empty" && h.op !== "notEmpty" && /* @__PURE__ */ o(
|
|
349
|
+
T,
|
|
350
|
+
{
|
|
351
|
+
label: n("noCode.field.expression", "Value"),
|
|
352
|
+
labelPlacement: "inside",
|
|
353
|
+
value: h.value ?? "",
|
|
354
|
+
onChange: (m) => _(d.map((C, b) => b === w ? { ...C, value: m } : C)),
|
|
355
|
+
readOnly: a,
|
|
356
|
+
size: "sm"
|
|
357
|
+
}
|
|
358
|
+
),
|
|
359
|
+
!a && /* @__PURE__ */ o(
|
|
360
|
+
"button",
|
|
361
|
+
{
|
|
362
|
+
type: "button",
|
|
363
|
+
className: "nice-nocode-script__icon-btn",
|
|
364
|
+
"aria-label": n("noCode.removeRow", "Remove"),
|
|
365
|
+
onClick: () => _(d.filter((m, C) => C !== w)),
|
|
366
|
+
children: /* @__PURE__ */ o($, { name: "close", size: 12 })
|
|
367
|
+
}
|
|
368
|
+
)
|
|
369
|
+
] }, w)),
|
|
370
|
+
!a && /* @__PURE__ */ c(
|
|
371
|
+
"button",
|
|
372
|
+
{
|
|
373
|
+
type: "button",
|
|
374
|
+
className: "nice-nocode-script__btn",
|
|
375
|
+
onClick: () => _([...d, { field: "", op: "eq", value: "" }]),
|
|
376
|
+
children: [
|
|
377
|
+
/* @__PURE__ */ o($, { name: "plus", size: 12 }),
|
|
378
|
+
" ",
|
|
379
|
+
n("noCode.addRow", "Add")
|
|
380
|
+
]
|
|
381
|
+
}
|
|
382
|
+
)
|
|
383
|
+
] });
|
|
384
|
+
}, g = (r, d, _, h) => /* @__PURE__ */ c("fieldset", { className: "nice-nocode-script__rows", children: [
|
|
385
|
+
/* @__PURE__ */ o("legend", { children: r }),
|
|
386
|
+
d.map(([w, m], C) => /* @__PURE__ */ c("div", { className: "nice-nocode-script__row", children: [
|
|
387
|
+
/* @__PURE__ */ o(
|
|
388
|
+
T,
|
|
389
|
+
{
|
|
390
|
+
label: h[0],
|
|
391
|
+
labelPlacement: "inside",
|
|
392
|
+
value: w,
|
|
393
|
+
onChange: (b) => _(d.map((y, k) => k === C ? [b, y[1]] : y)),
|
|
394
|
+
readOnly: a,
|
|
395
|
+
size: "sm"
|
|
396
|
+
}
|
|
397
|
+
),
|
|
398
|
+
/* @__PURE__ */ o(
|
|
399
|
+
T,
|
|
400
|
+
{
|
|
401
|
+
label: h[1],
|
|
402
|
+
labelPlacement: "inside",
|
|
403
|
+
value: m,
|
|
404
|
+
onChange: (b) => _(d.map((y, k) => k === C ? [y[0], b] : y)),
|
|
405
|
+
readOnly: a,
|
|
406
|
+
size: "sm"
|
|
407
|
+
}
|
|
408
|
+
),
|
|
409
|
+
!a && /* @__PURE__ */ o(
|
|
410
|
+
"button",
|
|
411
|
+
{
|
|
412
|
+
type: "button",
|
|
413
|
+
className: "nice-nocode-script__icon-btn",
|
|
414
|
+
"aria-label": n("noCode.removeRow", "Remove"),
|
|
415
|
+
onClick: () => _(d.filter((b, y) => y !== C)),
|
|
416
|
+
children: /* @__PURE__ */ o($, { name: "close", size: 12 })
|
|
417
|
+
}
|
|
418
|
+
)
|
|
419
|
+
] }, C)),
|
|
420
|
+
!a && /* @__PURE__ */ c(
|
|
421
|
+
"button",
|
|
422
|
+
{
|
|
423
|
+
type: "button",
|
|
424
|
+
className: "nice-nocode-script__btn",
|
|
425
|
+
onClick: () => _([...d, ["", ""]]),
|
|
426
|
+
children: [
|
|
427
|
+
/* @__PURE__ */ o($, { name: "plus", size: 12 }),
|
|
428
|
+
" ",
|
|
429
|
+
n("noCode.addRow", "Add")
|
|
430
|
+
]
|
|
431
|
+
}
|
|
432
|
+
)
|
|
433
|
+
] }), N = n("noCode.field.into", "Into variable"), I = n("noCode.field.from", "Input variable");
|
|
434
|
+
let v;
|
|
435
|
+
switch (e.type) {
|
|
436
|
+
case "read":
|
|
437
|
+
v = /* @__PURE__ */ c(E, { children: [
|
|
438
|
+
f(n("noCode.field.source", "Data source"), "source"),
|
|
439
|
+
R("where"),
|
|
440
|
+
f(N, "into")
|
|
441
|
+
] });
|
|
442
|
+
break;
|
|
443
|
+
case "filter":
|
|
444
|
+
v = /* @__PURE__ */ c(E, { children: [
|
|
445
|
+
f(I, "from"),
|
|
446
|
+
R("where"),
|
|
447
|
+
f(N, "into")
|
|
448
|
+
] });
|
|
449
|
+
break;
|
|
450
|
+
case "map":
|
|
451
|
+
v = /* @__PURE__ */ c(E, { children: [
|
|
452
|
+
f(I, "from"),
|
|
453
|
+
g(
|
|
454
|
+
n("noCode.field.fields", "Fields"),
|
|
455
|
+
e.fields.map((r) => [r.target, r.expression]),
|
|
456
|
+
(r) => z({ fields: r.map(([d, _]) => ({ target: d, expression: _ })) }),
|
|
457
|
+
[n("noCode.field.target", "Target"), n("noCode.field.expression", "Value")]
|
|
458
|
+
),
|
|
459
|
+
f(N, "into")
|
|
460
|
+
] });
|
|
461
|
+
break;
|
|
462
|
+
case "aggregate":
|
|
463
|
+
v = /* @__PURE__ */ c(E, { children: [
|
|
464
|
+
f(I, "from"),
|
|
465
|
+
/* @__PURE__ */ o(
|
|
466
|
+
T,
|
|
467
|
+
{
|
|
468
|
+
label: n("noCode.field.groupBy", "Group by"),
|
|
469
|
+
value: (e.groupBy ?? []).join(", "),
|
|
470
|
+
onChange: (r) => z({
|
|
471
|
+
groupBy: r.split(",").map((d) => d.trim()).filter(Boolean)
|
|
472
|
+
}),
|
|
473
|
+
readOnly: a,
|
|
474
|
+
size: "sm"
|
|
475
|
+
}
|
|
476
|
+
),
|
|
477
|
+
g(
|
|
478
|
+
n("noCode.field.measures", "Measures"),
|
|
479
|
+
e.measures.map((r) => [r.name, `${r.op}${r.field ? `(${r.field})` : ""}`]),
|
|
480
|
+
(r) => z({
|
|
481
|
+
measures: r.map(([d, _]) => {
|
|
482
|
+
const h = /^(count|sum|avg|min|max)(?:\(([^)]*)\))?$/.exec(_.trim());
|
|
483
|
+
return {
|
|
484
|
+
name: d,
|
|
485
|
+
op: h?.[1] ?? "count",
|
|
486
|
+
...h?.[2] ? { field: h[2] } : {}
|
|
487
|
+
};
|
|
488
|
+
})
|
|
489
|
+
}),
|
|
490
|
+
[n("noCode.field.name", "Name"), n("noCode.field.measure", "Measure: sum(field)")]
|
|
491
|
+
),
|
|
492
|
+
f(N, "into")
|
|
493
|
+
] });
|
|
494
|
+
break;
|
|
495
|
+
case "set":
|
|
496
|
+
v = /* @__PURE__ */ c(E, { children: [
|
|
497
|
+
f(n("noCode.field.variable", "Variable"), "variable"),
|
|
498
|
+
f(n("noCode.field.expression", "Value"), "expression")
|
|
499
|
+
] });
|
|
500
|
+
break;
|
|
501
|
+
case "if":
|
|
502
|
+
v = R("when");
|
|
503
|
+
break;
|
|
504
|
+
case "forEach":
|
|
505
|
+
v = /* @__PURE__ */ c(E, { children: [
|
|
506
|
+
f(I, "from"),
|
|
507
|
+
f(n("noCode.field.as", "Item variable"), "as")
|
|
508
|
+
] });
|
|
509
|
+
break;
|
|
510
|
+
case "write":
|
|
511
|
+
v = /* @__PURE__ */ c(E, { children: [
|
|
512
|
+
f(n("noCode.field.target", "Target"), "target"),
|
|
513
|
+
f(I, "from"),
|
|
514
|
+
/* @__PURE__ */ o(
|
|
515
|
+
M,
|
|
516
|
+
{
|
|
517
|
+
label: n("noCode.field.mode", "Mode"),
|
|
518
|
+
value: e.mode ?? "insert",
|
|
519
|
+
options: ["insert", "update", "upsert", "delete"],
|
|
520
|
+
onChange: (r) => z({ mode: String(r) }),
|
|
521
|
+
size: "sm"
|
|
522
|
+
}
|
|
523
|
+
)
|
|
524
|
+
] });
|
|
525
|
+
break;
|
|
526
|
+
case "callScript":
|
|
527
|
+
v = /* @__PURE__ */ c(E, { children: [
|
|
528
|
+
f(n("noCode.field.script", "Script"), "script"),
|
|
529
|
+
g(
|
|
530
|
+
n("noCode.field.args", "Arguments"),
|
|
531
|
+
Object.entries(e.args ?? {}),
|
|
532
|
+
(r) => z({ args: Object.fromEntries(r) }),
|
|
533
|
+
[n("noCode.field.name", "Name"), n("noCode.field.expression", "Value")]
|
|
534
|
+
),
|
|
535
|
+
f(N, "into")
|
|
536
|
+
] });
|
|
537
|
+
break;
|
|
538
|
+
case "return":
|
|
539
|
+
v = f(n("noCode.field.expression", "Value"), "expression");
|
|
540
|
+
break;
|
|
541
|
+
}
|
|
542
|
+
return /* @__PURE__ */ c("div", { className: "nice-nocode-script__form", children: [
|
|
543
|
+
/* @__PURE__ */ c("div", { className: "nice-nocode-script__form-head", children: [
|
|
544
|
+
/* @__PURE__ */ o("strong", { children: n(`noCode.step.${e.type}`, e.type) }),
|
|
545
|
+
!a && /* @__PURE__ */ c("span", { className: "nice-nocode-script__form-actions", children: [
|
|
546
|
+
/* @__PURE__ */ o(
|
|
547
|
+
"button",
|
|
548
|
+
{
|
|
549
|
+
type: "button",
|
|
550
|
+
className: "nice-nocode-script__icon-btn",
|
|
551
|
+
"aria-label": n("noCode.moveUp", "Move up"),
|
|
552
|
+
onClick: () => u(-1),
|
|
553
|
+
children: /* @__PURE__ */ o($, { name: "arrow-up", size: 14 })
|
|
554
|
+
}
|
|
555
|
+
),
|
|
556
|
+
/* @__PURE__ */ o(
|
|
557
|
+
"button",
|
|
558
|
+
{
|
|
559
|
+
type: "button",
|
|
560
|
+
className: "nice-nocode-script__icon-btn",
|
|
561
|
+
"aria-label": n("noCode.moveDown", "Move down"),
|
|
562
|
+
onClick: () => u(1),
|
|
563
|
+
children: /* @__PURE__ */ o($, { name: "arrow-down", size: 14 })
|
|
564
|
+
}
|
|
565
|
+
),
|
|
566
|
+
/* @__PURE__ */ o(
|
|
567
|
+
"button",
|
|
568
|
+
{
|
|
569
|
+
type: "button",
|
|
570
|
+
className: "nice-nocode-script__icon-btn",
|
|
571
|
+
"aria-label": n("noCode.removeStep", "Remove step"),
|
|
572
|
+
onClick: l,
|
|
573
|
+
children: /* @__PURE__ */ o($, { name: "trash", size: 14 })
|
|
574
|
+
}
|
|
575
|
+
)
|
|
576
|
+
] })
|
|
577
|
+
] }),
|
|
578
|
+
v
|
|
579
|
+
] });
|
|
580
|
+
}
|
|
581
|
+
export {
|
|
582
|
+
ue as NiceNoCodeScriptEditor,
|
|
583
|
+
te as newNoCodeStep
|
|
584
|
+
};
|