@overmap-ai/forms 1.0.3-form-improvements.6 → 1.0.3-form-improvements.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/forms.js +230 -221
- package/dist/forms.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/forms.js
CHANGED
|
@@ -2,11 +2,11 @@ var Nt = Object.defineProperty;
|
|
|
2
2
|
var Bt = (s, i, e) => i in s ? Nt(s, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[i] = e;
|
|
3
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 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
|
|
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 bi, { useMemo as
|
|
7
|
+
import bi, { useMemo as v, memo as S, useCallback as T, useState as ce, useEffect as we, useRef as yi, forwardRef as ve, useReducer as wi } 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 vi, useAppSelector as _, selectFormRevision as wt, useSDK as vt, 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,7 +90,7 @@ class M extends Ct {
|
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
m(M, "fieldTypeName"), m(M, "fieldTypeDescription");
|
|
93
|
-
const Li = "_description_17zed_1",
|
|
93
|
+
const Li = "_description_17zed_1", _e = {
|
|
94
94
|
description: Li
|
|
95
95
|
}, W = (s) => {
|
|
96
96
|
const { label: i, children: e, severity: t, inputId: n, labelId: o, flexProps: l } = s;
|
|
@@ -102,14 +102,14 @@ const Li = "_description_17zed_1", $e = {
|
|
|
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
|
-
/* @__PURE__ */ r(y, { direction: "column", children: /* @__PURE__ */ r(D, { size: "1", severity: t, className:
|
|
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
|
-
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`,
|
|
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`, h = `${u}-label`, p = e.required ? `${e.label} *` : e.label, g = v(() => ({
|
|
109
109
|
...o,
|
|
110
110
|
onChange: (F) => {
|
|
111
|
-
const
|
|
112
|
-
c.setValue(
|
|
111
|
+
const w = e.getValueFromChangeEvent(F);
|
|
112
|
+
c.setValue(w, !1).then(), (a || !e.onlyValidateAfterTouched) && c.setError(e.getError(w));
|
|
113
113
|
},
|
|
114
114
|
onBlur: (F) => {
|
|
115
115
|
c.setTouched(!0, !1).then(), c.setError(e.getError(e.getValueFromChangeEvent(F)));
|
|
@@ -120,15 +120,15 @@ const Li = "_description_17zed_1", $e = {
|
|
|
120
120
|
helpText: f,
|
|
121
121
|
severity: d,
|
|
122
122
|
inputId: u,
|
|
123
|
-
labelId:
|
|
124
|
-
label:
|
|
123
|
+
labelId: h,
|
|
124
|
+
label: p,
|
|
125
125
|
fieldProps: g,
|
|
126
126
|
helpers: c,
|
|
127
127
|
field: e
|
|
128
128
|
},
|
|
129
|
-
{ ...n, "aria-labelledby":
|
|
129
|
+
{ ...n, "aria-labelledby": h }
|
|
130
130
|
];
|
|
131
|
-
}, Pi = [!0, "true"], Vi =
|
|
131
|
+
}, Pi = [!0, "true"], Vi = S(function(i) {
|
|
132
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
133
|
return /* @__PURE__ */ r(j, { helpText: o, severity: n, children: /* @__PURE__ */ r(
|
|
134
134
|
W,
|
|
@@ -180,7 +180,7 @@ const Li = "_description_17zed_1", $e = {
|
|
|
180
180
|
};
|
|
181
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 ki =
|
|
183
|
+
const ki = S(function(i) {
|
|
184
184
|
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: l, fieldProps: c, field: a }, f] = H(i), d = fe(n);
|
|
185
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,
|
|
@@ -271,7 +271,7 @@ const ki = T(function(i) {
|
|
|
271
271
|
};
|
|
272
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
273
|
let Y = B;
|
|
274
|
-
const Di =
|
|
274
|
+
const Di = S(function(i) {
|
|
275
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
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 {
|
|
@@ -365,7 +365,7 @@ 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
|
|
368
|
+
const $i = S(function(i) {
|
|
369
369
|
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: l, fieldProps: c, field: a }, f] = H(i), d = fe(n);
|
|
370
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 {
|
|
@@ -385,12 +385,12 @@ const _i = 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
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
|
|
393
|
+
const _i = S(function(i) {
|
|
394
394
|
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: l, fieldProps: c }, a] = H(i);
|
|
395
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 {
|
|
@@ -408,16 +408,16 @@ 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
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 Mi =
|
|
417
|
-
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: l, fieldProps: c, field: a }, f] = H(i), { onChange: d, onBlur: u } = c,
|
|
416
|
+
const Mi = S(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, h = v(
|
|
418
418
|
() => a.options.map((g) => ({ value: g.value, itemContent: g.label })),
|
|
419
419
|
[a.options]
|
|
420
|
-
),
|
|
420
|
+
), p = T(
|
|
421
421
|
(g) => {
|
|
422
422
|
d(g), u(g);
|
|
423
423
|
},
|
|
@@ -426,9 +426,9 @@ const Mi = T(function(i) {
|
|
|
426
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
|
-
items:
|
|
429
|
+
items: h,
|
|
430
430
|
...c,
|
|
431
|
-
onValueChange:
|
|
431
|
+
onValueChange: p,
|
|
432
432
|
placeholder: "Select one...",
|
|
433
433
|
id: e,
|
|
434
434
|
severity: n,
|
|
@@ -474,7 +474,7 @@ 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 `${
|
|
477
|
+
return `${vi(i)}-${e.getTime()}`;
|
|
478
478
|
}, zt = (s, i) => {
|
|
479
479
|
if (!i)
|
|
480
480
|
return null;
|
|
@@ -493,35 +493,35 @@ const St = (s, i) => {
|
|
|
493
493
|
for (; i.includes(t); )
|
|
494
494
|
t = `${s} (${++e})`;
|
|
495
495
|
return t;
|
|
496
|
-
}, Ni =
|
|
497
|
-
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: l, fieldProps: c }, a] = H(i), f = fe(n), d =
|
|
496
|
+
}, Ni = S(function(i) {
|
|
497
|
+
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: l, fieldProps: c }, a] = H(i), f = fe(n), d = v(() => Array.isArray(c.value) ? c.value : [], [c.value]), { onChange: u, onBlur: h } = c, p = `${e}-droppable`, { disabled: g } = a, [x, z] = ce(""), [F, w] = ce(""), L = F || o, P = F ? "red" : f, I = T(
|
|
498
498
|
(A) => {
|
|
499
|
-
u(A),
|
|
499
|
+
u(A), h(A);
|
|
500
500
|
},
|
|
501
|
-
[u,
|
|
502
|
-
), V =
|
|
501
|
+
[u, h]
|
|
502
|
+
), V = T(
|
|
503
503
|
(A) => {
|
|
504
|
-
d.findIndex((R) => R.value === A.target.value.trim()) >= 0 ?
|
|
504
|
+
d.findIndex((R) => R.value === A.target.value.trim()) >= 0 ? w("All options must be unique") : A.target.value ? w("") : w("Option cannot be empty"), z(A.target.value);
|
|
505
505
|
},
|
|
506
506
|
[z, d]
|
|
507
|
-
), O =
|
|
507
|
+
), O = T(() => {
|
|
508
508
|
if (F)
|
|
509
509
|
return;
|
|
510
510
|
if (!x.trim())
|
|
511
|
-
return
|
|
511
|
+
return w("Option cannot be empty");
|
|
512
512
|
const A = x.trim();
|
|
513
513
|
I([...d, { value: A, label: A }]), z("");
|
|
514
|
-
}, [x, F, I, d]), K =
|
|
514
|
+
}, [x, F, I, d]), K = T(
|
|
515
515
|
(A) => {
|
|
516
516
|
A.key === "Enter" && (A.preventDefault(), O());
|
|
517
517
|
},
|
|
518
518
|
[O]
|
|
519
|
-
), q =
|
|
519
|
+
), q = T(
|
|
520
520
|
(A) => {
|
|
521
521
|
I(Se(d, A));
|
|
522
522
|
},
|
|
523
523
|
[d, I]
|
|
524
|
-
), U =
|
|
524
|
+
), U = T(
|
|
525
525
|
(A) => {
|
|
526
526
|
if (!A.destination)
|
|
527
527
|
return;
|
|
@@ -557,17 +557,17 @@ const St = (s, i) => {
|
|
|
557
557
|
}
|
|
558
558
|
)
|
|
559
559
|
] }) }) }),
|
|
560
|
-
/* @__PURE__ */ r(Je, { droppableId:
|
|
560
|
+
/* @__PURE__ */ r(Je, { droppableId: p, children: (A) => /* @__PURE__ */ b(y, { ...A.droppableProps, ref: A.innerRef, direction: "column", children: [
|
|
561
561
|
d.map((R, C) => /* @__PURE__ */ r(
|
|
562
562
|
Ze,
|
|
563
563
|
{
|
|
564
564
|
draggableId: `${R.value}-draggable`,
|
|
565
565
|
index: C,
|
|
566
566
|
isDragDisabled: g,
|
|
567
|
-
children: ({ draggableProps: E, dragHandleProps:
|
|
567
|
+
children: ({ draggableProps: E, dragHandleProps: $, innerRef: k }) => /* @__PURE__ */ r(
|
|
568
568
|
y,
|
|
569
569
|
{
|
|
570
|
-
|
|
570
|
+
...$,
|
|
571
571
|
...E,
|
|
572
572
|
ref: k,
|
|
573
573
|
gap: "2",
|
|
@@ -691,8 +691,8 @@ const ne = class ne extends At {
|
|
|
691
691
|
};
|
|
692
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
|
-
const Bi = (s) => s ? Array.isArray(s) ? s : [s] : [], qi =
|
|
695
|
-
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: l, fieldProps: c, field: a }, f] = H(i), { onChange: d, onBlur: u } = c,
|
|
694
|
+
const Bi = (s) => s ? Array.isArray(s) ? s : [s] : [], qi = S(function(i) {
|
|
695
|
+
const [{ inputId: e, labelId: t, severity: n, helpText: o, label: l, fieldProps: c, field: a }, f] = H(i), { onChange: d, onBlur: u } = c, h = v(() => Bi(c.value), [c.value]), p = T(
|
|
696
696
|
(g) => {
|
|
697
697
|
d(g), u(g);
|
|
698
698
|
},
|
|
@@ -701,8 +701,8 @@ const Bi = (s) => s ? Array.isArray(s) ? s : [s] : [], qi = T(function(i) {
|
|
|
701
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
702
|
Xt,
|
|
703
703
|
{
|
|
704
|
-
value:
|
|
705
|
-
onValueChange:
|
|
704
|
+
value: h,
|
|
705
|
+
onValueChange: p,
|
|
706
706
|
options: a.options,
|
|
707
707
|
name: c.name,
|
|
708
708
|
placeholder: "Select one or more...",
|
|
@@ -737,8 +737,8 @@ const Bi = (s) => s ? Array.isArray(s) ? s : [s] : [], qi = T(function(i) {
|
|
|
737
737
|
};
|
|
738
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
|
-
const Wi =
|
|
741
|
-
const [{ value: t }] = Ye(i.options.clonedFieldIdentifier), n =
|
|
740
|
+
const Wi = S(function({ field: i, ...e }) {
|
|
741
|
+
const [{ value: t }] = Ye(i.options.clonedFieldIdentifier), n = v(() => {
|
|
742
742
|
const o = i.options.getFieldToClone(t);
|
|
743
743
|
return o ? Me(o) : null;
|
|
744
744
|
}, [i.options, t]);
|
|
@@ -766,21 +766,21 @@ class ji extends Le {
|
|
|
766
766
|
super(i, Wi);
|
|
767
767
|
}
|
|
768
768
|
}
|
|
769
|
-
const Hi =
|
|
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 =
|
|
771
|
-
|
|
769
|
+
const Hi = S(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 = v(() => Vt(c, d), [c, d]);
|
|
771
|
+
we(() => {
|
|
772
772
|
if (!u)
|
|
773
|
-
for (const
|
|
774
|
-
f(
|
|
773
|
+
for (const p of l)
|
|
774
|
+
f(p.getId(), "").then();
|
|
775
775
|
}, [u, l, f]);
|
|
776
|
-
const
|
|
776
|
+
const h = 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 }),
|
|
780
|
-
/* @__PURE__ */ r(D, { className:
|
|
780
|
+
/* @__PURE__ */ r(D, { className: _e.description, children: o })
|
|
781
781
|
] }),
|
|
782
|
-
|
|
783
|
-
] }) }) :
|
|
782
|
+
h
|
|
783
|
+
] }) }) : h : null;
|
|
784
784
|
}), oe = class oe extends Ct {
|
|
785
785
|
constructor(e) {
|
|
786
786
|
const { label: t = null, fields: n, condition: o = null, conditional: l, ...c } = e;
|
|
@@ -892,18 +892,18 @@ const Ui = "_previewImage_1ig84_1", Gi = {
|
|
|
892
892
|
for (; e > 1024 && t < i.length - 1; )
|
|
893
893
|
e /= 1024, t++;
|
|
894
894
|
return new Intl.NumberFormat([], { maximumFractionDigits: 2, style: "unit", unit: i[t] }).format(e);
|
|
895
|
-
}, Ki =
|
|
895
|
+
}, Ki = S(function(i) {
|
|
896
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),
|
|
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), h = yi(null), { value: p } = c, g = v(() => o || (a.maxFileSize ? `Maximum file size: ${it(a.maxFileSize)}` : null), [a.maxFileSize, o]), x = T(() => {
|
|
898
898
|
var I;
|
|
899
|
-
(I =
|
|
900
|
-
}, []), z =
|
|
899
|
+
(I = h.current) == null || I.click();
|
|
900
|
+
}, []), z = T(
|
|
901
901
|
(I) => {
|
|
902
|
-
const V = [...
|
|
902
|
+
const V = [...p];
|
|
903
903
|
V.splice(I, 1), d({ target: { files: V } });
|
|
904
904
|
},
|
|
905
|
-
[
|
|
906
|
-
), F =
|
|
905
|
+
[p, d]
|
|
906
|
+
), F = p ? "Select new files" : "Select files", w = p ? "Select new file" : "Select a file", L = a.maxFiles > 1 ? F : w;
|
|
907
907
|
return /* @__PURE__ */ b(y, { direction: "column", gap: "2", children: [
|
|
908
908
|
/* @__PURE__ */ r(j, { helpText: g, severity: n, children: /* @__PURE__ */ b(W, { severity: n, inputId: e, labelId: t, label: l, children: [
|
|
909
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: [
|
|
@@ -916,7 +916,7 @@ const Ui = "_previewImage_1ig84_1", Gi = {
|
|
|
916
916
|
{
|
|
917
917
|
...f,
|
|
918
918
|
type: "file",
|
|
919
|
-
ref:
|
|
919
|
+
ref: h,
|
|
920
920
|
id: e,
|
|
921
921
|
accept: (P = a.extensions) == null ? void 0 : P.join(","),
|
|
922
922
|
multiple: a.maxFiles > 1,
|
|
@@ -927,7 +927,7 @@ const Ui = "_previewImage_1ig84_1", Gi = {
|
|
|
927
927
|
}
|
|
928
928
|
)
|
|
929
929
|
] }) }),
|
|
930
|
-
Array.isArray(
|
|
930
|
+
Array.isArray(p) && p.length > 0 && /* @__PURE__ */ r(y, { direction: "column", gap: "2", children: p.map((I, V) => /* @__PURE__ */ r(
|
|
931
931
|
Yi,
|
|
932
932
|
{
|
|
933
933
|
field: a,
|
|
@@ -938,12 +938,12 @@ const Ui = "_previewImage_1ig84_1", Gi = {
|
|
|
938
938
|
V
|
|
939
939
|
)) })
|
|
940
940
|
] });
|
|
941
|
-
}), Yi =
|
|
942
|
-
const [o, l] = ce(null), c =
|
|
943
|
-
let u = null,
|
|
944
|
-
return o != null && o.type.startsWith("image/") && (u = URL.createObjectURL(o)), o ? (
|
|
941
|
+
}), Yi = S(function({ file: i, field: e, onRemove: t, disabled: n }) {
|
|
942
|
+
const [o, l] = ce(null), c = v(() => o && e.getError([o]), [e, o]), { url: a, name: f, size: d } = v(() => {
|
|
943
|
+
let u = null, h, p;
|
|
944
|
+
return o != null && o.type.startsWith("image/") && (u = URL.createObjectURL(o)), o ? (h = o.name, p = it(o.size)) : (h = "Downloading...", p = "..."), { url: u, name: h, size: p };
|
|
945
945
|
}, [o]);
|
|
946
|
-
return
|
|
946
|
+
return we(() => {
|
|
947
947
|
i instanceof Promise ? i.then(l) : l(i);
|
|
948
948
|
}, [i]), /* @__PURE__ */ r(ye, { children: /* @__PURE__ */ b(y, { direction: { initial: "column", sm: "row" }, gap: "3", justify: "between", children: [
|
|
949
949
|
/* @__PURE__ */ b(y, { direction: "row", gap: "3", align: "center", grow: "1", shrink: "0", children: [
|
|
@@ -1102,8 +1102,8 @@ function Vt(s, i) {
|
|
|
1102
1102
|
}
|
|
1103
1103
|
return t === i;
|
|
1104
1104
|
}
|
|
1105
|
-
const Pe = (s, i) =>
|
|
1106
|
-
const e =
|
|
1105
|
+
const Pe = (s, i) => v(() => !i || !s ? null : s.getInput(i), [s, i]), kt = (s, i) => {
|
|
1106
|
+
const e = v(() => 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
1108
|
}, Ve = (s) => Object.keys(s).length > 0, Dt = async (s, i) => {
|
|
1109
1109
|
const e = {};
|
|
@@ -1125,8 +1125,8 @@ const Pe = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), kt = (s,
|
|
|
1125
1125
|
return e;
|
|
1126
1126
|
}, Qi = [null, void 0], rt = (s, i) => s.reduce((e, t) => t instanceof Q ? { ...e, ...rt(t.fields, i) } : (Qi.includes(de(e, t.getId())) && tt(e, t.getId(), ""), e), i), Xi = () => {
|
|
1127
1127
|
throw new Error("onSubmit must be provided if form is not readonly.");
|
|
1128
|
-
}, ot =
|
|
1129
|
-
|
|
1128
|
+
}, ot = S(
|
|
1129
|
+
ve((s, i) => {
|
|
1130
1130
|
const {
|
|
1131
1131
|
schema: e,
|
|
1132
1132
|
values: t = {},
|
|
@@ -1139,50 +1139,50 @@ const Pe = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), kt = (s,
|
|
|
1139
1139
|
hideTitle: f = !e.title,
|
|
1140
1140
|
hideDescription: d,
|
|
1141
1141
|
className: u
|
|
1142
|
-
} = s, { readonly:
|
|
1142
|
+
} = s, { readonly: h } = e.meta, p = v(() => crypto.randomUUID(), []), g = Qe({
|
|
1143
1143
|
initialValues: rt(e.fields, t),
|
|
1144
1144
|
onSubmit: n,
|
|
1145
1145
|
validate: (L) => Dt(e, L),
|
|
1146
1146
|
// only validate the entire form on submit
|
|
1147
1147
|
validateOnBlur: !1,
|
|
1148
1148
|
validateOnChange: !1
|
|
1149
|
-
}), { dirty: x } = g, z =
|
|
1149
|
+
}), { dirty: x } = g, z = v(
|
|
1150
1150
|
() => typeof e.title == "string" ? /* @__PURE__ */ r(De, { children: e.title }) : e.title,
|
|
1151
1151
|
[e.title]
|
|
1152
|
-
), F =
|
|
1153
|
-
() => typeof e.description == "string" ? /* @__PURE__ */ r(D, { className:
|
|
1152
|
+
), F = v(
|
|
1153
|
+
() => typeof e.description == "string" ? /* @__PURE__ */ r(D, { className: _e.description, children: e.description }) : e.description,
|
|
1154
1154
|
[e.description]
|
|
1155
|
-
),
|
|
1156
|
-
return
|
|
1155
|
+
), w = kt(e.fields, { formId: p, disabled: h });
|
|
1156
|
+
return we(() => {
|
|
1157
1157
|
x && a && a();
|
|
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:
|
|
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: p, onSubmit: g.handleSubmit, children: [
|
|
1159
1159
|
!f && /* @__PURE__ */ r(ye, { children: /* @__PURE__ */ b(y, { direction: "column", gap: "1", children: [
|
|
1160
1160
|
z,
|
|
1161
1161
|
!d && F
|
|
1162
1162
|
] }) }),
|
|
1163
|
-
|
|
1164
|
-
!
|
|
1163
|
+
w,
|
|
1164
|
+
!h && /* @__PURE__ */ b(y, { justify: "end", gap: "2", children: [
|
|
1165
1165
|
l && /* @__PURE__ */ r(G, { type: "button", variant: "soft", onClick: c, children: l }),
|
|
1166
1166
|
/* @__PURE__ */ r(G, { type: "submit", disabled: !g.isValid, children: o })
|
|
1167
1167
|
] })
|
|
1168
1168
|
] }) }) });
|
|
1169
1169
|
})
|
|
1170
|
-
), Pn =
|
|
1171
|
-
|
|
1172
|
-
const { submission: e, showFormDescription: t = !1, showFormTitle: n = !0 } = s, o =
|
|
1170
|
+
), Pn = S(
|
|
1171
|
+
ve((s, i) => {
|
|
1172
|
+
const { submission: e, showFormDescription: t = !1, showFormTitle: n = !0 } = s, o = _(wt(e.form_revision)), { sdk: l } = vt();
|
|
1173
1173
|
if (!o)
|
|
1174
1174
|
throw new Error(
|
|
1175
1175
|
`Could not find revision ${e.form_revision} for submission ${e.offline_id}.`
|
|
1176
1176
|
);
|
|
1177
|
-
const c =
|
|
1177
|
+
const c = v(() => Pt(o, { readonly: !0 }), [o]), a = v(() => {
|
|
1178
1178
|
const f = xi(e.offline_id)(l.store.getState()) ?? [], d = {};
|
|
1179
1179
|
for (const u of f) {
|
|
1180
|
-
const
|
|
1180
|
+
const h = l.files.fetchFileFromUrl(u.file, u.file_sha1, u.file_name).then((g) => {
|
|
1181
1181
|
if (!g.success)
|
|
1182
1182
|
throw new Error(`Failed to download attachment ${u.file_name}.`);
|
|
1183
1183
|
return g.body;
|
|
1184
|
-
}),
|
|
1185
|
-
|
|
1184
|
+
}), p = d[u.field_identifier];
|
|
1185
|
+
p ? p.push(h) : d[u.field_identifier] = [h];
|
|
1186
1186
|
}
|
|
1187
1187
|
return { ...e.values, ...d };
|
|
1188
1188
|
}, [l.files, l.store, e.offline_id, e.values]);
|
|
@@ -1200,35 +1200,35 @@ const Pe = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), kt = (s,
|
|
|
1200
1200
|
), Ji = "_favoriteIcon_1bixi_1", Zi = "_regularIcon_1bixi_9", ct = {
|
|
1201
1201
|
favoriteIcon: Ji,
|
|
1202
1202
|
regularIcon: Zi
|
|
1203
|
-
}, Ne = "organization:", Be = "user:", Vn =
|
|
1204
|
-
|
|
1205
|
-
const { maxResults: e = 20, ...t } = s, [n, o] = ce(""), [l, c] = ce(""), { sdk: a } =
|
|
1206
|
-
const
|
|
1207
|
-
return l && (l.startsWith(Ne) ?
|
|
1208
|
-
}, [n, e, l]), d =
|
|
1209
|
-
(
|
|
1210
|
-
|
|
1203
|
+
}, Ne = "organization:", Be = "user:", Vn = S(
|
|
1204
|
+
ve((s, i) => {
|
|
1205
|
+
const { maxResults: e = 20, ...t } = s, [n, o] = ce(""), [l, c] = ce(""), { sdk: a } = vt(), f = v(() => {
|
|
1206
|
+
const w = { maxResults: e, searchTerm: n };
|
|
1207
|
+
return l && (l.startsWith(Ne) ? w.owner_organization = parseInt(l.slice(Ne.length)) : l.startsWith(Be) && (w.owner_user = parseInt(l.slice(Be.length)))), w;
|
|
1208
|
+
}, [n, e, l]), d = _(Ii(f)) ?? [], u = _(Fi), h = T(
|
|
1209
|
+
(w) => {
|
|
1210
|
+
w.favorite ? a.userForms.unfavorite(w.offline_id).then() : a.userForms.favorite(w.offline_id).then();
|
|
1211
1211
|
},
|
|
1212
1212
|
[a]
|
|
1213
|
-
),
|
|
1214
|
-
const
|
|
1213
|
+
), p = v(() => {
|
|
1214
|
+
const w = a.store.getState(), L = {};
|
|
1215
1215
|
for (const P of Object.values(u)) {
|
|
1216
|
-
const I = xt(P.owner_organization || -1)(
|
|
1216
|
+
const I = xt(P.owner_organization || -1)(w);
|
|
1217
1217
|
I && (L[`${Ne}${I.id}`] = I.name);
|
|
1218
|
-
const V = et(P.owner_user || -1)(
|
|
1218
|
+
const V = et(P.owner_user || -1)(w);
|
|
1219
1219
|
V && (L[`${Be}${V.id}`] = V.username);
|
|
1220
1220
|
}
|
|
1221
1221
|
return Object.entries(L).map(([P, I]) => ({ itemContent: I, value: P }));
|
|
1222
|
-
}, [u, a.store]), g =
|
|
1223
|
-
o(
|
|
1224
|
-
}, []), z = (
|
|
1222
|
+
}, [u, a.store]), g = T((w) => {
|
|
1223
|
+
o(w.currentTarget.value);
|
|
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 }) }) }),
|
|
1228
1228
|
/* @__PURE__ */ r(
|
|
1229
1229
|
ht,
|
|
1230
1230
|
{
|
|
1231
|
-
items:
|
|
1231
|
+
items: p,
|
|
1232
1232
|
value: l,
|
|
1233
1233
|
onValueChange: c,
|
|
1234
1234
|
placeholder: "Owner",
|
|
@@ -1236,26 +1236,26 @@ const Pe = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), kt = (s,
|
|
|
1236
1236
|
}
|
|
1237
1237
|
)
|
|
1238
1238
|
] }),
|
|
1239
|
-
d.length > 0 && /* @__PURE__ */ r(
|
|
1239
|
+
d.length > 0 && /* @__PURE__ */ r($e.Root, { children: d.map((w) => /* @__PURE__ */ r(
|
|
1240
1240
|
en,
|
|
1241
1241
|
{
|
|
1242
1242
|
...t,
|
|
1243
|
-
form:
|
|
1244
|
-
handleToggleFavorite: () =>
|
|
1243
|
+
form: w,
|
|
1244
|
+
handleToggleFavorite: () => h(w)
|
|
1245
1245
|
},
|
|
1246
|
-
|
|
1246
|
+
w.offline_id
|
|
1247
1247
|
)) }),
|
|
1248
1248
|
/* @__PURE__ */ r(he, { px: "3", children: /* @__PURE__ */ r(D, { size: "2", severity: "info", children: F }) })
|
|
1249
1249
|
] });
|
|
1250
1250
|
})
|
|
1251
1251
|
), en = (s) => {
|
|
1252
|
-
var
|
|
1253
|
-
const { form: i, onSelectForm: e, isFavoriteEditable: t, handleToggleFavorite: n } = s, o = (
|
|
1254
|
-
(
|
|
1255
|
-
|
|
1252
|
+
var h;
|
|
1253
|
+
const { form: i, onSelectForm: e, isFavoriteEditable: t, handleToggleFavorite: n } = s, o = (h = _(xt(i.owner_organization || -1))) == null ? void 0 : h.name, l = _(et(i.owner_user || -1)), c = _(It).id, a = !!l && l.id === c, f = o ?? (a ? "You" : l == null ? void 0 : l.username) ?? "Unknown", d = T(
|
|
1254
|
+
(p) => {
|
|
1255
|
+
p.stopPropagation(), n();
|
|
1256
1256
|
},
|
|
1257
1257
|
[n]
|
|
1258
|
-
), u = /* @__PURE__ */ r(
|
|
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,
|
|
@@ -1278,29 +1278,29 @@ const Pe = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), kt = (s,
|
|
|
1278
1278
|
] })
|
|
1279
1279
|
] }) });
|
|
1280
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",
|
|
1281
|
+
}, tn = "_submissionsContainer_9iirt_1", nn = "_stopHorizontalOverflow_9iirt_6", $t = {
|
|
1282
1282
|
submissionsContainer: tn,
|
|
1283
1283
|
stopHorizontalOverflow: nn
|
|
1284
|
-
}, rn =
|
|
1285
|
-
var
|
|
1286
|
-
const { submission: e, onSubmissionClick: t, compact: n, labelType: o, rowDecorator: l } = i, c =
|
|
1284
|
+
}, rn = S(function(i) {
|
|
1285
|
+
var w;
|
|
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
|
-
}) : Si(f), u =
|
|
1289
|
+
}) : Si(f), u = _(wt(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
|
|
1292
|
+
const h = (w = _(zi(u.form))) == null ? void 0 : w.revision, p = 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 ===
|
|
1295
|
+
}), g = (a == null ? void 0 : a.username.charAt(0).toUpperCase()) ?? "?", x = u.revision === h, z = bi.useCallback(() => {
|
|
1296
1296
|
t && t({ submission: e });
|
|
1297
|
-
}, [e, t]), F = /* @__PURE__ */ r(
|
|
1298
|
-
/* @__PURE__ */ b(y, { gap: "2", align: "center", className:
|
|
1299
|
-
/* @__PURE__ */ r(oi, { src:
|
|
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: $t.stopHorizontalOverflow, children: [
|
|
1299
|
+
/* @__PURE__ */ r(oi, { src: p, 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: [
|
|
1303
|
-
!n && (u.revision ? /* @__PURE__ */ r(qe, { variant: "soft", severity: x ? "primary" : "info", children: n ? u.revision.toString() : `Revision #${u.revision}` }) : !!
|
|
1303
|
+
!n && (u.revision ? /* @__PURE__ */ r(qe, { variant: "soft", severity: x ? "primary" : "info", children: n ? u.revision.toString() : `Revision #${u.revision}` }) : !!h && /* @__PURE__ */ r(qe, { children: "Original" })),
|
|
1304
1304
|
/* @__PURE__ */ r(D, { size: "2", noWrap: !0, children: d })
|
|
1305
1305
|
] })
|
|
1306
1306
|
] }) });
|
|
@@ -1308,7 +1308,7 @@ const Pe = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), kt = (s,
|
|
|
1308
1308
|
}), Ke = (s) => {
|
|
1309
1309
|
const i = "created_at" in s ? s.created_at : s.submitted_at;
|
|
1310
1310
|
return new Date(i);
|
|
1311
|
-
}, kn =
|
|
1311
|
+
}, kn = S(function(i) {
|
|
1312
1312
|
const {
|
|
1313
1313
|
formId: e,
|
|
1314
1314
|
submissions: t,
|
|
@@ -1320,16 +1320,16 @@ const Pe = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), kt = (s,
|
|
|
1320
1320
|
} = i;
|
|
1321
1321
|
if (!!e == !!t)
|
|
1322
1322
|
throw new Error("Either formId or submissions must be provided, but not both.");
|
|
1323
|
-
const f =
|
|
1323
|
+
const f = _(
|
|
1324
1324
|
t ? () => t : Ai(e)
|
|
1325
|
-
), d =
|
|
1326
|
-
() => f == null ? void 0 : f.sort((u,
|
|
1325
|
+
), d = v(
|
|
1326
|
+
() => f == null ? void 0 : f.sort((u, h) => Ke(h).getTime() - Ke(u).getTime()),
|
|
1327
1327
|
[f]
|
|
1328
1328
|
);
|
|
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: [
|
|
@@ -1338,20 +1338,20 @@ const Pe = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), kt = (s,
|
|
|
1338
1338
|
" submissions of this form."
|
|
1339
1339
|
] }),
|
|
1340
1340
|
after: l,
|
|
1341
|
-
children: d == null ? void 0 : d.map((u,
|
|
1341
|
+
children: d == null ? void 0 : d.map((u, h) => /* @__PURE__ */ r(
|
|
1342
1342
|
rn,
|
|
1343
1343
|
{
|
|
1344
1344
|
submission: u,
|
|
1345
1345
|
compact: n,
|
|
1346
1346
|
...a
|
|
1347
1347
|
},
|
|
1348
|
-
|
|
1348
|
+
h
|
|
1349
1349
|
))
|
|
1350
1350
|
}
|
|
1351
1351
|
);
|
|
1352
|
-
}), Dn =
|
|
1352
|
+
}), Dn = S(function(i) {
|
|
1353
1353
|
const { name: e, render: t } = i, { submitForm: n } = me(), [o, l, c] = Ye(e);
|
|
1354
|
-
return
|
|
1354
|
+
return v(() => {
|
|
1355
1355
|
const a = (f) => c.setValue(f, !1);
|
|
1356
1356
|
return t({
|
|
1357
1357
|
value: o.value,
|
|
@@ -1359,9 +1359,9 @@ const Pe = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), kt = (s,
|
|
|
1359
1359
|
patchValue: n
|
|
1360
1360
|
});
|
|
1361
1361
|
}, [n, c, o.value, t]);
|
|
1362
|
-
}),
|
|
1363
|
-
|
|
1364
|
-
const { children: e, schema: t, values: n, onPatch: o, onError: l, ...c } = s, a =
|
|
1362
|
+
}), $n = S(
|
|
1363
|
+
ve((s, i) => {
|
|
1364
|
+
const { children: e, schema: t, values: n, onPatch: o, onError: l, ...c } = s, a = v(() => rt(t.fields, n), [t.fields, n]), f = T(
|
|
1365
1365
|
(g) => {
|
|
1366
1366
|
const x = {};
|
|
1367
1367
|
for (const z in g) {
|
|
@@ -1371,7 +1371,7 @@ const Pe = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), kt = (s,
|
|
|
1371
1371
|
Ve(x) && o(x);
|
|
1372
1372
|
},
|
|
1373
1373
|
[a, o]
|
|
1374
|
-
), d =
|
|
1374
|
+
), d = T(
|
|
1375
1375
|
async (g) => {
|
|
1376
1376
|
const x = await Dt(t, g);
|
|
1377
1377
|
return x && l(x), x;
|
|
@@ -1384,15 +1384,15 @@ const Pe = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), kt = (s,
|
|
|
1384
1384
|
// only validate the entire form on submit
|
|
1385
1385
|
validateOnBlur: !1,
|
|
1386
1386
|
validateOnChange: !1
|
|
1387
|
-
}), { errors:
|
|
1388
|
-
return
|
|
1389
|
-
Ve(
|
|
1390
|
-
}, [
|
|
1387
|
+
}), { errors: h, resetForm: p } = u;
|
|
1388
|
+
return we(() => {
|
|
1389
|
+
Ve(h) && p({ values: a, errors: {} });
|
|
1390
|
+
}, [h, a, p]), /* @__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
|
-
}, on =
|
|
1395
|
+
}, on = S(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
1398
|
/* @__PURE__ */ r(G, { type: "button", variant: "surface", onClick: t, style: { width: "135px" }, children: /* @__PURE__ */ b(y, { gap: "3", align: "center", grow: "1", children: [
|
|
@@ -1405,7 +1405,7 @@ const Pe = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), kt = (s,
|
|
|
1405
1405
|
["string", "text"],
|
|
1406
1406
|
["select", "multi-select", "upload"],
|
|
1407
1407
|
["boolean", "date", "number", "multi-string"]
|
|
1408
|
-
], sn = Mt.length - 1, ln =
|
|
1408
|
+
], sn = Mt.length - 1, ln = S(function(i) {
|
|
1409
1409
|
const { setFieldType: e } = i;
|
|
1410
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(
|
|
@@ -1441,9 +1441,9 @@ const Pe = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), kt = (s,
|
|
|
1441
1441
|
...e,
|
|
1442
1442
|
new ue({ label: "Required", description: null, required: !1, identifier: "required" })
|
|
1443
1443
|
];
|
|
1444
|
-
}, dn =
|
|
1445
|
-
const { fieldType: e, handleCancel: t, handleCreateField: n, defaultField: o, conditionalSourceFields: l } = i, c =
|
|
1446
|
-
const d = Et(a.values.fields).filter((
|
|
1444
|
+
}, dn = S(function(i) {
|
|
1445
|
+
const { fieldType: e, handleCancel: t, handleCreateField: n, defaultField: o, conditionalSourceFields: l } = i, c = _t[e], a = me(), f = v(() => {
|
|
1446
|
+
const d = Et(a.values.fields).filter((h) => h !== (o == null ? void 0 : o.label));
|
|
1447
1447
|
let u = cn(d, e);
|
|
1448
1448
|
if (c === Q) {
|
|
1449
1449
|
if (l === void 0)
|
|
@@ -1471,13 +1471,13 @@ const Pe = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), kt = (s,
|
|
|
1471
1471
|
onCancel: t
|
|
1472
1472
|
}
|
|
1473
1473
|
);
|
|
1474
|
-
}), pe =
|
|
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 ?
|
|
1474
|
+
}), pe = S(function(i) {
|
|
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: h, values: p } = me();
|
|
1476
1476
|
if (l && !o)
|
|
1477
1477
|
throw new Error("Initial field must be provided if editing is true.");
|
|
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 =
|
|
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 = T(() => f(void 0), []), w = T((I) => {
|
|
1479
1479
|
f(void 0), I();
|
|
1480
|
-
}, []), L =
|
|
1480
|
+
}, []), L = T(
|
|
1481
1481
|
(I, V) => {
|
|
1482
1482
|
const { label: O } = I;
|
|
1483
1483
|
if (!d)
|
|
@@ -1488,16 +1488,16 @@ const Pe = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), kt = (s,
|
|
|
1488
1488
|
type: d,
|
|
1489
1489
|
...I,
|
|
1490
1490
|
identifier: St(I.identifier, O)
|
|
1491
|
-
}).serialize(), q = de(
|
|
1491
|
+
}).serialize(), q = de(p, e);
|
|
1492
1492
|
if (q === void 0)
|
|
1493
1493
|
throw new Error("Parent path must point to an existing field.");
|
|
1494
1494
|
let U;
|
|
1495
1495
|
if (!Array.isArray(q))
|
|
1496
1496
|
throw new Error("Parent path must point to an array.");
|
|
1497
|
-
l ? U = Ri(q, t, K) : U = Tt(q, t, K),
|
|
1497
|
+
l ? U = Ri(q, t, K) : U = Tt(q, t, K), h(e, U).then(), V();
|
|
1498
1498
|
},
|
|
1499
|
-
[l, d,
|
|
1500
|
-
), P =
|
|
1499
|
+
[l, d, p, e, h, t]
|
|
1500
|
+
), P = T(
|
|
1501
1501
|
(I) => g ? /* @__PURE__ */ r(ln, { setFieldType: f }) : /* @__PURE__ */ r(
|
|
1502
1502
|
dn,
|
|
1503
1503
|
{
|
|
@@ -1510,12 +1510,12 @@ const Pe = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), kt = (s,
|
|
|
1510
1510
|
),
|
|
1511
1511
|
[c, F, L, o, g, d]
|
|
1512
1512
|
);
|
|
1513
|
-
return /* @__PURE__ */ r(li, { onCloseInterrupt:
|
|
1513
|
+
return /* @__PURE__ */ r(li, { onCloseInterrupt: w, title: x, description: z, content: P, children: n });
|
|
1514
1514
|
}), dt = ({ children: s }) => /* @__PURE__ */ r(pt, { children: s }), ut = (s, i) => ({
|
|
1515
1515
|
initial: s ? i : "none",
|
|
1516
1516
|
sm: s ? "none" : i
|
|
1517
|
-
}), Ot =
|
|
1518
|
-
const { remove: e, dragHandleProps: t, editProps: n, insertAfterProps: o, duplicateProps: l } = i, c =
|
|
1517
|
+
}), Ot = S(function(i) {
|
|
1518
|
+
const { remove: e, dragHandleProps: t, editProps: n, insertAfterProps: o, duplicateProps: l } = i, c = v(
|
|
1519
1519
|
() => [
|
|
1520
1520
|
{
|
|
1521
1521
|
Wrapper: pe,
|
|
@@ -1581,8 +1581,15 @@ const Pe = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), kt = (s,
|
|
|
1581
1581
|
}
|
|
1582
1582
|
) })
|
|
1583
1583
|
] });
|
|
1584
|
-
}), Oe = "form-builder", un =
|
|
1585
|
-
const { field: e, index: t, sectionIndex: n, takenLabels: o, remove: l } = i, c =
|
|
1584
|
+
}), Oe = "form-builder", un = S(function(i) {
|
|
1585
|
+
const { field: e, index: t, sectionIndex: n, takenLabels: o, remove: l } = i, c = v(() => Me(e), [e]), a = Pe(c, { formId: Oe, disabled: !0 }), f = T(
|
|
1586
|
+
(p) => {
|
|
1587
|
+
if (p.label == null)
|
|
1588
|
+
throw new Error(`Expected a label for field ${p.identifier}`);
|
|
1589
|
+
return { ...p, label: He(p.label, o), identifier: "" };
|
|
1590
|
+
},
|
|
1591
|
+
[o]
|
|
1592
|
+
), d = v(
|
|
1586
1593
|
() => ({
|
|
1587
1594
|
index: t,
|
|
1588
1595
|
parentPath: `fields.${n}.fields`,
|
|
@@ -1590,14 +1597,14 @@ const Pe = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), kt = (s,
|
|
|
1590
1597
|
editing: !0
|
|
1591
1598
|
}),
|
|
1592
1599
|
[e, t, n]
|
|
1593
|
-
),
|
|
1600
|
+
), u = v(
|
|
1594
1601
|
() => ({
|
|
1595
1602
|
parentPath: `fields.${n}.fields`,
|
|
1596
1603
|
index: t + 1,
|
|
1597
|
-
initial:
|
|
1604
|
+
initial: f(e)
|
|
1598
1605
|
}),
|
|
1599
|
-
[e, t, n
|
|
1600
|
-
),
|
|
1606
|
+
[f, e, t, n]
|
|
1607
|
+
), h = v(
|
|
1601
1608
|
() => ({
|
|
1602
1609
|
parentPath: `fields.${n}.fields`,
|
|
1603
1610
|
index: t + 1,
|
|
@@ -1618,45 +1625,45 @@ const Pe = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), kt = (s,
|
|
|
1618
1625
|
Ot,
|
|
1619
1626
|
{
|
|
1620
1627
|
remove: l,
|
|
1621
|
-
editProps:
|
|
1622
|
-
duplicateProps:
|
|
1623
|
-
insertAfterProps:
|
|
1628
|
+
editProps: d,
|
|
1629
|
+
duplicateProps: u,
|
|
1630
|
+
insertAfterProps: h,
|
|
1624
1631
|
dragHandleProps: p.dragHandleProps
|
|
1625
1632
|
}
|
|
1626
1633
|
)
|
|
1627
1634
|
] })
|
|
1628
1635
|
}
|
|
1629
1636
|
) });
|
|
1630
|
-
}), fn =
|
|
1637
|
+
}), fn = S(function(i) {
|
|
1631
1638
|
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 =
|
|
1639
|
+
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 = T(
|
|
1633
1640
|
(C, E) => {
|
|
1634
|
-
for (const
|
|
1635
|
-
const k = E.indexOf(
|
|
1641
|
+
for (const $ of C) {
|
|
1642
|
+
const k = E.indexOf($);
|
|
1636
1643
|
l(`fields.${k}.condition`, null).then(), l(`fields.${k}.conditional`, !1).then();
|
|
1637
1644
|
}
|
|
1638
1645
|
},
|
|
1639
1646
|
[l]
|
|
1640
|
-
), u =
|
|
1647
|
+
), u = T(
|
|
1641
1648
|
(C) => {
|
|
1642
1649
|
var k;
|
|
1643
1650
|
const E = e.fields[C];
|
|
1644
1651
|
if (!E)
|
|
1645
1652
|
throw new Error("Could not find field to remove.");
|
|
1646
|
-
const
|
|
1653
|
+
const $ = [];
|
|
1647
1654
|
for (const N of c.fields)
|
|
1648
|
-
((k = N.condition) == null ? void 0 : k.identifier) === E.identifier &&
|
|
1655
|
+
((k = N.condition) == null ? void 0 : k.identifier) === E.identifier && $.push(N);
|
|
1649
1656
|
return {
|
|
1650
1657
|
removing: E,
|
|
1651
|
-
affectedSections:
|
|
1658
|
+
affectedSections: $,
|
|
1652
1659
|
action: () => l(`fields.${t}.fields`, Se(e.fields, C))
|
|
1653
1660
|
};
|
|
1654
1661
|
},
|
|
1655
1662
|
[e.fields, c.fields, l, t]
|
|
1656
|
-
),
|
|
1663
|
+
), h = T(
|
|
1657
1664
|
(C) => {
|
|
1658
|
-
const { affectedSections: E, action:
|
|
1659
|
-
|
|
1665
|
+
const { affectedSections: E, action: $, removing: k } = u(C), N = () => {
|
|
1666
|
+
$().then(), d(E, c.fields);
|
|
1660
1667
|
};
|
|
1661
1668
|
if (E.length > 0) {
|
|
1662
1669
|
const Re = E.map((xe) => xe.label).join(", ");
|
|
@@ -1671,11 +1678,11 @@ const Pe = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), kt = (s,
|
|
|
1671
1678
|
N();
|
|
1672
1679
|
},
|
|
1673
1680
|
[u, d, c.fields, a]
|
|
1674
|
-
),
|
|
1675
|
-
const E = e.fields.map((Ie, Rt) => u(Rt)).flatMap((Ie) => Ie.affectedSections),
|
|
1681
|
+
), p = T(() => {
|
|
1682
|
+
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);
|
|
1676
1683
|
if (E.length > 0)
|
|
1677
1684
|
return a({
|
|
1678
|
-
title:
|
|
1685
|
+
title: $,
|
|
1679
1686
|
description: Re,
|
|
1680
1687
|
severity: "danger",
|
|
1681
1688
|
actionText: "Remove",
|
|
@@ -1694,9 +1701,11 @@ const Pe = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), kt = (s,
|
|
|
1694
1701
|
l,
|
|
1695
1702
|
a,
|
|
1696
1703
|
d
|
|
1697
|
-
]), g =
|
|
1704
|
+
]), g = T(
|
|
1698
1705
|
(C) => {
|
|
1699
|
-
|
|
1706
|
+
if (C.label == null)
|
|
1707
|
+
throw new Error(`Expected a label for field ${C.identifier}`);
|
|
1708
|
+
const E = He(C.label, f), $ = C.fields.map((k) => {
|
|
1700
1709
|
const N = He(k.label, f);
|
|
1701
1710
|
return {
|
|
1702
1711
|
...k,
|
|
@@ -1704,10 +1713,10 @@ const Pe = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), kt = (s,
|
|
|
1704
1713
|
identifier: St(void 0, N)
|
|
1705
1714
|
};
|
|
1706
1715
|
});
|
|
1707
|
-
return { ...C, label: E, fields:
|
|
1716
|
+
return { ...C, label: E, fields: $, identifier: "" };
|
|
1708
1717
|
},
|
|
1709
1718
|
[f]
|
|
1710
|
-
), x =
|
|
1719
|
+
), x = v(
|
|
1711
1720
|
() => ({
|
|
1712
1721
|
index: t,
|
|
1713
1722
|
parentPath: "fields",
|
|
@@ -1716,7 +1725,7 @@ const Pe = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), kt = (s,
|
|
|
1716
1725
|
conditionalSourceFields: Fe(c.fields, t)
|
|
1717
1726
|
}),
|
|
1718
1727
|
[e, t, c.fields]
|
|
1719
|
-
), z =
|
|
1728
|
+
), z = v(
|
|
1720
1729
|
() => ({
|
|
1721
1730
|
index: t + 1,
|
|
1722
1731
|
parentPath: "fields",
|
|
@@ -1724,14 +1733,14 @@ const Pe = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), kt = (s,
|
|
|
1724
1733
|
conditionalSourceFields: Fe(c.fields, t + 1)
|
|
1725
1734
|
}),
|
|
1726
1735
|
[t, c.fields]
|
|
1727
|
-
), F =
|
|
1736
|
+
), F = v(
|
|
1728
1737
|
() => ({
|
|
1729
1738
|
parentPath: `fields.${t}.fields`,
|
|
1730
1739
|
index: e.fields.length,
|
|
1731
1740
|
initial: void 0
|
|
1732
1741
|
}),
|
|
1733
1742
|
[e.fields.length, t]
|
|
1734
|
-
),
|
|
1743
|
+
), w = v(
|
|
1735
1744
|
() => ({
|
|
1736
1745
|
index: t + 1,
|
|
1737
1746
|
parentPath: "fields",
|
|
@@ -1739,7 +1748,7 @@ const Pe = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), kt = (s,
|
|
|
1739
1748
|
conditionalSourceFields: Fe(c.fields, t + 1)
|
|
1740
1749
|
}),
|
|
1741
1750
|
[g, e, t, c.fields]
|
|
1742
|
-
), L =
|
|
1751
|
+
), L = v(
|
|
1743
1752
|
() => {
|
|
1744
1753
|
var C, E;
|
|
1745
1754
|
return (E = zt(c.fields, (C = e.condition) == null ? void 0 : C.identifier)) == null ? void 0 : E.label;
|
|
@@ -1760,7 +1769,7 @@ const Pe = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), kt = (s,
|
|
|
1760
1769
|
/* @__PURE__ */ b(y, { direction: "column", gap: "2", grow: "1", children: [
|
|
1761
1770
|
/* @__PURE__ */ b(y, { direction: "column", children: [
|
|
1762
1771
|
/* @__PURE__ */ r(De, { as: "h3", size: "3", children: e.label }),
|
|
1763
|
-
/* @__PURE__ */ r(D, { className:
|
|
1772
|
+
/* @__PURE__ */ r(D, { className: _e.description, children: e.description })
|
|
1764
1773
|
] }),
|
|
1765
1774
|
e.condition && /* @__PURE__ */ r(D, { size: "1", children: /* @__PURE__ */ b(hi, { children: [
|
|
1766
1775
|
"Display only if ",
|
|
@@ -1778,16 +1787,16 @@ const Pe = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), kt = (s,
|
|
|
1778
1787
|
direction: "column",
|
|
1779
1788
|
gap: "0",
|
|
1780
1789
|
children: [
|
|
1781
|
-
e.fields.map((
|
|
1790
|
+
e.fields.map(($, k) => /* @__PURE__ */ r(
|
|
1782
1791
|
un,
|
|
1783
1792
|
{
|
|
1784
|
-
field:
|
|
1793
|
+
field: $,
|
|
1785
1794
|
index: k,
|
|
1786
1795
|
sectionIndex: t,
|
|
1787
|
-
remove: () =>
|
|
1796
|
+
remove: () => h(k),
|
|
1788
1797
|
takenLabels: f
|
|
1789
1798
|
},
|
|
1790
|
-
|
|
1799
|
+
$.identifier
|
|
1791
1800
|
)),
|
|
1792
1801
|
E.placeholder,
|
|
1793
1802
|
/* @__PURE__ */ r(pe, { ...F, children: /* @__PURE__ */ b(G, { type: "button", variant: "outline", children: [
|
|
@@ -1801,11 +1810,11 @@ const Pe = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), kt = (s,
|
|
|
1801
1810
|
/* @__PURE__ */ r(
|
|
1802
1811
|
Ot,
|
|
1803
1812
|
{
|
|
1804
|
-
remove:
|
|
1813
|
+
remove: p,
|
|
1805
1814
|
insertAfterProps: z,
|
|
1806
1815
|
dragHandleProps: C.dragHandleProps,
|
|
1807
1816
|
editProps: x,
|
|
1808
|
-
duplicateProps:
|
|
1817
|
+
duplicateProps: w
|
|
1809
1818
|
}
|
|
1810
1819
|
)
|
|
1811
1820
|
] })
|
|
@@ -1857,19 +1866,19 @@ const Pe = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), kt = (s,
|
|
|
1857
1866
|
for (const [e, t] of Object.entries(s))
|
|
1858
1867
|
if (t.identifier === i)
|
|
1859
1868
|
return [t, e];
|
|
1860
|
-
}, hn =
|
|
1861
|
-
const { values: i, setFieldValue: e } = me(), [t, n] =
|
|
1862
|
-
|
|
1869
|
+
}, hn = S(function() {
|
|
1870
|
+
const { values: i, setFieldValue: e } = me(), [t, n] = wi(mn, i.fields, ft), { showInfo: o } = gi();
|
|
1871
|
+
we(() => {
|
|
1863
1872
|
n({ type: "update", state: ft(i.fields) });
|
|
1864
1873
|
}, [n, i.fields]);
|
|
1865
|
-
const l =
|
|
1874
|
+
const l = T((f) => {
|
|
1866
1875
|
f.type === "SECTION" && n({ type: "hold", fieldId: f.draggableId });
|
|
1867
|
-
}, []), c =
|
|
1876
|
+
}, []), c = T(
|
|
1868
1877
|
(f) => {
|
|
1869
|
-
const { source: d, destination: u, type:
|
|
1870
|
-
if (n({ type: "release" }), !u ||
|
|
1878
|
+
const { source: d, destination: u, type: h, reason: p, draggableId: g } = f;
|
|
1879
|
+
if (n({ type: "release" }), !u || p === "CANCEL")
|
|
1871
1880
|
return;
|
|
1872
|
-
if (
|
|
1881
|
+
if (h === "ROOT") {
|
|
1873
1882
|
const L = t[g];
|
|
1874
1883
|
if (!L)
|
|
1875
1884
|
throw new Error("Could not find section context.");
|
|
@@ -1884,9 +1893,9 @@ const Pe = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), kt = (s,
|
|
|
1884
1893
|
description: "Sections with conditions must be below the fields they reference."
|
|
1885
1894
|
}), e("fields", je(i.fields, d.index, P));
|
|
1886
1895
|
}
|
|
1887
|
-
if (
|
|
1896
|
+
if (h !== "SECTION")
|
|
1888
1897
|
throw new Error("Unexpected droppable type.");
|
|
1889
|
-
const [x, z] = mt(i.fields, d.droppableId) ?? [], [F,
|
|
1898
|
+
const [x, z] = mt(i.fields, d.droppableId) ?? [], [F, w] = mt(i.fields, u.droppableId) ?? [];
|
|
1890
1899
|
if (!(x != null && x.fields) || !F)
|
|
1891
1900
|
throw new Error("Could not find section with fields.");
|
|
1892
1901
|
if (x.identifier === F.identifier)
|
|
@@ -1899,13 +1908,13 @@ const Pe = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), kt = (s,
|
|
|
1899
1908
|
if (!L)
|
|
1900
1909
|
throw new Error("Could not find field to reorder.");
|
|
1901
1910
|
e(`fields.${z}.fields`, Se(x.fields, d.index)).then(), e(
|
|
1902
|
-
`fields.${
|
|
1911
|
+
`fields.${w}.fields`,
|
|
1903
1912
|
Tt(F.fields, u.index, L)
|
|
1904
1913
|
).then();
|
|
1905
1914
|
}
|
|
1906
1915
|
},
|
|
1907
1916
|
[i.fields, e, t, o]
|
|
1908
|
-
), a =
|
|
1917
|
+
), a = v(
|
|
1909
1918
|
() => ({
|
|
1910
1919
|
index: i.fields.length,
|
|
1911
1920
|
parentPath: "fields",
|
|
@@ -1949,28 +1958,28 @@ const Pe = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), kt = (s,
|
|
|
1949
1958
|
maxLength: 100,
|
|
1950
1959
|
required: !0,
|
|
1951
1960
|
identifier: "title"
|
|
1952
|
-
}), yn = { formId: Oe, placeholder: "Give your form a title." },
|
|
1961
|
+
}), yn = { formId: Oe, placeholder: "Give your form a title." }, wn = new be({
|
|
1953
1962
|
label: "Description",
|
|
1954
1963
|
minLength: 0,
|
|
1955
1964
|
maxLength: 1e3,
|
|
1956
1965
|
required: !1,
|
|
1957
1966
|
identifier: "description"
|
|
1958
|
-
}),
|
|
1967
|
+
}), vn = { formId: Oe, placeholder: "Explain the purpose of this form." }, xn = () => {
|
|
1959
1968
|
alert("This is a form preview, your data will not be saved.");
|
|
1960
|
-
},
|
|
1961
|
-
|
|
1962
|
-
const { onCancel: e, onSave: t, revision: n } = s, o = n ? "Edit form" : "Create a new form", { heading: l = o } = s, c =
|
|
1969
|
+
}, _n = S(
|
|
1970
|
+
ve((s, i) => {
|
|
1971
|
+
const { onCancel: e, onSave: t, revision: n } = s, o = n ? "Edit form" : "Create a new form", { heading: l = o } = s, c = T((p) => {
|
|
1963
1972
|
const g = {};
|
|
1964
|
-
if (
|
|
1973
|
+
if (p.title || (g.title = "Title is required."), (!p.fields || p.fields.length === 0) && (g.fields = "At least one field is required."), Ve(g))
|
|
1965
1974
|
return g;
|
|
1966
1975
|
}, []), a = Qe({
|
|
1967
1976
|
initialValues: Oi(n) ?? gn,
|
|
1968
1977
|
validate: c,
|
|
1969
|
-
onSubmit: (
|
|
1978
|
+
onSubmit: (p) => t(p),
|
|
1970
1979
|
// only validate the entire for on submit
|
|
1971
1980
|
validateOnChange: !1,
|
|
1972
1981
|
validateOnBlur: !1
|
|
1973
|
-
}), f =
|
|
1982
|
+
}), f = v(() => Pt(a.values), [a.values]), d = Pe(bn, yn), u = Pe(wn, vn), h = v(
|
|
1974
1983
|
() => typeof l == "object" ? l : /* @__PURE__ */ r(De, { children: l }),
|
|
1975
1984
|
[l]
|
|
1976
1985
|
);
|
|
@@ -1980,7 +1989,7 @@ const Pe = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), kt = (s,
|
|
|
1980
1989
|
/* @__PURE__ */ r(X.Trigger, { value: "preview", children: "Preview" })
|
|
1981
1990
|
] }),
|
|
1982
1991
|
/* @__PURE__ */ b(X.Content, { value: "edit", children: [
|
|
1983
|
-
|
|
1992
|
+
h,
|
|
1984
1993
|
/* @__PURE__ */ b(D, { children: [
|
|
1985
1994
|
"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",
|
|
1986
1995
|
" ",
|
|
@@ -2013,7 +2022,7 @@ export {
|
|
|
2013
2022
|
Di as DateInput,
|
|
2014
2023
|
Q as FieldSection,
|
|
2015
2024
|
Vn as FormBrowser,
|
|
2016
|
-
|
|
2025
|
+
_n as FormBuilder,
|
|
2017
2026
|
ot as FormRenderer,
|
|
2018
2027
|
kn as FormSubmissionBrowser,
|
|
2019
2028
|
Pn as FormSubmissionViewer,
|
|
@@ -2024,13 +2033,13 @@ export {
|
|
|
2024
2033
|
Y as NumberField,
|
|
2025
2034
|
ki as NumberInput,
|
|
2026
2035
|
Dn as PatchField,
|
|
2027
|
-
|
|
2036
|
+
$n as PatchFormProvider,
|
|
2028
2037
|
Ee as SelectField,
|
|
2029
2038
|
Mi as SelectInput,
|
|
2030
2039
|
ge as StringField,
|
|
2031
|
-
|
|
2040
|
+
$i as StringInput,
|
|
2032
2041
|
be as TextField,
|
|
2033
|
-
|
|
2042
|
+
_i as TextInput,
|
|
2034
2043
|
Me as deserialize,
|
|
2035
2044
|
Lt as deserializeField,
|
|
2036
2045
|
Pt as formRevisionToSchema,
|