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