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