@overmap-ai/forms 1.0.4-conditional-arrows-2.5 → 1.0.4-conditional-arrows-2.7
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 +522 -521
- package/dist/forms.umd.cjs +1 -1
- package/package.json +2 -2
package/dist/forms.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var m = (s, i, e) => (
|
|
4
|
-
import { jsx as r, jsxs as g, Fragment as
|
|
5
|
-
import { Flex as y, Text as $, useSeverityColor as me, Checkbox as
|
|
6
|
-
import { useField as
|
|
7
|
-
import
|
|
8
|
-
import { DragDropContext as
|
|
9
|
-
import { slugify as
|
|
1
|
+
var Gt = Object.defineProperty;
|
|
2
|
+
var Kt = (s, i, e) => i in s ? Gt(s, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[i] = e;
|
|
3
|
+
var m = (s, i, e) => (Kt(s, typeof i != "symbol" ? i + "" : i, e), e);
|
|
4
|
+
import { jsx as r, jsxs as g, Fragment as Je } from "react/jsx-runtime";
|
|
5
|
+
import { Flex as y, Text as $, useSeverityColor as me, Checkbox as Yt, CheckCircledIcon as Zt, TextField as ae, FontFamilyIcon as Xt, CalendarIcon as Qt, InputIcon as Jt, TextArea as ei, RowsIcon as ti, Select as It, Box as ge, IconButton as ce, PlusIcon as Oe, Badge as Ue, Cross1Icon as Ct, ListBulletIcon as ii, DropdownMenuIcon as ni, MultiSelect as ri, CheckboxIcon as oi, Card as we, Heading as Me, Button as G, UploadIcon as Ft, ButtonList as Re, divButtonProps as si, StarFilledIcon as li, StarIcon as ai, QuestionMarkCircledIcon as ci, PersonIcon as di, Tooltip as ui, Avatar as fi, Separator as mi, Dialog as pi, Pencil1Icon as hi, TrashIcon as gi, CopyIcon as bi, DragHandleDots2Icon as yi, DropdownMenu as wi, DotsVerticalIcon as vi, useAlertDialog as xi, Em as Ii, Strong as pt, useToast as Ci, Tabs as Q } from "@overmap-ai/blocks";
|
|
6
|
+
import { useField as et, useFormikContext as pe, useFormik as tt, FormikProvider as it } from "formik";
|
|
7
|
+
import Fi, { useMemo as x, memo as S, useCallback as T, useState as de, useEffect as ve, useRef as Ti, forwardRef as xe, useReducer as Si } from "react";
|
|
8
|
+
import { DragDropContext as Tt, Droppable as nt, Draggable as rt } from "@hello-pangea/dnd";
|
|
9
|
+
import { slugify as zi, useAppSelector as _, selectFormRevision as St, useSDK as zt, selectSubmissionAttachments as Ei, selectFilteredUserForms as Ai, selectUserFormMapping as Li, selectOrganization as Et, selectUser as ot, selectNumberOfUserForms as Pi, selectCurrentUser as At, classNames as Lt, isToday as ki, getLocalDateString as $i, selectLatestFormRevision as Vi, useFileSrc as Di, selectSubmissionsForForm as _i, selectAppearance as Oi } from "@overmap-ai/core";
|
|
10
10
|
import ue from "lodash.get";
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
class
|
|
11
|
+
import st from "lodash.set";
|
|
12
|
+
import ht from "react-xarrows";
|
|
13
|
+
class Pt {
|
|
14
14
|
constructor(i) {
|
|
15
15
|
m(this, "type");
|
|
16
16
|
m(this, "identifier");
|
|
@@ -34,7 +34,7 @@ class Et {
|
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
class M extends
|
|
37
|
+
class M extends Pt {
|
|
38
38
|
constructor(e) {
|
|
39
39
|
const { label: t, required: n, fieldValidators: o = [], formValidators: a = [], ...c } = e;
|
|
40
40
|
super(c);
|
|
@@ -91,22 +91,22 @@ class M extends Et {
|
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
m(M, "fieldTypeName"), m(M, "fieldTypeDescription");
|
|
94
|
-
const
|
|
95
|
-
description:
|
|
96
|
-
},
|
|
94
|
+
const Mi = "_description_17zed_1", Ne = {
|
|
95
|
+
description: Mi
|
|
96
|
+
}, q = (s) => {
|
|
97
97
|
const { label: i, children: e, severity: t, inputId: n, labelId: o, flexProps: a } = s;
|
|
98
98
|
return /* @__PURE__ */ r(y, { direction: "column", gap: "1", asChild: !0, ...a, children: /* @__PURE__ */ g("label", { htmlFor: n, children: [
|
|
99
99
|
/* @__PURE__ */ r($, { severity: t, id: o, children: i }),
|
|
100
100
|
e
|
|
101
101
|
] }) });
|
|
102
|
-
},
|
|
102
|
+
}, W = (s) => {
|
|
103
103
|
const { helpText: i, children: e, severity: t } = s;
|
|
104
104
|
return /* @__PURE__ */ g(y, { direction: "column", gap: "1", children: [
|
|
105
105
|
e,
|
|
106
|
-
/* @__PURE__ */ r(y, { direction: "column", children: /* @__PURE__ */ r($, { size: "1", severity: t, className:
|
|
106
|
+
/* @__PURE__ */ r(y, { direction: "column", children: /* @__PURE__ */ r($, { size: "1", severity: t, className: Ne.description, children: i }) })
|
|
107
107
|
] });
|
|
108
|
-
},
|
|
109
|
-
const { id: i, field: e, formId: t, ...n } = s, [o, a, c] =
|
|
108
|
+
}, H = (s) => {
|
|
109
|
+
const { id: i, field: e, formId: t, ...n } = s, [o, a, c] = et(e.getId()), { touched: l } = a, f = a.error ?? e.description, d = a.error ? "danger" : void 0, u = i ?? `${t}-${e.getId()}-input`, p = `${u}-label`, h = e.required ? `${e.label} *` : e.label, b = x(() => ({
|
|
110
110
|
...o,
|
|
111
111
|
onChange: (C) => {
|
|
112
112
|
const w = e.getValueFromChangeEvent(C);
|
|
@@ -121,18 +121,18 @@ const Vi = "_description_17zed_1", Re = {
|
|
|
121
121
|
helpText: f,
|
|
122
122
|
severity: d,
|
|
123
123
|
inputId: u,
|
|
124
|
-
labelId:
|
|
125
|
-
label:
|
|
124
|
+
labelId: p,
|
|
125
|
+
label: h,
|
|
126
126
|
fieldProps: b,
|
|
127
127
|
helpers: c,
|
|
128
128
|
field: e
|
|
129
129
|
},
|
|
130
|
-
{ ...n, "aria-labelledby":
|
|
130
|
+
{ ...n, "aria-labelledby": p }
|
|
131
131
|
];
|
|
132
|
-
},
|
|
133
|
-
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: a, fieldProps: c }, l] =
|
|
134
|
-
return /* @__PURE__ */ r(
|
|
135
|
-
|
|
132
|
+
}, Ri = [!0, "true"], Ni = S(function(i) {
|
|
133
|
+
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: a, fieldProps: c }, l] = H(i), f = me(n), d = Ri.includes(c.value);
|
|
134
|
+
return /* @__PURE__ */ r(W, { helpText: o, severity: n, children: /* @__PURE__ */ r(
|
|
135
|
+
q,
|
|
136
136
|
{
|
|
137
137
|
severity: n,
|
|
138
138
|
inputId: e,
|
|
@@ -140,7 +140,7 @@ const Vi = "_description_17zed_1", Re = {
|
|
|
140
140
|
label: a,
|
|
141
141
|
flexProps: { direction: "row-reverse", justify: "end", align: "center", gap: "2" },
|
|
142
142
|
children: /* @__PURE__ */ r(
|
|
143
|
-
|
|
143
|
+
Yt,
|
|
144
144
|
{
|
|
145
145
|
...l,
|
|
146
146
|
...c,
|
|
@@ -176,14 +176,14 @@ const Vi = "_description_17zed_1", Re = {
|
|
|
176
176
|
return new J(e);
|
|
177
177
|
}
|
|
178
178
|
getInput(e) {
|
|
179
|
-
return /* @__PURE__ */ r(
|
|
179
|
+
return /* @__PURE__ */ r(Ni, { ...e, field: this });
|
|
180
180
|
}
|
|
181
181
|
};
|
|
182
|
-
m(J, "fieldTypeName", "Checkbox"), m(J, "fieldTypeDescription", "Perfect for both optional and required yes/no questions."), m(J, "Icon",
|
|
182
|
+
m(J, "fieldTypeName", "Checkbox"), m(J, "fieldTypeDescription", "Perfect for both optional and required yes/no questions."), m(J, "Icon", Zt);
|
|
183
183
|
let fe = J;
|
|
184
|
-
const
|
|
185
|
-
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: a, fieldProps: c, field: l }, f] =
|
|
186
|
-
return /* @__PURE__ */ r(
|
|
184
|
+
const Bi = S(function(i) {
|
|
185
|
+
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: a, fieldProps: c, field: l }, f] = H(i), d = me(n);
|
|
186
|
+
return /* @__PURE__ */ r(W, { helpText: o, severity: n, children: /* @__PURE__ */ r(q, { severity: n, inputId: e, labelId: t, label: a, children: /* @__PURE__ */ r(
|
|
187
187
|
ae.Input,
|
|
188
188
|
{
|
|
189
189
|
...f,
|
|
@@ -267,14 +267,14 @@ const Oi = E(function(i) {
|
|
|
267
267
|
return new B(e);
|
|
268
268
|
}
|
|
269
269
|
getInput(e) {
|
|
270
|
-
return /* @__PURE__ */ r(
|
|
270
|
+
return /* @__PURE__ */ r(Bi, { field: this, ...e });
|
|
271
271
|
}
|
|
272
272
|
};
|
|
273
|
-
m(B, "fieldTypeName", "Number"), m(B, "fieldTypeDescription", "Allows specifying a number within a given range."), m(B, "Icon",
|
|
273
|
+
m(B, "fieldTypeName", "Number"), m(B, "fieldTypeDescription", "Allows specifying a number within a given range."), m(B, "Icon", Xt), 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
274
|
let Y = B;
|
|
275
|
-
const
|
|
276
|
-
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: a, fieldProps: c }, l] =
|
|
277
|
-
return /* @__PURE__ */ r(
|
|
275
|
+
const qi = S(function(i) {
|
|
276
|
+
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: a, fieldProps: c }, l] = H(i), f = me(n), d = c.value ? c.value.split("T")[0] : "";
|
|
277
|
+
return /* @__PURE__ */ r(W, { helpText: o, severity: n, children: /* @__PURE__ */ r(q, { severity: n, inputId: e, labelId: t, label: a, children: /* @__PURE__ */ r(ae.Input, { ...l, ...c, type: "date", id: e, color: f, value: d }) }) });
|
|
278
278
|
}), ee = class ee extends M {
|
|
279
279
|
constructor(e) {
|
|
280
280
|
super({ ...e, type: "date" });
|
|
@@ -292,12 +292,12 @@ const Mi = E(function(i) {
|
|
|
292
292
|
return new ee(e);
|
|
293
293
|
}
|
|
294
294
|
getInput(e) {
|
|
295
|
-
return /* @__PURE__ */ r(
|
|
295
|
+
return /* @__PURE__ */ r(qi, { field: this, ...e });
|
|
296
296
|
}
|
|
297
297
|
};
|
|
298
|
-
m(ee, "fieldTypeName", "Date"), m(ee, "fieldTypeDescription", "Allows specifying a date."), m(ee, "Icon",
|
|
299
|
-
let
|
|
300
|
-
class
|
|
298
|
+
m(ee, "fieldTypeName", "Date"), m(ee, "fieldTypeDescription", "Allows specifying a date."), m(ee, "Icon", Qt);
|
|
299
|
+
let Ge = ee;
|
|
300
|
+
class Ee extends M {
|
|
301
301
|
constructor(e) {
|
|
302
302
|
const { minLength: t, maxLength: n = 5e3, ...o } = e;
|
|
303
303
|
super(o);
|
|
@@ -356,20 +356,20 @@ class ze extends M {
|
|
|
356
356
|
* This function validates that the value given for "minimum length" (when creating a new field) is less than or
|
|
357
357
|
* equal to the value given for "maximum length".
|
|
358
358
|
*/
|
|
359
|
-
m(
|
|
359
|
+
m(Ee, "_validateMin", (e, t) => typeof t.maximum_length == "number" && typeof e == "number" && t.maximum_length < e ? "Minimum cannot be greater than maximum." : null), /**
|
|
360
360
|
* This function validates that the value given for "maximum length" (when creating a new field) is greater than or
|
|
361
361
|
* equal to the value given for "minimum length".
|
|
362
362
|
*/
|
|
363
|
-
m(
|
|
363
|
+
m(Ee, "_validateMax", (e, t) => {
|
|
364
364
|
if (typeof e != "number")
|
|
365
365
|
return null;
|
|
366
366
|
const { minimum_length: n } = t;
|
|
367
367
|
return typeof n != "number" ? null : n > e ? "Maximum cannot be less than minimum." : null;
|
|
368
368
|
});
|
|
369
|
-
const
|
|
370
|
-
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: a, fieldProps: c, field: l }, f] =
|
|
371
|
-
return /* @__PURE__ */ r(
|
|
372
|
-
}), te = class te extends
|
|
369
|
+
const Wi = S(function(i) {
|
|
370
|
+
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: a, fieldProps: c, field: l }, f] = H(i), d = me(n);
|
|
371
|
+
return /* @__PURE__ */ r(W, { helpText: o, severity: n, children: /* @__PURE__ */ r(q, { severity: n, inputId: e, labelId: t, label: a, children: /* @__PURE__ */ r(ae.Input, { ...f, ...c, type: l.inputType, id: e, color: d }) }) });
|
|
372
|
+
}), te = class te extends Ee {
|
|
373
373
|
constructor(e) {
|
|
374
374
|
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
375
|
super({ ...n, maxLength: o, minLength: a, type: "string" });
|
|
@@ -386,15 +386,15 @@ const Ri = E(function(i) {
|
|
|
386
386
|
return new te({ ...a, maxLength: t, minLength: n, inputType: o });
|
|
387
387
|
}
|
|
388
388
|
getInput(e) {
|
|
389
|
-
return /* @__PURE__ */ r(
|
|
389
|
+
return /* @__PURE__ */ r(Wi, { field: this, ...e });
|
|
390
390
|
}
|
|
391
391
|
};
|
|
392
|
-
m(te, "fieldTypeName", "Short Text"), m(te, "fieldTypeDescription", "Short text fields can hold up to 500 characters on a single line."), m(te, "Icon",
|
|
392
|
+
m(te, "fieldTypeName", "Short Text"), m(te, "fieldTypeDescription", "Short text fields can hold up to 500 characters on a single line."), m(te, "Icon", Jt);
|
|
393
393
|
let be = te;
|
|
394
|
-
const
|
|
395
|
-
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: a, fieldProps: c }, l] =
|
|
396
|
-
return /* @__PURE__ */ r(
|
|
397
|
-
}), ie = class ie extends
|
|
394
|
+
const Hi = S(function(i) {
|
|
395
|
+
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: a, fieldProps: c }, l] = H(i);
|
|
396
|
+
return /* @__PURE__ */ r(W, { helpText: o, severity: n, children: /* @__PURE__ */ r(q, { severity: n, inputId: e, labelId: t, label: a, children: /* @__PURE__ */ r(ei, { ...l, ...c, resize: "vertical", id: e, severity: n }) }) });
|
|
397
|
+
}), ie = class ie extends Ee {
|
|
398
398
|
constructor(i) {
|
|
399
399
|
const e = i.maxLength ? Math.min(5e3, i.maxLength) : 5e3, t = i.minLength ? Math.min(i.minLength, e) : void 0;
|
|
400
400
|
super({ ...i, maxLength: e, minLength: t, type: "text" });
|
|
@@ -409,137 +409,137 @@ const Ni = E(function(i) {
|
|
|
409
409
|
return new ie({ ...n, maxLength: e, minLength: t });
|
|
410
410
|
}
|
|
411
411
|
getInput(i) {
|
|
412
|
-
return /* @__PURE__ */ r(
|
|
412
|
+
return /* @__PURE__ */ r(Hi, { field: this, ...i });
|
|
413
413
|
}
|
|
414
414
|
};
|
|
415
|
-
m(ie, "fieldTypeName", "Paragraph"), m(ie, "fieldTypeDescription", "Paragraph fields can hold up to 5000 characters and can have multiple lines."), m(ie, "Icon",
|
|
415
|
+
m(ie, "fieldTypeName", "Paragraph"), m(ie, "fieldTypeDescription", "Paragraph fields can hold up to 5000 characters and can have multiple lines."), m(ie, "Icon", ti);
|
|
416
416
|
let ye = ie;
|
|
417
|
-
const
|
|
418
|
-
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: a, fieldProps: c, field: l }, f] =
|
|
417
|
+
const ji = S(function(i) {
|
|
418
|
+
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: a, fieldProps: c, field: l }, f] = H(i), { onChange: d, onBlur: u } = c, p = x(
|
|
419
419
|
() => l.options.map((b) => ({ value: b.value, itemContent: b.label })),
|
|
420
420
|
[l.options]
|
|
421
|
-
),
|
|
421
|
+
), h = T(
|
|
422
422
|
(b) => {
|
|
423
423
|
d(b), u(b);
|
|
424
424
|
},
|
|
425
425
|
[d, u]
|
|
426
426
|
);
|
|
427
|
-
return /* @__PURE__ */ r(
|
|
428
|
-
|
|
427
|
+
return /* @__PURE__ */ r(W, { helpText: o, severity: n, children: /* @__PURE__ */ r(q, { severity: n, inputId: e, labelId: t, label: a, children: /* @__PURE__ */ r(
|
|
428
|
+
It,
|
|
429
429
|
{
|
|
430
|
-
items:
|
|
430
|
+
items: p,
|
|
431
431
|
...c,
|
|
432
|
-
onValueChange:
|
|
432
|
+
onValueChange: h,
|
|
433
433
|
placeholder: "Select one...",
|
|
434
434
|
id: e,
|
|
435
435
|
severity: n,
|
|
436
436
|
...f
|
|
437
437
|
}
|
|
438
438
|
) }) });
|
|
439
|
-
}),
|
|
439
|
+
}), Ae = (s = "", i = []) => ({
|
|
440
440
|
type: "section",
|
|
441
441
|
fields: i,
|
|
442
442
|
identifier: s,
|
|
443
443
|
label: null,
|
|
444
444
|
condition: null,
|
|
445
445
|
conditional: !1
|
|
446
|
-
}),
|
|
446
|
+
}), Ui = (s) => {
|
|
447
447
|
if (!s)
|
|
448
448
|
return;
|
|
449
449
|
const i = s.fields;
|
|
450
450
|
let e = [];
|
|
451
451
|
const t = [];
|
|
452
452
|
for (const n of i)
|
|
453
|
-
n.type === "section" ? (e.length > 0 && (t.push(
|
|
454
|
-
return e.length > 0 && t.push(
|
|
453
|
+
n.type === "section" ? (e.length > 0 && (t.push(Ae(`AUTO_section-${i.indexOf(n)}`, e)), e = []), t.push(n)) : e.push(n);
|
|
454
|
+
return e.length > 0 && t.push(Ae("AUTO_section-last", e)), { ...s, fields: t, description: s.description ?? "" };
|
|
455
455
|
};
|
|
456
|
-
function
|
|
456
|
+
function Ke(s, i, e) {
|
|
457
457
|
const t = Array.from(s), [n] = t.splice(i, 1);
|
|
458
458
|
if (!n)
|
|
459
459
|
throw new Error("Could not find field to reorder.");
|
|
460
460
|
return t.splice(e, 0, n), t;
|
|
461
461
|
}
|
|
462
|
-
function
|
|
462
|
+
function Gi(s, i, e) {
|
|
463
463
|
const t = Array.from(s);
|
|
464
464
|
return t[i] = e, t;
|
|
465
465
|
}
|
|
466
|
-
function
|
|
466
|
+
function kt(s, i, e) {
|
|
467
467
|
const t = Array.from(s ?? []);
|
|
468
468
|
return t.splice(i, 0, e), t;
|
|
469
469
|
}
|
|
470
|
-
function
|
|
470
|
+
function Le(s, i) {
|
|
471
471
|
const e = Array.from(s);
|
|
472
472
|
return e.splice(i, 1), e;
|
|
473
473
|
}
|
|
474
|
-
const
|
|
474
|
+
const $t = (s, i) => {
|
|
475
475
|
if (typeof s == "string" && s.length > 0)
|
|
476
476
|
return s;
|
|
477
477
|
const e = /* @__PURE__ */ new Date();
|
|
478
|
-
return `${
|
|
479
|
-
},
|
|
478
|
+
return `${zi(i)}-${e.getTime()}`;
|
|
479
|
+
}, Vt = (s, i) => {
|
|
480
480
|
if (!i)
|
|
481
481
|
return null;
|
|
482
482
|
for (const e of s)
|
|
483
483
|
if (e.type === "section") {
|
|
484
|
-
const t =
|
|
484
|
+
const t = Vt(e.fields, i);
|
|
485
485
|
if (t)
|
|
486
486
|
return t;
|
|
487
487
|
} else if (e.identifier === i)
|
|
488
488
|
return e;
|
|
489
489
|
return null;
|
|
490
|
-
},
|
|
490
|
+
}, ze = (s, i) => s.filter((e, t) => t < i).flatMap((e) => e.fields), Dt = (s) => s.flatMap(
|
|
491
491
|
(i) => i.type === "section" ? [...i.fields.map((e) => e.label), i.label] : i.label
|
|
492
|
-
).filter((i) => i !== null),
|
|
492
|
+
).filter((i) => i !== null), Ye = (s, i) => {
|
|
493
493
|
let e = 1, t = `${s} (${e})`;
|
|
494
494
|
for (; i.includes(t); )
|
|
495
495
|
t = `${s} (${++e})`;
|
|
496
496
|
return t;
|
|
497
|
-
},
|
|
498
|
-
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: a, fieldProps: c }, l] =
|
|
497
|
+
}, Ki = S(function(i) {
|
|
498
|
+
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: a, fieldProps: c }, l] = H(i), f = me(n), d = x(() => Array.isArray(c.value) ? c.value : [], [c.value]), { onChange: u, onBlur: p } = c, h = `${e}-droppable`, { disabled: b } = l, [z, I] = de(""), [C, w] = de(""), V = C || o, L = C ? "red" : f, v = T(
|
|
499
499
|
(A) => {
|
|
500
|
-
u(A),
|
|
500
|
+
u(A), p(A);
|
|
501
501
|
},
|
|
502
|
-
[u,
|
|
503
|
-
), P =
|
|
502
|
+
[u, p]
|
|
503
|
+
), P = T(
|
|
504
504
|
(A) => {
|
|
505
505
|
d.findIndex((N) => N.value === A.target.value.trim()) >= 0 ? w("All options must be unique") : A.target.value ? w("") : w("Option cannot be empty"), I(A.target.value);
|
|
506
506
|
},
|
|
507
507
|
[I, d]
|
|
508
|
-
), R =
|
|
508
|
+
), R = T(() => {
|
|
509
509
|
if (C)
|
|
510
510
|
return;
|
|
511
|
-
if (!
|
|
511
|
+
if (!z.trim())
|
|
512
512
|
return w("Option cannot be empty");
|
|
513
|
-
const A =
|
|
513
|
+
const A = z.trim();
|
|
514
514
|
v([...d, { value: A, label: A }]), I("");
|
|
515
|
-
}, [
|
|
515
|
+
}, [z, C, v, d]), X = T(
|
|
516
516
|
(A) => {
|
|
517
517
|
A.key === "Enter" && (A.preventDefault(), R());
|
|
518
518
|
},
|
|
519
519
|
[R]
|
|
520
|
-
),
|
|
520
|
+
), j = T(
|
|
521
521
|
(A) => {
|
|
522
|
-
v(
|
|
522
|
+
v(Le(d, A));
|
|
523
523
|
},
|
|
524
524
|
[d, v]
|
|
525
|
-
), U =
|
|
525
|
+
), U = T(
|
|
526
526
|
(A) => {
|
|
527
527
|
if (!A.destination)
|
|
528
528
|
return;
|
|
529
529
|
const N = A.source.index, K = A.destination.index;
|
|
530
|
-
v(
|
|
530
|
+
v(Ke(d, N, K));
|
|
531
531
|
},
|
|
532
532
|
[v, d]
|
|
533
533
|
);
|
|
534
|
-
return /* @__PURE__ */ r(
|
|
535
|
-
/* @__PURE__ */ r(
|
|
534
|
+
return /* @__PURE__ */ r(Tt, { onDragEnd: U, children: /* @__PURE__ */ g(y, { direction: "column", gap: "2", children: [
|
|
535
|
+
/* @__PURE__ */ r(W, { helpText: V, severity: n, children: /* @__PURE__ */ r(q, { severity: n, inputId: e, labelId: t, label: a, children: (!b || d.length === 0) && /* @__PURE__ */ g(y, { gap: "2", children: [
|
|
536
536
|
/* @__PURE__ */ r(ge, { grow: "1", children: /* @__PURE__ */ r(
|
|
537
537
|
ae.Input,
|
|
538
538
|
{
|
|
539
539
|
placeholder: "Press enter to add a new option",
|
|
540
540
|
...l,
|
|
541
541
|
...c,
|
|
542
|
-
value:
|
|
542
|
+
value: z,
|
|
543
543
|
onChange: P,
|
|
544
544
|
onKeyDown: X,
|
|
545
545
|
id: e,
|
|
@@ -554,29 +554,29 @@ const Lt = (s, i) => {
|
|
|
554
554
|
"aria-label": "Add option",
|
|
555
555
|
disabled: !!C || b,
|
|
556
556
|
onClick: R,
|
|
557
|
-
children: /* @__PURE__ */ r(
|
|
557
|
+
children: /* @__PURE__ */ r(Oe, {})
|
|
558
558
|
}
|
|
559
559
|
)
|
|
560
560
|
] }) }) }),
|
|
561
|
-
/* @__PURE__ */ r(
|
|
561
|
+
/* @__PURE__ */ r(nt, { droppableId: h, children: (A) => /* @__PURE__ */ g(y, { ...A.droppableProps, ref: A.innerRef, direction: "column", children: [
|
|
562
562
|
d.map((N, K) => /* @__PURE__ */ r(
|
|
563
|
-
|
|
563
|
+
rt,
|
|
564
564
|
{
|
|
565
565
|
draggableId: `${N.value}-draggable`,
|
|
566
566
|
index: K,
|
|
567
567
|
isDragDisabled: b,
|
|
568
|
-
children: ({ draggableProps: Ie, dragHandleProps: Ce, innerRef:
|
|
568
|
+
children: ({ draggableProps: Ie, dragHandleProps: Ce, innerRef: Fe }) => /* @__PURE__ */ r(
|
|
569
569
|
y,
|
|
570
570
|
{
|
|
571
571
|
...Ce,
|
|
572
572
|
...Ie,
|
|
573
|
-
ref:
|
|
573
|
+
ref: Fe,
|
|
574
574
|
gap: "2",
|
|
575
575
|
align: "center",
|
|
576
576
|
justify: "between",
|
|
577
577
|
mb: "1",
|
|
578
578
|
asChild: !0,
|
|
579
|
-
children: /* @__PURE__ */ g(
|
|
579
|
+
children: /* @__PURE__ */ g(Ue, { color: "gray", size: "2", children: [
|
|
580
580
|
/* @__PURE__ */ r("span", { children: N.label }),
|
|
581
581
|
/* @__PURE__ */ r(
|
|
582
582
|
ce,
|
|
@@ -587,8 +587,8 @@ const Lt = (s, i) => {
|
|
|
587
587
|
"aria-label": "Delete option",
|
|
588
588
|
severity: "info",
|
|
589
589
|
disabled: b,
|
|
590
|
-
onClick: () =>
|
|
591
|
-
children: /* @__PURE__ */ r(
|
|
590
|
+
onClick: () => j(K),
|
|
591
|
+
children: /* @__PURE__ */ r(Ct, {})
|
|
592
592
|
}
|
|
593
593
|
)
|
|
594
594
|
] })
|
|
@@ -615,7 +615,7 @@ const Lt = (s, i) => {
|
|
|
615
615
|
throw new Error("Expected an array.");
|
|
616
616
|
}
|
|
617
617
|
getInput(e) {
|
|
618
|
-
return /* @__PURE__ */ r(
|
|
618
|
+
return /* @__PURE__ */ r(Ki, { field: this, ...e });
|
|
619
619
|
}
|
|
620
620
|
serialize() {
|
|
621
621
|
return { ...super._serialize(), minimum_length: this.minLength, maximum_length: this.maxLength };
|
|
@@ -639,9 +639,9 @@ const Lt = (s, i) => {
|
|
|
639
639
|
return new ne(e);
|
|
640
640
|
}
|
|
641
641
|
};
|
|
642
|
-
m(ne, "fieldTypeName", "Multi-string"), m(ne, "fieldTypeDescription", "Allows the user to provide multiple unique strings."), m(ne, "Icon",
|
|
643
|
-
let
|
|
644
|
-
class
|
|
642
|
+
m(ne, "fieldTypeName", "Multi-string"), m(ne, "fieldTypeDescription", "Allows the user to provide multiple unique strings."), m(ne, "Icon", ii);
|
|
643
|
+
let Pe = ne;
|
|
644
|
+
class _t extends M {
|
|
645
645
|
constructor(e) {
|
|
646
646
|
super(e);
|
|
647
647
|
m(this, "options");
|
|
@@ -660,7 +660,7 @@ class $t extends M {
|
|
|
660
660
|
}
|
|
661
661
|
static getFieldCreationSchema() {
|
|
662
662
|
return [
|
|
663
|
-
new
|
|
663
|
+
new Pe({
|
|
664
664
|
label: "Options",
|
|
665
665
|
description: "List possible options for the user to select from.",
|
|
666
666
|
required: !0,
|
|
@@ -671,7 +671,7 @@ class $t extends M {
|
|
|
671
671
|
];
|
|
672
672
|
}
|
|
673
673
|
}
|
|
674
|
-
const re = class re extends
|
|
674
|
+
const re = class re extends _t {
|
|
675
675
|
constructor(i) {
|
|
676
676
|
super({ ...i, type: "select" });
|
|
677
677
|
}
|
|
@@ -687,23 +687,23 @@ const re = class re extends $t {
|
|
|
687
687
|
return new re(i);
|
|
688
688
|
}
|
|
689
689
|
getInput(i) {
|
|
690
|
-
return /* @__PURE__ */ r(
|
|
690
|
+
return /* @__PURE__ */ r(ji, { field: this, ...i });
|
|
691
691
|
}
|
|
692
692
|
};
|
|
693
|
-
m(re, "fieldTypeName", "Dropdown"), m(re, "fieldTypeDescription", "Allows the user to select a single option from a list of options."), m(re, "Icon",
|
|
694
|
-
let
|
|
695
|
-
const
|
|
696
|
-
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: a, fieldProps: c, field: l }, f] =
|
|
693
|
+
m(re, "fieldTypeName", "Dropdown"), m(re, "fieldTypeDescription", "Allows the user to select a single option from a list of options."), m(re, "Icon", ni);
|
|
694
|
+
let ke = re;
|
|
695
|
+
const Yi = (s) => s ? Array.isArray(s) ? s : [s] : [], Zi = S(function(i) {
|
|
696
|
+
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: a, fieldProps: c, field: l }, f] = H(i), { onChange: d, onBlur: u } = c, p = x(() => Yi(c.value), [c.value]), h = T(
|
|
697
697
|
(b) => {
|
|
698
698
|
d(b), u(b);
|
|
699
699
|
},
|
|
700
700
|
[d, u]
|
|
701
701
|
);
|
|
702
|
-
return /* @__PURE__ */ r(
|
|
703
|
-
|
|
702
|
+
return /* @__PURE__ */ r(W, { helpText: o, severity: n, children: /* @__PURE__ */ r(q, { severity: n, inputId: e, labelId: t, label: a, children: /* @__PURE__ */ r(
|
|
703
|
+
ri,
|
|
704
704
|
{
|
|
705
|
-
value:
|
|
706
|
-
onValueChange:
|
|
705
|
+
value: p,
|
|
706
|
+
onValueChange: h,
|
|
707
707
|
options: l.options,
|
|
708
708
|
name: c.name,
|
|
709
709
|
placeholder: "Select one or more...",
|
|
@@ -712,7 +712,7 @@ const ji = (s) => s ? Array.isArray(s) ? s : [s] : [], Ui = E(function(i) {
|
|
|
712
712
|
...f
|
|
713
713
|
}
|
|
714
714
|
) }) });
|
|
715
|
-
}), oe = class oe extends
|
|
715
|
+
}), oe = class oe extends _t {
|
|
716
716
|
constructor(i) {
|
|
717
717
|
super({ ...i, type: "multi-select" });
|
|
718
718
|
}
|
|
@@ -733,19 +733,19 @@ const ji = (s) => s ? Array.isArray(s) ? s : [s] : [], Ui = E(function(i) {
|
|
|
733
733
|
return new oe(i);
|
|
734
734
|
}
|
|
735
735
|
getInput(i) {
|
|
736
|
-
return /* @__PURE__ */ r(
|
|
736
|
+
return /* @__PURE__ */ r(Zi, { field: this, ...i });
|
|
737
737
|
}
|
|
738
738
|
};
|
|
739
|
-
m(oe, "fieldTypeName", "Multi-select"), m(oe, "fieldTypeDescription", "Allows the user to select a multiple options from a list of options."), m(oe, "Icon",
|
|
740
|
-
let
|
|
741
|
-
const
|
|
742
|
-
const [{ value: t }] =
|
|
739
|
+
m(oe, "fieldTypeName", "Multi-select"), m(oe, "fieldTypeDescription", "Allows the user to select a multiple options from a list of options."), m(oe, "Icon", oi);
|
|
740
|
+
let $e = oe;
|
|
741
|
+
const Xi = S(function({ field: i, ...e }) {
|
|
742
|
+
const [{ value: t }] = et(i.options.clonedFieldIdentifier), n = x(() => {
|
|
743
743
|
const o = i.options.getFieldToClone(t);
|
|
744
|
-
return o ?
|
|
744
|
+
return o ? Be(o) : null;
|
|
745
745
|
}, [i.options, t]);
|
|
746
|
-
return
|
|
746
|
+
return De(n, e);
|
|
747
747
|
});
|
|
748
|
-
class
|
|
748
|
+
class Ve extends M {
|
|
749
749
|
constructor(e, t) {
|
|
750
750
|
super({ ...e, type: "custom" });
|
|
751
751
|
m(this, "Component");
|
|
@@ -761,28 +761,28 @@ class $e extends M {
|
|
|
761
761
|
return /* @__PURE__ */ r(t, { field: this, ...e });
|
|
762
762
|
}
|
|
763
763
|
}
|
|
764
|
-
m(
|
|
765
|
-
class
|
|
764
|
+
m(Ve, "fieldTypeName", "Custom"), m(Ve, "fieldTypeDescription", "Allows re-rendering of field already in the form");
|
|
765
|
+
class Qi extends Ve {
|
|
766
766
|
constructor(i) {
|
|
767
|
-
super(i,
|
|
767
|
+
super(i, Xi);
|
|
768
768
|
}
|
|
769
769
|
}
|
|
770
|
-
const
|
|
771
|
-
const { field: e, ...t } = i, { label: n, description: o, fields: a, condition: c } = e, { values: l, setFieldValue: f } =
|
|
770
|
+
const Ji = S(function(i) {
|
|
771
|
+
const { field: e, ...t } = i, { label: n, description: o, fields: a, condition: c } = e, { values: l, setFieldValue: f } = pe(), d = c != null && c.identifier ? ue(l, c.identifier) : void 0, u = x(() => Rt(c, d), [c, d]);
|
|
772
772
|
ve(() => {
|
|
773
773
|
if (!u)
|
|
774
|
-
for (const
|
|
775
|
-
f(
|
|
774
|
+
for (const h of a)
|
|
775
|
+
f(h.getId(), "").then();
|
|
776
776
|
}, [u, a, f]);
|
|
777
|
-
const
|
|
777
|
+
const p = Nt(a, t);
|
|
778
778
|
return u ? n ? /* @__PURE__ */ r(we, { children: /* @__PURE__ */ g(y, { direction: "column", gap: "3", children: [
|
|
779
779
|
/* @__PURE__ */ g(y, { direction: "column", children: [
|
|
780
|
-
/* @__PURE__ */ r(
|
|
781
|
-
/* @__PURE__ */ r($, { className:
|
|
780
|
+
/* @__PURE__ */ r(Me, { as: "h3", size: "3", children: n }),
|
|
781
|
+
/* @__PURE__ */ r($, { className: Ne.description, children: o })
|
|
782
782
|
] }),
|
|
783
|
-
|
|
784
|
-
] }) }) :
|
|
785
|
-
}), se = class se extends
|
|
783
|
+
p
|
|
784
|
+
] }) }) : p : null;
|
|
785
|
+
}), se = class se extends Pt {
|
|
786
786
|
constructor(e) {
|
|
787
787
|
const { label: t = null, fields: n, condition: o = null, conditional: a, ...c } = e;
|
|
788
788
|
super({ ...c, type: "section" });
|
|
@@ -812,7 +812,7 @@ const Yi = E(function(i) {
|
|
|
812
812
|
fields: [
|
|
813
813
|
// Declare a select field that will be used to select the field against which we will check the
|
|
814
814
|
// condition. This must be selected before the next field is rendered.
|
|
815
|
-
new
|
|
815
|
+
new ke({
|
|
816
816
|
label: "Field",
|
|
817
817
|
description: "The field to use for the condition.",
|
|
818
818
|
// The options (for the field against which we will check the condition) are all the labels of
|
|
@@ -829,7 +829,7 @@ const Yi = E(function(i) {
|
|
|
829
829
|
// Declare a custom field that will be used to input a value for the condition. The value of the
|
|
830
830
|
// conditional field selected in the previous step must be equal to the value the user inputs into
|
|
831
831
|
// this field for the section to be rendered.
|
|
832
|
-
new
|
|
832
|
+
new Qi({
|
|
833
833
|
label: "Value",
|
|
834
834
|
identifier: "condition.value",
|
|
835
835
|
required: !0,
|
|
@@ -856,7 +856,7 @@ const Yi = E(function(i) {
|
|
|
856
856
|
var n;
|
|
857
857
|
if (e.type !== "section")
|
|
858
858
|
throw new Error("Invalid type");
|
|
859
|
-
const t = ((n = e.fields) == null ? void 0 : n.map(
|
|
859
|
+
const t = ((n = e.fields) == null ? void 0 : n.map(Ot)) ?? [];
|
|
860
860
|
return new se({ ...e, fields: t });
|
|
861
861
|
}
|
|
862
862
|
conditional() {
|
|
@@ -875,40 +875,40 @@ const Yi = E(function(i) {
|
|
|
875
875
|
const t = {};
|
|
876
876
|
for (const n of this.fields) {
|
|
877
877
|
const o = n.getId(), a = n.getError(ue(e, o), e);
|
|
878
|
-
a &&
|
|
878
|
+
a && st(t, n.getId(), a);
|
|
879
879
|
}
|
|
880
880
|
return t;
|
|
881
881
|
}
|
|
882
882
|
getInput(e) {
|
|
883
|
-
return /* @__PURE__ */ r(
|
|
883
|
+
return /* @__PURE__ */ r(Ji, { field: this, ...e });
|
|
884
884
|
}
|
|
885
885
|
};
|
|
886
886
|
m(se, "fieldTypeName", "Section"), m(se, "fieldTypeDescription", "Sections can be useful for grouping fields together. They can also be conditionally shown or hidden.");
|
|
887
887
|
let Z = se;
|
|
888
|
-
const
|
|
889
|
-
previewImage:
|
|
890
|
-
},
|
|
888
|
+
const en = "_previewImage_1ig84_1", tn = {
|
|
889
|
+
previewImage: en
|
|
890
|
+
}, lt = (s) => {
|
|
891
891
|
const i = ["byte", "kilobyte", "megabyte"];
|
|
892
892
|
let e = s, t = 0;
|
|
893
893
|
for (; e > 1024 && t < i.length - 1; )
|
|
894
894
|
e /= 1024, t++;
|
|
895
895
|
return new Intl.NumberFormat([], { maximumFractionDigits: 2, style: "unit", unit: i[t] }).format(e);
|
|
896
|
-
},
|
|
896
|
+
}, nn = S(function(i) {
|
|
897
897
|
var L;
|
|
898
|
-
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: a, fieldProps: c, field: l }, f] =
|
|
898
|
+
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: a, fieldProps: c, field: l }, f] = H(i), { onChange: d } = c, u = me(n), p = Ti(null), { value: h } = c, b = x(() => o || (l.maxFileSize ? `Maximum file size: ${lt(l.maxFileSize)}` : null), [l.maxFileSize, o]), z = T(() => {
|
|
899
899
|
var v;
|
|
900
|
-
(v =
|
|
901
|
-
}, []), I =
|
|
900
|
+
(v = p.current) == null || v.click();
|
|
901
|
+
}, []), I = T(
|
|
902
902
|
(v) => {
|
|
903
|
-
const P = [...
|
|
903
|
+
const P = [...h];
|
|
904
904
|
P.splice(v, 1), d({ target: { files: P } });
|
|
905
905
|
},
|
|
906
|
-
[
|
|
907
|
-
), C =
|
|
906
|
+
[h, d]
|
|
907
|
+
), C = h ? "Select new files" : "Select files", w = h ? "Select new file" : "Select a file", V = l.maxFiles > 1 ? C : w;
|
|
908
908
|
return /* @__PURE__ */ g(y, { direction: "column", gap: "2", children: [
|
|
909
|
-
/* @__PURE__ */ r(
|
|
910
|
-
/* @__PURE__ */ r(y, { direction: "row", gap: "2", children: /* @__PURE__ */ r(ge, { width: "max-content", asChild: !0, children: /* @__PURE__ */ g(G, { ...f, onClick:
|
|
911
|
-
/* @__PURE__ */ r(
|
|
909
|
+
/* @__PURE__ */ r(W, { helpText: b, severity: n, children: /* @__PURE__ */ g(q, { severity: n, inputId: e, labelId: t, label: a, children: [
|
|
910
|
+
/* @__PURE__ */ r(y, { direction: "row", gap: "2", children: /* @__PURE__ */ r(ge, { width: "max-content", asChild: !0, children: /* @__PURE__ */ g(G, { ...f, onClick: z, children: [
|
|
911
|
+
/* @__PURE__ */ r(Ft, {}),
|
|
912
912
|
" ",
|
|
913
913
|
V
|
|
914
914
|
] }) }) }),
|
|
@@ -917,7 +917,7 @@ const Zi = "_previewImage_1ig84_1", Xi = {
|
|
|
917
917
|
{
|
|
918
918
|
...f,
|
|
919
919
|
type: "file",
|
|
920
|
-
ref:
|
|
920
|
+
ref: p,
|
|
921
921
|
id: e,
|
|
922
922
|
accept: (L = l.extensions) == null ? void 0 : L.join(","),
|
|
923
923
|
multiple: l.maxFiles > 1,
|
|
@@ -928,8 +928,8 @@ const Zi = "_previewImage_1ig84_1", Xi = {
|
|
|
928
928
|
}
|
|
929
929
|
)
|
|
930
930
|
] }) }),
|
|
931
|
-
Array.isArray(
|
|
932
|
-
|
|
931
|
+
Array.isArray(h) && h.length > 0 && /* @__PURE__ */ r(y, { direction: "column", gap: "2", children: h.map((v, P) => /* @__PURE__ */ r(
|
|
932
|
+
rn,
|
|
933
933
|
{
|
|
934
934
|
field: l,
|
|
935
935
|
file: v,
|
|
@@ -939,10 +939,10 @@ const Zi = "_previewImage_1ig84_1", Xi = {
|
|
|
939
939
|
P
|
|
940
940
|
)) })
|
|
941
941
|
] });
|
|
942
|
-
}),
|
|
942
|
+
}), rn = S(function({ file: i, field: e, onRemove: t, disabled: n }) {
|
|
943
943
|
const [o, a] = de(null), c = x(() => o && e.getError([o]), [e, o]), { url: l, name: f, size: d } = x(() => {
|
|
944
|
-
let u = null,
|
|
945
|
-
return o != null && o.type.startsWith("image/") && (u = URL.createObjectURL(o)), o ? (
|
|
944
|
+
let u = null, p, h;
|
|
945
|
+
return o != null && o.type.startsWith("image/") && (u = URL.createObjectURL(o)), o ? (p = o.name, h = lt(o.size)) : (p = "Downloading...", h = "..."), { url: u, name: p, size: h };
|
|
946
946
|
}, [o]);
|
|
947
947
|
return ve(() => {
|
|
948
948
|
i instanceof Promise ? i.then(a) : a(i);
|
|
@@ -956,7 +956,7 @@ const Zi = "_previewImage_1ig84_1", Xi = {
|
|
|
956
956
|
"aria-label": `Remove ${f}`,
|
|
957
957
|
disabled: n,
|
|
958
958
|
onClick: t,
|
|
959
|
-
children: /* @__PURE__ */ r(
|
|
959
|
+
children: /* @__PURE__ */ r(Ct, {})
|
|
960
960
|
}
|
|
961
961
|
),
|
|
962
962
|
/* @__PURE__ */ g(y, { direction: "column", gap: "1", children: [
|
|
@@ -965,9 +965,9 @@ const Zi = "_previewImage_1ig84_1", Xi = {
|
|
|
965
965
|
c && /* @__PURE__ */ r($, { size: "1", severity: "danger", children: c })
|
|
966
966
|
] })
|
|
967
967
|
] }),
|
|
968
|
-
l && /* @__PURE__ */ r("img", { className:
|
|
968
|
+
l && /* @__PURE__ */ r("img", { className: tn.previewImage, src: l, alt: f })
|
|
969
969
|
] }) });
|
|
970
|
-
}),
|
|
970
|
+
}), gt = 50 * 1024 * 1024, le = class le extends M {
|
|
971
971
|
constructor(e) {
|
|
972
972
|
const { extensions: t, maximum_files: n, maximum_size: o, ...a } = e;
|
|
973
973
|
super({ ...a, type: "upload" });
|
|
@@ -999,10 +999,10 @@ const Zi = "_previewImage_1ig84_1", Xi = {
|
|
|
999
999
|
required: !1,
|
|
1000
1000
|
identifier: "maximum_size",
|
|
1001
1001
|
minimum: 1,
|
|
1002
|
-
maximum:
|
|
1002
|
+
maximum: gt,
|
|
1003
1003
|
integers: !0
|
|
1004
1004
|
}),
|
|
1005
|
-
new
|
|
1005
|
+
new $e({
|
|
1006
1006
|
label: "Accepted file types",
|
|
1007
1007
|
description: "Types of allowed files to upload. If left blank, all files will be accepted.",
|
|
1008
1008
|
required: !1,
|
|
@@ -1033,10 +1033,10 @@ const Zi = "_previewImage_1ig84_1", Xi = {
|
|
|
1033
1033
|
];
|
|
1034
1034
|
}
|
|
1035
1035
|
getFieldValidators() {
|
|
1036
|
-
const e = super.getFieldValidators(), t = this.maxFileSize ??
|
|
1036
|
+
const e = super.getFieldValidators(), t = this.maxFileSize ?? gt, n = this.maxFiles ?? 1;
|
|
1037
1037
|
return e.push((o) => {
|
|
1038
1038
|
if (o && o.some((a) => a.size > t))
|
|
1039
|
-
return `Files must be at most ${
|
|
1039
|
+
return `Files must be at most ${lt(t)}.`;
|
|
1040
1040
|
}), e.push((o) => {
|
|
1041
1041
|
if (o && o.length > n)
|
|
1042
1042
|
return `You can only upload ${n} files.`;
|
|
@@ -1056,43 +1056,43 @@ const Zi = "_previewImage_1ig84_1", Xi = {
|
|
|
1056
1056
|
return new le(e);
|
|
1057
1057
|
}
|
|
1058
1058
|
getInput(e) {
|
|
1059
|
-
return /* @__PURE__ */ r(
|
|
1059
|
+
return /* @__PURE__ */ r(nn, { field: this, ...e });
|
|
1060
1060
|
}
|
|
1061
1061
|
};
|
|
1062
|
-
m(le, "fieldTypeName", "Upload"), m(le, "fieldTypeDescription", "Allows a file to be uploaded."), m(le, "Icon",
|
|
1063
|
-
let
|
|
1064
|
-
const
|
|
1065
|
-
date:
|
|
1062
|
+
m(le, "fieldTypeName", "Upload"), m(le, "fieldTypeDescription", "Allows a file to be uploaded."), m(le, "Icon", Ft);
|
|
1063
|
+
let Ze = le;
|
|
1064
|
+
const at = {
|
|
1065
|
+
date: Ge,
|
|
1066
1066
|
number: Y,
|
|
1067
1067
|
boolean: fe,
|
|
1068
|
-
select:
|
|
1068
|
+
select: ke,
|
|
1069
1069
|
string: be,
|
|
1070
1070
|
text: ye,
|
|
1071
|
-
custom:
|
|
1072
|
-
upload:
|
|
1071
|
+
custom: Ve,
|
|
1072
|
+
upload: Ze,
|
|
1073
1073
|
// TODO: Underscore
|
|
1074
|
-
"multi-string":
|
|
1075
|
-
"multi-select":
|
|
1076
|
-
},
|
|
1074
|
+
"multi-string": Pe,
|
|
1075
|
+
"multi-select": $e
|
|
1076
|
+
}, Ot = (s) => {
|
|
1077
1077
|
const i = s.type;
|
|
1078
|
-
return
|
|
1079
|
-
},
|
|
1080
|
-
function
|
|
1078
|
+
return at[i].deserialize(s);
|
|
1079
|
+
}, Be = (s) => s.type === "section" ? Z.deserialize(s) : Ot(s);
|
|
1080
|
+
function Mt(s, i = {}) {
|
|
1081
1081
|
const { readonly: e = !1 } = i;
|
|
1082
1082
|
return {
|
|
1083
1083
|
title: s.title,
|
|
1084
1084
|
description: s.description,
|
|
1085
|
-
fields: s.fields.map((t) =>
|
|
1085
|
+
fields: s.fields.map((t) => Be(t)),
|
|
1086
1086
|
meta: { readonly: e }
|
|
1087
1087
|
};
|
|
1088
1088
|
}
|
|
1089
|
-
function
|
|
1089
|
+
function Xe(s) {
|
|
1090
1090
|
return !!(Array.isArray(s) && s.some((i) => i instanceof File || i instanceof Promise));
|
|
1091
1091
|
}
|
|
1092
|
-
function
|
|
1092
|
+
function Rt(s, i) {
|
|
1093
1093
|
if (!s)
|
|
1094
1094
|
return !0;
|
|
1095
|
-
if (
|
|
1095
|
+
if (Xe(i) || Xe(s.value))
|
|
1096
1096
|
throw new Error("Conditions do not support file uploads");
|
|
1097
1097
|
const e = Array.isArray(i) ? i.map((n) => typeof n == "string" ? n : n.value) : i, t = Array.isArray(s.value) ? s.value.map((n) => typeof n == "string" ? n : n.value) : s.value;
|
|
1098
1098
|
if (Array.isArray(t) && Array.isArray(e)) {
|
|
@@ -1103,16 +1103,16 @@ function _t(s, i) {
|
|
|
1103
1103
|
}
|
|
1104
1104
|
return t === i;
|
|
1105
1105
|
}
|
|
1106
|
-
const
|
|
1106
|
+
const De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Nt = (s, i) => {
|
|
1107
1107
|
const e = x(() => s.map((t) => /* @__PURE__ */ r("div", { children: t.getInput(i) }, t.getId())), [s, i]);
|
|
1108
1108
|
return /* @__PURE__ */ r(y, { direction: "column", gap: "2", children: e });
|
|
1109
|
-
},
|
|
1109
|
+
}, _e = (s) => Object.keys(s).length > 0, Bt = async (s, i) => {
|
|
1110
1110
|
const e = {};
|
|
1111
1111
|
for (const t of s.fields)
|
|
1112
1112
|
if (t instanceof Z) {
|
|
1113
1113
|
if (t.condition) {
|
|
1114
1114
|
const { identifier: n } = t.condition;
|
|
1115
|
-
if (!
|
|
1115
|
+
if (!Rt(t.condition, ue(i, n)))
|
|
1116
1116
|
continue;
|
|
1117
1117
|
}
|
|
1118
1118
|
Object.assign(e, t.getErrors(i));
|
|
@@ -1120,18 +1120,18 @@ const Ve = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Ot = (s,
|
|
|
1120
1120
|
if (!(t instanceof M))
|
|
1121
1121
|
throw new Error("Invalid field type");
|
|
1122
1122
|
const n = t.getId(), o = t.getError(ue(i, n), i);
|
|
1123
|
-
o &&
|
|
1123
|
+
o && st(e, n, o);
|
|
1124
1124
|
}
|
|
1125
|
-
if (
|
|
1125
|
+
if (_e(e))
|
|
1126
1126
|
return e;
|
|
1127
|
-
},
|
|
1127
|
+
}, on = [null, void 0], ct = (s, i) => s.reduce((e, t) => t instanceof Z ? { ...e, ...ct(t.fields, i) } : (on.includes(ue(e, t.getId())) && st(e, t.getId(), ""), e), i), sn = () => {
|
|
1128
1128
|
throw new Error("onSubmit must be provided if form is not readonly.");
|
|
1129
|
-
},
|
|
1129
|
+
}, dt = S(
|
|
1130
1130
|
xe((s, i) => {
|
|
1131
1131
|
const {
|
|
1132
1132
|
schema: e,
|
|
1133
1133
|
values: t = {},
|
|
1134
|
-
onSubmit: n =
|
|
1134
|
+
onSubmit: n = sn,
|
|
1135
1135
|
submitText: o = "Submit",
|
|
1136
1136
|
cancelText: a,
|
|
1137
1137
|
onCancel: c,
|
|
@@ -1140,55 +1140,55 @@ const Ve = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Ot = (s,
|
|
|
1140
1140
|
hideTitle: f = !e.title,
|
|
1141
1141
|
hideDescription: d,
|
|
1142
1142
|
className: u
|
|
1143
|
-
} = s, { readonly:
|
|
1144
|
-
initialValues:
|
|
1143
|
+
} = s, { readonly: p } = e.meta, h = x(() => crypto.randomUUID(), []), b = tt({
|
|
1144
|
+
initialValues: ct(e.fields, t),
|
|
1145
1145
|
onSubmit: n,
|
|
1146
|
-
validate: (V) =>
|
|
1146
|
+
validate: (V) => Bt(e, V),
|
|
1147
1147
|
// only validate the entire form on submit
|
|
1148
1148
|
validateOnBlur: !1,
|
|
1149
1149
|
validateOnChange: !1
|
|
1150
|
-
}), { dirty:
|
|
1151
|
-
() => typeof e.title == "string" ? /* @__PURE__ */ r(
|
|
1150
|
+
}), { dirty: z } = b, I = x(
|
|
1151
|
+
() => typeof e.title == "string" ? /* @__PURE__ */ r(Me, { children: e.title }) : e.title,
|
|
1152
1152
|
[e.title]
|
|
1153
1153
|
), C = x(
|
|
1154
|
-
() => typeof e.description == "string" ? /* @__PURE__ */ r($, { className:
|
|
1154
|
+
() => typeof e.description == "string" ? /* @__PURE__ */ r($, { className: Ne.description, children: e.description }) : e.description,
|
|
1155
1155
|
[e.description]
|
|
1156
|
-
), w =
|
|
1156
|
+
), w = Nt(e.fields, { formId: h, disabled: p });
|
|
1157
1157
|
return ve(() => {
|
|
1158
|
-
|
|
1159
|
-
}, [
|
|
1158
|
+
z && l && l();
|
|
1159
|
+
}, [z, l]), /* @__PURE__ */ r(it, { value: b, children: /* @__PURE__ */ r(y, { ref: i, direction: "column", gap: "2", className: u, asChild: !0, children: /* @__PURE__ */ g("form", { id: h, onSubmit: b.handleSubmit, children: [
|
|
1160
1160
|
!f && /* @__PURE__ */ r(we, { children: /* @__PURE__ */ g(y, { direction: "column", gap: "1", children: [
|
|
1161
1161
|
I,
|
|
1162
1162
|
!d && C
|
|
1163
1163
|
] }) }),
|
|
1164
1164
|
w,
|
|
1165
|
-
!
|
|
1165
|
+
!p && /* @__PURE__ */ g(y, { justify: "end", gap: "2", children: [
|
|
1166
1166
|
a && /* @__PURE__ */ r(G, { type: "button", variant: "soft", onClick: c, children: a }),
|
|
1167
1167
|
/* @__PURE__ */ r(G, { type: "submit", disabled: !b.isValid, children: o })
|
|
1168
1168
|
] })
|
|
1169
1169
|
] }) }) });
|
|
1170
1170
|
})
|
|
1171
|
-
),
|
|
1171
|
+
), Nn = S(
|
|
1172
1172
|
xe((s, i) => {
|
|
1173
|
-
const { submission: e, showFormDescription: t = !1, showFormTitle: n = !0 } = s, o =
|
|
1173
|
+
const { submission: e, showFormDescription: t = !1, showFormTitle: n = !0 } = s, o = _(St(e.form_revision)), { sdk: a } = zt();
|
|
1174
1174
|
if (!o)
|
|
1175
1175
|
throw new Error(
|
|
1176
1176
|
`Could not find revision ${e.form_revision} for submission ${e.offline_id}.`
|
|
1177
1177
|
);
|
|
1178
|
-
const c = x(() =>
|
|
1179
|
-
const f =
|
|
1178
|
+
const c = x(() => Mt(o, { readonly: !0 }), [o]), l = x(() => {
|
|
1179
|
+
const f = Ei(e.offline_id)(a.store.getState()) ?? [], d = {};
|
|
1180
1180
|
for (const u of f) {
|
|
1181
|
-
const
|
|
1181
|
+
const p = a.files.fetchFileFromUrl(u.file, u.file_sha1, u.file_name).then((b) => {
|
|
1182
1182
|
if (!b.success)
|
|
1183
1183
|
throw new Error(`Failed to download attachment ${u.file_name}.`);
|
|
1184
1184
|
return b.body;
|
|
1185
|
-
}),
|
|
1186
|
-
|
|
1185
|
+
}), h = d[u.field_identifier];
|
|
1186
|
+
h ? h.push(p) : d[u.field_identifier] = [p];
|
|
1187
1187
|
}
|
|
1188
1188
|
return { ...e.values, ...d };
|
|
1189
1189
|
}, [a.files, a.store, e.offline_id, e.values]);
|
|
1190
1190
|
return /* @__PURE__ */ r(
|
|
1191
|
-
|
|
1191
|
+
dt,
|
|
1192
1192
|
{
|
|
1193
1193
|
ref: i,
|
|
1194
1194
|
schema: c,
|
|
@@ -1198,38 +1198,38 @@ const Ve = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Ot = (s,
|
|
|
1198
1198
|
}
|
|
1199
1199
|
);
|
|
1200
1200
|
})
|
|
1201
|
-
),
|
|
1202
|
-
favoriteIcon:
|
|
1203
|
-
regularIcon:
|
|
1204
|
-
},
|
|
1201
|
+
), ln = "_favoriteIcon_1bixi_1", an = "_regularIcon_1bixi_9", bt = {
|
|
1202
|
+
favoriteIcon: ln,
|
|
1203
|
+
regularIcon: an
|
|
1204
|
+
}, He = "organization:", je = "user:", Bn = S(
|
|
1205
1205
|
xe((s, i) => {
|
|
1206
|
-
const { maxResults: e = 20, ...t } = s, [n, o] = de(""), [a, c] = de(""), { sdk: l } =
|
|
1206
|
+
const { maxResults: e = 20, ...t } = s, [n, o] = de(""), [a, c] = de(""), { sdk: l } = zt(), f = x(() => {
|
|
1207
1207
|
const w = { maxResults: e, searchTerm: n };
|
|
1208
|
-
return a && (a.startsWith(
|
|
1209
|
-
}, [n, e, a]), d =
|
|
1208
|
+
return a && (a.startsWith(He) ? w.owner_organization = parseInt(a.slice(He.length)) : a.startsWith(je) && (w.owner_user = parseInt(a.slice(je.length)))), w;
|
|
1209
|
+
}, [n, e, a]), d = _(Ai(f)) ?? [], u = _(Li), p = T(
|
|
1210
1210
|
(w) => {
|
|
1211
1211
|
w.favorite ? l.userForms.unfavorite(w.offline_id).then() : l.userForms.favorite(w.offline_id).then();
|
|
1212
1212
|
},
|
|
1213
1213
|
[l]
|
|
1214
|
-
),
|
|
1214
|
+
), h = x(() => {
|
|
1215
1215
|
const w = l.store.getState(), V = {};
|
|
1216
1216
|
for (const L of Object.values(u)) {
|
|
1217
|
-
const v =
|
|
1218
|
-
v && (V[`${
|
|
1219
|
-
const P =
|
|
1220
|
-
P && (V[`${
|
|
1217
|
+
const v = Et(L.owner_organization || -1)(w);
|
|
1218
|
+
v && (V[`${He}${v.id}`] = v.name);
|
|
1219
|
+
const P = ot(L.owner_user || -1)(w);
|
|
1220
|
+
P && (V[`${je}${P.id}`] = P.username);
|
|
1221
1221
|
}
|
|
1222
1222
|
return Object.entries(V).map(([L, v]) => ({ itemContent: v, value: L }));
|
|
1223
|
-
}, [u, l.store]), b =
|
|
1223
|
+
}, [u, l.store]), b = T((w) => {
|
|
1224
1224
|
o(w.currentTarget.value);
|
|
1225
|
-
}, []), I = (
|
|
1225
|
+
}, []), I = (_(Pi) || 0) - d.length, C = d.length == e && I > 0 ? `Only the first ${e} results are shown (${I} hidden)` : I > 0 && `${I} hidden forms`;
|
|
1226
1226
|
return /* @__PURE__ */ g(y, { ref: i, direction: "column", gap: "2", children: [
|
|
1227
1227
|
/* @__PURE__ */ g(y, { gap: "2", grow: "1", children: [
|
|
1228
1228
|
/* @__PURE__ */ r(ge, { grow: "1", asChild: !0, children: /* @__PURE__ */ r(ae.Root, { size: "3", children: /* @__PURE__ */ r(ae.Input, { placeholder: "Filter", value: n, onChange: b }) }) }),
|
|
1229
1229
|
/* @__PURE__ */ r(
|
|
1230
|
-
|
|
1230
|
+
It,
|
|
1231
1231
|
{
|
|
1232
|
-
items:
|
|
1232
|
+
items: h,
|
|
1233
1233
|
value: a,
|
|
1234
1234
|
onValueChange: c,
|
|
1235
1235
|
placeholder: "Owner",
|
|
@@ -1237,79 +1237,79 @@ const Ve = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Ot = (s,
|
|
|
1237
1237
|
}
|
|
1238
1238
|
)
|
|
1239
1239
|
] }),
|
|
1240
|
-
d.length > 0 && /* @__PURE__ */ r(
|
|
1241
|
-
|
|
1240
|
+
d.length > 0 && /* @__PURE__ */ r(Re.Root, { children: d.map((w) => /* @__PURE__ */ r(
|
|
1241
|
+
cn,
|
|
1242
1242
|
{
|
|
1243
1243
|
...t,
|
|
1244
1244
|
form: w,
|
|
1245
|
-
handleToggleFavorite: () =>
|
|
1245
|
+
handleToggleFavorite: () => p(w)
|
|
1246
1246
|
},
|
|
1247
1247
|
w.offline_id
|
|
1248
1248
|
)) }),
|
|
1249
1249
|
/* @__PURE__ */ r(ge, { px: "3", children: /* @__PURE__ */ r($, { size: "2", severity: "info", children: C }) })
|
|
1250
1250
|
] });
|
|
1251
1251
|
})
|
|
1252
|
-
),
|
|
1253
|
-
var
|
|
1254
|
-
const { form: i, onSelectForm: e, isFavoriteEditable: t, handleToggleFavorite: n } = s, o = (
|
|
1255
|
-
(
|
|
1256
|
-
|
|
1252
|
+
), cn = (s) => {
|
|
1253
|
+
var p;
|
|
1254
|
+
const { form: i, onSelectForm: e, isFavoriteEditable: t, handleToggleFavorite: n } = s, o = (p = _(Et(i.owner_organization || -1))) == null ? void 0 : p.name, a = _(ot(i.owner_user || -1)), c = _(At).id, l = !!a && a.id === c, f = o ?? (l ? "You" : a == null ? void 0 : a.username) ?? "Unknown", d = T(
|
|
1255
|
+
(h) => {
|
|
1256
|
+
h.stopPropagation(), n();
|
|
1257
1257
|
},
|
|
1258
1258
|
[n]
|
|
1259
|
-
), u = /* @__PURE__ */ r(
|
|
1259
|
+
), u = /* @__PURE__ */ r(Re.Item, { onClick: () => e(i), asChild: !0, children: /* @__PURE__ */ g(y, { justify: "between", gap: "2", py: "2", px: "3", ...si, children: [
|
|
1260
1260
|
/* @__PURE__ */ g(y, { grow: "1", align: "center", gap: "2", children: [
|
|
1261
1261
|
/* @__PURE__ */ r(
|
|
1262
1262
|
ce,
|
|
1263
1263
|
{
|
|
1264
|
-
className:
|
|
1264
|
+
className: Lt(i.favorite ? bt.favoriteIcon : bt.regularIcon),
|
|
1265
1265
|
variant: "ghost",
|
|
1266
1266
|
onClick: d,
|
|
1267
1267
|
"aria-label": i.favorite ? "Favorite form" : "Standard form",
|
|
1268
1268
|
disabled: !t,
|
|
1269
|
-
children: i.favorite ? /* @__PURE__ */ r(
|
|
1269
|
+
children: i.favorite ? /* @__PURE__ */ r(li, {}) : /* @__PURE__ */ r(ai, {})
|
|
1270
1270
|
}
|
|
1271
1271
|
),
|
|
1272
1272
|
/* @__PURE__ */ r($, { noWrap: !0, children: i.latestRevision.title }),
|
|
1273
|
-
i.latestRevision.description && /* @__PURE__ */ r(
|
|
1273
|
+
i.latestRevision.description && /* @__PURE__ */ r(ci, {})
|
|
1274
1274
|
] }),
|
|
1275
1275
|
f && /* @__PURE__ */ g(y, { align: "center", gap: "2", children: [
|
|
1276
|
-
/* @__PURE__ */ r(
|
|
1276
|
+
/* @__PURE__ */ r(di, {}),
|
|
1277
1277
|
" ",
|
|
1278
1278
|
f
|
|
1279
1279
|
] })
|
|
1280
1280
|
] }) });
|
|
1281
|
-
return i.latestRevision.description ? /* @__PURE__ */ r(
|
|
1282
|
-
},
|
|
1283
|
-
submissionsContainer:
|
|
1284
|
-
stopHorizontalOverflow:
|
|
1285
|
-
},
|
|
1281
|
+
return i.latestRevision.description ? /* @__PURE__ */ r(ui, { content: i.latestRevision.description, children: u }, i.offline_id) : u;
|
|
1282
|
+
}, dn = "_submissionsContainer_9iirt_1", un = "_stopHorizontalOverflow_9iirt_6", qt = {
|
|
1283
|
+
submissionsContainer: dn,
|
|
1284
|
+
stopHorizontalOverflow: un
|
|
1285
|
+
}, fn = S(function(i) {
|
|
1286
1286
|
var w;
|
|
1287
|
-
const { submission: e, onSubmissionClick: t, compact: n, labelType: o, rowDecorator: a } = i, c =
|
|
1287
|
+
const { submission: e, onSubmissionClick: t, compact: n, labelType: o, rowDecorator: a } = i, c = _(At), l = _(ot("created_by" in e ? e.created_by : c.id)), f = Qe(e), d = ki(f) ? f.toLocaleTimeString([], {
|
|
1288
1288
|
hour: "2-digit",
|
|
1289
1289
|
minute: "2-digit"
|
|
1290
|
-
}) :
|
|
1290
|
+
}) : $i(f), u = _(St(e.form_revision));
|
|
1291
1291
|
if (!u)
|
|
1292
1292
|
throw new Error(`Could not find revision ${e.form_revision} for submission ${e.offline_id}.`);
|
|
1293
|
-
const
|
|
1293
|
+
const p = (w = _(Vi(u.form))) == null ? void 0 : w.revision, h = Di({
|
|
1294
1294
|
file: (l == null ? void 0 : l.profile.file) ?? null,
|
|
1295
1295
|
fileSha1: (l == null ? void 0 : l.profile.file_sha1) ?? null
|
|
1296
|
-
}), b = (l == null ? void 0 : l.username.charAt(0).toUpperCase()) ?? "?",
|
|
1296
|
+
}), b = (l == null ? void 0 : l.username.charAt(0).toUpperCase()) ?? "?", z = u.revision === p, I = Fi.useCallback(() => {
|
|
1297
1297
|
t && t({ submission: e });
|
|
1298
|
-
}, [e, t]), C = /* @__PURE__ */ r(
|
|
1299
|
-
/* @__PURE__ */ g(y, { gap: "2", align: "center", className:
|
|
1300
|
-
/* @__PURE__ */ r(
|
|
1298
|
+
}, [e, t]), C = /* @__PURE__ */ r(Re.Item, { onClick: I, asChild: !0, children: /* @__PURE__ */ g(y, { grow: "1", width: "100%", p: "2", gap: "2", justify: "between", children: [
|
|
1299
|
+
/* @__PURE__ */ g(y, { gap: "2", align: "center", className: qt.stopHorizontalOverflow, children: [
|
|
1300
|
+
/* @__PURE__ */ r(fi, { src: h, size: "1", fallback: b }),
|
|
1301
1301
|
/* @__PURE__ */ r($, { size: "2", noWrap: !0, children: o === "creator" ? (l || c).username : u.title })
|
|
1302
1302
|
] }),
|
|
1303
1303
|
/* @__PURE__ */ g(y, { gap: "2", align: "center", children: [
|
|
1304
|
-
!n && (u.revision ? /* @__PURE__ */ r(
|
|
1304
|
+
!n && (u.revision ? /* @__PURE__ */ r(Ue, { variant: "soft", severity: z ? "primary" : "info", children: n ? u.revision.toString() : `Revision #${u.revision}` }) : !!p && /* @__PURE__ */ r(Ue, { children: "Original" })),
|
|
1305
1305
|
/* @__PURE__ */ r($, { size: "2", noWrap: !0, children: d })
|
|
1306
1306
|
] })
|
|
1307
1307
|
] }) });
|
|
1308
1308
|
return a ? a(e, C) : C;
|
|
1309
|
-
}),
|
|
1309
|
+
}), Qe = (s) => {
|
|
1310
1310
|
const i = "created_at" in s ? s.created_at : s.submitted_at;
|
|
1311
1311
|
return new Date(i);
|
|
1312
|
-
},
|
|
1312
|
+
}, qn = S(function(i) {
|
|
1313
1313
|
const {
|
|
1314
1314
|
formId: e,
|
|
1315
1315
|
submissions: t,
|
|
@@ -1321,16 +1321,16 @@ const Ve = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Ot = (s,
|
|
|
1321
1321
|
} = i;
|
|
1322
1322
|
if (!!e == !!t)
|
|
1323
1323
|
throw new Error("Either formId or submissions must be provided, but not both.");
|
|
1324
|
-
const f =
|
|
1325
|
-
t ? () => t :
|
|
1324
|
+
const f = _(
|
|
1325
|
+
t ? () => t : _i(e)
|
|
1326
1326
|
), d = x(
|
|
1327
|
-
() => f == null ? void 0 : f.sort((u,
|
|
1327
|
+
() => f == null ? void 0 : f.sort((u, p) => Qe(p).getTime() - Qe(u).getTime()),
|
|
1328
1328
|
[f]
|
|
1329
1329
|
);
|
|
1330
1330
|
return /* @__PURE__ */ r(
|
|
1331
|
-
|
|
1331
|
+
Re.Root,
|
|
1332
1332
|
{
|
|
1333
|
-
className:
|
|
1333
|
+
className: Lt(qt.submissionsContainer, o),
|
|
1334
1334
|
size: "small",
|
|
1335
1335
|
variant: c,
|
|
1336
1336
|
before: !n && /* @__PURE__ */ g($, { severity: "info", children: [
|
|
@@ -1339,19 +1339,19 @@ const Ve = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Ot = (s,
|
|
|
1339
1339
|
" submissions of this form."
|
|
1340
1340
|
] }),
|
|
1341
1341
|
after: a,
|
|
1342
|
-
children: d == null ? void 0 : d.map((u,
|
|
1343
|
-
|
|
1342
|
+
children: d == null ? void 0 : d.map((u, p) => /* @__PURE__ */ r(
|
|
1343
|
+
fn,
|
|
1344
1344
|
{
|
|
1345
1345
|
submission: u,
|
|
1346
1346
|
compact: n,
|
|
1347
1347
|
...l
|
|
1348
1348
|
},
|
|
1349
|
-
|
|
1349
|
+
p
|
|
1350
1350
|
))
|
|
1351
1351
|
}
|
|
1352
1352
|
);
|
|
1353
|
-
}),
|
|
1354
|
-
const { name: e, render: t } = i, { submitForm: n } =
|
|
1353
|
+
}), Wn = S(function(i) {
|
|
1354
|
+
const { name: e, render: t } = i, { submitForm: n } = pe(), [o, a, c] = et(e);
|
|
1355
1355
|
return x(() => {
|
|
1356
1356
|
const l = (f) => c.setValue(f, !1);
|
|
1357
1357
|
return t({
|
|
@@ -1360,40 +1360,40 @@ const Ve = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Ot = (s,
|
|
|
1360
1360
|
patchValue: n
|
|
1361
1361
|
});
|
|
1362
1362
|
}, [n, c, o.value, t]);
|
|
1363
|
-
}),
|
|
1363
|
+
}), Hn = S(
|
|
1364
1364
|
xe((s, i) => {
|
|
1365
|
-
const { children: e, schema: t, values: n, onPatch: o, onError: a, ...c } = s, l = x(() =>
|
|
1365
|
+
const { children: e, schema: t, values: n, onPatch: o, onError: a, ...c } = s, l = x(() => ct(t.fields, n), [t.fields, n]), f = T(
|
|
1366
1366
|
(b) => {
|
|
1367
|
-
const
|
|
1367
|
+
const z = {};
|
|
1368
1368
|
for (const I in b) {
|
|
1369
1369
|
const C = b[I];
|
|
1370
|
-
C !== l[I] && C !== void 0 && (
|
|
1370
|
+
C !== l[I] && C !== void 0 && (z[I] = C);
|
|
1371
1371
|
}
|
|
1372
|
-
|
|
1372
|
+
_e(z) && o(z);
|
|
1373
1373
|
},
|
|
1374
1374
|
[l, o]
|
|
1375
|
-
), d =
|
|
1375
|
+
), d = T(
|
|
1376
1376
|
async (b) => {
|
|
1377
|
-
const
|
|
1378
|
-
return
|
|
1377
|
+
const z = await Bt(t, b);
|
|
1378
|
+
return z && a(z), z;
|
|
1379
1379
|
},
|
|
1380
1380
|
[t, a]
|
|
1381
|
-
), u =
|
|
1381
|
+
), u = tt({
|
|
1382
1382
|
initialValues: l,
|
|
1383
1383
|
onSubmit: f,
|
|
1384
1384
|
validate: d,
|
|
1385
1385
|
// only validate the entire form on submit
|
|
1386
1386
|
validateOnBlur: !1,
|
|
1387
1387
|
validateOnChange: !1
|
|
1388
|
-
}), { errors:
|
|
1388
|
+
}), { errors: p, resetForm: h } = u;
|
|
1389
1389
|
return ve(() => {
|
|
1390
|
-
|
|
1391
|
-
}, [
|
|
1390
|
+
_e(p) && h({ values: l, errors: {} });
|
|
1391
|
+
}, [p, l, h]), /* @__PURE__ */ r(it, { value: u, children: /* @__PURE__ */ r("form", { ...c, ref: i, onSubmit: u.handleSubmit, children: e }) });
|
|
1392
1392
|
})
|
|
1393
|
-
),
|
|
1394
|
-
...
|
|
1393
|
+
), Wt = {
|
|
1394
|
+
...at,
|
|
1395
1395
|
section: Z
|
|
1396
|
-
},
|
|
1396
|
+
}, mn = S(function(i) {
|
|
1397
1397
|
const { field: e, setFieldType: t } = i, n = e.fieldTypeName, o = e.fieldTypeDescription, a = e.Icon;
|
|
1398
1398
|
return /* @__PURE__ */ g(y, { gap: "4", align: "center", children: [
|
|
1399
1399
|
/* @__PURE__ */ r(G, { type: "button", variant: "surface", onClick: t, style: { width: "135px" }, children: /* @__PURE__ */ g(y, { gap: "3", align: "center", grow: "1", children: [
|
|
@@ -1402,34 +1402,34 @@ const Ve = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Ot = (s,
|
|
|
1402
1402
|
] }) }),
|
|
1403
1403
|
/* @__PURE__ */ r($, { children: o })
|
|
1404
1404
|
] });
|
|
1405
|
-
}),
|
|
1405
|
+
}), Ht = [
|
|
1406
1406
|
["string", "text"],
|
|
1407
1407
|
["select", "multi-select", "upload"],
|
|
1408
1408
|
["boolean", "date", "number", "multi-string"]
|
|
1409
|
-
],
|
|
1409
|
+
], pn = Ht.length - 1, hn = S(function(i) {
|
|
1410
1410
|
const { setFieldType: e } = i;
|
|
1411
|
-
return /* @__PURE__ */ r(y, { direction: "column", gap: "3", children:
|
|
1411
|
+
return /* @__PURE__ */ r(y, { direction: "column", gap: "3", children: Ht.map((t, n) => /* @__PURE__ */ g(y, { direction: "column", gap: "3", children: [
|
|
1412
1412
|
/* @__PURE__ */ r(y, { direction: "column", gap: "2", children: t.map((o) => /* @__PURE__ */ r(
|
|
1413
|
-
|
|
1413
|
+
mn,
|
|
1414
1414
|
{
|
|
1415
|
-
field:
|
|
1415
|
+
field: at[o],
|
|
1416
1416
|
setFieldType: () => e(o)
|
|
1417
1417
|
},
|
|
1418
1418
|
o
|
|
1419
1419
|
)) }),
|
|
1420
|
-
n <
|
|
1420
|
+
n < pn && /* @__PURE__ */ r(mi, { size: "4" })
|
|
1421
1421
|
] }, n)) });
|
|
1422
|
-
}),
|
|
1422
|
+
}), gn = (s) => (i) => {
|
|
1423
1423
|
if (!(!i || typeof i != "string") && s.includes(i.trim()))
|
|
1424
1424
|
return "This name is already taken.";
|
|
1425
|
-
},
|
|
1425
|
+
}, bn = (s, i) => {
|
|
1426
1426
|
const e = [
|
|
1427
1427
|
new be({
|
|
1428
1428
|
label: "Label",
|
|
1429
1429
|
required: !0,
|
|
1430
1430
|
maxLength: 200,
|
|
1431
1431
|
identifier: "label",
|
|
1432
|
-
fieldValidators: [
|
|
1432
|
+
fieldValidators: [gn(s)]
|
|
1433
1433
|
}),
|
|
1434
1434
|
new ye({
|
|
1435
1435
|
label: "Description",
|
|
@@ -1442,10 +1442,10 @@ const Ve = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Ot = (s,
|
|
|
1442
1442
|
...e,
|
|
1443
1443
|
new fe({ label: "Required", description: null, required: !1, identifier: "required" })
|
|
1444
1444
|
];
|
|
1445
|
-
},
|
|
1446
|
-
const { fieldType: e, handleCancel: t, handleCreateField: n, defaultField: o, conditionalSourceFields: a } = i, c =
|
|
1447
|
-
const d =
|
|
1448
|
-
let u =
|
|
1445
|
+
}, yn = S(function(i) {
|
|
1446
|
+
const { fieldType: e, handleCancel: t, handleCreateField: n, defaultField: o, conditionalSourceFields: a } = i, c = Wt[e], l = pe(), f = x(() => {
|
|
1447
|
+
const d = Dt(l.values.fields).filter((p) => p !== (o == null ? void 0 : o.label));
|
|
1448
|
+
let u = bn(d, e);
|
|
1449
1449
|
if (c === Z) {
|
|
1450
1450
|
if (a === void 0)
|
|
1451
1451
|
throw new Error("Conditional source fields must be provided when changing sections.");
|
|
@@ -1463,7 +1463,7 @@ const Ve = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Ot = (s,
|
|
|
1463
1463
|
};
|
|
1464
1464
|
}, [l.values.fields, e, c, o == null ? void 0 : o.label, a]);
|
|
1465
1465
|
return /* @__PURE__ */ r(
|
|
1466
|
-
|
|
1466
|
+
dt,
|
|
1467
1467
|
{
|
|
1468
1468
|
schema: f,
|
|
1469
1469
|
values: o,
|
|
@@ -1472,35 +1472,35 @@ const Ve = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Ot = (s,
|
|
|
1472
1472
|
onCancel: t
|
|
1473
1473
|
}
|
|
1474
1474
|
);
|
|
1475
|
-
}),
|
|
1476
|
-
const { parentPath: e, index: t, children: n, initial: o, editing: a, conditionalSourceFields: c } = i, [l, f] = de(), d = (o == null ? void 0 : o.type) ?? l, u = d ?
|
|
1475
|
+
}), he = S(function(i) {
|
|
1476
|
+
const { parentPath: e, index: t, children: n, initial: o, editing: a, conditionalSourceFields: c } = i, [l, f] = de(), d = (o == null ? void 0 : o.type) ?? l, u = d ? Wt[d].fieldTypeName : void 0, { setFieldValue: p, values: h } = pe();
|
|
1477
1477
|
if (a && !o)
|
|
1478
1478
|
throw new Error("Initial field must be provided if editing is true.");
|
|
1479
|
-
const b = !d && !a && !o,
|
|
1479
|
+
const b = !d && !a && !o, z = b ? "Choose a field type" : `${u} settings`, I = b ? "Select a field type to add to this section." : (u == null ? void 0 : u.toLowerCase()) === "section" ? "Customize your section" : `Customize your ${u == null ? void 0 : u.toLowerCase()} field.`, C = T(() => f(void 0), []), w = T((v) => {
|
|
1480
1480
|
f(void 0), v();
|
|
1481
|
-
}, []), V =
|
|
1481
|
+
}, []), V = T(
|
|
1482
1482
|
(v, P) => {
|
|
1483
1483
|
const { label: R } = v;
|
|
1484
1484
|
if (!d)
|
|
1485
1485
|
throw new Error("Field type must be selected before creating a field.");
|
|
1486
1486
|
if (!R || typeof R != "string")
|
|
1487
1487
|
throw new Error("Label must be provided before creating a field.");
|
|
1488
|
-
const X =
|
|
1488
|
+
const X = Be({
|
|
1489
1489
|
type: d,
|
|
1490
1490
|
...v,
|
|
1491
|
-
identifier:
|
|
1492
|
-
}).serialize(),
|
|
1493
|
-
if (
|
|
1491
|
+
identifier: $t(v.identifier, R)
|
|
1492
|
+
}).serialize(), j = ue(h, e);
|
|
1493
|
+
if (j === void 0)
|
|
1494
1494
|
throw new Error("Parent path must point to an existing field.");
|
|
1495
1495
|
let U;
|
|
1496
|
-
if (!Array.isArray(
|
|
1496
|
+
if (!Array.isArray(j))
|
|
1497
1497
|
throw new Error("Parent path must point to an array.");
|
|
1498
|
-
a ? U =
|
|
1498
|
+
a ? U = Gi(j, t, X) : U = kt(j, t, X), p(e, U).then(), P();
|
|
1499
1499
|
},
|
|
1500
|
-
[a, d,
|
|
1501
|
-
), L =
|
|
1502
|
-
(v) => b ? /* @__PURE__ */ r(
|
|
1503
|
-
|
|
1500
|
+
[a, d, h, e, p, t]
|
|
1501
|
+
), L = T(
|
|
1502
|
+
(v) => b ? /* @__PURE__ */ r(hn, { setFieldType: f }) : /* @__PURE__ */ r(
|
|
1503
|
+
yn,
|
|
1504
1504
|
{
|
|
1505
1505
|
conditionalSourceFields: c,
|
|
1506
1506
|
handleCancel: C,
|
|
@@ -1511,43 +1511,43 @@ const Ve = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Ot = (s,
|
|
|
1511
1511
|
),
|
|
1512
1512
|
[c, C, V, o, b, d]
|
|
1513
1513
|
);
|
|
1514
|
-
return /* @__PURE__ */ r(
|
|
1515
|
-
}),
|
|
1514
|
+
return /* @__PURE__ */ r(pi, { onCloseInterrupt: w, title: z, description: I, content: L, children: n });
|
|
1515
|
+
}), yt = ({ children: s }) => /* @__PURE__ */ r(Je, { children: s }), wt = (s, i) => ({
|
|
1516
1516
|
initial: s ? i : "none",
|
|
1517
1517
|
sm: s ? "none" : i
|
|
1518
|
-
}),
|
|
1518
|
+
}), jt = S(function(i) {
|
|
1519
1519
|
const { remove: e, dragHandleProps: t, editProps: n, insertAfterProps: o, duplicateProps: a } = i, c = x(
|
|
1520
1520
|
() => [
|
|
1521
1521
|
{
|
|
1522
|
-
Wrapper:
|
|
1522
|
+
Wrapper: he,
|
|
1523
1523
|
wrapperProps: n,
|
|
1524
|
-
Icon:
|
|
1524
|
+
Icon: hi,
|
|
1525
1525
|
text: "Edit"
|
|
1526
1526
|
},
|
|
1527
1527
|
{
|
|
1528
|
-
Icon:
|
|
1528
|
+
Icon: gi,
|
|
1529
1529
|
buttonProps: {
|
|
1530
1530
|
onClick: e
|
|
1531
1531
|
},
|
|
1532
1532
|
text: "Delete"
|
|
1533
1533
|
},
|
|
1534
1534
|
{
|
|
1535
|
-
Wrapper:
|
|
1535
|
+
Wrapper: he,
|
|
1536
1536
|
wrapperProps: a,
|
|
1537
|
-
Icon:
|
|
1537
|
+
Icon: bi,
|
|
1538
1538
|
text: "Duplicate"
|
|
1539
1539
|
},
|
|
1540
1540
|
{
|
|
1541
|
-
Wrapper:
|
|
1541
|
+
Wrapper: he,
|
|
1542
1542
|
wrapperProps: o,
|
|
1543
|
-
Icon:
|
|
1543
|
+
Icon: Oe,
|
|
1544
1544
|
text: "Add after"
|
|
1545
1545
|
},
|
|
1546
1546
|
{
|
|
1547
1547
|
// Wrapping icon in a div so that the asChild turns the button into a div
|
|
1548
1548
|
// so that the drag handle props are not applied to the icon
|
|
1549
1549
|
// Note: b/c the <button> does not handle the space-press event correctly
|
|
1550
|
-
Icon: (l) => /* @__PURE__ */ r("div", { ...l, children: /* @__PURE__ */ r(
|
|
1550
|
+
Icon: (l) => /* @__PURE__ */ r("div", { ...l, children: /* @__PURE__ */ r(yi, {}) }),
|
|
1551
1551
|
text: "Reorder",
|
|
1552
1552
|
disableOnMobile: !0,
|
|
1553
1553
|
buttonProps: { ...t, asChild: !0 }
|
|
@@ -1555,21 +1555,21 @@ const Ve = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Ot = (s,
|
|
|
1555
1555
|
],
|
|
1556
1556
|
[t, a, n, o, e]
|
|
1557
1557
|
);
|
|
1558
|
-
return /* @__PURE__ */ g(
|
|
1559
|
-
/* @__PURE__ */ r(y, { gap: "4", display:
|
|
1560
|
-
const f = l.Wrapper ??
|
|
1558
|
+
return /* @__PURE__ */ g(Je, { children: [
|
|
1559
|
+
/* @__PURE__ */ r(y, { gap: "4", display: wt(!1, "flex"), children: c.map((l) => {
|
|
1560
|
+
const f = l.Wrapper ?? yt;
|
|
1561
1561
|
return /* @__PURE__ */ r(f, { ...l.wrapperProps, children: /* @__PURE__ */ r(ce, { type: "button", variant: "ghost", "aria-label": l.text, ...l.buttonProps, children: /* @__PURE__ */ r(l.Icon, {}) }) }, l.text);
|
|
1562
1562
|
}) }),
|
|
1563
|
-
/* @__PURE__ */ r(ge, { display:
|
|
1564
|
-
|
|
1563
|
+
/* @__PURE__ */ r(ge, { display: wt(!0, "block"), children: /* @__PURE__ */ r(
|
|
1564
|
+
wi,
|
|
1565
1565
|
{
|
|
1566
|
-
trigger: /* @__PURE__ */ r(ce, { variant: "ghost", "aria-label": "Actions menu", children: /* @__PURE__ */ r(
|
|
1566
|
+
trigger: /* @__PURE__ */ r(ce, { variant: "ghost", "aria-label": "Actions menu", children: /* @__PURE__ */ r(vi, {}) }),
|
|
1567
1567
|
closeOnSelect: !1,
|
|
1568
1568
|
items: c.map((l) => {
|
|
1569
1569
|
var d;
|
|
1570
1570
|
if (l.disableOnMobile)
|
|
1571
1571
|
return null;
|
|
1572
|
-
const f = l.Wrapper ??
|
|
1572
|
+
const f = l.Wrapper ?? yt;
|
|
1573
1573
|
return {
|
|
1574
1574
|
...l.buttonProps,
|
|
1575
1575
|
onSelect: (d = l.buttonProps) == null ? void 0 : d.onClick,
|
|
@@ -1582,12 +1582,12 @@ const Ve = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Ot = (s,
|
|
|
1582
1582
|
}
|
|
1583
1583
|
) })
|
|
1584
1584
|
] });
|
|
1585
|
-
}),
|
|
1586
|
-
const { field: e, index: t, sectionIndex: n, takenLabels: o, remove: a } = i, c = x(() =>
|
|
1587
|
-
(
|
|
1588
|
-
if (
|
|
1589
|
-
throw new Error(`Expected a label for field ${
|
|
1590
|
-
return { ...
|
|
1585
|
+
}), qe = "form-builder", wn = S(function(i) {
|
|
1586
|
+
const { field: e, index: t, sectionIndex: n, takenLabels: o, remove: a } = i, c = x(() => Be(e), [e]), l = De(c, { formId: qe, disabled: !0 }), f = T(
|
|
1587
|
+
(h) => {
|
|
1588
|
+
if (h.label === null)
|
|
1589
|
+
throw new Error(`Expected a label for field ${h.identifier}`);
|
|
1590
|
+
return { ...h, label: Ye(h.label, o), identifier: "" };
|
|
1591
1591
|
},
|
|
1592
1592
|
[o]
|
|
1593
1593
|
), d = x(
|
|
@@ -1605,7 +1605,7 @@ const Ve = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Ot = (s,
|
|
|
1605
1605
|
initial: f(e)
|
|
1606
1606
|
}),
|
|
1607
1607
|
[f, e, t, n]
|
|
1608
|
-
),
|
|
1608
|
+
), p = x(
|
|
1609
1609
|
() => ({
|
|
1610
1610
|
parentPath: `fields.${n}.fields`,
|
|
1611
1611
|
index: t + 1,
|
|
@@ -1613,204 +1613,205 @@ const Ve = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Ot = (s,
|
|
|
1613
1613
|
}),
|
|
1614
1614
|
[t, n]
|
|
1615
1615
|
);
|
|
1616
|
-
return /* @__PURE__ */ r(
|
|
1616
|
+
return /* @__PURE__ */ r(rt, { draggableId: e.identifier, index: t, children: (h) => /* @__PURE__ */ r(
|
|
1617
1617
|
we,
|
|
1618
1618
|
{
|
|
1619
|
-
ref:
|
|
1620
|
-
...
|
|
1621
|
-
...
|
|
1619
|
+
ref: h.innerRef,
|
|
1620
|
+
...h.draggableProps,
|
|
1621
|
+
...h.dragHandleProps,
|
|
1622
1622
|
id: `${e.identifier}-card`,
|
|
1623
1623
|
mb: "4",
|
|
1624
1624
|
children: /* @__PURE__ */ g(y, { gap: "4", justify: "between", align: "center", children: [
|
|
1625
1625
|
l,
|
|
1626
1626
|
/* @__PURE__ */ r(
|
|
1627
|
-
|
|
1627
|
+
jt,
|
|
1628
1628
|
{
|
|
1629
1629
|
remove: a,
|
|
1630
1630
|
editProps: d,
|
|
1631
1631
|
duplicateProps: u,
|
|
1632
|
-
insertAfterProps:
|
|
1633
|
-
dragHandleProps:
|
|
1632
|
+
insertAfterProps: p,
|
|
1633
|
+
dragHandleProps: h.dragHandleProps
|
|
1634
1634
|
}
|
|
1635
1635
|
)
|
|
1636
1636
|
] })
|
|
1637
1637
|
}
|
|
1638
1638
|
) });
|
|
1639
|
-
}),
|
|
1640
|
-
var
|
|
1641
|
-
const { field: e, index: t, dropState: n, conditionalFieldCounts: o } = i, a = (
|
|
1642
|
-
(
|
|
1643
|
-
for (const D of
|
|
1644
|
-
const k =
|
|
1645
|
-
|
|
1639
|
+
}), vn = S(function(i) {
|
|
1640
|
+
var U, A, N, K, Ie, Ce, Fe, ut, ft;
|
|
1641
|
+
const { field: e, index: t, dropState: n, conditionalFieldCounts: o } = i, a = (U = n[e.identifier]) == null ? void 0 : U.disabled, c = _(Oi), { setFieldValue: l, values: f } = pe(), d = xi(), u = Dt(f.fields), p = T(
|
|
1642
|
+
(E, F) => {
|
|
1643
|
+
for (const D of E) {
|
|
1644
|
+
const k = F.indexOf(D);
|
|
1645
|
+
l(`fields.${k}.condition`, null).then(), l(`fields.${k}.conditional`, !1).then();
|
|
1646
1646
|
}
|
|
1647
1647
|
},
|
|
1648
|
-
[
|
|
1649
|
-
), h =
|
|
1650
|
-
(
|
|
1648
|
+
[l]
|
|
1649
|
+
), h = T(
|
|
1650
|
+
(E) => {
|
|
1651
1651
|
var k;
|
|
1652
|
-
const
|
|
1653
|
-
if (!
|
|
1652
|
+
const F = e.fields[E];
|
|
1653
|
+
if (!F)
|
|
1654
1654
|
throw new Error("Could not find field to remove.");
|
|
1655
1655
|
const D = [];
|
|
1656
|
-
for (const
|
|
1657
|
-
((k =
|
|
1656
|
+
for (const O of f.fields)
|
|
1657
|
+
((k = O.condition) == null ? void 0 : k.identifier) === F.identifier && D.push(O);
|
|
1658
1658
|
return {
|
|
1659
|
-
removing:
|
|
1659
|
+
removing: F,
|
|
1660
1660
|
affectedSections: D,
|
|
1661
|
-
action: () =>
|
|
1661
|
+
action: () => l(`fields.${t}.fields`, Le(e.fields, E))
|
|
1662
1662
|
};
|
|
1663
1663
|
},
|
|
1664
|
-
[e.fields,
|
|
1665
|
-
),
|
|
1666
|
-
(
|
|
1667
|
-
const { affectedSections:
|
|
1668
|
-
D().then(),
|
|
1664
|
+
[e.fields, f.fields, l, t]
|
|
1665
|
+
), b = T(
|
|
1666
|
+
(E) => {
|
|
1667
|
+
const { affectedSections: F, action: D, removing: k } = h(E), O = () => {
|
|
1668
|
+
D().then(), p(F, f.fields);
|
|
1669
1669
|
};
|
|
1670
|
-
if (
|
|
1671
|
-
const
|
|
1672
|
-
return
|
|
1670
|
+
if (F.length > 0) {
|
|
1671
|
+
const We = F.map((Te) => Te.label).join(", ");
|
|
1672
|
+
return d({
|
|
1673
1673
|
title: "Remove condition?",
|
|
1674
|
-
description: `${k.label} is being used as a condition, deleting it will remove the condition from the ${
|
|
1674
|
+
description: `${k.label} is being used as a condition, deleting it will remove the condition from the ${We} section(s).`,
|
|
1675
1675
|
severity: "danger",
|
|
1676
1676
|
actionText: "Remove",
|
|
1677
|
-
onAction:
|
|
1677
|
+
onAction: O
|
|
1678
1678
|
});
|
|
1679
1679
|
}
|
|
1680
|
-
|
|
1680
|
+
O();
|
|
1681
1681
|
},
|
|
1682
|
-
[h,
|
|
1683
|
-
),
|
|
1684
|
-
const
|
|
1685
|
-
if (
|
|
1686
|
-
return
|
|
1682
|
+
[h, p, f.fields, d]
|
|
1683
|
+
), z = T(() => {
|
|
1684
|
+
const F = e.fields.map((Se, Ut) => h(Ut)).flatMap((Se) => Se.affectedSections), D = F.length ? "Remove fields and conditions?" : "Remove fields?", k = e.fields.length, O = F.map((Se) => Se.label).join(", "), We = F.length ? `Deleting this section will remove the ${k} field(s) it contains and will remove the conditions from following sections: ${O}` : `Deleting this section will remove the ${k} field(s) it contains.`, Te = Le(f.fields, t), mt = () => l("fields", Te);
|
|
1685
|
+
if (F.length > 0)
|
|
1686
|
+
return d({
|
|
1687
1687
|
title: D,
|
|
1688
|
-
description:
|
|
1688
|
+
description: We,
|
|
1689
1689
|
severity: "danger",
|
|
1690
1690
|
actionText: "Remove",
|
|
1691
1691
|
onAction: () => {
|
|
1692
|
-
|
|
1693
|
-
|
|
1692
|
+
mt().then(() => {
|
|
1693
|
+
p(F, Te);
|
|
1694
1694
|
});
|
|
1695
1695
|
}
|
|
1696
1696
|
});
|
|
1697
|
-
|
|
1697
|
+
mt().then();
|
|
1698
1698
|
}, [
|
|
1699
1699
|
e.fields,
|
|
1700
|
-
|
|
1700
|
+
f.fields,
|
|
1701
1701
|
t,
|
|
1702
1702
|
h,
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
]),
|
|
1707
|
-
(
|
|
1708
|
-
if (
|
|
1709
|
-
throw new Error(`Expected a label for field ${
|
|
1710
|
-
const
|
|
1711
|
-
const
|
|
1703
|
+
l,
|
|
1704
|
+
d,
|
|
1705
|
+
p
|
|
1706
|
+
]), I = T(
|
|
1707
|
+
(E) => {
|
|
1708
|
+
if (E.label === null)
|
|
1709
|
+
throw new Error(`Expected a label for field ${E.identifier}`);
|
|
1710
|
+
const F = Ye(E.label, u), D = E.fields.map((k) => {
|
|
1711
|
+
const O = Ye(k.label, u);
|
|
1712
1712
|
return {
|
|
1713
1713
|
...k,
|
|
1714
|
-
label:
|
|
1715
|
-
identifier:
|
|
1714
|
+
label: O,
|
|
1715
|
+
identifier: $t(void 0, O)
|
|
1716
1716
|
};
|
|
1717
1717
|
});
|
|
1718
|
-
return { ...
|
|
1718
|
+
return { ...E, label: F, fields: D, identifier: "" };
|
|
1719
1719
|
},
|
|
1720
|
-
[
|
|
1721
|
-
),
|
|
1720
|
+
[u]
|
|
1721
|
+
), C = x(
|
|
1722
1722
|
() => ({
|
|
1723
1723
|
index: t,
|
|
1724
1724
|
parentPath: "fields",
|
|
1725
1725
|
initial: e,
|
|
1726
1726
|
editing: !0,
|
|
1727
|
-
conditionalSourceFields:
|
|
1727
|
+
conditionalSourceFields: ze(f.fields, t)
|
|
1728
1728
|
}),
|
|
1729
|
-
[e, t,
|
|
1730
|
-
),
|
|
1729
|
+
[e, t, f.fields]
|
|
1730
|
+
), w = x(
|
|
1731
1731
|
() => ({
|
|
1732
1732
|
index: t + 1,
|
|
1733
1733
|
parentPath: "fields",
|
|
1734
|
-
initial:
|
|
1735
|
-
conditionalSourceFields:
|
|
1734
|
+
initial: Ae(),
|
|
1735
|
+
conditionalSourceFields: ze(f.fields, t + 1)
|
|
1736
1736
|
}),
|
|
1737
|
-
[t,
|
|
1738
|
-
),
|
|
1737
|
+
[t, f.fields]
|
|
1738
|
+
), V = x(
|
|
1739
1739
|
() => ({
|
|
1740
1740
|
parentPath: `fields.${t}.fields`,
|
|
1741
1741
|
index: e.fields.length,
|
|
1742
1742
|
initial: void 0
|
|
1743
1743
|
}),
|
|
1744
1744
|
[e.fields.length, t]
|
|
1745
|
-
),
|
|
1745
|
+
), L = x(
|
|
1746
1746
|
() => ({
|
|
1747
1747
|
index: t + 1,
|
|
1748
1748
|
parentPath: "fields",
|
|
1749
|
-
initial:
|
|
1750
|
-
conditionalSourceFields:
|
|
1749
|
+
initial: I(e),
|
|
1750
|
+
conditionalSourceFields: ze(f.fields, t + 1)
|
|
1751
1751
|
}),
|
|
1752
|
-
[
|
|
1753
|
-
),
|
|
1752
|
+
[I, e, t, f.fields]
|
|
1753
|
+
), v = x(
|
|
1754
1754
|
() => {
|
|
1755
|
-
var
|
|
1756
|
-
return (
|
|
1755
|
+
var E, F;
|
|
1756
|
+
return (F = Vt(f.fields, (E = e.condition) == null ? void 0 : E.identifier)) == null ? void 0 : F.label;
|
|
1757
1757
|
},
|
|
1758
|
-
[(
|
|
1759
|
-
),
|
|
1760
|
-
if (
|
|
1758
|
+
[(A = e.condition) == null ? void 0 : A.identifier, f.fields]
|
|
1759
|
+
), P = Array.isArray((N = e.condition) == null ? void 0 : N.value) ? "contains all of" : "equals";
|
|
1760
|
+
if (Xe((K = e.condition) == null ? void 0 : K.value))
|
|
1761
1761
|
throw new Error("File values are not supported for conditions.");
|
|
1762
|
-
const
|
|
1763
|
-
const
|
|
1762
|
+
const R = Array.isArray((Ie = e.condition) == null ? void 0 : Ie.value) ? (Fe = (Ce = e.condition) == null ? void 0 : Ce.value) == null ? void 0 : Fe.map((E) => typeof E == "string" ? E : E.label).join(", ") : (ft = (ut = e.condition) == null ? void 0 : ut.value) == null ? void 0 : ft.toString(), X = () => {
|
|
1763
|
+
const F = o.filter((O) => O !== null).length, D = o[t] ?? 0, k = 6 / F * D;
|
|
1764
1764
|
return /* @__PURE__ */ r(
|
|
1765
1765
|
"div",
|
|
1766
1766
|
{
|
|
1767
1767
|
id: `${e.identifier}-floating-point`,
|
|
1768
1768
|
style: {
|
|
1769
1769
|
width: `${6 - k}%`,
|
|
1770
|
-
marginRight: `${k}
|
|
1770
|
+
marginRight: `${k}%`,
|
|
1771
|
+
marginBottom: "4"
|
|
1771
1772
|
}
|
|
1772
1773
|
}
|
|
1773
1774
|
);
|
|
1774
|
-
},
|
|
1775
|
+
}, j = () => e.condition ? /* @__PURE__ */ g(Je, { children: [
|
|
1775
1776
|
/* @__PURE__ */ r(
|
|
1776
|
-
|
|
1777
|
+
ht,
|
|
1777
1778
|
{
|
|
1778
1779
|
start: `${e.identifier}-card`,
|
|
1779
1780
|
end: `${e.identifier}-floating-point`,
|
|
1780
1781
|
startAnchor: "left",
|
|
1781
1782
|
endAnchor: "right",
|
|
1782
|
-
color: "white",
|
|
1783
|
+
color: c === "light" ? "black" : "white",
|
|
1783
1784
|
strokeWidth: 2,
|
|
1784
1785
|
path: "straight",
|
|
1785
1786
|
showHead: !1
|
|
1786
1787
|
}
|
|
1787
1788
|
),
|
|
1788
1789
|
/* @__PURE__ */ r(
|
|
1789
|
-
|
|
1790
|
+
ht,
|
|
1790
1791
|
{
|
|
1791
1792
|
start: `${e.identifier}-floating-point`,
|
|
1792
1793
|
end: `${e.condition.identifier}-card`,
|
|
1793
1794
|
startAnchor: "right",
|
|
1794
1795
|
endAnchor: "left",
|
|
1795
|
-
color: "white",
|
|
1796
|
+
color: c === "light" ? "white" : "black",
|
|
1796
1797
|
strokeWidth: 2,
|
|
1797
1798
|
path: "grid",
|
|
1798
1799
|
gridBreak: "0"
|
|
1799
1800
|
}
|
|
1800
1801
|
)
|
|
1801
1802
|
] }) : null;
|
|
1802
|
-
return /* @__PURE__ */ r(
|
|
1803
|
+
return /* @__PURE__ */ r(rt, { draggableId: e.identifier, index: t, children: (E) => /* @__PURE__ */ g(
|
|
1803
1804
|
y,
|
|
1804
1805
|
{
|
|
1805
|
-
ref:
|
|
1806
|
-
...
|
|
1807
|
-
...
|
|
1806
|
+
ref: E.innerRef,
|
|
1807
|
+
...E.draggableProps,
|
|
1808
|
+
...E.dragHandleProps,
|
|
1808
1809
|
direction: "row",
|
|
1809
1810
|
justify: "center",
|
|
1810
1811
|
align: "center",
|
|
1811
1812
|
children: [
|
|
1812
|
-
o.some((
|
|
1813
|
-
e.condition &&
|
|
1813
|
+
o.some((F) => F !== null) && X(),
|
|
1814
|
+
e.condition && j(),
|
|
1814
1815
|
/* @__PURE__ */ r(
|
|
1815
1816
|
we,
|
|
1816
1817
|
{
|
|
@@ -1820,45 +1821,45 @@ const Ve = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Ot = (s,
|
|
|
1820
1821
|
children: /* @__PURE__ */ g(y, { gap: "3", justify: "between", align: "center", children: [
|
|
1821
1822
|
/* @__PURE__ */ g(y, { direction: "column", gap: "2", grow: "1", children: [
|
|
1822
1823
|
/* @__PURE__ */ g(y, { direction: "column", children: [
|
|
1823
|
-
/* @__PURE__ */ r(
|
|
1824
|
-
/* @__PURE__ */ r($, { className:
|
|
1824
|
+
/* @__PURE__ */ r(Me, { as: "h3", size: "3", children: e.label }),
|
|
1825
|
+
/* @__PURE__ */ r($, { className: Ne.description, children: e.description })
|
|
1825
1826
|
] }),
|
|
1826
|
-
e.condition && /* @__PURE__ */ r($, { size: "1", children: /* @__PURE__ */ g(
|
|
1827
|
+
e.condition && /* @__PURE__ */ r($, { size: "1", children: /* @__PURE__ */ g(Ii, { children: [
|
|
1827
1828
|
"Display only if ",
|
|
1828
|
-
/* @__PURE__ */ r(
|
|
1829
|
+
/* @__PURE__ */ r(pt, { children: v }),
|
|
1829
1830
|
" ",
|
|
1830
|
-
|
|
1831
|
+
P,
|
|
1831
1832
|
" ",
|
|
1832
|
-
/* @__PURE__ */ r(
|
|
1833
|
+
/* @__PURE__ */ r(pt, { children: R })
|
|
1833
1834
|
] }) }),
|
|
1834
1835
|
/* @__PURE__ */ r(
|
|
1835
|
-
|
|
1836
|
+
nt,
|
|
1836
1837
|
{
|
|
1837
1838
|
droppableId: e.identifier,
|
|
1838
1839
|
type: "SECTION",
|
|
1839
1840
|
isDropDisabled: a,
|
|
1840
|
-
children: (
|
|
1841
|
+
children: (F) => /* @__PURE__ */ g(
|
|
1841
1842
|
y,
|
|
1842
1843
|
{
|
|
1843
|
-
ref:
|
|
1844
|
-
...
|
|
1844
|
+
ref: F.innerRef,
|
|
1845
|
+
...F.droppableProps,
|
|
1845
1846
|
direction: "column",
|
|
1846
1847
|
gap: "0",
|
|
1847
1848
|
children: [
|
|
1848
1849
|
e.fields.map((D, k) => /* @__PURE__ */ r(
|
|
1849
|
-
|
|
1850
|
+
wn,
|
|
1850
1851
|
{
|
|
1851
1852
|
field: D,
|
|
1852
1853
|
index: k,
|
|
1853
1854
|
sectionIndex: t,
|
|
1854
|
-
remove: () =>
|
|
1855
|
-
takenLabels:
|
|
1855
|
+
remove: () => b(k),
|
|
1856
|
+
takenLabels: u
|
|
1856
1857
|
},
|
|
1857
1858
|
D.identifier
|
|
1858
1859
|
)),
|
|
1859
|
-
|
|
1860
|
-
/* @__PURE__ */ r(
|
|
1861
|
-
/* @__PURE__ */ r(
|
|
1860
|
+
F.placeholder,
|
|
1861
|
+
/* @__PURE__ */ r(he, { ...V, children: /* @__PURE__ */ g(G, { type: "button", variant: "outline", children: [
|
|
1862
|
+
/* @__PURE__ */ r(Oe, {}),
|
|
1862
1863
|
" Add a field"
|
|
1863
1864
|
] }) })
|
|
1864
1865
|
]
|
|
@@ -1868,13 +1869,13 @@ const Ve = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Ot = (s,
|
|
|
1868
1869
|
)
|
|
1869
1870
|
] }),
|
|
1870
1871
|
/* @__PURE__ */ r(
|
|
1871
|
-
|
|
1872
|
+
jt,
|
|
1872
1873
|
{
|
|
1873
|
-
remove:
|
|
1874
|
-
insertAfterProps:
|
|
1875
|
-
dragHandleProps:
|
|
1876
|
-
editProps:
|
|
1877
|
-
duplicateProps:
|
|
1874
|
+
remove: z,
|
|
1875
|
+
insertAfterProps: w,
|
|
1876
|
+
dragHandleProps: E.dragHandleProps,
|
|
1877
|
+
editProps: C,
|
|
1878
|
+
duplicateProps: L
|
|
1878
1879
|
}
|
|
1879
1880
|
)
|
|
1880
1881
|
] })
|
|
@@ -1883,7 +1884,7 @@ const Ve = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Ot = (s,
|
|
|
1883
1884
|
]
|
|
1884
1885
|
}
|
|
1885
1886
|
) });
|
|
1886
|
-
}),
|
|
1887
|
+
}), xn = (s, i) => {
|
|
1887
1888
|
var t;
|
|
1888
1889
|
const e = { ...s };
|
|
1889
1890
|
switch (i.type) {
|
|
@@ -1898,7 +1899,7 @@ const Ve = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Ot = (s,
|
|
|
1898
1899
|
case "update":
|
|
1899
1900
|
return i.state;
|
|
1900
1901
|
}
|
|
1901
|
-
},
|
|
1902
|
+
}, In = (s, i) => {
|
|
1902
1903
|
if (i)
|
|
1903
1904
|
for (let e = 0; e < s.length; e++) {
|
|
1904
1905
|
const t = s[e];
|
|
@@ -1908,7 +1909,7 @@ const Ve = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Ot = (s,
|
|
|
1908
1909
|
return e;
|
|
1909
1910
|
}
|
|
1910
1911
|
}
|
|
1911
|
-
},
|
|
1912
|
+
}, vt = (s) => {
|
|
1912
1913
|
var e, t, n;
|
|
1913
1914
|
const i = {};
|
|
1914
1915
|
for (let o = 0; o < s.length; o++) {
|
|
@@ -1919,60 +1920,60 @@ const Ve = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Ot = (s,
|
|
|
1919
1920
|
(t = a.condition) != null && t.identifier && l.add(a.condition.identifier), i[a.identifier] = {
|
|
1920
1921
|
disabled: !1,
|
|
1921
1922
|
conditionFields: l,
|
|
1922
|
-
conditionIndex:
|
|
1923
|
+
conditionIndex: In(s, (n = a.condition) == null ? void 0 : n.identifier),
|
|
1923
1924
|
index: o,
|
|
1924
1925
|
label: a.label
|
|
1925
1926
|
};
|
|
1926
1927
|
}
|
|
1927
1928
|
return i;
|
|
1928
|
-
},
|
|
1929
|
+
}, xt = (s, i) => {
|
|
1929
1930
|
for (const [e, t] of Object.entries(s))
|
|
1930
1931
|
if (t.identifier === i)
|
|
1931
1932
|
return [t, e];
|
|
1932
|
-
},
|
|
1933
|
-
const { values: i, setFieldValue: e } =
|
|
1933
|
+
}, Cn = S(function() {
|
|
1934
|
+
const { values: i, setFieldValue: e } = pe(), [t, n] = Si(xn, i.fields, vt), { showInfo: o } = Ci();
|
|
1934
1935
|
ve(() => {
|
|
1935
|
-
n({ type: "update", state:
|
|
1936
|
+
n({ type: "update", state: vt(i.fields) });
|
|
1936
1937
|
}, [n, i.fields]);
|
|
1937
|
-
const a =
|
|
1938
|
+
const a = T((d) => {
|
|
1938
1939
|
d.type === "SECTION" && n({ type: "hold", fieldId: d.draggableId });
|
|
1939
|
-
}, []), c =
|
|
1940
|
+
}, []), c = T(
|
|
1940
1941
|
(d) => {
|
|
1941
|
-
const { source: u, destination:
|
|
1942
|
-
if (n({ type: "release" }), !
|
|
1942
|
+
const { source: u, destination: p, type: h, reason: b, draggableId: z } = d;
|
|
1943
|
+
if (n({ type: "release" }), !p || b === "CANCEL")
|
|
1943
1944
|
return;
|
|
1944
|
-
if (
|
|
1945
|
-
const L = t[
|
|
1945
|
+
if (h === "ROOT") {
|
|
1946
|
+
const L = t[z];
|
|
1946
1947
|
if (!L)
|
|
1947
1948
|
throw new Error("Could not find section context.");
|
|
1948
1949
|
let v = typeof L.conditionIndex < "u" ? (
|
|
1949
1950
|
// cannot move a section with a condition before the condition's field
|
|
1950
|
-
Math.max(L.conditionIndex + 1,
|
|
1951
|
-
) :
|
|
1951
|
+
Math.max(L.conditionIndex + 1, p.index)
|
|
1952
|
+
) : p.index;
|
|
1952
1953
|
for (const P of Object.values(t))
|
|
1953
1954
|
P.conditionIndex === u.index && (v = Math.min(v, P.index - 1));
|
|
1954
|
-
return v !=
|
|
1955
|
+
return v != p.index && o({
|
|
1955
1956
|
title: "Reordered sections",
|
|
1956
1957
|
description: "Sections with conditions must be below the fields they reference."
|
|
1957
|
-
}), e("fields",
|
|
1958
|
+
}), e("fields", Ke(i.fields, u.index, v));
|
|
1958
1959
|
}
|
|
1959
|
-
if (
|
|
1960
|
+
if (h !== "SECTION")
|
|
1960
1961
|
throw new Error("Unexpected droppable type.");
|
|
1961
|
-
const [I, C] =
|
|
1962
|
+
const [I, C] = xt(i.fields, u.droppableId) ?? [], [w, V] = xt(i.fields, p.droppableId) ?? [];
|
|
1962
1963
|
if (!(I != null && I.fields) || !w)
|
|
1963
1964
|
throw new Error("Could not find section with fields.");
|
|
1964
1965
|
if (I.identifier === w.identifier)
|
|
1965
1966
|
e(
|
|
1966
1967
|
`fields.${C}.fields`,
|
|
1967
|
-
|
|
1968
|
+
Ke(I.fields, u.index, p.index)
|
|
1968
1969
|
).then();
|
|
1969
1970
|
else {
|
|
1970
1971
|
const L = I.fields[u.index];
|
|
1971
1972
|
if (!L)
|
|
1972
1973
|
throw new Error("Could not find field to reorder.");
|
|
1973
|
-
e(`fields.${C}.fields`,
|
|
1974
|
+
e(`fields.${C}.fields`, Le(I.fields, u.index)).then(), e(
|
|
1974
1975
|
`fields.${V}.fields`,
|
|
1975
|
-
|
|
1976
|
+
kt(w.fields, p.index, L)
|
|
1976
1977
|
).then();
|
|
1977
1978
|
}
|
|
1978
1979
|
},
|
|
@@ -1981,15 +1982,15 @@ const Ve = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Ot = (s,
|
|
|
1981
1982
|
() => ({
|
|
1982
1983
|
index: i.fields.length,
|
|
1983
1984
|
parentPath: "fields",
|
|
1984
|
-
initial:
|
|
1985
|
-
conditionalSourceFields:
|
|
1985
|
+
initial: Ae(),
|
|
1986
|
+
conditionalSourceFields: ze(i.fields, i.fields.length)
|
|
1986
1987
|
}),
|
|
1987
1988
|
[i.fields]
|
|
1988
1989
|
), f = () => {
|
|
1989
|
-
let d =
|
|
1990
|
+
let d = 1;
|
|
1990
1991
|
return i.fields.map((u) => u.conditional ? d++ : null);
|
|
1991
1992
|
};
|
|
1992
|
-
return /* @__PURE__ */ r(
|
|
1993
|
+
return /* @__PURE__ */ r(Tt, { onDragStart: a, onDragEnd: c, children: /* @__PURE__ */ r(nt, { droppableId: "droppable", type: "ROOT", children: (d) => /* @__PURE__ */ g(
|
|
1993
1994
|
y,
|
|
1994
1995
|
{
|
|
1995
1996
|
ref: d.innerRef,
|
|
@@ -1997,57 +1998,57 @@ const Ve = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Ot = (s,
|
|
|
1997
1998
|
direction: "column",
|
|
1998
1999
|
gap: "0",
|
|
1999
2000
|
children: [
|
|
2000
|
-
i.fields.map((u,
|
|
2001
|
-
|
|
2001
|
+
i.fields.map((u, p) => /* @__PURE__ */ r(
|
|
2002
|
+
vn,
|
|
2002
2003
|
{
|
|
2003
2004
|
field: u,
|
|
2004
|
-
index:
|
|
2005
|
+
index: p,
|
|
2005
2006
|
dropState: t,
|
|
2006
2007
|
conditionalFieldCounts: f()
|
|
2007
2008
|
},
|
|
2008
2009
|
u.label
|
|
2009
2010
|
)),
|
|
2010
2011
|
d.placeholder,
|
|
2011
|
-
/* @__PURE__ */ r(
|
|
2012
|
-
/* @__PURE__ */ r(
|
|
2012
|
+
/* @__PURE__ */ r(he, { ...l, children: /* @__PURE__ */ g(G, { type: "button", variant: "outline", children: [
|
|
2013
|
+
/* @__PURE__ */ r(Oe, {}),
|
|
2013
2014
|
" Add a section"
|
|
2014
2015
|
] }) })
|
|
2015
2016
|
]
|
|
2016
2017
|
}
|
|
2017
2018
|
) }) });
|
|
2018
|
-
}),
|
|
2019
|
+
}), Fn = {
|
|
2019
2020
|
title: "",
|
|
2020
2021
|
description: "",
|
|
2021
2022
|
fields: []
|
|
2022
|
-
},
|
|
2023
|
+
}, Tn = new be({
|
|
2023
2024
|
label: "Title",
|
|
2024
2025
|
minLength: 0,
|
|
2025
2026
|
maxLength: 100,
|
|
2026
2027
|
required: !0,
|
|
2027
2028
|
identifier: "title"
|
|
2028
|
-
}),
|
|
2029
|
+
}), Sn = { formId: qe, placeholder: "Give your form a title." }, zn = new ye({
|
|
2029
2030
|
label: "Description",
|
|
2030
2031
|
minLength: 0,
|
|
2031
2032
|
maxLength: 1e3,
|
|
2032
2033
|
required: !1,
|
|
2033
2034
|
identifier: "description"
|
|
2034
|
-
}),
|
|
2035
|
+
}), En = { formId: qe, placeholder: "Explain the purpose of this form." }, An = () => {
|
|
2035
2036
|
alert("This is a form preview, your data will not be saved.");
|
|
2036
|
-
},
|
|
2037
|
+
}, jn = S(
|
|
2037
2038
|
xe((s, i) => {
|
|
2038
|
-
const { onCancel: e, onSave: t, revision: n } = s, o = n ? "Edit form" : "Create a new form", { heading: a = o } = s, c =
|
|
2039
|
+
const { onCancel: e, onSave: t, revision: n } = s, o = n ? "Edit form" : "Create a new form", { heading: a = o } = s, c = T((h) => {
|
|
2039
2040
|
const b = {};
|
|
2040
|
-
if (
|
|
2041
|
+
if (h.title || (b.title = "Title is required."), (!h.fields || h.fields.length === 0) && (b.fields = "At least one field is required."), _e(b))
|
|
2041
2042
|
return b;
|
|
2042
|
-
}, []), l =
|
|
2043
|
-
initialValues:
|
|
2043
|
+
}, []), l = tt({
|
|
2044
|
+
initialValues: Ui(n) ?? Fn,
|
|
2044
2045
|
validate: c,
|
|
2045
|
-
onSubmit: (
|
|
2046
|
+
onSubmit: (h) => t(h),
|
|
2046
2047
|
// only validate the entire for on submit
|
|
2047
2048
|
validateOnChange: !1,
|
|
2048
2049
|
validateOnBlur: !1
|
|
2049
|
-
}), f = x(() =>
|
|
2050
|
-
() => typeof a == "object" ? a : /* @__PURE__ */ r(
|
|
2050
|
+
}), f = x(() => Mt(l.values), [l.values]), d = De(Tn, Sn), u = De(zn, En), p = x(
|
|
2051
|
+
() => typeof a == "object" ? a : /* @__PURE__ */ r(Me, { children: a }),
|
|
2051
2052
|
[a]
|
|
2052
2053
|
);
|
|
2053
2054
|
return /* @__PURE__ */ r(Q.Root, { ref: i, defaultValue: "edit", children: /* @__PURE__ */ g(y, { direction: "column", gap: "2", children: [
|
|
@@ -2056,7 +2057,7 @@ const Ve = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Ot = (s,
|
|
|
2056
2057
|
/* @__PURE__ */ r(Q.Trigger, { value: "preview", children: "Preview" })
|
|
2057
2058
|
] }),
|
|
2058
2059
|
/* @__PURE__ */ g(Q.Content, { value: "edit", children: [
|
|
2059
|
-
|
|
2060
|
+
p,
|
|
2060
2061
|
/* @__PURE__ */ g($, { children: [
|
|
2061
2062
|
"Add a new form field by clicking a + button. Specify options for each field, then drag and drop to rearrange them. You can see what a submitted form might look like in the",
|
|
2062
2063
|
" ",
|
|
@@ -2065,11 +2066,11 @@ const Ve = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Ot = (s,
|
|
|
2065
2066
|
" ",
|
|
2066
2067
|
/* @__PURE__ */ r("strong", { children: "field values entered on this page will not be saved." })
|
|
2067
2068
|
] }),
|
|
2068
|
-
/* @__PURE__ */ r(y, { asChild: !0, direction: "column", gap: "2", mt: "3", children: /* @__PURE__ */ g("form", { id:
|
|
2069
|
-
/* @__PURE__ */ g(
|
|
2069
|
+
/* @__PURE__ */ r(y, { asChild: !0, direction: "column", gap: "2", mt: "3", children: /* @__PURE__ */ g("form", { id: qe, onSubmit: l.handleSubmit, children: [
|
|
2070
|
+
/* @__PURE__ */ g(it, { value: l, children: [
|
|
2070
2071
|
d,
|
|
2071
2072
|
u,
|
|
2072
|
-
/* @__PURE__ */ r(
|
|
2073
|
+
/* @__PURE__ */ r(Cn, {}),
|
|
2073
2074
|
/* @__PURE__ */ r($, { severity: "danger", size: "1", children: typeof l.errors.fields == "string" && l.errors.fields })
|
|
2074
2075
|
] }),
|
|
2075
2076
|
/* @__PURE__ */ g(y, { justify: "end", gap: "2", children: [
|
|
@@ -2078,40 +2079,40 @@ const Ve = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Ot = (s,
|
|
|
2078
2079
|
] })
|
|
2079
2080
|
] }) })
|
|
2080
2081
|
] }),
|
|
2081
|
-
/* @__PURE__ */ r(Q.Content, { value: "preview", children: /* @__PURE__ */ r(
|
|
2082
|
+
/* @__PURE__ */ r(Q.Content, { value: "preview", children: /* @__PURE__ */ r(dt, { schema: f, onSubmit: An }) })
|
|
2082
2083
|
] }) });
|
|
2083
2084
|
})
|
|
2084
2085
|
);
|
|
2085
2086
|
export {
|
|
2086
2087
|
fe as BooleanField,
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2088
|
+
Ni as BooleanInput,
|
|
2089
|
+
Ge as DateField,
|
|
2090
|
+
qi as DateInput,
|
|
2090
2091
|
Z as FieldSection,
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2092
|
+
Bn as FormBrowser,
|
|
2093
|
+
jn as FormBuilder,
|
|
2094
|
+
dt as FormRenderer,
|
|
2095
|
+
qn as FormSubmissionBrowser,
|
|
2096
|
+
Nn as FormSubmissionViewer,
|
|
2097
|
+
$e as MultiSelectField,
|
|
2098
|
+
Zi as MultiSelectInput,
|
|
2099
|
+
Pe as MultiStringField,
|
|
2100
|
+
Ki as MultiStringInput,
|
|
2100
2101
|
Y as NumberField,
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2102
|
+
Bi as NumberInput,
|
|
2103
|
+
Wn as PatchField,
|
|
2104
|
+
Hn as PatchFormProvider,
|
|
2105
|
+
ke as SelectField,
|
|
2106
|
+
ji as SelectInput,
|
|
2106
2107
|
be as StringField,
|
|
2107
|
-
|
|
2108
|
+
Wi as StringInput,
|
|
2108
2109
|
ye as TextField,
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2110
|
+
Hi as TextInput,
|
|
2111
|
+
Be as deserialize,
|
|
2112
|
+
Ot as deserializeField,
|
|
2113
|
+
Mt as formRevisionToSchema,
|
|
2114
|
+
Rt as isConditionMet,
|
|
2115
|
+
De as useFieldInput,
|
|
2116
|
+
Nt as useFieldInputs,
|
|
2117
|
+
Xe as valueIsFile
|
|
2117
2118
|
};
|