@overmap-ai/forms 1.0.3-alpha.0 → 1.0.3-draggability-and-dirty-check.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/forms.js +390 -387
- package/dist/forms.umd.cjs +1 -1
- package/dist/renderer/FormRenderer/FormRenderer.d.ts +1 -0
- package/package.json +3 -2
package/dist/forms.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
var kt = Object.defineProperty;
|
|
2
2
|
var _t = (s, i, e) => i in s ? kt(s, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[i] = e;
|
|
3
3
|
var m = (s, i, e) => (_t(s, typeof i != "symbol" ? i + "" : i, e), e);
|
|
4
|
-
import { jsx as r, jsxs as
|
|
5
|
-
import { Flex as v, Text as k, useSeverityColor as de, Checkbox as
|
|
4
|
+
import { jsx as r, jsxs as b, Fragment as dt } from "react/jsx-runtime";
|
|
5
|
+
import { Flex as v, Text as k, useSeverityColor as de, Checkbox as $t, CheckCircledIcon as Mt, TextField as se, FontFamilyIcon as Ot, CalendarIcon as Rt, InputIcon as Nt, TextArea as Bt, RowsIcon as qt, Select as ut, Box as me, IconButton as le, PlusIcon as De, Badge as Oe, Cross1Icon as ft, ListBulletIcon as Wt, DropdownMenuIcon as jt, MultiSelect as Ht, CheckboxIcon as Ut, Card as ge, Heading as Pe, Button as H, UploadIcon as mt, ButtonList as Le, divButtonProps as Gt, StarFilledIcon as Kt, StarIcon as Yt, QuestionMarkCircledIcon as Qt, PersonIcon as Xt, Tooltip as Jt, Avatar as Zt, Separator as ei, useDiscardAlertDialog as ti, Dialog as ii, Pencil1Icon as ni, TrashIcon as ri, DragHandleDots2Icon as oi, DropdownMenu as si, DotsVerticalIcon as li, useAlertDialog as ai, Em as ci, Strong as nt, useToast as di, Tabs as Q } from "@overmap-ai/blocks";
|
|
6
6
|
import { useField as He, useFormikContext as ue, useFormik as Ue, FormikProvider as Ge } from "formik";
|
|
7
|
-
import ui, { useMemo as C, memo as
|
|
7
|
+
import ui, { useMemo as C, memo as z, useCallback as E, useState as U, useEffect as be, useRef as fi, forwardRef as ye, useReducer as mi } from "react";
|
|
8
8
|
import { DragDropContext as ht, Droppable as Ke, Draggable as Ye } from "@hello-pangea/dnd";
|
|
9
|
-
import { slugify as hi, useAppSelector as
|
|
9
|
+
import { slugify as hi, useAppSelector as $, selectFormRevision as pt, useSDK as gt, selectSubmissionAttachments as pi, selectFilteredUserForms as gi, selectUserFormMapping as bi, selectOrganization as bt, selectUser as Qe, selectNumberOfUserForms as yi, selectCurrentUser as yt, classNames as vt, isToday as vi, getLocalDateString as wi, selectLatestFormRevision as xi, useFileSrc as Ii, selectSubmissionsForForm as Ci } from "@overmap-ai/core";
|
|
10
10
|
import ae from "lodash.get";
|
|
11
11
|
import Xe from "lodash.set";
|
|
12
|
+
import Fi from "react-draggable";
|
|
12
13
|
class wt {
|
|
13
14
|
constructor(i) {
|
|
14
15
|
m(this, "type");
|
|
@@ -33,7 +34,7 @@ class wt {
|
|
|
33
34
|
};
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
|
-
class
|
|
37
|
+
class M extends wt {
|
|
37
38
|
constructor(e) {
|
|
38
39
|
const { label: t, required: n, fieldValidators: o = [], formValidators: l = [], ...a } = e;
|
|
39
40
|
super(a);
|
|
@@ -89,23 +90,23 @@ class $ extends wt {
|
|
|
89
90
|
return [...this.formValidators];
|
|
90
91
|
}
|
|
91
92
|
}
|
|
92
|
-
m(
|
|
93
|
-
const
|
|
94
|
-
description:
|
|
93
|
+
m(M, "fieldTypeName"), m(M, "fieldTypeDescription");
|
|
94
|
+
const Ti = "_description_17zed_1", Ve = {
|
|
95
|
+
description: Ti
|
|
95
96
|
}, q = (s) => {
|
|
96
97
|
const { label: i, children: e, severity: t, inputId: n, labelId: o, flexProps: l } = s;
|
|
97
|
-
return /* @__PURE__ */ r(v, { direction: "column", gap: "1", asChild: !0, ...l, children: /* @__PURE__ */
|
|
98
|
+
return /* @__PURE__ */ r(v, { direction: "column", gap: "1", asChild: !0, ...l, children: /* @__PURE__ */ b("label", { htmlFor: n, children: [
|
|
98
99
|
/* @__PURE__ */ r(k, { severity: t, id: o, children: i }),
|
|
99
100
|
e
|
|
100
101
|
] }) });
|
|
101
102
|
}, W = (s) => {
|
|
102
103
|
const { helpText: i, children: e, severity: t } = s;
|
|
103
|
-
return /* @__PURE__ */
|
|
104
|
+
return /* @__PURE__ */ b(v, { direction: "column", gap: "1", children: [
|
|
104
105
|
e,
|
|
105
106
|
/* @__PURE__ */ r(v, { direction: "column", children: /* @__PURE__ */ r(k, { size: "1", severity: t, className: Ve.description, children: i }) })
|
|
106
107
|
] });
|
|
107
108
|
}, j = (s) => {
|
|
108
|
-
const { id: i, field: e, formId: t, ...n } = s, [o, l, a] = He(e.getId()), { touched: c } = l, u = l.error ?? e.description, d = l.error ? "danger" : void 0, f = i ?? `${t}-${e.getId()}-input`,
|
|
109
|
+
const { id: i, field: e, formId: t, ...n } = s, [o, l, a] = He(e.getId()), { touched: c } = l, u = l.error ?? e.description, d = l.error ? "danger" : void 0, f = i ?? `${t}-${e.getId()}-input`, p = `${f}-label`, h = e.required ? `${e.label} *` : e.label, y = C(() => ({
|
|
109
110
|
...o,
|
|
110
111
|
onChange: (I) => {
|
|
111
112
|
const w = e.getValueFromChangeEvent(I);
|
|
@@ -120,16 +121,16 @@ const Fi = "_description_17zed_1", Ve = {
|
|
|
120
121
|
helpText: u,
|
|
121
122
|
severity: d,
|
|
122
123
|
inputId: f,
|
|
123
|
-
labelId:
|
|
124
|
-
label:
|
|
125
|
-
fieldProps:
|
|
124
|
+
labelId: p,
|
|
125
|
+
label: h,
|
|
126
|
+
fieldProps: y,
|
|
126
127
|
helpers: a,
|
|
127
128
|
field: e
|
|
128
129
|
},
|
|
129
|
-
{ ...n, "aria-labelledby":
|
|
130
|
+
{ ...n, "aria-labelledby": p }
|
|
130
131
|
];
|
|
131
|
-
},
|
|
132
|
-
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: l, fieldProps: a }, c] = j(i), u = de(n), d =
|
|
132
|
+
}, Si = [!0, "true"], zi = z(function(i) {
|
|
133
|
+
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: l, fieldProps: a }, c] = j(i), u = de(n), d = Si.includes(a.value);
|
|
133
134
|
return /* @__PURE__ */ r(W, { helpText: o, severity: n, children: /* @__PURE__ */ r(
|
|
134
135
|
q,
|
|
135
136
|
{
|
|
@@ -139,7 +140,7 @@ const Fi = "_description_17zed_1", Ve = {
|
|
|
139
140
|
label: l,
|
|
140
141
|
flexProps: { direction: "row-reverse", justify: "end", align: "center", gap: "2" },
|
|
141
142
|
children: /* @__PURE__ */ r(
|
|
142
|
-
|
|
143
|
+
$t,
|
|
143
144
|
{
|
|
144
145
|
...c,
|
|
145
146
|
...a,
|
|
@@ -154,7 +155,7 @@ const Fi = "_description_17zed_1", Ve = {
|
|
|
154
155
|
)
|
|
155
156
|
}
|
|
156
157
|
) });
|
|
157
|
-
}), X = class X extends
|
|
158
|
+
}), X = class X extends M {
|
|
158
159
|
constructor(e) {
|
|
159
160
|
super({ ...e, type: "boolean" });
|
|
160
161
|
m(this, "onlyValidateAfterTouched", !1);
|
|
@@ -175,12 +176,12 @@ const Fi = "_description_17zed_1", Ve = {
|
|
|
175
176
|
return new X(e);
|
|
176
177
|
}
|
|
177
178
|
getInput(e) {
|
|
178
|
-
return /* @__PURE__ */ r(
|
|
179
|
+
return /* @__PURE__ */ r(zi, { ...e, field: this });
|
|
179
180
|
}
|
|
180
181
|
};
|
|
181
|
-
m(X, "fieldTypeName", "Checkbox"), m(X, "fieldTypeDescription", "Perfect for both optional and required yes/no questions."), m(X, "Icon",
|
|
182
|
+
m(X, "fieldTypeName", "Checkbox"), m(X, "fieldTypeDescription", "Perfect for both optional and required yes/no questions."), m(X, "Icon", Mt);
|
|
182
183
|
let ce = X;
|
|
183
|
-
const
|
|
184
|
+
const Ei = z(function(i) {
|
|
184
185
|
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: l, fieldProps: a, field: c }, u] = j(i), d = de(n);
|
|
185
186
|
return /* @__PURE__ */ r(W, { helpText: o, severity: n, children: /* @__PURE__ */ r(q, { severity: n, inputId: e, labelId: t, label: l, children: /* @__PURE__ */ r(
|
|
186
187
|
se.Input,
|
|
@@ -195,7 +196,7 @@ const zi = S(function(i) {
|
|
|
195
196
|
color: d
|
|
196
197
|
}
|
|
197
198
|
) }) });
|
|
198
|
-
}), R = class R extends
|
|
199
|
+
}), R = class R extends M {
|
|
199
200
|
constructor(e) {
|
|
200
201
|
const {
|
|
201
202
|
minimum: t = Number.MIN_SAFE_INTEGER,
|
|
@@ -266,15 +267,15 @@ const zi = S(function(i) {
|
|
|
266
267
|
return new R(e);
|
|
267
268
|
}
|
|
268
269
|
getInput(e) {
|
|
269
|
-
return /* @__PURE__ */ r(
|
|
270
|
+
return /* @__PURE__ */ r(Ei, { field: this, ...e });
|
|
270
271
|
}
|
|
271
272
|
};
|
|
272
273
|
m(R, "fieldTypeName", "Number"), m(R, "fieldTypeDescription", "Allows specifying a number within a given range."), m(R, "Icon", Ot), m(R, "_validateMin", (e, t) => typeof t.maximum == "number" && typeof e == "number" && t.maximum < e ? "Minimum cannot be greater than minimum." : null), m(R, "_validateMax", (e, t) => typeof t.minimum == "number" && typeof e == "number" && t.minimum > e ? "Maximum cannot be less than minimum." : null);
|
|
273
274
|
let G = R;
|
|
274
|
-
const
|
|
275
|
+
const Ai = z(function(i) {
|
|
275
276
|
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: l, fieldProps: a }, c] = j(i), u = de(n), d = a.value ? a.value.split("T")[0] : "";
|
|
276
277
|
return /* @__PURE__ */ r(W, { helpText: o, severity: n, children: /* @__PURE__ */ r(q, { severity: n, inputId: e, labelId: t, label: l, children: /* @__PURE__ */ r(se.Input, { ...c, ...a, type: "date", id: e, color: u, value: d }) }) });
|
|
277
|
-
}), J = class J extends
|
|
278
|
+
}), J = class J extends M {
|
|
278
279
|
constructor(e) {
|
|
279
280
|
super({ ...e, type: "date" });
|
|
280
281
|
m(this, "onlyValidateAfterTouched", !1);
|
|
@@ -291,12 +292,12 @@ const Ei = S(function(i) {
|
|
|
291
292
|
return new J(e);
|
|
292
293
|
}
|
|
293
294
|
getInput(e) {
|
|
294
|
-
return /* @__PURE__ */ r(
|
|
295
|
+
return /* @__PURE__ */ r(Ai, { field: this, ...e });
|
|
295
296
|
}
|
|
296
297
|
};
|
|
297
298
|
m(J, "fieldTypeName", "Date"), m(J, "fieldTypeDescription", "Allows specifying a date."), m(J, "Icon", Rt);
|
|
298
299
|
let Re = J;
|
|
299
|
-
class we extends
|
|
300
|
+
class we extends M {
|
|
300
301
|
constructor(e) {
|
|
301
302
|
const { minLength: t, maxLength: n = 5e3, ...o } = e;
|
|
302
303
|
super(o);
|
|
@@ -365,7 +366,7 @@ m(we, "_validateMax", (e, t) => {
|
|
|
365
366
|
const { minimum_length: n } = t;
|
|
366
367
|
return typeof n != "number" ? null : n > e ? "Maximum cannot be less than minimum." : null;
|
|
367
368
|
});
|
|
368
|
-
const
|
|
369
|
+
const Di = z(function(i) {
|
|
369
370
|
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: l, fieldProps: a, field: c }, u] = j(i), d = de(n);
|
|
370
371
|
return /* @__PURE__ */ r(W, { helpText: o, severity: n, children: /* @__PURE__ */ r(q, { severity: n, inputId: e, labelId: t, label: l, children: /* @__PURE__ */ r(se.Input, { ...u, ...a, type: c.inputType, id: e, color: d }) }) });
|
|
371
372
|
}), Z = class Z extends we {
|
|
@@ -385,12 +386,12 @@ const Ai = S(function(i) {
|
|
|
385
386
|
return new Z({ ...l, maxLength: t, minLength: n, inputType: o });
|
|
386
387
|
}
|
|
387
388
|
getInput(e) {
|
|
388
|
-
return /* @__PURE__ */ r(
|
|
389
|
+
return /* @__PURE__ */ r(Di, { field: this, ...e });
|
|
389
390
|
}
|
|
390
391
|
};
|
|
391
392
|
m(Z, "fieldTypeName", "Short Text"), m(Z, "fieldTypeDescription", "Short text fields can hold up to 500 characters on a single line."), m(Z, "Icon", Nt);
|
|
392
393
|
let he = Z;
|
|
393
|
-
const
|
|
394
|
+
const Pi = z(function(i) {
|
|
394
395
|
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: l, fieldProps: a }, c] = j(i);
|
|
395
396
|
return /* @__PURE__ */ r(W, { helpText: o, severity: n, children: /* @__PURE__ */ r(q, { severity: n, inputId: e, labelId: t, label: l, children: /* @__PURE__ */ r(Bt, { ...c, ...a, resize: "vertical", id: e, severity: n }) }) });
|
|
396
397
|
}), ee = class ee extends we {
|
|
@@ -408,27 +409,27 @@ const Di = S(function(i) {
|
|
|
408
409
|
return new ee({ ...n, maxLength: e, minLength: t });
|
|
409
410
|
}
|
|
410
411
|
getInput(i) {
|
|
411
|
-
return /* @__PURE__ */ r(
|
|
412
|
+
return /* @__PURE__ */ r(Pi, { field: this, ...i });
|
|
412
413
|
}
|
|
413
414
|
};
|
|
414
415
|
m(ee, "fieldTypeName", "Paragraph"), m(ee, "fieldTypeDescription", "Paragraph fields can hold up to 5000 characters and can have multiple lines."), m(ee, "Icon", qt);
|
|
415
416
|
let pe = ee;
|
|
416
|
-
const Li =
|
|
417
|
-
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: l, fieldProps: a, field: c }, u] = j(i), { onChange: d, onBlur: f } = a,
|
|
418
|
-
() => c.options.map((
|
|
417
|
+
const Li = z(function(i) {
|
|
418
|
+
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: l, fieldProps: a, field: c }, u] = j(i), { onChange: d, onBlur: f } = a, p = C(
|
|
419
|
+
() => c.options.map((y) => ({ value: y.value, itemContent: y.label })),
|
|
419
420
|
[c.options]
|
|
420
|
-
),
|
|
421
|
-
(
|
|
422
|
-
d(
|
|
421
|
+
), h = E(
|
|
422
|
+
(y) => {
|
|
423
|
+
d(y), f(y);
|
|
423
424
|
},
|
|
424
425
|
[d, f]
|
|
425
426
|
);
|
|
426
427
|
return /* @__PURE__ */ r(W, { helpText: o, severity: n, children: /* @__PURE__ */ r(q, { severity: n, inputId: e, labelId: t, label: l, children: /* @__PURE__ */ r(
|
|
427
428
|
ut,
|
|
428
429
|
{
|
|
429
|
-
items:
|
|
430
|
+
items: p,
|
|
430
431
|
...a,
|
|
431
|
-
onValueChange:
|
|
432
|
+
onValueChange: h,
|
|
432
433
|
placeholder: "Select one...",
|
|
433
434
|
id: e,
|
|
434
435
|
severity: n,
|
|
@@ -442,7 +443,7 @@ const Li = S(function(i) {
|
|
|
442
443
|
label: null,
|
|
443
444
|
condition: null,
|
|
444
445
|
conditional: !1
|
|
445
|
-
}),
|
|
446
|
+
}), Vi = (s) => {
|
|
446
447
|
if (!s)
|
|
447
448
|
return;
|
|
448
449
|
const i = s.fields;
|
|
@@ -458,7 +459,7 @@ function Ne(s, i, e) {
|
|
|
458
459
|
throw new Error("Could not find field to reorder.");
|
|
459
460
|
return t.splice(e, 0, n), t;
|
|
460
461
|
}
|
|
461
|
-
function
|
|
462
|
+
function ki(s, i, e) {
|
|
462
463
|
const t = Array.from(s);
|
|
463
464
|
return t[i] = e, t;
|
|
464
465
|
}
|
|
@@ -470,7 +471,7 @@ function Ie(s, i) {
|
|
|
470
471
|
const e = Array.from(s);
|
|
471
472
|
return e.splice(i, 1), e;
|
|
472
473
|
}
|
|
473
|
-
const
|
|
474
|
+
const _i = (s, i) => {
|
|
474
475
|
if (typeof s == "string" && s.length > 0)
|
|
475
476
|
return s;
|
|
476
477
|
const e = /* @__PURE__ */ new Date();
|
|
@@ -486,45 +487,45 @@ const ki = (s, i) => {
|
|
|
486
487
|
} else if (e.identifier === i)
|
|
487
488
|
return e;
|
|
488
489
|
return null;
|
|
489
|
-
}, Be = (s, i) => s.filter((e, t) => t < i).flatMap((e) => e.fields),
|
|
490
|
-
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: l, fieldProps: a }, c] = j(i), u = de(n), d = C(() => Array.isArray(a.value) ? a.value : [], [a.value]), { onChange: f, onBlur:
|
|
491
|
-
(
|
|
492
|
-
f(
|
|
490
|
+
}, Be = (s, i) => s.filter((e, t) => t < i).flatMap((e) => e.fields), $i = z(function(i) {
|
|
491
|
+
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: l, fieldProps: a }, c] = j(i), u = de(n), d = C(() => Array.isArray(a.value) ? a.value : [], [a.value]), { onChange: f, onBlur: p } = a, h = `${e}-droppable`, { disabled: y } = c, [x, F] = U(""), [I, w] = U(""), L = I || o, D = I ? "red" : u, T = E(
|
|
492
|
+
(g) => {
|
|
493
|
+
f(g), p(g);
|
|
493
494
|
},
|
|
494
|
-
[f,
|
|
495
|
+
[f, p]
|
|
495
496
|
), V = E(
|
|
496
|
-
(
|
|
497
|
-
d.findIndex((A) => A.value ===
|
|
497
|
+
(g) => {
|
|
498
|
+
d.findIndex((A) => A.value === g.target.value.trim()) >= 0 ? w("All options must be unique") : g.target.value ? w("") : w("Option cannot be empty"), F(g.target.value);
|
|
498
499
|
},
|
|
499
|
-
[
|
|
500
|
+
[F, d]
|
|
500
501
|
), N = E(() => {
|
|
501
502
|
if (I)
|
|
502
503
|
return;
|
|
503
504
|
if (!x.trim())
|
|
504
505
|
return w("Option cannot be empty");
|
|
505
|
-
const
|
|
506
|
-
|
|
507
|
-
}, [x, I,
|
|
508
|
-
(
|
|
509
|
-
|
|
506
|
+
const g = x.trim();
|
|
507
|
+
T([...d, { value: g, label: g }]), F("");
|
|
508
|
+
}, [x, I, T, d]), _ = E(
|
|
509
|
+
(g) => {
|
|
510
|
+
g.key === "Enter" && (g.preventDefault(), N());
|
|
510
511
|
},
|
|
511
512
|
[N]
|
|
512
513
|
), O = E(
|
|
513
|
-
(
|
|
514
|
-
|
|
514
|
+
(g) => {
|
|
515
|
+
T(Ie(d, g));
|
|
515
516
|
},
|
|
516
|
-
[d,
|
|
517
|
-
),
|
|
518
|
-
(
|
|
519
|
-
if (!
|
|
517
|
+
[d, T]
|
|
518
|
+
), S = E(
|
|
519
|
+
(g) => {
|
|
520
|
+
if (!g.destination)
|
|
520
521
|
return;
|
|
521
|
-
const A =
|
|
522
|
-
|
|
522
|
+
const A = g.source.index, P = g.destination.index;
|
|
523
|
+
T(Ne(d, A, P));
|
|
523
524
|
},
|
|
524
|
-
[
|
|
525
|
+
[T, d]
|
|
525
526
|
);
|
|
526
|
-
return /* @__PURE__ */ r(ht, { onDragEnd:
|
|
527
|
-
/* @__PURE__ */ r(W, { helpText: L, severity: n, children: /* @__PURE__ */ r(q, { severity: n, inputId: e, labelId: t, label: l, children: (!
|
|
527
|
+
return /* @__PURE__ */ r(ht, { onDragEnd: S, children: /* @__PURE__ */ b(v, { direction: "column", gap: "2", children: [
|
|
528
|
+
/* @__PURE__ */ r(W, { helpText: L, severity: n, children: /* @__PURE__ */ r(q, { severity: n, inputId: e, labelId: t, label: l, children: (!y || d.length === 0) && /* @__PURE__ */ b(v, { gap: "2", children: [
|
|
528
529
|
/* @__PURE__ */ r(me, { grow: "1", children: /* @__PURE__ */ r(
|
|
529
530
|
se.Input,
|
|
530
531
|
{
|
|
@@ -535,7 +536,7 @@ const ki = (s, i) => {
|
|
|
535
536
|
onChange: V,
|
|
536
537
|
onKeyDown: _,
|
|
537
538
|
id: e,
|
|
538
|
-
color:
|
|
539
|
+
color: D,
|
|
539
540
|
onBlur: void 0
|
|
540
541
|
}
|
|
541
542
|
) }),
|
|
@@ -544,19 +545,19 @@ const ki = (s, i) => {
|
|
|
544
545
|
{
|
|
545
546
|
type: "button",
|
|
546
547
|
"aria-label": "Add option",
|
|
547
|
-
disabled: !!I ||
|
|
548
|
+
disabled: !!I || y,
|
|
548
549
|
onClick: N,
|
|
549
550
|
children: /* @__PURE__ */ r(De, {})
|
|
550
551
|
}
|
|
551
552
|
)
|
|
552
553
|
] }) }) }),
|
|
553
|
-
/* @__PURE__ */ r(Ke, { droppableId:
|
|
554
|
-
d.map((A,
|
|
554
|
+
/* @__PURE__ */ r(Ke, { droppableId: h, children: (g) => /* @__PURE__ */ b(v, { ...g.droppableProps, ref: g.innerRef, direction: "column", children: [
|
|
555
|
+
d.map((A, P) => /* @__PURE__ */ r(
|
|
555
556
|
Ye,
|
|
556
557
|
{
|
|
557
558
|
draggableId: `${A.value}-draggable`,
|
|
558
|
-
index:
|
|
559
|
-
isDragDisabled:
|
|
559
|
+
index: P,
|
|
560
|
+
isDragDisabled: y,
|
|
560
561
|
children: ({ draggableProps: B, dragHandleProps: fe, innerRef: Y }) => /* @__PURE__ */ r(
|
|
561
562
|
v,
|
|
562
563
|
{
|
|
@@ -568,7 +569,7 @@ const ki = (s, i) => {
|
|
|
568
569
|
justify: "between",
|
|
569
570
|
mb: "1",
|
|
570
571
|
asChild: !0,
|
|
571
|
-
children: /* @__PURE__ */
|
|
572
|
+
children: /* @__PURE__ */ b(Oe, { color: "gray", size: "2", children: [
|
|
572
573
|
/* @__PURE__ */ r("span", { children: A.label }),
|
|
573
574
|
/* @__PURE__ */ r(
|
|
574
575
|
le,
|
|
@@ -578,8 +579,8 @@ const ki = (s, i) => {
|
|
|
578
579
|
type: "button",
|
|
579
580
|
"aria-label": "Delete option",
|
|
580
581
|
severity: "info",
|
|
581
|
-
disabled:
|
|
582
|
-
onClick: () => O(
|
|
582
|
+
disabled: y,
|
|
583
|
+
onClick: () => O(P),
|
|
583
584
|
children: /* @__PURE__ */ r(ft, {})
|
|
584
585
|
}
|
|
585
586
|
)
|
|
@@ -589,10 +590,10 @@ const ki = (s, i) => {
|
|
|
589
590
|
},
|
|
590
591
|
A.value
|
|
591
592
|
)),
|
|
592
|
-
|
|
593
|
+
g.placeholder
|
|
593
594
|
] }) })
|
|
594
595
|
] }) });
|
|
595
|
-
}), te = class te extends
|
|
596
|
+
}), te = class te extends M {
|
|
596
597
|
constructor(e) {
|
|
597
598
|
const { minimum_length: t, maximum_length: n, ...o } = e;
|
|
598
599
|
super({ ...o, type: "multi-string" });
|
|
@@ -607,7 +608,7 @@ const ki = (s, i) => {
|
|
|
607
608
|
throw new Error("Expected an array.");
|
|
608
609
|
}
|
|
609
610
|
getInput(e) {
|
|
610
|
-
return /* @__PURE__ */ r(
|
|
611
|
+
return /* @__PURE__ */ r($i, { field: this, ...e });
|
|
611
612
|
}
|
|
612
613
|
serialize() {
|
|
613
614
|
return { ...super._serialize(), minimum_length: this.minLength, maximum_length: this.maxLength };
|
|
@@ -633,7 +634,7 @@ const ki = (s, i) => {
|
|
|
633
634
|
};
|
|
634
635
|
m(te, "fieldTypeName", "Multi-string"), m(te, "fieldTypeDescription", "Allows the user to provide multiple unique strings."), m(te, "Icon", Wt);
|
|
635
636
|
let Ce = te;
|
|
636
|
-
class Ct extends
|
|
637
|
+
class Ct extends M {
|
|
637
638
|
constructor(e) {
|
|
638
639
|
super(e);
|
|
639
640
|
m(this, "options");
|
|
@@ -684,18 +685,18 @@ const ie = class ie extends Ct {
|
|
|
684
685
|
};
|
|
685
686
|
m(ie, "fieldTypeName", "Dropdown"), m(ie, "fieldTypeDescription", "Allows the user to select a single option from a list of options."), m(ie, "Icon", jt);
|
|
686
687
|
let Fe = ie;
|
|
687
|
-
const Mi = (s) => s ? Array.isArray(s) ? s : [s] : [],
|
|
688
|
-
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: l, fieldProps: a, field: c }, u] = j(i), { onChange: d, onBlur: f } = a,
|
|
689
|
-
(
|
|
690
|
-
d(
|
|
688
|
+
const Mi = (s) => s ? Array.isArray(s) ? s : [s] : [], Oi = z(function(i) {
|
|
689
|
+
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: l, fieldProps: a, field: c }, u] = j(i), { onChange: d, onBlur: f } = a, p = C(() => Mi(a.value), [a.value]), h = E(
|
|
690
|
+
(y) => {
|
|
691
|
+
d(y), f(y);
|
|
691
692
|
},
|
|
692
693
|
[d, f]
|
|
693
694
|
);
|
|
694
695
|
return /* @__PURE__ */ r(W, { helpText: o, severity: n, children: /* @__PURE__ */ r(q, { severity: n, inputId: e, labelId: t, label: l, children: /* @__PURE__ */ r(
|
|
695
696
|
Ht,
|
|
696
697
|
{
|
|
697
|
-
value:
|
|
698
|
-
onValueChange:
|
|
698
|
+
value: p,
|
|
699
|
+
onValueChange: h,
|
|
699
700
|
options: c.options,
|
|
700
701
|
name: a.name,
|
|
701
702
|
placeholder: "Select one or more...",
|
|
@@ -725,19 +726,19 @@ const Mi = (s) => s ? Array.isArray(s) ? s : [s] : [], $i = S(function(i) {
|
|
|
725
726
|
return new ne(i);
|
|
726
727
|
}
|
|
727
728
|
getInput(i) {
|
|
728
|
-
return /* @__PURE__ */ r(
|
|
729
|
+
return /* @__PURE__ */ r(Oi, { field: this, ...i });
|
|
729
730
|
}
|
|
730
731
|
};
|
|
731
732
|
m(ne, "fieldTypeName", "Multi-select"), m(ne, "fieldTypeDescription", "Allows the user to select a multiple options from a list of options."), m(ne, "Icon", Ut);
|
|
732
733
|
let Te = ne;
|
|
733
|
-
const
|
|
734
|
+
const Ri = z(function({ field: i, ...e }) {
|
|
734
735
|
const [{ value: t }] = He(i.options.clonedFieldIdentifier), n = C(() => {
|
|
735
736
|
const o = i.options.getFieldToClone(t);
|
|
736
737
|
return o ? ke(o) : null;
|
|
737
738
|
}, [i.options, t]);
|
|
738
739
|
return ze(n, e);
|
|
739
740
|
});
|
|
740
|
-
class Se extends
|
|
741
|
+
class Se extends M {
|
|
741
742
|
constructor(e, t) {
|
|
742
743
|
super({ ...e, type: "custom" });
|
|
743
744
|
m(this, "Component");
|
|
@@ -754,26 +755,26 @@ class Se extends $ {
|
|
|
754
755
|
}
|
|
755
756
|
}
|
|
756
757
|
m(Se, "fieldTypeName", "Custom"), m(Se, "fieldTypeDescription", "Allows re-rendering of field already in the form");
|
|
757
|
-
class
|
|
758
|
+
class Ni extends Se {
|
|
758
759
|
constructor(i) {
|
|
759
|
-
super(i,
|
|
760
|
+
super(i, Ri);
|
|
760
761
|
}
|
|
761
762
|
}
|
|
762
|
-
const
|
|
763
|
+
const Bi = z(function(i) {
|
|
763
764
|
const { field: e, ...t } = i, { label: n, description: o, fields: l, condition: a } = e, { values: c, setFieldValue: u } = ue(), d = a != null && a.identifier ? ae(c, a.identifier) : void 0, f = C(() => St(a, d), [a, d]);
|
|
764
765
|
be(() => {
|
|
765
766
|
if (!f)
|
|
766
|
-
for (const
|
|
767
|
-
u(
|
|
767
|
+
for (const h of l)
|
|
768
|
+
u(h.getId(), "").then();
|
|
768
769
|
}, [f, l, u]);
|
|
769
|
-
const
|
|
770
|
-
return f ? n ? /* @__PURE__ */ r(ge, { children: /* @__PURE__ */
|
|
771
|
-
/* @__PURE__ */
|
|
772
|
-
/* @__PURE__ */ r(
|
|
770
|
+
const p = zt(l, t);
|
|
771
|
+
return f ? n ? /* @__PURE__ */ r(ge, { children: /* @__PURE__ */ b(v, { direction: "column", gap: "3", children: [
|
|
772
|
+
/* @__PURE__ */ b(v, { direction: "column", children: [
|
|
773
|
+
/* @__PURE__ */ r(Pe, { as: "h3", size: "3", children: n }),
|
|
773
774
|
/* @__PURE__ */ r(k, { className: Ve.description, children: o })
|
|
774
775
|
] }),
|
|
775
|
-
|
|
776
|
-
] }) }) :
|
|
776
|
+
p
|
|
777
|
+
] }) }) : p : null;
|
|
777
778
|
}), re = class re extends wt {
|
|
778
779
|
constructor(e) {
|
|
779
780
|
const { label: t = null, fields: n, condition: o = null, conditional: l, ...a } = e;
|
|
@@ -821,7 +822,7 @@ const Ni = S(function(i) {
|
|
|
821
822
|
// Declare a custom field that will be used to input a value for the condition. The value of the
|
|
822
823
|
// conditional field selected in the previous step must be equal to the value the user inputs into
|
|
823
824
|
// this field for the section to be rendered.
|
|
824
|
-
new
|
|
825
|
+
new Ni({
|
|
825
826
|
label: "Value",
|
|
826
827
|
identifier: "condition.value",
|
|
827
828
|
required: !0,
|
|
@@ -872,34 +873,34 @@ const Ni = S(function(i) {
|
|
|
872
873
|
return t;
|
|
873
874
|
}
|
|
874
875
|
getInput(e) {
|
|
875
|
-
return /* @__PURE__ */ r(
|
|
876
|
+
return /* @__PURE__ */ r(Bi, { field: this, ...e });
|
|
876
877
|
}
|
|
877
878
|
};
|
|
878
879
|
m(re, "fieldTypeName", "Section"), m(re, "fieldTypeDescription", "Sections can be useful for grouping fields together. They can also be conditionally shown or hidden.");
|
|
879
880
|
let K = re;
|
|
880
|
-
const
|
|
881
|
-
previewImage:
|
|
881
|
+
const qi = "_previewImage_1ig84_1", Wi = {
|
|
882
|
+
previewImage: qi
|
|
882
883
|
}, Je = (s) => {
|
|
883
884
|
const i = ["byte", "kilobyte", "megabyte"];
|
|
884
885
|
let e = s, t = 0;
|
|
885
886
|
for (; e > 1024 && t < i.length - 1; )
|
|
886
887
|
e /= 1024, t++;
|
|
887
888
|
return new Intl.NumberFormat([], { maximumFractionDigits: 2, style: "unit", unit: i[t] }).format(e);
|
|
888
|
-
},
|
|
889
|
-
var
|
|
890
|
-
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: l, fieldProps: a, field: c }, u] = j(i), { onChange: d } = a, f = de(n),
|
|
891
|
-
var
|
|
892
|
-
(
|
|
893
|
-
}, []),
|
|
894
|
-
(
|
|
895
|
-
const V = [...
|
|
896
|
-
V.splice(
|
|
889
|
+
}, ji = z(function(i) {
|
|
890
|
+
var D;
|
|
891
|
+
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: l, fieldProps: a, field: c }, u] = j(i), { onChange: d } = a, f = de(n), p = fi(null), { value: h } = a, y = C(() => o || (c.maxFileSize ? `Maximum file size: ${Je(c.maxFileSize)}` : null), [c.maxFileSize, o]), x = E(() => {
|
|
892
|
+
var T;
|
|
893
|
+
(T = p.current) == null || T.click();
|
|
894
|
+
}, []), F = E(
|
|
895
|
+
(T) => {
|
|
896
|
+
const V = [...h];
|
|
897
|
+
V.splice(T, 1), d({ target: { files: V } });
|
|
897
898
|
},
|
|
898
|
-
[
|
|
899
|
-
), I =
|
|
900
|
-
return /* @__PURE__ */
|
|
901
|
-
/* @__PURE__ */ r(W, { helpText:
|
|
902
|
-
/* @__PURE__ */ r(v, { direction: "row", gap: "2", children: /* @__PURE__ */ r(me, { width: "max-content", asChild: !0, children: /* @__PURE__ */
|
|
899
|
+
[h, d]
|
|
900
|
+
), I = h ? "Select new files" : "Select files", w = h ? "Select new file" : "Select a file", L = c.maxFiles > 1 ? I : w;
|
|
901
|
+
return /* @__PURE__ */ b(v, { direction: "column", gap: "2", children: [
|
|
902
|
+
/* @__PURE__ */ r(W, { helpText: y, severity: n, children: /* @__PURE__ */ b(q, { severity: n, inputId: e, labelId: t, label: l, children: [
|
|
903
|
+
/* @__PURE__ */ r(v, { direction: "row", gap: "2", children: /* @__PURE__ */ r(me, { width: "max-content", asChild: !0, children: /* @__PURE__ */ b(H, { ...u, onClick: x, children: [
|
|
903
904
|
/* @__PURE__ */ r(mt, {}),
|
|
904
905
|
" ",
|
|
905
906
|
L
|
|
@@ -909,9 +910,9 @@ const Bi = "_previewImage_1ig84_1", qi = {
|
|
|
909
910
|
{
|
|
910
911
|
...u,
|
|
911
912
|
type: "file",
|
|
912
|
-
ref:
|
|
913
|
+
ref: p,
|
|
913
914
|
id: e,
|
|
914
|
-
accept: (
|
|
915
|
+
accept: (D = c.extensions) == null ? void 0 : D.join(","),
|
|
915
916
|
multiple: c.maxFiles > 1,
|
|
916
917
|
color: f,
|
|
917
918
|
style: { display: "none" },
|
|
@@ -920,26 +921,26 @@ const Bi = "_previewImage_1ig84_1", qi = {
|
|
|
920
921
|
}
|
|
921
922
|
)
|
|
922
923
|
] }) }),
|
|
923
|
-
Array.isArray(
|
|
924
|
-
|
|
924
|
+
Array.isArray(h) && h.length > 0 && /* @__PURE__ */ r(v, { direction: "column", gap: "2", children: h.map((T, V) => /* @__PURE__ */ r(
|
|
925
|
+
Hi,
|
|
925
926
|
{
|
|
926
927
|
field: c,
|
|
927
|
-
file:
|
|
928
|
-
onRemove: () =>
|
|
928
|
+
file: T,
|
|
929
|
+
onRemove: () => F(V),
|
|
929
930
|
disabled: u.disabled
|
|
930
931
|
},
|
|
931
932
|
V
|
|
932
933
|
)) })
|
|
933
934
|
] });
|
|
934
|
-
}),
|
|
935
|
+
}), Hi = z(function({ file: i, field: e, onRemove: t, disabled: n }) {
|
|
935
936
|
const [o, l] = U(null), a = C(() => o && e.getError([o]), [e, o]), { url: c, name: u, size: d } = C(() => {
|
|
936
|
-
let f = null,
|
|
937
|
-
return o != null && o.type.startsWith("image/") && (f = URL.createObjectURL(o)), o ? (
|
|
937
|
+
let f = null, p, h;
|
|
938
|
+
return o != null && o.type.startsWith("image/") && (f = URL.createObjectURL(o)), o ? (p = o.name, h = Je(o.size)) : (p = "Downloading...", h = "..."), { url: f, name: p, size: h };
|
|
938
939
|
}, [o]);
|
|
939
940
|
return be(() => {
|
|
940
941
|
i instanceof Promise ? i.then(l) : l(i);
|
|
941
|
-
}, [i]), /* @__PURE__ */ r(ge, { children: /* @__PURE__ */
|
|
942
|
-
/* @__PURE__ */
|
|
942
|
+
}, [i]), /* @__PURE__ */ r(ge, { children: /* @__PURE__ */ b(v, { direction: { initial: "column", sm: "row" }, gap: "3", justify: "between", children: [
|
|
943
|
+
/* @__PURE__ */ b(v, { direction: "row", gap: "3", align: "center", grow: "1", shrink: "0", children: [
|
|
943
944
|
/* @__PURE__ */ r(
|
|
944
945
|
le,
|
|
945
946
|
{
|
|
@@ -951,15 +952,15 @@ const Bi = "_previewImage_1ig84_1", qi = {
|
|
|
951
952
|
children: /* @__PURE__ */ r(ft, {})
|
|
952
953
|
}
|
|
953
954
|
),
|
|
954
|
-
/* @__PURE__ */
|
|
955
|
+
/* @__PURE__ */ b(v, { direction: "column", gap: "1", children: [
|
|
955
956
|
/* @__PURE__ */ r(k, { children: u }),
|
|
956
957
|
/* @__PURE__ */ r(k, { size: "1", children: d }),
|
|
957
958
|
a && /* @__PURE__ */ r(k, { size: "1", severity: "danger", children: a })
|
|
958
959
|
] })
|
|
959
960
|
] }),
|
|
960
|
-
c && /* @__PURE__ */ r("img", { className:
|
|
961
|
+
c && /* @__PURE__ */ r("img", { className: Wi.previewImage, src: c, alt: u })
|
|
961
962
|
] }) });
|
|
962
|
-
}), rt = 50 * 1024 * 1024, oe = class oe extends
|
|
963
|
+
}), rt = 50 * 1024 * 1024, oe = class oe extends M {
|
|
963
964
|
constructor(e) {
|
|
964
965
|
const { extensions: t, maximum_files: n, maximum_size: o, ...l } = e;
|
|
965
966
|
super({ ...l, type: "upload" });
|
|
@@ -1048,7 +1049,7 @@ const Bi = "_previewImage_1ig84_1", qi = {
|
|
|
1048
1049
|
return new oe(e);
|
|
1049
1050
|
}
|
|
1050
1051
|
getInput(e) {
|
|
1051
|
-
return /* @__PURE__ */ r(
|
|
1052
|
+
return /* @__PURE__ */ r(ji, { field: this, ...e });
|
|
1052
1053
|
}
|
|
1053
1054
|
};
|
|
1054
1055
|
m(oe, "fieldTypeName", "Upload"), m(oe, "fieldTypeDescription", "Allows a file to be uploaded."), m(oe, "Icon", mt);
|
|
@@ -1109,60 +1110,61 @@ const ze = (s, i) => C(() => !i || !s ? null : s.getInput(i), [s, i]), zt = (s,
|
|
|
1109
1110
|
}
|
|
1110
1111
|
Object.assign(e, t.getErrors(i));
|
|
1111
1112
|
} else {
|
|
1112
|
-
if (!(t instanceof
|
|
1113
|
+
if (!(t instanceof M))
|
|
1113
1114
|
throw new Error("Invalid field type");
|
|
1114
1115
|
const n = t.getId(), o = t.getError(ae(i, n), i);
|
|
1115
1116
|
o && Xe(e, n, o);
|
|
1116
1117
|
}
|
|
1117
1118
|
if (Ee(e))
|
|
1118
1119
|
return e;
|
|
1119
|
-
},
|
|
1120
|
+
}, Ui = [null, void 0], et = (s, i) => s.reduce((e, t) => t instanceof K ? { ...e, ...et(t.fields, i) } : (Ui.includes(ae(e, t.getId())) && Xe(e, t.getId(), ""), e), i), Gi = () => {
|
|
1120
1121
|
throw new Error("onSubmit must be provided if form is not readonly.");
|
|
1121
|
-
}, tt =
|
|
1122
|
+
}, tt = z(
|
|
1122
1123
|
ye((s, i) => {
|
|
1123
1124
|
const {
|
|
1124
1125
|
schema: e,
|
|
1125
1126
|
values: t = {},
|
|
1126
|
-
onSubmit: n =
|
|
1127
|
+
onSubmit: n = Gi,
|
|
1127
1128
|
submitText: o = "Submit",
|
|
1128
1129
|
cancelText: l,
|
|
1129
1130
|
onCancel: a,
|
|
1130
1131
|
onDirty: c,
|
|
1132
|
+
onDirtyChange: u,
|
|
1131
1133
|
// if the title isn't provided, hide it by default
|
|
1132
|
-
hideTitle:
|
|
1133
|
-
hideDescription:
|
|
1134
|
-
className:
|
|
1135
|
-
} = s, { readonly: h } = e.meta,
|
|
1134
|
+
hideTitle: d = !e.title,
|
|
1135
|
+
hideDescription: f,
|
|
1136
|
+
className: p
|
|
1137
|
+
} = s, { readonly: h } = e.meta, y = C(() => crypto.randomUUID(), []), x = Ue({
|
|
1136
1138
|
initialValues: et(e.fields, t),
|
|
1137
1139
|
onSubmit: n,
|
|
1138
|
-
validate: (
|
|
1140
|
+
validate: (D) => Et(e, D),
|
|
1139
1141
|
// only validate the entire form on submit
|
|
1140
1142
|
validateOnBlur: !1,
|
|
1141
1143
|
validateOnChange: !1
|
|
1142
|
-
}), { dirty:
|
|
1143
|
-
() => typeof e.title == "string" ? /* @__PURE__ */ r(
|
|
1144
|
+
}), { dirty: F } = x, I = C(
|
|
1145
|
+
() => typeof e.title == "string" ? /* @__PURE__ */ r(Pe, { children: e.title }) : e.title,
|
|
1144
1146
|
[e.title]
|
|
1145
|
-
),
|
|
1147
|
+
), w = C(
|
|
1146
1148
|
() => typeof e.description == "string" ? /* @__PURE__ */ r(k, { className: Ve.description, children: e.description }) : e.description,
|
|
1147
1149
|
[e.description]
|
|
1148
|
-
),
|
|
1150
|
+
), L = zt(e.fields, { formId: y, disabled: h });
|
|
1149
1151
|
return be(() => {
|
|
1150
|
-
|
|
1151
|
-
}, [
|
|
1152
|
-
!
|
|
1153
|
-
|
|
1154
|
-
!
|
|
1152
|
+
F && c && c(), u && u(F);
|
|
1153
|
+
}, [F, c, u]), /* @__PURE__ */ r(Ge, { value: x, children: /* @__PURE__ */ r(v, { ref: i, direction: "column", gap: "2", className: p, asChild: !0, children: /* @__PURE__ */ b("form", { id: y, onSubmit: x.handleSubmit, children: [
|
|
1154
|
+
!d && /* @__PURE__ */ r(ge, { children: /* @__PURE__ */ b(v, { direction: "column", gap: "1", children: [
|
|
1155
|
+
I,
|
|
1156
|
+
!f && w
|
|
1155
1157
|
] }) }),
|
|
1156
|
-
|
|
1157
|
-
!h && /* @__PURE__ */
|
|
1158
|
+
L,
|
|
1159
|
+
!h && /* @__PURE__ */ b(v, { justify: "end", gap: "2", children: [
|
|
1158
1160
|
l && /* @__PURE__ */ r(H, { type: "button", variant: "soft", onClick: a, children: l }),
|
|
1159
|
-
/* @__PURE__ */ r(H, { type: "submit", disabled: !
|
|
1161
|
+
/* @__PURE__ */ r(H, { type: "submit", disabled: !x.isValid, children: o })
|
|
1160
1162
|
] })
|
|
1161
1163
|
] }) }) });
|
|
1162
1164
|
})
|
|
1163
|
-
),
|
|
1165
|
+
), En = z(
|
|
1164
1166
|
ye((s, i) => {
|
|
1165
|
-
const { submission: e, showFormDescription: t = !1, showFormTitle: n = !0 } = s, o =
|
|
1167
|
+
const { submission: e, showFormDescription: t = !1, showFormTitle: n = !0 } = s, o = $(pt(e.form_revision)), { sdk: l } = gt();
|
|
1166
1168
|
if (!o)
|
|
1167
1169
|
throw new Error(
|
|
1168
1170
|
`Could not find revision ${e.form_revision} for submission ${e.offline_id}.`
|
|
@@ -1170,12 +1172,12 @@ const ze = (s, i) => C(() => !i || !s ? null : s.getInput(i), [s, i]), zt = (s,
|
|
|
1170
1172
|
const a = C(() => Tt(o, { readonly: !0 }), [o]), c = C(() => {
|
|
1171
1173
|
const u = pi(e.offline_id)(l.store.getState()) ?? [], d = {};
|
|
1172
1174
|
for (const f of u) {
|
|
1173
|
-
const
|
|
1174
|
-
if (!
|
|
1175
|
+
const p = l.files.fetchFileFromUrl(f.file, f.file_sha1, f.file_name).then((y) => {
|
|
1176
|
+
if (!y.success)
|
|
1175
1177
|
throw new Error(`Failed to download attachment ${f.file_name}.`);
|
|
1176
|
-
return
|
|
1177
|
-
}),
|
|
1178
|
-
|
|
1178
|
+
return y.body;
|
|
1179
|
+
}), h = d[f.field_identifier];
|
|
1180
|
+
h ? h.push(p) : d[f.field_identifier] = [p];
|
|
1179
1181
|
}
|
|
1180
1182
|
return { ...e.values, ...d };
|
|
1181
1183
|
}, [l.files, l.store, e.offline_id, e.values]);
|
|
@@ -1190,38 +1192,38 @@ const ze = (s, i) => C(() => !i || !s ? null : s.getInput(i), [s, i]), zt = (s,
|
|
|
1190
1192
|
}
|
|
1191
1193
|
);
|
|
1192
1194
|
})
|
|
1193
|
-
),
|
|
1194
|
-
favoriteIcon:
|
|
1195
|
-
regularIcon:
|
|
1196
|
-
},
|
|
1195
|
+
), Ki = "_favoriteIcon_1bixi_1", Yi = "_regularIcon_1bixi_9", ot = {
|
|
1196
|
+
favoriteIcon: Ki,
|
|
1197
|
+
regularIcon: Yi
|
|
1198
|
+
}, $e = "organization:", Me = "user:", An = z(
|
|
1197
1199
|
ye((s, i) => {
|
|
1198
1200
|
const { maxResults: e = 20, ...t } = s, [n, o] = U(""), [l, a] = U(""), { sdk: c } = gt(), u = C(() => {
|
|
1199
1201
|
const w = { maxResults: e, searchTerm: n };
|
|
1200
|
-
return l && (l.startsWith(
|
|
1201
|
-
}, [n, e, l]), d =
|
|
1202
|
+
return l && (l.startsWith($e) ? w.owner_organization = parseInt(l.slice($e.length)) : l.startsWith(Me) && (w.owner_user = parseInt(l.slice(Me.length)))), w;
|
|
1203
|
+
}, [n, e, l]), d = $(gi(u)) ?? [], f = $(bi), p = E(
|
|
1202
1204
|
(w) => {
|
|
1203
1205
|
w.favorite ? c.userForms.unfavorite(w.offline_id).then() : c.userForms.favorite(w.offline_id).then();
|
|
1204
1206
|
},
|
|
1205
1207
|
[c]
|
|
1206
|
-
),
|
|
1208
|
+
), h = C(() => {
|
|
1207
1209
|
const w = c.store.getState(), L = {};
|
|
1208
|
-
for (const
|
|
1209
|
-
const
|
|
1210
|
-
|
|
1211
|
-
const V = Qe(
|
|
1212
|
-
V && (L[`${
|
|
1210
|
+
for (const D of Object.values(f)) {
|
|
1211
|
+
const T = bt(D.owner_organization || -1)(w);
|
|
1212
|
+
T && (L[`${$e}${T.id}`] = T.name);
|
|
1213
|
+
const V = Qe(D.owner_user || -1)(w);
|
|
1214
|
+
V && (L[`${Me}${V.id}`] = V.username);
|
|
1213
1215
|
}
|
|
1214
|
-
return Object.entries(L).map(([
|
|
1215
|
-
}, [f, c.store]),
|
|
1216
|
+
return Object.entries(L).map(([D, T]) => ({ itemContent: T, value: D }));
|
|
1217
|
+
}, [f, c.store]), y = E((w) => {
|
|
1216
1218
|
o(w.currentTarget.value);
|
|
1217
|
-
}, []),
|
|
1218
|
-
return /* @__PURE__ */
|
|
1219
|
-
/* @__PURE__ */
|
|
1220
|
-
/* @__PURE__ */ r(me, { grow: "1", asChild: !0, children: /* @__PURE__ */ r(se.Root, { size: "3", children: /* @__PURE__ */ r(se.Input, { placeholder: "Filter", value: n, onChange:
|
|
1219
|
+
}, []), F = ($(yi) || 0) - d.length, I = d.length == e && F > 0 ? `Only the first ${e} results are shown (${F} hidden)` : F > 0 && `${F} hidden forms`;
|
|
1220
|
+
return /* @__PURE__ */ b(v, { ref: i, direction: "column", gap: "2", children: [
|
|
1221
|
+
/* @__PURE__ */ b(v, { gap: "2", grow: "1", children: [
|
|
1222
|
+
/* @__PURE__ */ r(me, { grow: "1", asChild: !0, children: /* @__PURE__ */ r(se.Root, { size: "3", children: /* @__PURE__ */ r(se.Input, { placeholder: "Filter", value: n, onChange: y }) }) }),
|
|
1221
1223
|
/* @__PURE__ */ r(
|
|
1222
1224
|
ut,
|
|
1223
1225
|
{
|
|
1224
|
-
items:
|
|
1226
|
+
items: h,
|
|
1225
1227
|
value: l,
|
|
1226
1228
|
onValueChange: a,
|
|
1227
1229
|
placeholder: "Owner",
|
|
@@ -1229,27 +1231,27 @@ const ze = (s, i) => C(() => !i || !s ? null : s.getInput(i), [s, i]), zt = (s,
|
|
|
1229
1231
|
}
|
|
1230
1232
|
)
|
|
1231
1233
|
] }),
|
|
1232
|
-
d.length > 0 && /* @__PURE__ */ r(
|
|
1233
|
-
|
|
1234
|
+
d.length > 0 && /* @__PURE__ */ r(Le.Root, { children: d.map((w) => /* @__PURE__ */ r(
|
|
1235
|
+
Qi,
|
|
1234
1236
|
{
|
|
1235
1237
|
...t,
|
|
1236
1238
|
form: w,
|
|
1237
|
-
handleToggleFavorite: () =>
|
|
1239
|
+
handleToggleFavorite: () => p(w)
|
|
1238
1240
|
},
|
|
1239
1241
|
w.offline_id
|
|
1240
1242
|
)) }),
|
|
1241
1243
|
/* @__PURE__ */ r(me, { px: "3", children: /* @__PURE__ */ r(k, { size: "2", severity: "info", children: I }) })
|
|
1242
1244
|
] });
|
|
1243
1245
|
})
|
|
1244
|
-
),
|
|
1245
|
-
var
|
|
1246
|
-
const { form: i, onSelectForm: e, isFavoriteEditable: t, handleToggleFavorite: n } = s, o = (
|
|
1247
|
-
(
|
|
1248
|
-
|
|
1246
|
+
), Qi = (s) => {
|
|
1247
|
+
var p;
|
|
1248
|
+
const { form: i, onSelectForm: e, isFavoriteEditable: t, handleToggleFavorite: n } = s, o = (p = $(bt(i.owner_organization || -1))) == null ? void 0 : p.name, l = $(Qe(i.owner_user || -1)), a = $(yt).id, c = !!l && l.id === a, u = o ?? (c ? "You" : l == null ? void 0 : l.username) ?? "Unknown", d = E(
|
|
1249
|
+
(h) => {
|
|
1250
|
+
h.stopPropagation(), n();
|
|
1249
1251
|
},
|
|
1250
1252
|
[n]
|
|
1251
|
-
), f = /* @__PURE__ */ r(
|
|
1252
|
-
/* @__PURE__ */
|
|
1253
|
+
), f = /* @__PURE__ */ r(Le.Item, { onClick: () => e(i), asChild: !0, children: /* @__PURE__ */ b(v, { justify: "between", gap: "2", py: "2", px: "3", ...Gt, children: [
|
|
1254
|
+
/* @__PURE__ */ b(v, { grow: "1", align: "center", gap: "2", children: [
|
|
1253
1255
|
/* @__PURE__ */ r(
|
|
1254
1256
|
le,
|
|
1255
1257
|
{
|
|
@@ -1264,36 +1266,36 @@ const ze = (s, i) => C(() => !i || !s ? null : s.getInput(i), [s, i]), zt = (s,
|
|
|
1264
1266
|
/* @__PURE__ */ r(k, { noWrap: !0, children: i.latestRevision.title }),
|
|
1265
1267
|
i.latestRevision.description && /* @__PURE__ */ r(Qt, {})
|
|
1266
1268
|
] }),
|
|
1267
|
-
u && /* @__PURE__ */
|
|
1269
|
+
u && /* @__PURE__ */ b(v, { align: "center", gap: "2", children: [
|
|
1268
1270
|
/* @__PURE__ */ r(Xt, {}),
|
|
1269
1271
|
" ",
|
|
1270
1272
|
u
|
|
1271
1273
|
] })
|
|
1272
1274
|
] }) });
|
|
1273
1275
|
return i.latestRevision.description ? /* @__PURE__ */ r(Jt, { content: i.latestRevision.description, children: f }, i.offline_id) : f;
|
|
1274
|
-
},
|
|
1275
|
-
submissionsContainer:
|
|
1276
|
-
stopHorizontalOverflow:
|
|
1277
|
-
},
|
|
1276
|
+
}, Xi = "_submissionsContainer_9iirt_1", Ji = "_stopHorizontalOverflow_9iirt_6", At = {
|
|
1277
|
+
submissionsContainer: Xi,
|
|
1278
|
+
stopHorizontalOverflow: Ji
|
|
1279
|
+
}, Zi = z(function(i) {
|
|
1278
1280
|
var w;
|
|
1279
|
-
const { submission: e, onSubmissionClick: t, compact: n, labelType: o, rowDecorator: l } = i, a =
|
|
1281
|
+
const { submission: e, onSubmissionClick: t, compact: n, labelType: o, rowDecorator: l } = i, a = $(yt), c = $(Qe("created_by" in e ? e.created_by : a.id)), u = je(e), d = vi(u) ? u.toLocaleTimeString([], {
|
|
1280
1282
|
hour: "2-digit",
|
|
1281
1283
|
minute: "2-digit"
|
|
1282
|
-
}) : wi(u), f =
|
|
1284
|
+
}) : wi(u), f = $(pt(e.form_revision));
|
|
1283
1285
|
if (!f)
|
|
1284
1286
|
throw new Error(`Could not find revision ${e.form_revision} for submission ${e.offline_id}.`);
|
|
1285
|
-
const
|
|
1287
|
+
const p = (w = $(xi(f.form))) == null ? void 0 : w.revision, h = Ii({
|
|
1286
1288
|
file: (c == null ? void 0 : c.profile.file) ?? null,
|
|
1287
1289
|
fileSha1: (c == null ? void 0 : c.profile.file_sha1) ?? null
|
|
1288
|
-
}),
|
|
1290
|
+
}), y = (c == null ? void 0 : c.username.charAt(0).toUpperCase()) ?? "?", x = f.revision === p, F = ui.useCallback(() => {
|
|
1289
1291
|
t && t({ submission: e });
|
|
1290
|
-
}, [e, t]), I = /* @__PURE__ */ r(
|
|
1291
|
-
/* @__PURE__ */
|
|
1292
|
-
/* @__PURE__ */ r(Zt, { src:
|
|
1292
|
+
}, [e, t]), I = /* @__PURE__ */ r(Le.Item, { onClick: F, asChild: !0, children: /* @__PURE__ */ b(v, { grow: "1", width: "100%", p: "2", gap: "2", justify: "between", children: [
|
|
1293
|
+
/* @__PURE__ */ b(v, { gap: "2", align: "center", className: At.stopHorizontalOverflow, children: [
|
|
1294
|
+
/* @__PURE__ */ r(Zt, { src: h, size: "1", fallback: y }),
|
|
1293
1295
|
/* @__PURE__ */ r(k, { size: "2", noWrap: !0, children: o === "creator" ? (c || a).username : f.title })
|
|
1294
1296
|
] }),
|
|
1295
|
-
/* @__PURE__ */
|
|
1296
|
-
!n && (f.revision ? /* @__PURE__ */ r(Oe, { variant: "soft", severity: x ? "primary" : "info", children: n ? f.revision.toString() : `Revision #${f.revision}` }) : !!
|
|
1297
|
+
/* @__PURE__ */ b(v, { gap: "2", align: "center", children: [
|
|
1298
|
+
!n && (f.revision ? /* @__PURE__ */ r(Oe, { variant: "soft", severity: x ? "primary" : "info", children: n ? f.revision.toString() : `Revision #${f.revision}` }) : !!p && /* @__PURE__ */ r(Oe, { children: "Original" })),
|
|
1297
1299
|
/* @__PURE__ */ r(k, { size: "2", noWrap: !0, children: d })
|
|
1298
1300
|
] })
|
|
1299
1301
|
] }) });
|
|
@@ -1301,7 +1303,7 @@ const ze = (s, i) => C(() => !i || !s ? null : s.getInput(i), [s, i]), zt = (s,
|
|
|
1301
1303
|
}), je = (s) => {
|
|
1302
1304
|
const i = "created_at" in s ? s.created_at : s.submitted_at;
|
|
1303
1305
|
return new Date(i);
|
|
1304
|
-
},
|
|
1306
|
+
}, Dn = z(function(i) {
|
|
1305
1307
|
const {
|
|
1306
1308
|
formId: e,
|
|
1307
1309
|
submissions: t,
|
|
@@ -1313,36 +1315,36 @@ const ze = (s, i) => C(() => !i || !s ? null : s.getInput(i), [s, i]), zt = (s,
|
|
|
1313
1315
|
} = i;
|
|
1314
1316
|
if (!!e == !!t)
|
|
1315
1317
|
throw new Error("Either formId or submissions must be provided, but not both.");
|
|
1316
|
-
const u =
|
|
1318
|
+
const u = $(
|
|
1317
1319
|
t ? () => t : Ci(e)
|
|
1318
1320
|
), d = C(
|
|
1319
|
-
() => u == null ? void 0 : u.sort((f,
|
|
1321
|
+
() => u == null ? void 0 : u.sort((f, p) => je(p).getTime() - je(f).getTime()),
|
|
1320
1322
|
[u]
|
|
1321
1323
|
);
|
|
1322
1324
|
return /* @__PURE__ */ r(
|
|
1323
|
-
|
|
1325
|
+
Le.Root,
|
|
1324
1326
|
{
|
|
1325
1327
|
className: vt(At.submissionsContainer, o),
|
|
1326
1328
|
size: "small",
|
|
1327
1329
|
variant: a,
|
|
1328
|
-
before: !n && /* @__PURE__ */
|
|
1330
|
+
before: !n && /* @__PURE__ */ b(k, { severity: "info", children: [
|
|
1329
1331
|
"There are ",
|
|
1330
1332
|
((u == null ? void 0 : u.length) || 0).toString(),
|
|
1331
1333
|
" submissions of this form."
|
|
1332
1334
|
] }),
|
|
1333
1335
|
after: l,
|
|
1334
|
-
children: d == null ? void 0 : d.map((f,
|
|
1335
|
-
|
|
1336
|
+
children: d == null ? void 0 : d.map((f, p) => /* @__PURE__ */ r(
|
|
1337
|
+
Zi,
|
|
1336
1338
|
{
|
|
1337
1339
|
submission: f,
|
|
1338
1340
|
compact: n,
|
|
1339
1341
|
...c
|
|
1340
1342
|
},
|
|
1341
|
-
|
|
1343
|
+
p
|
|
1342
1344
|
))
|
|
1343
1345
|
}
|
|
1344
1346
|
);
|
|
1345
|
-
}),
|
|
1347
|
+
}), Pn = z(function(i) {
|
|
1346
1348
|
const { name: e, render: t } = i, { submitForm: n } = ue(), [o, l, a] = He(e);
|
|
1347
1349
|
return C(() => {
|
|
1348
1350
|
const c = (u) => a.setValue(u, !1);
|
|
@@ -1352,21 +1354,21 @@ const ze = (s, i) => C(() => !i || !s ? null : s.getInput(i), [s, i]), zt = (s,
|
|
|
1352
1354
|
patchValue: n
|
|
1353
1355
|
});
|
|
1354
1356
|
}, [n, a, o.value, t]);
|
|
1355
|
-
}),
|
|
1357
|
+
}), Ln = z(
|
|
1356
1358
|
ye((s, i) => {
|
|
1357
1359
|
const { children: e, schema: t, values: n, onPatch: o, onError: l, ...a } = s, c = C(() => et(t.fields, n), [t.fields, n]), u = E(
|
|
1358
|
-
(
|
|
1360
|
+
(y) => {
|
|
1359
1361
|
const x = {};
|
|
1360
|
-
for (const
|
|
1361
|
-
const I =
|
|
1362
|
-
I !== c[
|
|
1362
|
+
for (const F in y) {
|
|
1363
|
+
const I = y[F];
|
|
1364
|
+
I !== c[F] && I !== void 0 && (x[F] = I);
|
|
1363
1365
|
}
|
|
1364
1366
|
Ee(x) && o(x);
|
|
1365
1367
|
},
|
|
1366
1368
|
[c, o]
|
|
1367
1369
|
), d = E(
|
|
1368
|
-
async (
|
|
1369
|
-
const x = await Et(t,
|
|
1370
|
+
async (y) => {
|
|
1371
|
+
const x = await Et(t, y);
|
|
1370
1372
|
return x && l(x), x;
|
|
1371
1373
|
},
|
|
1372
1374
|
[t, l]
|
|
@@ -1377,51 +1379,51 @@ const ze = (s, i) => C(() => !i || !s ? null : s.getInput(i), [s, i]), zt = (s,
|
|
|
1377
1379
|
// only validate the entire form on submit
|
|
1378
1380
|
validateOnBlur: !1,
|
|
1379
1381
|
validateOnChange: !1
|
|
1380
|
-
}), { errors:
|
|
1382
|
+
}), { errors: p, resetForm: h } = f;
|
|
1381
1383
|
return be(() => {
|
|
1382
|
-
Ee(
|
|
1383
|
-
}, [
|
|
1384
|
+
Ee(p) && h({ values: c, errors: {} });
|
|
1385
|
+
}, [p, c, h]), /* @__PURE__ */ r(Ge, { value: f, children: /* @__PURE__ */ r("form", { ...a, ref: i, onSubmit: f.handleSubmit, children: e }) });
|
|
1384
1386
|
})
|
|
1385
1387
|
), Dt = {
|
|
1386
1388
|
...Ze,
|
|
1387
1389
|
section: K
|
|
1388
|
-
},
|
|
1390
|
+
}, en = z(function(i) {
|
|
1389
1391
|
const { field: e, setFieldType: t } = i, n = e.fieldTypeName, o = e.fieldTypeDescription, l = e.Icon;
|
|
1390
|
-
return /* @__PURE__ */
|
|
1391
|
-
/* @__PURE__ */ r(H, { type: "button", variant: "surface", onClick: t, style: { width: "135px" }, children: /* @__PURE__ */
|
|
1392
|
+
return /* @__PURE__ */ b(v, { gap: "4", align: "center", children: [
|
|
1393
|
+
/* @__PURE__ */ r(H, { type: "button", variant: "surface", onClick: t, style: { width: "135px" }, children: /* @__PURE__ */ b(v, { gap: "3", align: "center", grow: "1", children: [
|
|
1392
1394
|
/* @__PURE__ */ r(l, {}),
|
|
1393
1395
|
n
|
|
1394
1396
|
] }) }),
|
|
1395
1397
|
/* @__PURE__ */ r(k, { children: o })
|
|
1396
1398
|
] });
|
|
1397
|
-
}),
|
|
1399
|
+
}), Pt = [
|
|
1398
1400
|
["string", "text"],
|
|
1399
1401
|
["select", "multi-select", "upload"],
|
|
1400
1402
|
["boolean", "date", "number", "multi-string"]
|
|
1401
|
-
],
|
|
1403
|
+
], tn = Pt.length - 1, nn = z(function(i) {
|
|
1402
1404
|
const { setFieldType: e } = i;
|
|
1403
|
-
return /* @__PURE__ */ r(v, { direction: "column", gap: "3", children:
|
|
1405
|
+
return /* @__PURE__ */ r(v, { direction: "column", gap: "3", children: Pt.map((t, n) => /* @__PURE__ */ b(v, { direction: "column", gap: "3", children: [
|
|
1404
1406
|
/* @__PURE__ */ r(v, { direction: "column", gap: "2", children: t.map((o) => /* @__PURE__ */ r(
|
|
1405
|
-
|
|
1407
|
+
en,
|
|
1406
1408
|
{
|
|
1407
1409
|
field: Ze[o],
|
|
1408
1410
|
setFieldType: () => e(o)
|
|
1409
1411
|
},
|
|
1410
1412
|
o
|
|
1411
1413
|
)) }),
|
|
1412
|
-
n <
|
|
1414
|
+
n < tn && /* @__PURE__ */ r(ei, { size: "4" })
|
|
1413
1415
|
] }, n)) });
|
|
1414
|
-
}),
|
|
1416
|
+
}), rn = (s) => (i) => {
|
|
1415
1417
|
if (!(!i || typeof i != "string") && s.includes(i.trim()))
|
|
1416
1418
|
return "This name is already taken.";
|
|
1417
|
-
},
|
|
1419
|
+
}, on = (s, i) => {
|
|
1418
1420
|
const e = [
|
|
1419
1421
|
new he({
|
|
1420
1422
|
label: "Label",
|
|
1421
1423
|
required: !0,
|
|
1422
1424
|
maxLength: 200,
|
|
1423
1425
|
identifier: "label",
|
|
1424
|
-
fieldValidators: [
|
|
1426
|
+
fieldValidators: [rn(s)]
|
|
1425
1427
|
}),
|
|
1426
1428
|
new pe({
|
|
1427
1429
|
label: "Description",
|
|
@@ -1434,23 +1436,23 @@ const ze = (s, i) => C(() => !i || !s ? null : s.getInput(i), [s, i]), zt = (s,
|
|
|
1434
1436
|
...e,
|
|
1435
1437
|
new ce({ label: "Required", description: null, required: !1, identifier: "required" })
|
|
1436
1438
|
];
|
|
1437
|
-
},
|
|
1439
|
+
}, sn = z(function(i) {
|
|
1438
1440
|
const { fieldType: e, handleCancel: t, handleCreateField: n, handleDirty: o, defaultField: l, conditionalSourceFields: a } = i, c = Dt[e], u = ue(), d = C(() => {
|
|
1439
1441
|
const f = u.values.fields.flatMap(
|
|
1440
|
-
(
|
|
1441
|
-
).filter((
|
|
1442
|
-
let
|
|
1442
|
+
(h) => h.type === "section" ? [...h.fields.map((y) => y.label), h.label] : h.label
|
|
1443
|
+
).filter((h) => h !== (l == null ? void 0 : l.label) && h !== null);
|
|
1444
|
+
let p = on(f, e);
|
|
1443
1445
|
if (c === K) {
|
|
1444
1446
|
if (a === void 0)
|
|
1445
1447
|
throw new Error("Conditional source fields must be provided when changing sections.");
|
|
1446
|
-
|
|
1448
|
+
p = p.concat(c.getFieldCreationSchema(a));
|
|
1447
1449
|
} else {
|
|
1448
|
-
if (!(c.prototype instanceof
|
|
1450
|
+
if (!(c.prototype instanceof M))
|
|
1449
1451
|
throw new Error(`Field must be an instance of BaseField. Got ${c}.`);
|
|
1450
|
-
|
|
1452
|
+
p = [...p, ...c.getFieldCreationSchema()];
|
|
1451
1453
|
}
|
|
1452
1454
|
return {
|
|
1453
|
-
fields:
|
|
1455
|
+
fields: p,
|
|
1454
1456
|
meta: { readonly: !1 },
|
|
1455
1457
|
// using the dialog title as the form title
|
|
1456
1458
|
title: null
|
|
@@ -1464,72 +1466,73 @@ const ze = (s, i) => C(() => !i || !s ? null : s.getInput(i), [s, i]), zt = (s,
|
|
|
1464
1466
|
onSubmit: n,
|
|
1465
1467
|
cancelText: l ? void 0 : "Back",
|
|
1466
1468
|
onCancel: t,
|
|
1467
|
-
|
|
1469
|
+
onDirtyChange: o
|
|
1468
1470
|
}
|
|
1469
1471
|
);
|
|
1470
|
-
}), Ae =
|
|
1471
|
-
const { parentPath: e, index: t, children: n, initial: o, editing: l, conditionalSourceFields: a } = i, [c, u] = U(), [d, f] = U(!1),
|
|
1472
|
+
}), Ae = z(function(i) {
|
|
1473
|
+
const { parentPath: e, index: t, children: n, initial: o, editing: l, conditionalSourceFields: a } = i, [c, u] = U(), [d, f] = U(!1), p = (o == null ? void 0 : o.type) ?? c, h = p ? Dt[p].fieldTypeName : void 0, { setFieldValue: y, values: x } = ue();
|
|
1472
1474
|
if (l && !o)
|
|
1473
1475
|
throw new Error("Initial field must be provided if editing is true.");
|
|
1474
|
-
const
|
|
1476
|
+
const F = ti(), I = !p && !l && !o, w = I ? "Choose a field type" : `${h} settings`, L = I ? "Select a field type to add to this section." : (h == null ? void 0 : h.toLowerCase()) === "section" ? "Customize your section" : `Customize your ${h == null ? void 0 : h.toLowerCase()} field.`, D = E(() => {
|
|
1475
1477
|
console.log("handlecancel ran", d), u(void 0), f(!1);
|
|
1476
|
-
}, []),
|
|
1477
|
-
(_, O) => (
|
|
1478
|
-
console.log("closeinterrupt ran", _), _ ?
|
|
1478
|
+
}, []), T = E(
|
|
1479
|
+
(_, O) => (S) => {
|
|
1480
|
+
console.log("closeinterrupt ran", _, d), _ ? F({
|
|
1479
1481
|
onDiscard: () => {
|
|
1480
|
-
O(!1), u(void 0),
|
|
1482
|
+
O(!1), u(void 0), S();
|
|
1481
1483
|
}
|
|
1482
|
-
}) : (u(void 0),
|
|
1484
|
+
}) : (u(void 0), S());
|
|
1483
1485
|
},
|
|
1484
|
-
[
|
|
1486
|
+
[F]
|
|
1485
1487
|
), V = E(
|
|
1486
1488
|
(_, O) => {
|
|
1487
|
-
const { label:
|
|
1488
|
-
if (!
|
|
1489
|
+
const { label: S } = _;
|
|
1490
|
+
if (!p)
|
|
1489
1491
|
throw new Error("Field type must be selected before creating a field.");
|
|
1490
|
-
if (!
|
|
1492
|
+
if (!S || typeof S != "string")
|
|
1491
1493
|
throw new Error("Label must be provided before creating a field.");
|
|
1492
|
-
const
|
|
1493
|
-
type:
|
|
1494
|
+
const g = ke({
|
|
1495
|
+
type: p,
|
|
1494
1496
|
..._,
|
|
1495
|
-
identifier:
|
|
1497
|
+
identifier: _i(_.identifier, S)
|
|
1496
1498
|
}).serialize(), A = ae(x, e);
|
|
1497
1499
|
if (A === void 0)
|
|
1498
1500
|
throw new Error("Parent path must point to an existing field.");
|
|
1499
|
-
let
|
|
1501
|
+
let P;
|
|
1500
1502
|
if (!Array.isArray(A))
|
|
1501
1503
|
throw new Error("Parent path must point to an array.");
|
|
1502
|
-
l ?
|
|
1504
|
+
l ? P = ki(A, t, g) : P = xt(A, t, g), y(e, P).then(), f(!1), O();
|
|
1503
1505
|
},
|
|
1504
|
-
[l,
|
|
1506
|
+
[l, p, x, e, y, t]
|
|
1505
1507
|
), N = E(
|
|
1506
|
-
(_) => I ? /* @__PURE__ */ r(
|
|
1507
|
-
|
|
1508
|
+
(_) => I ? /* @__PURE__ */ r(nn, { setFieldType: u }) : /* @__PURE__ */ r(
|
|
1509
|
+
sn,
|
|
1508
1510
|
{
|
|
1509
1511
|
conditionalSourceFields: a,
|
|
1510
|
-
handleCancel:
|
|
1512
|
+
handleCancel: D,
|
|
1511
1513
|
handleCreateField: (O) => V(O, _),
|
|
1512
|
-
fieldType:
|
|
1514
|
+
fieldType: p,
|
|
1513
1515
|
defaultField: o,
|
|
1514
1516
|
handleDirty: () => f(!0)
|
|
1515
1517
|
}
|
|
1516
1518
|
),
|
|
1517
|
-
[a,
|
|
1519
|
+
[a, D, V, o, I, p]
|
|
1518
1520
|
);
|
|
1519
|
-
return /* @__PURE__ */ r(
|
|
1521
|
+
return /* @__PURE__ */ r(Fi, { children: /* @__PURE__ */ r(
|
|
1520
1522
|
ii,
|
|
1521
1523
|
{
|
|
1522
|
-
onCloseInterrupt:
|
|
1524
|
+
onCloseInterrupt: T(d, f),
|
|
1523
1525
|
title: w,
|
|
1524
1526
|
description: L,
|
|
1525
1527
|
content: N,
|
|
1528
|
+
onPointerDownOutside: (_) => _.preventDefault(),
|
|
1526
1529
|
children: n
|
|
1527
1530
|
}
|
|
1528
|
-
);
|
|
1531
|
+
) });
|
|
1529
1532
|
}), st = ({ children: s }) => /* @__PURE__ */ r(dt, { children: s }), lt = (s, i) => ({
|
|
1530
1533
|
initial: s ? i : "none",
|
|
1531
1534
|
sm: s ? "none" : i
|
|
1532
|
-
}),
|
|
1535
|
+
}), Lt = z(function(i) {
|
|
1533
1536
|
const { remove: e, dragHandleProps: t, editProps: n, insertAfterProps: o } = i, l = C(
|
|
1534
1537
|
() => [
|
|
1535
1538
|
{
|
|
@@ -1563,7 +1566,7 @@ const ze = (s, i) => C(() => !i || !s ? null : s.getInput(i), [s, i]), zt = (s,
|
|
|
1563
1566
|
],
|
|
1564
1567
|
[t, n, o, e]
|
|
1565
1568
|
);
|
|
1566
|
-
return /* @__PURE__ */
|
|
1569
|
+
return /* @__PURE__ */ b(dt, { children: [
|
|
1567
1570
|
/* @__PURE__ */ r(v, { gap: "4", display: lt(!1, "flex"), children: l.map((a) => {
|
|
1568
1571
|
const c = a.Wrapper ?? st;
|
|
1569
1572
|
return /* @__PURE__ */ r(c, { ...a.wrapperProps, children: /* @__PURE__ */ r(le, { type: "button", variant: "ghost", "aria-label": a.text, ...a.buttonProps, children: /* @__PURE__ */ r(a.Icon, {}) }) }, a.text);
|
|
@@ -1581,7 +1584,7 @@ const ze = (s, i) => C(() => !i || !s ? null : s.getInput(i), [s, i]), zt = (s,
|
|
|
1581
1584
|
return {
|
|
1582
1585
|
...a.buttonProps,
|
|
1583
1586
|
onSelect: (u = a.buttonProps) == null ? void 0 : u.onClick,
|
|
1584
|
-
content: /* @__PURE__ */ r(c, { ...a.wrapperProps, children: /* @__PURE__ */
|
|
1587
|
+
content: /* @__PURE__ */ r(c, { ...a.wrapperProps, children: /* @__PURE__ */ b(v, { gap: "2", align: "center", children: [
|
|
1585
1588
|
/* @__PURE__ */ r(a.Icon, {}),
|
|
1586
1589
|
a.text
|
|
1587
1590
|
] }) })
|
|
@@ -1590,7 +1593,7 @@ const ze = (s, i) => C(() => !i || !s ? null : s.getInput(i), [s, i]), zt = (s,
|
|
|
1590
1593
|
}
|
|
1591
1594
|
) })
|
|
1592
1595
|
] });
|
|
1593
|
-
}), _e = "form-builder",
|
|
1596
|
+
}), _e = "form-builder", ln = z(function(i) {
|
|
1594
1597
|
const { field: e, index: t, sectionIndex: n, remove: o } = i, l = C(() => ke(e), [e]), a = ze(l, { formId: _e, disabled: !0 }), c = C(
|
|
1595
1598
|
() => ({
|
|
1596
1599
|
index: t,
|
|
@@ -1614,10 +1617,10 @@ const ze = (s, i) => C(() => !i || !s ? null : s.getInput(i), [s, i]), zt = (s,
|
|
|
1614
1617
|
...d.draggableProps,
|
|
1615
1618
|
...d.dragHandleProps,
|
|
1616
1619
|
mb: "4",
|
|
1617
|
-
children: /* @__PURE__ */
|
|
1620
|
+
children: /* @__PURE__ */ b(v, { gap: "4", justify: "between", align: "center", children: [
|
|
1618
1621
|
a,
|
|
1619
1622
|
/* @__PURE__ */ r(
|
|
1620
|
-
|
|
1623
|
+
Lt,
|
|
1621
1624
|
{
|
|
1622
1625
|
remove: o,
|
|
1623
1626
|
editProps: c,
|
|
@@ -1628,42 +1631,42 @@ const ze = (s, i) => C(() => !i || !s ? null : s.getInput(i), [s, i]), zt = (s,
|
|
|
1628
1631
|
] })
|
|
1629
1632
|
}
|
|
1630
1633
|
) });
|
|
1631
|
-
}),
|
|
1632
|
-
var L,
|
|
1634
|
+
}), an = z(function(i) {
|
|
1635
|
+
var L, D, T, V, N, _, O;
|
|
1633
1636
|
const { field: e, index: t, dropState: n } = i, o = (L = n[e.identifier]) == null ? void 0 : L.disabled, { setFieldValue: l, values: a } = ue(), c = ai(), u = E(
|
|
1634
|
-
(
|
|
1635
|
-
for (const A of
|
|
1636
|
-
const
|
|
1637
|
-
l(`fields.${
|
|
1637
|
+
(S, g) => {
|
|
1638
|
+
for (const A of S) {
|
|
1639
|
+
const P = g.indexOf(A);
|
|
1640
|
+
l(`fields.${P}.condition`, null).then(), l(`fields.${P}.conditional`, !1).then();
|
|
1638
1641
|
}
|
|
1639
1642
|
},
|
|
1640
1643
|
[l]
|
|
1641
1644
|
), d = E(
|
|
1642
|
-
(
|
|
1643
|
-
var
|
|
1644
|
-
const
|
|
1645
|
-
if (!
|
|
1645
|
+
(S) => {
|
|
1646
|
+
var P;
|
|
1647
|
+
const g = e.fields[S];
|
|
1648
|
+
if (!g)
|
|
1646
1649
|
throw new Error("Could not find field to remove.");
|
|
1647
1650
|
const A = [];
|
|
1648
1651
|
for (const B of a.fields)
|
|
1649
|
-
((
|
|
1652
|
+
((P = B.condition) == null ? void 0 : P.identifier) === g.identifier && A.push(B);
|
|
1650
1653
|
return {
|
|
1651
|
-
removing:
|
|
1654
|
+
removing: g,
|
|
1652
1655
|
affectedSections: A,
|
|
1653
|
-
action: () => l(`fields.${t}.fields`, Ie(e.fields,
|
|
1656
|
+
action: () => l(`fields.${t}.fields`, Ie(e.fields, S))
|
|
1654
1657
|
};
|
|
1655
1658
|
},
|
|
1656
1659
|
[e.fields, a.fields, l, t]
|
|
1657
1660
|
), f = E(
|
|
1658
|
-
(
|
|
1659
|
-
const { affectedSections:
|
|
1660
|
-
A().then(), u(
|
|
1661
|
+
(S) => {
|
|
1662
|
+
const { affectedSections: g, action: A, removing: P } = d(S), B = () => {
|
|
1663
|
+
A().then(), u(g, a.fields);
|
|
1661
1664
|
};
|
|
1662
|
-
if (
|
|
1663
|
-
const fe =
|
|
1665
|
+
if (g.length > 0) {
|
|
1666
|
+
const fe = g.map((Y) => Y.label).join(", ");
|
|
1664
1667
|
return c({
|
|
1665
1668
|
title: "Remove condition?",
|
|
1666
|
-
description: `${
|
|
1669
|
+
description: `${P.label} is being used as a condition, deleting it will remove the condition from the ${fe} section(s).`,
|
|
1667
1670
|
severity: "danger",
|
|
1668
1671
|
actionText: "Remove",
|
|
1669
1672
|
onAction: B
|
|
@@ -1672,9 +1675,9 @@ const ze = (s, i) => C(() => !i || !s ? null : s.getInput(i), [s, i]), zt = (s,
|
|
|
1672
1675
|
B();
|
|
1673
1676
|
},
|
|
1674
1677
|
[d, u, a.fields, c]
|
|
1675
|
-
),
|
|
1676
|
-
const
|
|
1677
|
-
if (
|
|
1678
|
+
), p = E(() => {
|
|
1679
|
+
const g = e.fields.map((ve, Vt) => d(Vt)).flatMap((ve) => ve.affectedSections), A = g.length ? "Remove fields and conditions?" : "Remove fields?", P = e.fields.length, B = g.map((ve) => ve.label).join(", "), fe = g.length ? `Deleting this section will remove the ${P} field(s) it contains and will remove the conditions from following sections: ${B}` : `Deleting this section will remove the ${P} field(s) it contains.`, Y = Ie(a.fields, t), it = () => l("fields", Y);
|
|
1680
|
+
if (g.length > 0)
|
|
1678
1681
|
return c({
|
|
1679
1682
|
title: A,
|
|
1680
1683
|
description: fe,
|
|
@@ -1682,7 +1685,7 @@ const ze = (s, i) => C(() => !i || !s ? null : s.getInput(i), [s, i]), zt = (s,
|
|
|
1682
1685
|
actionText: "Remove",
|
|
1683
1686
|
onAction: () => {
|
|
1684
1687
|
it().then(() => {
|
|
1685
|
-
u(
|
|
1688
|
+
u(g, Y);
|
|
1686
1689
|
});
|
|
1687
1690
|
}
|
|
1688
1691
|
});
|
|
@@ -1695,7 +1698,7 @@ const ze = (s, i) => C(() => !i || !s ? null : s.getInput(i), [s, i]), zt = (s,
|
|
|
1695
1698
|
l,
|
|
1696
1699
|
c,
|
|
1697
1700
|
u
|
|
1698
|
-
]),
|
|
1701
|
+
]), h = C(
|
|
1699
1702
|
() => ({
|
|
1700
1703
|
index: t,
|
|
1701
1704
|
parentPath: "fields",
|
|
@@ -1704,7 +1707,7 @@ const ze = (s, i) => C(() => !i || !s ? null : s.getInput(i), [s, i]), zt = (s,
|
|
|
1704
1707
|
conditionalSourceFields: Be(a.fields, t)
|
|
1705
1708
|
}),
|
|
1706
1709
|
[e, t, a.fields]
|
|
1707
|
-
),
|
|
1710
|
+
), y = C(
|
|
1708
1711
|
() => ({
|
|
1709
1712
|
index: t + 1,
|
|
1710
1713
|
parentPath: "fields",
|
|
@@ -1719,57 +1722,57 @@ const ze = (s, i) => C(() => !i || !s ? null : s.getInput(i), [s, i]), zt = (s,
|
|
|
1719
1722
|
initial: void 0
|
|
1720
1723
|
}),
|
|
1721
1724
|
[e.fields.length, t]
|
|
1722
|
-
),
|
|
1725
|
+
), F = C(
|
|
1723
1726
|
() => {
|
|
1724
|
-
var
|
|
1725
|
-
return (
|
|
1727
|
+
var S, g;
|
|
1728
|
+
return (g = It(a.fields, (S = e.condition) == null ? void 0 : S.identifier)) == null ? void 0 : g.label;
|
|
1726
1729
|
},
|
|
1727
|
-
[(
|
|
1728
|
-
), I = Array.isArray((
|
|
1730
|
+
[(D = e.condition) == null ? void 0 : D.identifier, a.fields]
|
|
1731
|
+
), I = Array.isArray((T = e.condition) == null ? void 0 : T.value) ? "contains all of" : "equals";
|
|
1729
1732
|
if (We((V = e.condition) == null ? void 0 : V.value))
|
|
1730
1733
|
throw new Error("File values are not supported for conditions.");
|
|
1731
|
-
const w = Array.isArray((N = e.condition) == null ? void 0 : N.value) ? (_ = e.condition) == null ? void 0 : _.value.map((
|
|
1732
|
-
return /* @__PURE__ */ r(Ye, { draggableId: e.identifier, index: t, children: (
|
|
1734
|
+
const w = Array.isArray((N = e.condition) == null ? void 0 : N.value) ? (_ = e.condition) == null ? void 0 : _.value.map((S) => typeof S == "string" ? S : S.label).join(", ") : (O = e.condition) == null ? void 0 : O.value.toString();
|
|
1735
|
+
return /* @__PURE__ */ r(Ye, { draggableId: e.identifier, index: t, children: (S) => /* @__PURE__ */ r(
|
|
1733
1736
|
ge,
|
|
1734
1737
|
{
|
|
1735
|
-
ref:
|
|
1736
|
-
...
|
|
1737
|
-
...
|
|
1738
|
+
ref: S.innerRef,
|
|
1739
|
+
...S.draggableProps,
|
|
1740
|
+
...S.dragHandleProps,
|
|
1738
1741
|
mb: "4",
|
|
1739
|
-
children: /* @__PURE__ */
|
|
1740
|
-
/* @__PURE__ */
|
|
1741
|
-
/* @__PURE__ */
|
|
1742
|
-
/* @__PURE__ */ r(
|
|
1742
|
+
children: /* @__PURE__ */ b(v, { gap: "3", justify: "between", align: "center", children: [
|
|
1743
|
+
/* @__PURE__ */ b(v, { direction: "column", gap: "2", grow: "1", children: [
|
|
1744
|
+
/* @__PURE__ */ b(v, { direction: "column", children: [
|
|
1745
|
+
/* @__PURE__ */ r(Pe, { as: "h3", size: "3", children: e.label }),
|
|
1743
1746
|
/* @__PURE__ */ r(k, { className: Ve.description, children: e.description })
|
|
1744
1747
|
] }),
|
|
1745
|
-
e.condition && /* @__PURE__ */ r(k, { size: "1", children: /* @__PURE__ */
|
|
1748
|
+
e.condition && /* @__PURE__ */ r(k, { size: "1", children: /* @__PURE__ */ b(ci, { children: [
|
|
1746
1749
|
"Display only if ",
|
|
1747
|
-
/* @__PURE__ */ r(nt, { children:
|
|
1750
|
+
/* @__PURE__ */ r(nt, { children: F }),
|
|
1748
1751
|
" ",
|
|
1749
1752
|
I,
|
|
1750
1753
|
" ",
|
|
1751
1754
|
/* @__PURE__ */ r(nt, { children: w })
|
|
1752
1755
|
] }) }),
|
|
1753
|
-
/* @__PURE__ */ r(Ke, { droppableId: e.identifier, type: "SECTION", isDropDisabled: o, children: (
|
|
1756
|
+
/* @__PURE__ */ r(Ke, { droppableId: e.identifier, type: "SECTION", isDropDisabled: o, children: (g) => /* @__PURE__ */ b(
|
|
1754
1757
|
v,
|
|
1755
1758
|
{
|
|
1756
|
-
ref:
|
|
1757
|
-
...
|
|
1759
|
+
ref: g.innerRef,
|
|
1760
|
+
...g.droppableProps,
|
|
1758
1761
|
direction: "column",
|
|
1759
1762
|
gap: "0",
|
|
1760
1763
|
children: [
|
|
1761
|
-
e.fields.map((A,
|
|
1762
|
-
|
|
1764
|
+
e.fields.map((A, P) => /* @__PURE__ */ r(
|
|
1765
|
+
ln,
|
|
1763
1766
|
{
|
|
1764
1767
|
field: A,
|
|
1765
|
-
index:
|
|
1768
|
+
index: P,
|
|
1766
1769
|
sectionIndex: t,
|
|
1767
|
-
remove: () => f(
|
|
1770
|
+
remove: () => f(P)
|
|
1768
1771
|
},
|
|
1769
1772
|
A.identifier
|
|
1770
1773
|
)),
|
|
1771
|
-
|
|
1772
|
-
/* @__PURE__ */ r(Ae, { ...x, children: /* @__PURE__ */
|
|
1774
|
+
g.placeholder,
|
|
1775
|
+
/* @__PURE__ */ r(Ae, { ...x, children: /* @__PURE__ */ b(H, { type: "button", variant: "outline", children: [
|
|
1773
1776
|
/* @__PURE__ */ r(De, {}),
|
|
1774
1777
|
" Add a field"
|
|
1775
1778
|
] }) })
|
|
@@ -1778,18 +1781,18 @@ const ze = (s, i) => C(() => !i || !s ? null : s.getInput(i), [s, i]), zt = (s,
|
|
|
1778
1781
|
) })
|
|
1779
1782
|
] }),
|
|
1780
1783
|
/* @__PURE__ */ r(
|
|
1781
|
-
|
|
1784
|
+
Lt,
|
|
1782
1785
|
{
|
|
1783
|
-
remove:
|
|
1784
|
-
insertAfterProps:
|
|
1785
|
-
dragHandleProps:
|
|
1786
|
-
editProps:
|
|
1786
|
+
remove: p,
|
|
1787
|
+
insertAfterProps: y,
|
|
1788
|
+
dragHandleProps: S.dragHandleProps,
|
|
1789
|
+
editProps: h
|
|
1787
1790
|
}
|
|
1788
1791
|
)
|
|
1789
1792
|
] })
|
|
1790
1793
|
}
|
|
1791
1794
|
) });
|
|
1792
|
-
}),
|
|
1795
|
+
}), cn = (s, i) => {
|
|
1793
1796
|
var t;
|
|
1794
1797
|
const e = { ...s };
|
|
1795
1798
|
switch (i.type) {
|
|
@@ -1804,7 +1807,7 @@ const ze = (s, i) => C(() => !i || !s ? null : s.getInput(i), [s, i]), zt = (s,
|
|
|
1804
1807
|
case "update":
|
|
1805
1808
|
return i.state;
|
|
1806
1809
|
}
|
|
1807
|
-
},
|
|
1810
|
+
}, dn = (s, i) => {
|
|
1808
1811
|
if (i)
|
|
1809
1812
|
for (let e = 0; e < s.length; e++) {
|
|
1810
1813
|
const t = s[e];
|
|
@@ -1825,7 +1828,7 @@ const ze = (s, i) => C(() => !i || !s ? null : s.getInput(i), [s, i]), zt = (s,
|
|
|
1825
1828
|
(t = l.condition) != null && t.identifier && c.add(l.condition.identifier), i[l.identifier] = {
|
|
1826
1829
|
disabled: !1,
|
|
1827
1830
|
conditionFields: c,
|
|
1828
|
-
conditionIndex:
|
|
1831
|
+
conditionIndex: dn(s, (n = l.condition) == null ? void 0 : n.identifier),
|
|
1829
1832
|
index: o,
|
|
1830
1833
|
label: l.label
|
|
1831
1834
|
};
|
|
@@ -1835,8 +1838,8 @@ const ze = (s, i) => C(() => !i || !s ? null : s.getInput(i), [s, i]), zt = (s,
|
|
|
1835
1838
|
for (const [e, t] of Object.entries(s))
|
|
1836
1839
|
if (t.identifier === i)
|
|
1837
1840
|
return [t, e];
|
|
1838
|
-
},
|
|
1839
|
-
const { values: i, setFieldValue: e } = ue(), [t, n] = mi(
|
|
1841
|
+
}, un = z(function() {
|
|
1842
|
+
const { values: i, setFieldValue: e } = ue(), [t, n] = mi(cn, i.fields, at), { showInfo: o } = di();
|
|
1840
1843
|
be(() => {
|
|
1841
1844
|
n({ type: "update", state: at(i.fields) });
|
|
1842
1845
|
}, [n, i.fields]);
|
|
@@ -1844,39 +1847,39 @@ const ze = (s, i) => C(() => !i || !s ? null : s.getInput(i), [s, i]), zt = (s,
|
|
|
1844
1847
|
u.type === "SECTION" && n({ type: "hold", fieldId: u.draggableId });
|
|
1845
1848
|
}, []), a = E(
|
|
1846
1849
|
(u) => {
|
|
1847
|
-
const { source: d, destination: f, type:
|
|
1848
|
-
if (n({ type: "release" }), !f ||
|
|
1850
|
+
const { source: d, destination: f, type: p, reason: h, draggableId: y } = u;
|
|
1851
|
+
if (n({ type: "release" }), !f || h === "CANCEL")
|
|
1849
1852
|
return;
|
|
1850
|
-
if (
|
|
1851
|
-
const L = t[
|
|
1853
|
+
if (p === "ROOT") {
|
|
1854
|
+
const L = t[y];
|
|
1852
1855
|
if (!L)
|
|
1853
1856
|
throw new Error("Could not find section context.");
|
|
1854
|
-
let
|
|
1857
|
+
let D = typeof L.conditionIndex < "u" ? (
|
|
1855
1858
|
// cannot move a section with a condition before the condition's field
|
|
1856
1859
|
Math.max(L.conditionIndex + 1, f.index)
|
|
1857
1860
|
) : f.index;
|
|
1858
|
-
for (const
|
|
1859
|
-
|
|
1860
|
-
return
|
|
1861
|
+
for (const T of Object.values(t))
|
|
1862
|
+
T.conditionIndex === d.index && (D = Math.min(D, T.index - 1));
|
|
1863
|
+
return D != f.index && o({
|
|
1861
1864
|
title: "Reordered sections",
|
|
1862
1865
|
description: "Sections with conditions must be below the fields they reference."
|
|
1863
|
-
}), e("fields", Ne(i.fields, d.index,
|
|
1866
|
+
}), e("fields", Ne(i.fields, d.index, D));
|
|
1864
1867
|
}
|
|
1865
|
-
if (
|
|
1868
|
+
if (p !== "SECTION")
|
|
1866
1869
|
throw new Error("Unexpected droppable type.");
|
|
1867
|
-
const [x,
|
|
1870
|
+
const [x, F] = ct(i.fields, d.droppableId) ?? [], [I, w] = ct(i.fields, f.droppableId) ?? [];
|
|
1868
1871
|
if (!(x != null && x.fields) || !I)
|
|
1869
1872
|
throw new Error("Could not find section with fields.");
|
|
1870
1873
|
if (x.identifier === I.identifier)
|
|
1871
1874
|
e(
|
|
1872
|
-
`fields.${
|
|
1875
|
+
`fields.${F}.fields`,
|
|
1873
1876
|
Ne(x.fields, d.index, f.index)
|
|
1874
1877
|
).then();
|
|
1875
1878
|
else {
|
|
1876
1879
|
const L = x.fields[d.index];
|
|
1877
1880
|
if (!L)
|
|
1878
1881
|
throw new Error("Could not find field to reorder.");
|
|
1879
|
-
e(`fields.${
|
|
1882
|
+
e(`fields.${F}.fields`, Ie(x.fields, d.index)).then(), e(
|
|
1880
1883
|
`fields.${w}.fields`,
|
|
1881
1884
|
xt(I.fields, f.index, L)
|
|
1882
1885
|
).then();
|
|
@@ -1892,7 +1895,7 @@ const ze = (s, i) => C(() => !i || !s ? null : s.getInput(i), [s, i]), zt = (s,
|
|
|
1892
1895
|
}),
|
|
1893
1896
|
[i.fields]
|
|
1894
1897
|
);
|
|
1895
|
-
return /* @__PURE__ */ r(ht, { onDragStart: l, onDragEnd: a, children: /* @__PURE__ */ r(Ke, { droppableId: "droppable", type: "ROOT", children: (u) => /* @__PURE__ */
|
|
1898
|
+
return /* @__PURE__ */ r(ht, { onDragStart: l, onDragEnd: a, children: /* @__PURE__ */ r(Ke, { droppableId: "droppable", type: "ROOT", children: (u) => /* @__PURE__ */ b(
|
|
1896
1899
|
v,
|
|
1897
1900
|
{
|
|
1898
1901
|
ref: u.innerRef,
|
|
@@ -1901,7 +1904,7 @@ const ze = (s, i) => C(() => !i || !s ? null : s.getInput(i), [s, i]), zt = (s,
|
|
|
1901
1904
|
gap: "0",
|
|
1902
1905
|
children: [
|
|
1903
1906
|
i.fields.map((d, f) => /* @__PURE__ */ r(
|
|
1904
|
-
|
|
1907
|
+
an,
|
|
1905
1908
|
{
|
|
1906
1909
|
field: d,
|
|
1907
1910
|
index: f,
|
|
@@ -1910,56 +1913,56 @@ const ze = (s, i) => C(() => !i || !s ? null : s.getInput(i), [s, i]), zt = (s,
|
|
|
1910
1913
|
d.label
|
|
1911
1914
|
)),
|
|
1912
1915
|
u.placeholder,
|
|
1913
|
-
/* @__PURE__ */ r(Ae, { ...c, children: /* @__PURE__ */
|
|
1916
|
+
/* @__PURE__ */ r(Ae, { ...c, children: /* @__PURE__ */ b(H, { type: "button", variant: "outline", children: [
|
|
1914
1917
|
/* @__PURE__ */ r(De, {}),
|
|
1915
1918
|
" Add a section"
|
|
1916
1919
|
] }) })
|
|
1917
1920
|
]
|
|
1918
1921
|
}
|
|
1919
1922
|
) }) });
|
|
1920
|
-
}),
|
|
1923
|
+
}), fn = {
|
|
1921
1924
|
title: "",
|
|
1922
1925
|
description: "",
|
|
1923
1926
|
fields: []
|
|
1924
|
-
},
|
|
1927
|
+
}, mn = new he({
|
|
1925
1928
|
label: "Title",
|
|
1926
1929
|
minLength: 0,
|
|
1927
1930
|
maxLength: 100,
|
|
1928
1931
|
required: !0,
|
|
1929
1932
|
identifier: "title"
|
|
1930
|
-
}),
|
|
1933
|
+
}), hn = { formId: _e, placeholder: "Give your form a title." }, pn = new pe({
|
|
1931
1934
|
label: "Description",
|
|
1932
1935
|
minLength: 0,
|
|
1933
1936
|
maxLength: 1e3,
|
|
1934
1937
|
required: !1,
|
|
1935
1938
|
identifier: "description"
|
|
1936
|
-
}),
|
|
1939
|
+
}), gn = { formId: _e, placeholder: "Explain the purpose of this form." }, bn = () => {
|
|
1937
1940
|
alert("This is a form preview, your data will not be saved.");
|
|
1938
|
-
},
|
|
1941
|
+
}, Vn = z(
|
|
1939
1942
|
ye((s, i) => {
|
|
1940
|
-
const { onCancel: e, onSave: t, revision: n } = s, o = n ? "Edit form" : "Create a new form", { heading: l = o } = s, a = E((
|
|
1941
|
-
const
|
|
1942
|
-
if (
|
|
1943
|
-
return
|
|
1943
|
+
const { onCancel: e, onSave: t, revision: n } = s, o = n ? "Edit form" : "Create a new form", { heading: l = o } = s, a = E((h) => {
|
|
1944
|
+
const y = {};
|
|
1945
|
+
if (h.title || (y.title = "Title is required."), (!h.fields || h.fields.length === 0) && (y.fields = "At least one field is required."), Ee(y))
|
|
1946
|
+
return y;
|
|
1944
1947
|
}, []), c = Ue({
|
|
1945
|
-
initialValues:
|
|
1948
|
+
initialValues: Vi(n) ?? fn,
|
|
1946
1949
|
validate: a,
|
|
1947
|
-
onSubmit: (
|
|
1950
|
+
onSubmit: (h) => t(h),
|
|
1948
1951
|
// only validate the entire for on submit
|
|
1949
1952
|
validateOnChange: !1,
|
|
1950
1953
|
validateOnBlur: !1
|
|
1951
|
-
}), u = C(() => Tt(c.values), [c.values]), d = ze(
|
|
1952
|
-
() => typeof l == "object" ? l : /* @__PURE__ */ r(
|
|
1954
|
+
}), u = C(() => Tt(c.values), [c.values]), d = ze(mn, hn), f = ze(pn, gn), p = C(
|
|
1955
|
+
() => typeof l == "object" ? l : /* @__PURE__ */ r(Pe, { children: l }),
|
|
1953
1956
|
[l]
|
|
1954
1957
|
);
|
|
1955
|
-
return /* @__PURE__ */ r(Q.Root, { ref: i, defaultValue: "edit", children: /* @__PURE__ */
|
|
1956
|
-
/* @__PURE__ */
|
|
1958
|
+
return /* @__PURE__ */ r(Q.Root, { ref: i, defaultValue: "edit", children: /* @__PURE__ */ b(v, { direction: "column", gap: "2", children: [
|
|
1959
|
+
/* @__PURE__ */ b(Q.List, { children: [
|
|
1957
1960
|
/* @__PURE__ */ r(Q.Trigger, { value: "edit", children: "Edit" }),
|
|
1958
1961
|
/* @__PURE__ */ r(Q.Trigger, { value: "preview", children: "Preview" })
|
|
1959
1962
|
] }),
|
|
1960
|
-
/* @__PURE__ */
|
|
1961
|
-
|
|
1962
|
-
/* @__PURE__ */
|
|
1963
|
+
/* @__PURE__ */ b(Q.Content, { value: "edit", children: [
|
|
1964
|
+
p,
|
|
1965
|
+
/* @__PURE__ */ b(k, { children: [
|
|
1963
1966
|
"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",
|
|
1964
1967
|
" ",
|
|
1965
1968
|
/* @__PURE__ */ r("em", { children: "Preview" }),
|
|
@@ -1967,48 +1970,48 @@ const ze = (s, i) => C(() => !i || !s ? null : s.getInput(i), [s, i]), zt = (s,
|
|
|
1967
1970
|
" ",
|
|
1968
1971
|
/* @__PURE__ */ r("strong", { children: "field values entered on this page will not be saved." })
|
|
1969
1972
|
] }),
|
|
1970
|
-
/* @__PURE__ */ r(v, { asChild: !0, direction: "column", gap: "2", mt: "3", children: /* @__PURE__ */
|
|
1971
|
-
/* @__PURE__ */
|
|
1973
|
+
/* @__PURE__ */ r(v, { asChild: !0, direction: "column", gap: "2", mt: "3", children: /* @__PURE__ */ b("form", { id: _e, onSubmit: c.handleSubmit, children: [
|
|
1974
|
+
/* @__PURE__ */ b(Ge, { value: c, children: [
|
|
1972
1975
|
d,
|
|
1973
1976
|
f,
|
|
1974
|
-
/* @__PURE__ */ r(
|
|
1977
|
+
/* @__PURE__ */ r(un, {}),
|
|
1975
1978
|
/* @__PURE__ */ r(k, { severity: "danger", size: "1", children: typeof c.errors.fields == "string" && c.errors.fields })
|
|
1976
1979
|
] }),
|
|
1977
|
-
/* @__PURE__ */
|
|
1980
|
+
/* @__PURE__ */ b(v, { justify: "end", gap: "2", children: [
|
|
1978
1981
|
/* @__PURE__ */ r(H, { type: "button", variant: "soft", onClick: e, children: "Cancel" }),
|
|
1979
1982
|
/* @__PURE__ */ r(H, { type: "submit", disabled: !c.isValid, children: "Save" })
|
|
1980
1983
|
] })
|
|
1981
1984
|
] }) })
|
|
1982
1985
|
] }),
|
|
1983
|
-
/* @__PURE__ */ r(Q.Content, { value: "preview", children: /* @__PURE__ */ r(tt, { schema: u, onSubmit:
|
|
1986
|
+
/* @__PURE__ */ r(Q.Content, { value: "preview", children: /* @__PURE__ */ r(tt, { schema: u, onSubmit: bn }) })
|
|
1984
1987
|
] }) });
|
|
1985
1988
|
})
|
|
1986
1989
|
);
|
|
1987
1990
|
export {
|
|
1988
1991
|
ce as BooleanField,
|
|
1989
|
-
|
|
1992
|
+
zi as BooleanInput,
|
|
1990
1993
|
Re as DateField,
|
|
1991
|
-
|
|
1994
|
+
Ai as DateInput,
|
|
1992
1995
|
K as FieldSection,
|
|
1993
|
-
|
|
1994
|
-
|
|
1996
|
+
An as FormBrowser,
|
|
1997
|
+
Vn as FormBuilder,
|
|
1995
1998
|
tt as FormRenderer,
|
|
1996
|
-
|
|
1997
|
-
|
|
1999
|
+
Dn as FormSubmissionBrowser,
|
|
2000
|
+
En as FormSubmissionViewer,
|
|
1998
2001
|
Te as MultiSelectField,
|
|
1999
|
-
|
|
2002
|
+
Oi as MultiSelectInput,
|
|
2000
2003
|
Ce as MultiStringField,
|
|
2001
|
-
|
|
2004
|
+
$i as MultiStringInput,
|
|
2002
2005
|
G as NumberField,
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
+
Ei as NumberInput,
|
|
2007
|
+
Pn as PatchField,
|
|
2008
|
+
Ln as PatchFormProvider,
|
|
2006
2009
|
Fe as SelectField,
|
|
2007
2010
|
Li as SelectInput,
|
|
2008
2011
|
he as StringField,
|
|
2009
|
-
|
|
2012
|
+
Di as StringInput,
|
|
2010
2013
|
pe as TextField,
|
|
2011
|
-
|
|
2014
|
+
Pi as TextInput,
|
|
2012
2015
|
ke as deserialize,
|
|
2013
2016
|
Ft as deserializeField,
|
|
2014
2017
|
Tt as formRevisionToSchema,
|