@overmap-ai/forms 1.0.3-form-improvements.4 → 1.0.3-form-improvements.6
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/builder/utils.d.ts +1 -1
- package/dist/forms.js +209 -212
- package/dist/forms.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/forms.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var m = (s, i, e) => (
|
|
1
|
+
var Nt = Object.defineProperty;
|
|
2
|
+
var Bt = (s, i, e) => i in s ? Nt(s, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[i] = e;
|
|
3
|
+
var m = (s, i, e) => (Bt(s, typeof i != "symbol" ? i + "" : i, e), e);
|
|
4
4
|
import { jsx as r, jsxs as b, Fragment as pt } from "react/jsx-runtime";
|
|
5
|
-
import { Flex as y, Text as D, useSeverityColor as fe, Checkbox as
|
|
5
|
+
import { Flex as y, Text as D, useSeverityColor as fe, Checkbox as qt, CheckCircledIcon as Wt, TextField as le, FontFamilyIcon as jt, CalendarIcon as Ht, InputIcon as Ut, TextArea as Gt, RowsIcon as Kt, Select as ht, Box as he, IconButton as ae, PlusIcon as ke, Badge as qe, Cross1Icon as gt, ListBulletIcon as Yt, DropdownMenuIcon as Qt, MultiSelect as Xt, CheckboxIcon as Jt, Card as ye, Heading as De, Button as G, UploadIcon as bt, ButtonList as _e, divButtonProps as Zt, StarFilledIcon as ei, StarIcon as ti, QuestionMarkCircledIcon as ii, PersonIcon as ni, Tooltip as ri, Avatar as oi, Separator as si, Dialog as li, Pencil1Icon as ai, TrashIcon as ci, CopyIcon as di, DragHandleDots2Icon as ui, DropdownMenu as fi, DotsVerticalIcon as mi, useAlertDialog as pi, Em as hi, Strong as lt, useToast as gi, Tabs as X } from "@overmap-ai/blocks";
|
|
6
6
|
import { useField as Ye, useFormikContext as me, useFormik as Qe, FormikProvider as Xe } from "formik";
|
|
7
|
-
import
|
|
7
|
+
import bi, { useMemo as w, memo as T, useCallback as S, useState as ce, useEffect as ve, useRef as yi, forwardRef as we, useReducer as vi } from "react";
|
|
8
8
|
import { DragDropContext as yt, Droppable as Je, Draggable as Ze } from "@hello-pangea/dnd";
|
|
9
|
-
import { slugify as
|
|
9
|
+
import { slugify as wi, useAppSelector as $, selectFormRevision as vt, useSDK as wt, selectSubmissionAttachments as xi, selectFilteredUserForms as Ii, selectUserFormMapping as Fi, selectOrganization as xt, selectUser as et, selectNumberOfUserForms as Ci, selectCurrentUser as It, classNames as Ft, isToday as Ti, getLocalDateString as Si, selectLatestFormRevision as zi, useFileSrc as Ei, selectSubmissionsForForm as Ai } from "@overmap-ai/core";
|
|
10
10
|
import de from "lodash.get";
|
|
11
11
|
import tt from "lodash.set";
|
|
12
12
|
class Ct {
|
|
@@ -90,21 +90,21 @@ class M extends Ct {
|
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
m(M, "fieldTypeName"), m(M, "fieldTypeDescription");
|
|
93
|
-
const
|
|
94
|
-
description:
|
|
95
|
-
},
|
|
93
|
+
const Li = "_description_17zed_1", $e = {
|
|
94
|
+
description: Li
|
|
95
|
+
}, W = (s) => {
|
|
96
96
|
const { label: i, children: e, severity: t, inputId: n, labelId: o, flexProps: l } = s;
|
|
97
97
|
return /* @__PURE__ */ r(y, { direction: "column", gap: "1", asChild: !0, ...l, children: /* @__PURE__ */ b("label", { htmlFor: n, children: [
|
|
98
98
|
/* @__PURE__ */ r(D, { severity: t, id: o, children: i }),
|
|
99
99
|
e
|
|
100
100
|
] }) });
|
|
101
|
-
},
|
|
101
|
+
}, j = (s) => {
|
|
102
102
|
const { helpText: i, children: e, severity: t } = s;
|
|
103
103
|
return /* @__PURE__ */ b(y, { direction: "column", gap: "1", children: [
|
|
104
104
|
e,
|
|
105
105
|
/* @__PURE__ */ r(y, { direction: "column", children: /* @__PURE__ */ r(D, { size: "1", severity: t, className: $e.description, children: i }) })
|
|
106
106
|
] });
|
|
107
|
-
},
|
|
107
|
+
}, H = (s) => {
|
|
108
108
|
const { id: i, field: e, formId: t, ...n } = s, [o, l, c] = Ye(e.getId()), { touched: a } = l, f = l.error ?? e.description, d = l.error ? "danger" : void 0, u = i ?? `${t}-${e.getId()}-input`, p = `${u}-label`, h = e.required ? `${e.label} *` : e.label, g = w(() => ({
|
|
109
109
|
...o,
|
|
110
110
|
onChange: (F) => {
|
|
@@ -128,10 +128,10 @@ const Ai = "_description_17zed_1", $e = {
|
|
|
128
128
|
},
|
|
129
129
|
{ ...n, "aria-labelledby": p }
|
|
130
130
|
];
|
|
131
|
-
}, Pi = [!0, "true"],
|
|
132
|
-
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: l, fieldProps: c }, a] =
|
|
133
|
-
return /* @__PURE__ */ r(
|
|
134
|
-
|
|
131
|
+
}, Pi = [!0, "true"], Vi = T(function(i) {
|
|
132
|
+
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: l, fieldProps: c }, a] = H(i), f = fe(n), d = Pi.includes(c.value);
|
|
133
|
+
return /* @__PURE__ */ r(j, { helpText: o, severity: n, children: /* @__PURE__ */ r(
|
|
134
|
+
W,
|
|
135
135
|
{
|
|
136
136
|
severity: n,
|
|
137
137
|
inputId: e,
|
|
@@ -139,7 +139,7 @@ const Ai = "_description_17zed_1", $e = {
|
|
|
139
139
|
label: l,
|
|
140
140
|
flexProps: { direction: "row-reverse", justify: "end", align: "center", gap: "2" },
|
|
141
141
|
children: /* @__PURE__ */ r(
|
|
142
|
-
|
|
142
|
+
qt,
|
|
143
143
|
{
|
|
144
144
|
...a,
|
|
145
145
|
...c,
|
|
@@ -175,14 +175,14 @@ const Ai = "_description_17zed_1", $e = {
|
|
|
175
175
|
return new J(e);
|
|
176
176
|
}
|
|
177
177
|
getInput(e) {
|
|
178
|
-
return /* @__PURE__ */ r(
|
|
178
|
+
return /* @__PURE__ */ r(Vi, { ...e, field: this });
|
|
179
179
|
}
|
|
180
180
|
};
|
|
181
|
-
m(J, "fieldTypeName", "Checkbox"), m(J, "fieldTypeDescription", "Perfect for both optional and required yes/no questions."), m(J, "Icon",
|
|
181
|
+
m(J, "fieldTypeName", "Checkbox"), m(J, "fieldTypeDescription", "Perfect for both optional and required yes/no questions."), m(J, "Icon", Wt);
|
|
182
182
|
let ue = J;
|
|
183
|
-
const
|
|
184
|
-
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: l, fieldProps: c, field: a }, f] =
|
|
185
|
-
return /* @__PURE__ */ r(
|
|
183
|
+
const ki = T(function(i) {
|
|
184
|
+
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: l, fieldProps: c, field: a }, f] = H(i), d = fe(n);
|
|
185
|
+
return /* @__PURE__ */ r(j, { helpText: o, severity: n, children: /* @__PURE__ */ r(W, { severity: n, inputId: e, labelId: t, label: l, children: /* @__PURE__ */ r(
|
|
186
186
|
le.Input,
|
|
187
187
|
{
|
|
188
188
|
...f,
|
|
@@ -195,7 +195,7 @@ const Vi = T(function(i) {
|
|
|
195
195
|
color: d
|
|
196
196
|
}
|
|
197
197
|
) }) });
|
|
198
|
-
}),
|
|
198
|
+
}), B = class B extends M {
|
|
199
199
|
constructor(e) {
|
|
200
200
|
const {
|
|
201
201
|
minimum: t = Number.MIN_SAFE_INTEGER,
|
|
@@ -215,7 +215,7 @@ const Vi = T(function(i) {
|
|
|
215
215
|
}
|
|
216
216
|
static getFieldCreationSchema() {
|
|
217
217
|
return [
|
|
218
|
-
new
|
|
218
|
+
new B({
|
|
219
219
|
label: "Minimum",
|
|
220
220
|
description: "Minimum value",
|
|
221
221
|
integers: !0,
|
|
@@ -223,7 +223,7 @@ const Vi = T(function(i) {
|
|
|
223
223
|
identifier: "minimum",
|
|
224
224
|
formValidators: [this._validateMin]
|
|
225
225
|
}),
|
|
226
|
-
new
|
|
226
|
+
new B({
|
|
227
227
|
label: "Maximum",
|
|
228
228
|
description: "Maximum value",
|
|
229
229
|
integers: !0,
|
|
@@ -263,17 +263,17 @@ const Vi = T(function(i) {
|
|
|
263
263
|
static deserialize(e) {
|
|
264
264
|
if (e.type !== "number")
|
|
265
265
|
throw new Error("Type mismatch.");
|
|
266
|
-
return new
|
|
266
|
+
return new B(e);
|
|
267
267
|
}
|
|
268
268
|
getInput(e) {
|
|
269
|
-
return /* @__PURE__ */ r(
|
|
269
|
+
return /* @__PURE__ */ r(ki, { field: this, ...e });
|
|
270
270
|
}
|
|
271
271
|
};
|
|
272
|
-
m(
|
|
273
|
-
let Y =
|
|
274
|
-
const
|
|
275
|
-
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: l, fieldProps: c }, a] =
|
|
276
|
-
return /* @__PURE__ */ r(
|
|
272
|
+
m(B, "fieldTypeName", "Number"), m(B, "fieldTypeDescription", "Allows specifying a number within a given range."), m(B, "Icon", jt), 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);
|
|
273
|
+
let Y = B;
|
|
274
|
+
const Di = T(function(i) {
|
|
275
|
+
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: l, fieldProps: c }, a] = H(i), f = fe(n), d = c.value ? c.value.split("T")[0] : "";
|
|
276
|
+
return /* @__PURE__ */ r(j, { helpText: o, severity: n, children: /* @__PURE__ */ r(W, { severity: n, inputId: e, labelId: t, label: l, children: /* @__PURE__ */ r(le.Input, { ...a, ...c, type: "date", id: e, color: f, value: d }) }) });
|
|
277
277
|
}), Z = class Z extends M {
|
|
278
278
|
constructor(e) {
|
|
279
279
|
super({ ...e, type: "date" });
|
|
@@ -291,10 +291,10 @@ const ki = T(function(i) {
|
|
|
291
291
|
return new Z(e);
|
|
292
292
|
}
|
|
293
293
|
getInput(e) {
|
|
294
|
-
return /* @__PURE__ */ r(
|
|
294
|
+
return /* @__PURE__ */ r(Di, { field: this, ...e });
|
|
295
295
|
}
|
|
296
296
|
};
|
|
297
|
-
m(Z, "fieldTypeName", "Date"), m(Z, "fieldTypeDescription", "Allows specifying a date."), m(Z, "Icon",
|
|
297
|
+
m(Z, "fieldTypeName", "Date"), m(Z, "fieldTypeDescription", "Allows specifying a date."), m(Z, "Icon", Ht);
|
|
298
298
|
let We = Z;
|
|
299
299
|
class Ce extends M {
|
|
300
300
|
constructor(e) {
|
|
@@ -365,9 +365,9 @@ m(Ce, "_validateMax", (e, t) => {
|
|
|
365
365
|
const { minimum_length: n } = t;
|
|
366
366
|
return typeof n != "number" ? null : n > e ? "Maximum cannot be less than minimum." : null;
|
|
367
367
|
});
|
|
368
|
-
const
|
|
369
|
-
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: l, fieldProps: c, field: a }, f] =
|
|
370
|
-
return /* @__PURE__ */ r(
|
|
368
|
+
const _i = T(function(i) {
|
|
369
|
+
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: l, fieldProps: c, field: a }, f] = H(i), d = fe(n);
|
|
370
|
+
return /* @__PURE__ */ r(j, { helpText: o, severity: n, children: /* @__PURE__ */ r(W, { severity: n, inputId: e, labelId: t, label: l, children: /* @__PURE__ */ r(le.Input, { ...f, ...c, type: a.inputType, id: e, color: d }) }) });
|
|
371
371
|
}), ee = class ee extends Ce {
|
|
372
372
|
constructor(e) {
|
|
373
373
|
const { inputType: t = "text", ...n } = e, o = e.maxLength ? Math.min(500, e.maxLength) : 500, l = e.minLength ? Math.min(e.minLength, o) : void 0;
|
|
@@ -385,14 +385,14 @@ const Di = T(function(i) {
|
|
|
385
385
|
return new ee({ ...l, maxLength: t, minLength: n, inputType: o });
|
|
386
386
|
}
|
|
387
387
|
getInput(e) {
|
|
388
|
-
return /* @__PURE__ */ r(
|
|
388
|
+
return /* @__PURE__ */ r(_i, { field: this, ...e });
|
|
389
389
|
}
|
|
390
390
|
};
|
|
391
|
-
m(ee, "fieldTypeName", "Short Text"), m(ee, "fieldTypeDescription", "Short text fields can hold up to 500 characters on a single line."), m(ee, "Icon",
|
|
391
|
+
m(ee, "fieldTypeName", "Short Text"), m(ee, "fieldTypeDescription", "Short text fields can hold up to 500 characters on a single line."), m(ee, "Icon", Ut);
|
|
392
392
|
let ge = ee;
|
|
393
|
-
const
|
|
394
|
-
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: l, fieldProps: c }, a] =
|
|
395
|
-
return /* @__PURE__ */ r(
|
|
393
|
+
const $i = T(function(i) {
|
|
394
|
+
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: l, fieldProps: c }, a] = H(i);
|
|
395
|
+
return /* @__PURE__ */ r(j, { helpText: o, severity: n, children: /* @__PURE__ */ r(W, { severity: n, inputId: e, labelId: t, label: l, children: /* @__PURE__ */ r(Gt, { ...a, ...c, resize: "vertical", id: e, severity: n }) }) });
|
|
396
396
|
}), te = class te extends Ce {
|
|
397
397
|
constructor(i) {
|
|
398
398
|
const e = i.maxLength ? Math.min(5e3, i.maxLength) : 5e3, t = i.minLength ? Math.min(i.minLength, e) : void 0;
|
|
@@ -408,13 +408,13 @@ const _i = T(function(i) {
|
|
|
408
408
|
return new te({ ...n, maxLength: e, minLength: t });
|
|
409
409
|
}
|
|
410
410
|
getInput(i) {
|
|
411
|
-
return /* @__PURE__ */ r(
|
|
411
|
+
return /* @__PURE__ */ r($i, { field: this, ...i });
|
|
412
412
|
}
|
|
413
413
|
};
|
|
414
|
-
m(te, "fieldTypeName", "Paragraph"), m(te, "fieldTypeDescription", "Paragraph fields can hold up to 5000 characters and can have multiple lines."), m(te, "Icon",
|
|
414
|
+
m(te, "fieldTypeName", "Paragraph"), m(te, "fieldTypeDescription", "Paragraph fields can hold up to 5000 characters and can have multiple lines."), m(te, "Icon", Kt);
|
|
415
415
|
let be = te;
|
|
416
|
-
const
|
|
417
|
-
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: l, fieldProps: c, field: a }, f] =
|
|
416
|
+
const Mi = T(function(i) {
|
|
417
|
+
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: l, fieldProps: c, field: a }, f] = H(i), { onChange: d, onBlur: u } = c, p = w(
|
|
418
418
|
() => a.options.map((g) => ({ value: g.value, itemContent: g.label })),
|
|
419
419
|
[a.options]
|
|
420
420
|
), h = S(
|
|
@@ -423,7 +423,7 @@ const $i = T(function(i) {
|
|
|
423
423
|
},
|
|
424
424
|
[d, u]
|
|
425
425
|
);
|
|
426
|
-
return /* @__PURE__ */ r(
|
|
426
|
+
return /* @__PURE__ */ r(j, { helpText: o, severity: n, children: /* @__PURE__ */ r(W, { severity: n, inputId: e, labelId: t, label: l, children: /* @__PURE__ */ r(
|
|
427
427
|
ht,
|
|
428
428
|
{
|
|
429
429
|
items: p,
|
|
@@ -442,7 +442,7 @@ const $i = T(function(i) {
|
|
|
442
442
|
label: null,
|
|
443
443
|
condition: null,
|
|
444
444
|
conditional: !1
|
|
445
|
-
}),
|
|
445
|
+
}), Oi = (s) => {
|
|
446
446
|
if (!s)
|
|
447
447
|
return;
|
|
448
448
|
const i = s.fields;
|
|
@@ -458,7 +458,7 @@ function je(s, i, e) {
|
|
|
458
458
|
throw new Error("Could not find field to reorder.");
|
|
459
459
|
return t.splice(e, 0, n), t;
|
|
460
460
|
}
|
|
461
|
-
function
|
|
461
|
+
function Ri(s, i, e) {
|
|
462
462
|
const t = Array.from(s);
|
|
463
463
|
return t[i] = e, t;
|
|
464
464
|
}
|
|
@@ -470,23 +470,23 @@ function Se(s, i) {
|
|
|
470
470
|
const e = Array.from(s);
|
|
471
471
|
return e.splice(i, 1), e;
|
|
472
472
|
}
|
|
473
|
-
const
|
|
473
|
+
const St = (s, i) => {
|
|
474
474
|
if (typeof s == "string" && s.length > 0)
|
|
475
475
|
return s;
|
|
476
476
|
const e = /* @__PURE__ */ new Date();
|
|
477
|
-
return `${
|
|
478
|
-
},
|
|
477
|
+
return `${wi(i)}-${e.getTime()}`;
|
|
478
|
+
}, zt = (s, i) => {
|
|
479
479
|
if (!i)
|
|
480
480
|
return null;
|
|
481
481
|
for (const e of s)
|
|
482
482
|
if (e.type === "section") {
|
|
483
|
-
const t =
|
|
483
|
+
const t = zt(e.fields, i);
|
|
484
484
|
if (t)
|
|
485
485
|
return t;
|
|
486
486
|
} else if (e.identifier === i)
|
|
487
487
|
return e;
|
|
488
488
|
return null;
|
|
489
|
-
}, Fe = (s, i) => s.filter((e, t) => t < i).flatMap((e) => e.fields),
|
|
489
|
+
}, Fe = (s, i) => s.filter((e, t) => t < i).flatMap((e) => e.fields), Et = (s) => s.flatMap(
|
|
490
490
|
(i) => i.type === "section" ? [...i.fields.map((e) => e.label), i.label] : i.label
|
|
491
491
|
).filter((i) => i !== null), He = (s, i) => {
|
|
492
492
|
let e = 1, t = `${s} (${e})`;
|
|
@@ -494,7 +494,7 @@ const Ri = (s, i) => {
|
|
|
494
494
|
t = `${s} (${++e})`;
|
|
495
495
|
return t;
|
|
496
496
|
}, Ni = T(function(i) {
|
|
497
|
-
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: l, fieldProps: c }, a] =
|
|
497
|
+
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: l, fieldProps: c }, a] = H(i), f = fe(n), d = w(() => Array.isArray(c.value) ? c.value : [], [c.value]), { onChange: u, onBlur: p } = c, h = `${e}-droppable`, { disabled: g } = a, [x, z] = ce(""), [F, v] = ce(""), L = F || o, P = F ? "red" : f, I = S(
|
|
498
498
|
(A) => {
|
|
499
499
|
u(A), p(A);
|
|
500
500
|
},
|
|
@@ -511,17 +511,17 @@ const Ri = (s, i) => {
|
|
|
511
511
|
return v("Option cannot be empty");
|
|
512
512
|
const A = x.trim();
|
|
513
513
|
I([...d, { value: A, label: A }]), z("");
|
|
514
|
-
}, [x, F, I, d]),
|
|
514
|
+
}, [x, F, I, d]), K = S(
|
|
515
515
|
(A) => {
|
|
516
516
|
A.key === "Enter" && (A.preventDefault(), O());
|
|
517
517
|
},
|
|
518
518
|
[O]
|
|
519
|
-
),
|
|
519
|
+
), q = S(
|
|
520
520
|
(A) => {
|
|
521
521
|
I(Se(d, A));
|
|
522
522
|
},
|
|
523
523
|
[d, I]
|
|
524
|
-
),
|
|
524
|
+
), U = S(
|
|
525
525
|
(A) => {
|
|
526
526
|
if (!A.destination)
|
|
527
527
|
return;
|
|
@@ -530,8 +530,8 @@ const Ri = (s, i) => {
|
|
|
530
530
|
},
|
|
531
531
|
[I, d]
|
|
532
532
|
);
|
|
533
|
-
return /* @__PURE__ */ r(yt, { onDragEnd:
|
|
534
|
-
/* @__PURE__ */ r(
|
|
533
|
+
return /* @__PURE__ */ r(yt, { onDragEnd: U, children: /* @__PURE__ */ b(y, { direction: "column", gap: "2", children: [
|
|
534
|
+
/* @__PURE__ */ r(j, { helpText: L, severity: n, children: /* @__PURE__ */ r(W, { severity: n, inputId: e, labelId: t, label: l, children: (!g || d.length === 0) && /* @__PURE__ */ b(y, { gap: "2", children: [
|
|
535
535
|
/* @__PURE__ */ r(he, { grow: "1", children: /* @__PURE__ */ r(
|
|
536
536
|
le.Input,
|
|
537
537
|
{
|
|
@@ -540,9 +540,9 @@ const Ri = (s, i) => {
|
|
|
540
540
|
...c,
|
|
541
541
|
value: x,
|
|
542
542
|
onChange: V,
|
|
543
|
-
onKeyDown:
|
|
543
|
+
onKeyDown: K,
|
|
544
544
|
id: e,
|
|
545
|
-
color:
|
|
545
|
+
color: P,
|
|
546
546
|
onBlur: void 0
|
|
547
547
|
}
|
|
548
548
|
) }),
|
|
@@ -586,7 +586,7 @@ const Ri = (s, i) => {
|
|
|
586
586
|
"aria-label": "Delete option",
|
|
587
587
|
severity: "info",
|
|
588
588
|
disabled: g,
|
|
589
|
-
onClick: () =>
|
|
589
|
+
onClick: () => q(C),
|
|
590
590
|
children: /* @__PURE__ */ r(gt, {})
|
|
591
591
|
}
|
|
592
592
|
)
|
|
@@ -638,9 +638,9 @@ const Ri = (s, i) => {
|
|
|
638
638
|
return new ie(e);
|
|
639
639
|
}
|
|
640
640
|
};
|
|
641
|
-
m(ie, "fieldTypeName", "Multi-string"), m(ie, "fieldTypeDescription", "Allows the user to provide multiple unique strings."), m(ie, "Icon",
|
|
641
|
+
m(ie, "fieldTypeName", "Multi-string"), m(ie, "fieldTypeDescription", "Allows the user to provide multiple unique strings."), m(ie, "Icon", Yt);
|
|
642
642
|
let ze = ie;
|
|
643
|
-
class
|
|
643
|
+
class At extends M {
|
|
644
644
|
constructor(e) {
|
|
645
645
|
super(e);
|
|
646
646
|
m(this, "options");
|
|
@@ -670,7 +670,7 @@ class Et extends M {
|
|
|
670
670
|
];
|
|
671
671
|
}
|
|
672
672
|
}
|
|
673
|
-
const ne = class ne extends
|
|
673
|
+
const ne = class ne extends At {
|
|
674
674
|
constructor(i) {
|
|
675
675
|
super({ ...i, type: "select" });
|
|
676
676
|
}
|
|
@@ -686,20 +686,20 @@ const ne = class ne extends Et {
|
|
|
686
686
|
return new ne(i);
|
|
687
687
|
}
|
|
688
688
|
getInput(i) {
|
|
689
|
-
return /* @__PURE__ */ r(
|
|
689
|
+
return /* @__PURE__ */ r(Mi, { field: this, ...i });
|
|
690
690
|
}
|
|
691
691
|
};
|
|
692
|
-
m(ne, "fieldTypeName", "Dropdown"), m(ne, "fieldTypeDescription", "Allows the user to select a single option from a list of options."), m(ne, "Icon",
|
|
692
|
+
m(ne, "fieldTypeName", "Dropdown"), m(ne, "fieldTypeDescription", "Allows the user to select a single option from a list of options."), m(ne, "Icon", Qt);
|
|
693
693
|
let Ee = ne;
|
|
694
694
|
const Bi = (s) => s ? Array.isArray(s) ? s : [s] : [], qi = T(function(i) {
|
|
695
|
-
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: l, fieldProps: c, field: a }, f] =
|
|
695
|
+
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: l, fieldProps: c, field: a }, f] = H(i), { onChange: d, onBlur: u } = c, p = w(() => Bi(c.value), [c.value]), h = S(
|
|
696
696
|
(g) => {
|
|
697
697
|
d(g), u(g);
|
|
698
698
|
},
|
|
699
699
|
[d, u]
|
|
700
700
|
);
|
|
701
|
-
return /* @__PURE__ */ r(
|
|
702
|
-
|
|
701
|
+
return /* @__PURE__ */ r(j, { helpText: o, severity: n, children: /* @__PURE__ */ r(W, { severity: n, inputId: e, labelId: t, label: l, children: /* @__PURE__ */ r(
|
|
702
|
+
Xt,
|
|
703
703
|
{
|
|
704
704
|
value: p,
|
|
705
705
|
onValueChange: h,
|
|
@@ -711,7 +711,7 @@ const Bi = (s) => s ? Array.isArray(s) ? s : [s] : [], qi = T(function(i) {
|
|
|
711
711
|
...f
|
|
712
712
|
}
|
|
713
713
|
) }) });
|
|
714
|
-
}), re = class re extends
|
|
714
|
+
}), re = class re extends At {
|
|
715
715
|
constructor(i) {
|
|
716
716
|
super({ ...i, type: "multi-select" });
|
|
717
717
|
}
|
|
@@ -735,16 +735,16 @@ const Bi = (s) => s ? Array.isArray(s) ? s : [s] : [], qi = T(function(i) {
|
|
|
735
735
|
return /* @__PURE__ */ r(qi, { field: this, ...i });
|
|
736
736
|
}
|
|
737
737
|
};
|
|
738
|
-
m(re, "fieldTypeName", "Multi-select"), m(re, "fieldTypeDescription", "Allows the user to select a multiple options from a list of options."), m(re, "Icon",
|
|
738
|
+
m(re, "fieldTypeName", "Multi-select"), m(re, "fieldTypeDescription", "Allows the user to select a multiple options from a list of options."), m(re, "Icon", Jt);
|
|
739
739
|
let Ae = re;
|
|
740
740
|
const Wi = T(function({ field: i, ...e }) {
|
|
741
741
|
const [{ value: t }] = Ye(i.options.clonedFieldIdentifier), n = w(() => {
|
|
742
742
|
const o = i.options.getFieldToClone(t);
|
|
743
743
|
return o ? Me(o) : null;
|
|
744
744
|
}, [i.options, t]);
|
|
745
|
-
return
|
|
745
|
+
return Pe(n, e);
|
|
746
746
|
});
|
|
747
|
-
class
|
|
747
|
+
class Le extends M {
|
|
748
748
|
constructor(e, t) {
|
|
749
749
|
super({ ...e, type: "custom" });
|
|
750
750
|
m(this, "Component");
|
|
@@ -760,20 +760,20 @@ class Pe extends M {
|
|
|
760
760
|
return /* @__PURE__ */ r(t, { field: this, ...e });
|
|
761
761
|
}
|
|
762
762
|
}
|
|
763
|
-
m(
|
|
764
|
-
class ji extends
|
|
763
|
+
m(Le, "fieldTypeName", "Custom"), m(Le, "fieldTypeDescription", "Allows re-rendering of field already in the form");
|
|
764
|
+
class ji extends Le {
|
|
765
765
|
constructor(i) {
|
|
766
766
|
super(i, Wi);
|
|
767
767
|
}
|
|
768
768
|
}
|
|
769
769
|
const Hi = T(function(i) {
|
|
770
|
-
const { field: e, ...t } = i, { label: n, description: o, fields: l, condition: c } = e, { values: a, setFieldValue: f } = me(), d = c != null && c.identifier ? de(a, c.identifier) : void 0, u = w(() =>
|
|
770
|
+
const { field: e, ...t } = i, { label: n, description: o, fields: l, condition: c } = e, { values: a, setFieldValue: f } = me(), d = c != null && c.identifier ? de(a, c.identifier) : void 0, u = w(() => Vt(c, d), [c, d]);
|
|
771
771
|
ve(() => {
|
|
772
772
|
if (!u)
|
|
773
773
|
for (const h of l)
|
|
774
774
|
f(h.getId(), "").then();
|
|
775
775
|
}, [u, l, f]);
|
|
776
|
-
const p =
|
|
776
|
+
const p = kt(l, t);
|
|
777
777
|
return u ? n ? /* @__PURE__ */ r(ye, { children: /* @__PURE__ */ b(y, { direction: "column", gap: "3", children: [
|
|
778
778
|
/* @__PURE__ */ b(y, { direction: "column", children: [
|
|
779
779
|
/* @__PURE__ */ r(De, { as: "h3", size: "3", children: n }),
|
|
@@ -855,7 +855,7 @@ const Hi = T(function(i) {
|
|
|
855
855
|
var n;
|
|
856
856
|
if (e.type !== "section")
|
|
857
857
|
throw new Error("Invalid type");
|
|
858
|
-
const t = ((n = e.fields) == null ? void 0 : n.map(
|
|
858
|
+
const t = ((n = e.fields) == null ? void 0 : n.map(Lt)) ?? [];
|
|
859
859
|
return new oe({ ...e, fields: t });
|
|
860
860
|
}
|
|
861
861
|
conditional() {
|
|
@@ -893,8 +893,8 @@ const Ui = "_previewImage_1ig84_1", Gi = {
|
|
|
893
893
|
e /= 1024, t++;
|
|
894
894
|
return new Intl.NumberFormat([], { maximumFractionDigits: 2, style: "unit", unit: i[t] }).format(e);
|
|
895
895
|
}, Ki = T(function(i) {
|
|
896
|
-
var
|
|
897
|
-
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: l, fieldProps: c, field: a }, f] =
|
|
896
|
+
var P;
|
|
897
|
+
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: l, fieldProps: c, field: a }, f] = H(i), { onChange: d } = c, u = fe(n), p = yi(null), { value: h } = c, g = w(() => o || (a.maxFileSize ? `Maximum file size: ${it(a.maxFileSize)}` : null), [a.maxFileSize, o]), x = S(() => {
|
|
898
898
|
var I;
|
|
899
899
|
(I = p.current) == null || I.click();
|
|
900
900
|
}, []), z = S(
|
|
@@ -903,13 +903,13 @@ const Ui = "_previewImage_1ig84_1", Gi = {
|
|
|
903
903
|
V.splice(I, 1), d({ target: { files: V } });
|
|
904
904
|
},
|
|
905
905
|
[h, d]
|
|
906
|
-
), F = h ? "Select new files" : "Select files", v = h ? "Select new file" : "Select a file",
|
|
906
|
+
), F = h ? "Select new files" : "Select files", v = h ? "Select new file" : "Select a file", L = a.maxFiles > 1 ? F : v;
|
|
907
907
|
return /* @__PURE__ */ b(y, { direction: "column", gap: "2", children: [
|
|
908
|
-
/* @__PURE__ */ r(
|
|
909
|
-
/* @__PURE__ */ r(y, { direction: "row", gap: "2", children: /* @__PURE__ */ r(he, { width: "max-content", asChild: !0, children: /* @__PURE__ */ b(
|
|
908
|
+
/* @__PURE__ */ r(j, { helpText: g, severity: n, children: /* @__PURE__ */ b(W, { severity: n, inputId: e, labelId: t, label: l, children: [
|
|
909
|
+
/* @__PURE__ */ r(y, { direction: "row", gap: "2", children: /* @__PURE__ */ r(he, { width: "max-content", asChild: !0, children: /* @__PURE__ */ b(G, { ...f, onClick: x, children: [
|
|
910
910
|
/* @__PURE__ */ r(bt, {}),
|
|
911
911
|
" ",
|
|
912
|
-
|
|
912
|
+
L
|
|
913
913
|
] }) }) }),
|
|
914
914
|
/* @__PURE__ */ r(
|
|
915
915
|
"input",
|
|
@@ -918,7 +918,7 @@ const Ui = "_previewImage_1ig84_1", Gi = {
|
|
|
918
918
|
type: "file",
|
|
919
919
|
ref: p,
|
|
920
920
|
id: e,
|
|
921
|
-
accept: (
|
|
921
|
+
accept: (P = a.extensions) == null ? void 0 : P.join(","),
|
|
922
922
|
multiple: a.maxFiles > 1,
|
|
923
923
|
color: u,
|
|
924
924
|
style: { display: "none" },
|
|
@@ -1067,15 +1067,15 @@ const nt = {
|
|
|
1067
1067
|
select: Ee,
|
|
1068
1068
|
string: ge,
|
|
1069
1069
|
text: be,
|
|
1070
|
-
custom:
|
|
1070
|
+
custom: Le,
|
|
1071
1071
|
upload: Ue,
|
|
1072
1072
|
// TODO: Underscore
|
|
1073
1073
|
"multi-string": ze,
|
|
1074
1074
|
"multi-select": Ae
|
|
1075
|
-
},
|
|
1075
|
+
}, Lt = (s) => {
|
|
1076
1076
|
const i = s.type;
|
|
1077
1077
|
return nt[i].deserialize(s);
|
|
1078
|
-
}, Me = (s) => s.type === "section" ? Q.deserialize(s) :
|
|
1078
|
+
}, Me = (s) => s.type === "section" ? Q.deserialize(s) : Lt(s);
|
|
1079
1079
|
function Pt(s, i = {}) {
|
|
1080
1080
|
const { readonly: e = !1 } = i;
|
|
1081
1081
|
return {
|
|
@@ -1088,7 +1088,7 @@ function Pt(s, i = {}) {
|
|
|
1088
1088
|
function Ge(s) {
|
|
1089
1089
|
return !!(Array.isArray(s) && s.some((i) => i instanceof File || i instanceof Promise));
|
|
1090
1090
|
}
|
|
1091
|
-
function
|
|
1091
|
+
function Vt(s, i) {
|
|
1092
1092
|
if (!s)
|
|
1093
1093
|
return !0;
|
|
1094
1094
|
if (Ge(i) || Ge(s.value))
|
|
@@ -1102,16 +1102,16 @@ function Lt(s, i) {
|
|
|
1102
1102
|
}
|
|
1103
1103
|
return t === i;
|
|
1104
1104
|
}
|
|
1105
|
-
const
|
|
1105
|
+
const Pe = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), kt = (s, i) => {
|
|
1106
1106
|
const e = w(() => s.map((t) => /* @__PURE__ */ r("div", { children: t.getInput(i) }, t.getId())), [s, i]);
|
|
1107
1107
|
return /* @__PURE__ */ r(y, { direction: "column", gap: "2", children: e });
|
|
1108
|
-
}, Ve = (s) => Object.keys(s).length > 0,
|
|
1108
|
+
}, Ve = (s) => Object.keys(s).length > 0, Dt = async (s, i) => {
|
|
1109
1109
|
const e = {};
|
|
1110
1110
|
for (const t of s.fields)
|
|
1111
1111
|
if (t instanceof Q) {
|
|
1112
1112
|
if (t.condition) {
|
|
1113
1113
|
const { identifier: n } = t.condition;
|
|
1114
|
-
if (!
|
|
1114
|
+
if (!Vt(t.condition, de(i, n)))
|
|
1115
1115
|
continue;
|
|
1116
1116
|
}
|
|
1117
1117
|
Object.assign(e, t.getErrors(i));
|
|
@@ -1142,7 +1142,7 @@ const Le = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), Vt = (s,
|
|
|
1142
1142
|
} = s, { readonly: p } = e.meta, h = w(() => crypto.randomUUID(), []), g = Qe({
|
|
1143
1143
|
initialValues: rt(e.fields, t),
|
|
1144
1144
|
onSubmit: n,
|
|
1145
|
-
validate: (
|
|
1145
|
+
validate: (L) => Dt(e, L),
|
|
1146
1146
|
// only validate the entire form on submit
|
|
1147
1147
|
validateOnBlur: !1,
|
|
1148
1148
|
validateOnChange: !1
|
|
@@ -1152,7 +1152,7 @@ const Le = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), Vt = (s,
|
|
|
1152
1152
|
), F = w(
|
|
1153
1153
|
() => typeof e.description == "string" ? /* @__PURE__ */ r(D, { className: $e.description, children: e.description }) : e.description,
|
|
1154
1154
|
[e.description]
|
|
1155
|
-
), v =
|
|
1155
|
+
), v = kt(e.fields, { formId: h, disabled: p });
|
|
1156
1156
|
return ve(() => {
|
|
1157
1157
|
x && a && a();
|
|
1158
1158
|
}, [x, a]), /* @__PURE__ */ r(Xe, { value: g, children: /* @__PURE__ */ r(y, { ref: i, direction: "column", gap: "2", className: u, asChild: !0, children: /* @__PURE__ */ b("form", { id: h, onSubmit: g.handleSubmit, children: [
|
|
@@ -1162,12 +1162,12 @@ const Le = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), Vt = (s,
|
|
|
1162
1162
|
] }) }),
|
|
1163
1163
|
v,
|
|
1164
1164
|
!p && /* @__PURE__ */ b(y, { justify: "end", gap: "2", children: [
|
|
1165
|
-
l && /* @__PURE__ */ r(
|
|
1166
|
-
/* @__PURE__ */ r(
|
|
1165
|
+
l && /* @__PURE__ */ r(G, { type: "button", variant: "soft", onClick: c, children: l }),
|
|
1166
|
+
/* @__PURE__ */ r(G, { type: "submit", disabled: !g.isValid, children: o })
|
|
1167
1167
|
] })
|
|
1168
1168
|
] }) }) });
|
|
1169
1169
|
})
|
|
1170
|
-
),
|
|
1170
|
+
), Pn = T(
|
|
1171
1171
|
we((s, i) => {
|
|
1172
1172
|
const { submission: e, showFormDescription: t = !1, showFormTitle: n = !0 } = s, o = $(vt(e.form_revision)), { sdk: l } = wt();
|
|
1173
1173
|
if (!o)
|
|
@@ -1175,7 +1175,7 @@ const Le = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), Vt = (s,
|
|
|
1175
1175
|
`Could not find revision ${e.form_revision} for submission ${e.offline_id}.`
|
|
1176
1176
|
);
|
|
1177
1177
|
const c = w(() => Pt(o, { readonly: !0 }), [o]), a = w(() => {
|
|
1178
|
-
const f =
|
|
1178
|
+
const f = xi(e.offline_id)(l.store.getState()) ?? [], d = {};
|
|
1179
1179
|
for (const u of f) {
|
|
1180
1180
|
const p = l.files.fetchFileFromUrl(u.file, u.file_sha1, u.file_name).then((g) => {
|
|
1181
1181
|
if (!g.success)
|
|
@@ -1205,23 +1205,23 @@ const Le = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), Vt = (s,
|
|
|
1205
1205
|
const { maxResults: e = 20, ...t } = s, [n, o] = ce(""), [l, c] = ce(""), { sdk: a } = wt(), f = w(() => {
|
|
1206
1206
|
const v = { maxResults: e, searchTerm: n };
|
|
1207
1207
|
return l && (l.startsWith(Ne) ? v.owner_organization = parseInt(l.slice(Ne.length)) : l.startsWith(Be) && (v.owner_user = parseInt(l.slice(Be.length)))), v;
|
|
1208
|
-
}, [n, e, l]), d = $(
|
|
1208
|
+
}, [n, e, l]), d = $(Ii(f)) ?? [], u = $(Fi), p = S(
|
|
1209
1209
|
(v) => {
|
|
1210
1210
|
v.favorite ? a.userForms.unfavorite(v.offline_id).then() : a.userForms.favorite(v.offline_id).then();
|
|
1211
1211
|
},
|
|
1212
1212
|
[a]
|
|
1213
1213
|
), h = w(() => {
|
|
1214
|
-
const v = a.store.getState(),
|
|
1215
|
-
for (const
|
|
1216
|
-
const I = xt(
|
|
1217
|
-
I && (
|
|
1218
|
-
const V = et(
|
|
1219
|
-
V && (
|
|
1214
|
+
const v = a.store.getState(), L = {};
|
|
1215
|
+
for (const P of Object.values(u)) {
|
|
1216
|
+
const I = xt(P.owner_organization || -1)(v);
|
|
1217
|
+
I && (L[`${Ne}${I.id}`] = I.name);
|
|
1218
|
+
const V = et(P.owner_user || -1)(v);
|
|
1219
|
+
V && (L[`${Be}${V.id}`] = V.username);
|
|
1220
1220
|
}
|
|
1221
|
-
return Object.entries(
|
|
1221
|
+
return Object.entries(L).map(([P, I]) => ({ itemContent: I, value: P }));
|
|
1222
1222
|
}, [u, a.store]), g = S((v) => {
|
|
1223
1223
|
o(v.currentTarget.value);
|
|
1224
|
-
}, []), z = ($(
|
|
1224
|
+
}, []), z = ($(Ci) || 0) - d.length, F = d.length == e && z > 0 ? `Only the first ${e} results are shown (${z} hidden)` : z > 0 && `${z} hidden forms`;
|
|
1225
1225
|
return /* @__PURE__ */ b(y, { ref: i, direction: "column", gap: "2", children: [
|
|
1226
1226
|
/* @__PURE__ */ b(y, { gap: "2", grow: "1", children: [
|
|
1227
1227
|
/* @__PURE__ */ r(he, { grow: "1", asChild: !0, children: /* @__PURE__ */ r(le.Root, { size: "3", children: /* @__PURE__ */ r(le.Input, { placeholder: "Filter", value: n, onChange: g }) }) }),
|
|
@@ -1255,7 +1255,7 @@ const Le = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), Vt = (s,
|
|
|
1255
1255
|
h.stopPropagation(), n();
|
|
1256
1256
|
},
|
|
1257
1257
|
[n]
|
|
1258
|
-
), u = /* @__PURE__ */ r(_e.Item, { onClick: () => e(i), asChild: !0, children: /* @__PURE__ */ b(y, { justify: "between", gap: "2", py: "2", px: "3", ...
|
|
1258
|
+
), u = /* @__PURE__ */ r(_e.Item, { onClick: () => e(i), asChild: !0, children: /* @__PURE__ */ b(y, { justify: "between", gap: "2", py: "2", px: "3", ...Zt, children: [
|
|
1259
1259
|
/* @__PURE__ */ b(y, { grow: "1", align: "center", gap: "2", children: [
|
|
1260
1260
|
/* @__PURE__ */ r(
|
|
1261
1261
|
ae,
|
|
@@ -1265,38 +1265,38 @@ const Le = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), Vt = (s,
|
|
|
1265
1265
|
onClick: d,
|
|
1266
1266
|
"aria-label": i.favorite ? "Favorite form" : "Standard form",
|
|
1267
1267
|
disabled: !t,
|
|
1268
|
-
children: i.favorite ? /* @__PURE__ */ r(
|
|
1268
|
+
children: i.favorite ? /* @__PURE__ */ r(ei, {}) : /* @__PURE__ */ r(ti, {})
|
|
1269
1269
|
}
|
|
1270
1270
|
),
|
|
1271
1271
|
/* @__PURE__ */ r(D, { noWrap: !0, children: i.latestRevision.title }),
|
|
1272
|
-
i.latestRevision.description && /* @__PURE__ */ r(
|
|
1272
|
+
i.latestRevision.description && /* @__PURE__ */ r(ii, {})
|
|
1273
1273
|
] }),
|
|
1274
1274
|
f && /* @__PURE__ */ b(y, { align: "center", gap: "2", children: [
|
|
1275
|
-
/* @__PURE__ */ r(
|
|
1275
|
+
/* @__PURE__ */ r(ni, {}),
|
|
1276
1276
|
" ",
|
|
1277
1277
|
f
|
|
1278
1278
|
] })
|
|
1279
1279
|
] }) });
|
|
1280
|
-
return i.latestRevision.description ? /* @__PURE__ */ r(
|
|
1281
|
-
}, tn = "_submissionsContainer_9iirt_1", nn = "_stopHorizontalOverflow_9iirt_6",
|
|
1280
|
+
return i.latestRevision.description ? /* @__PURE__ */ r(ri, { content: i.latestRevision.description, children: u }, i.offline_id) : u;
|
|
1281
|
+
}, tn = "_submissionsContainer_9iirt_1", nn = "_stopHorizontalOverflow_9iirt_6", _t = {
|
|
1282
1282
|
submissionsContainer: tn,
|
|
1283
1283
|
stopHorizontalOverflow: nn
|
|
1284
1284
|
}, rn = T(function(i) {
|
|
1285
1285
|
var v;
|
|
1286
|
-
const { submission: e, onSubmissionClick: t, compact: n, labelType: o, rowDecorator: l } = i, c = $(It), a = $(et("created_by" in e ? e.created_by : c.id)), f = Ke(e), d =
|
|
1286
|
+
const { submission: e, onSubmissionClick: t, compact: n, labelType: o, rowDecorator: l } = i, c = $(It), a = $(et("created_by" in e ? e.created_by : c.id)), f = Ke(e), d = Ti(f) ? f.toLocaleTimeString([], {
|
|
1287
1287
|
hour: "2-digit",
|
|
1288
1288
|
minute: "2-digit"
|
|
1289
|
-
}) :
|
|
1289
|
+
}) : Si(f), u = $(vt(e.form_revision));
|
|
1290
1290
|
if (!u)
|
|
1291
1291
|
throw new Error(`Could not find revision ${e.form_revision} for submission ${e.offline_id}.`);
|
|
1292
|
-
const p = (v = $(
|
|
1292
|
+
const p = (v = $(zi(u.form))) == null ? void 0 : v.revision, h = Ei({
|
|
1293
1293
|
file: (a == null ? void 0 : a.profile.file) ?? null,
|
|
1294
1294
|
fileSha1: (a == null ? void 0 : a.profile.file_sha1) ?? null
|
|
1295
|
-
}), g = (a == null ? void 0 : a.username.charAt(0).toUpperCase()) ?? "?", x = u.revision === p, z =
|
|
1295
|
+
}), g = (a == null ? void 0 : a.username.charAt(0).toUpperCase()) ?? "?", x = u.revision === p, z = bi.useCallback(() => {
|
|
1296
1296
|
t && t({ submission: e });
|
|
1297
1297
|
}, [e, t]), F = /* @__PURE__ */ r(_e.Item, { onClick: z, asChild: !0, children: /* @__PURE__ */ b(y, { grow: "1", width: "100%", p: "2", gap: "2", justify: "between", children: [
|
|
1298
|
-
/* @__PURE__ */ b(y, { gap: "2", align: "center", className:
|
|
1299
|
-
/* @__PURE__ */ r(
|
|
1298
|
+
/* @__PURE__ */ b(y, { gap: "2", align: "center", className: _t.stopHorizontalOverflow, children: [
|
|
1299
|
+
/* @__PURE__ */ r(oi, { src: h, size: "1", fallback: g }),
|
|
1300
1300
|
/* @__PURE__ */ r(D, { size: "2", noWrap: !0, children: o === "creator" ? (a || c).username : u.title })
|
|
1301
1301
|
] }),
|
|
1302
1302
|
/* @__PURE__ */ b(y, { gap: "2", align: "center", children: [
|
|
@@ -1321,7 +1321,7 @@ const Le = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), Vt = (s,
|
|
|
1321
1321
|
if (!!e == !!t)
|
|
1322
1322
|
throw new Error("Either formId or submissions must be provided, but not both.");
|
|
1323
1323
|
const f = $(
|
|
1324
|
-
t ? () => t :
|
|
1324
|
+
t ? () => t : Ai(e)
|
|
1325
1325
|
), d = w(
|
|
1326
1326
|
() => f == null ? void 0 : f.sort((u, p) => Ke(p).getTime() - Ke(u).getTime()),
|
|
1327
1327
|
[f]
|
|
@@ -1329,7 +1329,7 @@ const Le = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), Vt = (s,
|
|
|
1329
1329
|
return /* @__PURE__ */ r(
|
|
1330
1330
|
_e.Root,
|
|
1331
1331
|
{
|
|
1332
|
-
className: Ft(
|
|
1332
|
+
className: Ft(_t.submissionsContainer, o),
|
|
1333
1333
|
size: "small",
|
|
1334
1334
|
variant: c,
|
|
1335
1335
|
before: !n && /* @__PURE__ */ b(D, { severity: "info", children: [
|
|
@@ -1373,7 +1373,7 @@ const Le = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), Vt = (s,
|
|
|
1373
1373
|
[a, o]
|
|
1374
1374
|
), d = S(
|
|
1375
1375
|
async (g) => {
|
|
1376
|
-
const x = await
|
|
1376
|
+
const x = await Dt(t, g);
|
|
1377
1377
|
return x && l(x), x;
|
|
1378
1378
|
},
|
|
1379
1379
|
[t, l]
|
|
@@ -1389,25 +1389,25 @@ const Le = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), Vt = (s,
|
|
|
1389
1389
|
Ve(p) && h({ values: a, errors: {} });
|
|
1390
1390
|
}, [p, a, h]), /* @__PURE__ */ r(Xe, { value: u, children: /* @__PURE__ */ r("form", { ...c, ref: i, onSubmit: u.handleSubmit, children: e }) });
|
|
1391
1391
|
})
|
|
1392
|
-
),
|
|
1392
|
+
), $t = {
|
|
1393
1393
|
...nt,
|
|
1394
1394
|
section: Q
|
|
1395
1395
|
}, on = T(function(i) {
|
|
1396
1396
|
const { field: e, setFieldType: t } = i, n = e.fieldTypeName, o = e.fieldTypeDescription, l = e.Icon;
|
|
1397
1397
|
return /* @__PURE__ */ b(y, { gap: "4", align: "center", children: [
|
|
1398
|
-
/* @__PURE__ */ r(
|
|
1398
|
+
/* @__PURE__ */ r(G, { type: "button", variant: "surface", onClick: t, style: { width: "135px" }, children: /* @__PURE__ */ b(y, { gap: "3", align: "center", grow: "1", children: [
|
|
1399
1399
|
/* @__PURE__ */ r(l, {}),
|
|
1400
1400
|
n
|
|
1401
1401
|
] }) }),
|
|
1402
1402
|
/* @__PURE__ */ r(D, { children: o })
|
|
1403
1403
|
] });
|
|
1404
|
-
}),
|
|
1404
|
+
}), Mt = [
|
|
1405
1405
|
["string", "text"],
|
|
1406
1406
|
["select", "multi-select", "upload"],
|
|
1407
1407
|
["boolean", "date", "number", "multi-string"]
|
|
1408
|
-
], sn =
|
|
1408
|
+
], sn = Mt.length - 1, ln = T(function(i) {
|
|
1409
1409
|
const { setFieldType: e } = i;
|
|
1410
|
-
return /* @__PURE__ */ r(y, { direction: "column", gap: "3", children:
|
|
1410
|
+
return /* @__PURE__ */ r(y, { direction: "column", gap: "3", children: Mt.map((t, n) => /* @__PURE__ */ b(y, { direction: "column", gap: "3", children: [
|
|
1411
1411
|
/* @__PURE__ */ r(y, { direction: "column", gap: "2", children: t.map((o) => /* @__PURE__ */ r(
|
|
1412
1412
|
on,
|
|
1413
1413
|
{
|
|
@@ -1416,10 +1416,10 @@ const Le = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), Vt = (s,
|
|
|
1416
1416
|
},
|
|
1417
1417
|
o
|
|
1418
1418
|
)) }),
|
|
1419
|
-
n < sn && /* @__PURE__ */ r(
|
|
1419
|
+
n < sn && /* @__PURE__ */ r(si, { size: "4" })
|
|
1420
1420
|
] }, n)) });
|
|
1421
1421
|
}), an = (s) => (i) => {
|
|
1422
|
-
if (
|
|
1422
|
+
if (!(!i || typeof i != "string") && s.includes(i.trim()))
|
|
1423
1423
|
return "This name is already taken.";
|
|
1424
1424
|
}, cn = (s, i) => {
|
|
1425
1425
|
const e = [
|
|
@@ -1442,12 +1442,10 @@ const Le = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), Vt = (s,
|
|
|
1442
1442
|
new ue({ label: "Required", description: null, required: !1, identifier: "required" })
|
|
1443
1443
|
];
|
|
1444
1444
|
}, dn = T(function(i) {
|
|
1445
|
-
const { fieldType: e, handleCancel: t, handleCreateField: n, defaultField: o, conditionalSourceFields: l } = i, c =
|
|
1446
|
-
|
|
1447
|
-
const a = me(), f = w(() => {
|
|
1448
|
-
const d = zt(a.values.fields).filter((p) => p !== (o == null ? void 0 : o.label));
|
|
1445
|
+
const { fieldType: e, handleCancel: t, handleCreateField: n, defaultField: o, conditionalSourceFields: l } = i, c = $t[e], a = me(), f = w(() => {
|
|
1446
|
+
const d = Et(a.values.fields).filter((p) => p !== (o == null ? void 0 : o.label));
|
|
1449
1447
|
let u = cn(d, e);
|
|
1450
|
-
if (
|
|
1448
|
+
if (c === Q) {
|
|
1451
1449
|
if (l === void 0)
|
|
1452
1450
|
throw new Error("Conditional source fields must be provided when changing sections.");
|
|
1453
1451
|
u = u.concat(c.getFieldCreationSchema(l));
|
|
@@ -1474,59 +1472,59 @@ const Le = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), Vt = (s,
|
|
|
1474
1472
|
}
|
|
1475
1473
|
);
|
|
1476
1474
|
}), pe = T(function(i) {
|
|
1477
|
-
const { parentPath: e, index: t, children: n, initial: o, editing: l, conditionalSourceFields: c } = i, [a, f] = ce(), d = (o == null ? void 0 : o.type) ?? a, u = d ?
|
|
1475
|
+
const { parentPath: e, index: t, children: n, initial: o, editing: l, conditionalSourceFields: c } = i, [a, f] = ce(), d = (o == null ? void 0 : o.type) ?? a, u = d ? $t[d].fieldTypeName : void 0, { setFieldValue: p, values: h } = me();
|
|
1478
1476
|
if (l && !o)
|
|
1479
1477
|
throw new Error("Initial field must be provided if editing is true.");
|
|
1480
1478
|
const g = !d && !l && !o, x = g ? "Choose a field type" : `${u} settings`, z = g ? "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.`, F = S(() => f(void 0), []), v = S((I) => {
|
|
1481
1479
|
f(void 0), I();
|
|
1482
|
-
}, []),
|
|
1480
|
+
}, []), L = S(
|
|
1483
1481
|
(I, V) => {
|
|
1484
1482
|
const { label: O } = I;
|
|
1485
1483
|
if (!d)
|
|
1486
1484
|
throw new Error("Field type must be selected before creating a field.");
|
|
1487
1485
|
if (!O || typeof O != "string")
|
|
1488
1486
|
throw new Error("Label must be provided before creating a field.");
|
|
1489
|
-
const
|
|
1487
|
+
const K = Me({
|
|
1490
1488
|
type: d,
|
|
1491
1489
|
...I,
|
|
1492
|
-
identifier:
|
|
1493
|
-
}).serialize(),
|
|
1494
|
-
if (
|
|
1490
|
+
identifier: St(I.identifier, O)
|
|
1491
|
+
}).serialize(), q = de(h, e);
|
|
1492
|
+
if (q === void 0)
|
|
1495
1493
|
throw new Error("Parent path must point to an existing field.");
|
|
1496
|
-
let
|
|
1497
|
-
if (!Array.isArray(
|
|
1494
|
+
let U;
|
|
1495
|
+
if (!Array.isArray(q))
|
|
1498
1496
|
throw new Error("Parent path must point to an array.");
|
|
1499
|
-
l ?
|
|
1497
|
+
l ? U = Ri(q, t, K) : U = Tt(q, t, K), p(e, U).then(), V();
|
|
1500
1498
|
},
|
|
1501
1499
|
[l, d, h, e, p, t]
|
|
1502
|
-
),
|
|
1500
|
+
), P = S(
|
|
1503
1501
|
(I) => g ? /* @__PURE__ */ r(ln, { setFieldType: f }) : /* @__PURE__ */ r(
|
|
1504
1502
|
dn,
|
|
1505
1503
|
{
|
|
1506
1504
|
conditionalSourceFields: c,
|
|
1507
1505
|
handleCancel: F,
|
|
1508
|
-
handleCreateField: (V) =>
|
|
1506
|
+
handleCreateField: (V) => L(V, I),
|
|
1509
1507
|
fieldType: d,
|
|
1510
1508
|
defaultField: o
|
|
1511
1509
|
}
|
|
1512
1510
|
),
|
|
1513
|
-
[c, F,
|
|
1511
|
+
[c, F, L, o, g, d]
|
|
1514
1512
|
);
|
|
1515
|
-
return /* @__PURE__ */ r(
|
|
1513
|
+
return /* @__PURE__ */ r(li, { onCloseInterrupt: v, title: x, description: z, content: P, children: n });
|
|
1516
1514
|
}), dt = ({ children: s }) => /* @__PURE__ */ r(pt, { children: s }), ut = (s, i) => ({
|
|
1517
1515
|
initial: s ? i : "none",
|
|
1518
1516
|
sm: s ? "none" : i
|
|
1519
|
-
}),
|
|
1517
|
+
}), Ot = T(function(i) {
|
|
1520
1518
|
const { remove: e, dragHandleProps: t, editProps: n, insertAfterProps: o, duplicateProps: l } = i, c = w(
|
|
1521
1519
|
() => [
|
|
1522
1520
|
{
|
|
1523
1521
|
Wrapper: pe,
|
|
1524
1522
|
wrapperProps: n,
|
|
1525
|
-
Icon:
|
|
1523
|
+
Icon: ai,
|
|
1526
1524
|
text: "Edit"
|
|
1527
1525
|
},
|
|
1528
1526
|
{
|
|
1529
|
-
Icon:
|
|
1527
|
+
Icon: ci,
|
|
1530
1528
|
buttonProps: {
|
|
1531
1529
|
onClick: e
|
|
1532
1530
|
},
|
|
@@ -1535,7 +1533,7 @@ const Le = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), Vt = (s,
|
|
|
1535
1533
|
{
|
|
1536
1534
|
Wrapper: pe,
|
|
1537
1535
|
wrapperProps: l,
|
|
1538
|
-
Icon:
|
|
1536
|
+
Icon: di,
|
|
1539
1537
|
text: "Duplicate"
|
|
1540
1538
|
},
|
|
1541
1539
|
{
|
|
@@ -1548,7 +1546,7 @@ const Le = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), Vt = (s,
|
|
|
1548
1546
|
// Wrapping icon in a div so that the asChild turns the button into a div
|
|
1549
1547
|
// so that the drag handle props are not applied to the icon
|
|
1550
1548
|
// Note: b/c the <button> does not handle the space-press event correctly
|
|
1551
|
-
Icon: (a) => /* @__PURE__ */ r("div", { ...a, children: /* @__PURE__ */ r(
|
|
1549
|
+
Icon: (a) => /* @__PURE__ */ r("div", { ...a, children: /* @__PURE__ */ r(ui, {}) }),
|
|
1552
1550
|
text: "Reorder",
|
|
1553
1551
|
disableOnMobile: !0,
|
|
1554
1552
|
buttonProps: { ...t, asChild: !0 }
|
|
@@ -1562,9 +1560,9 @@ const Le = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), Vt = (s,
|
|
|
1562
1560
|
return /* @__PURE__ */ r(f, { ...a.wrapperProps, children: /* @__PURE__ */ r(ae, { type: "button", variant: "ghost", "aria-label": a.text, ...a.buttonProps, children: /* @__PURE__ */ r(a.Icon, {}) }) }, a.text);
|
|
1563
1561
|
}) }),
|
|
1564
1562
|
/* @__PURE__ */ r(he, { display: ut(!0, "block"), children: /* @__PURE__ */ r(
|
|
1565
|
-
|
|
1563
|
+
fi,
|
|
1566
1564
|
{
|
|
1567
|
-
trigger: /* @__PURE__ */ r(ae, { variant: "ghost", "aria-label": "Actions menu", children: /* @__PURE__ */ r(
|
|
1565
|
+
trigger: /* @__PURE__ */ r(ae, { variant: "ghost", "aria-label": "Actions menu", children: /* @__PURE__ */ r(mi, {}) }),
|
|
1568
1566
|
closeOnSelect: !1,
|
|
1569
1567
|
items: c.map((a) => {
|
|
1570
1568
|
var d;
|
|
@@ -1584,9 +1582,7 @@ const Le = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), Vt = (s,
|
|
|
1584
1582
|
) })
|
|
1585
1583
|
] });
|
|
1586
1584
|
}), Oe = "form-builder", un = T(function(i) {
|
|
1587
|
-
const { field: e, index: t, sectionIndex: n, takenLabels: o, remove: l } = i, c = w(() => Me(e), [e]), a =
|
|
1588
|
-
console.log(e, t, n, c);
|
|
1589
|
-
const f = w(
|
|
1585
|
+
const { field: e, index: t, sectionIndex: n, takenLabels: o, remove: l } = i, c = w(() => Me(e), [e]), a = Pe(c, { formId: Oe, disabled: !0 }), f = w(
|
|
1590
1586
|
() => ({
|
|
1591
1587
|
index: t,
|
|
1592
1588
|
parentPath: `fields.${n}.fields`,
|
|
@@ -1619,7 +1615,7 @@ const Le = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), Vt = (s,
|
|
|
1619
1615
|
children: /* @__PURE__ */ b(y, { gap: "4", justify: "between", align: "center", children: [
|
|
1620
1616
|
a,
|
|
1621
1617
|
/* @__PURE__ */ r(
|
|
1622
|
-
|
|
1618
|
+
Ot,
|
|
1623
1619
|
{
|
|
1624
1620
|
remove: l,
|
|
1625
1621
|
editProps: f,
|
|
@@ -1632,10 +1628,8 @@ const Le = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), Vt = (s,
|
|
|
1632
1628
|
}
|
|
1633
1629
|
) });
|
|
1634
1630
|
}), fn = T(function(i) {
|
|
1635
|
-
var V, O,
|
|
1636
|
-
const { field: e, index: t, dropState: n } = i, o = (V = n[e.identifier]) == null ? void 0 : V.disabled, { setFieldValue: l, values: c } = me(), a =
|
|
1637
|
-
console.log("field section", e, t, c);
|
|
1638
|
-
const d = S(
|
|
1631
|
+
var V, O, K, q, U, A, R;
|
|
1632
|
+
const { field: e, index: t, dropState: n } = i, o = (V = n[e.identifier]) == null ? void 0 : V.disabled, { setFieldValue: l, values: c } = me(), a = pi(), f = Et(c.fields), d = S(
|
|
1639
1633
|
(C, E) => {
|
|
1640
1634
|
for (const _ of C) {
|
|
1641
1635
|
const k = E.indexOf(_);
|
|
@@ -1650,8 +1644,8 @@ const Le = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), Vt = (s,
|
|
|
1650
1644
|
if (!E)
|
|
1651
1645
|
throw new Error("Could not find field to remove.");
|
|
1652
1646
|
const _ = [];
|
|
1653
|
-
for (const
|
|
1654
|
-
((k =
|
|
1647
|
+
for (const N of c.fields)
|
|
1648
|
+
((k = N.condition) == null ? void 0 : k.identifier) === E.identifier && _.push(N);
|
|
1655
1649
|
return {
|
|
1656
1650
|
removing: E,
|
|
1657
1651
|
affectedSections: _,
|
|
@@ -1661,7 +1655,7 @@ const Le = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), Vt = (s,
|
|
|
1661
1655
|
[e.fields, c.fields, l, t]
|
|
1662
1656
|
), p = S(
|
|
1663
1657
|
(C) => {
|
|
1664
|
-
const { affectedSections: E, action: _, removing: k } = u(C),
|
|
1658
|
+
const { affectedSections: E, action: _, removing: k } = u(C), N = () => {
|
|
1665
1659
|
_().then(), d(E, c.fields);
|
|
1666
1660
|
};
|
|
1667
1661
|
if (E.length > 0) {
|
|
@@ -1671,14 +1665,14 @@ const Le = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), Vt = (s,
|
|
|
1671
1665
|
description: `${k.label} is being used as a condition, deleting it will remove the condition from the ${Re} section(s).`,
|
|
1672
1666
|
severity: "danger",
|
|
1673
1667
|
actionText: "Remove",
|
|
1674
|
-
onAction:
|
|
1668
|
+
onAction: N
|
|
1675
1669
|
});
|
|
1676
1670
|
}
|
|
1677
|
-
|
|
1671
|
+
N();
|
|
1678
1672
|
},
|
|
1679
1673
|
[u, d, c.fields, a]
|
|
1680
1674
|
), h = S(() => {
|
|
1681
|
-
const E = e.fields.map((Ie,
|
|
1675
|
+
const E = e.fields.map((Ie, Rt) => u(Rt)).flatMap((Ie) => Ie.affectedSections), _ = E.length ? "Remove fields and conditions?" : "Remove fields?", k = e.fields.length, N = E.map((Ie) => Ie.label).join(", "), Re = E.length ? `Deleting this section will remove the ${k} field(s) it contains and will remove the conditions from following sections: ${N}` : `Deleting this section will remove the ${k} field(s) it contains.`, xe = Se(c.fields, t), st = () => l("fields", xe);
|
|
1682
1676
|
if (E.length > 0)
|
|
1683
1677
|
return a({
|
|
1684
1678
|
title: _,
|
|
@@ -1702,12 +1696,15 @@ const Le = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), Vt = (s,
|
|
|
1702
1696
|
d
|
|
1703
1697
|
]), g = S(
|
|
1704
1698
|
(C) => {
|
|
1705
|
-
const E = He(C.label ?? "", f), _ = C.fields.map((k) =>
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1699
|
+
const E = He(C.label ?? "", f), _ = C.fields.map((k) => {
|
|
1700
|
+
const N = He(k.label, f);
|
|
1701
|
+
return {
|
|
1702
|
+
...k,
|
|
1703
|
+
label: N,
|
|
1704
|
+
identifier: St(void 0, N)
|
|
1705
|
+
};
|
|
1706
|
+
});
|
|
1707
|
+
return { ...C, label: E, fields: _, identifier: "" };
|
|
1711
1708
|
},
|
|
1712
1709
|
[f]
|
|
1713
1710
|
), x = w(
|
|
@@ -1742,16 +1739,16 @@ const Le = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), Vt = (s,
|
|
|
1742
1739
|
conditionalSourceFields: Fe(c.fields, t + 1)
|
|
1743
1740
|
}),
|
|
1744
1741
|
[g, e, t, c.fields]
|
|
1745
|
-
),
|
|
1742
|
+
), L = w(
|
|
1746
1743
|
() => {
|
|
1747
1744
|
var C, E;
|
|
1748
|
-
return (E =
|
|
1745
|
+
return (E = zt(c.fields, (C = e.condition) == null ? void 0 : C.identifier)) == null ? void 0 : E.label;
|
|
1749
1746
|
},
|
|
1750
1747
|
[(O = e.condition) == null ? void 0 : O.identifier, c.fields]
|
|
1751
|
-
),
|
|
1752
|
-
if (Ge((
|
|
1748
|
+
), P = Array.isArray((K = e.condition) == null ? void 0 : K.value) ? "contains all of" : "equals";
|
|
1749
|
+
if (Ge((q = e.condition) == null ? void 0 : q.value))
|
|
1753
1750
|
throw new Error("File values are not supported for conditions.");
|
|
1754
|
-
const I = Array.isArray((
|
|
1751
|
+
const I = Array.isArray((U = e.condition) == null ? void 0 : U.value) ? (A = e.condition) == null ? void 0 : A.value.map((C) => typeof C == "string" ? C : C.label).join(", ") : (R = e.condition) == null ? void 0 : R.value.toString();
|
|
1755
1752
|
return /* @__PURE__ */ r(Ze, { draggableId: e.identifier, index: t, children: (C) => /* @__PURE__ */ r(
|
|
1756
1753
|
ye,
|
|
1757
1754
|
{
|
|
@@ -1765,11 +1762,11 @@ const Le = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), Vt = (s,
|
|
|
1765
1762
|
/* @__PURE__ */ r(De, { as: "h3", size: "3", children: e.label }),
|
|
1766
1763
|
/* @__PURE__ */ r(D, { className: $e.description, children: e.description })
|
|
1767
1764
|
] }),
|
|
1768
|
-
e.condition && /* @__PURE__ */ r(D, { size: "1", children: /* @__PURE__ */ b(
|
|
1765
|
+
e.condition && /* @__PURE__ */ r(D, { size: "1", children: /* @__PURE__ */ b(hi, { children: [
|
|
1769
1766
|
"Display only if ",
|
|
1770
|
-
/* @__PURE__ */ r(lt, { children:
|
|
1767
|
+
/* @__PURE__ */ r(lt, { children: L }),
|
|
1771
1768
|
" ",
|
|
1772
|
-
|
|
1769
|
+
P,
|
|
1773
1770
|
" ",
|
|
1774
1771
|
/* @__PURE__ */ r(lt, { children: I })
|
|
1775
1772
|
] }) }),
|
|
@@ -1793,7 +1790,7 @@ const Le = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), Vt = (s,
|
|
|
1793
1790
|
_.identifier
|
|
1794
1791
|
)),
|
|
1795
1792
|
E.placeholder,
|
|
1796
|
-
/* @__PURE__ */ r(pe, { ...F, children: /* @__PURE__ */ b(
|
|
1793
|
+
/* @__PURE__ */ r(pe, { ...F, children: /* @__PURE__ */ b(G, { type: "button", variant: "outline", children: [
|
|
1797
1794
|
/* @__PURE__ */ r(ke, {}),
|
|
1798
1795
|
" Add a field"
|
|
1799
1796
|
] }) })
|
|
@@ -1802,7 +1799,7 @@ const Le = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), Vt = (s,
|
|
|
1802
1799
|
) })
|
|
1803
1800
|
] }),
|
|
1804
1801
|
/* @__PURE__ */ r(
|
|
1805
|
-
|
|
1802
|
+
Ot,
|
|
1806
1803
|
{
|
|
1807
1804
|
remove: h,
|
|
1808
1805
|
insertAfterProps: z,
|
|
@@ -1861,7 +1858,7 @@ const Le = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), Vt = (s,
|
|
|
1861
1858
|
if (t.identifier === i)
|
|
1862
1859
|
return [t, e];
|
|
1863
1860
|
}, hn = T(function() {
|
|
1864
|
-
const { values: i, setFieldValue: e } = me(), [t, n] =
|
|
1861
|
+
const { values: i, setFieldValue: e } = me(), [t, n] = vi(mn, i.fields, ft), { showInfo: o } = gi();
|
|
1865
1862
|
ve(() => {
|
|
1866
1863
|
n({ type: "update", state: ft(i.fields) });
|
|
1867
1864
|
}, [n, i.fields]);
|
|
@@ -1873,19 +1870,19 @@ const Le = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), Vt = (s,
|
|
|
1873
1870
|
if (n({ type: "release" }), !u || h === "CANCEL")
|
|
1874
1871
|
return;
|
|
1875
1872
|
if (p === "ROOT") {
|
|
1876
|
-
const
|
|
1877
|
-
if (!
|
|
1873
|
+
const L = t[g];
|
|
1874
|
+
if (!L)
|
|
1878
1875
|
throw new Error("Could not find section context.");
|
|
1879
|
-
let
|
|
1876
|
+
let P = typeof L.conditionIndex < "u" ? (
|
|
1880
1877
|
// cannot move a section with a condition before the condition's field
|
|
1881
|
-
Math.max(
|
|
1878
|
+
Math.max(L.conditionIndex + 1, u.index)
|
|
1882
1879
|
) : u.index;
|
|
1883
1880
|
for (const I of Object.values(t))
|
|
1884
|
-
I.conditionIndex === d.index && (
|
|
1885
|
-
return
|
|
1881
|
+
I.conditionIndex === d.index && (P = Math.min(P, I.index - 1));
|
|
1882
|
+
return P != u.index && o({
|
|
1886
1883
|
title: "Reordered sections",
|
|
1887
1884
|
description: "Sections with conditions must be below the fields they reference."
|
|
1888
|
-
}), e("fields", je(i.fields, d.index,
|
|
1885
|
+
}), e("fields", je(i.fields, d.index, P));
|
|
1889
1886
|
}
|
|
1890
1887
|
if (p !== "SECTION")
|
|
1891
1888
|
throw new Error("Unexpected droppable type.");
|
|
@@ -1898,12 +1895,12 @@ const Le = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), Vt = (s,
|
|
|
1898
1895
|
je(x.fields, d.index, u.index)
|
|
1899
1896
|
).then();
|
|
1900
1897
|
else {
|
|
1901
|
-
const
|
|
1902
|
-
if (!
|
|
1898
|
+
const L = x.fields[d.index];
|
|
1899
|
+
if (!L)
|
|
1903
1900
|
throw new Error("Could not find field to reorder.");
|
|
1904
1901
|
e(`fields.${z}.fields`, Se(x.fields, d.index)).then(), e(
|
|
1905
1902
|
`fields.${v}.fields`,
|
|
1906
|
-
Tt(F.fields, u.index,
|
|
1903
|
+
Tt(F.fields, u.index, L)
|
|
1907
1904
|
).then();
|
|
1908
1905
|
}
|
|
1909
1906
|
},
|
|
@@ -1935,7 +1932,7 @@ const Le = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), Vt = (s,
|
|
|
1935
1932
|
d.label
|
|
1936
1933
|
)),
|
|
1937
1934
|
f.placeholder,
|
|
1938
|
-
/* @__PURE__ */ r(pe, { ...a, children: /* @__PURE__ */ b(
|
|
1935
|
+
/* @__PURE__ */ r(pe, { ...a, children: /* @__PURE__ */ b(G, { type: "button", variant: "outline", children: [
|
|
1939
1936
|
/* @__PURE__ */ r(ke, {}),
|
|
1940
1937
|
" Add a section"
|
|
1941
1938
|
] }) })
|
|
@@ -1967,13 +1964,13 @@ const Le = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), Vt = (s,
|
|
|
1967
1964
|
if (h.title || (g.title = "Title is required."), (!h.fields || h.fields.length === 0) && (g.fields = "At least one field is required."), Ve(g))
|
|
1968
1965
|
return g;
|
|
1969
1966
|
}, []), a = Qe({
|
|
1970
|
-
initialValues:
|
|
1967
|
+
initialValues: Oi(n) ?? gn,
|
|
1971
1968
|
validate: c,
|
|
1972
1969
|
onSubmit: (h) => t(h),
|
|
1973
1970
|
// only validate the entire for on submit
|
|
1974
1971
|
validateOnChange: !1,
|
|
1975
1972
|
validateOnBlur: !1
|
|
1976
|
-
}), f = w(() => Pt(a.values), [a.values]), d =
|
|
1973
|
+
}), f = w(() => Pt(a.values), [a.values]), d = Pe(bn, yn), u = Pe(vn, wn), p = w(
|
|
1977
1974
|
() => typeof l == "object" ? l : /* @__PURE__ */ r(De, { children: l }),
|
|
1978
1975
|
[l]
|
|
1979
1976
|
);
|
|
@@ -2000,8 +1997,8 @@ const Le = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), Vt = (s,
|
|
|
2000
1997
|
/* @__PURE__ */ r(D, { severity: "danger", size: "1", children: typeof a.errors.fields == "string" && a.errors.fields })
|
|
2001
1998
|
] }),
|
|
2002
1999
|
/* @__PURE__ */ b(y, { justify: "end", gap: "2", children: [
|
|
2003
|
-
/* @__PURE__ */ r(
|
|
2004
|
-
/* @__PURE__ */ r(
|
|
2000
|
+
/* @__PURE__ */ r(G, { type: "button", variant: "soft", onClick: e, children: "Cancel" }),
|
|
2001
|
+
/* @__PURE__ */ r(G, { type: "submit", disabled: !a.isValid, children: "Save" })
|
|
2005
2002
|
] })
|
|
2006
2003
|
] }) })
|
|
2007
2004
|
] }),
|
|
@@ -2011,34 +2008,34 @@ const Le = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), Vt = (s,
|
|
|
2011
2008
|
);
|
|
2012
2009
|
export {
|
|
2013
2010
|
ue as BooleanField,
|
|
2014
|
-
|
|
2011
|
+
Vi as BooleanInput,
|
|
2015
2012
|
We as DateField,
|
|
2016
|
-
|
|
2013
|
+
Di as DateInput,
|
|
2017
2014
|
Q as FieldSection,
|
|
2018
2015
|
Vn as FormBrowser,
|
|
2019
2016
|
$n as FormBuilder,
|
|
2020
2017
|
ot as FormRenderer,
|
|
2021
2018
|
kn as FormSubmissionBrowser,
|
|
2022
|
-
|
|
2019
|
+
Pn as FormSubmissionViewer,
|
|
2023
2020
|
Ae as MultiSelectField,
|
|
2024
2021
|
qi as MultiSelectInput,
|
|
2025
2022
|
ze as MultiStringField,
|
|
2026
2023
|
Ni as MultiStringInput,
|
|
2027
2024
|
Y as NumberField,
|
|
2028
|
-
|
|
2025
|
+
ki as NumberInput,
|
|
2029
2026
|
Dn as PatchField,
|
|
2030
2027
|
_n as PatchFormProvider,
|
|
2031
2028
|
Ee as SelectField,
|
|
2032
|
-
|
|
2029
|
+
Mi as SelectInput,
|
|
2033
2030
|
ge as StringField,
|
|
2034
|
-
|
|
2031
|
+
_i as StringInput,
|
|
2035
2032
|
be as TextField,
|
|
2036
|
-
|
|
2033
|
+
$i as TextInput,
|
|
2037
2034
|
Me as deserialize,
|
|
2038
|
-
|
|
2035
|
+
Lt as deserializeField,
|
|
2039
2036
|
Pt as formRevisionToSchema,
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2037
|
+
Vt as isConditionMet,
|
|
2038
|
+
Pe as useFieldInput,
|
|
2039
|
+
kt as useFieldInputs,
|
|
2043
2040
|
Ge as valueIsFile
|
|
2044
2041
|
};
|