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