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