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