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