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