@mieweb/forms-editor 2.1.3 → 2.1.4-prerelease.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.
Files changed (3) hide show
  1. package/README.md +46 -46
  2. package/dist/index.js +134 -133
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -1,46 +1,46 @@
1
- # @mieweb/forms-editor
2
-
3
- Visual questionnaire builder with three editing modes: Build, Code, and Preview.
4
-
5
- ## Installation
6
-
7
- ```bash
8
- npm install @mieweb/forms-editor
9
- ```
10
-
11
- **Requirements:** React 18+ and React DOM 18+
12
-
13
- ## Quick Start
14
-
15
- ```jsx
16
- import { QuestionnaireEditor } from '@mieweb/forms-editor';
17
-
18
- function App() {
19
- const [formData, setFormData] = React.useState({
20
- schemaType: 'mieforms-v1.0',
21
- fields: []
22
- });
23
-
24
- return (
25
- <QuestionnaireEditor
26
- initialFormData={formData}
27
- onChange={setFormData}
28
- />
29
- );
30
- }
31
- ```
32
-
33
- ## Documentation
34
-
35
- **[Full Documentation](https://questionnaire-builder.opensource.mieweb.org/docs/editor/overview)**
36
-
37
- For detailed information, see:
38
- - [Quick Start Guide](https://questionnaire-builder.opensource.mieweb.org/docs/getting-started/quickstart-editor)
39
- - [Props Reference](https://questionnaire-builder.opensource.mieweb.org/docs/editor/props)
40
- - [Editor Modes](https://questionnaire-builder.opensource.mieweb.org/docs/editor/modes)
41
- - [Field Editing](https://questionnaire-builder.opensource.mieweb.org/docs/editor/field-editing)
42
- - [Import/Export](https://questionnaire-builder.opensource.mieweb.org/docs/editor/importing)
43
-
44
- ## License
45
-
46
- MIT
1
+ # @mieweb/forms-editor
2
+
3
+ Visual questionnaire builder with three editing modes: Build, Code, and Preview.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @mieweb/forms-editor
9
+ ```
10
+
11
+ **Requirements:** React 18+ and React DOM 18+
12
+
13
+ ## Quick Start
14
+
15
+ ```jsx
16
+ import { QuestionnaireEditor } from '@mieweb/forms-editor';
17
+
18
+ function App() {
19
+ const [formData, setFormData] = React.useState({
20
+ schemaType: 'mieforms-v1.0',
21
+ fields: []
22
+ });
23
+
24
+ return (
25
+ <QuestionnaireEditor
26
+ initialFormData={formData}
27
+ onChange={setFormData}
28
+ />
29
+ );
30
+ }
31
+ ```
32
+
33
+ ## Documentation
34
+
35
+ **[Full Documentation](https://questionnaire-builder.opensource.mieweb.org/docs/editor/overview)**
36
+
37
+ For detailed information, see:
38
+ - [Quick Start Guide](https://questionnaire-builder.opensource.mieweb.org/docs/getting-started/quickstart-editor)
39
+ - [Props Reference](https://questionnaire-builder.opensource.mieweb.org/docs/editor/props)
40
+ - [Editor Modes](https://questionnaire-builder.opensource.mieweb.org/docs/editor/modes)
41
+ - [Field Editing](https://questionnaire-builder.opensource.mieweb.org/docs/editor/field-editing)
42
+ - [Import/Export](https://questionnaire-builder.opensource.mieweb.org/docs/editor/importing)
43
+
44
+ ## License
45
+
46
+ MIT
package/dist/index.js CHANGED
@@ -10,7 +10,7 @@
10
10
  }
11
11
  window.__QUESTIONNAIRE_EDITOR_CSS_INJECTED = true;
12
12
  })();
13
- import c, { useCallback as ue, useMemo as Ee, memo as Oe, useState as fe, useRef as V, useEffect as J } from "react";
13
+ import m, { useCallback as ue, useMemo as Ee, memo as Oe, useState as fe, useRef as V, useEffect as J } from "react";
14
14
  import { useFormStore as Y, useFormDefinition as Ue, useAlert as ze, useUIApi as B, VEDITOR_ICON as ti, CODE_ICON as ri, PICTURE_ICON as ni, UPLOAD_ICON as oi, DOWNLOAD_ICON as si, parseAndDetect as pe, adaptSchema as he, fieldTypes as X, TOOLS_ICON as ai, X_ICON as li, PAPERCLIP_ICON as mi, MATRIX_ICON as ci, RANKING_ICON as di, SELECTINPUT_ICON as ui, FOLDERS_ICON as fi, TEXTINPUT_ICON as pi, useInstanceId as K, CustomCheckbox as hi, TRASHCANTWO_ICON as oe, useFormApi as Ne, FormStoreContext as Te, ARROWDOWN_ICON as xi, NUMERIC_EXPRESSION_FORMATS as bi, EDIT_ICON as gi, EYEEDIT_ICON as vi, useVisibleFields as yi, useUIStore as ji, getFieldComponent as wi, MIE_FORMS_SCHEMA_TYPE as ye, createFormStore as Ci, createUIStore as Ei, UIStoreContext as Ni, AlertProvider as Oi } from "@mieweb/forms-engine";
15
15
  import ee from "js-yaml";
16
16
  import { useStore as Ti } from "zustand";
@@ -21,8 +21,8 @@ function Ii() {
21
21
  Ie = 1;
22
22
  var e = /* @__PURE__ */ Symbol.for("react.transitional.element"), t = /* @__PURE__ */ Symbol.for("react.fragment");
23
23
  function r(n, o, a) {
24
- var m = null;
25
- if (a !== void 0 && (m = "" + a), o.key !== void 0 && (m = "" + o.key), "key" in o) {
24
+ var c = null;
25
+ if (a !== void 0 && (c = "" + a), o.key !== void 0 && (c = "" + o.key), "key" in o) {
26
26
  a = {};
27
27
  for (var l in o)
28
28
  l !== "key" && (a[l] = o[l]);
@@ -30,7 +30,7 @@ function Ii() {
30
30
  return o = a.ref, {
31
31
  $$typeof: e,
32
32
  type: n,
33
- key: m,
33
+ key: c,
34
34
  ref: o !== void 0 ? o : null,
35
35
  props: a
36
36
  };
@@ -122,7 +122,7 @@ function Si() {
122
122
  function a() {
123
123
  return Error("react-stack-top-frame");
124
124
  }
125
- function m(s) {
125
+ function c(s) {
126
126
  if (f.call(s, "key")) {
127
127
  var C = Object.getOwnPropertyDescriptor(s, "key").get;
128
128
  if (C && C.isReactWarning) return !1;
@@ -211,7 +211,7 @@ React keys must be passed directly to JSX without using spread:
211
211
  U
212
212
  ), z[U + j] = !0);
213
213
  }
214
- if (U = null, $ !== void 0 && (r($), U = "" + $), m(C) && (r(C.key), U = "" + C.key), "key" in C) {
214
+ if (U = null, $ !== void 0 && (r($), U = "" + $), c(C) && (r(C.key), U = "" + C.key), "key" in C) {
215
215
  $ = {};
216
216
  for (var ve in C)
217
217
  ve !== "key" && ($[ve] = C[ve]);
@@ -234,7 +234,7 @@ React keys must be passed directly to JSX without using spread:
234
234
  function N(s) {
235
235
  return typeof s == "object" && s !== null && s.$$typeof === W;
236
236
  }
237
- var M = c, W = /* @__PURE__ */ Symbol.for("react.transitional.element"), F = /* @__PURE__ */ Symbol.for("react.portal"), E = /* @__PURE__ */ Symbol.for("react.fragment"), T = /* @__PURE__ */ Symbol.for("react.strict_mode"), y = /* @__PURE__ */ Symbol.for("react.profiler"), R = /* @__PURE__ */ Symbol.for("react.consumer"), A = /* @__PURE__ */ Symbol.for("react.context"), b = /* @__PURE__ */ Symbol.for("react.forward_ref"), O = /* @__PURE__ */ Symbol.for("react.suspense"), x = /* @__PURE__ */ Symbol.for("react.suspense_list"), q = /* @__PURE__ */ Symbol.for("react.memo"), P = /* @__PURE__ */ Symbol.for("react.lazy"), I = /* @__PURE__ */ Symbol.for("react.activity"), w = /* @__PURE__ */ Symbol.for("react.client.reference"), S = M.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, f = Object.prototype.hasOwnProperty, g = Array.isArray, v = console.createTask ? console.createTask : function() {
237
+ var M = m, W = /* @__PURE__ */ Symbol.for("react.transitional.element"), F = /* @__PURE__ */ Symbol.for("react.portal"), E = /* @__PURE__ */ Symbol.for("react.fragment"), T = /* @__PURE__ */ Symbol.for("react.strict_mode"), y = /* @__PURE__ */ Symbol.for("react.profiler"), R = /* @__PURE__ */ Symbol.for("react.consumer"), A = /* @__PURE__ */ Symbol.for("react.context"), b = /* @__PURE__ */ Symbol.for("react.forward_ref"), O = /* @__PURE__ */ Symbol.for("react.suspense"), x = /* @__PURE__ */ Symbol.for("react.suspense_list"), q = /* @__PURE__ */ Symbol.for("react.memo"), P = /* @__PURE__ */ Symbol.for("react.lazy"), I = /* @__PURE__ */ Symbol.for("react.activity"), w = /* @__PURE__ */ Symbol.for("react.client.reference"), S = M.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, f = Object.prototype.hasOwnProperty, g = Array.isArray, v = console.createTask ? console.createTask : function() {
238
238
  return null;
239
239
  };
240
240
  M = {
@@ -275,11 +275,11 @@ function ki() {
275
275
  }
276
276
  var i = ki();
277
277
  function Ri() {
278
- const [e, t] = c.useState(!1), [r, n] = c.useState(null), o = Y((y) => y.replaceAll), a = Ue(), { showAlert: m } = ze(), l = B(), d = l.state.isPreview, u = l.state.isCodeEditor ?? !1, p = l.state.codeEditorHasError ?? !1, h = (y) => {
278
+ const [e, t] = m.useState(!1), [r, n] = m.useState(null), o = Y((y) => y.replaceAll), a = Ue(), { showAlert: c } = ze(), l = B(), d = l.state.isPreview, u = l.state.isCodeEditor ?? !1, p = l.state.codeEditorHasError ?? !1, h = (y) => {
279
279
  try {
280
280
  const R = String(y).replace(/^\uFEFF/, "").trim(), { data: A, schemaType: b } = pe(R);
281
281
  if (b !== "mieforms" && b !== "surveyjs") {
282
- m(
282
+ c(
283
283
  `Expected: MIE Forms or SurveyJS
284
284
  Detected: ${b}`,
285
285
  { title: "Unsupported Schema Format" }
@@ -288,7 +288,7 @@ Detected: ${b}`,
288
288
  }
289
289
  n({ data: A, detectedSchemaType: b }), t(!0);
290
290
  } catch (R) {
291
- m(
291
+ c(
292
292
  R?.message || "Invalid file format",
293
293
  { title: "Failed to Parse File" }
294
294
  );
@@ -311,7 +311,7 @@ Detected: ${b}`,
311
311
  }
312
312
  if (o(O), l.selectedFieldId.clear(), l.preview.set(!1), y === "surveyjs" && A.conversionReport) {
313
313
  const x = A.conversionReport, q = x.unsupportedFields?.length || 0;
314
- m(
314
+ c(
315
315
  `Format: SurveyJS → MIE Forms
316
316
 
317
317
  Converted: ${x.convertedFields || 0} field(s)
@@ -319,14 +319,14 @@ Unsupported: ${q} field(s)${q > 0 ? " ⚠️" : ""}`,
319
319
  { title: "✅ Import Successful" }
320
320
  );
321
321
  } else
322
- m(
322
+ c(
323
323
  `Format: ${y === "surveyjs" ? "SurveyJS" : "MIE Forms"}
324
324
  Loaded ${b.length} field(s)`,
325
325
  { title: "✅ Import Successful" }
326
326
  );
327
327
  t(!1), n(null);
328
328
  } catch (R) {
329
- m(
329
+ c(
330
330
  R?.message || "Invalid format",
331
331
  { title: "Import Failed" }
332
332
  ), t(!1), n(null);
@@ -467,21 +467,20 @@ const Ai = (e) => {
467
467
  return null;
468
468
  }
469
469
  }, $i = ({ isPreview: e = !1 }) => {
470
- if (e) return null;
471
470
  const t = Y((u) => u.addField), r = B(), n = Y(
472
471
  ue(
473
472
  (u) => r.selectedFieldId.value ? u.byId[r.selectedFieldId.value] : null,
474
473
  [r.selectedFieldId.value]
475
474
  )
476
- ), o = n?.fieldType === "section", a = n?.title || "Section", m = c.useCallback(() => {
475
+ ), o = n?.fieldType === "section", a = n?.title || "Section", c = m.useCallback(() => {
477
476
  r.selectedFieldId.set(null);
478
477
  }, [r.selectedFieldId]);
479
- c.useEffect(() => {
478
+ m.useEffect(() => {
480
479
  const u = (p) => {
481
- p.key === "Escape" && (p.preventDefault(), p.stopPropagation(), m());
480
+ p.key === "Escape" && (p.preventDefault(), p.stopPropagation(), c());
482
481
  };
483
482
  return window.addEventListener("keydown", u), () => window.removeEventListener("keydown", u);
484
- }, [m]);
483
+ }, [c]);
485
484
  const l = Ee(() => {
486
485
  const u = {};
487
486
  return Object.entries(X).filter(([p]) => p !== "unsupported").forEach(([p, h]) => {
@@ -501,7 +500,7 @@ const Ai = (e) => {
501
500
  });
502
501
  }), u;
503
502
  }, [l, t, o, n?.id]);
504
- return /* @__PURE__ */ i.jsx(
503
+ return e ? null : /* @__PURE__ */ i.jsx(
505
504
  "div",
506
505
  {
507
506
  className: " mie:border mie:border-mieborder mie:rounded-lg mie:bg-miesurface mie:overflow-y-auto mie:custom-scrollbar mie:max-h-[calc(100svh-24rem)] mie:lg:max-h-[calc(100dvh-20rem)]",
@@ -515,7 +514,7 @@ const Ai = (e) => {
515
514
  o && /* @__PURE__ */ i.jsx(
516
515
  "button",
517
516
  {
518
- onClick: m,
517
+ onClick: c,
519
518
  className: "mie:bg-transparent mie:text-mietextmuted mie:hover:text-miedanger mie:hover:bg-miedanger/10 mie:p-1 mie:rounded mie:transition-colors mie:shrink-0",
520
519
  title: "Unselect section",
521
520
  children: /* @__PURE__ */ i.jsx(li, { className: "mie:w-5 mie:h-5" })
@@ -551,7 +550,7 @@ const Ai = (e) => {
551
550
  ] })
552
551
  }
553
552
  );
554
- }, Re = c.memo($i, (e, t) => e.isPreview === t.isPreview);
553
+ }, Re = m.memo($i, (e, t) => e.isPreview === t.isPreview);
555
554
  function Ve({
556
555
  id: e = "",
557
556
  label: t = "ID",
@@ -560,11 +559,11 @@ function Ve({
560
559
  placeholder: o = "Enter unique ID…",
561
560
  className: a = ""
562
561
  }) {
563
- const m = K(), [l, d] = c.useState(e ?? ""), [u, p] = c.useState("");
564
- c.useEffect(() => {
562
+ const c = K(), [l, d] = m.useState(e ?? ""), [u, p] = m.useState("");
563
+ m.useEffect(() => {
565
564
  d(e ?? ""), p("");
566
565
  }, [e]);
567
- const h = c.useCallback(() => {
566
+ const h = m.useCallback(() => {
568
567
  const N = String(l ?? "").trim();
569
568
  if (!N) {
570
569
  p("ID cannot be empty."), d(e ?? "");
@@ -582,11 +581,11 @@ function Ve({
582
581
  }
583
582
  }, [l, e, r, n]);
584
583
  return /* @__PURE__ */ i.jsxs("div", { className: a ? `draft-id-editor-container ${a}` : "draft-id-editor-container", children: [
585
- /* @__PURE__ */ i.jsx("label", { htmlFor: `${m}-editor-field-id-${e}`, className: "mie:block mie:text-sm mie:text-mietext mie:mb-1", children: t }),
584
+ /* @__PURE__ */ i.jsx("label", { htmlFor: `${c}-editor-field-id-${e}`, className: "mie:block mie:text-sm mie:text-mietext mie:mb-1", children: t }),
586
585
  /* @__PURE__ */ i.jsx(
587
586
  "input",
588
587
  {
589
- id: `${m}-editor-field-id-${e}`,
588
+ id: `${c}-editor-field-id-${e}`,
590
589
  "aria-label": t,
591
590
  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 mie:outline-none mie:transition-colors",
592
591
  value: l,
@@ -663,8 +662,8 @@ function Mi({ field: e, onUpdate: t }) {
663
662
  "aria-label": "Input Type",
664
663
  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 mie:outline-none mie:cursor-pointer mie:transition-colors",
665
664
  value: n,
666
- onChange: (m) => t("inputType", m.target.value),
667
- children: Fi.map((m) => /* @__PURE__ */ i.jsx("option", { value: m.value, children: m.label }, m.value))
665
+ onChange: (c) => t("inputType", c.target.value),
666
+ children: Fi.map((c) => /* @__PURE__ */ i.jsx("option", { value: c.value, children: c.label }, c.value))
668
667
  }
669
668
  )
670
669
  ] }),
@@ -677,10 +676,10 @@ function Mi({ field: e, onUpdate: t }) {
677
676
  "aria-label": "Unit (optional)",
678
677
  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 mie:outline-none mie:cursor-pointer mie:transition-colors",
679
678
  value: o,
680
- onChange: (m) => t("unit", m.target.value),
679
+ onChange: (c) => t("unit", c.target.value),
681
680
  children: [
682
681
  /* @__PURE__ */ i.jsx("option", { value: "", children: "None" }),
683
- Object.entries(Pi).map(([m, l]) => /* @__PURE__ */ i.jsx("optgroup", { label: m, children: l.map((d) => /* @__PURE__ */ i.jsx("option", { value: d.value, children: d.label }, d.value)) }, m))
682
+ Object.entries(Pi).map(([c, l]) => /* @__PURE__ */ i.jsx("optgroup", { label: c, children: l.map((d) => /* @__PURE__ */ i.jsx("option", { value: d.value, children: d.label }, d.value)) }, c))
684
683
  ]
685
684
  }
686
685
  )
@@ -688,9 +687,9 @@ function Mi({ field: e, onUpdate: t }) {
688
687
  ] });
689
688
  }
690
689
  function We({ f: e, onUpdateField: t }) {
691
- const r = K(), n = Y(c.useCallback((a) => a.byId, [])), o = c.useCallback((a, m) => {
690
+ const r = K(), n = Y(m.useCallback((a) => a.byId, [])), o = m.useCallback((a, c) => {
692
691
  if (!a?.trim()) return "ID cannot be empty.";
693
- if (a === m) return "";
692
+ if (a === c) return "";
694
693
  const l = new Set(Object.keys(n));
695
694
  return Object.values(n).forEach((d) => {
696
695
  d?.fieldType === "section" && Array.isArray(d.fields) && d.fields.forEach((u) => l.add(u.id));
@@ -749,16 +748,16 @@ function We({ f: e, onUpdateField: t }) {
749
748
  ] });
750
749
  }
751
750
  function He({ field: e, api: t }) {
752
- const r = K(), n = e.options || [], o = e.fieldType === "boolean", a = e.fieldType === "multitext", m = c.useRef(null), l = c.useRef(n.length), d = a ? "Text Inputs" : "Options", u = a ? "Text Input" : "Option", p = a ? "Input label" : "Option text";
753
- return c.useEffect(() => {
754
- if (n.length > l.current && m.current) {
755
- const h = m.current.lastElementChild;
751
+ const r = K(), n = e.options || [], o = e.fieldType === "boolean", a = e.fieldType === "multitext", c = m.useRef(null), l = m.useRef(n.length), d = a ? "Text Inputs" : "Options", u = a ? "Text Input" : "Option", p = a ? "Input label" : "Option text";
752
+ return m.useEffect(() => {
753
+ if (n.length > l.current && c.current) {
754
+ const h = c.current.lastElementChild;
756
755
  h && h.scrollIntoView({ behavior: "smooth", block: "nearest" });
757
756
  }
758
757
  l.current = n.length;
759
758
  }, [n.length]), /* @__PURE__ */ i.jsxs("div", { className: "mie:space-y-3", children: [
760
759
  /* @__PURE__ */ i.jsx("span", { className: "mie:block mie:text-sm mie:font-medium mie:text-mietext", children: d }),
761
- /* @__PURE__ */ i.jsx("div", { ref: m, className: "mie:space-y-2", children: n.map((h) => /* @__PURE__ */ i.jsxs("div", { className: "mie:flex mie:items-center mie:gap-2 mie:px-3 mie:py-2 mie:border mie:border-mieborder mie:rounded-lg mie:shadow-sm mie:hover:border-mieprimary/50 mie:transition-colors", children: [
760
+ /* @__PURE__ */ i.jsx("div", { ref: c, className: "mie:space-y-2", children: n.map((h) => /* @__PURE__ */ i.jsxs("div", { className: "mie:flex mie:items-center mie:gap-2 mie:px-3 mie:py-2 mie:border mie:border-mieborder mie:rounded-lg mie:shadow-sm mie:hover:border-mieprimary/50 mie:transition-colors", children: [
762
761
  /* @__PURE__ */ i.jsx(
763
762
  "input",
764
763
  {
@@ -794,16 +793,16 @@ function He({ field: e, api: t }) {
794
793
  ] });
795
794
  }
796
795
  function Ye({ field: e, api: t }) {
797
- const r = K(), n = e.rows || [], o = e.columns || [], a = c.useRef(null), m = c.useRef(null), l = c.useRef(n.length), d = c.useRef(o.length);
798
- return c.useEffect(() => {
796
+ const r = K(), n = e.rows || [], o = e.columns || [], a = m.useRef(null), c = m.useRef(null), l = m.useRef(n.length), d = m.useRef(o.length);
797
+ return m.useEffect(() => {
799
798
  if (n.length > l.current && a.current) {
800
799
  const u = a.current.lastElementChild;
801
800
  u && u.scrollIntoView({ behavior: "smooth", block: "nearest" });
802
801
  }
803
802
  l.current = n.length;
804
- }, [n.length]), c.useEffect(() => {
805
- if (o.length > d.current && m.current) {
806
- const u = m.current.lastElementChild;
803
+ }, [n.length]), m.useEffect(() => {
804
+ if (o.length > d.current && c.current) {
805
+ const u = c.current.lastElementChild;
807
806
  u && u.scrollIntoView({ behavior: "smooth", block: "nearest" });
808
807
  }
809
808
  d.current = o.length;
@@ -843,7 +842,7 @@ function Ye({ field: e, api: t }) {
843
842
  ] }),
844
843
  /* @__PURE__ */ i.jsxs("div", { className: "mie:space-y-3", children: [
845
844
  /* @__PURE__ */ i.jsx("span", { className: "mie:block mie:text-sm mie:font-medium mie:text-mietext", children: "Columns" }),
846
- /* @__PURE__ */ i.jsx("div", { ref: m, className: "mie:space-y-2", children: o.map((u) => /* @__PURE__ */ i.jsxs("div", { className: "mie:flex mie:items-center mie:gap-2 mie:px-3 mie:py-2 mie:border mie:border-mieborder mie:rounded-lg mie:shadow-sm mie:hover:border-mieprimary/50 mie:transition-colors", children: [
845
+ /* @__PURE__ */ i.jsx("div", { ref: c, className: "mie:space-y-2", children: o.map((u) => /* @__PURE__ */ i.jsxs("div", { className: "mie:flex mie:items-center mie:gap-2 mie:px-3 mie:py-2 mie:border mie:border-mieborder mie:rounded-lg mie:shadow-sm mie:hover:border-mieprimary/50 mie:transition-colors", children: [
847
846
  /* @__PURE__ */ i.jsx(
848
847
  "input",
849
848
  {
@@ -877,10 +876,10 @@ function Ye({ field: e, api: t }) {
877
876
  ] });
878
877
  }
879
878
  function _i({ f: e }) {
880
- const t = K(), r = Ne(e.id), n = c.useCallback(
879
+ const t = K(), r = Ne(e.id), n = m.useCallback(
881
880
  (l, d) => r.field.update(l, d),
882
881
  [r]
883
- ), o = X[e.fieldType] || {}, a = o.hasOptions || !1, m = o.hasMatrix || !1;
882
+ ), o = X[e.fieldType] || {}, a = o.hasOptions || !1, c = o.hasMatrix || !1;
884
883
  return /* @__PURE__ */ i.jsxs(i.Fragment, { children: [
885
884
  /* @__PURE__ */ i.jsx(We, { f: e, onUpdateField: n }),
886
885
  e.fieldType === "input" && /* @__PURE__ */ i.jsxs("div", { className: "non-section-editor-default-answer mie:mt-4", children: [
@@ -898,36 +897,39 @@ function _i({ f: e }) {
898
897
  )
899
898
  ] }),
900
899
  a && /* @__PURE__ */ i.jsx(He, { field: e, api: r }),
901
- m && /* @__PURE__ */ i.jsx(Ye, { field: e, api: r })
900
+ c && /* @__PURE__ */ i.jsx(Ye, { field: e, api: r })
902
901
  ] });
903
902
  }
904
903
  function Di({ section: e, onActiveChildChange: t }) {
905
- const r = K(), n = Ne(e.id), o = c.useContext(Te), a = B();
904
+ const r = K(), n = Ne(e.id), o = m.useContext(Te), a = B();
906
905
  if (!o) throw new Error("Missing FormStoreContext.Provider in the tree");
907
- const m = Array.isArray(e.fields) ? e.fields : [], l = a.selectedChildId.ParentId, d = a.selectedChildId.ChildId, u = c.useMemo(() => l === e.id && d && m.some((x) => x.id === d) ? d : m[0]?.id || null, []), [p, h] = c.useState(u), N = c.useRef(d);
908
- c.useEffect(() => {
906
+ const c = m.useMemo(
907
+ () => Array.isArray(e.fields) ? e.fields : [],
908
+ [e.fields]
909
+ ), l = a.selectedChildId.ParentId, d = a.selectedChildId.ChildId, u = m.useMemo(() => l === e.id && d && c.some((x) => x.id === d) ? d : c[0]?.id || null, []), [p, h] = m.useState(u), N = m.useRef(d);
910
+ m.useEffect(() => {
909
911
  N.current !== d && (N.current = d, l === e.id && d && d !== p && h(d));
910
- }, [l, d, e.id, p]), c.useEffect(() => {
911
- if (!m.length) {
912
+ }, [l, d, e.id, p]), m.useEffect(() => {
913
+ if (!c.length) {
912
914
  p !== null && h(null);
913
915
  return;
914
916
  }
915
- m.some((q) => q.id === p) || h(m[0].id);
916
- }, [m, p]), c.useEffect(() => {
917
+ c.some((q) => q.id === p) || h(c[0].id);
918
+ }, [c, p]), m.useEffect(() => {
917
919
  t?.(e.id, p || null);
918
920
  }, [e.id, p, t]);
919
- const M = c.useCallback(
921
+ const M = m.useCallback(
920
922
  (x) => {
921
923
  h(x), a.selectedChildId.set(e.id, x);
922
924
  },
923
925
  [e.id, a.selectedChildId]
924
- ), W = c.useCallback((x) => x.question?.trim() || X[x.fieldType]?.label || "Untitled", []), F = c.useCallback(
926
+ ), W = m.useCallback((x) => x.question?.trim() || X[x.fieldType]?.label || "Untitled", []), F = m.useCallback(
925
927
  (x, q) => n.field.update(x, q),
926
928
  [n]
927
- ), E = c.useMemo(
928
- () => m.find((x) => x.id === p) || null,
929
- [m, p]
930
- ), T = Ne(E?.id || "", e.id), y = E && T ? T : null, R = c.useCallback(
929
+ ), E = m.useMemo(
930
+ () => c.find((x) => x.id === p) || null,
931
+ [c, p]
932
+ ), T = Ne(E?.id || "", e.id), y = E && T ? T : null, R = m.useCallback(
931
933
  (x, q) => {
932
934
  if (E) {
933
935
  if (x === "id") {
@@ -953,12 +955,12 @@ function Di({ section: e, onActiveChildChange: t }) {
953
955
  }
954
956
  },
955
957
  [E, e.id, o]
956
- ), A = c.useCallback(() => {
958
+ ), A = m.useCallback(() => {
957
959
  E && o.getState().deleteField(E.id, { sectionId: e.id });
958
- }, [E, e.id, o]), b = c.useMemo(
960
+ }, [E, e.id, o]), b = m.useMemo(
959
961
  () => E && (X[E.fieldType] || {}).hasOptions || !1,
960
962
  [E]
961
- ), O = c.useMemo(
963
+ ), O = m.useMemo(
962
964
  () => E && (X[E.fieldType] || {}).hasMatrix || !1,
963
965
  [E]
964
966
  );
@@ -990,10 +992,10 @@ function Di({ section: e, onActiveChildChange: t }) {
990
992
  /* @__PURE__ */ i.jsxs("div", { className: "mie:space-y-3", children: [
991
993
  /* @__PURE__ */ i.jsxs("h3", { className: "mie:text-sm mie:font-semibold mie:text-mietext mie:uppercase mie:tracking-wide", children: [
992
994
  "Fields (",
993
- m.length,
995
+ c.length,
994
996
  ")"
995
997
  ] }),
996
- m.length === 0 ? /* @__PURE__ */ i.jsxs("div", { className: "mie:flex mie:flex-col mie:items-center mie:justify-center mie:p-6 mie:bg-miebackground mie:border-2 mie:border-dashed mie:border-mieborder mie:rounded-lg mie:text-center", children: [
998
+ c.length === 0 ? /* @__PURE__ */ i.jsxs("div", { className: "mie:flex mie:flex-col mie:items-center mie:justify-center mie:p-6 mie:bg-miebackground mie:border-2 mie:border-dashed mie:border-mieborder mie:rounded-lg mie:text-center", children: [
997
999
  /* @__PURE__ */ i.jsx("p", { className: "mie:text-sm mie:text-mietextmuted", children: "No fields in this section" }),
998
1000
  /* @__PURE__ */ i.jsx("p", { className: "mie:text-xs mie:text-mietextmuted/70 mie:mt-1", children: "Use the Tool Panel to add fields" })
999
1001
  ] }) : /* @__PURE__ */ i.jsxs(i.Fragment, { children: [
@@ -1006,7 +1008,7 @@ function Di({ section: e, onActiveChildChange: t }) {
1006
1008
  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",
1007
1009
  value: p || "",
1008
1010
  onChange: (x) => M(x.target.value),
1009
- children: m.map((x) => /* @__PURE__ */ i.jsxs("option", { value: x.id, children: [
1011
+ children: c.map((x) => /* @__PURE__ */ i.jsxs("option", { value: x.id, children: [
1010
1012
  W(x),
1011
1013
  " — ",
1012
1014
  X[x.fieldType]?.label
@@ -1125,18 +1127,18 @@ function $e(e) {
1125
1127
  function Ui() {
1126
1128
  const e = B(), t = Y((f) => f.byId), r = Y((f) => f.setEnableWhen), n = Y((f) => f.updateField), o = e?.selectedFieldId?.value ?? null;
1127
1129
  e?.selectedChildId?.ParentId;
1128
- const a = e?.selectedChildId?.ChildId ?? null, m = o ? t[o] : null, l = K(), d = m?.fieldType === "section", u = c.useMemo(() => d ? Array.isArray(m?.fields) ? m.fields : [] : [], [d, m]), p = c.useMemo(() => !d || !a ? !1 : u.some((f) => f.id === a), [d, a, u]), h = c.useMemo(() => d && p ? `child:${a}` : "", [d, p, a]), [N, M] = c.useState(h);
1129
- c.useEffect(() => {
1130
+ const a = e?.selectedChildId?.ChildId ?? null, c = o ? t[o] : null, l = K(), d = c?.fieldType === "section", u = m.useMemo(() => d ? Array.isArray(c?.fields) ? c.fields : [] : [], [d, c]), p = m.useMemo(() => !d || !a ? !1 : u.some((f) => f.id === a), [d, a, u]), h = m.useMemo(() => d && p ? `child:${a}` : "", [d, p, a]), [N, M] = m.useState(h);
1131
+ m.useEffect(() => {
1130
1132
  M(h);
1131
1133
  }, [h]);
1132
- const W = c.useCallback((f) => {
1134
+ const W = m.useCallback((f) => {
1133
1135
  if (M(f), !!d)
1134
1136
  if (f && f.startsWith("child:")) {
1135
1137
  const g = f.slice(6);
1136
1138
  e.selectedChildId.set(o, g);
1137
1139
  } else
1138
1140
  e.selectedChildId.set(null, null);
1139
- }, [d, o, e]), F = !!(d && N && N.startsWith("child:")), E = F ? N.slice(6) : null, T = F ? E : o, y = c.useMemo(() => T ? F ? u.find((f) => f.id === E) ?? null : t[T] ?? null : null, [t, T, F, E, u]), R = c.useMemo(() => {
1141
+ }, [d, o, e]), F = !!(d && N && N.startsWith("child:")), E = F ? N.slice(6) : null, T = F ? E : o, y = m.useMemo(() => T ? F ? u.find((f) => f.id === E) ?? null : t[T] ?? null : null, [t, T, F, E, u]), R = m.useMemo(() => {
1140
1142
  const f = [];
1141
1143
  for (const g of Object.values(t))
1142
1144
  if (g)
@@ -1162,17 +1164,17 @@ function Ui() {
1162
1164
  options: Array.isArray(g.options) ? g.options : []
1163
1165
  });
1164
1166
  return f;
1165
- }, [t]), A = c.useCallback(
1167
+ }, [t]), A = m.useCallback(
1166
1168
  (f) => R.find((g) => g.id === f) || null,
1167
1169
  [R]
1168
- ), b = c.useCallback(
1170
+ ), b = m.useCallback(
1169
1171
  (f) => {
1170
1172
  if (!T) return;
1171
1173
  const g = f && Array.isArray(f.conditions) ? { logic: f.logic || "AND", conditions: f.conditions } : void 0;
1172
1174
  F && o ? n(T, { enableWhen: g }, { sectionId: o }) : r(T, g);
1173
1175
  },
1174
1176
  [T, F, o, r, n]
1175
- ), O = c.useMemo(() => y?.enableWhen && Array.isArray(y.enableWhen.conditions) ? { logic: y.enableWhen.logic || "AND", conditions: y.enableWhen.conditions } : { logic: "AND", conditions: [] }, [y]), x = c.useCallback(() => {
1177
+ ), O = m.useMemo(() => y?.enableWhen && Array.isArray(y.enableWhen.conditions) ? { logic: y.enableWhen.logic || "AND", conditions: y.enableWhen.conditions } : { logic: "AND", conditions: [] }, [y]), x = m.useCallback(() => {
1176
1178
  const f = {
1177
1179
  logic: O.logic || "AND",
1178
1180
  conditions: [
@@ -1181,13 +1183,13 @@ function Ui() {
1181
1183
  ]
1182
1184
  };
1183
1185
  b(f);
1184
- }, [O, b]), q = c.useCallback(() => b(null), [b]), P = c.useCallback(
1186
+ }, [O, b]), q = m.useCallback(() => b(null), [b]), P = m.useCallback(
1185
1187
  (f) => {
1186
1188
  const v = (Array.isArray(O.conditions) ? O.conditions : []).filter((k, _) => _ !== f);
1187
1189
  b({ ...O, conditions: v });
1188
1190
  },
1189
1191
  [O, b]
1190
- ), I = c.useCallback(
1192
+ ), I = m.useCallback(
1191
1193
  (f, g) => {
1192
1194
  const k = [...Array.isArray(O.conditions) ? O.conditions : []], D = { ...k[f] || { targetId: "", operator: "equals", value: "" }, ...g };
1193
1195
  if ("targetId" in g) {
@@ -1199,7 +1201,7 @@ function Ui() {
1199
1201
  k[f] = D, b({ ...O, conditions: k });
1200
1202
  },
1201
1203
  [O, A, b]
1202
- ), w = c.useMemo(
1204
+ ), w = m.useMemo(
1203
1205
  () => R.filter((f) => f.id !== T),
1204
1206
  [R, T]
1205
1207
  ), S = !y || !T;
@@ -1388,20 +1390,21 @@ function Ui() {
1388
1390
  }
1389
1391
  function Fe({ isMobileModal: e = !1 }) {
1390
1392
  const t = B(), r = Y(
1391
- c.useCallback(
1393
+ m.useCallback(
1392
1394
  (d) => t.selectedFieldId.value ? d.byId[t.selectedFieldId.value] : null,
1393
1395
  [t.selectedFieldId.value]
1394
1396
  )
1395
- ), [n, o] = c.useState("EDIT"), a = c.useCallback(
1397
+ ), [n, o] = m.useState("EDIT"), a = m.useCallback(
1396
1398
  (d, u) => {
1397
1399
  t.selectedChildId.set(d, u);
1398
1400
  },
1401
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- .set is stable
1399
1402
  [t.selectedChildId.set]
1400
1403
  );
1401
- if (c.useEffect(() => {
1404
+ if (m.useEffect(() => {
1402
1405
  t.selectedChildId.set(null, null), o("EDIT");
1403
1406
  }, [t.selectedFieldId.value]), t.state.isPreview) return null;
1404
- const m = !r, l = r?.fieldType === "section";
1407
+ const c = !r, l = r?.fieldType === "section";
1405
1408
  return /* @__PURE__ */ i.jsxs(
1406
1409
  "div",
1407
1410
  {
@@ -1434,8 +1437,8 @@ function Fe({ isMobileModal: e = !1 }) {
1434
1437
  )
1435
1438
  ] }) }),
1436
1439
  /* @__PURE__ */ i.jsxs("div", { className: "mie:p-4", children: [
1437
- m && /* @__PURE__ */ i.jsx("div", { className: "edit-panel-empty mie:text-mietextmuted", children: /* @__PURE__ */ i.jsx("p", { children: "Select a field in the center panel to edit its properties." }) }),
1438
- !m && n === "EDIT" && /* @__PURE__ */ i.jsxs(i.Fragment, { children: [
1440
+ c && /* @__PURE__ */ i.jsx("div", { className: "edit-panel-empty mie:text-mietextmuted", children: /* @__PURE__ */ i.jsx("p", { children: "Select a field in the center panel to edit its properties." }) }),
1441
+ !c && n === "EDIT" && /* @__PURE__ */ i.jsxs(i.Fragment, { children: [
1439
1442
  !l && /* @__PURE__ */ i.jsx(_i, { f: r }),
1440
1443
  l && /* @__PURE__ */ i.jsx(
1441
1444
  Di,
@@ -1445,15 +1448,15 @@ function Fe({ isMobileModal: e = !1 }) {
1445
1448
  }
1446
1449
  )
1447
1450
  ] }),
1448
- !m && n === "LOGIC" && /* @__PURE__ */ i.jsx(Ui, {})
1451
+ !c && n === "LOGIC" && /* @__PURE__ */ i.jsx(Ui, {})
1449
1452
  ] })
1450
1453
  ]
1451
1454
  }
1452
1455
  );
1453
1456
  }
1454
1457
  function zi() {
1455
- const e = B(), { fields: t } = yi(e.state.isPreview), r = ji((l) => l.hideUnsupportedFields), n = Y((l) => l.order), o = c.useRef(null), a = c.useRef(0), m = Ee(() => (r ? t.filter((d) => d.fieldType !== "unsupported") : t).map((d) => d.id), [t, r]);
1456
- return c.useEffect(() => {
1458
+ const e = B(), { fields: t } = yi(e.state.isPreview), r = ji((l) => l.hideUnsupportedFields), n = Y((l) => l.order), o = m.useRef(null), a = m.useRef(0), c = Ee(() => (r ? t.filter((d) => d.fieldType !== "unsupported") : t).map((d) => d.id), [t, r]);
1459
+ return m.useEffect(() => {
1457
1460
  if (!e.state.isPreview) {
1458
1461
  if (n.length > a.current) {
1459
1462
  const l = n[n.length - 1], d = o.current?.querySelector(`[data-field-id="${l}"]`);
@@ -1469,15 +1472,13 @@ function zi() {
1469
1472
  ${e.state.isPreview ? "mie:max-w-4xl" : "mie:max-w-xl"}
1470
1473
  mie:mx-auto mie:rounded-lg mie:overflow-y-auto mie:max-h-[calc(100svh-13rem)] mie:lg:max-h-[calc(100dvh-11rem)] mie:custom-scrollbar mie:lg:pr-2`,
1471
1474
  onClick: () => !e.state.isPreview && e.selectedFieldId.clear(),
1472
- children: m.length === 0 ? /* @__PURE__ */ i.jsx(Wi, {}) : m.map((l) => /* @__PURE__ */ i.jsx(Vi, { id: l }, l))
1475
+ children: c.length === 0 ? /* @__PURE__ */ i.jsx(Wi, {}) : c.map((l) => /* @__PURE__ */ i.jsx(Vi, { id: l }, l))
1473
1476
  }
1474
1477
  );
1475
1478
  }
1476
- const Vi = c.memo(function({ id: t }) {
1477
- const r = Y(c.useCallback((o) => o.byId[t], [t]));
1478
- if (!r) return null;
1479
- const n = wi(r.fieldType);
1480
- return n ? /* @__PURE__ */ i.jsx("div", { className: "mie:mb-1.5", "data-field-type": r.fieldType, "data-field-id": r.id, children: /* @__PURE__ */ i.jsx(n, { field: r }) }) : null;
1479
+ const Vi = m.memo(function({ id: t }) {
1480
+ const r = Y(m.useCallback((o) => o.byId[t], [t])), n = r ? wi(r.fieldType) : null;
1481
+ return !r || !n ? null : /* @__PURE__ */ i.jsx("div", { className: "mie:mb-1.5", "data-field-type": r.fieldType, "data-field-id": r.id, children: /* @__PURE__ */ i.jsx(n, { field: r }) });
1481
1482
  });
1482
1483
  function Wi() {
1483
1484
  return /* @__PURE__ */ i.jsxs(
@@ -1525,14 +1526,14 @@ function Yi(e, t, r) {
1525
1526
  function Ji(e, t) {
1526
1527
  var r = e == null ? null : typeof Symbol < "u" && e[Symbol.iterator] || e["@@iterator"];
1527
1528
  if (r != null) {
1528
- var n, o, a, m, l = [], d = !0, u = !1;
1529
+ var n, o, a, c, l = [], d = !0, u = !1;
1529
1530
  try {
1530
1531
  if (a = (r = r.call(e)).next, t !== 0) for (; !(d = (n = a.call(r)).done) && (l.push(n.value), l.length !== t); d = !0) ;
1531
1532
  } catch (p) {
1532
1533
  u = !0, o = p;
1533
1534
  } finally {
1534
1535
  try {
1535
- if (!d && r.return != null && (m = r.return(), Object(m) !== m)) return;
1536
+ if (!d && r.return != null && (c = r.return(), Object(c) !== c)) return;
1536
1537
  } finally {
1537
1538
  if (u) throw o;
1538
1539
  }
@@ -1650,7 +1651,7 @@ function re(e) {
1650
1651
  for (var r = this, n = arguments.length, o = new Array(n), a = 0; a < n; a++)
1651
1652
  o[a] = arguments[a];
1652
1653
  return o.length >= e.length ? e.apply(this, o) : function() {
1653
- for (var m = arguments.length, l = new Array(m), d = 0; d < m; d++)
1654
+ for (var c = arguments.length, l = new Array(c), d = 0; d < c; d++)
1654
1655
  l[d] = arguments[d];
1655
1656
  return t.apply(r, [].concat(o, l));
1656
1657
  };
@@ -1708,7 +1709,7 @@ function dt(e) {
1708
1709
  ce.initial(e), ce.handler(t);
1709
1710
  var r = {
1710
1711
  current: e
1711
- }, n = re(pt)(r, t), o = re(ft)(r), a = re(ce.changes)(e), m = re(ut)(r);
1712
+ }, n = re(pt)(r, t), o = re(ft)(r), a = re(ce.changes)(e), c = re(ut)(r);
1712
1713
  function l() {
1713
1714
  var u = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : function(p) {
1714
1715
  return p;
@@ -1716,7 +1717,7 @@ function dt(e) {
1716
1717
  return ce.selector(u), u(r.current);
1717
1718
  }
1718
1719
  function d(u) {
1719
- tt(n, o, a, m)(u);
1720
+ tt(n, o, a, c)(u);
1720
1721
  }
1721
1722
  return [l, d];
1722
1723
  }
@@ -1744,7 +1745,7 @@ function bt(e) {
1744
1745
  for (var r = this, n = arguments.length, o = new Array(n), a = 0; a < n; a++)
1745
1746
  o[a] = arguments[a];
1746
1747
  return o.length >= e.length ? e.apply(this, o) : function() {
1747
- for (var m = arguments.length, l = new Array(m), d = 0; d < m; d++)
1748
+ for (var c = arguments.length, l = new Array(c), d = 0; d < c; d++)
1748
1749
  l[d] = arguments[d];
1749
1750
  return t.apply(r, [].concat(o, l));
1750
1751
  };
@@ -1786,8 +1787,8 @@ var Je = {
1786
1787
  for (var t = arguments.length, r = new Array(t), n = 0; n < t; n++)
1787
1788
  r[n] = arguments[n];
1788
1789
  return function(o) {
1789
- return r.reduceRight(function(a, m) {
1790
- return m(a);
1790
+ return r.reduceRight(function(a, c) {
1791
+ return c(a);
1791
1792
  }, o);
1792
1793
  };
1793
1794
  };
@@ -1903,11 +1904,11 @@ var we = new Promise(function(e, t) {
1903
1904
  __getMonacoInstance: $t
1904
1905
  }, Ft = { wrapper: { display: "flex", position: "relative", textAlign: "initial" }, fullWidth: { width: "100%" }, hide: { display: "none" } }, Ce = Ft, Pt = { container: { display: "flex", height: "100%", width: "100%", justifyContent: "center", alignItems: "center" } }, Mt = Pt;
1905
1906
  function _t({ children: e }) {
1906
- return c.createElement("div", { style: Mt.container }, e);
1907
+ return m.createElement("div", { style: Mt.container }, e);
1907
1908
  }
1908
1909
  var Dt = _t, qt = Dt;
1909
- function Lt({ width: e, height: t, isEditorReady: r, loading: n, _ref: o, className: a, wrapperProps: m }) {
1910
- return c.createElement("section", { style: { ...Ce.wrapper, width: e, height: t }, ...m }, !r && c.createElement(qt, null, n), c.createElement("div", { ref: o, style: { ...Ce.fullWidth, ...!r && Ce.hide }, className: a }));
1910
+ function Lt({ width: e, height: t, isEditorReady: r, loading: n, _ref: o, className: a, wrapperProps: c }) {
1911
+ return m.createElement("section", { style: { ...Ce.wrapper, width: e, height: t }, ...c }, !r && m.createElement(qt, null, n), m.createElement("div", { ref: o, style: { ...Ce.fullWidth, ...!r && Ce.hide }, className: a }));
1911
1912
  }
1912
1913
  var Ut = Lt, Qe = Oe(Ut);
1913
1914
  function zt(e) {
@@ -1935,7 +1936,7 @@ function Ht(e, t, r, n) {
1935
1936
  function ei(e, t) {
1936
1937
  return e.Uri.parse(t);
1937
1938
  }
1938
- function Yt({ original: e, modified: t, language: r, originalLanguage: n, modifiedLanguage: o, originalModelPath: a, modifiedModelPath: m, keepCurrentOriginalModel: l = !1, keepCurrentModifiedModel: d = !1, theme: u = "light", loading: p = "Loading...", options: h = {}, height: N = "100%", width: M = "100%", className: W, wrapperProps: F = {}, beforeMount: E = ne, onMount: T = ne }) {
1939
+ function Yt({ original: e, modified: t, language: r, originalLanguage: n, modifiedLanguage: o, originalModelPath: a, modifiedModelPath: c, keepCurrentOriginalModel: l = !1, keepCurrentModifiedModel: d = !1, theme: u = "light", loading: p = "Loading...", options: h = {}, height: N = "100%", width: M = "100%", className: W, wrapperProps: F = {}, beforeMount: E = ne, onMount: T = ne }) {
1939
1940
  let [y, R] = fe(!1), [A, b] = fe(!0), O = V(null), x = V(null), q = V(null), P = V(T), I = V(E), w = V(!1);
1940
1941
  Ze(() => {
1941
1942
  let v = Xe.init();
@@ -1947,10 +1948,10 @@ function Yt({ original: e, modified: t, language: r, originalLanguage: n, modifi
1947
1948
  }
1948
1949
  }, [a], y), H(() => {
1949
1950
  if (O.current && x.current) {
1950
- let v = O.current.getModifiedEditor(), k = Z(x.current, t || "", o || r || "text", m || "");
1951
+ let v = O.current.getModifiedEditor(), k = Z(x.current, t || "", o || r || "text", c || "");
1951
1952
  k !== v.getModel() && v.setModel(k);
1952
1953
  }
1953
- }, [m], y), H(() => {
1954
+ }, [c], y), H(() => {
1954
1955
  let v = O.current.getModifiedEditor();
1955
1956
  v.getOption(x.current.editor.EditorOption.readOnly) ? v.setValue(t || "") : t !== v.getValue() && (v.executeEdits("", [{ range: v.getModel().getFullModelRange(), text: t || "", forceMoveMarkers: !0 }]), v.pushUndoStop());
1956
1957
  }, [t], y), H(() => {
@@ -1966,9 +1967,9 @@ function Yt({ original: e, modified: t, language: r, originalLanguage: n, modifi
1966
1967
  let S = ue(() => {
1967
1968
  if (!x.current) return;
1968
1969
  I.current(x.current);
1969
- let v = Z(x.current, e || "", n || r || "text", a || ""), k = Z(x.current, t || "", o || r || "text", m || "");
1970
+ let v = Z(x.current, e || "", n || r || "text", a || ""), k = Z(x.current, t || "", o || r || "text", c || "");
1970
1971
  O.current?.setModel({ original: v, modified: k });
1971
- }, [r, t, o, e, n, a, m]), f = ue(() => {
1972
+ }, [r, t, o, e, n, a, c]), f = ue(() => {
1972
1973
  !w.current && q.current && (O.current = x.current.editor.createDiffEditor(q.current, { automaticLayout: !0, ...h }), S(), x.current?.editor.setTheme(u), R(!0), w.current = !0);
1973
1974
  }, [h, u, S]);
1974
1975
  J(() => {
@@ -1980,7 +1981,7 @@ function Yt({ original: e, modified: t, language: r, originalLanguage: n, modifi
1980
1981
  let v = O.current?.getModel();
1981
1982
  l || v?.original?.dispose(), d || v?.modified?.dispose(), O.current?.dispose();
1982
1983
  }
1983
- return c.createElement(Qe, { width: M, height: N, isEditorReady: y, loading: p, _ref: q, className: W, wrapperProps: F });
1984
+ return m.createElement(Qe, { width: M, height: N, isEditorReady: y, loading: p, _ref: q, className: W, wrapperProps: F });
1984
1985
  }
1985
1986
  var Jt = Yt;
1986
1987
  Oe(Jt);
@@ -1991,7 +1992,7 @@ function Bt(e) {
1991
1992
  }, [e]), t.current;
1992
1993
  }
1993
1994
  var Gt = Bt, de = /* @__PURE__ */ new Map();
1994
- function Kt({ defaultValue: e, defaultLanguage: t, defaultPath: r, value: n, language: o, path: a, theme: m = "light", line: l, loading: d = "Loading...", options: u = {}, overrideServices: p = {}, saveViewState: h = !0, keepCurrentModel: N = !1, width: M = "100%", height: W = "100%", className: F, wrapperProps: E = {}, beforeMount: T = ne, onMount: y = ne, onChange: R, onValidate: A = ne }) {
1995
+ function Kt({ defaultValue: e, defaultLanguage: t, defaultPath: r, value: n, language: o, path: a, theme: c = "light", line: l, loading: d = "Loading...", options: u = {}, overrideServices: p = {}, saveViewState: h = !0, keepCurrentModel: N = !1, width: M = "100%", height: W = "100%", className: F, wrapperProps: E = {}, beforeMount: T = ne, onMount: y = ne, onChange: R, onValidate: A = ne }) {
1995
1996
  let [b, O] = fe(!1), [x, q] = fe(!0), P = V(null), I = V(null), w = V(null), S = V(y), f = V(T), g = V(), v = V(n), k = Gt(a), _ = V(!1), D = V(!1);
1996
1997
  Ze(() => {
1997
1998
  let s = Xe.init();
@@ -2009,15 +2010,15 @@ function Kt({ defaultValue: e, defaultLanguage: t, defaultPath: r, value: n, lan
2009
2010
  }, [o], b), H(() => {
2010
2011
  l !== void 0 && I.current?.revealLine(l);
2011
2012
  }, [l], b), H(() => {
2012
- P.current?.editor.setTheme(m);
2013
- }, [m], b);
2013
+ P.current?.editor.setTheme(c);
2014
+ }, [c], b);
2014
2015
  let L = ue(() => {
2015
2016
  if (!(!w.current || !P.current) && !_.current) {
2016
2017
  f.current(P.current);
2017
2018
  let s = a || r, C = Z(P.current, n || e || "", t || o || "", s || "");
2018
- I.current = P.current?.editor.create(w.current, { model: C, automaticLayout: !0, ...u }, p), h && I.current.restoreViewState(de.get(s)), P.current.editor.setTheme(m), l !== void 0 && I.current.revealLine(l), O(!0), _.current = !0;
2019
+ I.current = P.current?.editor.create(w.current, { model: C, automaticLayout: !0, ...u }, p), h && I.current.restoreViewState(de.get(s)), P.current.editor.setTheme(c), l !== void 0 && I.current.revealLine(l), O(!0), _.current = !0;
2019
2020
  }
2020
- }, [e, t, r, n, o, a, u, p, h, m, l]);
2021
+ }, [e, t, r, n, o, a, u, p, h, c, l]);
2021
2022
  J(() => {
2022
2023
  b && S.current(I.current, P.current);
2023
2024
  }, [b]), J(() => {
@@ -2045,12 +2046,12 @@ function Kt({ defaultValue: e, defaultLanguage: t, defaultPath: r, value: n, lan
2045
2046
  function z() {
2046
2047
  g.current?.dispose(), N ? h && de.set(a, I.current.saveViewState()) : I.current.getModel()?.dispose(), I.current.dispose();
2047
2048
  }
2048
- return c.createElement(Qe, { width: M, height: W, isEditorReady: b, loading: d, _ref: w, className: F, wrapperProps: E });
2049
+ return m.createElement(Qe, { width: M, height: W, isEditorReady: b, loading: d, _ref: w, className: F, wrapperProps: E });
2049
2050
  }
2050
2051
  var Xt = Kt, Qt = Oe(Xt), Zt = Qt;
2051
2052
  function er() {
2052
- const e = Ue(), t = Y((w) => w.replaceAll), r = B(), { showAlert: n } = ze(), o = c.useRef(null), a = c.useRef(""), m = c.useRef(null), l = c.useRef(!1), d = c.useRef(t), u = c.useRef(r), p = c.useRef(e), [h, N] = c.useState("yaml"), M = c.useRef(h), [W, F] = c.useState(!1);
2053
- c.useEffect(() => {
2053
+ const e = Ue(), t = Y((w) => w.replaceAll), r = B(), { showAlert: n } = ze(), o = m.useRef(null), a = m.useRef(""), c = m.useRef(null), l = m.useRef(!1), d = m.useRef(t), u = m.useRef(r), p = m.useRef(e), [h, N] = m.useState("yaml"), M = m.useRef(h), [W, F] = m.useState(!1);
2054
+ m.useEffect(() => {
2054
2055
  const w = document.querySelector(".qb-editor-root");
2055
2056
  if (!w) return;
2056
2057
  const S = () => {
@@ -2060,20 +2061,20 @@ function er() {
2060
2061
  const f = new MutationObserver(S);
2061
2062
  return f.observe(w, { attributes: !0, attributeFilter: ["class"] }), () => f.disconnect();
2062
2063
  }, []);
2063
- const [E, T] = c.useState(640), [y, R] = c.useState(() => {
2064
+ const [E, T] = m.useState(640), [y, R] = m.useState(() => {
2064
2065
  try {
2065
2066
  return ee.dump(e, { indent: 2, lineWidth: -1 });
2066
2067
  } catch {
2067
2068
  return "";
2068
2069
  }
2069
- }), [A, b] = c.useState("");
2070
- c.useEffect(() => {
2070
+ }), [A, b] = m.useState("");
2071
+ m.useEffect(() => {
2071
2072
  r.setCodeEditorHasError(!1);
2072
- }, []), c.useEffect(() => {
2073
+ }, []), m.useEffect(() => {
2073
2074
  d.current = t, u.current = r, p.current = e, M.current = h;
2074
2075
  });
2075
- const O = c.useCallback((w) => h === "json" ? JSON.parse(w) : ee.load(w), [h]), x = c.useCallback((w) => h === "json" ? JSON.stringify(w, null, 2) : ee.dump(w, { indent: 2, lineWidth: -1 }), [h]);
2076
- c.useEffect(() => {
2076
+ const O = m.useCallback((w) => h === "json" ? JSON.parse(w) : ee.load(w), [h]), x = m.useCallback((w) => h === "json" ? JSON.stringify(w, null, 2) : ee.dump(w, { indent: 2, lineWidth: -1 }), [h]);
2077
+ m.useEffect(() => {
2077
2078
  const w = () => {
2078
2079
  if (o.current) {
2079
2080
  const S = o.current.getBoundingClientRect().top, f = window.innerHeight - S - 20;
@@ -2081,7 +2082,7 @@ function er() {
2081
2082
  }
2082
2083
  };
2083
2084
  return w(), window.addEventListener("resize", w), () => window.removeEventListener("resize", w);
2084
- }, []), c.useEffect(() => {
2085
+ }, []), m.useEffect(() => {
2085
2086
  if (!l.current)
2086
2087
  try {
2087
2088
  const w = x(e);
@@ -2102,7 +2103,7 @@ function er() {
2102
2103
  b(f), r.setCodeEditorHasError(!0);
2103
2104
  }
2104
2105
  }, P = (w) => {
2105
- m.current = w, w.onDidPaste((S) => {
2106
+ c.current = w, w.onDidPaste((S) => {
2106
2107
  const f = y, g = w.getModel().getValue();
2107
2108
  try {
2108
2109
  const v = O(g);
@@ -2154,7 +2155,7 @@ Please use MIE Forms schema inside of code editor for the best experience in the
2154
2155
  b(`Cannot convert: ${S.message}`), r.setCodeEditorHasError(!0);
2155
2156
  }
2156
2157
  };
2157
- return c.useEffect(() => () => {
2158
+ return m.useEffect(() => () => {
2158
2159
  const w = a.current?.trim(), S = M.current, f = p.current, g = d.current, v = u.current, k = (_) => S === "json" ? JSON.parse(_) : ee.load(_);
2159
2160
  if (!w) {
2160
2161
  g({ schemaType: ye, fields: [] }), l.current = !1;
@@ -2225,13 +2226,13 @@ Please use MIE Forms schema inside of code editor for the best experience in the
2225
2226
  ] });
2226
2227
  }
2227
2228
  function ir({ selectedField: e }) {
2228
- const t = B(), [r, n] = c.useState(!1), o = t.state.isPreview, a = t.state.isCodeEditor, m = t.state.isEditModalOpen, l = t.state.panelResetKey, d = !o;
2229
+ const t = B(), [r, n] = m.useState(!1), o = t.state.isPreview, a = t.state.isCodeEditor, c = t.state.isEditModalOpen, l = t.state.panelResetKey, d = !o;
2229
2230
  return /* @__PURE__ */ i.jsxs("div", { className: "layout-container mie:w-full mie:h-fit mie:rounded-lg mie:mt-3", children: [
2230
2231
  a ? /* @__PURE__ */ i.jsx("div", { className: "mie:border mie:border-mieborder mie:rounded-lg", children: /* @__PURE__ */ i.jsx(er, {}) }) : /* @__PURE__ */ i.jsxs("div", { className: "layout-grid mie:flex mie:lg:gap-3 mie:h-full", children: [
2231
2232
  d && /* @__PURE__ */ i.jsx("div", { className: "layout-tool-panel mie:hidden mie:lg:block mie:lg:w-72", children: /* @__PURE__ */ i.jsx(Re, {}) }),
2232
2233
  /* @__PURE__ */ i.jsx("div", { className: "layout-main-content mie:flex-1 mie:min-w-0", children: /* @__PURE__ */ i.jsx(zi, {}) }),
2233
2234
  d && /* @__PURE__ */ i.jsx("div", { className: "layout-edit-panel mie:hidden mie:lg:block mie:lg:w-90 mie:md:w-80", children: /* @__PURE__ */ i.jsx(Fe, {}, l) }),
2234
- d && /* @__PURE__ */ i.jsx("div", { className: "layout-mobile-modal mie:lg:hidden", children: m && e && /* @__PURE__ */ i.jsxs(i.Fragment, { children: [
2235
+ d && /* @__PURE__ */ i.jsx("div", { className: "layout-mobile-modal mie:lg:hidden", children: c && e && /* @__PURE__ */ i.jsxs(i.Fragment, { children: [
2235
2236
  /* @__PURE__ */ i.jsx(
2236
2237
  "div",
2237
2238
  {
@@ -2272,11 +2273,11 @@ function tr({
2272
2273
  className: n = "",
2273
2274
  showHeader: o = !0,
2274
2275
  startInPreview: a = !1,
2275
- hideUnsupportedFields: m = !1,
2276
+ hideUnsupportedFields: c = !1,
2276
2277
  theme: l = "light"
2277
2278
  }) {
2278
- const [d, u] = c.useState("json"), p = B(), h = c.useRef(!1), N = c.useContext(Te);
2279
- c.useEffect(() => {
2279
+ const [d, u] = m.useState("json"), p = B(), h = m.useRef(!1), N = m.useContext(Te);
2280
+ m.useEffect(() => {
2280
2281
  if (!(h.current || !N)) {
2281
2282
  if (e)
2282
2283
  try {
@@ -2298,9 +2299,9 @@ function tr({
2298
2299
  }
2299
2300
  p.preview.set(!!a), h.current = !0;
2300
2301
  }
2301
- }, [e, t, a, p, N]), c.useEffect(() => {
2302
- p.setHideUnsupportedFields(m);
2303
- }, [m, p]), c.useEffect(() => {
2302
+ }, [e, t, a, p, N]), m.useEffect(() => {
2303
+ p.setHideUnsupportedFields(c);
2304
+ }, [c, p]), m.useEffect(() => {
2304
2305
  if (!(!r || !N))
2305
2306
  return N.subscribe((F) => {
2306
2307
  r({
@@ -2320,7 +2321,7 @@ function tr({
2320
2321
  ] }) });
2321
2322
  }
2322
2323
  function ar(e) {
2323
- const t = c.useRef(Ci()).current, r = c.useRef(Ei()).current;
2324
+ const t = m.useMemo(() => Ci(), []), r = m.useMemo(() => Ei(), []);
2324
2325
  return /* @__PURE__ */ i.jsx(Te.Provider, { value: t, children: /* @__PURE__ */ i.jsx(Ni.Provider, { value: r, children: /* @__PURE__ */ i.jsx(tr, { ...e }) }) });
2325
2326
  }
2326
2327
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mieweb/forms-editor",
3
- "version": "2.1.3",
3
+ "version": "2.1.4-prerelease.0",
4
4
  "description": "Embeddable questionnaire form editor component",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -30,7 +30,7 @@
30
30
  "react-dom": ">=18.0.0"
31
31
  },
32
32
  "dependencies": {
33
- "@mieweb/forms-engine": "^2.1.3",
33
+ "@mieweb/forms-engine": "^2.1.4-prerelease.0",
34
34
  "@monaco-editor/react": "^4.6.0",
35
35
  "js-yaml": "^4.1.0"
36
36
  },