@overmap-ai/forms 1.0.4-conditional-arrows-2.6 → 1.0.4-conditional-arrows-2.8
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 +451 -454
- 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) => (
|
|
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
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
|
|
6
|
-
import { useField as et, useFormikContext as
|
|
7
|
-
import
|
|
8
|
-
import { DragDropContext as
|
|
9
|
-
import { slugify as
|
|
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 z, useCallback as S, 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
11
|
import st from "lodash.set";
|
|
12
|
-
import
|
|
13
|
-
class
|
|
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 At {
|
|
|
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,8 +91,8 @@ class M extends At {
|
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
m(M, "fieldTypeName"), m(M, "fieldTypeDescription");
|
|
94
|
-
const
|
|
95
|
-
description:
|
|
94
|
+
const Mi = "_description_17zed_1", Ne = {
|
|
95
|
+
description: Mi
|
|
96
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: [
|
|
@@ -106,7 +106,7 @@ const _i = "_description_17zed_1", Ne = {
|
|
|
106
106
|
/* @__PURE__ */ r(y, { direction: "column", children: /* @__PURE__ */ r($, { size: "1", severity: t, className: Ne.description, children: i }) })
|
|
107
107
|
] });
|
|
108
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`,
|
|
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,16 +121,16 @@ const _i = "_description_17zed_1", Ne = {
|
|
|
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] = H(i), f = me(n), d =
|
|
132
|
+
}, Ri = [!0, "true"], Ni = z(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
134
|
return /* @__PURE__ */ r(W, { helpText: o, severity: n, children: /* @__PURE__ */ r(
|
|
135
135
|
q,
|
|
136
136
|
{
|
|
@@ -140,7 +140,7 @@ const _i = "_description_17zed_1", Ne = {
|
|
|
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,12 +176,12 @@ const _i = "_description_17zed_1", Ne = {
|
|
|
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
|
|
184
|
+
const Bi = z(function(i) {
|
|
185
185
|
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: a, fieldProps: c, field: l }, f] = H(i), d = me(n);
|
|
186
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,
|
|
@@ -267,12 +267,12 @@ const Ri = S(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
|
|
275
|
+
const qi = z(function(i) {
|
|
276
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
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 {
|
|
@@ -292,10 +292,10 @@ const Ni = S(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",
|
|
298
|
+
m(ee, "fieldTypeName", "Date"), m(ee, "fieldTypeDescription", "Allows specifying a date."), m(ee, "Icon", Qt);
|
|
299
299
|
let Ge = ee;
|
|
300
300
|
class Ee extends M {
|
|
301
301
|
constructor(e) {
|
|
@@ -366,7 +366,7 @@ m(Ee, "_validateMax", (e, t) => {
|
|
|
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
|
|
369
|
+
const Wi = z(function(i) {
|
|
370
370
|
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: a, fieldProps: c, field: l }, f] = H(i), d = me(n);
|
|
371
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
372
|
}), te = class te extends Ee {
|
|
@@ -386,14 +386,14 @@ const Bi = S(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
|
|
394
|
+
const Hi = z(function(i) {
|
|
395
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(
|
|
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
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;
|
|
@@ -409,27 +409,27 @@ const qi = S(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] = H(i), { onChange: d, onBlur: u } = c,
|
|
417
|
+
const ji = z(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 = S(
|
|
422
422
|
(b) => {
|
|
423
423
|
d(b), u(b);
|
|
424
424
|
},
|
|
425
425
|
[d, u]
|
|
426
426
|
);
|
|
427
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
|
-
|
|
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,
|
|
@@ -443,7 +443,7 @@ const Wi = S(function(i) {
|
|
|
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;
|
|
@@ -459,11 +459,11 @@ function Ke(s, i, e) {
|
|
|
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
|
}
|
|
@@ -471,58 +471,58 @@ 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
|
-
}, ze = (s, i) => s.filter((e, t) => t < i).flatMap((e) => e.fields),
|
|
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
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] = H(i), f = me(n), d = x(() => Array.isArray(c.value) ? c.value : [], [c.value]), { onChange: u, onBlur:
|
|
497
|
+
}, Ki = z(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, [E, I] = de(""), [C, w] = de(""), V = C || o, L = C ? "red" : f, v = S(
|
|
499
499
|
(A) => {
|
|
500
|
-
u(A),
|
|
500
|
+
u(A), p(A);
|
|
501
501
|
},
|
|
502
|
-
[u,
|
|
503
|
-
), P =
|
|
502
|
+
[u, p]
|
|
503
|
+
), P = S(
|
|
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 = S(() => {
|
|
509
509
|
if (C)
|
|
510
510
|
return;
|
|
511
|
-
if (!
|
|
511
|
+
if (!E.trim())
|
|
512
512
|
return w("Option cannot be empty");
|
|
513
|
-
const A =
|
|
513
|
+
const A = E.trim();
|
|
514
514
|
v([...d, { value: A, label: A }]), I("");
|
|
515
|
-
}, [
|
|
515
|
+
}, [E, C, v, d]), X = S(
|
|
516
516
|
(A) => {
|
|
517
517
|
A.key === "Enter" && (A.preventDefault(), R());
|
|
518
518
|
},
|
|
519
519
|
[R]
|
|
520
|
-
), j =
|
|
520
|
+
), j = S(
|
|
521
521
|
(A) => {
|
|
522
522
|
v(Le(d, A));
|
|
523
523
|
},
|
|
524
524
|
[d, v]
|
|
525
|
-
), U =
|
|
525
|
+
), U = S(
|
|
526
526
|
(A) => {
|
|
527
527
|
if (!A.destination)
|
|
528
528
|
return;
|
|
@@ -531,7 +531,7 @@ const Pt = (s, i) => {
|
|
|
531
531
|
},
|
|
532
532
|
[v, d]
|
|
533
533
|
);
|
|
534
|
-
return /* @__PURE__ */ r(
|
|
534
|
+
return /* @__PURE__ */ r(Tt, { onDragEnd: U, children: /* @__PURE__ */ g(y, { direction: "column", gap: "2", children: [
|
|
535
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,
|
|
@@ -539,7 +539,7 @@ const Pt = (s, i) => {
|
|
|
539
539
|
placeholder: "Press enter to add a new option",
|
|
540
540
|
...l,
|
|
541
541
|
...c,
|
|
542
|
-
value:
|
|
542
|
+
value: E,
|
|
543
543
|
onChange: P,
|
|
544
544
|
onKeyDown: X,
|
|
545
545
|
id: e,
|
|
@@ -558,7 +558,7 @@ const Pt = (s, i) => {
|
|
|
558
558
|
}
|
|
559
559
|
)
|
|
560
560
|
] }) }) }),
|
|
561
|
-
/* @__PURE__ */ r(nt, { droppableId:
|
|
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
|
{
|
|
@@ -588,7 +588,7 @@ const Pt = (s, i) => {
|
|
|
588
588
|
severity: "info",
|
|
589
589
|
disabled: b,
|
|
590
590
|
onClick: () => j(K),
|
|
591
|
-
children: /* @__PURE__ */ r(
|
|
591
|
+
children: /* @__PURE__ */ r(Ct, {})
|
|
592
592
|
}
|
|
593
593
|
)
|
|
594
594
|
] })
|
|
@@ -615,7 +615,7 @@ const Pt = (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 Pt = (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",
|
|
642
|
+
m(ne, "fieldTypeName", "Multi-string"), m(ne, "fieldTypeDescription", "Allows the user to provide multiple unique strings."), m(ne, "Icon", ii);
|
|
643
643
|
let Pe = ne;
|
|
644
|
-
class
|
|
644
|
+
class _t extends M {
|
|
645
645
|
constructor(e) {
|
|
646
646
|
super(e);
|
|
647
647
|
m(this, "options");
|
|
@@ -671,7 +671,7 @@ class Vt 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 Vt {
|
|
|
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",
|
|
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
694
|
let ke = re;
|
|
695
|
-
const
|
|
696
|
-
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: a, fieldProps: c, field: l }, f] = H(i), { onChange: d, onBlur: u } = c,
|
|
695
|
+
const Yi = (s) => s ? Array.isArray(s) ? s : [s] : [], Zi = z(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 = S(
|
|
697
697
|
(b) => {
|
|
698
698
|
d(b), u(b);
|
|
699
699
|
},
|
|
700
700
|
[d, u]
|
|
701
701
|
);
|
|
702
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
|
-
|
|
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 Gi = (s) => s ? Array.isArray(s) ? s : [s] : [], Ki = S(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,12 +733,12 @@ const Gi = (s) => s ? Array.isArray(s) ? s : [s] : [], Ki = S(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",
|
|
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
740
|
let $e = oe;
|
|
741
|
-
const
|
|
741
|
+
const Xi = z(function({ field: i, ...e }) {
|
|
742
742
|
const [{ value: t }] = et(i.options.clonedFieldIdentifier), n = x(() => {
|
|
743
743
|
const o = i.options.getFieldToClone(t);
|
|
744
744
|
return o ? Be(o) : null;
|
|
@@ -762,27 +762,27 @@ class Ve extends M {
|
|
|
762
762
|
}
|
|
763
763
|
}
|
|
764
764
|
m(Ve, "fieldTypeName", "Custom"), m(Ve, "fieldTypeDescription", "Allows re-rendering of field already in the form");
|
|
765
|
-
class
|
|
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 = z(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
780
|
/* @__PURE__ */ r(Me, { as: "h3", size: "3", children: n }),
|
|
781
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" });
|
|
@@ -829,7 +829,7 @@ const Xi = S(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 Xi = S(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() {
|
|
@@ -880,35 +880,35 @@ const Xi = S(function(i) {
|
|
|
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:
|
|
888
|
+
const en = "_previewImage_1ig84_1", tn = {
|
|
889
|
+
previewImage: en
|
|
890
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 = z(function(i) {
|
|
897
897
|
var L;
|
|
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),
|
|
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]), E = S(() => {
|
|
899
899
|
var v;
|
|
900
|
-
(v =
|
|
901
|
-
}, []), I =
|
|
900
|
+
(v = p.current) == null || v.click();
|
|
901
|
+
}, []), I = S(
|
|
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
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:
|
|
911
|
-
/* @__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: E, children: [
|
|
911
|
+
/* @__PURE__ */ r(Ft, {}),
|
|
912
912
|
" ",
|
|
913
913
|
V
|
|
914
914
|
] }) }) }),
|
|
@@ -917,7 +917,7 @@ const Qi = "_previewImage_1ig84_1", Ji = {
|
|
|
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 Qi = "_previewImage_1ig84_1", Ji = {
|
|
|
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 Qi = "_previewImage_1ig84_1", Ji = {
|
|
|
939
939
|
P
|
|
940
940
|
)) })
|
|
941
941
|
] });
|
|
942
|
-
}),
|
|
942
|
+
}), rn = z(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 Qi = "_previewImage_1ig84_1", Ji = {
|
|
|
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 Qi = "_previewImage_1ig84_1", Ji = {
|
|
|
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,7 +999,7 @@ const Qi = "_previewImage_1ig84_1", Ji = {
|
|
|
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
1005
|
new $e({
|
|
@@ -1033,7 +1033,7 @@ const Qi = "_previewImage_1ig84_1", Ji = {
|
|
|
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
1039
|
return `Files must be at most ${lt(t)}.`;
|
|
@@ -1056,10 +1056,10 @@ const Qi = "_previewImage_1ig84_1", Ji = {
|
|
|
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",
|
|
1062
|
+
m(le, "fieldTypeName", "Upload"), m(le, "fieldTypeDescription", "Allows a file to be uploaded."), m(le, "Icon", Ft);
|
|
1063
1063
|
let Ze = le;
|
|
1064
1064
|
const at = {
|
|
1065
1065
|
date: Ge,
|
|
@@ -1073,11 +1073,11 @@ const at = {
|
|
|
1073
1073
|
// TODO: Underscore
|
|
1074
1074
|
"multi-string": Pe,
|
|
1075
1075
|
"multi-select": $e
|
|
1076
|
-
},
|
|
1076
|
+
}, Ot = (s) => {
|
|
1077
1077
|
const i = s.type;
|
|
1078
1078
|
return at[i].deserialize(s);
|
|
1079
|
-
}, Be = (s) => s.type === "section" ? Z.deserialize(s) :
|
|
1080
|
-
function
|
|
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,
|
|
@@ -1089,7 +1089,7 @@ function _t(s, i = {}) {
|
|
|
1089
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
1095
|
if (Xe(i) || Xe(s.value))
|
|
@@ -1103,16 +1103,16 @@ function Ot(s, i) {
|
|
|
1103
1103
|
}
|
|
1104
1104
|
return t === i;
|
|
1105
1105
|
}
|
|
1106
|
-
const De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]),
|
|
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
|
-
}, _e = (s) => Object.keys(s).length > 0,
|
|
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));
|
|
@@ -1124,14 +1124,14 @@ const De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Mt = (s,
|
|
|
1124
1124
|
}
|
|
1125
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
|
-
}, dt =
|
|
1129
|
+
}, dt = z(
|
|
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,50 +1140,50 @@ const De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Mt = (s,
|
|
|
1140
1140
|
hideTitle: f = !e.title,
|
|
1141
1141
|
hideDescription: d,
|
|
1142
1142
|
className: u
|
|
1143
|
-
} = s, { readonly:
|
|
1143
|
+
} = s, { readonly: p } = e.meta, h = x(() => crypto.randomUUID(), []), b = tt({
|
|
1144
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:
|
|
1150
|
+
}), { dirty: E } = b, I = x(
|
|
1151
1151
|
() => typeof e.title == "string" ? /* @__PURE__ */ r(Me, { children: e.title }) : e.title,
|
|
1152
1152
|
[e.title]
|
|
1153
1153
|
), C = x(
|
|
1154
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
|
+
E && l && l();
|
|
1159
|
+
}, [E, 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 = z(
|
|
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]);
|
|
@@ -1198,38 +1198,38 @@ const De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Mt = (s,
|
|
|
1198
1198
|
}
|
|
1199
1199
|
);
|
|
1200
1200
|
})
|
|
1201
|
-
),
|
|
1202
|
-
favoriteIcon:
|
|
1203
|
-
regularIcon:
|
|
1204
|
-
}, He = "organization:", je = "user:",
|
|
1201
|
+
), ln = "_favoriteIcon_1bixi_1", an = "_regularIcon_1bixi_9", bt = {
|
|
1202
|
+
favoriteIcon: ln,
|
|
1203
|
+
regularIcon: an
|
|
1204
|
+
}, He = "organization:", je = "user:", Bn = z(
|
|
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
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 =
|
|
1209
|
+
}, [n, e, a]), d = _(Ai(f)) ?? [], u = _(Li), p = S(
|
|
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 =
|
|
1217
|
+
const v = Et(L.owner_organization || -1)(w);
|
|
1218
1218
|
v && (V[`${He}${v.id}`] = v.name);
|
|
1219
1219
|
const P = ot(L.owner_user || -1)(w);
|
|
1220
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 = S((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",
|
|
@@ -1238,70 +1238,70 @@ const De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Mt = (s,
|
|
|
1238
1238
|
)
|
|
1239
1239
|
] }),
|
|
1240
1240
|
d.length > 0 && /* @__PURE__ */ r(Re.Root, { children: d.map((w) => /* @__PURE__ */ r(
|
|
1241
|
-
|
|
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 = S(
|
|
1255
|
+
(h) => {
|
|
1256
|
+
h.stopPropagation(), n();
|
|
1257
1257
|
},
|
|
1258
1258
|
[n]
|
|
1259
|
-
), u = /* @__PURE__ */ r(Re.Item, { onClick: () => e(i), asChild: !0, children: /* @__PURE__ */ g(y, { justify: "between", gap: "2", py: "2", px: "3", ...
|
|
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 = z(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()) ?? "?", E = u.revision === p, I = Fi.useCallback(() => {
|
|
1297
1297
|
t && t({ submission: e });
|
|
1298
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:
|
|
1300
|
-
/* @__PURE__ */ r(
|
|
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(Ue, { variant: "soft", severity:
|
|
1304
|
+
!n && (u.revision ? /* @__PURE__ */ r(Ue, { variant: "soft", severity: E ? "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
|
] }) });
|
|
@@ -1309,7 +1309,7 @@ const De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Mt = (s,
|
|
|
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 = z(function(i) {
|
|
1313
1313
|
const {
|
|
1314
1314
|
formId: e,
|
|
1315
1315
|
submissions: t,
|
|
@@ -1321,16 +1321,16 @@ const De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Mt = (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 De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Mt = (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 = z(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,22 +1360,22 @@ const De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Mt = (s,
|
|
|
1360
1360
|
patchValue: n
|
|
1361
1361
|
});
|
|
1362
1362
|
}, [n, c, o.value, t]);
|
|
1363
|
-
}),
|
|
1363
|
+
}), Hn = z(
|
|
1364
1364
|
xe((s, i) => {
|
|
1365
|
-
const { children: e, schema: t, values: n, onPatch: o, onError: a, ...c } = s, l = x(() => ct(t.fields, n), [t.fields, n]), f =
|
|
1365
|
+
const { children: e, schema: t, values: n, onPatch: o, onError: a, ...c } = s, l = x(() => ct(t.fields, n), [t.fields, n]), f = S(
|
|
1366
1366
|
(b) => {
|
|
1367
|
-
const
|
|
1367
|
+
const E = {};
|
|
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 && (E[I] = C);
|
|
1371
1371
|
}
|
|
1372
|
-
_e(
|
|
1372
|
+
_e(E) && o(E);
|
|
1373
1373
|
},
|
|
1374
1374
|
[l, o]
|
|
1375
|
-
), d =
|
|
1375
|
+
), d = S(
|
|
1376
1376
|
async (b) => {
|
|
1377
|
-
const
|
|
1378
|
-
return
|
|
1377
|
+
const E = await Bt(t, b);
|
|
1378
|
+
return E && a(E), E;
|
|
1379
1379
|
},
|
|
1380
1380
|
[t, a]
|
|
1381
1381
|
), u = tt({
|
|
@@ -1385,15 +1385,15 @@ const De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Mt = (s,
|
|
|
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
|
-
_e(
|
|
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
|
-
),
|
|
1393
|
+
), Wt = {
|
|
1394
1394
|
...at,
|
|
1395
1395
|
section: Z
|
|
1396
|
-
},
|
|
1396
|
+
}, mn = z(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 De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Mt = (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 = z(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
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 De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Mt = (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 = z(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.");
|
|
@@ -1472,13 +1472,13 @@ const De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Mt = (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 = z(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, E = 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 = S(() => f(void 0), []), w = S((v) => {
|
|
1480
1480
|
f(void 0), v();
|
|
1481
|
-
}, []), V =
|
|
1481
|
+
}, []), V = S(
|
|
1482
1482
|
(v, P) => {
|
|
1483
1483
|
const { label: R } = v;
|
|
1484
1484
|
if (!d)
|
|
@@ -1488,19 +1488,19 @@ const De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Mt = (s,
|
|
|
1488
1488
|
const X = Be({
|
|
1489
1489
|
type: d,
|
|
1490
1490
|
...v,
|
|
1491
|
-
identifier:
|
|
1492
|
-
}).serialize(), j = ue(
|
|
1491
|
+
identifier: $t(v.identifier, R)
|
|
1492
|
+
}).serialize(), j = ue(h, e);
|
|
1493
1493
|
if (j === void 0)
|
|
1494
1494
|
throw new Error("Parent path must point to an existing field.");
|
|
1495
1495
|
let U;
|
|
1496
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 = S(
|
|
1502
|
+
(v) => b ? /* @__PURE__ */ r(hn, { setFieldType: f }) : /* @__PURE__ */ r(
|
|
1503
|
+
yn,
|
|
1504
1504
|
{
|
|
1505
1505
|
conditionalSourceFields: c,
|
|
1506
1506
|
handleCancel: C,
|
|
@@ -1511,34 +1511,34 @@ const De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Mt = (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: E, 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 = z(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
1543
|
Icon: Oe,
|
|
1544
1544
|
text: "Add after"
|
|
@@ -1547,7 +1547,7 @@ const De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Mt = (s,
|
|
|
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 }
|
|
@@ -1556,20 +1556,20 @@ const De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Mt = (s,
|
|
|
1556
1556
|
[t, a, n, o, e]
|
|
1557
1557
|
);
|
|
1558
1558
|
return /* @__PURE__ */ g(Je, { children: [
|
|
1559
|
-
/* @__PURE__ */ r(y, { gap: "4", display:
|
|
1560
|
-
const f = l.Wrapper ??
|
|
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 De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Mt = (s,
|
|
|
1582
1582
|
}
|
|
1583
1583
|
) })
|
|
1584
1584
|
] });
|
|
1585
|
-
}), qe = "form-builder",
|
|
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 =
|
|
1587
|
-
(
|
|
1588
|
-
if (
|
|
1589
|
-
throw new Error(`Expected a label for field ${
|
|
1590
|
-
return { ...
|
|
1585
|
+
}), qe = "form-builder", wn = z(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 = S(
|
|
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 De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Mt = (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,109 +1613,109 @@ const De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Mt = (s,
|
|
|
1613
1613
|
}),
|
|
1614
1614
|
[t, n]
|
|
1615
1615
|
);
|
|
1616
|
-
return /* @__PURE__ */ r(rt, { draggableId: e.identifier, index: t, children: (
|
|
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 U, A, N, K, Ie, Ce, Fe;
|
|
1641
|
-
const { field: e, index: t, dropState: n, conditionalFieldCounts: o } = i, a = (U = n[e.identifier]) == null ? void 0 : U.disabled,
|
|
1642
|
-
(
|
|
1643
|
-
for (const D of
|
|
1644
|
-
const k =
|
|
1639
|
+
}), vn = z(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 = S(
|
|
1642
|
+
(F, T) => {
|
|
1643
|
+
for (const D of F) {
|
|
1644
|
+
const k = T.indexOf(D);
|
|
1645
1645
|
l(`fields.${k}.condition`, null).then(), l(`fields.${k}.conditional`, !1).then();
|
|
1646
1646
|
}
|
|
1647
1647
|
},
|
|
1648
1648
|
[l]
|
|
1649
|
-
),
|
|
1650
|
-
(
|
|
1649
|
+
), h = S(
|
|
1650
|
+
(F) => {
|
|
1651
1651
|
var k;
|
|
1652
|
-
const
|
|
1653
|
-
if (!
|
|
1652
|
+
const T = e.fields[F];
|
|
1653
|
+
if (!T)
|
|
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) === T.identifier && D.push(O);
|
|
1658
1658
|
return {
|
|
1659
|
-
removing:
|
|
1659
|
+
removing: T,
|
|
1660
1660
|
affectedSections: D,
|
|
1661
|
-
action: () => l(`fields.${t}.fields`, Le(e.fields,
|
|
1661
|
+
action: () => l(`fields.${t}.fields`, Le(e.fields, F))
|
|
1662
1662
|
};
|
|
1663
1663
|
},
|
|
1664
1664
|
[e.fields, f.fields, l, t]
|
|
1665
|
-
), b =
|
|
1666
|
-
(
|
|
1667
|
-
const { affectedSections:
|
|
1668
|
-
D().then(),
|
|
1665
|
+
), b = S(
|
|
1666
|
+
(F) => {
|
|
1667
|
+
const { affectedSections: T, action: D, removing: k } = h(F), O = () => {
|
|
1668
|
+
D().then(), p(T, f.fields);
|
|
1669
1669
|
};
|
|
1670
|
-
if (
|
|
1671
|
-
const We =
|
|
1670
|
+
if (T.length > 0) {
|
|
1671
|
+
const We = T.map((Te) => Te.label).join(", ");
|
|
1672
1672
|
return d({
|
|
1673
1673
|
title: "Remove condition?",
|
|
1674
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
|
-
[
|
|
1683
|
-
),
|
|
1684
|
-
const
|
|
1685
|
-
if (
|
|
1682
|
+
[h, p, f.fields, d]
|
|
1683
|
+
), E = S(() => {
|
|
1684
|
+
const T = e.fields.map((Se, Ut) => h(Ut)).flatMap((Se) => Se.affectedSections), D = T.length ? "Remove fields and conditions?" : "Remove fields?", k = e.fields.length, O = T.map((Se) => Se.label).join(", "), We = T.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 (T.length > 0)
|
|
1686
1686
|
return d({
|
|
1687
1687
|
title: D,
|
|
1688
1688
|
description: We,
|
|
1689
1689
|
severity: "danger",
|
|
1690
1690
|
actionText: "Remove",
|
|
1691
1691
|
onAction: () => {
|
|
1692
|
-
|
|
1693
|
-
|
|
1692
|
+
mt().then(() => {
|
|
1693
|
+
p(T, 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
1703
|
l,
|
|
1704
1704
|
d,
|
|
1705
|
-
|
|
1706
|
-
]), I =
|
|
1707
|
-
(
|
|
1708
|
-
if (
|
|
1709
|
-
throw new Error(`Expected a label for field ${
|
|
1710
|
-
const
|
|
1711
|
-
const
|
|
1705
|
+
p
|
|
1706
|
+
]), I = S(
|
|
1707
|
+
(F) => {
|
|
1708
|
+
if (F.label === null)
|
|
1709
|
+
throw new Error(`Expected a label for field ${F.identifier}`);
|
|
1710
|
+
const T = Ye(F.label, u), D = F.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 { ...F, label: T, fields: D, identifier: "" };
|
|
1719
1719
|
},
|
|
1720
1720
|
[u]
|
|
1721
1721
|
), C = x(
|
|
@@ -1752,139 +1752,136 @@ const De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Mt = (s,
|
|
|
1752
1752
|
[I, e, t, f.fields]
|
|
1753
1753
|
), v = x(
|
|
1754
1754
|
() => {
|
|
1755
|
-
var
|
|
1756
|
-
return (
|
|
1755
|
+
var F, T;
|
|
1756
|
+
return (T = Vt(f.fields, (F = e.condition) == null ? void 0 : F.identifier)) == null ? void 0 : T.label;
|
|
1757
1757
|
},
|
|
1758
1758
|
[(A = e.condition) == null ? void 0 : A.identifier, f.fields]
|
|
1759
1759
|
), P = Array.isArray((N = e.condition) == null ? void 0 : N.value) ? "contains all of" : "equals";
|
|
1760
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 R = Array.isArray((Ie = e.condition) == null ? void 0 : Ie.value) ? (Ce = e.condition) == null ? void 0 : Ce.value.map((
|
|
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((F) => typeof F == "string" ? F : F.label).join(", ") : (ft = (ut = e.condition) == null ? void 0 : ut.value) == null ? void 0 : ft.toString(), X = () => {
|
|
1763
|
+
const T = o.filter((O) => O !== null).length, D = o[t] ?? 0, k = 6 / T * 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}
|
|
1771
|
-
height: "100%"
|
|
1770
|
+
marginRight: `${k}%`
|
|
1772
1771
|
}
|
|
1773
1772
|
}
|
|
1774
1773
|
);
|
|
1775
|
-
}, j = () =>
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1774
|
+
}, j = () => {
|
|
1775
|
+
if (!e.condition)
|
|
1776
|
+
return null;
|
|
1777
|
+
const F = c === "light" ? "black" : "white";
|
|
1778
|
+
return /* @__PURE__ */ g(Je, { children: [
|
|
1779
|
+
/* @__PURE__ */ r(
|
|
1780
|
+
ht,
|
|
1781
|
+
{
|
|
1782
|
+
start: `${e.identifier}-card`,
|
|
1783
|
+
end: `${e.identifier}-floating-point`,
|
|
1784
|
+
startAnchor: "left",
|
|
1785
|
+
endAnchor: "right",
|
|
1786
|
+
color: F,
|
|
1787
|
+
strokeWidth: 2,
|
|
1788
|
+
path: "straight",
|
|
1789
|
+
showHead: !1
|
|
1790
|
+
}
|
|
1791
|
+
),
|
|
1792
|
+
/* @__PURE__ */ r(
|
|
1793
|
+
ht,
|
|
1794
|
+
{
|
|
1795
|
+
start: `${e.identifier}-floating-point`,
|
|
1796
|
+
end: `${e.condition.identifier}-card`,
|
|
1797
|
+
startAnchor: "right",
|
|
1798
|
+
endAnchor: "left",
|
|
1799
|
+
color: F,
|
|
1800
|
+
strokeWidth: 2,
|
|
1801
|
+
path: "grid",
|
|
1802
|
+
gridBreak: "0"
|
|
1803
|
+
}
|
|
1804
|
+
)
|
|
1805
|
+
] });
|
|
1806
|
+
};
|
|
1807
|
+
return /* @__PURE__ */ r(rt, { draggableId: e.identifier, index: t, children: (F) => /* @__PURE__ */ g(
|
|
1804
1808
|
y,
|
|
1805
1809
|
{
|
|
1806
|
-
ref:
|
|
1807
|
-
...
|
|
1808
|
-
...
|
|
1810
|
+
ref: F.innerRef,
|
|
1811
|
+
...F.draggableProps,
|
|
1812
|
+
...F.dragHandleProps,
|
|
1809
1813
|
direction: "row",
|
|
1810
1814
|
justify: "center",
|
|
1811
1815
|
align: "center",
|
|
1816
|
+
mb: "4",
|
|
1812
1817
|
children: [
|
|
1813
|
-
o.some((
|
|
1818
|
+
o.some((T) => T !== null) && X(),
|
|
1814
1819
|
e.condition && j(),
|
|
1815
|
-
/* @__PURE__ */ r(
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
/* @__PURE__ */
|
|
1836
|
-
|
|
1820
|
+
/* @__PURE__ */ r(we, { id: `${e.identifier}-card`, style: { flexGrow: "1" }, children: /* @__PURE__ */ g(y, { gap: "3", justify: "between", align: "center", children: [
|
|
1821
|
+
/* @__PURE__ */ g(y, { direction: "column", gap: "2", grow: "1", children: [
|
|
1822
|
+
/* @__PURE__ */ g(y, { direction: "column", children: [
|
|
1823
|
+
/* @__PURE__ */ r(Me, { as: "h3", size: "3", children: e.label }),
|
|
1824
|
+
/* @__PURE__ */ r($, { className: Ne.description, children: e.description })
|
|
1825
|
+
] }),
|
|
1826
|
+
e.condition && /* @__PURE__ */ r($, { size: "1", children: /* @__PURE__ */ g(Ii, { children: [
|
|
1827
|
+
"Display only if ",
|
|
1828
|
+
/* @__PURE__ */ r(pt, { children: v }),
|
|
1829
|
+
" ",
|
|
1830
|
+
P,
|
|
1831
|
+
" ",
|
|
1832
|
+
/* @__PURE__ */ r(pt, { children: R })
|
|
1833
|
+
] }) }),
|
|
1834
|
+
/* @__PURE__ */ r(
|
|
1835
|
+
nt,
|
|
1836
|
+
{
|
|
1837
|
+
droppableId: e.identifier,
|
|
1838
|
+
type: "SECTION",
|
|
1839
|
+
isDropDisabled: a,
|
|
1840
|
+
children: (T) => /* @__PURE__ */ g(
|
|
1841
|
+
y,
|
|
1837
1842
|
{
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
F.placeholder,
|
|
1861
|
-
/* @__PURE__ */ r(pe, { ...V, children: /* @__PURE__ */ g(G, { type: "button", variant: "outline", children: [
|
|
1862
|
-
/* @__PURE__ */ r(Oe, {}),
|
|
1863
|
-
" Add a field"
|
|
1864
|
-
] }) })
|
|
1865
|
-
]
|
|
1866
|
-
}
|
|
1867
|
-
)
|
|
1843
|
+
ref: T.innerRef,
|
|
1844
|
+
...T.droppableProps,
|
|
1845
|
+
direction: "column",
|
|
1846
|
+
gap: "0",
|
|
1847
|
+
children: [
|
|
1848
|
+
e.fields.map((D, k) => /* @__PURE__ */ r(
|
|
1849
|
+
wn,
|
|
1850
|
+
{
|
|
1851
|
+
field: D,
|
|
1852
|
+
index: k,
|
|
1853
|
+
sectionIndex: t,
|
|
1854
|
+
remove: () => b(k),
|
|
1855
|
+
takenLabels: u
|
|
1856
|
+
},
|
|
1857
|
+
D.identifier
|
|
1858
|
+
)),
|
|
1859
|
+
T.placeholder,
|
|
1860
|
+
/* @__PURE__ */ r(he, { ...V, children: /* @__PURE__ */ g(G, { type: "button", variant: "outline", children: [
|
|
1861
|
+
/* @__PURE__ */ r(Oe, {}),
|
|
1862
|
+
" Add a field"
|
|
1863
|
+
] }) })
|
|
1864
|
+
]
|
|
1868
1865
|
}
|
|
1869
1866
|
)
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
)
|
|
1867
|
+
}
|
|
1868
|
+
)
|
|
1869
|
+
] }),
|
|
1870
|
+
/* @__PURE__ */ r(
|
|
1871
|
+
jt,
|
|
1872
|
+
{
|
|
1873
|
+
remove: E,
|
|
1874
|
+
insertAfterProps: w,
|
|
1875
|
+
dragHandleProps: F.dragHandleProps,
|
|
1876
|
+
editProps: C,
|
|
1877
|
+
duplicateProps: L
|
|
1878
|
+
}
|
|
1879
|
+
)
|
|
1880
|
+
] }) })
|
|
1884
1881
|
]
|
|
1885
1882
|
}
|
|
1886
1883
|
) });
|
|
1887
|
-
}),
|
|
1884
|
+
}), xn = (s, i) => {
|
|
1888
1885
|
var t;
|
|
1889
1886
|
const e = { ...s };
|
|
1890
1887
|
switch (i.type) {
|
|
@@ -1899,7 +1896,7 @@ const De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Mt = (s,
|
|
|
1899
1896
|
case "update":
|
|
1900
1897
|
return i.state;
|
|
1901
1898
|
}
|
|
1902
|
-
},
|
|
1899
|
+
}, In = (s, i) => {
|
|
1903
1900
|
if (i)
|
|
1904
1901
|
for (let e = 0; e < s.length; e++) {
|
|
1905
1902
|
const t = s[e];
|
|
@@ -1909,7 +1906,7 @@ const De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Mt = (s,
|
|
|
1909
1906
|
return e;
|
|
1910
1907
|
}
|
|
1911
1908
|
}
|
|
1912
|
-
},
|
|
1909
|
+
}, vt = (s) => {
|
|
1913
1910
|
var e, t, n;
|
|
1914
1911
|
const i = {};
|
|
1915
1912
|
for (let o = 0; o < s.length; o++) {
|
|
@@ -1920,52 +1917,52 @@ const De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Mt = (s,
|
|
|
1920
1917
|
(t = a.condition) != null && t.identifier && l.add(a.condition.identifier), i[a.identifier] = {
|
|
1921
1918
|
disabled: !1,
|
|
1922
1919
|
conditionFields: l,
|
|
1923
|
-
conditionIndex:
|
|
1920
|
+
conditionIndex: In(s, (n = a.condition) == null ? void 0 : n.identifier),
|
|
1924
1921
|
index: o,
|
|
1925
1922
|
label: a.label
|
|
1926
1923
|
};
|
|
1927
1924
|
}
|
|
1928
1925
|
return i;
|
|
1929
|
-
},
|
|
1926
|
+
}, xt = (s, i) => {
|
|
1930
1927
|
for (const [e, t] of Object.entries(s))
|
|
1931
1928
|
if (t.identifier === i)
|
|
1932
1929
|
return [t, e];
|
|
1933
|
-
},
|
|
1934
|
-
const { values: i, setFieldValue: e } =
|
|
1930
|
+
}, Cn = z(function() {
|
|
1931
|
+
const { values: i, setFieldValue: e } = pe(), [t, n] = Si(xn, i.fields, vt), { showInfo: o } = Ci();
|
|
1935
1932
|
ve(() => {
|
|
1936
|
-
n({ type: "update", state:
|
|
1933
|
+
n({ type: "update", state: vt(i.fields) });
|
|
1937
1934
|
}, [n, i.fields]);
|
|
1938
|
-
const a =
|
|
1935
|
+
const a = S((d) => {
|
|
1939
1936
|
d.type === "SECTION" && n({ type: "hold", fieldId: d.draggableId });
|
|
1940
|
-
}, []), c =
|
|
1937
|
+
}, []), c = S(
|
|
1941
1938
|
(d) => {
|
|
1942
|
-
const { source: u, destination:
|
|
1943
|
-
if (n({ type: "release" }), !
|
|
1939
|
+
const { source: u, destination: p, type: h, reason: b, draggableId: E } = d;
|
|
1940
|
+
if (n({ type: "release" }), !p || b === "CANCEL")
|
|
1944
1941
|
return;
|
|
1945
|
-
if (
|
|
1946
|
-
const L = t[
|
|
1942
|
+
if (h === "ROOT") {
|
|
1943
|
+
const L = t[E];
|
|
1947
1944
|
if (!L)
|
|
1948
1945
|
throw new Error("Could not find section context.");
|
|
1949
1946
|
let v = typeof L.conditionIndex < "u" ? (
|
|
1950
1947
|
// cannot move a section with a condition before the condition's field
|
|
1951
|
-
Math.max(L.conditionIndex + 1,
|
|
1952
|
-
) :
|
|
1948
|
+
Math.max(L.conditionIndex + 1, p.index)
|
|
1949
|
+
) : p.index;
|
|
1953
1950
|
for (const P of Object.values(t))
|
|
1954
1951
|
P.conditionIndex === u.index && (v = Math.min(v, P.index - 1));
|
|
1955
|
-
return v !=
|
|
1952
|
+
return v != p.index && o({
|
|
1956
1953
|
title: "Reordered sections",
|
|
1957
1954
|
description: "Sections with conditions must be below the fields they reference."
|
|
1958
1955
|
}), e("fields", Ke(i.fields, u.index, v));
|
|
1959
1956
|
}
|
|
1960
|
-
if (
|
|
1957
|
+
if (h !== "SECTION")
|
|
1961
1958
|
throw new Error("Unexpected droppable type.");
|
|
1962
|
-
const [I, C] =
|
|
1959
|
+
const [I, C] = xt(i.fields, u.droppableId) ?? [], [w, V] = xt(i.fields, p.droppableId) ?? [];
|
|
1963
1960
|
if (!(I != null && I.fields) || !w)
|
|
1964
1961
|
throw new Error("Could not find section with fields.");
|
|
1965
1962
|
if (I.identifier === w.identifier)
|
|
1966
1963
|
e(
|
|
1967
1964
|
`fields.${C}.fields`,
|
|
1968
|
-
Ke(I.fields, u.index,
|
|
1965
|
+
Ke(I.fields, u.index, p.index)
|
|
1969
1966
|
).then();
|
|
1970
1967
|
else {
|
|
1971
1968
|
const L = I.fields[u.index];
|
|
@@ -1973,7 +1970,7 @@ const De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Mt = (s,
|
|
|
1973
1970
|
throw new Error("Could not find field to reorder.");
|
|
1974
1971
|
e(`fields.${C}.fields`, Le(I.fields, u.index)).then(), e(
|
|
1975
1972
|
`fields.${V}.fields`,
|
|
1976
|
-
|
|
1973
|
+
kt(w.fields, p.index, L)
|
|
1977
1974
|
).then();
|
|
1978
1975
|
}
|
|
1979
1976
|
},
|
|
@@ -1990,7 +1987,7 @@ const De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Mt = (s,
|
|
|
1990
1987
|
let d = 1;
|
|
1991
1988
|
return i.fields.map((u) => u.conditional ? d++ : null);
|
|
1992
1989
|
};
|
|
1993
|
-
return /* @__PURE__ */ r(
|
|
1990
|
+
return /* @__PURE__ */ r(Tt, { onDragStart: a, onDragEnd: c, children: /* @__PURE__ */ r(nt, { droppableId: "droppable", type: "ROOT", children: (d) => /* @__PURE__ */ g(
|
|
1994
1991
|
y,
|
|
1995
1992
|
{
|
|
1996
1993
|
ref: d.innerRef,
|
|
@@ -1998,56 +1995,56 @@ const De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Mt = (s,
|
|
|
1998
1995
|
direction: "column",
|
|
1999
1996
|
gap: "0",
|
|
2000
1997
|
children: [
|
|
2001
|
-
i.fields.map((u,
|
|
2002
|
-
|
|
1998
|
+
i.fields.map((u, p) => /* @__PURE__ */ r(
|
|
1999
|
+
vn,
|
|
2003
2000
|
{
|
|
2004
2001
|
field: u,
|
|
2005
|
-
index:
|
|
2002
|
+
index: p,
|
|
2006
2003
|
dropState: t,
|
|
2007
2004
|
conditionalFieldCounts: f()
|
|
2008
2005
|
},
|
|
2009
2006
|
u.label
|
|
2010
2007
|
)),
|
|
2011
2008
|
d.placeholder,
|
|
2012
|
-
/* @__PURE__ */ r(
|
|
2009
|
+
/* @__PURE__ */ r(he, { ...l, children: /* @__PURE__ */ g(G, { type: "button", variant: "outline", children: [
|
|
2013
2010
|
/* @__PURE__ */ r(Oe, {}),
|
|
2014
2011
|
" Add a section"
|
|
2015
2012
|
] }) })
|
|
2016
2013
|
]
|
|
2017
2014
|
}
|
|
2018
2015
|
) }) });
|
|
2019
|
-
}),
|
|
2016
|
+
}), Fn = {
|
|
2020
2017
|
title: "",
|
|
2021
2018
|
description: "",
|
|
2022
2019
|
fields: []
|
|
2023
|
-
},
|
|
2020
|
+
}, Tn = new be({
|
|
2024
2021
|
label: "Title",
|
|
2025
2022
|
minLength: 0,
|
|
2026
2023
|
maxLength: 100,
|
|
2027
2024
|
required: !0,
|
|
2028
2025
|
identifier: "title"
|
|
2029
|
-
}),
|
|
2026
|
+
}), Sn = { formId: qe, placeholder: "Give your form a title." }, zn = new ye({
|
|
2030
2027
|
label: "Description",
|
|
2031
2028
|
minLength: 0,
|
|
2032
2029
|
maxLength: 1e3,
|
|
2033
2030
|
required: !1,
|
|
2034
2031
|
identifier: "description"
|
|
2035
|
-
}),
|
|
2032
|
+
}), En = { formId: qe, placeholder: "Explain the purpose of this form." }, An = () => {
|
|
2036
2033
|
alert("This is a form preview, your data will not be saved.");
|
|
2037
|
-
},
|
|
2034
|
+
}, jn = z(
|
|
2038
2035
|
xe((s, i) => {
|
|
2039
|
-
const { onCancel: e, onSave: t, revision: n } = s, o = n ? "Edit form" : "Create a new form", { heading: a = o } = s, c =
|
|
2036
|
+
const { onCancel: e, onSave: t, revision: n } = s, o = n ? "Edit form" : "Create a new form", { heading: a = o } = s, c = S((h) => {
|
|
2040
2037
|
const b = {};
|
|
2041
|
-
if (
|
|
2038
|
+
if (h.title || (b.title = "Title is required."), (!h.fields || h.fields.length === 0) && (b.fields = "At least one field is required."), _e(b))
|
|
2042
2039
|
return b;
|
|
2043
2040
|
}, []), l = tt({
|
|
2044
|
-
initialValues:
|
|
2041
|
+
initialValues: Ui(n) ?? Fn,
|
|
2045
2042
|
validate: c,
|
|
2046
|
-
onSubmit: (
|
|
2043
|
+
onSubmit: (h) => t(h),
|
|
2047
2044
|
// only validate the entire for on submit
|
|
2048
2045
|
validateOnChange: !1,
|
|
2049
2046
|
validateOnBlur: !1
|
|
2050
|
-
}), f = x(() =>
|
|
2047
|
+
}), f = x(() => Mt(l.values), [l.values]), d = De(Tn, Sn), u = De(zn, En), p = x(
|
|
2051
2048
|
() => typeof a == "object" ? a : /* @__PURE__ */ r(Me, { children: a }),
|
|
2052
2049
|
[a]
|
|
2053
2050
|
);
|
|
@@ -2057,7 +2054,7 @@ const De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Mt = (s,
|
|
|
2057
2054
|
/* @__PURE__ */ r(Q.Trigger, { value: "preview", children: "Preview" })
|
|
2058
2055
|
] }),
|
|
2059
2056
|
/* @__PURE__ */ g(Q.Content, { value: "edit", children: [
|
|
2060
|
-
|
|
2057
|
+
p,
|
|
2061
2058
|
/* @__PURE__ */ g($, { children: [
|
|
2062
2059
|
"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",
|
|
2063
2060
|
" ",
|
|
@@ -2070,7 +2067,7 @@ const De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Mt = (s,
|
|
|
2070
2067
|
/* @__PURE__ */ g(it, { value: l, children: [
|
|
2071
2068
|
d,
|
|
2072
2069
|
u,
|
|
2073
|
-
/* @__PURE__ */ r(
|
|
2070
|
+
/* @__PURE__ */ r(Cn, {}),
|
|
2074
2071
|
/* @__PURE__ */ r($, { severity: "danger", size: "1", children: typeof l.errors.fields == "string" && l.errors.fields })
|
|
2075
2072
|
] }),
|
|
2076
2073
|
/* @__PURE__ */ g(y, { justify: "end", gap: "2", children: [
|
|
@@ -2079,40 +2076,40 @@ const De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Mt = (s,
|
|
|
2079
2076
|
] })
|
|
2080
2077
|
] }) })
|
|
2081
2078
|
] }),
|
|
2082
|
-
/* @__PURE__ */ r(Q.Content, { value: "preview", children: /* @__PURE__ */ r(dt, { schema: f, onSubmit:
|
|
2079
|
+
/* @__PURE__ */ r(Q.Content, { value: "preview", children: /* @__PURE__ */ r(dt, { schema: f, onSubmit: An }) })
|
|
2083
2080
|
] }) });
|
|
2084
2081
|
})
|
|
2085
2082
|
);
|
|
2086
2083
|
export {
|
|
2087
2084
|
fe as BooleanField,
|
|
2088
|
-
|
|
2085
|
+
Ni as BooleanInput,
|
|
2089
2086
|
Ge as DateField,
|
|
2090
|
-
|
|
2087
|
+
qi as DateInput,
|
|
2091
2088
|
Z as FieldSection,
|
|
2092
|
-
|
|
2093
|
-
|
|
2089
|
+
Bn as FormBrowser,
|
|
2090
|
+
jn as FormBuilder,
|
|
2094
2091
|
dt as FormRenderer,
|
|
2095
|
-
|
|
2096
|
-
|
|
2092
|
+
qn as FormSubmissionBrowser,
|
|
2093
|
+
Nn as FormSubmissionViewer,
|
|
2097
2094
|
$e as MultiSelectField,
|
|
2098
|
-
|
|
2095
|
+
Zi as MultiSelectInput,
|
|
2099
2096
|
Pe as MultiStringField,
|
|
2100
|
-
|
|
2097
|
+
Ki as MultiStringInput,
|
|
2101
2098
|
Y as NumberField,
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2099
|
+
Bi as NumberInput,
|
|
2100
|
+
Wn as PatchField,
|
|
2101
|
+
Hn as PatchFormProvider,
|
|
2105
2102
|
ke as SelectField,
|
|
2106
|
-
|
|
2103
|
+
ji as SelectInput,
|
|
2107
2104
|
be as StringField,
|
|
2108
|
-
|
|
2105
|
+
Wi as StringInput,
|
|
2109
2106
|
ye as TextField,
|
|
2110
|
-
|
|
2107
|
+
Hi as TextInput,
|
|
2111
2108
|
Be as deserialize,
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2109
|
+
Ot as deserializeField,
|
|
2110
|
+
Mt as formRevisionToSchema,
|
|
2111
|
+
Rt as isConditionMet,
|
|
2115
2112
|
De as useFieldInput,
|
|
2116
|
-
|
|
2113
|
+
Nt as useFieldInputs,
|
|
2117
2114
|
Xe as valueIsFile
|
|
2118
2115
|
};
|