@mieweb/forms-editor 1.3.0 → 2.0.1
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/dist/index.js +337 -347
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -47,35 +47,35 @@ function It() {
|
|
|
47
47
|
return a.$$typeof === P ? null : a.displayName || a.name || null;
|
|
48
48
|
if (typeof a == "string") return a;
|
|
49
49
|
switch (a) {
|
|
50
|
-
case
|
|
50
|
+
case k:
|
|
51
51
|
return "Fragment";
|
|
52
|
-
case
|
|
52
|
+
case w:
|
|
53
53
|
return "Profiler";
|
|
54
54
|
case R:
|
|
55
55
|
return "StrictMode";
|
|
56
|
-
case
|
|
56
|
+
case b:
|
|
57
57
|
return "Suspense";
|
|
58
58
|
case f:
|
|
59
59
|
return "SuspenseList";
|
|
60
|
-
case
|
|
60
|
+
case I:
|
|
61
61
|
return "Activity";
|
|
62
62
|
}
|
|
63
63
|
if (typeof a == "object")
|
|
64
64
|
switch (typeof a.tag == "number" && console.error(
|
|
65
65
|
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
66
66
|
), a.$$typeof) {
|
|
67
|
-
case
|
|
67
|
+
case j:
|
|
68
68
|
return "Portal";
|
|
69
|
-
case
|
|
69
|
+
case T:
|
|
70
70
|
return a.displayName || "Context";
|
|
71
|
-
case
|
|
71
|
+
case A:
|
|
72
72
|
return (a._context.displayName || "Context") + ".Consumer";
|
|
73
|
-
case
|
|
73
|
+
case x:
|
|
74
74
|
var v = a.render;
|
|
75
75
|
return a = a.displayName, a || (a = v.displayName || v.name || "", a = a !== "" ? "ForwardRef(" + a + ")" : "ForwardRef"), a;
|
|
76
|
-
case
|
|
76
|
+
case O:
|
|
77
77
|
return v = a.displayName || null, v !== null ? v : e(a.type) || "Memo";
|
|
78
|
-
case
|
|
78
|
+
case E:
|
|
79
79
|
v = a._payload, a = a._init;
|
|
80
80
|
try {
|
|
81
81
|
return e(a(v));
|
|
@@ -105,8 +105,8 @@ function It() {
|
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
function n(a) {
|
|
108
|
-
if (a ===
|
|
109
|
-
if (typeof a == "object" && a !== null && a.$$typeof ===
|
|
108
|
+
if (a === k) return "<>";
|
|
109
|
+
if (typeof a == "object" && a !== null && a.$$typeof === E)
|
|
110
110
|
return "<...>";
|
|
111
111
|
try {
|
|
112
112
|
var v = e(a);
|
|
@@ -148,14 +148,14 @@ function It() {
|
|
|
148
148
|
)), a = this.props.ref, a !== void 0 ? a : null;
|
|
149
149
|
}
|
|
150
150
|
function u(a, v, y, D, oe, be) {
|
|
151
|
-
var
|
|
151
|
+
var L = y.ref;
|
|
152
152
|
return a = {
|
|
153
153
|
$$typeof: _,
|
|
154
154
|
type: a,
|
|
155
155
|
key: v,
|
|
156
156
|
props: y,
|
|
157
157
|
_owner: D
|
|
158
|
-
}, (
|
|
158
|
+
}, (L !== void 0 ? L : null) !== null ? Object.defineProperty(a, "ref", {
|
|
159
159
|
enumerable: !1,
|
|
160
160
|
get: c
|
|
161
161
|
}) : Object.defineProperty(a, "ref", { enumerable: !1, value: null }), a._store = {}, Object.defineProperty(a._store, "validated", {
|
|
@@ -181,24 +181,24 @@ function It() {
|
|
|
181
181
|
}), Object.freeze && (Object.freeze(a.props), Object.freeze(a)), a;
|
|
182
182
|
}
|
|
183
183
|
function h(a, v, y, D, oe, be) {
|
|
184
|
-
var
|
|
185
|
-
if (
|
|
184
|
+
var L = v.children;
|
|
185
|
+
if (L !== void 0)
|
|
186
186
|
if (D)
|
|
187
|
-
if (M(
|
|
188
|
-
for (D = 0; D <
|
|
189
|
-
g(
|
|
190
|
-
Object.freeze && Object.freeze(
|
|
187
|
+
if (M(L)) {
|
|
188
|
+
for (D = 0; D < L.length; D++)
|
|
189
|
+
g(L[D]);
|
|
190
|
+
Object.freeze && Object.freeze(L);
|
|
191
191
|
} else
|
|
192
192
|
console.error(
|
|
193
193
|
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
194
194
|
);
|
|
195
|
-
else g(
|
|
195
|
+
else g(L);
|
|
196
196
|
if (C.call(v, "key")) {
|
|
197
|
-
|
|
197
|
+
L = e(a);
|
|
198
198
|
var X = Object.keys(v).filter(function(et) {
|
|
199
199
|
return et !== "key";
|
|
200
200
|
});
|
|
201
|
-
D = 0 < X.length ? "{key: someKey, " + X.join(": ..., ") + ": ...}" : "{key: someKey}", Y[
|
|
201
|
+
D = 0 < X.length ? "{key: someKey, " + X.join(": ..., ") + ": ...}" : "{key: someKey}", Y[L + D] || (X = 0 < X.length ? "{" + X.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
202
202
|
`A props object containing a "key" prop is being spread into JSX:
|
|
203
203
|
let props = %s;
|
|
204
204
|
<%s {...props} />
|
|
@@ -206,22 +206,22 @@ React keys must be passed directly to JSX without using spread:
|
|
|
206
206
|
let props = %s;
|
|
207
207
|
<%s key={someKey} {...props} />`,
|
|
208
208
|
D,
|
|
209
|
-
|
|
209
|
+
L,
|
|
210
210
|
X,
|
|
211
|
-
|
|
212
|
-
), Y[
|
|
211
|
+
L
|
|
212
|
+
), Y[L + D] = !0);
|
|
213
213
|
}
|
|
214
|
-
if (
|
|
214
|
+
if (L = null, y !== void 0 && (r(y), L = "" + y), d(v) && (r(v.key), L = "" + v.key), "key" in v) {
|
|
215
215
|
y = {};
|
|
216
216
|
for (var ge in v)
|
|
217
217
|
ge !== "key" && (y[ge] = v[ge]);
|
|
218
218
|
} else y = v;
|
|
219
|
-
return
|
|
219
|
+
return L && m(
|
|
220
220
|
y,
|
|
221
221
|
typeof a == "function" ? a.displayName || a.name || "Unknown" : a
|
|
222
222
|
), u(
|
|
223
223
|
a,
|
|
224
|
-
|
|
224
|
+
L,
|
|
225
225
|
y,
|
|
226
226
|
s(),
|
|
227
227
|
oe,
|
|
@@ -229,24 +229,24 @@ React keys must be passed directly to JSX without using spread:
|
|
|
229
229
|
);
|
|
230
230
|
}
|
|
231
231
|
function g(a) {
|
|
232
|
-
|
|
232
|
+
S(a) ? a._store && (a._store.validated = 1) : typeof a == "object" && a !== null && a.$$typeof === E && (a._payload.status === "fulfilled" ? S(a._payload.value) && a._payload.value._store && (a._payload.value._store.validated = 1) : a._store && (a._store.validated = 1));
|
|
233
233
|
}
|
|
234
|
-
function
|
|
234
|
+
function S(a) {
|
|
235
235
|
return typeof a == "object" && a !== null && a.$$typeof === _;
|
|
236
236
|
}
|
|
237
|
-
var
|
|
237
|
+
var q = l, _ = /* @__PURE__ */ Symbol.for("react.transitional.element"), j = /* @__PURE__ */ Symbol.for("react.portal"), k = /* @__PURE__ */ Symbol.for("react.fragment"), R = /* @__PURE__ */ Symbol.for("react.strict_mode"), w = /* @__PURE__ */ Symbol.for("react.profiler"), A = /* @__PURE__ */ Symbol.for("react.consumer"), T = /* @__PURE__ */ Symbol.for("react.context"), x = /* @__PURE__ */ Symbol.for("react.forward_ref"), b = /* @__PURE__ */ Symbol.for("react.suspense"), f = /* @__PURE__ */ Symbol.for("react.suspense_list"), O = /* @__PURE__ */ Symbol.for("react.memo"), E = /* @__PURE__ */ Symbol.for("react.lazy"), I = /* @__PURE__ */ Symbol.for("react.activity"), P = /* @__PURE__ */ Symbol.for("react.client.reference"), p = q.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, C = Object.prototype.hasOwnProperty, M = Array.isArray, N = console.createTask ? console.createTask : function() {
|
|
238
238
|
return null;
|
|
239
239
|
};
|
|
240
|
-
|
|
240
|
+
q = {
|
|
241
241
|
react_stack_bottom_frame: function(a) {
|
|
242
242
|
return a();
|
|
243
243
|
}
|
|
244
244
|
};
|
|
245
|
-
var F, $ = {}, z =
|
|
246
|
-
|
|
245
|
+
var F, $ = {}, z = q.react_stack_bottom_frame.bind(
|
|
246
|
+
q,
|
|
247
247
|
o
|
|
248
|
-
)(), H =
|
|
249
|
-
ee.Fragment =
|
|
248
|
+
)(), H = N(n(o)), Y = {};
|
|
249
|
+
ee.Fragment = k, ee.jsx = function(a, v, y) {
|
|
250
250
|
var D = 1e4 > p.recentlyCreatedOwnerStacks++;
|
|
251
251
|
return h(
|
|
252
252
|
a,
|
|
@@ -254,7 +254,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
254
254
|
y,
|
|
255
255
|
!1,
|
|
256
256
|
D ? Error("react-stack-top-frame") : z,
|
|
257
|
-
D ?
|
|
257
|
+
D ? N(n(a)) : H
|
|
258
258
|
);
|
|
259
259
|
}, ee.jsxs = function(a, v, y) {
|
|
260
260
|
var D = 1e4 > p.recentlyCreatedOwnerStacks++;
|
|
@@ -264,7 +264,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
264
264
|
y,
|
|
265
265
|
!0,
|
|
266
266
|
D ? Error("react-stack-top-frame") : z,
|
|
267
|
-
D ?
|
|
267
|
+
D ? N(n(a)) : H
|
|
268
268
|
);
|
|
269
269
|
};
|
|
270
270
|
})()), ee;
|
|
@@ -275,73 +275,73 @@ function St() {
|
|
|
275
275
|
}
|
|
276
276
|
var t = St();
|
|
277
277
|
function kt() {
|
|
278
|
-
const [e, i] = l.useState(!1), [r, n] = l.useState(null), s = V((
|
|
278
|
+
const [e, i] = l.useState(!1), [r, n] = l.useState(null), s = V((w) => w.replaceAll), o = $e(), { showAlert: d } = Ue(), m = B(), c = m.state.isPreview, u = m.state.isCodeEditor ?? !1, h = m.state.codeEditorHasError ?? !1, g = (w) => {
|
|
279
279
|
try {
|
|
280
|
-
const
|
|
281
|
-
if (
|
|
280
|
+
const A = String(w).replace(/^\uFEFF/, "").trim(), { data: T, schemaType: x } = fe(A);
|
|
281
|
+
if (x !== "mieforms" && x !== "surveyjs") {
|
|
282
282
|
d(
|
|
283
283
|
`Expected: MIE Forms or SurveyJS
|
|
284
|
-
Detected: ${
|
|
284
|
+
Detected: ${x}`,
|
|
285
285
|
{ title: "Unsupported Schema Format" }
|
|
286
286
|
);
|
|
287
287
|
return;
|
|
288
288
|
}
|
|
289
|
-
n({ data:
|
|
290
|
-
} catch (
|
|
289
|
+
n({ data: T, detectedSchemaType: x }), i(!0);
|
|
290
|
+
} catch (A) {
|
|
291
291
|
d(
|
|
292
|
-
|
|
292
|
+
A?.message || "Invalid file format",
|
|
293
293
|
{ title: "Failed to Parse File" }
|
|
294
294
|
);
|
|
295
295
|
}
|
|
296
|
-
},
|
|
296
|
+
}, S = (w) => {
|
|
297
297
|
if (r)
|
|
298
298
|
try {
|
|
299
|
-
const { data:
|
|
300
|
-
if (!Array.isArray(
|
|
299
|
+
const { data: A } = r, T = pe(A, w), x = T.fields || [];
|
|
300
|
+
if (!Array.isArray(x))
|
|
301
301
|
throw new Error("Expected array of fields");
|
|
302
|
-
|
|
303
|
-
const
|
|
304
|
-
schemaType:
|
|
305
|
-
...
|
|
306
|
-
fields:
|
|
302
|
+
T.conversionReport && m.setConversionReport(T.conversionReport);
|
|
303
|
+
const b = {
|
|
304
|
+
schemaType: w === "surveyjs" ? "mieforms-v1.0" : A.schemaType || "mieforms-v1.0",
|
|
305
|
+
...T.conversionReport?.surveyMetadata || {},
|
|
306
|
+
fields: x
|
|
307
307
|
};
|
|
308
|
-
if (
|
|
309
|
-
const { fields: f, schemaType:
|
|
310
|
-
Object.keys(
|
|
308
|
+
if (w === "mieforms") {
|
|
309
|
+
const { fields: f, schemaType: O, ...E } = A;
|
|
310
|
+
Object.keys(E).length > 0 && Object.assign(b, E);
|
|
311
311
|
}
|
|
312
|
-
if (s(
|
|
313
|
-
const f =
|
|
312
|
+
if (s(b), m.selectedFieldId.clear(), m.preview.set(!1), w === "surveyjs" && T.conversionReport) {
|
|
313
|
+
const f = T.conversionReport, O = f.unsupportedFields?.length || 0;
|
|
314
314
|
d(
|
|
315
315
|
`Format: SurveyJS → MIE Forms
|
|
316
316
|
|
|
317
317
|
Converted: ${f.convertedFields || 0} field(s)
|
|
318
|
-
Unsupported: ${
|
|
318
|
+
Unsupported: ${O} field(s)${O > 0 ? " ⚠️" : ""}`,
|
|
319
319
|
{ title: "✅ Import Successful" }
|
|
320
320
|
);
|
|
321
321
|
} else
|
|
322
322
|
d(
|
|
323
|
-
`Format: ${
|
|
324
|
-
Loaded ${
|
|
323
|
+
`Format: ${w === "surveyjs" ? "SurveyJS" : "MIE Forms"}
|
|
324
|
+
Loaded ${x.length} field(s)`,
|
|
325
325
|
{ title: "✅ Import Successful" }
|
|
326
326
|
);
|
|
327
327
|
i(!1), n(null);
|
|
328
|
-
} catch (
|
|
328
|
+
} catch (A) {
|
|
329
329
|
d(
|
|
330
|
-
|
|
330
|
+
A?.message || "Invalid format",
|
|
331
331
|
{ title: "Import Failed" }
|
|
332
332
|
), i(!1), n(null);
|
|
333
333
|
}
|
|
334
|
-
},
|
|
334
|
+
}, q = () => {
|
|
335
335
|
i(!1), n(null);
|
|
336
336
|
}, _ = () => {
|
|
337
337
|
m.preview.set(!1), m.codeEditor.set(!1);
|
|
338
|
-
},
|
|
338
|
+
}, j = () => {
|
|
339
339
|
m.preview.set(!1), m.codeEditor.set(!0);
|
|
340
|
-
},
|
|
340
|
+
}, k = () => {
|
|
341
341
|
m.preview.set(!0), m.codeEditor.set(!1), m.selectedFieldId.clear();
|
|
342
342
|
}, R = () => {
|
|
343
|
-
const
|
|
344
|
-
|
|
343
|
+
const w = JSON.stringify(o, null, 2), A = new Blob([w], { type: "application/json" }), T = URL.createObjectURL(A), x = document.createElement("a");
|
|
344
|
+
x.href = T, x.download = "questionnaire.json", x.click(), URL.revokeObjectURL(T);
|
|
345
345
|
};
|
|
346
346
|
return /* @__PURE__ */ t.jsxs("header", { className: "editor-header mie:w-full mie:bg-miesurface mie:border mie:border-mieborder mie:rounded-lg mie:shadow-sm", children: [
|
|
347
347
|
/* @__PURE__ */ t.jsx("div", { className: "mie:px-4 mie:py-4", children: /* @__PURE__ */ t.jsxs("div", { className: "mie:flex mie:flex-wrap mie:items-center mie:justify-between mie:gap-3", children: [
|
|
@@ -363,7 +363,7 @@ Loaded ${b.length} field(s)`,
|
|
|
363
363
|
"button",
|
|
364
364
|
{
|
|
365
365
|
className: `mie:flex mie:items-center mie:justify-center mie:gap-2 mie:px-2 mie:lg:px-4 mie:py-2 mie:lg:py-2 mie:rounded-lg mie:text-xs mie:lg:text-sm mie:font-medium mie:transition-colors mie:border-0 mie:outline-none mie:focus:outline-none ${u ? "mie:bg-mieprimary mie:text-mietextsecondary mie:shadow-sm" : "mie:bg-transparent mie:text-mietextmuted mie:hover:text-mietext mie:hover:bg-miesurface"}`,
|
|
366
|
-
onClick:
|
|
366
|
+
onClick: j,
|
|
367
367
|
title: "Code Editor",
|
|
368
368
|
children: [
|
|
369
369
|
/* @__PURE__ */ t.jsx(it, { className: "mie:w-5 mie:h-5" }),
|
|
@@ -375,7 +375,7 @@ Loaded ${b.length} field(s)`,
|
|
|
375
375
|
"button",
|
|
376
376
|
{
|
|
377
377
|
className: `mie:flex mie:items-center mie:justify-center mie:gap-2 mie:px-2 mie:lg:px-4 mie:py-2 mie:lg:py-2 mie:rounded-lg mie:text-xs mie:lg:text-sm mie:font-medium mie:transition-colors mie:border-0 mie:outline-none mie:focus:outline-none ${c ? "mie:bg-mieprimary mie:text-mietextsecondary mie:shadow-sm" : h ? "mie:bg-transparent mie:text-mietextmuted/50 mie:cursor-not-allowed" : "mie:bg-transparent mie:text-mietextmuted mie:hover:text-mietext mie:hover:bg-miesurface"}`,
|
|
378
|
-
onClick:
|
|
378
|
+
onClick: k,
|
|
379
379
|
disabled: h,
|
|
380
380
|
title: h ? "Fix code errors before switching" : "Preview Form",
|
|
381
381
|
children: [
|
|
@@ -395,11 +395,11 @@ Loaded ${b.length} field(s)`,
|
|
|
395
395
|
className: "mie:hidden",
|
|
396
396
|
type: "file",
|
|
397
397
|
accept: ".json,.yaml,.yml,application/json,text/yaml",
|
|
398
|
-
onChange: (
|
|
399
|
-
const
|
|
400
|
-
if (!
|
|
401
|
-
const
|
|
402
|
-
|
|
398
|
+
onChange: (w) => {
|
|
399
|
+
const A = w.target.files?.[0];
|
|
400
|
+
if (!A) return;
|
|
401
|
+
const T = new FileReader();
|
|
402
|
+
T.onload = (x) => g(x.target?.result ?? ""), T.readAsText(A), w.target.value = "";
|
|
403
403
|
}
|
|
404
404
|
}
|
|
405
405
|
)
|
|
@@ -432,7 +432,7 @@ Loaded ${b.length} field(s)`,
|
|
|
432
432
|
/* @__PURE__ */ t.jsx(
|
|
433
433
|
"button",
|
|
434
434
|
{
|
|
435
|
-
onClick: () =>
|
|
435
|
+
onClick: () => S(r.detectedSchemaType),
|
|
436
436
|
className: "mie:flex-1 mie:px-6 mie:py-3 mie:rounded-xl mie:bg-mieprimary mie:text-miesurface mie:font-semibold mie:hover:bg-mieprimary/90 mie:transition-colors mie:shadow-sm mie:hover:shadow",
|
|
437
437
|
children: "Yes, Import"
|
|
438
438
|
}
|
|
@@ -440,7 +440,7 @@ Loaded ${b.length} field(s)`,
|
|
|
440
440
|
/* @__PURE__ */ t.jsx(
|
|
441
441
|
"button",
|
|
442
442
|
{
|
|
443
|
-
onClick:
|
|
443
|
+
onClick: q,
|
|
444
444
|
className: "mie:flex-1 mie:px-6 mie:py-3 mie:rounded-xl mie:border-2 mie:border-mieborder mie:bg-miesurface mie:hover:bg-miebackground mie:text-mietext mie:font-semibold mie:transition-colors",
|
|
445
445
|
children: "Abort"
|
|
446
446
|
}
|
|
@@ -485,8 +485,8 @@ const Rt = (e) => {
|
|
|
485
485
|
const m = Ee(() => {
|
|
486
486
|
const u = {};
|
|
487
487
|
return Object.entries(K).filter(([h]) => h !== "unsupported").forEach(([h, g]) => {
|
|
488
|
-
const
|
|
489
|
-
u[
|
|
488
|
+
const S = g.category || "Other";
|
|
489
|
+
u[S] || (u[S] = []), u[S].push({
|
|
490
490
|
type: h,
|
|
491
491
|
label: g.label
|
|
492
492
|
});
|
|
@@ -530,18 +530,18 @@ const Rt = (e) => {
|
|
|
530
530
|
})(),
|
|
531
531
|
u
|
|
532
532
|
] }),
|
|
533
|
-
/* @__PURE__ */ t.jsx("div", { className: "tool-items mie:grid mie:grid-cols-1 mie:gap-2 mie:px-4 mie:py-3", children: h.map(({ type: g, label:
|
|
534
|
-
const
|
|
533
|
+
/* @__PURE__ */ t.jsx("div", { className: "tool-items mie:grid mie:grid-cols-1 mie:gap-2 mie:px-4 mie:py-3", children: h.map(({ type: g, label: S }) => {
|
|
534
|
+
const q = s && g === "section";
|
|
535
535
|
return /* @__PURE__ */ t.jsxs(
|
|
536
536
|
"button",
|
|
537
537
|
{
|
|
538
|
-
disabled:
|
|
539
|
-
className: `mie:px-3 mie:py-2 mie:text-sm mie:text-left mie:border mie:rounded-md mie:transition-colors mie:duration-150 ${
|
|
538
|
+
disabled: q,
|
|
539
|
+
className: `mie:px-3 mie:py-2 mie:text-sm mie:text-left mie:border mie:rounded-md mie:transition-colors mie:duration-150 ${q ? "mie:border-mieborder mie:bg-miebackground mie:text-mietextmuted/50 mie:cursor-not-allowed" : "mie:bg-miesurface mie:text-mietext mie:border-mieborder mie:hover:bg-mieprimary/10 mie:hover:border-mieprimary/50 mie:hover:text-mieprimary"}`,
|
|
540
540
|
onClick: c[g],
|
|
541
|
-
title:
|
|
541
|
+
title: q ? "Cannot add section to a section" : `Add ${S}`,
|
|
542
542
|
children: [
|
|
543
543
|
"+ ",
|
|
544
|
-
|
|
544
|
+
S
|
|
545
545
|
]
|
|
546
546
|
},
|
|
547
547
|
g
|
|
@@ -572,9 +572,9 @@ function ze({
|
|
|
572
572
|
}
|
|
573
573
|
if (g !== (e ?? "")) {
|
|
574
574
|
if (typeof n == "function") {
|
|
575
|
-
const
|
|
576
|
-
if (
|
|
577
|
-
u(
|
|
575
|
+
const S = n(g, e ?? "");
|
|
576
|
+
if (S) {
|
|
577
|
+
u(S);
|
|
578
578
|
return;
|
|
579
579
|
}
|
|
580
580
|
}
|
|
@@ -885,7 +885,7 @@ function _t({ f: e }) {
|
|
|
885
885
|
function Dt({ section: e, onActiveChildChange: i }) {
|
|
886
886
|
const r = Ne(e.id), n = l.useContext(Oe), s = B();
|
|
887
887
|
if (!n) throw new Error("Missing FormStoreContext.Provider in the tree");
|
|
888
|
-
const o = Array.isArray(e.fields) ? e.fields : [], d = s.selectedChildId.ParentId, m = s.selectedChildId.ChildId, c = l.useMemo(() => d === e.id && m && o.some((
|
|
888
|
+
const o = Array.isArray(e.fields) ? e.fields : [], d = s.selectedChildId.ParentId, m = s.selectedChildId.ChildId, c = l.useMemo(() => d === e.id && m && o.some((b) => b.id === m) ? m : o[0]?.id || null, []), [u, h] = l.useState(c), g = l.useRef(m);
|
|
889
889
|
l.useEffect(() => {
|
|
890
890
|
g.current !== m && (g.current = m, d === e.id && m && m !== u && h(m));
|
|
891
891
|
}, [d, m, e.id, u]), l.useEffect(() => {
|
|
@@ -897,51 +897,51 @@ function Dt({ section: e, onActiveChildChange: i }) {
|
|
|
897
897
|
}, [o, u]), l.useEffect(() => {
|
|
898
898
|
i?.(e.id, u || null);
|
|
899
899
|
}, [e.id, u, i]);
|
|
900
|
-
const
|
|
901
|
-
(
|
|
902
|
-
h(
|
|
900
|
+
const S = l.useCallback(
|
|
901
|
+
(b) => {
|
|
902
|
+
h(b), s.selectedChildId.set(e.id, b);
|
|
903
903
|
},
|
|
904
904
|
[e.id, s.selectedChildId]
|
|
905
|
-
),
|
|
906
|
-
(
|
|
905
|
+
), q = l.useCallback((b) => b.question?.trim() || K[b.fieldType]?.label || "Untitled", []), _ = l.useCallback(
|
|
906
|
+
(b, f) => r.field.update(b, f),
|
|
907
907
|
[r]
|
|
908
|
-
),
|
|
909
|
-
() => o.find((
|
|
908
|
+
), j = l.useMemo(
|
|
909
|
+
() => o.find((b) => b.id === u) || null,
|
|
910
910
|
[o, u]
|
|
911
|
-
),
|
|
912
|
-
(
|
|
913
|
-
if (
|
|
914
|
-
if (
|
|
915
|
-
const
|
|
916
|
-
if (!
|
|
911
|
+
), k = Ne(j?.id || "", e.id), R = j && k ? k : null, w = l.useCallback(
|
|
912
|
+
(b, f) => {
|
|
913
|
+
if (j) {
|
|
914
|
+
if (b === "id") {
|
|
915
|
+
const O = String(f ?? "").trim();
|
|
916
|
+
if (!O) return;
|
|
917
917
|
n.getState().updateField(
|
|
918
|
-
|
|
919
|
-
{ id:
|
|
918
|
+
j.id,
|
|
919
|
+
{ id: O },
|
|
920
920
|
{
|
|
921
921
|
sectionId: e.id,
|
|
922
|
-
onIdChange: (
|
|
923
|
-
h((P) => P ===
|
|
922
|
+
onIdChange: (E, I) => {
|
|
923
|
+
h((P) => P === I ? E : P);
|
|
924
924
|
}
|
|
925
925
|
}
|
|
926
926
|
);
|
|
927
927
|
return;
|
|
928
928
|
}
|
|
929
929
|
n.getState().updateField(
|
|
930
|
-
|
|
931
|
-
{ [
|
|
930
|
+
j.id,
|
|
931
|
+
{ [b]: f },
|
|
932
932
|
{ sectionId: e.id }
|
|
933
933
|
);
|
|
934
934
|
}
|
|
935
935
|
},
|
|
936
|
-
[
|
|
937
|
-
),
|
|
938
|
-
|
|
939
|
-
}, [
|
|
940
|
-
() =>
|
|
941
|
-
[
|
|
942
|
-
),
|
|
943
|
-
() =>
|
|
944
|
-
[
|
|
936
|
+
[j, e.id, n]
|
|
937
|
+
), A = l.useCallback(() => {
|
|
938
|
+
j && n.getState().deleteField(j.id, { sectionId: e.id });
|
|
939
|
+
}, [j, e.id, n]), T = l.useMemo(
|
|
940
|
+
() => j && (K[j.fieldType] || {}).hasOptions || !1,
|
|
941
|
+
[j]
|
|
942
|
+
), x = l.useMemo(
|
|
943
|
+
() => j && (K[j.fieldType] || {}).hasMatrix || !1,
|
|
944
|
+
[j]
|
|
945
945
|
);
|
|
946
946
|
return /* @__PURE__ */ t.jsxs("div", { className: "mie:space-y-4", children: [
|
|
947
947
|
/* @__PURE__ */ t.jsxs("div", { className: "mie:space-y-3", children: [
|
|
@@ -950,7 +950,7 @@ function Dt({ section: e, onActiveChildChange: i }) {
|
|
|
950
950
|
ze,
|
|
951
951
|
{
|
|
952
952
|
id: e.id,
|
|
953
|
-
onCommit: (
|
|
953
|
+
onCommit: (b) => r.field.renameId(b)
|
|
954
954
|
}
|
|
955
955
|
),
|
|
956
956
|
/* @__PURE__ */ t.jsxs("div", { className: "section-editor-title", children: [
|
|
@@ -960,7 +960,7 @@ function Dt({ section: e, onActiveChildChange: i }) {
|
|
|
960
960
|
{
|
|
961
961
|
className: "mie:w-full mie:px-3 mie:py-2 mie:border mie:border-mieborder mie:bg-miesurface mie:text-mietext mie:rounded mie:focus:border-mieprimary mie:focus:ring-1 mie:focus:ring-mieprimary/30 mie:outline-none",
|
|
962
962
|
value: e.title || "",
|
|
963
|
-
onChange: (
|
|
963
|
+
onChange: (b) => _("title", b.target.value),
|
|
964
964
|
placeholder: "e.g., Patient Information"
|
|
965
965
|
}
|
|
966
966
|
)
|
|
@@ -982,24 +982,24 @@ function Dt({ section: e, onActiveChildChange: i }) {
|
|
|
982
982
|
{
|
|
983
983
|
className: "mie:w-full mie:px-3 mie:py-2 mie:pr-10 mie:border mie:border-mieborder mie:rounded mie:bg-miesurface mie:text-mietext mie:focus:border-mieprimary mie:focus:ring-1 mie:focus:ring-mieprimary/30 mie:outline-none mie:appearance-none mie:cursor-pointer",
|
|
984
984
|
value: u || "",
|
|
985
|
-
onChange: (
|
|
986
|
-
children: o.map((
|
|
987
|
-
|
|
985
|
+
onChange: (b) => S(b.target.value),
|
|
986
|
+
children: o.map((b) => /* @__PURE__ */ t.jsxs("option", { value: b.id, children: [
|
|
987
|
+
q(b),
|
|
988
988
|
" — ",
|
|
989
|
-
K[
|
|
990
|
-
] },
|
|
989
|
+
K[b.fieldType]?.label
|
|
990
|
+
] }, b.id))
|
|
991
991
|
}
|
|
992
992
|
),
|
|
993
993
|
/* @__PURE__ */ t.jsx(ht, { className: "mie:absolute mie:right-3 mie:top-1/2 mie:-translate-y-1/2 mie:w-4 mie:h-4 mie:text-mietextmuted mie:pointer-events-none" })
|
|
994
994
|
] }),
|
|
995
|
-
|
|
995
|
+
j && /* @__PURE__ */ t.jsxs("div", { className: "mie:space-y-4 mie:p-4 mie:bg-miebackground mie:border mie:border-mieborder mie:rounded-lg", children: [
|
|
996
996
|
/* @__PURE__ */ t.jsxs("div", { className: "mie:flex mie:items-center mie:justify-between", children: [
|
|
997
|
-
/* @__PURE__ */ t.jsx("span", { className: "mie:inline-flex mie:items-center mie:px-2.5 mie:py-0.5 mie:rounded-full mie:text-xs mie:font-medium mie:bg-mieprimary/10 mie:text-mieprimary", children: K[
|
|
997
|
+
/* @__PURE__ */ t.jsx("span", { className: "mie:inline-flex mie:items-center mie:px-2.5 mie:py-0.5 mie:rounded-full mie:text-xs mie:font-medium mie:bg-mieprimary/10 mie:text-mieprimary", children: K[j.fieldType]?.label || j.fieldType }),
|
|
998
998
|
/* @__PURE__ */ t.jsxs(
|
|
999
999
|
"button",
|
|
1000
1000
|
{
|
|
1001
1001
|
className: "mie:flex mie:items-center mie:gap-1.5 mie:px-3 mie:py-1.5 mie:text-xs mie:font-medium mie:bg-miesurface mie:text-miedanger mie:hover:text-miedanger mie:hover:bg-miedanger/10 mie:border mie:border-miedanger/50 mie:rounded mie:transition-colors",
|
|
1002
|
-
onClick:
|
|
1002
|
+
onClick: A,
|
|
1003
1003
|
title: "Delete this field",
|
|
1004
1004
|
children: [
|
|
1005
1005
|
/* @__PURE__ */ t.jsx(re, { className: "mie:w-3.5 mie:h-3.5" }),
|
|
@@ -1008,21 +1008,21 @@ function Dt({ section: e, onActiveChildChange: i }) {
|
|
|
1008
1008
|
}
|
|
1009
1009
|
)
|
|
1010
1010
|
] }),
|
|
1011
|
-
/* @__PURE__ */ t.jsx(We, { f:
|
|
1012
|
-
|
|
1011
|
+
/* @__PURE__ */ t.jsx(We, { f: j, onUpdateField: w }),
|
|
1012
|
+
j.fieldType === "input" && /* @__PURE__ */ t.jsxs("div", { className: "section-editor-default-answer", children: [
|
|
1013
1013
|
/* @__PURE__ */ t.jsx("label", { className: "mie:block mie:text-sm mie:font-medium mie:text-mietext mie:mb-1", children: "Default Answer" }),
|
|
1014
1014
|
/* @__PURE__ */ t.jsx(
|
|
1015
1015
|
"input",
|
|
1016
1016
|
{
|
|
1017
1017
|
className: "mie:w-full mie:px-3 mie:py-2 mie:border mie:border-mieborder mie:bg-miesurface mie:text-mietext mie:rounded mie:focus:border-mieprimary mie:focus:ring-1 mie:focus:ring-mieprimary/30 mie:outline-none",
|
|
1018
|
-
value:
|
|
1019
|
-
onChange: (
|
|
1018
|
+
value: j.answer || "",
|
|
1019
|
+
onChange: (b) => w("answer", b.target.value),
|
|
1020
1020
|
placeholder: "Default value"
|
|
1021
1021
|
}
|
|
1022
1022
|
)
|
|
1023
1023
|
] }),
|
|
1024
|
-
|
|
1025
|
-
|
|
1024
|
+
T && R && /* @__PURE__ */ t.jsx(Ve, { field: j, api: R }),
|
|
1025
|
+
x && R && /* @__PURE__ */ t.jsx(He, { field: j, api: R })
|
|
1026
1026
|
] })
|
|
1027
1027
|
] })
|
|
1028
1028
|
] })
|
|
@@ -1050,7 +1050,7 @@ function Re(e, i, r) {
|
|
|
1050
1050
|
return ["equals", "notEquals"];
|
|
1051
1051
|
}
|
|
1052
1052
|
}
|
|
1053
|
-
function
|
|
1053
|
+
function qt(e) {
|
|
1054
1054
|
switch (e) {
|
|
1055
1055
|
case "check":
|
|
1056
1056
|
case "multiselectdropdown":
|
|
@@ -1063,7 +1063,7 @@ function Lt(e) {
|
|
|
1063
1063
|
return [];
|
|
1064
1064
|
}
|
|
1065
1065
|
}
|
|
1066
|
-
function
|
|
1066
|
+
function Lt(e) {
|
|
1067
1067
|
switch (e) {
|
|
1068
1068
|
case "equals":
|
|
1069
1069
|
return "= (equals)";
|
|
@@ -1100,31 +1100,31 @@ function Ae(e) {
|
|
|
1100
1100
|
function $t() {
|
|
1101
1101
|
const e = B(), i = V((p) => p.byId), r = V((p) => p.setEnableWhen), n = V((p) => p.updateField), s = e?.selectedFieldId?.value ?? null;
|
|
1102
1102
|
e?.selectedChildId?.ParentId;
|
|
1103
|
-
const o = e?.selectedChildId?.ChildId ?? null, d = s ? i[s] : null, m = d?.fieldType === "section", c = l.useMemo(() => m ? Array.isArray(d?.fields) ? d.fields : [] : [], [m, d]), u = l.useMemo(() => !m || !o ? !1 : c.some((p) => p.id === o), [m, o, c]), h = l.useMemo(() => m && u ? `child:${o}` : "", [m, u, o]), [g,
|
|
1103
|
+
const o = e?.selectedChildId?.ChildId ?? null, d = s ? i[s] : null, m = d?.fieldType === "section", c = l.useMemo(() => m ? Array.isArray(d?.fields) ? d.fields : [] : [], [m, d]), u = l.useMemo(() => !m || !o ? !1 : c.some((p) => p.id === o), [m, o, c]), h = l.useMemo(() => m && u ? `child:${o}` : "", [m, u, o]), [g, S] = l.useState(h);
|
|
1104
1104
|
l.useEffect(() => {
|
|
1105
|
-
|
|
1105
|
+
S(h);
|
|
1106
1106
|
}, [h]);
|
|
1107
|
-
const
|
|
1108
|
-
if (
|
|
1107
|
+
const q = l.useCallback((p) => {
|
|
1108
|
+
if (S(p), !!m)
|
|
1109
1109
|
if (p && p.startsWith("child:")) {
|
|
1110
1110
|
const C = p.slice(6);
|
|
1111
1111
|
e.selectedChildId.set(s, C);
|
|
1112
1112
|
} else
|
|
1113
1113
|
e.selectedChildId.set(null, null);
|
|
1114
|
-
}, [m, s, e]), _ = !!(m && g && g.startsWith("child:")),
|
|
1114
|
+
}, [m, s, e]), _ = !!(m && g && g.startsWith("child:")), j = _ ? g.slice(6) : null, k = _ ? j : s, R = l.useMemo(() => k ? _ ? c.find((p) => p.id === j) ?? null : i[k] ?? null : null, [i, k, _, j, c]), w = l.useMemo(() => {
|
|
1115
1115
|
const p = [];
|
|
1116
1116
|
for (const C of Object.values(i))
|
|
1117
1117
|
if (C)
|
|
1118
1118
|
if (C.fieldType === "section" && Array.isArray(C.fields)) {
|
|
1119
1119
|
const M = C.title?.trim() || "Section";
|
|
1120
|
-
C.fields.forEach((
|
|
1120
|
+
C.fields.forEach((N) => {
|
|
1121
1121
|
p.push({
|
|
1122
|
-
id:
|
|
1122
|
+
id: N.id,
|
|
1123
1123
|
parentId: C.id,
|
|
1124
|
-
label: `${M} › ${
|
|
1125
|
-
fieldType:
|
|
1126
|
-
displayFormat:
|
|
1127
|
-
options: Array.isArray(
|
|
1124
|
+
label: `${M} › ${N.question?.trim() || N.id}`,
|
|
1125
|
+
fieldType: N.fieldType,
|
|
1126
|
+
displayFormat: N.displayFormat,
|
|
1127
|
+
options: Array.isArray(N.options) ? N.options : []
|
|
1128
1128
|
});
|
|
1129
1129
|
});
|
|
1130
1130
|
} else
|
|
@@ -1137,47 +1137,47 @@ function $t() {
|
|
|
1137
1137
|
options: Array.isArray(C.options) ? C.options : []
|
|
1138
1138
|
});
|
|
1139
1139
|
return p;
|
|
1140
|
-
}, [i]),
|
|
1141
|
-
(p) =>
|
|
1142
|
-
[
|
|
1143
|
-
),
|
|
1140
|
+
}, [i]), A = l.useCallback(
|
|
1141
|
+
(p) => w.find((C) => C.id === p) || null,
|
|
1142
|
+
[w]
|
|
1143
|
+
), T = l.useCallback(
|
|
1144
1144
|
(p) => {
|
|
1145
|
-
if (!
|
|
1145
|
+
if (!k) return;
|
|
1146
1146
|
const C = p && Array.isArray(p.conditions) ? { logic: p.logic || "AND", conditions: p.conditions } : void 0;
|
|
1147
|
-
_ && s ? n(
|
|
1147
|
+
_ && s ? n(k, { enableWhen: C }, { sectionId: s }) : r(k, C);
|
|
1148
1148
|
},
|
|
1149
|
-
[
|
|
1150
|
-
),
|
|
1149
|
+
[k, _, s, r, n]
|
|
1150
|
+
), x = l.useMemo(() => R?.enableWhen && Array.isArray(R.enableWhen.conditions) ? { logic: R.enableWhen.logic || "AND", conditions: R.enableWhen.conditions } : { logic: "AND", conditions: [] }, [R]), b = l.useCallback(() => {
|
|
1151
1151
|
const p = {
|
|
1152
|
-
logic:
|
|
1152
|
+
logic: x.logic || "AND",
|
|
1153
1153
|
conditions: [
|
|
1154
|
-
...Array.isArray(
|
|
1154
|
+
...Array.isArray(x.conditions) ? x.conditions : [],
|
|
1155
1155
|
{ targetId: "", operator: "equals", value: "" }
|
|
1156
1156
|
]
|
|
1157
1157
|
};
|
|
1158
|
-
|
|
1159
|
-
}, [
|
|
1158
|
+
T(p);
|
|
1159
|
+
}, [x, T]), f = l.useCallback(() => T(null), [T]), O = l.useCallback(
|
|
1160
1160
|
(p) => {
|
|
1161
|
-
const M = (Array.isArray(
|
|
1162
|
-
|
|
1161
|
+
const M = (Array.isArray(x.conditions) ? x.conditions : []).filter((N, F) => F !== p);
|
|
1162
|
+
T({ ...x, conditions: M });
|
|
1163
1163
|
},
|
|
1164
|
-
[
|
|
1165
|
-
),
|
|
1164
|
+
[x, T]
|
|
1165
|
+
), E = l.useCallback(
|
|
1166
1166
|
(p, C) => {
|
|
1167
|
-
const
|
|
1167
|
+
const N = [...Array.isArray(x.conditions) ? x.conditions : []], $ = { ...N[p] || { targetId: "", operator: "equals", value: "" }, ...C };
|
|
1168
1168
|
if ("targetId" in C) {
|
|
1169
|
-
const z =
|
|
1169
|
+
const z = A($.targetId), H = Re(z?.fieldType, z?.displayFormat, z?.inputType);
|
|
1170
1170
|
H.includes($.operator) || ($.operator = H[0] || "equals");
|
|
1171
1171
|
const Y = Array.isArray(z?.options) ? z.options.map(Ae) : [];
|
|
1172
1172
|
Y.length > 0 && (new Set(Y.map((v) => v.id)).has($.value) || ($.value = ""));
|
|
1173
1173
|
}
|
|
1174
|
-
|
|
1174
|
+
N[p] = $, T({ ...x, conditions: N });
|
|
1175
1175
|
},
|
|
1176
|
-
[
|
|
1177
|
-
),
|
|
1178
|
-
() =>
|
|
1179
|
-
[
|
|
1180
|
-
), P = !R || !
|
|
1176
|
+
[x, A, T]
|
|
1177
|
+
), I = l.useMemo(
|
|
1178
|
+
() => w.filter((p) => p.id !== k),
|
|
1179
|
+
[w, k]
|
|
1180
|
+
), P = !R || !k;
|
|
1181
1181
|
return /* @__PURE__ */ t.jsxs("div", { className: "logic-editor-container mie:space-y-4", children: [
|
|
1182
1182
|
m && /* @__PURE__ */ t.jsxs("div", { className: "mie:space-y-2", children: [
|
|
1183
1183
|
/* @__PURE__ */ t.jsx("label", { className: "mie:block mie:text-sm mie:font-medium mie:text-mietext", children: "Target Field" }),
|
|
@@ -1186,7 +1186,7 @@ function $t() {
|
|
|
1186
1186
|
{
|
|
1187
1187
|
className: "mie:w-full mie:px-3 mie:py-2 mie:border mie:border-mieborder mie:rounded-lg mie:focus:border-mieprimary mie:focus:ring-1 mie:focus:ring-mieprimary/30 mie:outline-none mie:bg-miesurface mie:text-mietext mie:cursor-pointer mie:transition-colors",
|
|
1188
1188
|
value: g,
|
|
1189
|
-
onChange: (p) =>
|
|
1189
|
+
onChange: (p) => q(p.target.value),
|
|
1190
1190
|
children: [
|
|
1191
1191
|
/* @__PURE__ */ t.jsx("option", { value: "", children: "Section (this)" }),
|
|
1192
1192
|
c.map((p) => /* @__PURE__ */ t.jsx("option", { value: `child:${p.id}`, children: p.question?.trim() || p.title?.trim() || p.id }, p.id))
|
|
@@ -1200,8 +1200,8 @@ function $t() {
|
|
|
1200
1200
|
/* @__PURE__ */ t.jsxs(
|
|
1201
1201
|
"select",
|
|
1202
1202
|
{
|
|
1203
|
-
value:
|
|
1204
|
-
onChange: (p) =>
|
|
1203
|
+
value: x.logic || "AND",
|
|
1204
|
+
onChange: (p) => T({ ...x, logic: p.target.value }),
|
|
1205
1205
|
className: "mie:w-full mie:px-3 mie:py-2 mie:border mie:border-mieborder mie:rounded-lg mie:focus:border-mieprimary mie:focus:ring-1 mie:focus:ring-mieprimary/30 mie:outline-none mie:bg-miesurface mie:text-mietext mie:cursor-pointer mie:transition-colors",
|
|
1206
1206
|
disabled: P,
|
|
1207
1207
|
children: [
|
|
@@ -1217,7 +1217,7 @@ function $t() {
|
|
|
1217
1217
|
{
|
|
1218
1218
|
type: "button",
|
|
1219
1219
|
className: "mie:flex-1 mie:px-3 mie:py-2 mie:text-sm mie:font-medium mie:bg-miesurface mie:text-mieprimary mie:border mie:border-mieprimary/50 mie:rounded-lg mie:hover:bg-mieprimary/10 mie:transition-colors mie:disabled:opacity-50 mie:disabled:cursor-not-allowed",
|
|
1220
|
-
onClick:
|
|
1220
|
+
onClick: b,
|
|
1221
1221
|
disabled: P,
|
|
1222
1222
|
children: "+ Add Condition"
|
|
1223
1223
|
}
|
|
@@ -1234,14 +1234,14 @@ function $t() {
|
|
|
1234
1234
|
)
|
|
1235
1235
|
] })
|
|
1236
1236
|
] }),
|
|
1237
|
-
|
|
1237
|
+
x.conditions.length > 0 && /* @__PURE__ */ t.jsxs("div", { className: "mie:space-y-3", children: [
|
|
1238
1238
|
/* @__PURE__ */ t.jsxs("h4", { className: "mie:text-sm mie:font-medium mie:text-mietext", children: [
|
|
1239
1239
|
"Conditions (",
|
|
1240
|
-
|
|
1240
|
+
x.conditions.length,
|
|
1241
1241
|
")"
|
|
1242
1242
|
] }),
|
|
1243
|
-
/* @__PURE__ */ t.jsx("div", { className: "mie:space-y-3", children:
|
|
1244
|
-
const M =
|
|
1243
|
+
/* @__PURE__ */ t.jsx("div", { className: "mie:space-y-3", children: x.conditions.map((p, C) => {
|
|
1244
|
+
const M = A(p.targetId), N = Re(M?.fieldType, M?.displayFormat, M?.inputType), F = M ? qt(M.fieldType) : [], $ = F.length > 0, z = Array.isArray(M?.options) ? M.options.map(Ae) : [], H = z.length > 0, Y = !["empty", "notEmpty"].includes(p.operator), v = ["greaterThan", "greaterThanOrEqual", "lessThan", "lessThanOrEqual"].includes(p.operator);
|
|
1245
1245
|
return /* @__PURE__ */ t.jsxs("div", { className: "mie:p-3 mie:bg-miebackground mie:border mie:border-mieborder mie:rounded-lg mie:space-y-2", children: [
|
|
1246
1246
|
/* @__PURE__ */ t.jsxs("div", { className: "mie:flex mie:items-center mie:justify-between mie:mb-2", children: [
|
|
1247
1247
|
/* @__PURE__ */ t.jsxs("span", { className: "mie:text-xs mie:font-semibold mie:text-mietextmuted mie:uppercase mie:tracking-wide", children: [
|
|
@@ -1252,7 +1252,7 @@ function $t() {
|
|
|
1252
1252
|
"button",
|
|
1253
1253
|
{
|
|
1254
1254
|
type: "button",
|
|
1255
|
-
onClick: () =>
|
|
1255
|
+
onClick: () => O(C),
|
|
1256
1256
|
className: "mie:bg-transparent mie:text-mietextmuted/70 mie:hover:text-miedanger mie:transition-colors mie:border-0 mie:outline-none mie:focus:outline-none",
|
|
1257
1257
|
title: "Remove condition",
|
|
1258
1258
|
disabled: P,
|
|
@@ -1268,11 +1268,11 @@ function $t() {
|
|
|
1268
1268
|
{
|
|
1269
1269
|
className: "mie:w-full mie:px-3 mie:py-2 mie:border mie:border-mieborder mie:rounded-lg mie:focus:border-mieprimary mie:focus:ring-1 mie:focus:ring-mieprimary/30 mie:outline-none mie:bg-miesurface mie:text-mietext mie:text-sm mie:cursor-pointer mie:transition-colors",
|
|
1270
1270
|
value: p.targetId,
|
|
1271
|
-
onChange: (y) =>
|
|
1271
|
+
onChange: (y) => E(C, { targetId: y.target.value }),
|
|
1272
1272
|
disabled: P,
|
|
1273
1273
|
children: [
|
|
1274
1274
|
/* @__PURE__ */ t.jsx("option", { value: "", children: "— Select field —" }),
|
|
1275
|
-
|
|
1275
|
+
I.map((y) => /* @__PURE__ */ t.jsx("option", { value: y.id, children: y.label }, y.id))
|
|
1276
1276
|
]
|
|
1277
1277
|
}
|
|
1278
1278
|
)
|
|
@@ -1284,7 +1284,7 @@ function $t() {
|
|
|
1284
1284
|
{
|
|
1285
1285
|
className: "mie:w-full mie:px-3 mie:py-2 mie:border mie:border-mieborder mie:rounded-lg mie:focus:border-mieprimary mie:focus:ring-1 mie:focus:ring-mieprimary/30 mie:outline-none mie:bg-miesurface mie:text-mietext mie:text-sm mie:cursor-pointer mie:transition-colors",
|
|
1286
1286
|
value: p.propertyAccessor || "",
|
|
1287
|
-
onChange: (y) =>
|
|
1287
|
+
onChange: (y) => E(C, { propertyAccessor: y.target.value || void 0 }),
|
|
1288
1288
|
disabled: P || !M,
|
|
1289
1289
|
children: [
|
|
1290
1290
|
/* @__PURE__ */ t.jsx("option", { value: "", children: "— Direct value —" }),
|
|
@@ -1308,9 +1308,9 @@ function $t() {
|
|
|
1308
1308
|
{
|
|
1309
1309
|
className: "mie:w-full mie:px-3 mie:py-2 mie:border mie:border-mieborder mie:rounded-lg mie:focus:border-mieprimary mie:focus:ring-1 mie:focus:ring-mieprimary/30 mie:outline-none mie:bg-miesurface mie:text-mietext mie:text-sm mie:cursor-pointer mie:transition-colors",
|
|
1310
1310
|
value: p.operator,
|
|
1311
|
-
onChange: (y) =>
|
|
1311
|
+
onChange: (y) => E(C, { operator: y.target.value }),
|
|
1312
1312
|
disabled: P || !M,
|
|
1313
|
-
children: (M ?
|
|
1313
|
+
children: (M ? N : ["equals"]).map((y) => /* @__PURE__ */ t.jsx("option", { value: y, children: Lt(y) }, y))
|
|
1314
1314
|
}
|
|
1315
1315
|
)
|
|
1316
1316
|
] }),
|
|
@@ -1321,7 +1321,7 @@ function $t() {
|
|
|
1321
1321
|
{
|
|
1322
1322
|
className: "mie:w-full mie:px-3 mie:py-2 mie:border mie:border-mieborder mie:rounded-lg mie:focus:border-mieprimary mie:focus:ring-1 mie:focus:ring-mieprimary/30 mie:outline-none mie:bg-miesurface mie:text-mietext mie:text-sm mie:cursor-pointer mie:transition-colors",
|
|
1323
1323
|
value: p.value,
|
|
1324
|
-
onChange: (y) =>
|
|
1324
|
+
onChange: (y) => E(C, { value: y.target.value }),
|
|
1325
1325
|
disabled: P || !M,
|
|
1326
1326
|
children: [
|
|
1327
1327
|
/* @__PURE__ */ t.jsx("option", { value: "", children: "— Select option —" }),
|
|
@@ -1335,7 +1335,7 @@ function $t() {
|
|
|
1335
1335
|
placeholder: p.propertyAccessor || v ? "Enter number" : "Enter value",
|
|
1336
1336
|
type: p.propertyAccessor || v ? "number" : "text",
|
|
1337
1337
|
value: p.value,
|
|
1338
|
-
onChange: (y) =>
|
|
1338
|
+
onChange: (y) => E(C, { value: y.target.value }),
|
|
1339
1339
|
disabled: P || !M
|
|
1340
1340
|
}
|
|
1341
1341
|
) : /* @__PURE__ */ t.jsx("div", { className: "mie:w-full mie:px-3 mie:py-2 mie:border mie:border-mieborder mie:rounded-lg mie:bg-miebackground mie:text-sm mie:text-mietextmuted mie:flex mie:items-center", children: "(no value needed)" })
|
|
@@ -1586,7 +1586,7 @@ function De(e, i) {
|
|
|
1586
1586
|
}
|
|
1587
1587
|
return r;
|
|
1588
1588
|
}
|
|
1589
|
-
function
|
|
1589
|
+
function qe(e) {
|
|
1590
1590
|
for (var i = 1; i < arguments.length; i++) {
|
|
1591
1591
|
var r = arguments[i] != null ? arguments[i] : {};
|
|
1592
1592
|
i % 2 ? De(Object(r), !0).forEach(function(n) {
|
|
@@ -1685,7 +1685,7 @@ function di(e, i) {
|
|
|
1685
1685
|
return ne(i) ? i(e.current) : i;
|
|
1686
1686
|
}
|
|
1687
1687
|
function ui(e, i) {
|
|
1688
|
-
return e.current =
|
|
1688
|
+
return e.current = qe(qe({}, e.current), i), i;
|
|
1689
1689
|
}
|
|
1690
1690
|
function fi(e, i, r) {
|
|
1691
1691
|
return ne(i) ? i(e.current) : Object.keys(r).forEach(function(n) {
|
|
@@ -1715,7 +1715,7 @@ function bi(e) {
|
|
|
1715
1715
|
return {}.toString.call(e).includes("Object");
|
|
1716
1716
|
}
|
|
1717
1717
|
function gi(e) {
|
|
1718
|
-
return e ||
|
|
1718
|
+
return e || Le("configIsRequired"), bi(e) || Le("configType"), e.urls ? (vi(), {
|
|
1719
1719
|
paths: {
|
|
1720
1720
|
vs: e.urls.monacoBase
|
|
1721
1721
|
}
|
|
@@ -1741,7 +1741,7 @@ var Ye = {
|
|
|
1741
1741
|
|
|
1742
1742
|
For more please check the link https://github.com/suren-atoyan/monaco-loader#config
|
|
1743
1743
|
`
|
|
1744
|
-
},
|
|
1744
|
+
}, Le = xi(yi)(Ye), ji = {
|
|
1745
1745
|
config: gi
|
|
1746
1746
|
}, wi = function() {
|
|
1747
1747
|
for (var i = arguments.length, r = new Array(i), n = 0; n < i; n++)
|
|
@@ -1866,11 +1866,11 @@ var je = new Promise(function(e, i) {
|
|
|
1866
1866
|
function _i({ children: e }) {
|
|
1867
1867
|
return l.createElement("div", { style: Fi.container }, e);
|
|
1868
1868
|
}
|
|
1869
|
-
var Di = _i,
|
|
1870
|
-
function
|
|
1871
|
-
return l.createElement("section", { style: { ...we.wrapper, width: e, height: i }, ...d }, !r && l.createElement(
|
|
1869
|
+
var Di = _i, qi = Di;
|
|
1870
|
+
function Li({ width: e, height: i, isEditorReady: r, loading: n, _ref: s, className: o, wrapperProps: d }) {
|
|
1871
|
+
return l.createElement("section", { style: { ...we.wrapper, width: e, height: i }, ...d }, !r && l.createElement(qi, null, n), l.createElement("div", { ref: s, style: { ...we.fullWidth, ...!r && we.hide }, className: o }));
|
|
1872
1872
|
}
|
|
1873
|
-
var $i =
|
|
1873
|
+
var $i = Li, Xe = Ce($i);
|
|
1874
1874
|
function Ui(e) {
|
|
1875
1875
|
J(e, []);
|
|
1876
1876
|
}
|
|
@@ -1896,52 +1896,52 @@ function Vi(e, i, r, n) {
|
|
|
1896
1896
|
function Ze(e, i) {
|
|
1897
1897
|
return e.Uri.parse(i);
|
|
1898
1898
|
}
|
|
1899
|
-
function Hi({ original: e, modified: i, language: r, originalLanguage: n, modifiedLanguage: s, originalModelPath: o, modifiedModelPath: d, keepCurrentOriginalModel: m = !1, keepCurrentModifiedModel: c = !1, theme: u = "light", loading: h = "Loading...", options: g = {}, height:
|
|
1900
|
-
let [
|
|
1899
|
+
function Hi({ original: e, modified: i, language: r, originalLanguage: n, modifiedLanguage: s, originalModelPath: o, modifiedModelPath: d, keepCurrentOriginalModel: m = !1, keepCurrentModifiedModel: c = !1, theme: u = "light", loading: h = "Loading...", options: g = {}, height: S = "100%", width: q = "100%", className: _, wrapperProps: j = {}, beforeMount: k = ie, onMount: R = ie }) {
|
|
1900
|
+
let [w, A] = ue(!1), [T, x] = ue(!0), b = U(null), f = U(null), O = U(null), E = U(R), I = U(k), P = U(!1);
|
|
1901
1901
|
Qe(() => {
|
|
1902
|
-
let
|
|
1903
|
-
return
|
|
1902
|
+
let N = Ke.init();
|
|
1903
|
+
return N.then((F) => (f.current = F) && x(!1)).catch((F) => F?.type !== "cancelation" && console.error("Monaco initialization: error:", F)), () => b.current ? M() : N.cancel();
|
|
1904
1904
|
}), W(() => {
|
|
1905
|
-
if (
|
|
1906
|
-
let
|
|
1907
|
-
F !==
|
|
1905
|
+
if (b.current && f.current) {
|
|
1906
|
+
let N = b.current.getOriginalEditor(), F = Q(f.current, e || "", n || r || "text", o || "");
|
|
1907
|
+
F !== N.getModel() && N.setModel(F);
|
|
1908
1908
|
}
|
|
1909
|
-
}, [o],
|
|
1910
|
-
if (
|
|
1911
|
-
let
|
|
1912
|
-
F !==
|
|
1909
|
+
}, [o], w), W(() => {
|
|
1910
|
+
if (b.current && f.current) {
|
|
1911
|
+
let N = b.current.getModifiedEditor(), F = Q(f.current, i || "", s || r || "text", d || "");
|
|
1912
|
+
F !== N.getModel() && N.setModel(F);
|
|
1913
1913
|
}
|
|
1914
|
-
}, [d],
|
|
1915
|
-
let
|
|
1916
|
-
|
|
1917
|
-
}, [i],
|
|
1918
|
-
|
|
1919
|
-
}, [e],
|
|
1920
|
-
let { original:
|
|
1921
|
-
f.current.editor.setModelLanguage(
|
|
1922
|
-
}, [r, n, s],
|
|
1914
|
+
}, [d], w), W(() => {
|
|
1915
|
+
let N = b.current.getModifiedEditor();
|
|
1916
|
+
N.getOption(f.current.editor.EditorOption.readOnly) ? N.setValue(i || "") : i !== N.getValue() && (N.executeEdits("", [{ range: N.getModel().getFullModelRange(), text: i || "", forceMoveMarkers: !0 }]), N.pushUndoStop());
|
|
1917
|
+
}, [i], w), W(() => {
|
|
1918
|
+
b.current?.getModel()?.original.setValue(e || "");
|
|
1919
|
+
}, [e], w), W(() => {
|
|
1920
|
+
let { original: N, modified: F } = b.current.getModel();
|
|
1921
|
+
f.current.editor.setModelLanguage(N, n || r || "text"), f.current.editor.setModelLanguage(F, s || r || "text");
|
|
1922
|
+
}, [r, n, s], w), W(() => {
|
|
1923
1923
|
f.current?.editor.setTheme(u);
|
|
1924
|
-
}, [u],
|
|
1925
|
-
|
|
1926
|
-
}, [g],
|
|
1924
|
+
}, [u], w), W(() => {
|
|
1925
|
+
b.current?.updateOptions(g);
|
|
1926
|
+
}, [g], w);
|
|
1927
1927
|
let p = de(() => {
|
|
1928
1928
|
if (!f.current) return;
|
|
1929
|
-
|
|
1930
|
-
let
|
|
1931
|
-
|
|
1929
|
+
I.current(f.current);
|
|
1930
|
+
let N = Q(f.current, e || "", n || r || "text", o || ""), F = Q(f.current, i || "", s || r || "text", d || "");
|
|
1931
|
+
b.current?.setModel({ original: N, modified: F });
|
|
1932
1932
|
}, [r, i, s, e, n, o, d]), C = de(() => {
|
|
1933
|
-
!P.current &&
|
|
1933
|
+
!P.current && O.current && (b.current = f.current.editor.createDiffEditor(O.current, { automaticLayout: !0, ...g }), p(), f.current?.editor.setTheme(u), A(!0), P.current = !0);
|
|
1934
1934
|
}, [g, u, p]);
|
|
1935
1935
|
J(() => {
|
|
1936
|
-
|
|
1937
|
-
}, [
|
|
1938
|
-
!
|
|
1939
|
-
}, [
|
|
1936
|
+
w && E.current(b.current, f.current);
|
|
1937
|
+
}, [w]), J(() => {
|
|
1938
|
+
!T && !w && C();
|
|
1939
|
+
}, [T, w, C]);
|
|
1940
1940
|
function M() {
|
|
1941
|
-
let
|
|
1942
|
-
m ||
|
|
1941
|
+
let N = b.current?.getModel();
|
|
1942
|
+
m || N?.original?.dispose(), c || N?.modified?.dispose(), b.current?.dispose();
|
|
1943
1943
|
}
|
|
1944
|
-
return l.createElement(Xe, { width:
|
|
1944
|
+
return l.createElement(Xe, { width: q, height: S, isEditorReady: w, loading: h, _ref: O, className: _, wrapperProps: j });
|
|
1945
1945
|
}
|
|
1946
1946
|
var Yi = Hi;
|
|
1947
1947
|
Ce(Yi);
|
|
@@ -1952,48 +1952,48 @@ function Ji(e) {
|
|
|
1952
1952
|
}, [e]), i.current;
|
|
1953
1953
|
}
|
|
1954
1954
|
var Bi = Ji, ce = /* @__PURE__ */ new Map();
|
|
1955
|
-
function Gi({ defaultValue: e, defaultLanguage: i, defaultPath: r, value: n, language: s, path: o, theme: d = "light", line: m, loading: c = "Loading...", options: u = {}, overrideServices: h = {}, saveViewState: g = !0, keepCurrentModel:
|
|
1956
|
-
let [
|
|
1955
|
+
function Gi({ defaultValue: e, defaultLanguage: i, defaultPath: r, value: n, language: s, path: o, theme: d = "light", line: m, loading: c = "Loading...", options: u = {}, overrideServices: h = {}, saveViewState: g = !0, keepCurrentModel: S = !1, width: q = "100%", height: _ = "100%", className: j, wrapperProps: k = {}, beforeMount: R = ie, onMount: w = ie, onChange: A, onValidate: T = ie }) {
|
|
1956
|
+
let [x, b] = ue(!1), [f, O] = ue(!0), E = U(null), I = U(null), P = U(null), p = U(w), C = U(R), M = U(), N = U(n), F = Bi(o), $ = U(!1), z = U(!1);
|
|
1957
1957
|
Qe(() => {
|
|
1958
1958
|
let a = Ke.init();
|
|
1959
|
-
return a.then((v) => (
|
|
1959
|
+
return a.then((v) => (E.current = v) && O(!1)).catch((v) => v?.type !== "cancelation" && console.error("Monaco initialization: error:", v)), () => I.current ? Y() : a.cancel();
|
|
1960
1960
|
}), W(() => {
|
|
1961
|
-
let a = Q(
|
|
1962
|
-
a !==
|
|
1963
|
-
}, [o],
|
|
1964
|
-
|
|
1965
|
-
}, [u],
|
|
1966
|
-
!
|
|
1967
|
-
}, [n],
|
|
1968
|
-
let a =
|
|
1969
|
-
a && s &&
|
|
1970
|
-
}, [s],
|
|
1971
|
-
m !== void 0 &&
|
|
1972
|
-
}, [m],
|
|
1973
|
-
|
|
1974
|
-
}, [d],
|
|
1961
|
+
let a = Q(E.current, e || n || "", i || s || "", o || r || "");
|
|
1962
|
+
a !== I.current?.getModel() && (g && ce.set(F, I.current?.saveViewState()), I.current?.setModel(a), g && I.current?.restoreViewState(ce.get(o)));
|
|
1963
|
+
}, [o], x), W(() => {
|
|
1964
|
+
I.current?.updateOptions(u);
|
|
1965
|
+
}, [u], x), W(() => {
|
|
1966
|
+
!I.current || n === void 0 || (I.current.getOption(E.current.editor.EditorOption.readOnly) ? I.current.setValue(n) : n !== I.current.getValue() && (z.current = !0, I.current.executeEdits("", [{ range: I.current.getModel().getFullModelRange(), text: n, forceMoveMarkers: !0 }]), I.current.pushUndoStop(), z.current = !1));
|
|
1967
|
+
}, [n], x), W(() => {
|
|
1968
|
+
let a = I.current?.getModel();
|
|
1969
|
+
a && s && E.current?.editor.setModelLanguage(a, s);
|
|
1970
|
+
}, [s], x), W(() => {
|
|
1971
|
+
m !== void 0 && I.current?.revealLine(m);
|
|
1972
|
+
}, [m], x), W(() => {
|
|
1973
|
+
E.current?.editor.setTheme(d);
|
|
1974
|
+
}, [d], x);
|
|
1975
1975
|
let H = de(() => {
|
|
1976
|
-
if (!(!P.current || !
|
|
1977
|
-
C.current(
|
|
1978
|
-
let a = o || r, v = Q(
|
|
1979
|
-
|
|
1976
|
+
if (!(!P.current || !E.current) && !$.current) {
|
|
1977
|
+
C.current(E.current);
|
|
1978
|
+
let a = o || r, v = Q(E.current, n || e || "", i || s || "", a || "");
|
|
1979
|
+
I.current = E.current?.editor.create(P.current, { model: v, automaticLayout: !0, ...u }, h), g && I.current.restoreViewState(ce.get(a)), E.current.editor.setTheme(d), m !== void 0 && I.current.revealLine(m), b(!0), $.current = !0;
|
|
1980
1980
|
}
|
|
1981
1981
|
}, [e, i, r, n, s, o, u, h, g, d, m]);
|
|
1982
1982
|
J(() => {
|
|
1983
|
-
|
|
1984
|
-
}, [
|
|
1985
|
-
!f && !
|
|
1986
|
-
}, [f,
|
|
1987
|
-
|
|
1988
|
-
z.current || I
|
|
1983
|
+
x && p.current(I.current, E.current);
|
|
1984
|
+
}, [x]), J(() => {
|
|
1985
|
+
!f && !x && H();
|
|
1986
|
+
}, [f, x, H]), N.current = n, J(() => {
|
|
1987
|
+
x && A && (M.current?.dispose(), M.current = I.current?.onDidChangeModelContent((a) => {
|
|
1988
|
+
z.current || A(I.current.getValue(), a);
|
|
1989
1989
|
}));
|
|
1990
|
-
}, [
|
|
1991
|
-
if (
|
|
1992
|
-
let a =
|
|
1993
|
-
let y =
|
|
1990
|
+
}, [x, A]), J(() => {
|
|
1991
|
+
if (x) {
|
|
1992
|
+
let a = E.current.editor.onDidChangeMarkers((v) => {
|
|
1993
|
+
let y = I.current.getModel()?.uri;
|
|
1994
1994
|
if (y && v.find((D) => D.path === y.path)) {
|
|
1995
|
-
let D =
|
|
1996
|
-
|
|
1995
|
+
let D = E.current.editor.getModelMarkers({ resource: y });
|
|
1996
|
+
T?.(D);
|
|
1997
1997
|
}
|
|
1998
1998
|
});
|
|
1999
1999
|
return () => {
|
|
@@ -2002,11 +2002,11 @@ function Gi({ defaultValue: e, defaultLanguage: i, defaultPath: r, value: n, lan
|
|
|
2002
2002
|
}
|
|
2003
2003
|
return () => {
|
|
2004
2004
|
};
|
|
2005
|
-
}, [
|
|
2005
|
+
}, [x, T]);
|
|
2006
2006
|
function Y() {
|
|
2007
|
-
M.current?.dispose(),
|
|
2007
|
+
M.current?.dispose(), S ? g && ce.set(o, I.current.saveViewState()) : I.current.getModel()?.dispose(), I.current.dispose();
|
|
2008
2008
|
}
|
|
2009
|
-
return l.createElement(Xe, { width:
|
|
2009
|
+
return l.createElement(Xe, { width: q, height: _, isEditorReady: x, loading: c, _ref: P, className: j, wrapperProps: k });
|
|
2010
2010
|
}
|
|
2011
2011
|
var Ki = Gi, Xi = Ce(Ki), Qi = Xi;
|
|
2012
2012
|
function Zi() {
|
|
@@ -2014,57 +2014,57 @@ function Zi() {
|
|
|
2014
2014
|
l.useEffect(() => {
|
|
2015
2015
|
const f = document.querySelector(".qb-editor-root");
|
|
2016
2016
|
if (!f) return;
|
|
2017
|
-
const
|
|
2017
|
+
const O = () => {
|
|
2018
2018
|
g(f.classList.contains("dark"));
|
|
2019
2019
|
};
|
|
2020
|
-
|
|
2021
|
-
const
|
|
2022
|
-
return
|
|
2020
|
+
O();
|
|
2021
|
+
const E = new MutationObserver(O);
|
|
2022
|
+
return E.observe(f, { attributes: !0, attributeFilter: ["class"] }), () => E.disconnect();
|
|
2023
2023
|
}, []);
|
|
2024
|
-
const [
|
|
2024
|
+
const [S, q] = l.useState(640), [_, j] = l.useState(() => {
|
|
2025
2025
|
try {
|
|
2026
2026
|
return ae.dump(e, { indent: 2, lineWidth: -1 });
|
|
2027
2027
|
} catch {
|
|
2028
2028
|
return "";
|
|
2029
2029
|
}
|
|
2030
|
-
}), [
|
|
2030
|
+
}), [k, R] = l.useState("");
|
|
2031
2031
|
l.useEffect(() => {
|
|
2032
2032
|
r.setCodeEditorHasError(!1);
|
|
2033
2033
|
}, []);
|
|
2034
|
-
const
|
|
2034
|
+
const w = l.useCallback((f) => c === "json" ? JSON.parse(f) : ae.load(f), [c]), A = l.useCallback((f) => c === "json" ? JSON.stringify(f, null, 2) : ae.dump(f, { indent: 2, lineWidth: -1 }), [c]);
|
|
2035
2035
|
l.useEffect(() => {
|
|
2036
2036
|
const f = () => {
|
|
2037
2037
|
if (s.current) {
|
|
2038
|
-
const
|
|
2039
|
-
|
|
2038
|
+
const O = s.current.getBoundingClientRect().top, E = window.innerHeight - O - 20;
|
|
2039
|
+
q(Math.max(400, E));
|
|
2040
2040
|
}
|
|
2041
2041
|
};
|
|
2042
2042
|
return f(), window.addEventListener("resize", f), () => window.removeEventListener("resize", f);
|
|
2043
2043
|
}, []), l.useEffect(() => {
|
|
2044
2044
|
if (!m.current)
|
|
2045
2045
|
try {
|
|
2046
|
-
const f =
|
|
2047
|
-
|
|
2046
|
+
const f = A(e);
|
|
2047
|
+
j(f), o.current = f, R(""), r.setCodeEditorHasError(!1);
|
|
2048
2048
|
} catch (f) {
|
|
2049
2049
|
R(`Failed to serialize: ${f.message}`), r.setCodeEditorHasError(!0);
|
|
2050
2050
|
}
|
|
2051
|
-
}, [e,
|
|
2052
|
-
const
|
|
2053
|
-
|
|
2051
|
+
}, [e, A, r]);
|
|
2052
|
+
const T = (f) => {
|
|
2053
|
+
j(f || ""), o.current = f || "", m.current = !0;
|
|
2054
2054
|
try {
|
|
2055
|
-
const
|
|
2056
|
-
if (!
|
|
2055
|
+
const O = w(f || "{}");
|
|
2056
|
+
if (!O || typeof O != "object")
|
|
2057
2057
|
throw new Error("Invalid form data: must be an object");
|
|
2058
2058
|
R(""), r.setCodeEditorHasError(!1);
|
|
2059
|
-
} catch (
|
|
2060
|
-
const
|
|
2061
|
-
R(
|
|
2059
|
+
} catch (O) {
|
|
2060
|
+
const E = `Invalid ${c.toUpperCase()}: ${O.message}`;
|
|
2061
|
+
R(E), r.setCodeEditorHasError(!0);
|
|
2062
2062
|
}
|
|
2063
|
-
},
|
|
2064
|
-
d.current = f, f.onDidPaste((
|
|
2065
|
-
const
|
|
2063
|
+
}, x = (f) => {
|
|
2064
|
+
d.current = f, f.onDidPaste((O) => {
|
|
2065
|
+
const E = _, I = f.getModel().getValue();
|
|
2066
2066
|
try {
|
|
2067
|
-
const P =
|
|
2067
|
+
const P = w(I);
|
|
2068
2068
|
if (P && typeof P == "object") {
|
|
2069
2069
|
const { schemaType: p } = fe(P);
|
|
2070
2070
|
p === "surveyjs" && n(
|
|
@@ -2076,14 +2076,14 @@ Do you want to proceed with the conversion?`,
|
|
|
2076
2076
|
confirmText: "Yes, Convert",
|
|
2077
2077
|
cancelText: "No, Cancel Paste",
|
|
2078
2078
|
onConfirm: () => {
|
|
2079
|
-
const { fields: C, conversionReport: M } = pe(P, p),
|
|
2079
|
+
const { fields: C, conversionReport: M } = pe(P, p), N = {
|
|
2080
2080
|
schemaType: P.schemaType || ve,
|
|
2081
2081
|
...M?.surveyMetadata || {},
|
|
2082
2082
|
fields: C
|
|
2083
2083
|
};
|
|
2084
|
-
i(
|
|
2085
|
-
const F =
|
|
2086
|
-
|
|
2084
|
+
i(N);
|
|
2085
|
+
const F = A(N);
|
|
2086
|
+
j(F), o.current = F, f.setValue(F), R(""), m.current = !1, M && (r.setConversionReport(M), setTimeout(() => {
|
|
2087
2087
|
const $ = M?.unsupportedFields?.length || 0;
|
|
2088
2088
|
n(
|
|
2089
2089
|
`This schema has been converted to MIE Forms format.
|
|
@@ -2097,7 +2097,7 @@ Please use MIE Forms schema inside of code editor for the best experience in the
|
|
|
2097
2097
|
}, 100));
|
|
2098
2098
|
},
|
|
2099
2099
|
onCancel: () => {
|
|
2100
|
-
f.setValue(
|
|
2100
|
+
f.setValue(E), j(E), o.current = E;
|
|
2101
2101
|
}
|
|
2102
2102
|
}
|
|
2103
2103
|
);
|
|
@@ -2105,12 +2105,12 @@ Please use MIE Forms schema inside of code editor for the best experience in the
|
|
|
2105
2105
|
} catch {
|
|
2106
2106
|
}
|
|
2107
2107
|
});
|
|
2108
|
-
},
|
|
2108
|
+
}, b = (f) => {
|
|
2109
2109
|
try {
|
|
2110
|
-
const
|
|
2111
|
-
|
|
2112
|
-
} catch (
|
|
2113
|
-
R(`Cannot convert: ${
|
|
2110
|
+
const O = w(_), E = f === "json" ? JSON.stringify(O, null, 2) : ae.dump(O, { indent: 2, lineWidth: -1 });
|
|
2111
|
+
j(E), o.current = E, u(f), R(""), r.setCodeEditorHasError(!1);
|
|
2112
|
+
} catch (O) {
|
|
2113
|
+
R(`Cannot convert: ${O.message}`), r.setCodeEditorHasError(!0);
|
|
2114
2114
|
}
|
|
2115
2115
|
};
|
|
2116
2116
|
return l.useEffect(() => () => {
|
|
@@ -2120,23 +2120,23 @@ Please use MIE Forms schema inside of code editor for the best experience in the
|
|
|
2120
2120
|
return;
|
|
2121
2121
|
}
|
|
2122
2122
|
try {
|
|
2123
|
-
const
|
|
2124
|
-
if (!
|
|
2125
|
-
const { schemaType:
|
|
2126
|
-
schemaType:
|
|
2123
|
+
const O = w(f);
|
|
2124
|
+
if (!O || typeof O != "object" || JSON.stringify(e) === JSON.stringify(O)) return;
|
|
2125
|
+
const { schemaType: E } = fe(O), { fields: I, conversionReport: P } = pe(O, E), p = {
|
|
2126
|
+
schemaType: O.schemaType || ve,
|
|
2127
2127
|
...P?.surveyMetadata || {},
|
|
2128
|
-
fields:
|
|
2128
|
+
fields: I
|
|
2129
2129
|
};
|
|
2130
2130
|
P && r.setConversionReport(P), i(p), r.setCodeEditorHasError(!1), m.current = !1;
|
|
2131
2131
|
} catch {
|
|
2132
2132
|
}
|
|
2133
|
-
}, [
|
|
2133
|
+
}, [w, i, r, e]), /* @__PURE__ */ t.jsxs("div", { ref: s, className: "code-editor-container mie:flex mie:flex-col mie:bg-miebackground mie:max-w-7xl mie:w-full", style: { height: `${S}px` }, children: [
|
|
2134
2134
|
/* @__PURE__ */ t.jsxs("div", { className: "code-editor-header mie:flex mie:items-center mie:justify-between mie:gap-3 mie:p-4 mie:bg-miesurface mie:border-b mie:border-mieborder", children: [
|
|
2135
2135
|
/* @__PURE__ */ t.jsx("div", { className: "mie:flex mie:items-center mie:gap-2", children: /* @__PURE__ */ t.jsxs("div", { className: "mie:flex mie:gap-1 mie:rounded-lg mie:border mie:border-mieborder mie:bg-miebackground mie:p-1", children: [
|
|
2136
2136
|
/* @__PURE__ */ t.jsx(
|
|
2137
2137
|
"button",
|
|
2138
2138
|
{
|
|
2139
|
-
onClick: () =>
|
|
2139
|
+
onClick: () => b("yaml"),
|
|
2140
2140
|
className: `mie:px-3 mie:py-1 mie:rounded-md mie:text-sm mie:font-medium mie:transition-colors mie:border-0 mie:outline-none mie:focus:outline-none ${c === "yaml" ? "mie:bg-mieprimary mie:text-mietextsecondary mie:shadow-sm" : "mie:bg-transparent mie:text-mietextmuted mie:hover:text-mietext mie:hover:bg-miesurface"}`,
|
|
2141
2141
|
children: "YAML"
|
|
2142
2142
|
}
|
|
@@ -2144,7 +2144,7 @@ Please use MIE Forms schema inside of code editor for the best experience in the
|
|
|
2144
2144
|
/* @__PURE__ */ t.jsx(
|
|
2145
2145
|
"button",
|
|
2146
2146
|
{
|
|
2147
|
-
onClick: () =>
|
|
2147
|
+
onClick: () => b("json"),
|
|
2148
2148
|
className: `mie:px-3 mie:py-1 mie:rounded-md mie:text-sm mie:font-medium mie:transition-colors mie:border-0 mie:outline-none mie:focus:outline-none ${c === "json" ? "mie:bg-mieprimary mie:text-mietextsecondary mie:shadow-sm" : "mie:bg-transparent mie:text-mietextmuted mie:hover:text-mietext mie:hover:bg-miesurface"}`,
|
|
2149
2149
|
children: "JSON"
|
|
2150
2150
|
}
|
|
@@ -2152,7 +2152,7 @@ Please use MIE Forms schema inside of code editor for the best experience in the
|
|
|
2152
2152
|
] }) }),
|
|
2153
2153
|
/* @__PURE__ */ t.jsxs("div", { className: "mie:flex mie:items-center mie:gap-2", children: [
|
|
2154
2154
|
/* @__PURE__ */ t.jsx("div", { className: "mie:text-xs mie:text-mietextmuted mie:px-3 mie:py-1", children: "Auto-saves when switching tabs" }),
|
|
2155
|
-
|
|
2155
|
+
k && /* @__PURE__ */ t.jsx("div", { className: "mie:text-xs mie:text-miedanger mie:bg-miedanger/10 mie:px-3 mie:py-1 mie:rounded-lg", children: k })
|
|
2156
2156
|
] })
|
|
2157
2157
|
] }),
|
|
2158
2158
|
/* @__PURE__ */ t.jsx("div", { className: "code-editor-content mie:flex-1 mie:overflow-hidden", children: /* @__PURE__ */ t.jsx(
|
|
@@ -2161,8 +2161,8 @@ Please use MIE Forms schema inside of code editor for the best experience in the
|
|
|
2161
2161
|
height: "100%",
|
|
2162
2162
|
language: c,
|
|
2163
2163
|
value: _,
|
|
2164
|
-
onChange:
|
|
2165
|
-
onMount:
|
|
2164
|
+
onChange: T,
|
|
2165
|
+
onMount: x,
|
|
2166
2166
|
theme: h ? "vs-dark" : "light",
|
|
2167
2167
|
options: {
|
|
2168
2168
|
minimap: { enabled: !1 },
|
|
@@ -2230,60 +2230,50 @@ function tr({
|
|
|
2230
2230
|
showHeader: s = !0,
|
|
2231
2231
|
startInPreview: o = !1,
|
|
2232
2232
|
hideUnsupportedFields: d = !1,
|
|
2233
|
-
theme: m = "
|
|
2233
|
+
theme: m = "light"
|
|
2234
2234
|
}) {
|
|
2235
|
-
const [c, u] = l.useState("json"), h = B(), g = l.useRef(!1),
|
|
2235
|
+
const [c, u] = l.useState("json"), h = B(), g = l.useRef(!1), S = l.useContext(Oe);
|
|
2236
2236
|
l.useEffect(() => {
|
|
2237
|
-
if (!(g.current || !
|
|
2237
|
+
if (!(g.current || !S)) {
|
|
2238
2238
|
if (e)
|
|
2239
2239
|
try {
|
|
2240
|
-
const { data:
|
|
2241
|
-
|
|
2242
|
-
const
|
|
2243
|
-
schemaType:
|
|
2244
|
-
fields:
|
|
2240
|
+
const { data: j, schemaType: k } = fe(e, i), R = pe(j, k);
|
|
2241
|
+
R.conversionReport && h.setConversionReport(R.conversionReport);
|
|
2242
|
+
const w = {
|
|
2243
|
+
schemaType: k === "surveyjs" ? "mieforms-v1.0" : j.schemaType || "mieforms-v1.0",
|
|
2244
|
+
fields: R.fields || []
|
|
2245
2245
|
};
|
|
2246
|
-
if (
|
|
2247
|
-
Object.assign(
|
|
2248
|
-
else if (
|
|
2249
|
-
const { fields:
|
|
2250
|
-
Object.keys(x).length > 0 && Object.assign(
|
|
2246
|
+
if (k === "surveyjs" && R.conversionReport?.surveyMetadata)
|
|
2247
|
+
Object.assign(w, R.conversionReport.surveyMetadata);
|
|
2248
|
+
else if (k === "mieforms") {
|
|
2249
|
+
const { fields: A, schemaType: T, ...x } = j;
|
|
2250
|
+
Object.keys(x).length > 0 && Object.assign(w, x);
|
|
2251
2251
|
}
|
|
2252
|
-
Array.isArray(
|
|
2252
|
+
Array.isArray(w.fields) && w.fields.length && S.getState().replaceAll(w);
|
|
2253
2253
|
} catch {
|
|
2254
|
-
|
|
2254
|
+
S.getState().replaceAll({ schemaType: "mieforms-v1.0", fields: [] });
|
|
2255
2255
|
}
|
|
2256
2256
|
h.preview.set(!!o), g.current = !0;
|
|
2257
2257
|
}
|
|
2258
|
-
}, [e, i, o, h,
|
|
2258
|
+
}, [e, i, o, h, S]), l.useEffect(() => {
|
|
2259
2259
|
h.setHideUnsupportedFields(d);
|
|
2260
2260
|
}, [d, h]), l.useEffect(() => {
|
|
2261
|
-
if (!(!r || !
|
|
2262
|
-
return
|
|
2261
|
+
if (!(!r || !S))
|
|
2262
|
+
return S.subscribe((j) => {
|
|
2263
2263
|
r({
|
|
2264
|
-
schemaType:
|
|
2265
|
-
...
|
|
2266
|
-
fields:
|
|
2264
|
+
schemaType: j.schemaType || "mieforms-v1.0",
|
|
2265
|
+
...j.schemaMetadata,
|
|
2266
|
+
fields: j.order.map((k) => j.byId[k])
|
|
2267
2267
|
});
|
|
2268
2268
|
});
|
|
2269
|
-
}, [r,
|
|
2270
|
-
const
|
|
2271
|
-
|
|
2272
|
-
(
|
|
2273
|
-
),
|
|
2274
|
-
return
|
|
2275
|
-
if (m !== "auto") {
|
|
2276
|
-
N(m === "dark");
|
|
2277
|
-
return;
|
|
2278
|
-
}
|
|
2279
|
-
const O = new MutationObserver(() => {
|
|
2280
|
-
const R = document.documentElement.getAttribute("data-theme") === "dark" || document.documentElement.classList.contains("dark") || document.body.classList.contains("dark");
|
|
2281
|
-
N(R);
|
|
2282
|
-
});
|
|
2283
|
-
return O.observe(document.documentElement, { attributes: !0, attributeFilter: ["data-theme", "class"] }), O.observe(document.body, { attributes: !0, attributeFilter: ["class"] }), () => O.disconnect();
|
|
2284
|
-
}, [m]), /* @__PURE__ */ t.jsx("div", { className: `qb-editor-root editor-container mie:w-full mie:max-w-7xl mie:mx-auto mie:bg-miebackground mie:font-titillium ${_ ? "dark" : ""} ${n}`, children: /* @__PURE__ */ t.jsxs(Ct, { children: [
|
|
2269
|
+
}, [r, S]);
|
|
2270
|
+
const q = Ot(
|
|
2271
|
+
S,
|
|
2272
|
+
(j) => h.selectedFieldId.value ? j.byId[h.selectedFieldId.value] : null
|
|
2273
|
+
), _ = m === "dark";
|
|
2274
|
+
return /* @__PURE__ */ t.jsx("div", { className: `qb-editor-root editor-container mie:w-full mie:max-w-7xl mie:mx-auto mie:bg-miebackground mie:font-titillium ${_ ? "dark" : ""} ${n}`, children: /* @__PURE__ */ t.jsxs(Ct, { children: [
|
|
2285
2275
|
s && /* @__PURE__ */ t.jsx(kt, { codeFormat: c, onCodeFormatChange: u }),
|
|
2286
|
-
/* @__PURE__ */ t.jsx(er, { selectedField:
|
|
2276
|
+
/* @__PURE__ */ t.jsx(er, { selectedField: q, codeFormat: c })
|
|
2287
2277
|
] }) });
|
|
2288
2278
|
}
|
|
2289
2279
|
function or(e) {
|