@overmap-ai/forms 1.0.4-conditional-arrows-2.16 → 1.0.4-conditional-arrows-2.17
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/forms.js +215 -213
- package/dist/forms.umd.cjs +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/forms.js
CHANGED
|
@@ -2,9 +2,9 @@ var Wt = Object.defineProperty;
|
|
|
2
2
|
var jt = (s, i, e) => i in s ? Wt(s, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[i] = e;
|
|
3
3
|
var m = (s, i, e) => (jt(s, typeof i != "symbol" ? i + "" : i, e), e);
|
|
4
4
|
import { jsx as r, jsxs as b, Fragment as bt } from "react/jsx-runtime";
|
|
5
|
-
import { Flex as y, Text as k, useSeverityColor as fe, Checkbox as Ht, CheckCircledIcon as Ut, TextField as ce, FontFamilyIcon as Gt, CalendarIcon as Kt, InputIcon as Zt, TextArea as Yt, RowsIcon as Xt, Select as yt, Box as pe, IconButton as ge, PlusIcon as
|
|
5
|
+
import { Flex as y, Text as k, useSeverityColor as fe, Checkbox as Ht, CheckCircledIcon as Ut, TextField as ce, FontFamilyIcon as Gt, CalendarIcon as Kt, InputIcon as Zt, TextArea as Yt, RowsIcon as Xt, Select as yt, Box as pe, IconButton as ge, PlusIcon as Me, Badge as Ue, Cross1Icon as vt, ListBulletIcon as Qt, DropdownMenuIcon as Jt, MultiSelect as ei, CheckboxIcon as ti, Card as we, Heading as Ne, Button as G, UploadIcon as wt, ButtonList as Re, divButtonProps as ii, StarFilledIcon as ni, StarIcon as ri, QuestionMarkCircledIcon as oi, PersonIcon as si, Tooltip as li, Avatar as ai, Separator as ci, Dialog as di, Pencil1Icon as ui, TrashIcon as fi, CopyIcon as mi, DropdownMenu as hi, DotsVerticalIcon as pi, useAlertDialog as gi, Em as bi, Strong as ut, useToast as yi, Tabs as J } from "@overmap-ai/blocks";
|
|
6
6
|
import { useField as Je, useFormikContext as me, useFormik as et, FormikProvider as tt } from "formik";
|
|
7
|
-
import vi, { useMemo as w, memo as z, useCallback as F, useState as K, useEffect as
|
|
7
|
+
import vi, { useMemo as w, memo as z, useCallback as F, useState as K, useEffect as xe, useRef as wi, forwardRef as Ie, useReducer as xi } from "react";
|
|
8
8
|
import { DragDropContext as xt, Droppable as it, Draggable as nt } from "@hello-pangea/dnd";
|
|
9
9
|
import { slugify as Ii, useAppSelector as O, selectFormRevision as It, useSDK as Ct, selectSubmissionAttachments as Ci, selectFilteredUserForms as Fi, selectUserFormMapping as Ti, selectOrganization as Ft, selectUser as rt, selectNumberOfUserForms as Si, selectCurrentUser as Tt, classNames as St, isToday as zi, getLocalDateString as Ei, selectLatestFormRevision as Ai, useFileSrc as Li, selectSubmissionsForForm as Pi } from "@overmap-ai/core";
|
|
10
10
|
import de from "lodash.get";
|
|
@@ -91,8 +91,9 @@ class M extends zt {
|
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
m(M, "fieldTypeName"), m(M, "fieldTypeDescription");
|
|
94
|
-
const $i = "
|
|
95
|
-
description: $i
|
|
94
|
+
const $i = "_description_zyr02_1", ki = "_sectionContainer_zyr02_5", be = {
|
|
95
|
+
description: $i,
|
|
96
|
+
sectionContainer: ki
|
|
96
97
|
}, W = (s) => {
|
|
97
98
|
const { label: i, children: e, severity: t, inputId: n, labelId: o, flexProps: a } = s;
|
|
98
99
|
return /* @__PURE__ */ r(y, { direction: "column", gap: "1", asChild: !0, ...a, children: /* @__PURE__ */ b("label", { htmlFor: n, children: [
|
|
@@ -103,7 +104,7 @@ const $i = "_description_17zed_1", Re = {
|
|
|
103
104
|
const { helpText: i, children: e, severity: t } = s;
|
|
104
105
|
return /* @__PURE__ */ b(y, { direction: "column", gap: "1", children: [
|
|
105
106
|
e,
|
|
106
|
-
/* @__PURE__ */ r(y, { direction: "column", children: /* @__PURE__ */ r(k, { size: "1", severity: t, className:
|
|
107
|
+
/* @__PURE__ */ r(y, { direction: "column", children: /* @__PURE__ */ r(k, { size: "1", severity: t, className: be.description, children: i }) })
|
|
107
108
|
] });
|
|
108
109
|
}, H = (s) => {
|
|
109
110
|
const { id: i, field: e, formId: t, ...n } = s, [o, a, c] = Je(e.getId()), { touched: l } = a, f = a.error ?? e.description, d = a.error ? "danger" : void 0, u = i ?? `${t}-${e.getId()}-input`, h = `${u}-label`, p = e.required ? `${e.label} *` : e.label, g = w(() => ({
|
|
@@ -129,8 +130,8 @@ const $i = "_description_17zed_1", Re = {
|
|
|
129
130
|
},
|
|
130
131
|
{ ...n, "aria-labelledby": h }
|
|
131
132
|
];
|
|
132
|
-
},
|
|
133
|
-
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: a, fieldProps: c }, l] = H(i), f = fe(n), d =
|
|
133
|
+
}, Vi = [!0, "true"], _i = z(function(i) {
|
|
134
|
+
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: a, fieldProps: c }, l] = H(i), f = fe(n), d = Vi.includes(c.value);
|
|
134
135
|
return /* @__PURE__ */ r(j, { helpText: o, severity: n, children: /* @__PURE__ */ r(
|
|
135
136
|
W,
|
|
136
137
|
{
|
|
@@ -176,7 +177,7 @@ const $i = "_description_17zed_1", Re = {
|
|
|
176
177
|
return new ee(e);
|
|
177
178
|
}
|
|
178
179
|
getInput(e) {
|
|
179
|
-
return /* @__PURE__ */ r(
|
|
180
|
+
return /* @__PURE__ */ r(_i, { ...e, field: this });
|
|
180
181
|
}
|
|
181
182
|
};
|
|
182
183
|
m(ee, "fieldTypeName", "Checkbox"), m(ee, "fieldTypeDescription", "Perfect for both optional and required yes/no questions."), m(ee, "Icon", Ut);
|
|
@@ -272,7 +273,7 @@ const Di = z(function(i) {
|
|
|
272
273
|
};
|
|
273
274
|
m(B, "fieldTypeName", "Number"), m(B, "fieldTypeDescription", "Allows specifying a number within a given range."), m(B, "Icon", Gt), m(B, "_validateMin", (e, t) => typeof t.maximum == "number" && typeof e == "number" && t.maximum < e ? "Minimum cannot be greater than minimum." : null), m(B, "_validateMax", (e, t) => typeof t.minimum == "number" && typeof e == "number" && t.minimum > e ? "Maximum cannot be less than minimum." : null);
|
|
274
275
|
let X = B;
|
|
275
|
-
const
|
|
276
|
+
const Oi = z(function(i) {
|
|
276
277
|
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: a, fieldProps: c }, l] = H(i), f = fe(n), d = c.value ? c.value.split("T")[0] : "";
|
|
277
278
|
return /* @__PURE__ */ r(j, { helpText: o, severity: n, children: /* @__PURE__ */ r(W, { severity: n, inputId: e, labelId: t, label: a, children: /* @__PURE__ */ r(ce.Input, { ...l, ...c, type: "date", id: e, color: f, value: d }) }) });
|
|
278
279
|
}), te = class te extends M {
|
|
@@ -292,12 +293,12 @@ const _i = z(function(i) {
|
|
|
292
293
|
return new te(e);
|
|
293
294
|
}
|
|
294
295
|
getInput(e) {
|
|
295
|
-
return /* @__PURE__ */ r(
|
|
296
|
+
return /* @__PURE__ */ r(Oi, { field: this, ...e });
|
|
296
297
|
}
|
|
297
298
|
};
|
|
298
299
|
m(te, "fieldTypeName", "Date"), m(te, "fieldTypeDescription", "Allows specifying a date."), m(te, "Icon", Kt);
|
|
299
300
|
let Ge = te;
|
|
300
|
-
class
|
|
301
|
+
class Ae extends M {
|
|
301
302
|
constructor(e) {
|
|
302
303
|
const { minLength: t, maxLength: n = 5e3, ...o } = e;
|
|
303
304
|
super(o);
|
|
@@ -356,20 +357,20 @@ class Ee extends M {
|
|
|
356
357
|
* This function validates that the value given for "minimum length" (when creating a new field) is less than or
|
|
357
358
|
* equal to the value given for "maximum length".
|
|
358
359
|
*/
|
|
359
|
-
m(
|
|
360
|
+
m(Ae, "_validateMin", (e, t) => typeof t.maximum_length == "number" && typeof e == "number" && t.maximum_length < e ? "Minimum cannot be greater than maximum." : null), /**
|
|
360
361
|
* This function validates that the value given for "maximum length" (when creating a new field) is greater than or
|
|
361
362
|
* equal to the value given for "minimum length".
|
|
362
363
|
*/
|
|
363
|
-
m(
|
|
364
|
+
m(Ae, "_validateMax", (e, t) => {
|
|
364
365
|
if (typeof e != "number")
|
|
365
366
|
return null;
|
|
366
367
|
const { minimum_length: n } = t;
|
|
367
368
|
return typeof n != "number" ? null : n > e ? "Maximum cannot be less than minimum." : null;
|
|
368
369
|
});
|
|
369
|
-
const
|
|
370
|
+
const Mi = z(function(i) {
|
|
370
371
|
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: a, fieldProps: c, field: l }, f] = H(i), d = fe(n);
|
|
371
372
|
return /* @__PURE__ */ r(j, { helpText: o, severity: n, children: /* @__PURE__ */ r(W, { severity: n, inputId: e, labelId: t, label: a, children: /* @__PURE__ */ r(ce.Input, { ...f, ...c, type: l.inputType, id: e, color: d }) }) });
|
|
372
|
-
}), ie = class ie extends
|
|
373
|
+
}), ie = class ie extends Ae {
|
|
373
374
|
constructor(e) {
|
|
374
375
|
const { inputType: t = "text", ...n } = e, o = e.maxLength ? Math.min(500, e.maxLength) : 500, a = e.minLength ? Math.min(e.minLength, o) : void 0;
|
|
375
376
|
super({ ...n, maxLength: o, minLength: a, type: "string" });
|
|
@@ -386,15 +387,15 @@ const Oi = z(function(i) {
|
|
|
386
387
|
return new ie({ ...a, maxLength: t, minLength: n, inputType: o });
|
|
387
388
|
}
|
|
388
389
|
getInput(e) {
|
|
389
|
-
return /* @__PURE__ */ r(
|
|
390
|
+
return /* @__PURE__ */ r(Mi, { field: this, ...e });
|
|
390
391
|
}
|
|
391
392
|
};
|
|
392
393
|
m(ie, "fieldTypeName", "Short Text"), m(ie, "fieldTypeDescription", "Short text fields can hold up to 500 characters on a single line."), m(ie, "Icon", Zt);
|
|
393
|
-
let
|
|
394
|
-
const
|
|
394
|
+
let ye = ie;
|
|
395
|
+
const Ni = z(function(i) {
|
|
395
396
|
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: a, fieldProps: c }, l] = H(i);
|
|
396
397
|
return /* @__PURE__ */ r(j, { helpText: o, severity: n, children: /* @__PURE__ */ r(W, { severity: n, inputId: e, labelId: t, label: a, children: /* @__PURE__ */ r(Yt, { ...l, ...c, resize: "vertical", id: e, severity: n }) }) });
|
|
397
|
-
}), ne = class ne extends
|
|
398
|
+
}), ne = class ne extends Ae {
|
|
398
399
|
constructor(i) {
|
|
399
400
|
const e = i.maxLength ? Math.min(5e3, i.maxLength) : 5e3, t = i.minLength ? Math.min(i.minLength, e) : void 0;
|
|
400
401
|
super({ ...i, maxLength: e, minLength: t, type: "text" });
|
|
@@ -409,12 +410,12 @@ const Mi = z(function(i) {
|
|
|
409
410
|
return new ne({ ...n, maxLength: e, minLength: t });
|
|
410
411
|
}
|
|
411
412
|
getInput(i) {
|
|
412
|
-
return /* @__PURE__ */ r(
|
|
413
|
+
return /* @__PURE__ */ r(Ni, { field: this, ...i });
|
|
413
414
|
}
|
|
414
415
|
};
|
|
415
416
|
m(ne, "fieldTypeName", "Paragraph"), m(ne, "fieldTypeDescription", "Paragraph fields can hold up to 5000 characters and can have multiple lines."), m(ne, "Icon", Xt);
|
|
416
|
-
let
|
|
417
|
-
const
|
|
417
|
+
let ve = ne;
|
|
418
|
+
const Ri = z(function(i) {
|
|
418
419
|
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: a, fieldProps: c, field: l }, f] = H(i), { onChange: d, onBlur: u } = c, h = w(
|
|
419
420
|
() => l.options.map((g) => ({ value: g.value, itemContent: g.label })),
|
|
420
421
|
[l.options]
|
|
@@ -436,22 +437,22 @@ const Ni = z(function(i) {
|
|
|
436
437
|
...f
|
|
437
438
|
}
|
|
438
439
|
) }) });
|
|
439
|
-
}),
|
|
440
|
+
}), Le = (s = "", i = []) => ({
|
|
440
441
|
type: "section",
|
|
441
442
|
fields: i,
|
|
442
443
|
identifier: s,
|
|
443
444
|
label: null,
|
|
444
445
|
condition: null,
|
|
445
446
|
conditional: !1
|
|
446
|
-
}),
|
|
447
|
+
}), Bi = (s) => {
|
|
447
448
|
if (!s)
|
|
448
449
|
return;
|
|
449
450
|
const i = s.fields;
|
|
450
451
|
let e = [];
|
|
451
452
|
const t = [];
|
|
452
453
|
for (const n of i)
|
|
453
|
-
n.type === "section" ? (e.length > 0 && (t.push(
|
|
454
|
-
return e.length > 0 && t.push(
|
|
454
|
+
n.type === "section" ? (e.length > 0 && (t.push(Le(`AUTO_section-${i.indexOf(n)}`, e)), e = []), t.push(n)) : e.push(n);
|
|
455
|
+
return e.length > 0 && t.push(Le("AUTO_section-last", e)), { ...s, fields: t, description: s.description ?? "" };
|
|
455
456
|
};
|
|
456
457
|
function Ke(s, i, e) {
|
|
457
458
|
const t = Array.from(s), [n] = t.splice(i, 1);
|
|
@@ -459,7 +460,7 @@ function Ke(s, i, e) {
|
|
|
459
460
|
throw new Error("Could not find field to reorder.");
|
|
460
461
|
return t.splice(e, 0, n), t;
|
|
461
462
|
}
|
|
462
|
-
function
|
|
463
|
+
function qi(s, i, e) {
|
|
463
464
|
const t = Array.from(s);
|
|
464
465
|
return t[i] = e, t;
|
|
465
466
|
}
|
|
@@ -467,7 +468,7 @@ function Et(s, i, e) {
|
|
|
467
468
|
const t = Array.from(s ?? []);
|
|
468
469
|
return t.splice(i, 0, e), t;
|
|
469
470
|
}
|
|
470
|
-
function
|
|
471
|
+
function Pe(s, i) {
|
|
471
472
|
const e = Array.from(s);
|
|
472
473
|
return e.splice(i, 1), e;
|
|
473
474
|
}
|
|
@@ -487,14 +488,14 @@ const At = (s, i) => {
|
|
|
487
488
|
} else if (e.identifier === i)
|
|
488
489
|
return e;
|
|
489
490
|
return null;
|
|
490
|
-
},
|
|
491
|
+
}, Ee = (s, i) => s.filter((e, t) => t < i).flatMap((e) => e.fields), Pt = (s) => s.flatMap(
|
|
491
492
|
(i) => i.type === "section" ? [...i.fields.map((e) => e.label), i.label] : i.label
|
|
492
493
|
).filter((i) => i !== null), Ze = (s, i) => {
|
|
493
494
|
let e = 1, t = `${s} (${e})`;
|
|
494
495
|
for (; i.includes(t); )
|
|
495
496
|
t = `${s} (${++e})`;
|
|
496
497
|
return t;
|
|
497
|
-
},
|
|
498
|
+
}, Wi = z(function(i) {
|
|
498
499
|
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: a, fieldProps: c }, l] = H(i), f = fe(n), d = w(() => Array.isArray(c.value) ? c.value : [], [c.value]), { onChange: u, onBlur: h } = c, p = `${e}-droppable`, { disabled: g } = l, [T, I] = K(""), [C, v] = K(""), V = C || o, L = C ? "red" : f, x = F(
|
|
499
500
|
(E) => {
|
|
500
501
|
u(E), h(E);
|
|
@@ -519,7 +520,7 @@ const At = (s, i) => {
|
|
|
519
520
|
[N]
|
|
520
521
|
), q = F(
|
|
521
522
|
(E) => {
|
|
522
|
-
x(
|
|
523
|
+
x(Pe(d, E));
|
|
523
524
|
},
|
|
524
525
|
[d, x]
|
|
525
526
|
), U = F(
|
|
@@ -554,7 +555,7 @@ const At = (s, i) => {
|
|
|
554
555
|
"aria-label": "Add option",
|
|
555
556
|
disabled: !!C || g,
|
|
556
557
|
onClick: N,
|
|
557
|
-
children: /* @__PURE__ */ r(
|
|
558
|
+
children: /* @__PURE__ */ r(Me, {})
|
|
558
559
|
}
|
|
559
560
|
)
|
|
560
561
|
] }) }) }),
|
|
@@ -565,12 +566,12 @@ const At = (s, i) => {
|
|
|
565
566
|
draggableId: `${R.value}-draggable`,
|
|
566
567
|
index: Y,
|
|
567
568
|
isDragDisabled: g,
|
|
568
|
-
children: ({ draggableProps:
|
|
569
|
+
children: ({ draggableProps: Ce, dragHandleProps: Fe, innerRef: Te }) => /* @__PURE__ */ r(
|
|
569
570
|
y,
|
|
570
571
|
{
|
|
572
|
+
...Fe,
|
|
571
573
|
...Ce,
|
|
572
|
-
|
|
573
|
-
ref: Fe,
|
|
574
|
+
ref: Te,
|
|
574
575
|
gap: "2",
|
|
575
576
|
align: "center",
|
|
576
577
|
justify: "between",
|
|
@@ -615,7 +616,7 @@ const At = (s, i) => {
|
|
|
615
616
|
throw new Error("Expected an array.");
|
|
616
617
|
}
|
|
617
618
|
getInput(e) {
|
|
618
|
-
return /* @__PURE__ */ r(
|
|
619
|
+
return /* @__PURE__ */ r(Wi, { field: this, ...e });
|
|
619
620
|
}
|
|
620
621
|
serialize() {
|
|
621
622
|
return { ...super._serialize(), minimum_length: this.minLength, maximum_length: this.maxLength };
|
|
@@ -640,7 +641,7 @@ const At = (s, i) => {
|
|
|
640
641
|
}
|
|
641
642
|
};
|
|
642
643
|
m(re, "fieldTypeName", "Multi-string"), m(re, "fieldTypeDescription", "Allows the user to provide multiple unique strings."), m(re, "Icon", Qt);
|
|
643
|
-
let
|
|
644
|
+
let $e = re;
|
|
644
645
|
class $t extends M {
|
|
645
646
|
constructor(e) {
|
|
646
647
|
super(e);
|
|
@@ -660,7 +661,7 @@ class $t extends M {
|
|
|
660
661
|
}
|
|
661
662
|
static getFieldCreationSchema() {
|
|
662
663
|
return [
|
|
663
|
-
new
|
|
664
|
+
new $e({
|
|
664
665
|
label: "Options",
|
|
665
666
|
description: "List possible options for the user to select from.",
|
|
666
667
|
required: !0,
|
|
@@ -687,13 +688,13 @@ const oe = class oe extends $t {
|
|
|
687
688
|
return new oe(i);
|
|
688
689
|
}
|
|
689
690
|
getInput(i) {
|
|
690
|
-
return /* @__PURE__ */ r(
|
|
691
|
+
return /* @__PURE__ */ r(Ri, { field: this, ...i });
|
|
691
692
|
}
|
|
692
693
|
};
|
|
693
694
|
m(oe, "fieldTypeName", "Dropdown"), m(oe, "fieldTypeDescription", "Allows the user to select a single option from a list of options."), m(oe, "Icon", Jt);
|
|
694
|
-
let
|
|
695
|
-
const
|
|
696
|
-
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: a, fieldProps: c, field: l }, f] = H(i), { onChange: d, onBlur: u } = c, h = w(() =>
|
|
695
|
+
let ke = oe;
|
|
696
|
+
const ji = (s) => s ? Array.isArray(s) ? s : [s] : [], Hi = z(function(i) {
|
|
697
|
+
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: a, fieldProps: c, field: l }, f] = H(i), { onChange: d, onBlur: u } = c, h = w(() => ji(c.value), [c.value]), p = F(
|
|
697
698
|
(g) => {
|
|
698
699
|
d(g), u(g);
|
|
699
700
|
},
|
|
@@ -733,19 +734,19 @@ const Wi = (s) => s ? Array.isArray(s) ? s : [s] : [], ji = z(function(i) {
|
|
|
733
734
|
return new se(i);
|
|
734
735
|
}
|
|
735
736
|
getInput(i) {
|
|
736
|
-
return /* @__PURE__ */ r(
|
|
737
|
+
return /* @__PURE__ */ r(Hi, { field: this, ...i });
|
|
737
738
|
}
|
|
738
739
|
};
|
|
739
740
|
m(se, "fieldTypeName", "Multi-select"), m(se, "fieldTypeDescription", "Allows the user to select a multiple options from a list of options."), m(se, "Icon", ti);
|
|
740
|
-
let
|
|
741
|
-
const
|
|
741
|
+
let Ve = se;
|
|
742
|
+
const Ui = z(function({ field: i, ...e }) {
|
|
742
743
|
const [{ value: t }] = Je(i.options.clonedFieldIdentifier), n = w(() => {
|
|
743
744
|
const o = i.options.getFieldToClone(t);
|
|
744
745
|
return o ? Be(o) : null;
|
|
745
746
|
}, [i.options, t]);
|
|
746
747
|
return De(n, e);
|
|
747
748
|
});
|
|
748
|
-
class
|
|
749
|
+
class _e extends M {
|
|
749
750
|
constructor(e, t) {
|
|
750
751
|
super({ ...e, type: "custom" });
|
|
751
752
|
m(this, "Component");
|
|
@@ -761,24 +762,24 @@ class Ve extends M {
|
|
|
761
762
|
return /* @__PURE__ */ r(t, { field: this, ...e });
|
|
762
763
|
}
|
|
763
764
|
}
|
|
764
|
-
m(
|
|
765
|
-
class
|
|
765
|
+
m(_e, "fieldTypeName", "Custom"), m(_e, "fieldTypeDescription", "Allows re-rendering of field already in the form");
|
|
766
|
+
class Gi extends _e {
|
|
766
767
|
constructor(i) {
|
|
767
|
-
super(i,
|
|
768
|
+
super(i, Ui);
|
|
768
769
|
}
|
|
769
770
|
}
|
|
770
|
-
const
|
|
771
|
-
const { field: e, ...t } = i, { label: n, description: o, fields: a, condition: c } = e, { values: l, setFieldValue: f } = me(), d = c != null && c.identifier ? de(l, c.identifier) : void 0, u = w(() =>
|
|
772
|
-
|
|
771
|
+
const Ki = z(function(i) {
|
|
772
|
+
const { field: e, ...t } = i, { label: n, description: o, fields: a, condition: c } = e, { values: l, setFieldValue: f } = me(), d = c != null && c.identifier ? de(l, c.identifier) : void 0, u = w(() => _t(c, d), [c, d]);
|
|
773
|
+
xe(() => {
|
|
773
774
|
if (!u)
|
|
774
775
|
for (const p of a)
|
|
775
776
|
f(p.getId(), "").then();
|
|
776
777
|
}, [u, a, f]);
|
|
777
|
-
const h =
|
|
778
|
-
return u ? n ? /* @__PURE__ */ r(
|
|
778
|
+
const h = Dt(a, t);
|
|
779
|
+
return u ? n ? /* @__PURE__ */ r(we, { children: /* @__PURE__ */ b(y, { direction: "column", gap: "3", children: [
|
|
779
780
|
/* @__PURE__ */ b(y, { direction: "column", children: [
|
|
780
|
-
/* @__PURE__ */ r(
|
|
781
|
-
/* @__PURE__ */ r(k, { className:
|
|
781
|
+
/* @__PURE__ */ r(Ne, { as: "h3", size: "3", children: n }),
|
|
782
|
+
/* @__PURE__ */ r(k, { className: be.description, children: o })
|
|
782
783
|
] }),
|
|
783
784
|
h
|
|
784
785
|
] }) }) : h : null;
|
|
@@ -812,7 +813,7 @@ const Gi = z(function(i) {
|
|
|
812
813
|
fields: [
|
|
813
814
|
// Declare a select field that will be used to select the field against which we will check the
|
|
814
815
|
// condition. This must be selected before the next field is rendered.
|
|
815
|
-
new
|
|
816
|
+
new ke({
|
|
816
817
|
label: "Field",
|
|
817
818
|
description: "The field to use for the condition.",
|
|
818
819
|
// The options (for the field against which we will check the condition) are all the labels of
|
|
@@ -829,7 +830,7 @@ const Gi = z(function(i) {
|
|
|
829
830
|
// Declare a custom field that will be used to input a value for the condition. The value of the
|
|
830
831
|
// conditional field selected in the previous step must be equal to the value the user inputs into
|
|
831
832
|
// this field for the section to be rendered.
|
|
832
|
-
new
|
|
833
|
+
new Gi({
|
|
833
834
|
label: "Value",
|
|
834
835
|
identifier: "condition.value",
|
|
835
836
|
required: !0,
|
|
@@ -880,20 +881,20 @@ const Gi = z(function(i) {
|
|
|
880
881
|
return t;
|
|
881
882
|
}
|
|
882
883
|
getInput(e) {
|
|
883
|
-
return /* @__PURE__ */ r(
|
|
884
|
+
return /* @__PURE__ */ r(Ki, { field: this, ...e });
|
|
884
885
|
}
|
|
885
886
|
};
|
|
886
887
|
m(le, "fieldTypeName", "Section"), m(le, "fieldTypeDescription", "Sections can be useful for grouping fields together. They can also be conditionally shown or hidden.");
|
|
887
888
|
let Q = le;
|
|
888
|
-
const
|
|
889
|
-
previewImage:
|
|
889
|
+
const Zi = "_previewImage_1ig84_1", Yi = {
|
|
890
|
+
previewImage: Zi
|
|
890
891
|
}, st = (s) => {
|
|
891
892
|
const i = ["byte", "kilobyte", "megabyte"];
|
|
892
893
|
let e = s, t = 0;
|
|
893
894
|
for (; e > 1024 && t < i.length - 1; )
|
|
894
895
|
e /= 1024, t++;
|
|
895
896
|
return new Intl.NumberFormat([], { maximumFractionDigits: 2, style: "unit", unit: i[t] }).format(e);
|
|
896
|
-
},
|
|
897
|
+
}, Xi = z(function(i) {
|
|
897
898
|
var L;
|
|
898
899
|
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: a, fieldProps: c, field: l }, f] = H(i), { onChange: d } = c, u = fe(n), h = wi(null), { value: p } = c, g = w(() => o || (l.maxFileSize ? `Maximum file size: ${st(l.maxFileSize)}` : null), [l.maxFileSize, o]), T = F(() => {
|
|
899
900
|
var x;
|
|
@@ -929,7 +930,7 @@ const Ki = "_previewImage_1ig84_1", Zi = {
|
|
|
929
930
|
)
|
|
930
931
|
] }) }),
|
|
931
932
|
Array.isArray(p) && p.length > 0 && /* @__PURE__ */ r(y, { direction: "column", gap: "2", children: p.map((x, P) => /* @__PURE__ */ r(
|
|
932
|
-
|
|
933
|
+
Qi,
|
|
933
934
|
{
|
|
934
935
|
field: l,
|
|
935
936
|
file: x,
|
|
@@ -939,14 +940,14 @@ const Ki = "_previewImage_1ig84_1", Zi = {
|
|
|
939
940
|
P
|
|
940
941
|
)) })
|
|
941
942
|
] });
|
|
942
|
-
}),
|
|
943
|
+
}), Qi = z(function({ file: i, field: e, onRemove: t, disabled: n }) {
|
|
943
944
|
const [o, a] = K(null), c = w(() => o && e.getError([o]), [e, o]), { url: l, name: f, size: d } = w(() => {
|
|
944
945
|
let u = null, h, p;
|
|
945
946
|
return o != null && o.type.startsWith("image/") && (u = URL.createObjectURL(o)), o ? (h = o.name, p = st(o.size)) : (h = "Downloading...", p = "..."), { url: u, name: h, size: p };
|
|
946
947
|
}, [o]);
|
|
947
|
-
return
|
|
948
|
+
return xe(() => {
|
|
948
949
|
i instanceof Promise ? i.then(a) : a(i);
|
|
949
|
-
}, [i]), /* @__PURE__ */ r(
|
|
950
|
+
}, [i]), /* @__PURE__ */ r(we, { children: /* @__PURE__ */ b(y, { direction: { initial: "column", sm: "row" }, gap: "3", justify: "between", children: [
|
|
950
951
|
/* @__PURE__ */ b(y, { direction: "row", gap: "3", align: "center", grow: "1", shrink: "0", children: [
|
|
951
952
|
/* @__PURE__ */ r(
|
|
952
953
|
ge,
|
|
@@ -965,7 +966,7 @@ const Ki = "_previewImage_1ig84_1", Zi = {
|
|
|
965
966
|
c && /* @__PURE__ */ r(k, { size: "1", severity: "danger", children: c })
|
|
966
967
|
] })
|
|
967
968
|
] }),
|
|
968
|
-
l && /* @__PURE__ */ r("img", { className:
|
|
969
|
+
l && /* @__PURE__ */ r("img", { className: Yi.previewImage, src: l, alt: f })
|
|
969
970
|
] }) });
|
|
970
971
|
}), mt = 50 * 1024 * 1024, ae = class ae extends M {
|
|
971
972
|
constructor(e) {
|
|
@@ -1002,7 +1003,7 @@ const Ki = "_previewImage_1ig84_1", Zi = {
|
|
|
1002
1003
|
maximum: mt,
|
|
1003
1004
|
integers: !0
|
|
1004
1005
|
}),
|
|
1005
|
-
new
|
|
1006
|
+
new Ve({
|
|
1006
1007
|
label: "Accepted file types",
|
|
1007
1008
|
description: "Types of allowed files to upload. If left blank, all files will be accepted.",
|
|
1008
1009
|
required: !1,
|
|
@@ -1056,7 +1057,7 @@ const Ki = "_previewImage_1ig84_1", Zi = {
|
|
|
1056
1057
|
return new ae(e);
|
|
1057
1058
|
}
|
|
1058
1059
|
getInput(e) {
|
|
1059
|
-
return /* @__PURE__ */ r(
|
|
1060
|
+
return /* @__PURE__ */ r(Xi, { field: this, ...e });
|
|
1060
1061
|
}
|
|
1061
1062
|
};
|
|
1062
1063
|
m(ae, "fieldTypeName", "Upload"), m(ae, "fieldTypeDescription", "Allows a file to be uploaded."), m(ae, "Icon", wt);
|
|
@@ -1065,14 +1066,14 @@ const lt = {
|
|
|
1065
1066
|
date: Ge,
|
|
1066
1067
|
number: X,
|
|
1067
1068
|
boolean: ue,
|
|
1068
|
-
select:
|
|
1069
|
-
string:
|
|
1070
|
-
text:
|
|
1071
|
-
custom:
|
|
1069
|
+
select: ke,
|
|
1070
|
+
string: ye,
|
|
1071
|
+
text: ve,
|
|
1072
|
+
custom: _e,
|
|
1072
1073
|
upload: Ye,
|
|
1073
1074
|
// TODO: Underscore
|
|
1074
|
-
"multi-string":
|
|
1075
|
-
"multi-select":
|
|
1075
|
+
"multi-string": $e,
|
|
1076
|
+
"multi-select": Ve
|
|
1076
1077
|
}, kt = (s) => {
|
|
1077
1078
|
const i = s.type;
|
|
1078
1079
|
return lt[i].deserialize(s);
|
|
@@ -1089,7 +1090,7 @@ function Vt(s, i = {}) {
|
|
|
1089
1090
|
function Xe(s) {
|
|
1090
1091
|
return !!(Array.isArray(s) && s.some((i) => i instanceof File || i instanceof Promise));
|
|
1091
1092
|
}
|
|
1092
|
-
function
|
|
1093
|
+
function _t(s, i) {
|
|
1093
1094
|
if (!s)
|
|
1094
1095
|
return !0;
|
|
1095
1096
|
if (Xe(i) || Xe(s.value))
|
|
@@ -1103,16 +1104,16 @@ function Dt(s, i) {
|
|
|
1103
1104
|
}
|
|
1104
1105
|
return t === i;
|
|
1105
1106
|
}
|
|
1106
|
-
const De = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]),
|
|
1107
|
+
const De = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), Dt = (s, i) => {
|
|
1107
1108
|
const e = w(() => s.map((t) => /* @__PURE__ */ r("div", { children: t.getInput(i) }, t.getId())), [s, i]);
|
|
1108
1109
|
return /* @__PURE__ */ r(y, { direction: "column", gap: "2", children: e });
|
|
1109
|
-
},
|
|
1110
|
+
}, Oe = (s) => Object.keys(s).length > 0, Ot = async (s, i) => {
|
|
1110
1111
|
const e = {};
|
|
1111
1112
|
for (const t of s.fields)
|
|
1112
1113
|
if (t instanceof Q) {
|
|
1113
1114
|
if (t.condition) {
|
|
1114
1115
|
const { identifier: n } = t.condition;
|
|
1115
|
-
if (!
|
|
1116
|
+
if (!_t(t.condition, de(i, n)))
|
|
1116
1117
|
continue;
|
|
1117
1118
|
}
|
|
1118
1119
|
Object.assign(e, t.getErrors(i));
|
|
@@ -1122,16 +1123,16 @@ const De = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), _t = (s,
|
|
|
1122
1123
|
const n = t.getId(), o = t.getError(de(i, n), i);
|
|
1123
1124
|
o && ot(e, n, o);
|
|
1124
1125
|
}
|
|
1125
|
-
if (
|
|
1126
|
+
if (Oe(e))
|
|
1126
1127
|
return e;
|
|
1127
|
-
},
|
|
1128
|
+
}, Ji = [null, void 0], at = (s, i) => s.reduce((e, t) => t instanceof Q ? { ...e, ...at(t.fields, i) } : (Ji.includes(de(e, t.getId())) && ot(e, t.getId(), ""), e), i), en = () => {
|
|
1128
1129
|
throw new Error("onSubmit must be provided if form is not readonly.");
|
|
1129
1130
|
}, ct = z(
|
|
1130
|
-
|
|
1131
|
+
Ie((s, i) => {
|
|
1131
1132
|
const {
|
|
1132
1133
|
schema: e,
|
|
1133
1134
|
values: t = {},
|
|
1134
|
-
onSubmit: n =
|
|
1135
|
+
onSubmit: n = en,
|
|
1135
1136
|
submitText: o = "Submit",
|
|
1136
1137
|
cancelText: a,
|
|
1137
1138
|
onCancel: c,
|
|
@@ -1148,16 +1149,16 @@ const De = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), _t = (s,
|
|
|
1148
1149
|
validateOnBlur: !1,
|
|
1149
1150
|
validateOnChange: !1
|
|
1150
1151
|
}), { dirty: T } = g, I = w(
|
|
1151
|
-
() => typeof e.title == "string" ? /* @__PURE__ */ r(
|
|
1152
|
+
() => typeof e.title == "string" ? /* @__PURE__ */ r(Ne, { children: e.title }) : e.title,
|
|
1152
1153
|
[e.title]
|
|
1153
1154
|
), C = w(
|
|
1154
|
-
() => typeof e.description == "string" ? /* @__PURE__ */ r(k, { className:
|
|
1155
|
+
() => typeof e.description == "string" ? /* @__PURE__ */ r(k, { className: be.description, children: e.description }) : e.description,
|
|
1155
1156
|
[e.description]
|
|
1156
|
-
), v =
|
|
1157
|
-
return
|
|
1157
|
+
), v = Dt(e.fields, { formId: p, disabled: h });
|
|
1158
|
+
return xe(() => {
|
|
1158
1159
|
T && l && l();
|
|
1159
1160
|
}, [T, l]), /* @__PURE__ */ r(tt, { value: g, children: /* @__PURE__ */ r(y, { ref: i, direction: "column", gap: "2", className: u, asChild: !0, children: /* @__PURE__ */ b("form", { id: p, onSubmit: g.handleSubmit, children: [
|
|
1160
|
-
!f && /* @__PURE__ */ r(
|
|
1161
|
+
!f && /* @__PURE__ */ r(we, { children: /* @__PURE__ */ b(y, { direction: "column", gap: "1", children: [
|
|
1161
1162
|
I,
|
|
1162
1163
|
!d && C
|
|
1163
1164
|
] }) }),
|
|
@@ -1168,8 +1169,8 @@ const De = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), _t = (s,
|
|
|
1168
1169
|
] })
|
|
1169
1170
|
] }) }) });
|
|
1170
1171
|
})
|
|
1171
|
-
),
|
|
1172
|
-
|
|
1172
|
+
), On = z(
|
|
1173
|
+
Ie((s, i) => {
|
|
1173
1174
|
const { submission: e, showFormDescription: t = !1, showFormTitle: n = !0 } = s, o = O(It(e.form_revision)), { sdk: a } = Ct();
|
|
1174
1175
|
if (!o)
|
|
1175
1176
|
throw new Error(
|
|
@@ -1198,11 +1199,11 @@ const De = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), _t = (s,
|
|
|
1198
1199
|
}
|
|
1199
1200
|
);
|
|
1200
1201
|
})
|
|
1201
|
-
),
|
|
1202
|
-
favoriteIcon:
|
|
1203
|
-
regularIcon:
|
|
1204
|
-
}, je = "organization:", He = "user:",
|
|
1205
|
-
|
|
1202
|
+
), tn = "_favoriteIcon_1bixi_1", nn = "_regularIcon_1bixi_9", ht = {
|
|
1203
|
+
favoriteIcon: tn,
|
|
1204
|
+
regularIcon: nn
|
|
1205
|
+
}, je = "organization:", He = "user:", Mn = z(
|
|
1206
|
+
Ie((s, i) => {
|
|
1206
1207
|
const { maxResults: e = 20, ...t } = s, [n, o] = K(""), [a, c] = K(""), { sdk: l } = Ct(), f = w(() => {
|
|
1207
1208
|
const v = { maxResults: e, searchTerm: n };
|
|
1208
1209
|
return a && (a.startsWith(je) ? v.owner_organization = parseInt(a.slice(je.length)) : a.startsWith(He) && (v.owner_user = parseInt(a.slice(He.length)))), v;
|
|
@@ -1237,8 +1238,8 @@ const De = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), _t = (s,
|
|
|
1237
1238
|
}
|
|
1238
1239
|
)
|
|
1239
1240
|
] }),
|
|
1240
|
-
d.length > 0 && /* @__PURE__ */ r(
|
|
1241
|
-
|
|
1241
|
+
d.length > 0 && /* @__PURE__ */ r(Re.Root, { children: d.map((v) => /* @__PURE__ */ r(
|
|
1242
|
+
rn,
|
|
1242
1243
|
{
|
|
1243
1244
|
...t,
|
|
1244
1245
|
form: v,
|
|
@@ -1249,14 +1250,14 @@ const De = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), _t = (s,
|
|
|
1249
1250
|
/* @__PURE__ */ r(pe, { px: "3", children: /* @__PURE__ */ r(k, { size: "2", severity: "info", children: C }) })
|
|
1250
1251
|
] });
|
|
1251
1252
|
})
|
|
1252
|
-
),
|
|
1253
|
+
), rn = (s) => {
|
|
1253
1254
|
var h;
|
|
1254
1255
|
const { form: i, onSelectForm: e, isFavoriteEditable: t, handleToggleFavorite: n } = s, o = (h = O(Ft(i.owner_organization || -1))) == null ? void 0 : h.name, a = O(rt(i.owner_user || -1)), c = O(Tt).id, l = !!a && a.id === c, f = o ?? (l ? "You" : a == null ? void 0 : a.username) ?? "Unknown", d = F(
|
|
1255
1256
|
(p) => {
|
|
1256
1257
|
p.stopPropagation(), n();
|
|
1257
1258
|
},
|
|
1258
1259
|
[n]
|
|
1259
|
-
), u = /* @__PURE__ */ r(
|
|
1260
|
+
), u = /* @__PURE__ */ r(Re.Item, { onClick: () => e(i), asChild: !0, children: /* @__PURE__ */ b(y, { justify: "between", gap: "2", py: "2", px: "3", ...ii, children: [
|
|
1260
1261
|
/* @__PURE__ */ b(y, { grow: "1", align: "center", gap: "2", children: [
|
|
1261
1262
|
/* @__PURE__ */ r(
|
|
1262
1263
|
ge,
|
|
@@ -1279,10 +1280,10 @@ const De = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), _t = (s,
|
|
|
1279
1280
|
] })
|
|
1280
1281
|
] }) });
|
|
1281
1282
|
return i.latestRevision.description ? /* @__PURE__ */ r(li, { content: i.latestRevision.description, children: u }, i.offline_id) : u;
|
|
1282
|
-
},
|
|
1283
|
-
submissionsContainer:
|
|
1284
|
-
stopHorizontalOverflow:
|
|
1285
|
-
},
|
|
1283
|
+
}, on = "_submissionsContainer_9iirt_1", sn = "_stopHorizontalOverflow_9iirt_6", Mt = {
|
|
1284
|
+
submissionsContainer: on,
|
|
1285
|
+
stopHorizontalOverflow: sn
|
|
1286
|
+
}, ln = z(function(i) {
|
|
1286
1287
|
var v;
|
|
1287
1288
|
const { submission: e, onSubmissionClick: t, compact: n, labelType: o, rowDecorator: a } = i, c = O(Tt), l = O(rt("created_by" in e ? e.created_by : c.id)), f = Qe(e), d = zi(f) ? f.toLocaleTimeString([], {
|
|
1288
1289
|
hour: "2-digit",
|
|
@@ -1295,7 +1296,7 @@ const De = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), _t = (s,
|
|
|
1295
1296
|
fileSha1: (l == null ? void 0 : l.profile.file_sha1) ?? null
|
|
1296
1297
|
}), g = (l == null ? void 0 : l.username.charAt(0).toUpperCase()) ?? "?", T = u.revision === h, I = vi.useCallback(() => {
|
|
1297
1298
|
t && t({ submission: e });
|
|
1298
|
-
}, [e, t]), C = /* @__PURE__ */ r(
|
|
1299
|
+
}, [e, t]), C = /* @__PURE__ */ r(Re.Item, { onClick: I, asChild: !0, children: /* @__PURE__ */ b(y, { grow: "1", width: "100%", p: "2", gap: "2", justify: "between", children: [
|
|
1299
1300
|
/* @__PURE__ */ b(y, { gap: "2", align: "center", className: Mt.stopHorizontalOverflow, children: [
|
|
1300
1301
|
/* @__PURE__ */ r(ai, { src: p, size: "1", fallback: g }),
|
|
1301
1302
|
/* @__PURE__ */ r(k, { size: "2", noWrap: !0, children: o === "creator" ? (l || c).username : u.title })
|
|
@@ -1309,7 +1310,7 @@ const De = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), _t = (s,
|
|
|
1309
1310
|
}), Qe = (s) => {
|
|
1310
1311
|
const i = "created_at" in s ? s.created_at : s.submitted_at;
|
|
1311
1312
|
return new Date(i);
|
|
1312
|
-
},
|
|
1313
|
+
}, Nn = z(function(i) {
|
|
1313
1314
|
const {
|
|
1314
1315
|
formId: e,
|
|
1315
1316
|
submissions: t,
|
|
@@ -1328,7 +1329,7 @@ const De = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), _t = (s,
|
|
|
1328
1329
|
[f]
|
|
1329
1330
|
);
|
|
1330
1331
|
return /* @__PURE__ */ r(
|
|
1331
|
-
|
|
1332
|
+
Re.Root,
|
|
1332
1333
|
{
|
|
1333
1334
|
className: St(Mt.submissionsContainer, o),
|
|
1334
1335
|
size: "small",
|
|
@@ -1340,7 +1341,7 @@ const De = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), _t = (s,
|
|
|
1340
1341
|
] }),
|
|
1341
1342
|
after: a,
|
|
1342
1343
|
children: d == null ? void 0 : d.map((u, h) => /* @__PURE__ */ r(
|
|
1343
|
-
|
|
1344
|
+
ln,
|
|
1344
1345
|
{
|
|
1345
1346
|
submission: u,
|
|
1346
1347
|
compact: n,
|
|
@@ -1350,7 +1351,7 @@ const De = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), _t = (s,
|
|
|
1350
1351
|
))
|
|
1351
1352
|
}
|
|
1352
1353
|
);
|
|
1353
|
-
}),
|
|
1354
|
+
}), Rn = z(function(i) {
|
|
1354
1355
|
const { name: e, render: t } = i, { submitForm: n } = me(), [o, a, c] = Je(e);
|
|
1355
1356
|
return w(() => {
|
|
1356
1357
|
const l = (f) => c.setValue(f, !1);
|
|
@@ -1360,8 +1361,8 @@ const De = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), _t = (s,
|
|
|
1360
1361
|
patchValue: n
|
|
1361
1362
|
});
|
|
1362
1363
|
}, [n, c, o.value, t]);
|
|
1363
|
-
}),
|
|
1364
|
-
|
|
1364
|
+
}), Bn = z(
|
|
1365
|
+
Ie((s, i) => {
|
|
1365
1366
|
const { children: e, schema: t, values: n, onPatch: o, onError: a, ...c } = s, l = w(() => at(t.fields, n), [t.fields, n]), f = F(
|
|
1366
1367
|
(g) => {
|
|
1367
1368
|
const T = {};
|
|
@@ -1369,7 +1370,7 @@ const De = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), _t = (s,
|
|
|
1369
1370
|
const C = g[I];
|
|
1370
1371
|
C !== l[I] && C !== void 0 && (T[I] = C);
|
|
1371
1372
|
}
|
|
1372
|
-
|
|
1373
|
+
Oe(T) && o(T);
|
|
1373
1374
|
},
|
|
1374
1375
|
[l, o]
|
|
1375
1376
|
), d = F(
|
|
@@ -1386,14 +1387,14 @@ const De = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), _t = (s,
|
|
|
1386
1387
|
validateOnBlur: !1,
|
|
1387
1388
|
validateOnChange: !1
|
|
1388
1389
|
}), { errors: h, resetForm: p } = u;
|
|
1389
|
-
return
|
|
1390
|
-
|
|
1390
|
+
return xe(() => {
|
|
1391
|
+
Oe(h) && p({ values: l, errors: {} });
|
|
1391
1392
|
}, [h, l, p]), /* @__PURE__ */ r(tt, { value: u, children: /* @__PURE__ */ r("form", { ...c, ref: i, onSubmit: u.handleSubmit, children: e }) });
|
|
1392
1393
|
})
|
|
1393
1394
|
), Nt = {
|
|
1394
1395
|
...lt,
|
|
1395
1396
|
section: Q
|
|
1396
|
-
},
|
|
1397
|
+
}, an = z(function(i) {
|
|
1397
1398
|
const { field: e, setFieldType: t } = i, n = e.fieldTypeName, o = e.fieldTypeDescription, a = e.Icon;
|
|
1398
1399
|
return /* @__PURE__ */ b(y, { gap: "4", align: "center", children: [
|
|
1399
1400
|
/* @__PURE__ */ r(G, { type: "button", variant: "surface", onClick: t, style: { width: "135px" }, children: /* @__PURE__ */ b(y, { gap: "3", align: "center", grow: "1", children: [
|
|
@@ -1406,32 +1407,32 @@ const De = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), _t = (s,
|
|
|
1406
1407
|
["string", "text"],
|
|
1407
1408
|
["select", "multi-select", "upload"],
|
|
1408
1409
|
["boolean", "date", "number", "multi-string"]
|
|
1409
|
-
],
|
|
1410
|
+
], cn = Rt.length - 1, dn = z(function(i) {
|
|
1410
1411
|
const { setFieldType: e } = i;
|
|
1411
1412
|
return /* @__PURE__ */ r(y, { direction: "column", gap: "3", children: Rt.map((t, n) => /* @__PURE__ */ b(y, { direction: "column", gap: "3", children: [
|
|
1412
1413
|
/* @__PURE__ */ r(y, { direction: "column", gap: "2", children: t.map((o) => /* @__PURE__ */ r(
|
|
1413
|
-
|
|
1414
|
+
an,
|
|
1414
1415
|
{
|
|
1415
1416
|
field: lt[o],
|
|
1416
1417
|
setFieldType: () => e(o)
|
|
1417
1418
|
},
|
|
1418
1419
|
o
|
|
1419
1420
|
)) }),
|
|
1420
|
-
n <
|
|
1421
|
+
n < cn && /* @__PURE__ */ r(ci, { size: "4" })
|
|
1421
1422
|
] }, n)) });
|
|
1422
|
-
}),
|
|
1423
|
+
}), un = (s) => (i) => {
|
|
1423
1424
|
if (!(!i || typeof i != "string") && s.includes(i.trim()))
|
|
1424
1425
|
return "This name is already taken.";
|
|
1425
|
-
},
|
|
1426
|
+
}, fn = (s, i) => {
|
|
1426
1427
|
const e = [
|
|
1427
|
-
new
|
|
1428
|
+
new ye({
|
|
1428
1429
|
label: "Label",
|
|
1429
1430
|
required: !0,
|
|
1430
1431
|
maxLength: 200,
|
|
1431
1432
|
identifier: "label",
|
|
1432
|
-
fieldValidators: [
|
|
1433
|
+
fieldValidators: [un(s)]
|
|
1433
1434
|
}),
|
|
1434
|
-
new
|
|
1435
|
+
new ve({
|
|
1435
1436
|
label: "Description",
|
|
1436
1437
|
required: !1,
|
|
1437
1438
|
maxLength: 1e3,
|
|
@@ -1442,10 +1443,10 @@ const De = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), _t = (s,
|
|
|
1442
1443
|
...e,
|
|
1443
1444
|
new ue({ label: "Required", description: null, required: !1, identifier: "required" })
|
|
1444
1445
|
];
|
|
1445
|
-
},
|
|
1446
|
+
}, mn = z(function(i) {
|
|
1446
1447
|
const { fieldType: e, handleCancel: t, handleCreateField: n, defaultField: o, conditionalSourceFields: a } = i, c = Nt[e], l = me(), f = w(() => {
|
|
1447
1448
|
const d = Pt(l.values.fields).filter((h) => h !== (o == null ? void 0 : o.label));
|
|
1448
|
-
let u =
|
|
1449
|
+
let u = fn(d, e);
|
|
1449
1450
|
if (c === Q) {
|
|
1450
1451
|
if (a === void 0)
|
|
1451
1452
|
throw new Error("Conditional source fields must be provided when changing sections.");
|
|
@@ -1495,12 +1496,12 @@ const De = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), _t = (s,
|
|
|
1495
1496
|
let U;
|
|
1496
1497
|
if (!Array.isArray(q))
|
|
1497
1498
|
throw new Error("Parent path must point to an array.");
|
|
1498
|
-
a ? U =
|
|
1499
|
+
a ? U = qi(q, t, Z) : U = Et(q, t, Z), h(e, U).then(), P();
|
|
1499
1500
|
},
|
|
1500
1501
|
[a, d, p, e, h, t]
|
|
1501
1502
|
), L = F(
|
|
1502
|
-
(x) => g ? /* @__PURE__ */ r(
|
|
1503
|
-
|
|
1503
|
+
(x) => g ? /* @__PURE__ */ r(dn, { setFieldType: f }) : /* @__PURE__ */ r(
|
|
1504
|
+
mn,
|
|
1504
1505
|
{
|
|
1505
1506
|
conditionalSourceFields: c,
|
|
1506
1507
|
handleCancel: C,
|
|
@@ -1512,7 +1513,7 @@ const De = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), _t = (s,
|
|
|
1512
1513
|
[c, C, V, o, g, d]
|
|
1513
1514
|
);
|
|
1514
1515
|
return /* @__PURE__ */ r(di, { onCloseInterrupt: v, title: T, description: I, content: L, children: n });
|
|
1515
|
-
}),
|
|
1516
|
+
}), hn = ({ children: s }) => /* @__PURE__ */ r(bt, { children: s }), Bt = z(function(i) {
|
|
1516
1517
|
const { remove: e, editProps: t, insertAfterProps: n, duplicateProps: o, type: a } = i, c = w(
|
|
1517
1518
|
() => [
|
|
1518
1519
|
{
|
|
@@ -1537,7 +1538,7 @@ const De = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), _t = (s,
|
|
|
1537
1538
|
{
|
|
1538
1539
|
Wrapper: he,
|
|
1539
1540
|
wrapperProps: n,
|
|
1540
|
-
Icon:
|
|
1541
|
+
Icon: Me,
|
|
1541
1542
|
text: `Add ${a === "section" ? "section" : "field"}`
|
|
1542
1543
|
}
|
|
1543
1544
|
],
|
|
@@ -1550,7 +1551,7 @@ const De = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), _t = (s,
|
|
|
1550
1551
|
closeOnSelect: !1,
|
|
1551
1552
|
items: c.map((l) => {
|
|
1552
1553
|
var d;
|
|
1553
|
-
const f = l.Wrapper ??
|
|
1554
|
+
const f = l.Wrapper ?? hn;
|
|
1554
1555
|
return {
|
|
1555
1556
|
...l.buttonProps,
|
|
1556
1557
|
onSelect: (d = l.buttonProps) == null ? void 0 : d.onClick,
|
|
@@ -1562,7 +1563,7 @@ const De = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), _t = (s,
|
|
|
1562
1563
|
}).filter((l) => l !== null)
|
|
1563
1564
|
}
|
|
1564
1565
|
) });
|
|
1565
|
-
}), qe = "form-builder",
|
|
1566
|
+
}), qe = "form-builder", pn = z(function(i) {
|
|
1566
1567
|
const { field: e, index: t, sectionIndex: n, takenLabels: o, remove: a } = i, c = w(() => Be(e), [e]), l = De(c, { formId: qe, disabled: !0 }), f = F(
|
|
1567
1568
|
(p) => {
|
|
1568
1569
|
if (p.label === null)
|
|
@@ -1594,7 +1595,7 @@ const De = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), _t = (s,
|
|
|
1594
1595
|
[t, n]
|
|
1595
1596
|
);
|
|
1596
1597
|
return /* @__PURE__ */ r(nt, { draggableId: e.identifier, index: t, children: (p) => /* @__PURE__ */ r(
|
|
1597
|
-
|
|
1598
|
+
we,
|
|
1598
1599
|
{
|
|
1599
1600
|
ref: p.innerRef,
|
|
1600
1601
|
...p.draggableProps,
|
|
@@ -1615,7 +1616,7 @@ const De = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), _t = (s,
|
|
|
1615
1616
|
] })
|
|
1616
1617
|
}
|
|
1617
1618
|
) });
|
|
1618
|
-
}),
|
|
1619
|
+
}), gn = (s) => {
|
|
1619
1620
|
const { identifier: i, condition: e } = s, t = { primary: "var(--gray-a4)", hover: "var(--primary-color)" }, [n, o] = K(t.primary), [a, c] = K(0), l = F(() => {
|
|
1620
1621
|
o(t.hover), c(1);
|
|
1621
1622
|
}, [t.hover]), f = F(() => {
|
|
@@ -1657,12 +1658,12 @@ const De = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), _t = (s,
|
|
|
1657
1658
|
}
|
|
1658
1659
|
)
|
|
1659
1660
|
] }) : null;
|
|
1660
|
-
},
|
|
1661
|
-
var Z, q, U, E, R, Y,
|
|
1661
|
+
}, bn = z(function(i) {
|
|
1662
|
+
var Z, q, U, E, R, Y, Ce, Fe, Te;
|
|
1662
1663
|
const { field: e, index: t, dropState: n, conditionalFieldCounts: o } = i, a = (Z = n[e.identifier]) == null ? void 0 : Z.disabled, { setFieldValue: c, values: l } = me(), f = gi(), d = Pt(l.fields), u = F(
|
|
1663
1664
|
(A, S) => {
|
|
1664
|
-
for (const
|
|
1665
|
-
const $ = S.indexOf(
|
|
1665
|
+
for (const _ of A) {
|
|
1666
|
+
const $ = S.indexOf(_);
|
|
1666
1667
|
c(`fields.${$}.condition`, null).then(), c(`fields.${$}.conditional`, !1).then();
|
|
1667
1668
|
}
|
|
1668
1669
|
},
|
|
@@ -1673,45 +1674,45 @@ const De = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), _t = (s,
|
|
|
1673
1674
|
const S = e.fields[A];
|
|
1674
1675
|
if (!S)
|
|
1675
1676
|
throw new Error("Could not find field to remove.");
|
|
1676
|
-
const
|
|
1677
|
-
for (const
|
|
1678
|
-
(($ =
|
|
1677
|
+
const _ = [];
|
|
1678
|
+
for (const D of l.fields)
|
|
1679
|
+
(($ = D.condition) == null ? void 0 : $.identifier) === S.identifier && _.push(D);
|
|
1679
1680
|
return {
|
|
1680
1681
|
removing: S,
|
|
1681
|
-
affectedSections:
|
|
1682
|
-
action: () => c(`fields.${t}.fields`,
|
|
1682
|
+
affectedSections: _,
|
|
1683
|
+
action: () => c(`fields.${t}.fields`, Pe(e.fields, A))
|
|
1683
1684
|
};
|
|
1684
1685
|
},
|
|
1685
1686
|
[e.fields, l.fields, c, t]
|
|
1686
1687
|
), p = F(
|
|
1687
1688
|
(A) => {
|
|
1688
|
-
const { affectedSections: S, action:
|
|
1689
|
-
|
|
1689
|
+
const { affectedSections: S, action: _, removing: $ } = h(A), D = () => {
|
|
1690
|
+
_().then(), u(S, l.fields);
|
|
1690
1691
|
};
|
|
1691
1692
|
if (S.length > 0) {
|
|
1692
|
-
const We = S.map((
|
|
1693
|
+
const We = S.map((Se) => Se.label).join(", ");
|
|
1693
1694
|
return f({
|
|
1694
1695
|
title: "Remove condition?",
|
|
1695
1696
|
description: `${$.label} is being used as a condition, deleting it will remove the condition from the ${We} section(s).`,
|
|
1696
1697
|
severity: "danger",
|
|
1697
1698
|
actionText: "Remove",
|
|
1698
|
-
onAction:
|
|
1699
|
+
onAction: D
|
|
1699
1700
|
});
|
|
1700
1701
|
}
|
|
1701
|
-
|
|
1702
|
+
D();
|
|
1702
1703
|
},
|
|
1703
1704
|
[h, u, l.fields, f]
|
|
1704
1705
|
), g = F(() => {
|
|
1705
|
-
const S = e.fields.map((
|
|
1706
|
+
const S = e.fields.map((ze, qt) => h(qt)).flatMap((ze) => ze.affectedSections), _ = S.length ? "Remove fields and conditions?" : "Remove fields?", $ = e.fields.length, D = S.map((ze) => ze.label).join(", "), We = S.length ? `Deleting this section will remove the ${$} field(s) it contains and will remove the conditions from following sections: ${D}` : `Deleting this section will remove the ${$} field(s) it contains.`, Se = Pe(l.fields, t), dt = () => c("fields", Se);
|
|
1706
1707
|
if (S.length > 0)
|
|
1707
1708
|
return f({
|
|
1708
|
-
title:
|
|
1709
|
+
title: _,
|
|
1709
1710
|
description: We,
|
|
1710
1711
|
severity: "danger",
|
|
1711
1712
|
actionText: "Remove",
|
|
1712
1713
|
onAction: () => {
|
|
1713
1714
|
dt().then(() => {
|
|
1714
|
-
u(S,
|
|
1715
|
+
u(S, Se);
|
|
1715
1716
|
});
|
|
1716
1717
|
}
|
|
1717
1718
|
});
|
|
@@ -1728,15 +1729,15 @@ const De = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), _t = (s,
|
|
|
1728
1729
|
(A) => {
|
|
1729
1730
|
if (A.label === null)
|
|
1730
1731
|
throw new Error(`Expected a label for field ${A.identifier}`);
|
|
1731
|
-
const S = Ze(A.label, d),
|
|
1732
|
-
const
|
|
1732
|
+
const S = Ze(A.label, d), _ = A.fields.map(($) => {
|
|
1733
|
+
const D = Ze($.label, d);
|
|
1733
1734
|
return {
|
|
1734
1735
|
...$,
|
|
1735
|
-
label:
|
|
1736
|
-
identifier: At(void 0,
|
|
1736
|
+
label: D,
|
|
1737
|
+
identifier: At(void 0, D)
|
|
1737
1738
|
};
|
|
1738
1739
|
});
|
|
1739
|
-
return { ...A, label: S, fields:
|
|
1740
|
+
return { ...A, label: S, fields: _, identifier: "" };
|
|
1740
1741
|
},
|
|
1741
1742
|
[d]
|
|
1742
1743
|
), I = w(
|
|
@@ -1745,15 +1746,15 @@ const De = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), _t = (s,
|
|
|
1745
1746
|
parentPath: "fields",
|
|
1746
1747
|
initial: e,
|
|
1747
1748
|
editing: !0,
|
|
1748
|
-
conditionalSourceFields:
|
|
1749
|
+
conditionalSourceFields: Ee(l.fields, t)
|
|
1749
1750
|
}),
|
|
1750
1751
|
[e, t, l.fields]
|
|
1751
1752
|
), C = w(
|
|
1752
1753
|
() => ({
|
|
1753
1754
|
index: t + 1,
|
|
1754
1755
|
parentPath: "fields",
|
|
1755
|
-
initial:
|
|
1756
|
-
conditionalSourceFields:
|
|
1756
|
+
initial: Le(),
|
|
1757
|
+
conditionalSourceFields: Ee(l.fields, t + 1)
|
|
1757
1758
|
}),
|
|
1758
1759
|
[t, l.fields]
|
|
1759
1760
|
), v = w(
|
|
@@ -1768,7 +1769,7 @@ const De = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), _t = (s,
|
|
|
1768
1769
|
index: t + 1,
|
|
1769
1770
|
parentPath: "fields",
|
|
1770
1771
|
initial: T(e),
|
|
1771
|
-
conditionalSourceFields:
|
|
1772
|
+
conditionalSourceFields: Ee(l.fields, t + 1)
|
|
1772
1773
|
}),
|
|
1773
1774
|
[T, e, t, l.fields]
|
|
1774
1775
|
), L = w(
|
|
@@ -1780,8 +1781,8 @@ const De = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), _t = (s,
|
|
|
1780
1781
|
), x = Array.isArray((U = e.condition) == null ? void 0 : U.value) ? "contains all of" : "equals";
|
|
1781
1782
|
if (Xe((E = e.condition) == null ? void 0 : E.value))
|
|
1782
1783
|
throw new Error("File values are not supported for conditions.");
|
|
1783
|
-
const P = Array.isArray((R = e.condition) == null ? void 0 : R.value) ? (
|
|
1784
|
-
const S = o.filter((
|
|
1784
|
+
const P = Array.isArray((R = e.condition) == null ? void 0 : R.value) ? (Ce = (Y = e.condition) == null ? void 0 : Y.value) == null ? void 0 : Ce.map((A) => typeof A == "string" ? A : A.label).join(", ") : (Te = (Fe = e.condition) == null ? void 0 : Fe.value) == null ? void 0 : Te.toString(), N = () => {
|
|
1785
|
+
const S = o.filter((D) => D !== null).length, _ = o[t] ?? 0, $ = 2 / S * _;
|
|
1785
1786
|
return /* @__PURE__ */ r(
|
|
1786
1787
|
"div",
|
|
1787
1788
|
{
|
|
@@ -1796,13 +1797,14 @@ const De = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), _t = (s,
|
|
|
1796
1797
|
return /* @__PURE__ */ r(nt, { draggableId: e.identifier, index: t, children: (A) => /* @__PURE__ */ b(
|
|
1797
1798
|
y,
|
|
1798
1799
|
{
|
|
1800
|
+
className: be.sectionContainer,
|
|
1799
1801
|
direction: "row",
|
|
1800
1802
|
justify: "center",
|
|
1801
1803
|
align: "center",
|
|
1802
1804
|
mb: "4",
|
|
1803
1805
|
children: [
|
|
1804
1806
|
/* @__PURE__ */ r(
|
|
1805
|
-
|
|
1807
|
+
we,
|
|
1806
1808
|
{
|
|
1807
1809
|
ref: A.innerRef,
|
|
1808
1810
|
...A.draggableProps,
|
|
@@ -1812,8 +1814,8 @@ const De = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), _t = (s,
|
|
|
1812
1814
|
children: /* @__PURE__ */ b(y, { gap: "3", justify: "between", align: "center", children: [
|
|
1813
1815
|
/* @__PURE__ */ b(y, { direction: "column", gap: "2", grow: "1", children: [
|
|
1814
1816
|
/* @__PURE__ */ b(y, { direction: "column", children: [
|
|
1815
|
-
/* @__PURE__ */ r(
|
|
1816
|
-
/* @__PURE__ */ r(k, { className:
|
|
1817
|
+
/* @__PURE__ */ r(Ne, { as: "h3", size: "3", children: e.label }),
|
|
1818
|
+
/* @__PURE__ */ r(k, { className: be.description, children: e.description })
|
|
1817
1819
|
] }),
|
|
1818
1820
|
e.condition && /* @__PURE__ */ r(k, { size: "1", children: /* @__PURE__ */ b(bi, { children: [
|
|
1819
1821
|
"Display only if ",
|
|
@@ -1837,20 +1839,20 @@ const De = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), _t = (s,
|
|
|
1837
1839
|
direction: "column",
|
|
1838
1840
|
gap: "0",
|
|
1839
1841
|
children: [
|
|
1840
|
-
e.fields.map((
|
|
1841
|
-
|
|
1842
|
+
e.fields.map((_, $) => /* @__PURE__ */ r(
|
|
1843
|
+
pn,
|
|
1842
1844
|
{
|
|
1843
|
-
field:
|
|
1845
|
+
field: _,
|
|
1844
1846
|
index: $,
|
|
1845
1847
|
sectionIndex: t,
|
|
1846
1848
|
remove: () => p($),
|
|
1847
1849
|
takenLabels: d
|
|
1848
1850
|
},
|
|
1849
|
-
|
|
1851
|
+
_.identifier
|
|
1850
1852
|
)),
|
|
1851
1853
|
S.placeholder,
|
|
1852
1854
|
/* @__PURE__ */ r(he, { ...v, children: /* @__PURE__ */ b(G, { type: "button", variant: "outline", children: [
|
|
1853
|
-
/* @__PURE__ */ r(
|
|
1855
|
+
/* @__PURE__ */ r(Me, {}),
|
|
1854
1856
|
" Add a field"
|
|
1855
1857
|
] }) })
|
|
1856
1858
|
]
|
|
@@ -1873,11 +1875,11 @@ const De = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), _t = (s,
|
|
|
1873
1875
|
}
|
|
1874
1876
|
),
|
|
1875
1877
|
o.some((S) => S !== null) && N(),
|
|
1876
|
-
e.condition && /* @__PURE__ */ r(
|
|
1878
|
+
e.condition && /* @__PURE__ */ r(gn, { identifier: e.identifier, condition: e.condition })
|
|
1877
1879
|
]
|
|
1878
1880
|
}
|
|
1879
1881
|
) });
|
|
1880
|
-
}),
|
|
1882
|
+
}), yn = (s, i) => {
|
|
1881
1883
|
var t;
|
|
1882
1884
|
const e = { ...s };
|
|
1883
1885
|
switch (i.type) {
|
|
@@ -1892,7 +1894,7 @@ const De = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), _t = (s,
|
|
|
1892
1894
|
case "update":
|
|
1893
1895
|
return i.state;
|
|
1894
1896
|
}
|
|
1895
|
-
},
|
|
1897
|
+
}, vn = (s, i) => {
|
|
1896
1898
|
if (i)
|
|
1897
1899
|
for (let e = 0; e < s.length; e++) {
|
|
1898
1900
|
const t = s[e];
|
|
@@ -1913,7 +1915,7 @@ const De = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), _t = (s,
|
|
|
1913
1915
|
(t = a.condition) != null && t.identifier && l.add(a.condition.identifier), i[a.identifier] = {
|
|
1914
1916
|
disabled: !1,
|
|
1915
1917
|
conditionFields: l,
|
|
1916
|
-
conditionIndex:
|
|
1918
|
+
conditionIndex: vn(s, (n = a.condition) == null ? void 0 : n.identifier),
|
|
1917
1919
|
index: o,
|
|
1918
1920
|
label: a.label
|
|
1919
1921
|
};
|
|
@@ -1923,9 +1925,9 @@ const De = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), _t = (s,
|
|
|
1923
1925
|
for (const [e, t] of Object.entries(s))
|
|
1924
1926
|
if (t.identifier === i)
|
|
1925
1927
|
return [t, e];
|
|
1926
|
-
},
|
|
1927
|
-
const { values: i, setFieldValue: e } = me(), [t, n] = xi(
|
|
1928
|
-
|
|
1928
|
+
}, wn = z(function() {
|
|
1929
|
+
const { values: i, setFieldValue: e } = me(), [t, n] = xi(yn, i.fields, pt), { showInfo: o } = yi();
|
|
1930
|
+
xe(() => {
|
|
1929
1931
|
n({ type: "update", state: pt(i.fields) });
|
|
1930
1932
|
}, [n, i.fields]);
|
|
1931
1933
|
const a = F((d) => {
|
|
@@ -1964,7 +1966,7 @@ const De = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), _t = (s,
|
|
|
1964
1966
|
const L = I.fields[u.index];
|
|
1965
1967
|
if (!L)
|
|
1966
1968
|
throw new Error("Could not find field to reorder.");
|
|
1967
|
-
e(`fields.${C}.fields`,
|
|
1969
|
+
e(`fields.${C}.fields`, Pe(I.fields, u.index)).then(), e(
|
|
1968
1970
|
`fields.${V}.fields`,
|
|
1969
1971
|
Et(v.fields, h.index, L)
|
|
1970
1972
|
).then();
|
|
@@ -1975,8 +1977,8 @@ const De = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), _t = (s,
|
|
|
1975
1977
|
() => ({
|
|
1976
1978
|
index: i.fields.length,
|
|
1977
1979
|
parentPath: "fields",
|
|
1978
|
-
initial:
|
|
1979
|
-
conditionalSourceFields:
|
|
1980
|
+
initial: Le(),
|
|
1981
|
+
conditionalSourceFields: Ee(i.fields, i.fields.length)
|
|
1980
1982
|
}),
|
|
1981
1983
|
[i.fields]
|
|
1982
1984
|
), f = () => {
|
|
@@ -1992,7 +1994,7 @@ const De = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), _t = (s,
|
|
|
1992
1994
|
gap: "0",
|
|
1993
1995
|
children: [
|
|
1994
1996
|
i.fields.map((u, h) => /* @__PURE__ */ r(
|
|
1995
|
-
|
|
1997
|
+
bn,
|
|
1996
1998
|
{
|
|
1997
1999
|
field: u,
|
|
1998
2000
|
index: h,
|
|
@@ -2003,45 +2005,45 @@ const De = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), _t = (s,
|
|
|
2003
2005
|
)),
|
|
2004
2006
|
d.placeholder,
|
|
2005
2007
|
/* @__PURE__ */ r(he, { ...l, children: /* @__PURE__ */ b(G, { type: "button", variant: "outline", children: [
|
|
2006
|
-
/* @__PURE__ */ r(
|
|
2008
|
+
/* @__PURE__ */ r(Me, {}),
|
|
2007
2009
|
" Add a section"
|
|
2008
2010
|
] }) })
|
|
2009
2011
|
]
|
|
2010
2012
|
}
|
|
2011
2013
|
) }) });
|
|
2012
|
-
}),
|
|
2014
|
+
}), xn = {
|
|
2013
2015
|
title: "",
|
|
2014
2016
|
description: "",
|
|
2015
2017
|
fields: []
|
|
2016
|
-
},
|
|
2018
|
+
}, In = new ye({
|
|
2017
2019
|
label: "Title",
|
|
2018
2020
|
minLength: 0,
|
|
2019
2021
|
maxLength: 100,
|
|
2020
2022
|
required: !0,
|
|
2021
2023
|
identifier: "title"
|
|
2022
|
-
}),
|
|
2024
|
+
}), Cn = { formId: qe, placeholder: "Give your form a title." }, Fn = new ve({
|
|
2023
2025
|
label: "Description",
|
|
2024
2026
|
minLength: 0,
|
|
2025
2027
|
maxLength: 1e3,
|
|
2026
2028
|
required: !1,
|
|
2027
2029
|
identifier: "description"
|
|
2028
|
-
}),
|
|
2030
|
+
}), Tn = { formId: qe, placeholder: "Explain the purpose of this form." }, Sn = () => {
|
|
2029
2031
|
alert("This is a form preview, your data will not be saved.");
|
|
2030
|
-
},
|
|
2031
|
-
|
|
2032
|
+
}, qn = z(
|
|
2033
|
+
Ie((s, i) => {
|
|
2032
2034
|
const { onCancel: e, onSave: t, revision: n } = s, o = n ? "Edit form" : "Create a new form", { heading: a = o } = s, c = F((p) => {
|
|
2033
2035
|
const g = {};
|
|
2034
|
-
if (p.title || (g.title = "Title is required."), (!p.fields || p.fields.length === 0) && (g.fields = "At least one field is required."),
|
|
2036
|
+
if (p.title || (g.title = "Title is required."), (!p.fields || p.fields.length === 0) && (g.fields = "At least one field is required."), Oe(g))
|
|
2035
2037
|
return g;
|
|
2036
2038
|
}, []), l = et({
|
|
2037
|
-
initialValues:
|
|
2039
|
+
initialValues: Bi(n) ?? xn,
|
|
2038
2040
|
validate: c,
|
|
2039
2041
|
onSubmit: (p) => t(p),
|
|
2040
2042
|
// only validate the entire for on submit
|
|
2041
2043
|
validateOnChange: !1,
|
|
2042
2044
|
validateOnBlur: !1
|
|
2043
|
-
}), f = w(() => Vt(l.values), [l.values]), d = De(
|
|
2044
|
-
() => typeof a == "object" ? a : /* @__PURE__ */ r(
|
|
2045
|
+
}), f = w(() => Vt(l.values), [l.values]), d = De(In, Cn), u = De(Fn, Tn), h = w(
|
|
2046
|
+
() => typeof a == "object" ? a : /* @__PURE__ */ r(Ne, { children: a }),
|
|
2045
2047
|
[a]
|
|
2046
2048
|
);
|
|
2047
2049
|
return /* @__PURE__ */ r(J.Root, { ref: i, defaultValue: "edit", children: /* @__PURE__ */ b(y, { direction: "column", gap: "2", children: [
|
|
@@ -2063,7 +2065,7 @@ const De = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), _t = (s,
|
|
|
2063
2065
|
/* @__PURE__ */ b(tt, { value: l, children: [
|
|
2064
2066
|
d,
|
|
2065
2067
|
u,
|
|
2066
|
-
/* @__PURE__ */ r(
|
|
2068
|
+
/* @__PURE__ */ r(wn, {}),
|
|
2067
2069
|
/* @__PURE__ */ r(k, { severity: "danger", size: "1", children: typeof l.errors.fields == "string" && l.errors.fields })
|
|
2068
2070
|
] }),
|
|
2069
2071
|
/* @__PURE__ */ b(y, { justify: "end", gap: "2", children: [
|
|
@@ -2072,40 +2074,40 @@ const De = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), _t = (s,
|
|
|
2072
2074
|
] })
|
|
2073
2075
|
] }) })
|
|
2074
2076
|
] }),
|
|
2075
|
-
/* @__PURE__ */ r(J.Content, { value: "preview", children: /* @__PURE__ */ r(ct, { schema: f, onSubmit:
|
|
2077
|
+
/* @__PURE__ */ r(J.Content, { value: "preview", children: /* @__PURE__ */ r(ct, { schema: f, onSubmit: Sn }) })
|
|
2076
2078
|
] }) });
|
|
2077
2079
|
})
|
|
2078
2080
|
);
|
|
2079
2081
|
export {
|
|
2080
2082
|
ue as BooleanField,
|
|
2081
|
-
|
|
2083
|
+
_i as BooleanInput,
|
|
2082
2084
|
Ge as DateField,
|
|
2083
|
-
|
|
2085
|
+
Oi as DateInput,
|
|
2084
2086
|
Q as FieldSection,
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
+
Mn as FormBrowser,
|
|
2088
|
+
qn as FormBuilder,
|
|
2087
2089
|
ct as FormRenderer,
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2090
|
+
Nn as FormSubmissionBrowser,
|
|
2091
|
+
On as FormSubmissionViewer,
|
|
2092
|
+
Ve as MultiSelectField,
|
|
2093
|
+
Hi as MultiSelectInput,
|
|
2094
|
+
$e as MultiStringField,
|
|
2095
|
+
Wi as MultiStringInput,
|
|
2094
2096
|
X as NumberField,
|
|
2095
2097
|
Di as NumberInput,
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2098
|
+
Rn as PatchField,
|
|
2099
|
+
Bn as PatchFormProvider,
|
|
2100
|
+
ke as SelectField,
|
|
2101
|
+
Ri as SelectInput,
|
|
2102
|
+
ye as StringField,
|
|
2103
|
+
Mi as StringInput,
|
|
2104
|
+
ve as TextField,
|
|
2105
|
+
Ni as TextInput,
|
|
2104
2106
|
Be as deserialize,
|
|
2105
2107
|
kt as deserializeField,
|
|
2106
2108
|
Vt as formRevisionToSchema,
|
|
2107
|
-
|
|
2109
|
+
_t as isConditionMet,
|
|
2108
2110
|
De as useFieldInput,
|
|
2109
|
-
|
|
2111
|
+
Dt as useFieldInputs,
|
|
2110
2112
|
Xe as valueIsFile
|
|
2111
2113
|
};
|