@nice2dev/ui-forms 1.1.9 → 1.2.0
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/README.md +0 -6
- package/dist/index.cjs +3 -1
- package/dist/index.mjs +2440 -16
- package/dist/ui-forms.css +1 -1
- package/package.json +6 -4
package/dist/index.mjs
CHANGED
|
@@ -1,18 +1,2442 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx as e, jsxs as u } from "react/jsx-runtime";
|
|
2
|
+
import { useNiceTranslation as ze } from "@nice2dev/i18n";
|
|
3
|
+
import { useControllableState as le, NiceIcon as z, NiceDataGrid as fe, useNiceTranslation as Z, evaluateValidation as Ee, NiceTutorialButton as se, resolveTutorial as ce, NiceTooltip as X, NiceForm as Je, useNiceAI as Ue, useFormGeneration as He, NiceScriptRunner as we, NiceLifecycleHooksEditor as ke, NiceRevisionHistory as Se, NiceConsole as Te, NiceLogConsole as Fe, NiceBadge as ae, NiceValidationBuilder as Ge, NiceButton as te, NiceTabs as We, NiceCheckbox as Ye, NiceSelect as Qe, NiceTextInput as Xe, NiceAccessManager as Ze, NiceViewEditor as et, NiceWorkflowDesigner as tt, NiceDataSourceBuilder as it } from "@nice2dev/ui";
|
|
4
|
+
import nt, { useState as K, forwardRef as ee, useMemo as P, useEffect as oe, useCallback as Q, useImperativeHandle as at } from "react";
|
|
5
|
+
import { useNiceTranslation as ot, useControllableState as rt, NiceTutorialButton as lt, resolveTutorial as st, NiceIcon as be } from "@nice2dev/ui-core";
|
|
6
|
+
function Bt(t) {
|
|
7
|
+
var l, o;
|
|
8
|
+
const r = {
|
|
9
|
+
text: "text",
|
|
10
|
+
email: "email",
|
|
11
|
+
password: "password",
|
|
12
|
+
phone: "phone",
|
|
13
|
+
url: "url",
|
|
14
|
+
textarea: "textarea",
|
|
15
|
+
number: "number",
|
|
16
|
+
date: "date",
|
|
17
|
+
datetime: "datetime",
|
|
18
|
+
time: "time",
|
|
19
|
+
select: "select",
|
|
20
|
+
multiselect: "tags",
|
|
21
|
+
checkbox: "checkbox",
|
|
22
|
+
toggle: "toggle",
|
|
23
|
+
radio: "radio",
|
|
24
|
+
slider: "slider",
|
|
25
|
+
rating: "rating",
|
|
26
|
+
color: "color",
|
|
27
|
+
file: "file",
|
|
28
|
+
image: "file"
|
|
29
|
+
}, a = [];
|
|
30
|
+
for (const i of t.sections)
|
|
31
|
+
for (const n of i.fields)
|
|
32
|
+
n.type === "heading" || n.type === "paragraph" || n.type === "divider" || n.type === "spacer" || n.type === "section" || a.push({
|
|
33
|
+
field: n.name,
|
|
34
|
+
label: n.label || n.name,
|
|
35
|
+
type: r[n.type] || "text",
|
|
36
|
+
placeholder: n.placeholder,
|
|
37
|
+
hint: n.helpText,
|
|
38
|
+
defaultValue: n.defaultValue,
|
|
39
|
+
required: n.required || ((l = n.validations) == null ? void 0 : l.some((c) => c.type === "required")),
|
|
40
|
+
disabled: n.disabled,
|
|
41
|
+
readOnly: n.readonly,
|
|
42
|
+
group: i.title,
|
|
43
|
+
options: (o = n.options) == null ? void 0 : o.map(
|
|
44
|
+
(c) => typeof c == "string" ? { label: c, value: c } : { label: c.label, value: c.value }
|
|
45
|
+
)
|
|
46
|
+
});
|
|
47
|
+
return a;
|
|
48
|
+
}
|
|
49
|
+
function ve(t) {
|
|
50
|
+
var a;
|
|
51
|
+
const r = {
|
|
52
|
+
text: "NiceTextInput",
|
|
53
|
+
textarea: "NiceTextArea",
|
|
54
|
+
number: "NiceNumberInput",
|
|
55
|
+
email: "NiceTextInput",
|
|
56
|
+
password: "NicePasswordInput",
|
|
57
|
+
date: "NiceDateTimePicker",
|
|
58
|
+
datetime: "NiceDateTimePicker",
|
|
59
|
+
time: "NiceDateTimePicker",
|
|
60
|
+
select: "NiceSelect",
|
|
61
|
+
multiselect: "NiceTagBox",
|
|
62
|
+
checkbox: "NiceCheckbox",
|
|
63
|
+
toggle: "NiceToggle",
|
|
64
|
+
radio: "NiceRadioGroup",
|
|
65
|
+
slider: "NiceSlider",
|
|
66
|
+
rating: "NiceRating",
|
|
67
|
+
color: "NiceColorPicker"
|
|
68
|
+
};
|
|
69
|
+
return {
|
|
70
|
+
dataField: t.name,
|
|
71
|
+
label: { text: t.label },
|
|
72
|
+
editorType: r[t.type] || "NiceTextInput",
|
|
73
|
+
editorOptions: {
|
|
74
|
+
placeholder: t.placeholder,
|
|
75
|
+
disabled: t.disabled,
|
|
76
|
+
readOnly: t.readonly,
|
|
77
|
+
...t.props
|
|
78
|
+
},
|
|
79
|
+
colSpan: Math.ceil((t.colSpan || 12) / 6),
|
|
80
|
+
validationRules: (a = t.validations) == null ? void 0 : a.map((l) => ({
|
|
81
|
+
type: l.type,
|
|
82
|
+
message: l.message,
|
|
83
|
+
...l.value !== void 0 ? { [l.type]: l.value } : {}
|
|
84
|
+
})),
|
|
85
|
+
helpText: t.helpText
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function zt(t) {
|
|
89
|
+
const r = [];
|
|
90
|
+
for (const a of t.sections)
|
|
91
|
+
a.title ? r.push({
|
|
92
|
+
itemType: "group",
|
|
93
|
+
caption: a.title,
|
|
94
|
+
colCount: a.columns || 2,
|
|
95
|
+
items: a.fields.map(ve)
|
|
96
|
+
}) : r.push(...a.fields.map(ve));
|
|
97
|
+
return r;
|
|
98
|
+
}
|
|
99
|
+
function Jt(t) {
|
|
100
|
+
const r = [];
|
|
101
|
+
t.version || r.push("Missing schema version"), t.id || r.push("Missing form ID"), (!t.sections || t.sections.length === 0) && r.push("Form must have at least one section");
|
|
102
|
+
const a = /* @__PURE__ */ new Set();
|
|
103
|
+
for (const l of t.sections || [])
|
|
104
|
+
for (const o of l.fields || [])
|
|
105
|
+
o.id || r.push(`Field missing ID: ${o.name}`), o.name || r.push(`Field missing name: ${o.id}`), a.has(o.name) && r.push(`Duplicate field name: ${o.name}`), a.add(o.name);
|
|
106
|
+
return { valid: r.length === 0, errors: r };
|
|
107
|
+
}
|
|
108
|
+
function _e(t) {
|
|
109
|
+
const { value: r, onChange: a, readOnly: l } = t, [o, i] = K(() => {
|
|
110
|
+
try {
|
|
111
|
+
return r === void 0 ? "" : JSON.stringify(r, null, 2);
|
|
112
|
+
} catch {
|
|
113
|
+
return "";
|
|
114
|
+
}
|
|
115
|
+
}), [n, c] = K(null);
|
|
116
|
+
return nt.useEffect(() => {
|
|
117
|
+
try {
|
|
118
|
+
i(r === void 0 ? "" : JSON.stringify(r, null, 2));
|
|
119
|
+
} catch {
|
|
120
|
+
}
|
|
121
|
+
}, [JSON.stringify(r)]), /* @__PURE__ */ u("div", { className: "nice-schema-form__json-field", children: [
|
|
122
|
+
/* @__PURE__ */ e(
|
|
123
|
+
"textarea",
|
|
124
|
+
{
|
|
125
|
+
className: "nice-schema-form__json-textarea",
|
|
126
|
+
value: o,
|
|
127
|
+
readOnly: l,
|
|
128
|
+
spellCheck: !1,
|
|
129
|
+
rows: Math.min(12, Math.max(3, o.split(`
|
|
130
|
+
`).length)),
|
|
131
|
+
onChange: (f) => {
|
|
132
|
+
const p = f.target.value;
|
|
133
|
+
i(p);
|
|
134
|
+
const y = p.trim();
|
|
135
|
+
if (y === "") {
|
|
136
|
+
c(null), a(void 0);
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
try {
|
|
140
|
+
a(JSON.parse(y)), c(null);
|
|
141
|
+
} catch (s) {
|
|
142
|
+
c(s instanceof Error ? s.message : "Invalid JSON");
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
),
|
|
147
|
+
n && /* @__PURE__ */ e("div", { className: "nice-schema-form__json-error", children: n })
|
|
148
|
+
] });
|
|
149
|
+
}
|
|
150
|
+
function ct(t) {
|
|
151
|
+
switch (t) {
|
|
152
|
+
case "email":
|
|
153
|
+
return "email";
|
|
154
|
+
case "uri":
|
|
155
|
+
case "url":
|
|
156
|
+
return "url";
|
|
157
|
+
case "date":
|
|
158
|
+
return "date";
|
|
159
|
+
case "date-time":
|
|
160
|
+
return "datetime";
|
|
161
|
+
case "time":
|
|
162
|
+
return "time";
|
|
163
|
+
case "color":
|
|
164
|
+
return "color";
|
|
165
|
+
case "password":
|
|
166
|
+
return "password";
|
|
167
|
+
case "phone":
|
|
168
|
+
return "phone";
|
|
169
|
+
case "data-url":
|
|
170
|
+
return "file";
|
|
171
|
+
default:
|
|
172
|
+
return "text";
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
function dt(t, r, a, l = {}) {
|
|
176
|
+
const o = {
|
|
177
|
+
field: t,
|
|
178
|
+
label: r.title ?? t,
|
|
179
|
+
required: a,
|
|
180
|
+
hint: r.description,
|
|
181
|
+
defaultValue: r.default
|
|
182
|
+
};
|
|
183
|
+
if (r.enum && r.enum.length > 0)
|
|
184
|
+
return {
|
|
185
|
+
...o,
|
|
186
|
+
type: "select",
|
|
187
|
+
options: r.enum.map((i) => ({ label: String(i), value: i }))
|
|
188
|
+
};
|
|
189
|
+
switch (r.type) {
|
|
190
|
+
case "number":
|
|
191
|
+
case "integer":
|
|
192
|
+
return { ...o, type: "number" };
|
|
193
|
+
case "boolean":
|
|
194
|
+
return { ...o, type: "checkbox" };
|
|
195
|
+
case "string":
|
|
196
|
+
return { ...o, type: ct(r.format) };
|
|
197
|
+
case "array": {
|
|
198
|
+
const i = r.items;
|
|
199
|
+
if (i != null && i.enum && i.enum.length > 0)
|
|
200
|
+
return {
|
|
201
|
+
...o,
|
|
202
|
+
type: "tags",
|
|
203
|
+
options: i.enum.map((n) => ({ label: String(n), value: String(n) }))
|
|
204
|
+
};
|
|
205
|
+
if ((i == null ? void 0 : i.type) === "object" && i.properties && l.renderArrayField) {
|
|
206
|
+
const n = l.renderArrayField;
|
|
207
|
+
return {
|
|
208
|
+
...o,
|
|
209
|
+
render: (c, f) => n(
|
|
210
|
+
c ?? [],
|
|
211
|
+
f,
|
|
212
|
+
i,
|
|
213
|
+
o.label
|
|
214
|
+
)
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
return (i == null ? void 0 : i.type) === "string" || (i == null ? void 0 : i.type) === "number" || (i == null ? void 0 : i.type) === "integer" ? { ...o, type: "tags" } : {
|
|
218
|
+
...o,
|
|
219
|
+
render: (n, c) => /* @__PURE__ */ e(_e, { value: n, onChange: c })
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
case "object":
|
|
223
|
+
if (l.renderObjectField) {
|
|
224
|
+
const i = l.renderObjectField;
|
|
225
|
+
return {
|
|
226
|
+
...o,
|
|
227
|
+
render: (n, c) => i(
|
|
228
|
+
n ?? {},
|
|
229
|
+
c,
|
|
230
|
+
r,
|
|
231
|
+
o.label
|
|
232
|
+
)
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
return {
|
|
236
|
+
...o,
|
|
237
|
+
render: (i, n) => /* @__PURE__ */ e(_e, { value: i, onChange: n })
|
|
238
|
+
};
|
|
239
|
+
default:
|
|
240
|
+
return { ...o, type: "text" };
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
function xe(t, r = {}) {
|
|
244
|
+
const { uiSchema: a, renderArrayField: l, renderObjectField: o } = r, i = { renderArrayField: l, renderObjectField: o }, n = t.properties ?? {}, c = new Set(t.required ?? []);
|
|
245
|
+
return Object.keys(n).map((f) => {
|
|
246
|
+
const p = dt(f, n[f], c.has(f), i);
|
|
247
|
+
return a != null && a[f] ? { ...p, ...a[f] } : p;
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
const ut = {
|
|
251
|
+
text: "text",
|
|
252
|
+
textarea: "textarea",
|
|
253
|
+
number: "number",
|
|
254
|
+
email: "email",
|
|
255
|
+
password: "password",
|
|
256
|
+
phone: "phone",
|
|
257
|
+
url: "url",
|
|
258
|
+
date: "date",
|
|
259
|
+
datetime: "datetime",
|
|
260
|
+
time: "time",
|
|
261
|
+
select: "select",
|
|
262
|
+
multiselect: "tags",
|
|
263
|
+
checkbox: "checkbox",
|
|
264
|
+
toggle: "toggle",
|
|
265
|
+
radio: "radio",
|
|
266
|
+
slider: "slider",
|
|
267
|
+
rating: "rating",
|
|
268
|
+
color: "color"
|
|
269
|
+
};
|
|
270
|
+
function Ce(t, r = {}) {
|
|
271
|
+
var o, i;
|
|
272
|
+
const { uiSchema: a } = r, l = [];
|
|
273
|
+
for (const n of t) {
|
|
274
|
+
if (n.type === "section" && n.children) {
|
|
275
|
+
for (const p of Ce(n.children, r))
|
|
276
|
+
l.push(n.label ? { ...p, group: n.label } : p);
|
|
277
|
+
continue;
|
|
278
|
+
}
|
|
279
|
+
const c = ut[n.type];
|
|
280
|
+
if (!c)
|
|
281
|
+
continue;
|
|
282
|
+
const f = {
|
|
283
|
+
field: n.name,
|
|
284
|
+
label: n.label,
|
|
285
|
+
type: c,
|
|
286
|
+
required: n.required || ((o = n.validations) == null ? void 0 : o.some((p) => p.type === "required")),
|
|
287
|
+
placeholder: n.placeholder,
|
|
288
|
+
hint: n.helpText,
|
|
289
|
+
defaultValue: n.defaultValue,
|
|
290
|
+
disabled: n.disabled,
|
|
291
|
+
readOnly: n.readonly,
|
|
292
|
+
options: (i = n.options) == null ? void 0 : i.map(
|
|
293
|
+
(p) => typeof p == "string" ? { label: p, value: p } : { label: p.label, value: p.value }
|
|
294
|
+
)
|
|
295
|
+
};
|
|
296
|
+
l.push(a != null && a[n.name] ? { ...f, ...a[n.name] } : f);
|
|
297
|
+
}
|
|
298
|
+
return l;
|
|
299
|
+
}
|
|
300
|
+
function Ne(t) {
|
|
301
|
+
return t == null || t === "" || Array.isArray(t) && t.length === 0;
|
|
302
|
+
}
|
|
303
|
+
function Ie(t, r) {
|
|
304
|
+
const a = [], l = r.properties ?? {}, o = new Set(r.required ?? []);
|
|
305
|
+
for (const i of Object.keys(l)) {
|
|
306
|
+
const n = l[i], c = t[i];
|
|
307
|
+
if (o.has(i) && Ne(c)) {
|
|
308
|
+
a.push({ field: i, message: `${n.title ?? i} is required` });
|
|
309
|
+
continue;
|
|
310
|
+
}
|
|
311
|
+
if (!Ne(c) && (n.enum && !n.enum.includes(c) && a.push({
|
|
312
|
+
field: i,
|
|
313
|
+
message: `${n.title ?? i} must be one of: ${n.enum.join(", ")}`
|
|
314
|
+
}), (n.type === "number" || n.type === "integer") && typeof c == "number" && (n.minimum !== void 0 && c < n.minimum && a.push({ field: i, message: `${n.title ?? i} must be ≥ ${n.minimum}` }), n.maximum !== void 0 && c > n.maximum && a.push({ field: i, message: `${n.title ?? i} must be ≤ ${n.maximum}` })), n.type === "string" && typeof c == "string" && (n.minLength !== void 0 && c.length < n.minLength && a.push({
|
|
315
|
+
field: i,
|
|
316
|
+
message: `${n.title ?? i} must be at least ${n.minLength} chars`
|
|
317
|
+
}), n.maxLength !== void 0 && c.length > n.maxLength && a.push({
|
|
318
|
+
field: i,
|
|
319
|
+
message: `${n.title ?? i} must be at most ${n.maxLength} chars`
|
|
320
|
+
}), n.pattern)))
|
|
321
|
+
try {
|
|
322
|
+
new RegExp(n.pattern).test(c) || a.push({ field: i, message: `${n.title ?? i} has an invalid format` });
|
|
323
|
+
} catch {
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
return a;
|
|
327
|
+
}
|
|
328
|
+
const ue = "__nafRid";
|
|
329
|
+
function mt(t) {
|
|
330
|
+
return Array.isArray(t) ? `[${t.length}]` : t && typeof t == "object" ? "{…}" : t == null ? "" : String(t);
|
|
331
|
+
}
|
|
332
|
+
const pt = ee(
|
|
333
|
+
function(r, a) {
|
|
334
|
+
const {
|
|
335
|
+
value: l,
|
|
336
|
+
defaultValue: o,
|
|
337
|
+
onChange: i,
|
|
338
|
+
itemSchema: n,
|
|
339
|
+
title: c,
|
|
340
|
+
readOnly: f = !1,
|
|
341
|
+
columns: p,
|
|
342
|
+
className: y,
|
|
343
|
+
style: s,
|
|
344
|
+
"data-testid": h
|
|
345
|
+
} = r, [F, O] = le({
|
|
346
|
+
value: l,
|
|
347
|
+
defaultValue: o,
|
|
348
|
+
fallbackValue: [],
|
|
349
|
+
onChange: i,
|
|
350
|
+
componentName: "NiceArrayField"
|
|
351
|
+
}), D = n.properties ?? {}, A = P(() => (p ?? Object.keys(D)).map((I) => {
|
|
352
|
+
const v = D[I] ?? {}, k = { field: I, header: v.title ?? I };
|
|
353
|
+
return v.type === "boolean" ? (k.render = (j) => j ? /* @__PURE__ */ e(z, { name: "check", size: 14, title: "true" }) : "", k.align = "center") : (v.type === "array" || v.type === "object") && (k.render = (j) => mt(j)), k;
|
|
354
|
+
}), [n, p]), C = P(
|
|
355
|
+
() => xe(n),
|
|
356
|
+
[n]
|
|
357
|
+
), w = P(() => F.map((M, I) => ({ ...M, [ue]: String(I) })), [F]), $ = (M) => {
|
|
358
|
+
const { [ue]: I, ...v } = M;
|
|
359
|
+
return v;
|
|
360
|
+
}, J = "nice-array-field" + (y ? ` ${y}` : "");
|
|
361
|
+
return /* @__PURE__ */ e("div", { ref: a, className: J, style: s, "data-testid": h, children: /* @__PURE__ */ e(
|
|
362
|
+
fe,
|
|
363
|
+
{
|
|
364
|
+
data: w,
|
|
365
|
+
keyField: ue,
|
|
366
|
+
columns: A,
|
|
367
|
+
editMode: "popup",
|
|
368
|
+
formItems: C,
|
|
369
|
+
editFormTitle: c ? `${c} — item` : "Edit item",
|
|
370
|
+
emptyText: `No items${c ? ` in ${c}` : ""}`,
|
|
371
|
+
compact: !0,
|
|
372
|
+
onRowAdd: f ? void 0 : (M) => O([...F, $(M)]),
|
|
373
|
+
onRowEdit: f ? void 0 : (M, I) => {
|
|
374
|
+
const v = Number(M);
|
|
375
|
+
O(
|
|
376
|
+
F.map(
|
|
377
|
+
(k, j) => j === v ? $(I) : k
|
|
378
|
+
)
|
|
379
|
+
);
|
|
380
|
+
},
|
|
381
|
+
onRowDelete: f ? void 0 : (M) => {
|
|
382
|
+
const I = Number(M);
|
|
383
|
+
O(F.filter((v, k) => k !== I));
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
) });
|
|
387
|
+
}
|
|
388
|
+
), ht = [
|
|
389
|
+
{
|
|
390
|
+
target: ".nice-schema-form",
|
|
391
|
+
titleKey: "tutorial.schemaForm.intro.title",
|
|
392
|
+
title: "Schema form",
|
|
393
|
+
contentKey: "tutorial.schemaForm.intro.content",
|
|
394
|
+
content: "This form is generated from a schema. Required fields and validation errors are flagged; use the JSON toggle for raw editing.",
|
|
395
|
+
placement: "auto"
|
|
396
|
+
},
|
|
397
|
+
{
|
|
398
|
+
target: '[data-tour="sf-viewtoggle"]',
|
|
399
|
+
titleKey: "tutorial.schemaForm.viewToggle.title",
|
|
400
|
+
title: "Form ⇄ JSON",
|
|
401
|
+
contentKey: "tutorial.schemaForm.viewToggle.content",
|
|
402
|
+
content: "Switch between the visual form and the raw JSON value — handy for power users and copy/paste.",
|
|
403
|
+
placement: "bottom"
|
|
404
|
+
},
|
|
405
|
+
{
|
|
406
|
+
target: ".nice-schema-form",
|
|
407
|
+
titleKey: "tutorial.schemaForm.validation.title",
|
|
408
|
+
title: "Live validation",
|
|
409
|
+
contentKey: "tutorial.schemaForm.validation.content",
|
|
410
|
+
content: "Values are validated against the schema as you type; any problems are listed below the form.",
|
|
411
|
+
placement: "auto"
|
|
412
|
+
}
|
|
413
|
+
];
|
|
414
|
+
function ft(t) {
|
|
415
|
+
const r = [], a = (l) => {
|
|
416
|
+
for (const o of l) {
|
|
417
|
+
if (o.type === "section" && o.children) {
|
|
418
|
+
a(o.children);
|
|
419
|
+
continue;
|
|
420
|
+
}
|
|
421
|
+
o.required && r.push({ id: `${o.name}-required`, field: o.name, op: "required" });
|
|
422
|
+
for (const i of o.validations ?? [])
|
|
423
|
+
r.push({
|
|
424
|
+
id: `${o.name}-${i.type}`,
|
|
425
|
+
field: o.name,
|
|
426
|
+
op: i.type,
|
|
427
|
+
value: typeof i.value == "boolean" ? void 0 : i.value,
|
|
428
|
+
message: i.message ?? (i.type === "required" ? `${o.label ?? o.name} is required` : void 0)
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
};
|
|
432
|
+
return a(t), r;
|
|
433
|
+
}
|
|
434
|
+
function yt(t, r) {
|
|
435
|
+
return Ee(ft(t), r).filter((a) => a.severity === "error").map((a) => ({ field: a.field, message: a.message }));
|
|
436
|
+
}
|
|
437
|
+
const de = ee(
|
|
438
|
+
function(r, a) {
|
|
439
|
+
const {
|
|
440
|
+
schema: l,
|
|
441
|
+
fields: o,
|
|
442
|
+
uiSchema: i,
|
|
443
|
+
value: n,
|
|
444
|
+
defaultValue: c,
|
|
445
|
+
onChange: f,
|
|
446
|
+
onValidate: p,
|
|
447
|
+
showJsonView: y = !1,
|
|
448
|
+
columns: s = 1,
|
|
449
|
+
labelPosition: h = "top",
|
|
450
|
+
readOnly: F = !1,
|
|
451
|
+
liveValidation: O = !0,
|
|
452
|
+
validationRules: D,
|
|
453
|
+
tutorial: A,
|
|
454
|
+
className: C,
|
|
455
|
+
style: w,
|
|
456
|
+
id: $,
|
|
457
|
+
"data-testid": J
|
|
458
|
+
} = r, { t: M } = Z(), [I, v] = le({
|
|
459
|
+
value: n,
|
|
460
|
+
defaultValue: c,
|
|
461
|
+
fallbackValue: {},
|
|
462
|
+
onChange: f,
|
|
463
|
+
componentName: "NiceSchemaForm"
|
|
464
|
+
}), [k, j] = K(!1), [U, L] = K(""), [S, H] = K(null), N = P(() => l ? xe(l, {
|
|
465
|
+
uiSchema: i,
|
|
466
|
+
// Inject the structured array editor (avoids an import cycle in the converter).
|
|
467
|
+
renderArrayField: (E, g, x, R) => /* @__PURE__ */ e(
|
|
468
|
+
pt,
|
|
469
|
+
{
|
|
470
|
+
value: E,
|
|
471
|
+
onChange: g,
|
|
472
|
+
itemSchema: x,
|
|
473
|
+
title: R,
|
|
474
|
+
readOnly: F
|
|
475
|
+
}
|
|
476
|
+
)
|
|
477
|
+
}) : o ? Ce(o, { uiSchema: i }) : [], [l, o, i, F]), q = P(() => {
|
|
478
|
+
const E = l ? Ie(I, l) : o ? yt(o, I) : [];
|
|
479
|
+
if (D != null && D.length) {
|
|
480
|
+
const g = Ee(D, I).filter((x) => x.severity === "error").map((x) => ({ field: x.field, message: x.message }));
|
|
481
|
+
return [...E, ...g];
|
|
482
|
+
}
|
|
483
|
+
return E;
|
|
484
|
+
}, [l, o, I, D]);
|
|
485
|
+
oe(() => {
|
|
486
|
+
p == null || p(q);
|
|
487
|
+
}, [q, p]), oe(() => {
|
|
488
|
+
if (k)
|
|
489
|
+
try {
|
|
490
|
+
L(JSON.stringify(I, null, 2)), H(null);
|
|
491
|
+
} catch {
|
|
492
|
+
}
|
|
493
|
+
}, [k, I]);
|
|
494
|
+
const m = (E, g) => {
|
|
495
|
+
v({ ...I, [E]: g });
|
|
496
|
+
}, _ = "nice-schema-form" + (C ? ` ${C}` : "");
|
|
497
|
+
return /* @__PURE__ */ u("div", { ref: a, id: $, className: _, style: w, "data-testid": J, children: [
|
|
498
|
+
A && /* @__PURE__ */ e("div", { className: "nice-schema-form__tutorial", children: /* @__PURE__ */ e(se, { steps: ce(A, ht) }) }),
|
|
499
|
+
y && /* @__PURE__ */ u("div", { className: "nice-schema-form__toolbar", "data-tour": "sf-viewtoggle", children: [
|
|
500
|
+
/* @__PURE__ */ e(
|
|
501
|
+
"button",
|
|
502
|
+
{
|
|
503
|
+
type: "button",
|
|
504
|
+
className: "nice-schema-form__tab" + (k ? "" : " nice-schema-form__tab--active"),
|
|
505
|
+
onClick: () => j(!1),
|
|
506
|
+
children: M("schemaForm.tab.form", "Form")
|
|
507
|
+
}
|
|
508
|
+
),
|
|
509
|
+
/* @__PURE__ */ e(
|
|
510
|
+
X,
|
|
511
|
+
{
|
|
512
|
+
content: M("schemaForm.tab.json.help", "Edit the raw JSON value directly"),
|
|
513
|
+
children: /* @__PURE__ */ e(
|
|
514
|
+
"button",
|
|
515
|
+
{
|
|
516
|
+
type: "button",
|
|
517
|
+
className: "nice-schema-form__tab" + (k ? " nice-schema-form__tab--active" : ""),
|
|
518
|
+
onClick: () => j(!0),
|
|
519
|
+
children: M("schemaForm.tab.json", "JSON")
|
|
520
|
+
}
|
|
521
|
+
)
|
|
522
|
+
}
|
|
523
|
+
)
|
|
524
|
+
] }),
|
|
525
|
+
k ? /* @__PURE__ */ u("div", { className: "nice-schema-form__json", children: [
|
|
526
|
+
/* @__PURE__ */ e(
|
|
527
|
+
"textarea",
|
|
528
|
+
{
|
|
529
|
+
className: "nice-schema-form__json-textarea",
|
|
530
|
+
value: U,
|
|
531
|
+
readOnly: F,
|
|
532
|
+
spellCheck: !1,
|
|
533
|
+
rows: Math.min(24, Math.max(6, U.split(`
|
|
534
|
+
`).length)),
|
|
535
|
+
onChange: (E) => {
|
|
536
|
+
const g = E.target.value;
|
|
537
|
+
L(g);
|
|
538
|
+
try {
|
|
539
|
+
const x = JSON.parse(g);
|
|
540
|
+
H(null), v(x);
|
|
541
|
+
} catch (x) {
|
|
542
|
+
H(
|
|
543
|
+
x instanceof Error ? x.message : M("schemaForm.invalidJson", "Invalid JSON")
|
|
544
|
+
);
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
),
|
|
549
|
+
S && /* @__PURE__ */ e("div", { className: "nice-schema-form__json-error", children: S })
|
|
550
|
+
] }) : /* @__PURE__ */ e(
|
|
551
|
+
Je,
|
|
552
|
+
{
|
|
553
|
+
items: N,
|
|
554
|
+
data: I,
|
|
555
|
+
onFieldChange: m,
|
|
556
|
+
columns: s,
|
|
557
|
+
labelPosition: h,
|
|
558
|
+
readOnly: F
|
|
559
|
+
}
|
|
560
|
+
),
|
|
561
|
+
O && q.length > 0 && /* @__PURE__ */ e("ul", { className: "nice-schema-form__errors", role: "alert", children: q.map((E, g) => /* @__PURE__ */ e("li", { className: "nice-schema-form__error", children: E.message }, `${E.field}-${g}`)) })
|
|
562
|
+
] });
|
|
563
|
+
}
|
|
564
|
+
), gt = [
|
|
565
|
+
{ name: "Contact Form", description: "A simple contact form with name, email, and message" },
|
|
566
|
+
{
|
|
567
|
+
name: "Registration Form",
|
|
568
|
+
description: "User registration with username, email, password, and profile info"
|
|
569
|
+
},
|
|
570
|
+
{
|
|
571
|
+
name: "Survey Form",
|
|
572
|
+
description: "Customer satisfaction survey with rating and feedback fields"
|
|
573
|
+
},
|
|
574
|
+
{
|
|
575
|
+
name: "Order Form",
|
|
576
|
+
description: "Product order form with shipping address and payment details"
|
|
577
|
+
},
|
|
578
|
+
{
|
|
579
|
+
name: "Job Application",
|
|
580
|
+
description: "Job application with personal info, experience, and file uploads"
|
|
581
|
+
},
|
|
582
|
+
{ name: "Event Registration", description: "Event sign-up with attendee info and preferences" }
|
|
583
|
+
];
|
|
584
|
+
function bt(t) {
|
|
585
|
+
return {
|
|
586
|
+
text: "text",
|
|
587
|
+
string: "text",
|
|
588
|
+
textarea: "textarea",
|
|
589
|
+
number: "number",
|
|
590
|
+
integer: "number",
|
|
591
|
+
email: "email",
|
|
592
|
+
password: "password",
|
|
593
|
+
phone: "phone",
|
|
594
|
+
tel: "phone",
|
|
595
|
+
url: "url",
|
|
596
|
+
date: "date",
|
|
597
|
+
datetime: "datetime",
|
|
598
|
+
time: "time",
|
|
599
|
+
select: "select",
|
|
600
|
+
dropdown: "select",
|
|
601
|
+
multiselect: "multiselect",
|
|
602
|
+
checkbox: "checkbox",
|
|
603
|
+
boolean: "checkbox",
|
|
604
|
+
toggle: "toggle",
|
|
605
|
+
switch: "toggle",
|
|
606
|
+
radio: "radio",
|
|
607
|
+
slider: "slider",
|
|
608
|
+
range: "slider",
|
|
609
|
+
rating: "rating",
|
|
610
|
+
stars: "rating",
|
|
611
|
+
color: "color",
|
|
612
|
+
file: "file",
|
|
613
|
+
upload: "file",
|
|
614
|
+
signature: "signature"
|
|
615
|
+
}[t.toLowerCase()] || "text";
|
|
616
|
+
}
|
|
617
|
+
function vt(t) {
|
|
618
|
+
return t.map((r, a) => {
|
|
619
|
+
var l;
|
|
620
|
+
return {
|
|
621
|
+
id: `field_${Date.now()}_${a}`,
|
|
622
|
+
type: bt(r.type),
|
|
623
|
+
label: r.label,
|
|
624
|
+
name: r.field,
|
|
625
|
+
placeholder: r.placeholder,
|
|
626
|
+
helperText: r.helpText,
|
|
627
|
+
required: r.required,
|
|
628
|
+
options: (l = r.options) == null ? void 0 : l.map((o, i) => ({
|
|
629
|
+
value: o.toLowerCase().replace(/\s+/g, "_"),
|
|
630
|
+
label: o
|
|
631
|
+
})),
|
|
632
|
+
validation: r.required ? [{ type: "required", message: `${r.label} is required` }] : [],
|
|
633
|
+
width: "100%",
|
|
634
|
+
order: a
|
|
635
|
+
};
|
|
636
|
+
});
|
|
637
|
+
}
|
|
638
|
+
const Ut = ee(
|
|
639
|
+
function(r, a) {
|
|
640
|
+
const {
|
|
641
|
+
enableAI: l = !0,
|
|
642
|
+
aiModel: o,
|
|
643
|
+
enableGenerate: i = !0,
|
|
644
|
+
enableSuggestions: n = !0,
|
|
645
|
+
onGenerate: c,
|
|
646
|
+
showAIToolbar: f = !0,
|
|
647
|
+
templates: p = gt,
|
|
648
|
+
fields: y,
|
|
649
|
+
onChange: s
|
|
650
|
+
} = r, [h, F] = K(!1), [O, D] = K(""), [A, C] = K([]), [w, $] = K(y || []), [J, M] = K(!1), [I, v] = K({}), { t: k } = ze(), j = Ue(), { generateForm: U, isLoading: L } = He(), S = l && j.isConfigured, H = Q(
|
|
651
|
+
async (g) => {
|
|
652
|
+
if (!S || !i || !g.trim())
|
|
653
|
+
return [];
|
|
654
|
+
try {
|
|
655
|
+
const x = await U(g);
|
|
656
|
+
return C(x), c == null || c(g, x), x;
|
|
657
|
+
} catch {
|
|
658
|
+
return [];
|
|
659
|
+
}
|
|
660
|
+
},
|
|
661
|
+
[S, i, U, c]
|
|
662
|
+
), N = Q(
|
|
663
|
+
(g) => {
|
|
664
|
+
const x = vt(g);
|
|
665
|
+
$((R) => [...R, ...x]), s == null || s([...w, ...x]), F(!1), C([]), D("");
|
|
666
|
+
},
|
|
667
|
+
[s]
|
|
668
|
+
), q = Q(() => w, [w]), m = Q(() => {
|
|
669
|
+
$([]), s == null || s([]);
|
|
670
|
+
}, [s]), _ = (g) => {
|
|
671
|
+
D(g.description), M(!1), H(g.description);
|
|
672
|
+
};
|
|
673
|
+
at(a, () => ({
|
|
674
|
+
generateForm: H,
|
|
675
|
+
getFields: q,
|
|
676
|
+
applyFields: N,
|
|
677
|
+
clearFields: m
|
|
678
|
+
}));
|
|
679
|
+
const E = (g) => ({
|
|
680
|
+
text: "edit",
|
|
681
|
+
textarea: "file",
|
|
682
|
+
number: "hash",
|
|
683
|
+
email: "mail",
|
|
684
|
+
password: "lock",
|
|
685
|
+
phone: "phone",
|
|
686
|
+
date: "calendar",
|
|
687
|
+
select: "list",
|
|
688
|
+
checkbox: "check",
|
|
689
|
+
toggle: "settings",
|
|
690
|
+
radio: "circle",
|
|
691
|
+
file: "paperclip",
|
|
692
|
+
rating: "star"
|
|
693
|
+
})[g] || "edit";
|
|
694
|
+
return /* @__PURE__ */ u("div", { className: "nice-form-builder-ai", "data-testid": r["data-testid"], children: [
|
|
695
|
+
f && S && /* @__PURE__ */ u("div", { className: "nice-form-builder-ai__toolbar", children: [
|
|
696
|
+
/* @__PURE__ */ u("div", { className: "nice-form-builder-ai__toolbar-left", children: [
|
|
697
|
+
/* @__PURE__ */ e("span", { className: "nice-form-builder-ai__badge", children: "AI" }),
|
|
698
|
+
L && /* @__PURE__ */ e("span", { className: "nice-form-builder-ai__loading", children: k("formBuilderAI.generating", "Generating...") })
|
|
699
|
+
] }),
|
|
700
|
+
/* @__PURE__ */ u("div", { className: "nice-form-builder-ai__toolbar-right", children: [
|
|
701
|
+
i && /* @__PURE__ */ u(
|
|
702
|
+
"button",
|
|
703
|
+
{
|
|
704
|
+
type: "button",
|
|
705
|
+
className: "nice-form-builder-ai__btn",
|
|
706
|
+
onClick: () => F(!0),
|
|
707
|
+
disabled: L,
|
|
708
|
+
children: [
|
|
709
|
+
/* @__PURE__ */ e(z, { name: "zap", size: "sm" }),
|
|
710
|
+
" ",
|
|
711
|
+
k("formBuilderAI.generateForm", "Generate Form")
|
|
712
|
+
]
|
|
713
|
+
}
|
|
714
|
+
),
|
|
715
|
+
/* @__PURE__ */ u("div", { className: "nice-form-builder-ai__templates-dropdown", children: [
|
|
716
|
+
/* @__PURE__ */ u(
|
|
717
|
+
"button",
|
|
718
|
+
{
|
|
719
|
+
type: "button",
|
|
720
|
+
className: "nice-form-builder-ai__btn nice-form-builder-ai__btn--secondary",
|
|
721
|
+
onClick: () => M(!J),
|
|
722
|
+
children: [
|
|
723
|
+
/* @__PURE__ */ e(z, { name: "list", size: "sm" }),
|
|
724
|
+
" ",
|
|
725
|
+
k("formBuilderAI.templates", "Templates"),
|
|
726
|
+
" ",
|
|
727
|
+
/* @__PURE__ */ e(z, { name: "chevron-down", size: "sm" })
|
|
728
|
+
]
|
|
729
|
+
}
|
|
730
|
+
),
|
|
731
|
+
J && /* @__PURE__ */ e("div", { className: "nice-form-builder-ai__templates-menu", children: p.map((g, x) => /* @__PURE__ */ u(
|
|
732
|
+
"button",
|
|
733
|
+
{
|
|
734
|
+
type: "button",
|
|
735
|
+
className: "nice-form-builder-ai__template-item",
|
|
736
|
+
onClick: () => _(g),
|
|
737
|
+
children: [
|
|
738
|
+
/* @__PURE__ */ e("span", { className: "nice-form-builder-ai__template-name", children: g.name }),
|
|
739
|
+
/* @__PURE__ */ e("span", { className: "nice-form-builder-ai__template-desc", children: g.description })
|
|
740
|
+
]
|
|
741
|
+
},
|
|
742
|
+
x
|
|
743
|
+
)) })
|
|
744
|
+
] })
|
|
745
|
+
] })
|
|
746
|
+
] }),
|
|
747
|
+
/* @__PURE__ */ e("div", { className: "nice-form-builder-ai__builder-wrapper", children: /* @__PURE__ */ e(
|
|
748
|
+
de,
|
|
749
|
+
{
|
|
750
|
+
fields: w,
|
|
751
|
+
value: I,
|
|
752
|
+
onChange: v,
|
|
753
|
+
columns: 1
|
|
754
|
+
}
|
|
755
|
+
) }),
|
|
756
|
+
h && /* @__PURE__ */ u("div", { className: "nice-form-builder-ai__panel", children: [
|
|
757
|
+
/* @__PURE__ */ e(
|
|
758
|
+
"div",
|
|
759
|
+
{
|
|
760
|
+
className: "nice-form-builder-ai__panel-overlay",
|
|
761
|
+
onClick: () => F(!1)
|
|
762
|
+
}
|
|
763
|
+
),
|
|
764
|
+
/* @__PURE__ */ u("div", { className: "nice-form-builder-ai__panel-content", children: [
|
|
765
|
+
/* @__PURE__ */ u("div", { className: "nice-form-builder-ai__panel-header", children: [
|
|
766
|
+
/* @__PURE__ */ u("h4", { children: [
|
|
767
|
+
/* @__PURE__ */ e(z, { name: "zap", size: "sm" }),
|
|
768
|
+
" ",
|
|
769
|
+
k("formBuilderAI.generateFormTitle", "Generate Form with AI")
|
|
770
|
+
] }),
|
|
771
|
+
/* @__PURE__ */ e(
|
|
772
|
+
"button",
|
|
773
|
+
{
|
|
774
|
+
type: "button",
|
|
775
|
+
className: "nice-form-builder-ai__panel-close",
|
|
776
|
+
onClick: () => {
|
|
777
|
+
F(!1), C([]), D("");
|
|
778
|
+
},
|
|
779
|
+
"aria-label": "Close",
|
|
780
|
+
children: /* @__PURE__ */ e(z, { name: "close", size: "sm" })
|
|
781
|
+
}
|
|
782
|
+
)
|
|
783
|
+
] }),
|
|
784
|
+
/* @__PURE__ */ u("div", { className: "nice-form-builder-ai__panel-body", children: [
|
|
785
|
+
/* @__PURE__ */ u("div", { className: "nice-form-builder-ai__prompt-section", children: [
|
|
786
|
+
/* @__PURE__ */ e("label", { className: "nice-form-builder-ai__label", children: k("formBuilderAI.describeForm", "Describe the form you want to create:") }),
|
|
787
|
+
/* @__PURE__ */ e(
|
|
788
|
+
"textarea",
|
|
789
|
+
{
|
|
790
|
+
className: "nice-form-builder-ai__textarea",
|
|
791
|
+
placeholder: k(
|
|
792
|
+
"formBuilderAI.promptPlaceholder",
|
|
793
|
+
'e.g., "A contact form with name, email, phone, subject dropdown, and message textarea"'
|
|
794
|
+
),
|
|
795
|
+
value: O,
|
|
796
|
+
onChange: (g) => D(g.target.value),
|
|
797
|
+
rows: 3
|
|
798
|
+
}
|
|
799
|
+
),
|
|
800
|
+
/* @__PURE__ */ e(
|
|
801
|
+
"button",
|
|
802
|
+
{
|
|
803
|
+
type: "button",
|
|
804
|
+
className: "nice-form-builder-ai__generate-btn",
|
|
805
|
+
onClick: () => H(O),
|
|
806
|
+
disabled: L || !O.trim(),
|
|
807
|
+
children: L ? k("formBuilderAI.generating", "Generating...") : k("formBuilderAI.generate", "Generate")
|
|
808
|
+
}
|
|
809
|
+
)
|
|
810
|
+
] }),
|
|
811
|
+
A.length > 0 && /* @__PURE__ */ u("div", { className: "nice-form-builder-ai__preview-section", children: [
|
|
812
|
+
/* @__PURE__ */ e("h5", { children: k("formBuilderAI.previewCount", "Preview ({count} fields)").replace(
|
|
813
|
+
"{count}",
|
|
814
|
+
String(A.length)
|
|
815
|
+
) }),
|
|
816
|
+
/* @__PURE__ */ e("div", { className: "nice-form-builder-ai__fields-preview", children: A.map((g, x) => /* @__PURE__ */ u("div", { className: "nice-form-builder-ai__field-preview", children: [
|
|
817
|
+
/* @__PURE__ */ e("span", { className: "nice-form-builder-ai__field-icon", children: /* @__PURE__ */ e(z, { name: E(g.type), size: "sm" }) }),
|
|
818
|
+
/* @__PURE__ */ u("div", { className: "nice-form-builder-ai__field-info", children: [
|
|
819
|
+
/* @__PURE__ */ u("span", { className: "nice-form-builder-ai__field-label", children: [
|
|
820
|
+
g.label,
|
|
821
|
+
g.required && /* @__PURE__ */ e("span", { className: "nice-form-builder-ai__required", children: "*" })
|
|
822
|
+
] }),
|
|
823
|
+
/* @__PURE__ */ e("span", { className: "nice-form-builder-ai__field-type", children: g.type })
|
|
824
|
+
] }),
|
|
825
|
+
g.options && /* @__PURE__ */ u("span", { className: "nice-form-builder-ai__field-options", children: [
|
|
826
|
+
g.options.length,
|
|
827
|
+
" options"
|
|
828
|
+
] })
|
|
829
|
+
] }, x)) })
|
|
830
|
+
] })
|
|
831
|
+
] }),
|
|
832
|
+
/* @__PURE__ */ u("div", { className: "nice-form-builder-ai__panel-footer", children: [
|
|
833
|
+
/* @__PURE__ */ u(
|
|
834
|
+
"button",
|
|
835
|
+
{
|
|
836
|
+
type: "button",
|
|
837
|
+
className: "nice-form-builder-ai__apply-btn",
|
|
838
|
+
onClick: () => N(A),
|
|
839
|
+
disabled: A.length === 0 || L,
|
|
840
|
+
children: [
|
|
841
|
+
/* @__PURE__ */ e(z, { name: "check", size: "sm" }),
|
|
842
|
+
" ",
|
|
843
|
+
k("formBuilderAI.addToForm", "Add to Form")
|
|
844
|
+
]
|
|
845
|
+
}
|
|
846
|
+
),
|
|
847
|
+
/* @__PURE__ */ e(
|
|
848
|
+
"button",
|
|
849
|
+
{
|
|
850
|
+
type: "button",
|
|
851
|
+
className: "nice-form-builder-ai__cancel-btn",
|
|
852
|
+
onClick: () => {
|
|
853
|
+
F(!1), C([]), D("");
|
|
854
|
+
},
|
|
855
|
+
children: k("formBuilderAI.cancel", "Cancel")
|
|
856
|
+
}
|
|
857
|
+
)
|
|
858
|
+
] })
|
|
859
|
+
] })
|
|
860
|
+
] })
|
|
861
|
+
] });
|
|
862
|
+
}
|
|
863
|
+
), _t = {
|
|
864
|
+
text: { type: "string" },
|
|
865
|
+
textarea: { type: "string" },
|
|
866
|
+
password: { type: "string", format: "password" },
|
|
867
|
+
phone: { type: "string", format: "phone" },
|
|
868
|
+
url: { type: "string", format: "uri" },
|
|
869
|
+
email: { type: "string", format: "email" },
|
|
870
|
+
date: { type: "string", format: "date" },
|
|
871
|
+
datetime: { type: "string", format: "date-time" },
|
|
872
|
+
time: { type: "string", format: "time" },
|
|
873
|
+
color: { type: "string", format: "color" },
|
|
874
|
+
number: { type: "number" },
|
|
875
|
+
slider: { type: "number" },
|
|
876
|
+
rating: { type: "integer" },
|
|
877
|
+
checkbox: { type: "boolean" },
|
|
878
|
+
toggle: { type: "boolean" },
|
|
879
|
+
select: { type: "string" },
|
|
880
|
+
radio: { type: "string" },
|
|
881
|
+
multiselect: { type: "array", items: { type: "string" } },
|
|
882
|
+
file: { type: "string", format: "data-url" },
|
|
883
|
+
signature: { type: "string", format: "data-url" },
|
|
884
|
+
richtext: { type: "string" },
|
|
885
|
+
markdown: { type: "string" },
|
|
886
|
+
code: { type: "string" },
|
|
887
|
+
image: { type: "string", format: "uri" }
|
|
888
|
+
};
|
|
889
|
+
function Nt(t, r) {
|
|
890
|
+
if (r)
|
|
891
|
+
for (const a of r)
|
|
892
|
+
switch (a.type) {
|
|
893
|
+
case "minLength":
|
|
894
|
+
typeof a.value == "number" && (t.minLength = a.value);
|
|
895
|
+
break;
|
|
896
|
+
case "maxLength":
|
|
897
|
+
typeof a.value == "number" && (t.maxLength = a.value);
|
|
898
|
+
break;
|
|
899
|
+
case "min":
|
|
900
|
+
typeof a.value == "number" && (t.minimum = a.value);
|
|
901
|
+
break;
|
|
902
|
+
case "max":
|
|
903
|
+
typeof a.value == "number" && (t.maximum = a.value);
|
|
904
|
+
break;
|
|
905
|
+
case "pattern":
|
|
906
|
+
typeof a.value == "string" && (t.pattern = a.value);
|
|
907
|
+
break;
|
|
908
|
+
case "email":
|
|
909
|
+
t.format = "email";
|
|
910
|
+
break;
|
|
911
|
+
case "url":
|
|
912
|
+
t.format = "uri";
|
|
913
|
+
break;
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
function Et(t) {
|
|
917
|
+
if (t.type === "heading" || t.type === "paragraph" || t.type === "divider" || t.type === "spacer")
|
|
918
|
+
return null;
|
|
919
|
+
const r = _t[t.type];
|
|
920
|
+
if (!r)
|
|
921
|
+
return null;
|
|
922
|
+
const a = { ...r };
|
|
923
|
+
return t.label && (a.title = t.label), t.helpText && (a.description = t.helpText), t.defaultValue !== void 0 && (a.default = t.defaultValue), t.options && (t.type === "select" || t.type === "radio") && (a.enum = t.options.map((l) => typeof l == "string" ? l : l.value)), t.options && t.type === "multiselect" && (a.items = {
|
|
924
|
+
type: "string",
|
|
925
|
+
enum: t.options.map((l) => typeof l == "string" ? l : String(l.value))
|
|
926
|
+
}), Nt(a, t.validations), a;
|
|
927
|
+
}
|
|
928
|
+
function Ht(t) {
|
|
929
|
+
const r = {}, a = [], l = (i) => {
|
|
930
|
+
var n;
|
|
931
|
+
for (const c of i) {
|
|
932
|
+
if (c.type === "section" && c.children) {
|
|
933
|
+
l(c.children);
|
|
934
|
+
continue;
|
|
935
|
+
}
|
|
936
|
+
const f = Et(c);
|
|
937
|
+
f && (r[c.name] = f, (c.required || (n = c.validations) != null && n.some((p) => p.type === "required")) && a.push(c.name));
|
|
938
|
+
}
|
|
939
|
+
};
|
|
940
|
+
for (const i of t.sections)
|
|
941
|
+
l(i.fields);
|
|
942
|
+
const o = {
|
|
943
|
+
$schema: "http://json-schema.org/draft-07/schema#",
|
|
944
|
+
$id: t.id,
|
|
945
|
+
type: "object",
|
|
946
|
+
title: t.title,
|
|
947
|
+
description: t.description,
|
|
948
|
+
properties: r,
|
|
949
|
+
additionalProperties: !1
|
|
950
|
+
};
|
|
951
|
+
return a.length > 0 && (o.required = a), o;
|
|
952
|
+
}
|
|
953
|
+
const wt = [
|
|
954
|
+
{
|
|
955
|
+
target: ".nice-manifest-editor",
|
|
956
|
+
titleKey: "tutorial.manifestEditor.intro.title",
|
|
957
|
+
title: "Manifest editor",
|
|
958
|
+
contentKey: "tutorial.manifestEditor.intro.content",
|
|
959
|
+
content: "Edit the manifest in schema-driven sections. Toggle Form ⇄ JSON per section; validation appears in the status bar.",
|
|
960
|
+
placement: "auto"
|
|
961
|
+
},
|
|
962
|
+
{
|
|
963
|
+
target: ".nice-manifest-editor__pane",
|
|
964
|
+
titleKey: "tutorial.manifestEditor.sections.title",
|
|
965
|
+
title: "Sections",
|
|
966
|
+
contentKey: "tutorial.manifestEditor.sections.content",
|
|
967
|
+
content: "The manifest is split into schema-driven sections — switch between them using the tabs at the top.",
|
|
968
|
+
placement: "auto"
|
|
969
|
+
},
|
|
970
|
+
{
|
|
971
|
+
target: ".nice-manifest-editor__pane",
|
|
972
|
+
titleKey: "tutorial.manifestEditor.json.title",
|
|
973
|
+
title: "Form ⇄ JSON",
|
|
974
|
+
contentKey: "tutorial.manifestEditor.json.content",
|
|
975
|
+
content: "Each section can be edited as a visual form or as raw JSON — use the toggle inside the section.",
|
|
976
|
+
placement: "auto"
|
|
977
|
+
}
|
|
978
|
+
];
|
|
979
|
+
function Gt(t) {
|
|
980
|
+
return t;
|
|
981
|
+
}
|
|
982
|
+
const Wt = ee(
|
|
983
|
+
function(r, a) {
|
|
984
|
+
var x;
|
|
985
|
+
const {
|
|
986
|
+
value: l,
|
|
987
|
+
defaultValue: o,
|
|
988
|
+
sections: i,
|
|
989
|
+
onChange: n,
|
|
990
|
+
jsonView: c = !0,
|
|
991
|
+
scriptRunner: f,
|
|
992
|
+
triggers: p,
|
|
993
|
+
bindings: y = [],
|
|
994
|
+
handlers: s,
|
|
995
|
+
onBindingsChange: h,
|
|
996
|
+
revisions: F,
|
|
997
|
+
onRollback: O,
|
|
998
|
+
loadContent: D,
|
|
999
|
+
logs: A,
|
|
1000
|
+
onClearLogs: C,
|
|
1001
|
+
extraTabs: w,
|
|
1002
|
+
validate: $,
|
|
1003
|
+
theme: J = "light",
|
|
1004
|
+
height: M = 560,
|
|
1005
|
+
tutorial: I,
|
|
1006
|
+
className: v,
|
|
1007
|
+
style: k,
|
|
1008
|
+
id: j,
|
|
1009
|
+
"data-testid": U
|
|
1010
|
+
} = r, { t: L } = Z(), [S, H] = le({
|
|
1011
|
+
value: l,
|
|
1012
|
+
defaultValue: o,
|
|
1013
|
+
fallbackValue: {},
|
|
1014
|
+
onChange: n,
|
|
1015
|
+
componentName: "NiceManifestEditor"
|
|
1016
|
+
}), N = P(() => {
|
|
1017
|
+
const R = i.map((G) => ({
|
|
1018
|
+
key: `section:${G.id}`,
|
|
1019
|
+
label: G.title,
|
|
1020
|
+
icon: G.icon,
|
|
1021
|
+
content: /* @__PURE__ */ e("div", { className: "nice-manifest-editor__pane", children: /* @__PURE__ */ e(
|
|
1022
|
+
de,
|
|
1023
|
+
{
|
|
1024
|
+
schema: G.schema,
|
|
1025
|
+
fields: G.fields,
|
|
1026
|
+
uiSchema: G.uiSchema,
|
|
1027
|
+
value: S,
|
|
1028
|
+
onChange: H,
|
|
1029
|
+
showJsonView: c
|
|
1030
|
+
}
|
|
1031
|
+
) })
|
|
1032
|
+
}));
|
|
1033
|
+
return f && R.push({
|
|
1034
|
+
key: "scripts",
|
|
1035
|
+
label: L("manifestEditor.tab.scripts", "Scripts"),
|
|
1036
|
+
content: /* @__PURE__ */ e("div", { className: "nice-manifest-editor__pane", children: /* @__PURE__ */ e(we, { ...f }) })
|
|
1037
|
+
}), p && p.length > 0 && R.push({
|
|
1038
|
+
key: "lifecycle",
|
|
1039
|
+
label: L("manifestEditor.tab.lifecycle", "Lifecycle"),
|
|
1040
|
+
content: /* @__PURE__ */ e("div", { className: "nice-manifest-editor__pane", children: /* @__PURE__ */ e(
|
|
1041
|
+
ke,
|
|
1042
|
+
{
|
|
1043
|
+
triggers: p,
|
|
1044
|
+
bindings: y,
|
|
1045
|
+
handlers: s,
|
|
1046
|
+
onChange: (G) => h == null ? void 0 : h(G),
|
|
1047
|
+
groupByTrigger: !0,
|
|
1048
|
+
allowCondition: !0
|
|
1049
|
+
}
|
|
1050
|
+
) })
|
|
1051
|
+
}), F && F.length > 0 && R.push({
|
|
1052
|
+
key: "history",
|
|
1053
|
+
label: L("manifestEditor.tab.history", "History"),
|
|
1054
|
+
content: /* @__PURE__ */ e("div", { className: "nice-manifest-editor__pane", children: /* @__PURE__ */ e(
|
|
1055
|
+
Se,
|
|
1056
|
+
{
|
|
1057
|
+
revisions: F,
|
|
1058
|
+
onRollback: O,
|
|
1059
|
+
loadContent: D,
|
|
1060
|
+
language: "json"
|
|
1061
|
+
}
|
|
1062
|
+
) })
|
|
1063
|
+
}), w && R.push(...w), R;
|
|
1064
|
+
}, [
|
|
1065
|
+
i,
|
|
1066
|
+
S,
|
|
1067
|
+
H,
|
|
1068
|
+
c,
|
|
1069
|
+
f,
|
|
1070
|
+
p,
|
|
1071
|
+
y,
|
|
1072
|
+
s,
|
|
1073
|
+
h,
|
|
1074
|
+
F,
|
|
1075
|
+
O,
|
|
1076
|
+
D,
|
|
1077
|
+
w,
|
|
1078
|
+
L
|
|
1079
|
+
]), [q, m] = K(((x = N[0]) == null ? void 0 : x.key) ?? "");
|
|
1080
|
+
oe(() => {
|
|
1081
|
+
N.length > 0 && !N.some((R) => R.key === q) && m(N[0].key);
|
|
1082
|
+
}, [N, q]);
|
|
1083
|
+
const _ = P(() => $ ? $(S) : [], [$, S]), E = P(() => {
|
|
1084
|
+
const R = [
|
|
1085
|
+
{
|
|
1086
|
+
key: "sections",
|
|
1087
|
+
label: `${i.length} ${L("manifestEditor.sections", "sections")}`,
|
|
1088
|
+
position: "left"
|
|
1089
|
+
}
|
|
1090
|
+
];
|
|
1091
|
+
return $ && R.push({
|
|
1092
|
+
key: "validation",
|
|
1093
|
+
label: /* @__PURE__ */ u("span", { className: "nice-manifest-editor__status", children: [
|
|
1094
|
+
/* @__PURE__ */ e(z, { name: _.length === 0 ? "check" : "warning", size: 12 }),
|
|
1095
|
+
_.length === 0 ? L("manifestEditor.status.valid", "Valid") : `${_.length} ${L("manifestEditor.status.issues", "issues")}`
|
|
1096
|
+
] }),
|
|
1097
|
+
position: "left"
|
|
1098
|
+
}), R;
|
|
1099
|
+
}, [i.length, $, _.length, L]), g = "nice-manifest-editor" + (v ? ` ${v}` : "");
|
|
1100
|
+
return /* @__PURE__ */ e(
|
|
1101
|
+
Te,
|
|
1102
|
+
{
|
|
1103
|
+
ref: a,
|
|
1104
|
+
id: j,
|
|
1105
|
+
className: g,
|
|
1106
|
+
style: { height: M, ...k },
|
|
1107
|
+
"data-testid": U,
|
|
1108
|
+
theme: J,
|
|
1109
|
+
tabs: N,
|
|
1110
|
+
activeTabKey: q,
|
|
1111
|
+
onTabChange: m,
|
|
1112
|
+
statusItems: E,
|
|
1113
|
+
toolbar: I ? /* @__PURE__ */ e(se, { steps: ce(I, wt) }) : void 0,
|
|
1114
|
+
bottomPanel: A !== void 0 ? /* @__PURE__ */ e(
|
|
1115
|
+
Fe,
|
|
1116
|
+
{
|
|
1117
|
+
title: L("manifestEditor.output", "Output"),
|
|
1118
|
+
entries: A,
|
|
1119
|
+
onClear: C,
|
|
1120
|
+
maxHeight: "100%"
|
|
1121
|
+
}
|
|
1122
|
+
) : void 0
|
|
1123
|
+
}
|
|
1124
|
+
);
|
|
1125
|
+
}
|
|
1126
|
+
), me = "__eeRid", pe = "__eeFid", kt = [
|
|
1127
|
+
{
|
|
1128
|
+
target: ".nice-entity-editor",
|
|
1129
|
+
titleKey: "tutorial.entityEditor.intro.title",
|
|
1130
|
+
title: "Entity editor",
|
|
1131
|
+
contentKey: "tutorial.entityEditor.intro.content",
|
|
1132
|
+
content: "Browse your entities in the list, then click one (or “New entity”) to edit its metadata, fields and validation on a dedicated screen.",
|
|
1133
|
+
placement: "auto"
|
|
1134
|
+
}
|
|
1135
|
+
], St = {
|
|
1136
|
+
type: "object",
|
|
1137
|
+
properties: {
|
|
1138
|
+
name: {
|
|
1139
|
+
type: "string",
|
|
1140
|
+
title: "Name",
|
|
1141
|
+
minLength: 1,
|
|
1142
|
+
description: "Unique technical name of the entity (PascalCase)."
|
|
1143
|
+
},
|
|
1144
|
+
displayName: {
|
|
1145
|
+
type: "string",
|
|
1146
|
+
title: "Display name",
|
|
1147
|
+
description: "Human-friendly name shown in the UI."
|
|
1148
|
+
},
|
|
1149
|
+
tableName: {
|
|
1150
|
+
type: "string",
|
|
1151
|
+
title: "Table name",
|
|
1152
|
+
description: "Database table that backs this entity."
|
|
1153
|
+
},
|
|
1154
|
+
description: {
|
|
1155
|
+
type: "string",
|
|
1156
|
+
title: "Description",
|
|
1157
|
+
description: "Optional notes about the entity's purpose."
|
|
1158
|
+
},
|
|
1159
|
+
entityIcon: {
|
|
1160
|
+
type: "string",
|
|
1161
|
+
title: "Icon",
|
|
1162
|
+
description: "Icon key shown next to the entity."
|
|
1163
|
+
},
|
|
1164
|
+
isAudited: {
|
|
1165
|
+
type: "boolean",
|
|
1166
|
+
title: "Audited",
|
|
1167
|
+
description: "Track who created/changed each record and when."
|
|
1168
|
+
},
|
|
1169
|
+
isSoftDeleteEnabled: {
|
|
1170
|
+
type: "boolean",
|
|
1171
|
+
title: "Soft delete",
|
|
1172
|
+
description: "Flag rows as deleted instead of physically removing them."
|
|
1173
|
+
}
|
|
1174
|
+
},
|
|
1175
|
+
required: ["name"]
|
|
1176
|
+
}, Tt = {
|
|
1177
|
+
type: "object",
|
|
1178
|
+
properties: {
|
|
1179
|
+
name: {
|
|
1180
|
+
type: "string",
|
|
1181
|
+
title: "Name",
|
|
1182
|
+
minLength: 1,
|
|
1183
|
+
description: "Field's technical name (the database column)."
|
|
1184
|
+
},
|
|
1185
|
+
displayName: {
|
|
1186
|
+
type: "string",
|
|
1187
|
+
title: "Display name",
|
|
1188
|
+
description: "Human-friendly label shown in the UI."
|
|
1189
|
+
},
|
|
1190
|
+
dataType: {
|
|
1191
|
+
type: "string",
|
|
1192
|
+
title: "Type",
|
|
1193
|
+
description: "Storage / data type of the field.",
|
|
1194
|
+
enum: [
|
|
1195
|
+
"Guid",
|
|
1196
|
+
"string",
|
|
1197
|
+
"text",
|
|
1198
|
+
"int",
|
|
1199
|
+
"long",
|
|
1200
|
+
"decimal",
|
|
1201
|
+
"double",
|
|
1202
|
+
"bool",
|
|
1203
|
+
"DateTime",
|
|
1204
|
+
"DateOnly",
|
|
1205
|
+
"json"
|
|
1206
|
+
]
|
|
1207
|
+
},
|
|
1208
|
+
isPrimaryKey: {
|
|
1209
|
+
type: "boolean",
|
|
1210
|
+
title: "Primary key",
|
|
1211
|
+
description: "Primary key — uniquely identifies each record."
|
|
1212
|
+
},
|
|
1213
|
+
isForeignKey: {
|
|
1214
|
+
type: "boolean",
|
|
1215
|
+
title: "Foreign key",
|
|
1216
|
+
description: "Foreign key — references another entity's primary key."
|
|
1217
|
+
},
|
|
1218
|
+
isRequired: {
|
|
1219
|
+
type: "boolean",
|
|
1220
|
+
title: "Required",
|
|
1221
|
+
description: "Value must be provided (NOT NULL)."
|
|
1222
|
+
},
|
|
1223
|
+
isUnique: {
|
|
1224
|
+
type: "boolean",
|
|
1225
|
+
title: "Unique",
|
|
1226
|
+
description: "Each value must be unique across all records."
|
|
1227
|
+
},
|
|
1228
|
+
isIndexed: {
|
|
1229
|
+
type: "boolean",
|
|
1230
|
+
title: "Indexed",
|
|
1231
|
+
description: "Add a database index for faster lookups and filtering."
|
|
1232
|
+
},
|
|
1233
|
+
isNullable: {
|
|
1234
|
+
type: "boolean",
|
|
1235
|
+
title: "Nullable",
|
|
1236
|
+
description: "Allow empty (NULL) values."
|
|
1237
|
+
},
|
|
1238
|
+
maxLength: {
|
|
1239
|
+
type: "integer",
|
|
1240
|
+
title: "Max length",
|
|
1241
|
+
description: "Maximum number of characters (for string types)."
|
|
1242
|
+
},
|
|
1243
|
+
defaultValue: {
|
|
1244
|
+
type: "string",
|
|
1245
|
+
title: "Default",
|
|
1246
|
+
description: "Value used when none is provided."
|
|
1247
|
+
},
|
|
1248
|
+
description: {
|
|
1249
|
+
type: "string",
|
|
1250
|
+
title: "Description",
|
|
1251
|
+
description: "Optional notes about the field."
|
|
1252
|
+
},
|
|
1253
|
+
isComputed: {
|
|
1254
|
+
type: "boolean",
|
|
1255
|
+
title: "Computed",
|
|
1256
|
+
description: "Value is derived from an expression instead of stored input."
|
|
1257
|
+
},
|
|
1258
|
+
computedExpression: {
|
|
1259
|
+
type: "string",
|
|
1260
|
+
title: "Computed expression",
|
|
1261
|
+
description: "Expression used to compute the value (when Computed is on)."
|
|
1262
|
+
}
|
|
1263
|
+
},
|
|
1264
|
+
required: ["name", "dataType"]
|
|
1265
|
+
};
|
|
1266
|
+
function he({ title: t, help: r }) {
|
|
1267
|
+
return /* @__PURE__ */ u("span", { className: "nice-entity-editor__field-label", children: [
|
|
1268
|
+
t,
|
|
1269
|
+
r ? /* @__PURE__ */ e(X, { content: r, children: /* @__PURE__ */ e("span", { className: "nice-entity-editor__help", role: "img", "aria-label": r, children: /* @__PURE__ */ e(z, { name: "info", size: 14 }) }) }) : null
|
|
1270
|
+
] });
|
|
1271
|
+
}
|
|
1272
|
+
function Ft({
|
|
1273
|
+
schema: t,
|
|
1274
|
+
value: r,
|
|
1275
|
+
onChange: a,
|
|
1276
|
+
readOnly: l
|
|
1277
|
+
}) {
|
|
1278
|
+
const o = t.properties ?? {};
|
|
1279
|
+
return /* @__PURE__ */ e("div", { className: "nice-entity-editor__field-form", children: Object.entries(o).map(([i, n]) => {
|
|
1280
|
+
const c = r[i], f = n.description, p = n.title ?? i;
|
|
1281
|
+
if (n.type === "boolean")
|
|
1282
|
+
return /* @__PURE__ */ e(
|
|
1283
|
+
"div",
|
|
1284
|
+
{
|
|
1285
|
+
className: "nice-entity-editor__field-row nice-entity-editor__field-row--check",
|
|
1286
|
+
children: /* @__PURE__ */ e(
|
|
1287
|
+
Ye,
|
|
1288
|
+
{
|
|
1289
|
+
label: /* @__PURE__ */ e(he, { title: p, help: f }),
|
|
1290
|
+
checked: !!c,
|
|
1291
|
+
onChange: (s) => a(i, s),
|
|
1292
|
+
disabled: l
|
|
1293
|
+
}
|
|
1294
|
+
)
|
|
1295
|
+
},
|
|
1296
|
+
i
|
|
1297
|
+
);
|
|
1298
|
+
if (Array.isArray(n.enum) && n.enum.length > 0)
|
|
1299
|
+
return /* @__PURE__ */ u("div", { className: "nice-entity-editor__field-row", children: [
|
|
1300
|
+
/* @__PURE__ */ e(he, { title: p, help: f }),
|
|
1301
|
+
/* @__PURE__ */ e(
|
|
1302
|
+
Qe,
|
|
1303
|
+
{
|
|
1304
|
+
options: n.enum.map((s) => ({ label: String(s), value: String(s) })),
|
|
1305
|
+
value: c == null ? "" : String(c),
|
|
1306
|
+
onChange: (s) => a(i, s),
|
|
1307
|
+
clearable: !0,
|
|
1308
|
+
disabled: l
|
|
1309
|
+
}
|
|
1310
|
+
)
|
|
1311
|
+
] }, i);
|
|
1312
|
+
const y = n.type === "integer" || n.type === "number";
|
|
1313
|
+
return /* @__PURE__ */ u("div", { className: "nice-entity-editor__field-row", children: [
|
|
1314
|
+
/* @__PURE__ */ e(he, { title: p, help: f }),
|
|
1315
|
+
/* @__PURE__ */ e(
|
|
1316
|
+
Xe,
|
|
1317
|
+
{
|
|
1318
|
+
value: c == null ? "" : String(c),
|
|
1319
|
+
onChange: (s) => a(i, y ? s === "" ? void 0 : Number(s) : s),
|
|
1320
|
+
disabled: l
|
|
1321
|
+
}
|
|
1322
|
+
)
|
|
1323
|
+
] }, i);
|
|
1324
|
+
}) });
|
|
1325
|
+
}
|
|
1326
|
+
function xt({
|
|
1327
|
+
fields: t,
|
|
1328
|
+
onChange: r,
|
|
1329
|
+
fieldSchema: a,
|
|
1330
|
+
readOnly: l
|
|
1331
|
+
}) {
|
|
1332
|
+
const { t: o } = Z(), [i, n] = K(null), c = P(() => t.map((s, h) => ({ ...s, [pe]: String(h) })), [t]), f = P(
|
|
1333
|
+
() => [
|
|
1334
|
+
{
|
|
1335
|
+
field: "name",
|
|
1336
|
+
header: o("entityEditor.field.name", "Name"),
|
|
1337
|
+
sortable: !0,
|
|
1338
|
+
render: (s) => /* @__PURE__ */ e("span", { className: "nice-entity-editor__name", children: String(s ?? "") })
|
|
1339
|
+
},
|
|
1340
|
+
{
|
|
1341
|
+
field: "dataType",
|
|
1342
|
+
header: o("entityEditor.field.type", "Type"),
|
|
1343
|
+
sortable: !0,
|
|
1344
|
+
render: (s) => /* @__PURE__ */ e(ae, { variant: "secondary", size: "sm", outline: !0, children: String(s ?? "—") })
|
|
1345
|
+
},
|
|
1346
|
+
{
|
|
1347
|
+
field: "__flags",
|
|
1348
|
+
header: o("entityEditor.field.flags", "Constraints"),
|
|
1349
|
+
headerTooltip: o(
|
|
1350
|
+
"entityEditor.field.flags.help",
|
|
1351
|
+
"Key / required / unique / indexed constraints on this field"
|
|
1352
|
+
),
|
|
1353
|
+
render: (s, h) => {
|
|
1354
|
+
const F = [
|
|
1355
|
+
[!!(h != null && h.isPrimaryKey), "PK", o("entityEditor.flag.pk", "Primary key"), "info"],
|
|
1356
|
+
[!!(h != null && h.isForeignKey), "FK", o("entityEditor.flag.fk", "Foreign key"), "info"],
|
|
1357
|
+
[
|
|
1358
|
+
!!(h != null && h.isRequired),
|
|
1359
|
+
"Req",
|
|
1360
|
+
o("entityEditor.flag.required", "Required (NOT NULL)"),
|
|
1361
|
+
"warning"
|
|
1362
|
+
],
|
|
1363
|
+
[!!(h != null && h.isUnique), "Uniq", o("entityEditor.flag.unique", "Unique"), "secondary"],
|
|
1364
|
+
[
|
|
1365
|
+
!!(h != null && h.isIndexed),
|
|
1366
|
+
"Idx",
|
|
1367
|
+
o("entityEditor.flag.indexed", "Indexed"),
|
|
1368
|
+
"secondary"
|
|
1369
|
+
]
|
|
1370
|
+
];
|
|
1371
|
+
return /* @__PURE__ */ e("span", { className: "nice-entity-editor__flags", children: F.filter(([O]) => O).map(([, O, D, A]) => /* @__PURE__ */ e(X, { content: D, children: /* @__PURE__ */ e(ae, { variant: A, size: "sm", children: O }) }, O)) });
|
|
1372
|
+
}
|
|
1373
|
+
}
|
|
1374
|
+
],
|
|
1375
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1376
|
+
[]
|
|
1377
|
+
), p = (s, h, F) => {
|
|
1378
|
+
r(t.map((O, D) => D === s ? { ...O, [h]: F } : O));
|
|
1379
|
+
}, y = () => {
|
|
1380
|
+
const s = [...t, { name: `field${t.length + 1}`, dataType: "string" }];
|
|
1381
|
+
r(s), n(s.length - 1);
|
|
1382
|
+
};
|
|
1383
|
+
if (i != null && t[i]) {
|
|
1384
|
+
const s = t[i];
|
|
1385
|
+
return /* @__PURE__ */ u("div", { className: "nice-entity-editor__field-detail", children: [
|
|
1386
|
+
/* @__PURE__ */ u("header", { className: "nice-entity-editor__edit-header", children: [
|
|
1387
|
+
/* @__PURE__ */ e(X, { content: o("entityEditor.field.backHint", "Back to the field list"), children: /* @__PURE__ */ e(
|
|
1388
|
+
te,
|
|
1389
|
+
{
|
|
1390
|
+
variant: "ghost",
|
|
1391
|
+
size: "sm",
|
|
1392
|
+
leftIcon: /* @__PURE__ */ e(z, { name: "arrow-left", size: 14 }),
|
|
1393
|
+
onClick: () => n(null),
|
|
1394
|
+
children: o("entityEditor.field.back", "Fields")
|
|
1395
|
+
}
|
|
1396
|
+
) }),
|
|
1397
|
+
/* @__PURE__ */ e("span", { className: "nice-entity-editor__breadcrumb-sep", children: "/" }),
|
|
1398
|
+
/* @__PURE__ */ e("span", { className: "nice-entity-editor__edit-title", children: String(s.name ?? o("entityEditor.field.untitled", "New field")) })
|
|
1399
|
+
] }),
|
|
1400
|
+
/* @__PURE__ */ e(
|
|
1401
|
+
Ft,
|
|
1402
|
+
{
|
|
1403
|
+
schema: a,
|
|
1404
|
+
value: s,
|
|
1405
|
+
onChange: (h, F) => p(i, h, F),
|
|
1406
|
+
readOnly: l
|
|
1407
|
+
}
|
|
1408
|
+
),
|
|
1409
|
+
/* @__PURE__ */ e("div", { className: "nice-entity-editor__field-detail-actions", children: /* @__PURE__ */ e(te, { variant: "primary", size: "sm", onClick: () => n(null), children: o("entityEditor.field.done", "Done") }) })
|
|
1410
|
+
] });
|
|
1411
|
+
}
|
|
1412
|
+
return /* @__PURE__ */ e(
|
|
1413
|
+
fe,
|
|
1414
|
+
{
|
|
1415
|
+
data: c,
|
|
1416
|
+
keyField: pe,
|
|
1417
|
+
columns: f,
|
|
1418
|
+
searchable: !0,
|
|
1419
|
+
searchPlaceholder: o("entityEditor.field.search", "Search fields…"),
|
|
1420
|
+
emptyText: o("entityEditor.field.empty", "No fields yet. Add one to define this entity."),
|
|
1421
|
+
onRowClick: (s) => n(Number(s[pe])),
|
|
1422
|
+
onRowDelete: l ? void 0 : (s) => r(t.filter((h, F) => F !== Number(s))),
|
|
1423
|
+
toolbar: l ? void 0 : /* @__PURE__ */ e(
|
|
1424
|
+
te,
|
|
1425
|
+
{
|
|
1426
|
+
variant: "primary",
|
|
1427
|
+
size: "sm",
|
|
1428
|
+
leftIcon: /* @__PURE__ */ e(z, { name: "plus", size: 14 }),
|
|
1429
|
+
onClick: y,
|
|
1430
|
+
children: o("entityEditor.field.add", "Add field")
|
|
1431
|
+
}
|
|
1432
|
+
),
|
|
1433
|
+
compact: !0,
|
|
1434
|
+
striped: !0
|
|
1435
|
+
}
|
|
1436
|
+
);
|
|
1437
|
+
}
|
|
1438
|
+
const Ct = ee(
|
|
1439
|
+
function(r, a) {
|
|
1440
|
+
const {
|
|
1441
|
+
value: l,
|
|
1442
|
+
defaultValue: o,
|
|
1443
|
+
onChange: i,
|
|
1444
|
+
entityMetaSchema: n = St,
|
|
1445
|
+
fieldSchema: c = Tt,
|
|
1446
|
+
fieldsKey: f = "fields",
|
|
1447
|
+
validationsKey: p = "validations",
|
|
1448
|
+
nameKey: y = "name",
|
|
1449
|
+
renderErPreview: s,
|
|
1450
|
+
readOnly: h = !1,
|
|
1451
|
+
tutorial: F,
|
|
1452
|
+
className: O,
|
|
1453
|
+
style: D,
|
|
1454
|
+
id: A,
|
|
1455
|
+
"data-testid": C
|
|
1456
|
+
} = r, { t: w } = Z(), [$, J] = le({
|
|
1457
|
+
value: l,
|
|
1458
|
+
defaultValue: o,
|
|
1459
|
+
fallbackValue: [],
|
|
1460
|
+
onChange: i,
|
|
1461
|
+
componentName: "NiceEntityEditor"
|
|
1462
|
+
}), [M, I] = K("list"), [v, k] = K(0), [j, U] = K("general"), L = Math.min(v, Math.max(0, $.length - 1)), S = $[L], H = M === "edit" && S != null, N = P(() => {
|
|
1463
|
+
const T = S == null ? void 0 : S[f];
|
|
1464
|
+
return Array.isArray(T) ? T : [];
|
|
1465
|
+
}, [S, f]), q = P(() => {
|
|
1466
|
+
const T = (B) => {
|
|
1467
|
+
const Y = B.toLowerCase();
|
|
1468
|
+
return /(int|long|decimal|double|float|number|money)/.test(Y) ? "number" : /bool/.test(Y) ? "boolean" : /date|time/.test(Y) ? "date" : "string";
|
|
1469
|
+
}, V = [];
|
|
1470
|
+
for (const B of N) {
|
|
1471
|
+
const Y = String(B.name ?? "");
|
|
1472
|
+
Y && V.push({
|
|
1473
|
+
field: Y,
|
|
1474
|
+
label: String(B.displayName ?? Y),
|
|
1475
|
+
type: T(String(B.dataType ?? "string"))
|
|
1476
|
+
});
|
|
1477
|
+
}
|
|
1478
|
+
return V;
|
|
1479
|
+
}, [N]), m = P(() => {
|
|
1480
|
+
const T = S == null ? void 0 : S[p];
|
|
1481
|
+
return Array.isArray(T) ? T : [];
|
|
1482
|
+
}, [S, p]), _ = P(() => $.map((T, V) => ({ ...T, [me]: String(V) })), [$]), E = (T) => {
|
|
1483
|
+
J($.map((V, B) => B === L ? { ...V, ...T } : V));
|
|
1484
|
+
}, g = (T) => {
|
|
1485
|
+
E({ [f]: T });
|
|
1486
|
+
}, x = (T) => {
|
|
1487
|
+
k(T), U("general"), I("edit");
|
|
1488
|
+
}, R = () => {
|
|
1489
|
+
const T = [...$, { [y]: `Entity${$.length + 1}`, [f]: [] }];
|
|
1490
|
+
J(T), k(T.length - 1), U("general"), I("edit");
|
|
1491
|
+
}, G = (T) => {
|
|
1492
|
+
J($.filter((V, B) => B !== T)), k((V) => V >= T ? Math.max(0, V - 1) : V);
|
|
1493
|
+
}, re = P(
|
|
1494
|
+
() => [
|
|
1495
|
+
{
|
|
1496
|
+
field: y,
|
|
1497
|
+
header: w("entityEditor.col.name", "Name"),
|
|
1498
|
+
sortable: !0,
|
|
1499
|
+
render: (T) => /* @__PURE__ */ e("span", { className: "nice-entity-editor__name", children: String(T ?? "") })
|
|
1500
|
+
},
|
|
1501
|
+
{
|
|
1502
|
+
field: "displayName",
|
|
1503
|
+
header: w("entityEditor.col.displayName", "Display name"),
|
|
1504
|
+
sortable: !0,
|
|
1505
|
+
render: (T) => /* @__PURE__ */ e("span", { className: "nice-entity-editor__muted", children: String(T ?? "—") })
|
|
1506
|
+
},
|
|
1507
|
+
{
|
|
1508
|
+
field: "tableName",
|
|
1509
|
+
header: w("entityEditor.col.table", "Table"),
|
|
1510
|
+
sortable: !0,
|
|
1511
|
+
render: (T) => /* @__PURE__ */ e("span", { className: "nice-entity-editor__muted", children: String(T ?? "—") })
|
|
1512
|
+
},
|
|
1513
|
+
{
|
|
1514
|
+
field: f,
|
|
1515
|
+
header: w("entityEditor.col.fields", "Fields"),
|
|
1516
|
+
align: "center",
|
|
1517
|
+
headerTooltip: w(
|
|
1518
|
+
"entityEditor.col.fields.help",
|
|
1519
|
+
"Number of fields defined on this entity"
|
|
1520
|
+
),
|
|
1521
|
+
render: (T) => /* @__PURE__ */ e(ae, { variant: "secondary", size: "sm", children: Array.isArray(T) ? T.length : 0 })
|
|
1522
|
+
},
|
|
1523
|
+
{
|
|
1524
|
+
field: "__flags",
|
|
1525
|
+
header: w("entityEditor.col.flags", "Flags"),
|
|
1526
|
+
render: (T, V) => /* @__PURE__ */ u("span", { className: "nice-entity-editor__flags", children: [
|
|
1527
|
+
V != null && V.isAudited ? /* @__PURE__ */ e(
|
|
1528
|
+
X,
|
|
1529
|
+
{
|
|
1530
|
+
content: w(
|
|
1531
|
+
"entityEditor.flag.audited",
|
|
1532
|
+
"Audited — tracks who changed each record and when"
|
|
1533
|
+
),
|
|
1534
|
+
children: /* @__PURE__ */ e(ae, { variant: "info", size: "sm", outline: !0, children: w("entityEditor.flag.audited.abbr", "Audit") })
|
|
1535
|
+
}
|
|
1536
|
+
) : null,
|
|
1537
|
+
V != null && V.isSoftDeleteEnabled ? /* @__PURE__ */ e(
|
|
1538
|
+
X,
|
|
1539
|
+
{
|
|
1540
|
+
content: w(
|
|
1541
|
+
"entityEditor.flag.softDelete",
|
|
1542
|
+
"Soft delete — rows are flagged deleted, never physically removed"
|
|
1543
|
+
),
|
|
1544
|
+
children: /* @__PURE__ */ e(ae, { variant: "secondary", size: "sm", outline: !0, children: w("entityEditor.flag.softDelete.abbr", "Soft-del") })
|
|
1545
|
+
}
|
|
1546
|
+
) : null
|
|
1547
|
+
] })
|
|
1548
|
+
}
|
|
1549
|
+
],
|
|
1550
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1551
|
+
[y, f]
|
|
1552
|
+
), W = P(() => {
|
|
1553
|
+
const T = [
|
|
1554
|
+
{
|
|
1555
|
+
id: "general",
|
|
1556
|
+
label: w("entityEditor.tab.general", "General"),
|
|
1557
|
+
content: S ? /* @__PURE__ */ e(
|
|
1558
|
+
de,
|
|
1559
|
+
{
|
|
1560
|
+
schema: n,
|
|
1561
|
+
value: S,
|
|
1562
|
+
onChange: (V) => E(V),
|
|
1563
|
+
columns: 2,
|
|
1564
|
+
readOnly: h,
|
|
1565
|
+
liveValidation: !0
|
|
1566
|
+
}
|
|
1567
|
+
) : null
|
|
1568
|
+
},
|
|
1569
|
+
{
|
|
1570
|
+
id: "fields",
|
|
1571
|
+
label: w("entityEditor.tab.fields", "Fields"),
|
|
1572
|
+
badge: N.length || void 0,
|
|
1573
|
+
content: /* @__PURE__ */ e(
|
|
1574
|
+
xt,
|
|
1575
|
+
{
|
|
1576
|
+
fields: N,
|
|
1577
|
+
onChange: g,
|
|
1578
|
+
fieldSchema: c,
|
|
1579
|
+
readOnly: h
|
|
1580
|
+
}
|
|
1581
|
+
)
|
|
1582
|
+
},
|
|
1583
|
+
{
|
|
1584
|
+
id: "validation",
|
|
1585
|
+
label: w("entityEditor.tab.validation", "Validation"),
|
|
1586
|
+
badge: m.length || void 0,
|
|
1587
|
+
content: /* @__PURE__ */ e(
|
|
1588
|
+
Ge,
|
|
1589
|
+
{
|
|
1590
|
+
fields: q,
|
|
1591
|
+
value: m,
|
|
1592
|
+
onChange: (V) => E({ [p]: V })
|
|
1593
|
+
}
|
|
1594
|
+
)
|
|
1595
|
+
}
|
|
1596
|
+
];
|
|
1597
|
+
return s && T.push({
|
|
1598
|
+
id: "er",
|
|
1599
|
+
label: w("entityEditor.tab.er", "ER diagram"),
|
|
1600
|
+
content: /* @__PURE__ */ e("div", { className: "nice-entity-editor__er", children: s($) })
|
|
1601
|
+
}), T;
|
|
1602
|
+
}, [
|
|
1603
|
+
S,
|
|
1604
|
+
N,
|
|
1605
|
+
m,
|
|
1606
|
+
q,
|
|
1607
|
+
n,
|
|
1608
|
+
c,
|
|
1609
|
+
h,
|
|
1610
|
+
s,
|
|
1611
|
+
$
|
|
1612
|
+
]), ie = "nice-entity-editor" + (O ? ` ${O}` : "");
|
|
1613
|
+
return /* @__PURE__ */ u("div", { ref: a, id: A, className: ie, style: D, "data-testid": C, children: [
|
|
1614
|
+
F && /* @__PURE__ */ e("div", { className: "nice-entity-editor__tutorial", children: /* @__PURE__ */ e(se, { steps: ce(F, kt) }) }),
|
|
1615
|
+
H ? /* @__PURE__ */ u("div", { className: "nice-entity-editor__edit", children: [
|
|
1616
|
+
/* @__PURE__ */ u("header", { className: "nice-entity-editor__edit-header", children: [
|
|
1617
|
+
/* @__PURE__ */ e(X, { content: w("entityEditor.backHint", "Back to the entity list"), children: /* @__PURE__ */ e(
|
|
1618
|
+
te,
|
|
1619
|
+
{
|
|
1620
|
+
variant: "ghost",
|
|
1621
|
+
size: "sm",
|
|
1622
|
+
leftIcon: /* @__PURE__ */ e(z, { name: "arrow-left", size: 14 }),
|
|
1623
|
+
onClick: () => I("list"),
|
|
1624
|
+
children: w("entityEditor.back", "Entities")
|
|
1625
|
+
}
|
|
1626
|
+
) }),
|
|
1627
|
+
/* @__PURE__ */ e("span", { className: "nice-entity-editor__breadcrumb-sep", children: "/" }),
|
|
1628
|
+
/* @__PURE__ */ e("span", { className: "nice-entity-editor__edit-title", children: String((S == null ? void 0 : S[y]) ?? w("entityEditor.untitled", "Untitled entity")) }),
|
|
1629
|
+
!h && /* @__PURE__ */ e(X, { content: w("entityEditor.deleteHint", "Delete this entity"), children: /* @__PURE__ */ e(
|
|
1630
|
+
te,
|
|
1631
|
+
{
|
|
1632
|
+
variant: "ghost",
|
|
1633
|
+
size: "sm",
|
|
1634
|
+
leftIcon: /* @__PURE__ */ e(z, { name: "trash", size: 14 }),
|
|
1635
|
+
onClick: () => {
|
|
1636
|
+
G(L), I("list");
|
|
1637
|
+
},
|
|
1638
|
+
children: w("entityEditor.delete", "Delete")
|
|
1639
|
+
}
|
|
1640
|
+
) })
|
|
1641
|
+
] }),
|
|
1642
|
+
/* @__PURE__ */ e(
|
|
1643
|
+
We,
|
|
1644
|
+
{
|
|
1645
|
+
tabs: W,
|
|
1646
|
+
activeTab: j,
|
|
1647
|
+
onChange: U,
|
|
1648
|
+
variant: "enclosed"
|
|
1649
|
+
}
|
|
1650
|
+
)
|
|
1651
|
+
] }) : /* @__PURE__ */ e("div", { className: "nice-entity-editor__list-view", children: /* @__PURE__ */ e(
|
|
1652
|
+
fe,
|
|
1653
|
+
{
|
|
1654
|
+
data: _,
|
|
1655
|
+
keyField: me,
|
|
1656
|
+
columns: re,
|
|
1657
|
+
searchable: !0,
|
|
1658
|
+
searchPlaceholder: w("entityEditor.search", "Search entities…"),
|
|
1659
|
+
emptyText: w("entityEditor.empty", "No entities yet. Create one to get started."),
|
|
1660
|
+
onRowClick: (T) => x(Number(T[me])),
|
|
1661
|
+
onRowDelete: h ? void 0 : (T) => G(Number(T)),
|
|
1662
|
+
toolbar: h ? void 0 : /* @__PURE__ */ e(
|
|
1663
|
+
te,
|
|
1664
|
+
{
|
|
1665
|
+
variant: "primary",
|
|
1666
|
+
size: "sm",
|
|
1667
|
+
leftIcon: /* @__PURE__ */ e(z, { name: "plus", size: 14 }),
|
|
1668
|
+
onClick: R,
|
|
1669
|
+
children: w("entityEditor.new", "New entity")
|
|
1670
|
+
}
|
|
1671
|
+
),
|
|
1672
|
+
compact: !0,
|
|
1673
|
+
striped: !0
|
|
1674
|
+
}
|
|
1675
|
+
) })
|
|
1676
|
+
] });
|
|
1677
|
+
}
|
|
1678
|
+
), It = [
|
|
1679
|
+
{
|
|
1680
|
+
target: ".nice-i18n-editor",
|
|
1681
|
+
titleKey: "tutorial.i18nEditor.intro.title",
|
|
1682
|
+
title: "Translations",
|
|
1683
|
+
contentKey: "tutorial.i18nEditor.intro.content",
|
|
1684
|
+
content: "Edit translations as a keys × locales grid. Add keys and locales; amber cells mark missing translations.",
|
|
1685
|
+
placement: "auto"
|
|
1686
|
+
},
|
|
1687
|
+
{
|
|
1688
|
+
target: '[data-tour="i18n-grid"]',
|
|
1689
|
+
titleKey: "tutorial.i18nEditor.grid.title",
|
|
1690
|
+
title: "Keys × locales",
|
|
1691
|
+
contentKey: "tutorial.i18nEditor.grid.content",
|
|
1692
|
+
content: "Each row is a translation key and each column a locale. Edit a cell to set a translation; amber cells are still missing.",
|
|
1693
|
+
placement: "top"
|
|
1694
|
+
},
|
|
1695
|
+
{
|
|
1696
|
+
target: '[data-tour="i18n-add"]',
|
|
1697
|
+
titleKey: "tutorial.i18nEditor.add.title",
|
|
1698
|
+
title: "Add keys & locales",
|
|
1699
|
+
contentKey: "tutorial.i18nEditor.add.content",
|
|
1700
|
+
content: "Add a new translation key or a new locale column here; new cells start empty and are flagged as missing.",
|
|
1701
|
+
placement: "top"
|
|
1702
|
+
}
|
|
1703
|
+
], At = ee(
|
|
1704
|
+
function(r, a) {
|
|
1705
|
+
const {
|
|
1706
|
+
value: l,
|
|
1707
|
+
defaultValue: o,
|
|
1708
|
+
onChange: i,
|
|
1709
|
+
locales: n,
|
|
1710
|
+
allowEditLocales: c = !0,
|
|
1711
|
+
allowEditKeys: f = !0,
|
|
1712
|
+
highlightMissing: p = !0,
|
|
1713
|
+
readOnly: y = !1,
|
|
1714
|
+
tutorial: s,
|
|
1715
|
+
className: h,
|
|
1716
|
+
style: F,
|
|
1717
|
+
id: O,
|
|
1718
|
+
"data-testid": D
|
|
1719
|
+
} = r, { t: A } = ot(), [C, w] = rt({
|
|
1720
|
+
value: l,
|
|
1721
|
+
defaultValue: o,
|
|
1722
|
+
fallbackValue: {},
|
|
1723
|
+
onChange: i,
|
|
1724
|
+
componentName: "NiceI18nEditor"
|
|
1725
|
+
}), [$, J] = K(""), [M, I] = K(""), v = P(() => n ?? Object.keys(C), [n, C]), k = P(() => {
|
|
1726
|
+
const m = /* @__PURE__ */ new Set();
|
|
1727
|
+
for (const _ of Object.keys(C))
|
|
1728
|
+
for (const E of Object.keys(C[_] ?? {}))
|
|
1729
|
+
m.add(E);
|
|
1730
|
+
return [...m].sort();
|
|
1731
|
+
}, [C]), j = (m, _, E) => {
|
|
1732
|
+
w({ ...C, [m]: { ...C[m] ?? {}, [_]: E } });
|
|
1733
|
+
}, U = (m, _) => {
|
|
1734
|
+
if (!_ || _ === m)
|
|
1735
|
+
return;
|
|
1736
|
+
const E = {};
|
|
1737
|
+
for (const g of Object.keys(C)) {
|
|
1738
|
+
const x = { ...C[g] ?? {} };
|
|
1739
|
+
m in x && (x[_] = x[m], delete x[m]), E[g] = x;
|
|
1740
|
+
}
|
|
1741
|
+
w(E);
|
|
1742
|
+
}, L = (m) => {
|
|
1743
|
+
const _ = {};
|
|
1744
|
+
for (const E of Object.keys(C)) {
|
|
1745
|
+
const g = { ...C[E] ?? {} };
|
|
1746
|
+
delete g[m], _[E] = g;
|
|
1747
|
+
}
|
|
1748
|
+
w(_);
|
|
1749
|
+
}, S = () => {
|
|
1750
|
+
const m = $.trim();
|
|
1751
|
+
if (!m || k.includes(m))
|
|
1752
|
+
return;
|
|
1753
|
+
const _ = {};
|
|
1754
|
+
for (const E of v)
|
|
1755
|
+
_[E] = { ...C[E] ?? {}, [m]: "" };
|
|
1756
|
+
for (const E of Object.keys(C))
|
|
1757
|
+
_[E] || (_[E] = C[E]);
|
|
1758
|
+
w(_), J("");
|
|
1759
|
+
}, H = () => {
|
|
1760
|
+
const m = M.trim();
|
|
1761
|
+
if (!m || C[m])
|
|
1762
|
+
return;
|
|
1763
|
+
const _ = {};
|
|
1764
|
+
for (const E of k)
|
|
1765
|
+
_[E] = "";
|
|
1766
|
+
w({ ...C, [m]: _ }), I("");
|
|
1767
|
+
}, N = (m) => {
|
|
1768
|
+
const _ = { ...C };
|
|
1769
|
+
delete _[m], w(_);
|
|
1770
|
+
}, q = "nice-i18n-editor" + (h ? ` ${h}` : "");
|
|
1771
|
+
return /* @__PURE__ */ u("div", { ref: a, id: O, className: q, style: F, "data-testid": D, children: [
|
|
1772
|
+
s && /* @__PURE__ */ e("div", { className: "nice-i18n-editor__tutorial", children: /* @__PURE__ */ e(lt, { steps: st(s, It) }) }),
|
|
1773
|
+
/* @__PURE__ */ e("div", { className: "nice-i18n-editor__scroll", "data-tour": "i18n-grid", children: /* @__PURE__ */ u("table", { className: "nice-i18n-editor__table", children: [
|
|
1774
|
+
/* @__PURE__ */ e("thead", { children: /* @__PURE__ */ u("tr", { children: [
|
|
1775
|
+
/* @__PURE__ */ e("th", { className: "nice-i18n-editor__key-head", children: A("i18nEditor.keyHead", "Key") }),
|
|
1776
|
+
v.map((m) => /* @__PURE__ */ u("th", { className: "nice-i18n-editor__locale-head", children: [
|
|
1777
|
+
/* @__PURE__ */ e("span", { children: m }),
|
|
1778
|
+
c && !y && /* @__PURE__ */ e(
|
|
1779
|
+
"button",
|
|
1780
|
+
{
|
|
1781
|
+
type: "button",
|
|
1782
|
+
className: "nice-i18n-editor__locale-remove",
|
|
1783
|
+
"aria-label": `${A("i18nEditor.removeLocale", "Remove locale")} ${m}`,
|
|
1784
|
+
onClick: () => N(m),
|
|
1785
|
+
children: /* @__PURE__ */ e(be, { name: "close", size: 12 })
|
|
1786
|
+
}
|
|
1787
|
+
)
|
|
1788
|
+
] }, m))
|
|
1789
|
+
] }) }),
|
|
1790
|
+
/* @__PURE__ */ u("tbody", { children: [
|
|
1791
|
+
k.map((m) => /* @__PURE__ */ u("tr", { children: [
|
|
1792
|
+
/* @__PURE__ */ u("td", { className: "nice-i18n-editor__key-cell", children: [
|
|
1793
|
+
f && !y ? /* @__PURE__ */ e(
|
|
1794
|
+
"input",
|
|
1795
|
+
{
|
|
1796
|
+
className: "nice-i18n-editor__key-input",
|
|
1797
|
+
defaultValue: m,
|
|
1798
|
+
onBlur: (_) => U(m, _.target.value.trim()),
|
|
1799
|
+
"aria-label": A("i18nEditor.keyAria", "Translation key")
|
|
1800
|
+
}
|
|
1801
|
+
) : /* @__PURE__ */ e("span", { className: "nice-i18n-editor__key-text", children: m }),
|
|
1802
|
+
f && !y && /* @__PURE__ */ e(
|
|
1803
|
+
"button",
|
|
1804
|
+
{
|
|
1805
|
+
type: "button",
|
|
1806
|
+
className: "nice-i18n-editor__key-remove",
|
|
1807
|
+
"aria-label": `${A("i18nEditor.removeKey", "Remove key")} ${m}`,
|
|
1808
|
+
onClick: () => L(m),
|
|
1809
|
+
children: /* @__PURE__ */ e(be, { name: "close", size: 12 })
|
|
1810
|
+
}
|
|
1811
|
+
)
|
|
1812
|
+
] }),
|
|
1813
|
+
v.map((_) => {
|
|
1814
|
+
var x;
|
|
1815
|
+
const E = ((x = C[_]) == null ? void 0 : x[m]) ?? "";
|
|
1816
|
+
return /* @__PURE__ */ e("td", { className: "nice-i18n-editor__cell", children: /* @__PURE__ */ e(
|
|
1817
|
+
"input",
|
|
1818
|
+
{
|
|
1819
|
+
className: "nice-i18n-editor__cell-input" + (p && E === "" ? " nice-i18n-editor__cell-input--missing" : ""),
|
|
1820
|
+
value: E,
|
|
1821
|
+
readOnly: y,
|
|
1822
|
+
onChange: (R) => j(_, m, R.target.value),
|
|
1823
|
+
"aria-label": `${m} (${_})`
|
|
1824
|
+
}
|
|
1825
|
+
) }, _);
|
|
1826
|
+
})
|
|
1827
|
+
] }, m)),
|
|
1828
|
+
k.length === 0 && /* @__PURE__ */ e("tr", { children: /* @__PURE__ */ e("td", { className: "nice-i18n-editor__empty", colSpan: v.length + 1, children: A("i18nEditor.empty", "No translation keys yet.") }) })
|
|
1829
|
+
] })
|
|
1830
|
+
] }) }),
|
|
1831
|
+
!y && (f || c) && /* @__PURE__ */ u("div", { className: "nice-i18n-editor__toolbar", "data-tour": "i18n-add", children: [
|
|
1832
|
+
f && /* @__PURE__ */ u("div", { className: "nice-i18n-editor__add", children: [
|
|
1833
|
+
/* @__PURE__ */ e(
|
|
1834
|
+
"input",
|
|
1835
|
+
{
|
|
1836
|
+
className: "nice-i18n-editor__add-input",
|
|
1837
|
+
placeholder: A("i18nEditor.newKeyPlaceholder", "new.key"),
|
|
1838
|
+
value: $,
|
|
1839
|
+
onChange: (m) => J(m.target.value),
|
|
1840
|
+
onKeyDown: (m) => {
|
|
1841
|
+
m.key === "Enter" && S();
|
|
1842
|
+
},
|
|
1843
|
+
"aria-label": A("i18nEditor.newKeyAria", "New key")
|
|
1844
|
+
}
|
|
1845
|
+
),
|
|
1846
|
+
/* @__PURE__ */ u("button", { type: "button", onClick: S, children: [
|
|
1847
|
+
"+ ",
|
|
1848
|
+
A("i18nEditor.addKey", "Key")
|
|
1849
|
+
] })
|
|
1850
|
+
] }),
|
|
1851
|
+
c && /* @__PURE__ */ u("div", { className: "nice-i18n-editor__add", children: [
|
|
1852
|
+
/* @__PURE__ */ e(
|
|
1853
|
+
"input",
|
|
1854
|
+
{
|
|
1855
|
+
className: "nice-i18n-editor__add-input",
|
|
1856
|
+
placeholder: A("i18nEditor.newLocalePlaceholder", "locale (e.g. de)"),
|
|
1857
|
+
value: M,
|
|
1858
|
+
onChange: (m) => I(m.target.value),
|
|
1859
|
+
onKeyDown: (m) => {
|
|
1860
|
+
m.key === "Enter" && H();
|
|
1861
|
+
},
|
|
1862
|
+
"aria-label": A("i18nEditor.newLocaleAria", "New locale")
|
|
1863
|
+
}
|
|
1864
|
+
),
|
|
1865
|
+
/* @__PURE__ */ u("button", { type: "button", onClick: H, children: [
|
|
1866
|
+
"+ ",
|
|
1867
|
+
A("i18nEditor.addLocale", "Locale")
|
|
1868
|
+
] })
|
|
1869
|
+
] })
|
|
1870
|
+
] })
|
|
1871
|
+
] });
|
|
1872
|
+
}
|
|
1873
|
+
), $t = [
|
|
1874
|
+
{
|
|
1875
|
+
target: ".nice-module-editor",
|
|
1876
|
+
titleKey: "tutorial.moduleEditor.intro.title",
|
|
1877
|
+
title: "Module editor",
|
|
1878
|
+
contentKey: "tutorial.moduleEditor.intro.content",
|
|
1879
|
+
content: "Design a whole module end-to-end — manifest, entities, translations, views, workflows, data sources and permissions — then validate and save.",
|
|
1880
|
+
placement: "auto"
|
|
1881
|
+
},
|
|
1882
|
+
{
|
|
1883
|
+
target: '[data-tour="nme-browser"]',
|
|
1884
|
+
titleKey: "tutorial.moduleEditor.browser.title",
|
|
1885
|
+
title: "Module browser",
|
|
1886
|
+
contentKey: "tutorial.moduleEditor.browser.content",
|
|
1887
|
+
content: "Search and pick a module here to open its manifest, entities and translations.",
|
|
1888
|
+
placement: "right"
|
|
1889
|
+
},
|
|
1890
|
+
{
|
|
1891
|
+
target: '[data-tour="nme-tabs"]',
|
|
1892
|
+
titleKey: "tutorial.moduleEditor.tabs.title",
|
|
1893
|
+
title: "Module parts",
|
|
1894
|
+
contentKey: "tutorial.moduleEditor.tabs.content",
|
|
1895
|
+
content: "Each tab edits one part of the module: Manifest sections, Entities, i18n, Views, Workflows, Data sources, Permissions and more.",
|
|
1896
|
+
placement: "bottom"
|
|
1897
|
+
},
|
|
1898
|
+
{
|
|
1899
|
+
target: '[data-tour="nme-validate"]',
|
|
1900
|
+
titleKey: "tutorial.moduleEditor.validate.title",
|
|
1901
|
+
title: "Validate",
|
|
1902
|
+
contentKey: "tutorial.moduleEditor.validate.content",
|
|
1903
|
+
content: "Check the module against the manifest schema. Issues appear in the status bar and the output panel.",
|
|
1904
|
+
placement: "bottom"
|
|
1905
|
+
},
|
|
1906
|
+
{
|
|
1907
|
+
target: '[data-tour="nme-save"]',
|
|
1908
|
+
titleKey: "tutorial.moduleEditor.save.title",
|
|
1909
|
+
title: "Save",
|
|
1910
|
+
contentKey: "tutorial.moduleEditor.save.content",
|
|
1911
|
+
content: "Persist your changes through the configured data provider (e.g. write the files back to disk).",
|
|
1912
|
+
placement: "bottom"
|
|
1913
|
+
},
|
|
1914
|
+
{
|
|
1915
|
+
target: '[data-tour="nme-output"]',
|
|
1916
|
+
titleKey: "tutorial.moduleEditor.output.title",
|
|
1917
|
+
title: "Output",
|
|
1918
|
+
contentKey: "tutorial.moduleEditor.output.content",
|
|
1919
|
+
content: "Validation results and load/save activity are logged here.",
|
|
1920
|
+
placement: "top"
|
|
1921
|
+
}
|
|
1922
|
+
], Yt = ee(
|
|
1923
|
+
function(r, a) {
|
|
1924
|
+
var ge;
|
|
1925
|
+
const {
|
|
1926
|
+
dataProvider: l,
|
|
1927
|
+
manifestSections: o,
|
|
1928
|
+
entityConfig: i,
|
|
1929
|
+
locales: n,
|
|
1930
|
+
validate: c,
|
|
1931
|
+
scriptRunner: f,
|
|
1932
|
+
triggers: p,
|
|
1933
|
+
bindings: y = [],
|
|
1934
|
+
handlers: s,
|
|
1935
|
+
onBindingsChange: h,
|
|
1936
|
+
revisions: F,
|
|
1937
|
+
onRollback: O,
|
|
1938
|
+
loadContent: D,
|
|
1939
|
+
theme: A = "light",
|
|
1940
|
+
height: C = 640,
|
|
1941
|
+
tutorial: w,
|
|
1942
|
+
className: $,
|
|
1943
|
+
style: J,
|
|
1944
|
+
id: M,
|
|
1945
|
+
"data-testid": I
|
|
1946
|
+
} = r, { t: v } = Z(), [k, j] = K([]), [U, L] = K(""), [S, H] = K(null), [N, q] = K(null), [m, _] = K(!1), [E, g] = K(!1), [x, R] = K([]), [G, re] = K(""), W = Q((d, b, je) => {
|
|
1947
|
+
R((Be) => [...Be, { level: d, message: b, data: je, timestamp: Date.now() }].slice(-200));
|
|
1948
|
+
}, []), ie = Q(async () => {
|
|
1949
|
+
g(!0);
|
|
1950
|
+
try {
|
|
1951
|
+
j(await l.listModules());
|
|
1952
|
+
} catch (d) {
|
|
1953
|
+
W("error", `List modules failed: ${d instanceof Error ? d.message : String(d)}`);
|
|
1954
|
+
} finally {
|
|
1955
|
+
g(!1);
|
|
1956
|
+
}
|
|
1957
|
+
}, [l, W]);
|
|
1958
|
+
oe(() => {
|
|
1959
|
+
ie();
|
|
1960
|
+
}, [ie]);
|
|
1961
|
+
const T = Q(
|
|
1962
|
+
async (d) => {
|
|
1963
|
+
g(!0);
|
|
1964
|
+
try {
|
|
1965
|
+
const b = await l.loadModule(d);
|
|
1966
|
+
q(b), H(d), _(!1), W("info", `Loaded module ${d}`);
|
|
1967
|
+
} catch (b) {
|
|
1968
|
+
W("error", `Load failed: ${b instanceof Error ? b.message : String(b)}`);
|
|
1969
|
+
} finally {
|
|
1970
|
+
g(!1);
|
|
1971
|
+
}
|
|
1972
|
+
},
|
|
1973
|
+
[l, W]
|
|
1974
|
+
), V = Q(async () => {
|
|
1975
|
+
if (!(!S || !N)) {
|
|
1976
|
+
g(!0);
|
|
1977
|
+
try {
|
|
1978
|
+
await l.saveModule(S, N), _(!1), W("info", `Saved module ${S}`);
|
|
1979
|
+
} catch (d) {
|
|
1980
|
+
W("error", `Save failed: ${d instanceof Error ? d.message : String(d)}`);
|
|
1981
|
+
} finally {
|
|
1982
|
+
g(!1);
|
|
1983
|
+
}
|
|
1984
|
+
}
|
|
1985
|
+
}, [S, N, l, W]), B = P(() => {
|
|
1986
|
+
if (!N)
|
|
1987
|
+
return [];
|
|
1988
|
+
const d = [];
|
|
1989
|
+
for (const b of o)
|
|
1990
|
+
b.schema && d.push(...Ie(N.manifest ?? {}, b.schema));
|
|
1991
|
+
return c && d.push(...c(N)), d;
|
|
1992
|
+
}, [N, o, c]), Y = Q(() => {
|
|
1993
|
+
if (B.length === 0)
|
|
1994
|
+
W("info", "Validation passed");
|
|
1995
|
+
else {
|
|
1996
|
+
W("warn", `${B.length} validation issue(s)`);
|
|
1997
|
+
for (const d of B)
|
|
1998
|
+
W("error", `${d.field}: ${d.message}`);
|
|
1999
|
+
}
|
|
2000
|
+
}, [B, W]), Ae = (d) => {
|
|
2001
|
+
q((b) => b && { ...b, manifest: d }), _(!0);
|
|
2002
|
+
}, $e = (d) => {
|
|
2003
|
+
q((b) => b && { ...b, entities: d }), _(!0);
|
|
2004
|
+
}, Ke = (d) => {
|
|
2005
|
+
q((b) => b && { ...b, i18n: d }), _(!0);
|
|
2006
|
+
}, Oe = (d) => {
|
|
2007
|
+
q((b) => b && { ...b, views: d }), _(!0);
|
|
2008
|
+
}, De = (d) => {
|
|
2009
|
+
q((b) => b && { ...b, workflows: d }), _(!0);
|
|
2010
|
+
}, Me = (d) => {
|
|
2011
|
+
q((b) => b && { ...b, dataSources: d }), _(!0);
|
|
2012
|
+
}, Le = (d) => {
|
|
2013
|
+
q((b) => b && { ...b, rbac: d }), _(!0);
|
|
2014
|
+
}, ne = P(() => {
|
|
2015
|
+
if (!N)
|
|
2016
|
+
return [];
|
|
2017
|
+
const d = o.map((b) => ({
|
|
2018
|
+
key: `section:${b.id}`,
|
|
2019
|
+
label: b.title,
|
|
2020
|
+
icon: b.icon,
|
|
2021
|
+
content: /* @__PURE__ */ e("div", { className: "nice-module-editor__pane", children: /* @__PURE__ */ e(
|
|
2022
|
+
de,
|
|
2023
|
+
{
|
|
2024
|
+
schema: b.schema,
|
|
2025
|
+
fields: b.fields,
|
|
2026
|
+
uiSchema: b.uiSchema,
|
|
2027
|
+
value: N.manifest ?? {},
|
|
2028
|
+
onChange: Ae,
|
|
2029
|
+
showJsonView: !0
|
|
2030
|
+
}
|
|
2031
|
+
) })
|
|
2032
|
+
}));
|
|
2033
|
+
return d.push({
|
|
2034
|
+
key: "entities",
|
|
2035
|
+
label: v("moduleEditor.tab.entities", "Entities"),
|
|
2036
|
+
content: /* @__PURE__ */ e("div", { className: "nice-module-editor__pane", children: /* @__PURE__ */ e(
|
|
2037
|
+
Ct,
|
|
2038
|
+
{
|
|
2039
|
+
value: N.entities ?? [],
|
|
2040
|
+
onChange: $e,
|
|
2041
|
+
entityMetaSchema: i == null ? void 0 : i.entityMetaSchema,
|
|
2042
|
+
fieldSchema: i == null ? void 0 : i.fieldSchema,
|
|
2043
|
+
fieldsKey: i == null ? void 0 : i.fieldsKey,
|
|
2044
|
+
nameKey: i == null ? void 0 : i.nameKey,
|
|
2045
|
+
renderErPreview: i == null ? void 0 : i.renderErPreview
|
|
2046
|
+
}
|
|
2047
|
+
) })
|
|
2048
|
+
}), d.push({
|
|
2049
|
+
key: "i18n",
|
|
2050
|
+
label: v("moduleEditor.tab.i18n", "i18n"),
|
|
2051
|
+
content: /* @__PURE__ */ e("div", { className: "nice-module-editor__pane", children: /* @__PURE__ */ e(At, { value: N.i18n ?? {}, onChange: Ke, locales: n }) })
|
|
2052
|
+
}), d.push({
|
|
2053
|
+
key: "views",
|
|
2054
|
+
label: v("moduleEditor.tab.views", "Views"),
|
|
2055
|
+
content: /* @__PURE__ */ e("div", { className: "nice-module-editor__pane", children: /* @__PURE__ */ e(
|
|
2056
|
+
Kt,
|
|
2057
|
+
{
|
|
2058
|
+
views: N.views ?? [],
|
|
2059
|
+
entities: N.entities ?? [],
|
|
2060
|
+
onChange: Oe
|
|
2061
|
+
}
|
|
2062
|
+
) })
|
|
2063
|
+
}), d.push({
|
|
2064
|
+
key: "workflows",
|
|
2065
|
+
label: v("moduleEditor.tab.workflows", "Workflows"),
|
|
2066
|
+
content: /* @__PURE__ */ e("div", { className: "nice-module-editor__pane", children: /* @__PURE__ */ e(Ot, { workflows: N.workflows ?? [], onChange: De }) })
|
|
2067
|
+
}), d.push({
|
|
2068
|
+
key: "data",
|
|
2069
|
+
label: v("moduleEditor.tab.data", "Data"),
|
|
2070
|
+
content: /* @__PURE__ */ e("div", { className: "nice-module-editor__pane", children: /* @__PURE__ */ e(
|
|
2071
|
+
Lt,
|
|
2072
|
+
{
|
|
2073
|
+
dataSources: N.dataSources ?? [],
|
|
2074
|
+
schemas: Dt(N.entities ?? []),
|
|
2075
|
+
onChange: Me
|
|
2076
|
+
}
|
|
2077
|
+
) })
|
|
2078
|
+
}), d.push({
|
|
2079
|
+
key: "permissions",
|
|
2080
|
+
label: v("moduleEditor.tab.permissions", "Permissions"),
|
|
2081
|
+
content: /* @__PURE__ */ e("div", { className: "nice-module-editor__pane", children: /* @__PURE__ */ e(
|
|
2082
|
+
Ze,
|
|
2083
|
+
{
|
|
2084
|
+
value: N.rbac ?? Mt(N),
|
|
2085
|
+
onChange: Le
|
|
2086
|
+
}
|
|
2087
|
+
) })
|
|
2088
|
+
}), f && d.push({
|
|
2089
|
+
key: "scripts",
|
|
2090
|
+
label: v("moduleEditor.tab.scripts", "Scripts"),
|
|
2091
|
+
content: /* @__PURE__ */ e("div", { className: "nice-module-editor__pane", children: /* @__PURE__ */ e(we, { ...f }) })
|
|
2092
|
+
}), p && p.length > 0 && d.push({
|
|
2093
|
+
key: "lifecycle",
|
|
2094
|
+
label: v("moduleEditor.tab.lifecycle", "Lifecycle"),
|
|
2095
|
+
content: /* @__PURE__ */ e("div", { className: "nice-module-editor__pane", children: /* @__PURE__ */ e(
|
|
2096
|
+
ke,
|
|
2097
|
+
{
|
|
2098
|
+
triggers: p,
|
|
2099
|
+
bindings: y,
|
|
2100
|
+
handlers: s,
|
|
2101
|
+
onChange: (b) => h == null ? void 0 : h(b),
|
|
2102
|
+
groupByTrigger: !0,
|
|
2103
|
+
allowCondition: !0
|
|
2104
|
+
}
|
|
2105
|
+
) })
|
|
2106
|
+
}), F && F.length > 0 && d.push({
|
|
2107
|
+
key: "history",
|
|
2108
|
+
label: v("moduleEditor.tab.history", "History"),
|
|
2109
|
+
content: /* @__PURE__ */ e("div", { className: "nice-module-editor__pane", children: /* @__PURE__ */ e(
|
|
2110
|
+
Se,
|
|
2111
|
+
{
|
|
2112
|
+
revisions: F,
|
|
2113
|
+
onRollback: O,
|
|
2114
|
+
loadContent: D,
|
|
2115
|
+
language: "json"
|
|
2116
|
+
}
|
|
2117
|
+
) })
|
|
2118
|
+
}), d.push({
|
|
2119
|
+
key: "source",
|
|
2120
|
+
label: v("moduleEditor.tab.source", "Source"),
|
|
2121
|
+
content: /* @__PURE__ */ e("div", { className: "nice-module-editor__pane", children: /* @__PURE__ */ e("pre", { className: "nice-module-editor__source", children: JSON.stringify(N, null, 2) }) })
|
|
2122
|
+
}), d;
|
|
2123
|
+
}, [
|
|
2124
|
+
N,
|
|
2125
|
+
o,
|
|
2126
|
+
i,
|
|
2127
|
+
n,
|
|
2128
|
+
f,
|
|
2129
|
+
p,
|
|
2130
|
+
y,
|
|
2131
|
+
s,
|
|
2132
|
+
F,
|
|
2133
|
+
v
|
|
2134
|
+
]);
|
|
2135
|
+
oe(() => {
|
|
2136
|
+
ne.length > 0 && !ne.some((d) => d.key === G) && re(ne[0].key);
|
|
2137
|
+
}, [ne, G]);
|
|
2138
|
+
const ye = P(() => {
|
|
2139
|
+
const d = U.trim().toLowerCase();
|
|
2140
|
+
return d ? k.filter(
|
|
2141
|
+
(b) => b.id.toLowerCase().includes(d) || (b.name ?? "").toLowerCase().includes(d) || (b.category ?? "").toLowerCase().includes(d)
|
|
2142
|
+
) : k;
|
|
2143
|
+
}, [k, U]), Ve = P(() => {
|
|
2144
|
+
const d = [];
|
|
2145
|
+
return S && d.push({ key: "mod", label: S + (m ? " •" : ""), position: "left" }), d.push({
|
|
2146
|
+
key: "val",
|
|
2147
|
+
label: /* @__PURE__ */ u("span", { className: "nice-module-editor__status", children: [
|
|
2148
|
+
/* @__PURE__ */ e(z, { name: B.length === 0 ? "check" : "warning", size: 12 }),
|
|
2149
|
+
B.length === 0 ? v("moduleEditor.status.valid", "Valid") : `${B.length} ${v("moduleEditor.status.issues", "issues")}`
|
|
2150
|
+
] }),
|
|
2151
|
+
position: "left"
|
|
2152
|
+
}), d;
|
|
2153
|
+
}, [S, m, B.length, v]), qe = /* @__PURE__ */ u("div", { className: "nice-module-editor__browser", "data-tour": "nme-browser", children: [
|
|
2154
|
+
/* @__PURE__ */ e(
|
|
2155
|
+
"input",
|
|
2156
|
+
{
|
|
2157
|
+
className: "nice-module-editor__search",
|
|
2158
|
+
placeholder: v("moduleEditor.searchModules", "Search modules…"),
|
|
2159
|
+
value: U,
|
|
2160
|
+
onChange: (d) => L(d.target.value),
|
|
2161
|
+
"aria-label": v("moduleEditor.searchModules", "Search modules…")
|
|
2162
|
+
}
|
|
2163
|
+
),
|
|
2164
|
+
/* @__PURE__ */ u("div", { className: "nice-module-editor__modules", children: [
|
|
2165
|
+
ye.map((d) => /* @__PURE__ */ u(
|
|
2166
|
+
"button",
|
|
2167
|
+
{
|
|
2168
|
+
type: "button",
|
|
2169
|
+
className: "nice-module-editor__module" + (d.id === S ? " nice-module-editor__module--active" : ""),
|
|
2170
|
+
onClick: () => void T(d.id),
|
|
2171
|
+
title: d.description,
|
|
2172
|
+
children: [
|
|
2173
|
+
/* @__PURE__ */ e("span", { className: "nice-module-editor__module-name", children: d.name ?? d.id }),
|
|
2174
|
+
d.category && /* @__PURE__ */ e("span", { className: "nice-module-editor__module-cat", children: d.category })
|
|
2175
|
+
]
|
|
2176
|
+
},
|
|
2177
|
+
d.id
|
|
2178
|
+
)),
|
|
2179
|
+
ye.length === 0 && /* @__PURE__ */ e("div", { className: "nice-module-editor__browser-empty", children: E ? v("moduleEditor.loading", "Loading…") : v("moduleEditor.noModules", "No modules. Open a source first.") })
|
|
2180
|
+
] })
|
|
2181
|
+
] }), Pe = /* @__PURE__ */ u("div", { className: "nice-module-editor__toolbar", children: [
|
|
2182
|
+
/* @__PURE__ */ e("strong", { className: "nice-module-editor__title", "data-tour": "nme-tabs", children: S ? ((ge = N == null ? void 0 : N.manifest) == null ? void 0 : ge.packageName) ?? S : v("moduleEditor.title", "Module Editor") }),
|
|
2183
|
+
w && /* @__PURE__ */ e(se, { steps: ce(w, $t) }),
|
|
2184
|
+
/* @__PURE__ */ e("span", { className: "nice-module-editor__spacer" }),
|
|
2185
|
+
/* @__PURE__ */ u("button", { type: "button", onClick: () => void ie(), disabled: E, children: [
|
|
2186
|
+
/* @__PURE__ */ e(z, { name: "refresh", size: 14 }),
|
|
2187
|
+
" ",
|
|
2188
|
+
v("moduleEditor.refresh", "Refresh")
|
|
2189
|
+
] }),
|
|
2190
|
+
/* @__PURE__ */ u("button", { type: "button", "data-tour": "nme-validate", onClick: Y, disabled: !N, children: [
|
|
2191
|
+
/* @__PURE__ */ e(z, { name: "check", size: 14 }),
|
|
2192
|
+
" ",
|
|
2193
|
+
v("moduleEditor.validate", "Validate")
|
|
2194
|
+
] }),
|
|
2195
|
+
/* @__PURE__ */ e(
|
|
2196
|
+
"button",
|
|
2197
|
+
{
|
|
2198
|
+
type: "button",
|
|
2199
|
+
"data-tour": "nme-save",
|
|
2200
|
+
className: "nice-module-editor__save",
|
|
2201
|
+
onClick: () => void V(),
|
|
2202
|
+
disabled: !N || !m || E,
|
|
2203
|
+
children: E ? v("moduleEditor.saving", "Saving…") : v("moduleEditor.save", "Save")
|
|
2204
|
+
}
|
|
2205
|
+
)
|
|
2206
|
+
] }), Re = "nice-module-editor" + ($ ? ` ${$}` : "");
|
|
2207
|
+
return /* @__PURE__ */ e(
|
|
2208
|
+
Te,
|
|
2209
|
+
{
|
|
2210
|
+
ref: a,
|
|
2211
|
+
id: M,
|
|
2212
|
+
className: Re,
|
|
2213
|
+
style: { height: C, ...J },
|
|
2214
|
+
"data-testid": I,
|
|
2215
|
+
theme: A,
|
|
2216
|
+
tabs: ne,
|
|
2217
|
+
activeTabKey: G,
|
|
2218
|
+
onTabChange: re,
|
|
2219
|
+
toolbar: Pe,
|
|
2220
|
+
sidePanel: qe,
|
|
2221
|
+
sidePanelWidth: 260,
|
|
2222
|
+
statusItems: Ve,
|
|
2223
|
+
bottomPanel: /* @__PURE__ */ e("div", { "data-tour": "nme-output", style: { height: "100%" }, children: /* @__PURE__ */ e(
|
|
2224
|
+
Fe,
|
|
2225
|
+
{
|
|
2226
|
+
title: v("moduleEditor.output", "Output"),
|
|
2227
|
+
entries: x,
|
|
2228
|
+
onClear: () => R([]),
|
|
2229
|
+
maxHeight: "100%"
|
|
2230
|
+
}
|
|
2231
|
+
) }),
|
|
2232
|
+
children: !N && /* @__PURE__ */ e("div", { className: "nice-module-editor__placeholder", children: v("moduleEditor.placeholder", "Select a module from the left to start editing.") })
|
|
2233
|
+
}
|
|
2234
|
+
);
|
|
2235
|
+
}
|
|
2236
|
+
);
|
|
2237
|
+
function Kt({
|
|
2238
|
+
views: t,
|
|
2239
|
+
entities: r,
|
|
2240
|
+
onChange: a
|
|
2241
|
+
}) {
|
|
2242
|
+
var y;
|
|
2243
|
+
const { t: l } = Z(), [o, i] = K(((y = t[0]) == null ? void 0 : y.id) ?? null), n = t.find((s) => s.id === o) ?? null, c = (s) => {
|
|
2244
|
+
a(t.map((h) => h.id === o ? s : h)), s.id !== o && i(s.id);
|
|
2245
|
+
}, f = () => {
|
|
2246
|
+
const s = {
|
|
2247
|
+
id: `view-${Date.now().toString(36)}`,
|
|
2248
|
+
name: "New View",
|
|
2249
|
+
version: 2,
|
|
2250
|
+
columns: 12,
|
|
2251
|
+
rows: [],
|
|
2252
|
+
dataSources: []
|
|
2253
|
+
};
|
|
2254
|
+
a([...t, s]), i(s.id);
|
|
2255
|
+
}, p = (s) => {
|
|
2256
|
+
a(t.filter((h) => h.id !== s)), o === s && i(null);
|
|
2257
|
+
};
|
|
2258
|
+
return /* @__PURE__ */ u("div", { className: "nice-module-views", children: [
|
|
2259
|
+
/* @__PURE__ */ u("div", { className: "nice-module-views__bar", children: [
|
|
2260
|
+
/* @__PURE__ */ u(
|
|
2261
|
+
"select",
|
|
2262
|
+
{
|
|
2263
|
+
className: "nice-module-views__select",
|
|
2264
|
+
value: o ?? "",
|
|
2265
|
+
onChange: (s) => i(s.target.value || null),
|
|
2266
|
+
"aria-label": l("moduleEditor.views.select", "Select view"),
|
|
2267
|
+
children: [
|
|
2268
|
+
/* @__PURE__ */ e("option", { value: "", children: l("moduleEditor.views.placeholder", "— select view —") }),
|
|
2269
|
+
t.map((s) => /* @__PURE__ */ e("option", { value: s.id, children: s.name }, s.id))
|
|
2270
|
+
]
|
|
2271
|
+
}
|
|
2272
|
+
),
|
|
2273
|
+
/* @__PURE__ */ u("button", { type: "button", onClick: f, children: [
|
|
2274
|
+
"+ ",
|
|
2275
|
+
l("moduleEditor.views.new", "New view")
|
|
2276
|
+
] }),
|
|
2277
|
+
n && /* @__PURE__ */ e("button", { type: "button", onClick: () => p(n.id), children: l("moduleEditor.delete", "Delete") })
|
|
2278
|
+
] }),
|
|
2279
|
+
n ? /* @__PURE__ */ e(et, { value: n, onChange: c, entities: r, height: 520 }) : /* @__PURE__ */ e("div", { className: "nice-module-views__empty", children: l(
|
|
2280
|
+
"moduleEditor.views.empty",
|
|
2281
|
+
"No view selected. Create one, then use “New from entity” inside the editor."
|
|
2282
|
+
) })
|
|
2283
|
+
] });
|
|
2284
|
+
}
|
|
2285
|
+
function Ot({
|
|
2286
|
+
workflows: t,
|
|
2287
|
+
onChange: r
|
|
2288
|
+
}) {
|
|
2289
|
+
var p;
|
|
2290
|
+
const { t: a } = Z(), [l, o] = K(((p = t[0]) == null ? void 0 : p.id) ?? null), i = t.find((y) => y.id === l) ?? null, n = (y) => {
|
|
2291
|
+
r(t.map((s) => s.id === l ? y : s)), y.id !== l && o(y.id);
|
|
2292
|
+
}, c = () => {
|
|
2293
|
+
const y = {
|
|
2294
|
+
id: `workflow-${Date.now().toString(36)}`,
|
|
2295
|
+
name: "New Workflow",
|
|
2296
|
+
entityType: "",
|
|
2297
|
+
version: 1,
|
|
2298
|
+
states: [],
|
|
2299
|
+
transitions: []
|
|
2300
|
+
};
|
|
2301
|
+
r([...t, y]), o(y.id);
|
|
2302
|
+
}, f = (y) => {
|
|
2303
|
+
r(t.filter((s) => s.id !== y)), l === y && o(null);
|
|
2304
|
+
};
|
|
2305
|
+
return /* @__PURE__ */ u("div", { className: "nice-module-views", children: [
|
|
2306
|
+
/* @__PURE__ */ u("div", { className: "nice-module-views__bar", children: [
|
|
2307
|
+
/* @__PURE__ */ u(
|
|
2308
|
+
"select",
|
|
2309
|
+
{
|
|
2310
|
+
className: "nice-module-views__select",
|
|
2311
|
+
value: l ?? "",
|
|
2312
|
+
onChange: (y) => o(y.target.value || null),
|
|
2313
|
+
"aria-label": a("moduleEditor.workflows.select", "Select workflow"),
|
|
2314
|
+
children: [
|
|
2315
|
+
/* @__PURE__ */ e("option", { value: "", children: a("moduleEditor.workflows.placeholder", "— select workflow —") }),
|
|
2316
|
+
t.map((y) => /* @__PURE__ */ e("option", { value: y.id, children: y.name }, y.id))
|
|
2317
|
+
]
|
|
2318
|
+
}
|
|
2319
|
+
),
|
|
2320
|
+
/* @__PURE__ */ u("button", { type: "button", onClick: c, children: [
|
|
2321
|
+
"+ ",
|
|
2322
|
+
a("moduleEditor.workflows.new", "New workflow")
|
|
2323
|
+
] }),
|
|
2324
|
+
i && /* @__PURE__ */ e("button", { type: "button", onClick: () => f(i.id), children: a("moduleEditor.delete", "Delete") })
|
|
2325
|
+
] }),
|
|
2326
|
+
i ? /* @__PURE__ */ e(tt, { workflow: i, onChange: n }) : /* @__PURE__ */ e("div", { className: "nice-module-views__empty", children: a(
|
|
2327
|
+
"moduleEditor.workflows.empty",
|
|
2328
|
+
"No workflow selected. Create one to start designing states and transitions."
|
|
2329
|
+
) })
|
|
2330
|
+
] });
|
|
2331
|
+
}
|
|
2332
|
+
function Dt(t) {
|
|
2333
|
+
return t.map((r) => {
|
|
2334
|
+
const a = r;
|
|
2335
|
+
return {
|
|
2336
|
+
name: String(a.tableName || a.name || "Entity"),
|
|
2337
|
+
columns: (Array.isArray(a.fields) ? a.fields : []).map((l) => ({
|
|
2338
|
+
name: String(l.name ?? ""),
|
|
2339
|
+
dataType: String(l.dataType ?? "string"),
|
|
2340
|
+
isPrimaryKey: !!l.isPrimaryKey,
|
|
2341
|
+
isForeignKey: !!l.isForeignKey
|
|
2342
|
+
}))
|
|
2343
|
+
};
|
|
2344
|
+
});
|
|
2345
|
+
}
|
|
2346
|
+
function Mt(t) {
|
|
2347
|
+
const r = t.manifest ?? {}, a = String(r.displayName || r.packageName || "Module"), l = (t.views ?? []).map((i) => ({
|
|
2348
|
+
id: `view:${i.id}`,
|
|
2349
|
+
label: i.name,
|
|
2350
|
+
type: "view"
|
|
2351
|
+
})), o = (t.entities ?? []).map((i) => {
|
|
2352
|
+
const n = String(i.name ?? "Entity");
|
|
2353
|
+
return { id: `entity:${n}`, label: n, type: "entity" };
|
|
2354
|
+
});
|
|
2355
|
+
return {
|
|
2356
|
+
roles: [
|
|
2357
|
+
{ id: "admin", label: "Admin" },
|
|
2358
|
+
{ id: "user", label: "User" }
|
|
2359
|
+
],
|
|
2360
|
+
actions: [
|
|
2361
|
+
{ id: "view", label: "View" },
|
|
2362
|
+
{ id: "create", label: "Create" },
|
|
2363
|
+
{ id: "edit", label: "Edit" },
|
|
2364
|
+
{ id: "delete", label: "Delete" }
|
|
2365
|
+
],
|
|
2366
|
+
resources: [
|
|
2367
|
+
{
|
|
2368
|
+
id: "module",
|
|
2369
|
+
label: a,
|
|
2370
|
+
type: "module",
|
|
2371
|
+
children: [
|
|
2372
|
+
...l.length ? [{ id: "views", label: "Views", type: "group", children: l }] : [],
|
|
2373
|
+
...o.length ? [{ id: "entities", label: "Entities", type: "group", children: o }] : []
|
|
2374
|
+
]
|
|
2375
|
+
}
|
|
2376
|
+
],
|
|
2377
|
+
grants: {}
|
|
2378
|
+
};
|
|
2379
|
+
}
|
|
2380
|
+
function Lt({
|
|
2381
|
+
dataSources: t,
|
|
2382
|
+
schemas: r,
|
|
2383
|
+
onChange: a
|
|
2384
|
+
}) {
|
|
2385
|
+
var y;
|
|
2386
|
+
const { t: l } = Z(), [o, i] = K(((y = t[0]) == null ? void 0 : y.key) ?? null), n = t.find((s) => s.key === o) ?? null, c = (s) => {
|
|
2387
|
+
a(t.map((h) => h.key === o ? s : h)), s.key !== o && i(s.key);
|
|
2388
|
+
}, f = () => {
|
|
2389
|
+
const s = {
|
|
2390
|
+
key: `ds-${Date.now().toString(36)}`,
|
|
2391
|
+
kind: "query",
|
|
2392
|
+
query: { tables: [], joins: [], conditions: [], sorts: [], groupBy: [], distinct: !1 },
|
|
2393
|
+
sql: ""
|
|
2394
|
+
};
|
|
2395
|
+
a([...t, s]), i(s.key);
|
|
2396
|
+
}, p = (s) => {
|
|
2397
|
+
a(t.filter((h) => h.key !== s)), o === s && i(null);
|
|
2398
|
+
};
|
|
2399
|
+
return /* @__PURE__ */ u("div", { className: "nice-module-views", children: [
|
|
2400
|
+
/* @__PURE__ */ u("div", { className: "nice-module-views__bar", children: [
|
|
2401
|
+
/* @__PURE__ */ u(
|
|
2402
|
+
"select",
|
|
2403
|
+
{
|
|
2404
|
+
className: "nice-module-views__select",
|
|
2405
|
+
value: o ?? "",
|
|
2406
|
+
onChange: (s) => i(s.target.value || null),
|
|
2407
|
+
"aria-label": l("moduleEditor.data.select", "Select data source"),
|
|
2408
|
+
children: [
|
|
2409
|
+
/* @__PURE__ */ e("option", { value: "", children: l("moduleEditor.data.placeholder", "— select data source —") }),
|
|
2410
|
+
t.map((s) => /* @__PURE__ */ e("option", { value: s.key, children: s.label || s.key }, s.key))
|
|
2411
|
+
]
|
|
2412
|
+
}
|
|
2413
|
+
),
|
|
2414
|
+
/* @__PURE__ */ u("button", { type: "button", onClick: f, children: [
|
|
2415
|
+
"+ ",
|
|
2416
|
+
l("moduleEditor.data.new", "New data source")
|
|
2417
|
+
] }),
|
|
2418
|
+
n && /* @__PURE__ */ e("button", { type: "button", onClick: () => p(n.key), children: l("moduleEditor.delete", "Delete") })
|
|
2419
|
+
] }),
|
|
2420
|
+
n ? /* @__PURE__ */ e(it, { value: n, onChange: c, schemas: r }) : /* @__PURE__ */ e("div", { className: "nice-module-views__empty", children: l(
|
|
2421
|
+
"moduleEditor.data.empty",
|
|
2422
|
+
"No data source selected. Create one to build a query from your module’s schema."
|
|
2423
|
+
) })
|
|
2424
|
+
] });
|
|
2425
|
+
}
|
|
2
2426
|
export {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
2427
|
+
pt as NiceArrayField,
|
|
2428
|
+
Ct as NiceEntityEditor,
|
|
2429
|
+
Ut as NiceFormBuilderAI,
|
|
2430
|
+
At as NiceI18nEditor,
|
|
2431
|
+
Wt as NiceManifestEditor,
|
|
2432
|
+
Yt as NiceModuleEditor,
|
|
2433
|
+
de as NiceSchemaForm,
|
|
2434
|
+
Gt as defineManifestSection,
|
|
2435
|
+
Bt as formBuilderSchemaToNiceFormItems,
|
|
2436
|
+
Ce as formFieldsToFormItems,
|
|
2437
|
+
Ht as formSchemaToJsonSchema,
|
|
2438
|
+
xe as jsonSchemaToFormItems,
|
|
2439
|
+
zt as schemaToFormItems,
|
|
2440
|
+
Ie as validateAgainstJsonSchema,
|
|
2441
|
+
Jt as validateFormSchema
|
|
18
2442
|
};
|