@overmap-ai/forms 1.0.39-field-groups.1 → 1.0.39-field-groups.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/form/builder/context.d.ts +1 -1
- package/dist/forms.js +237 -237
- package/dist/forms.umd.cjs +2 -2
- package/package.json +1 -1
package/dist/forms.js
CHANGED
|
@@ -13,11 +13,11 @@ import { v4 as G } from "uuid";
|
|
|
13
13
|
import { DragDropContext as Fs, Droppable as Ps, Draggable as Bs } from "@hello-pangea/dnd";
|
|
14
14
|
import { saveAs as Ma } from "file-saver";
|
|
15
15
|
import { DecodeHintType as ks, useZxing as Ls } from "react-zxing";
|
|
16
|
+
import bi from "@dagrejs/dagre";
|
|
16
17
|
import { DirectedGraph as zs } from "graphology";
|
|
17
18
|
import { bfsFromNode as Us } from "graphology-traversal";
|
|
18
19
|
import Va from "lodash.get";
|
|
19
20
|
import Hs from "lodash.set";
|
|
20
|
-
import bi from "@dagrejs/dagre";
|
|
21
21
|
/**
|
|
22
22
|
* @license lucide-react v0.542.0 - ISC
|
|
23
23
|
*
|
|
@@ -25964,207 +25964,6 @@ D(pr, "deserialize", (t) => {
|
|
|
25964
25964
|
return new pr({ ...t, fields: n, conditions: i });
|
|
25965
25965
|
});
|
|
25966
25966
|
let it = pr;
|
|
25967
|
-
const n0 = (r, e, t = {}) => {
|
|
25968
|
-
const { conditions: n = !1 } = t, i = r.get(e.identifier);
|
|
25969
|
-
if (!i)
|
|
25970
|
-
throw new Error(
|
|
25971
|
-
`Attempting to reseed serialized section with identifier ${e.identifier} which is not present in the reseeded identifier map`
|
|
25972
|
-
);
|
|
25973
|
-
const a = /* @__PURE__ */ new Map(), o = e.fields.map((l) => {
|
|
25974
|
-
const c = G(), { image: u, ...f } = l;
|
|
25975
|
-
return a.set(l.identifier, c), {
|
|
25976
|
-
...f,
|
|
25977
|
-
identifier: c
|
|
25978
|
-
};
|
|
25979
|
-
}), s = {};
|
|
25980
|
-
if (n)
|
|
25981
|
-
for (const [l, c] of Object.entries(e.conditions ?? {})) {
|
|
25982
|
-
const u = r.get(l);
|
|
25983
|
-
if (!u) continue;
|
|
25984
|
-
const f = c.map((d) => {
|
|
25985
|
-
const h = a.get(d.fieldId);
|
|
25986
|
-
if (!h)
|
|
25987
|
-
throw new Error(
|
|
25988
|
-
`Serialized condition referencing undefined field with identifier: ${d.fieldId}`
|
|
25989
|
-
);
|
|
25990
|
-
return { ...d, fieldId: h };
|
|
25991
|
-
});
|
|
25992
|
-
s[u] = f;
|
|
25993
|
-
}
|
|
25994
|
-
return {
|
|
25995
|
-
...e,
|
|
25996
|
-
identifier: i,
|
|
25997
|
-
conditions: s,
|
|
25998
|
-
fields: o
|
|
25999
|
-
};
|
|
26000
|
-
}, i0 = (r, e = {}) => {
|
|
26001
|
-
const t = new Map(
|
|
26002
|
-
r.map((n) => [n.identifier, G()])
|
|
26003
|
-
);
|
|
26004
|
-
return r.map((n) => n0(t, n, e));
|
|
26005
|
-
}, is = (r, e) => {
|
|
26006
|
-
const t = {}, n = r.filter((i) => i instanceof it);
|
|
26007
|
-
for (const i of r)
|
|
26008
|
-
if (i instanceof it) {
|
|
26009
|
-
const a = n.filter((s) => i.identifier in s.conditions);
|
|
26010
|
-
if (a.length > 0 && !a.some((s) => {
|
|
26011
|
-
const l = s.getConditions(i.identifier);
|
|
26012
|
-
return new gi(l).applyConditions(e);
|
|
26013
|
-
}))
|
|
26014
|
-
continue;
|
|
26015
|
-
const o = i.getErrors(e);
|
|
26016
|
-
Object.assign(t, o);
|
|
26017
|
-
} else {
|
|
26018
|
-
if (!(i instanceof Je))
|
|
26019
|
-
throw new Error("Invalid field type");
|
|
26020
|
-
const a = i.identifier, o = i.getError(Va(e, a));
|
|
26021
|
-
o && Hs(t, a, o);
|
|
26022
|
-
}
|
|
26023
|
-
return t;
|
|
26024
|
-
}, V0 = async (r) => {
|
|
26025
|
-
const e = {}, t = [];
|
|
26026
|
-
for (const n of r) {
|
|
26027
|
-
const { fields: i } = n, a = [];
|
|
26028
|
-
for (const o of i) {
|
|
26029
|
-
if (o.image) {
|
|
26030
|
-
if (o.image instanceof Promise)
|
|
26031
|
-
try {
|
|
26032
|
-
e[o.identifier] = await o.image;
|
|
26033
|
-
} catch (s) {
|
|
26034
|
-
console.error("Failed to get image from promise", s);
|
|
26035
|
-
}
|
|
26036
|
-
else
|
|
26037
|
-
e[o.identifier] = o.image;
|
|
26038
|
-
delete o.image;
|
|
26039
|
-
}
|
|
26040
|
-
a.push(o);
|
|
26041
|
-
}
|
|
26042
|
-
t.push({ ...n, fields: a });
|
|
26043
|
-
}
|
|
26044
|
-
return { fields: t, images: e };
|
|
26045
|
-
};
|
|
26046
|
-
async function F0(r) {
|
|
26047
|
-
const e = {};
|
|
26048
|
-
for (const [t, n] of Object.entries(r))
|
|
26049
|
-
e[t] = await Promise.all(n);
|
|
26050
|
-
return e;
|
|
26051
|
-
}
|
|
26052
|
-
class rr extends Gr {
|
|
26053
|
-
constructor(t) {
|
|
26054
|
-
super();
|
|
26055
|
-
D(this, "fieldSections");
|
|
26056
|
-
// Fields
|
|
26057
|
-
D(this, "fieldObserver", () => {
|
|
26058
|
-
this.notify(this);
|
|
26059
|
-
});
|
|
26060
|
-
D(this, "initFields", (t) => {
|
|
26061
|
-
for (const n of t) n.observe(this.fieldObserver);
|
|
26062
|
-
return t;
|
|
26063
|
-
});
|
|
26064
|
-
this.fieldSections = this.initFields(t);
|
|
26065
|
-
}
|
|
26066
|
-
serialize() {
|
|
26067
|
-
return this.fieldSections.map((t) => t.serialize());
|
|
26068
|
-
}
|
|
26069
|
-
static deserialize(t) {
|
|
26070
|
-
return new rr(t.map(it.deserialize));
|
|
26071
|
-
}
|
|
26072
|
-
static reseedFieldSections(t, n) {
|
|
26073
|
-
return i0(t, n);
|
|
26074
|
-
}
|
|
26075
|
-
getFields() {
|
|
26076
|
-
return this.fieldSections.flatMap((t) => t.getFields());
|
|
26077
|
-
}
|
|
26078
|
-
getFieldSections() {
|
|
26079
|
-
return this.fieldSections;
|
|
26080
|
-
}
|
|
26081
|
-
addFieldSection(t, n) {
|
|
26082
|
-
const i = [...this.fieldSections];
|
|
26083
|
-
i.splice(n ?? this.fieldSections.length, 0, t), this.fieldSections = this.initFields(i), this.notify(this);
|
|
26084
|
-
}
|
|
26085
|
-
removeFieldSection(t) {
|
|
26086
|
-
const n = this.fieldSections.filter((i) => i.identifier !== t.identifier);
|
|
26087
|
-
for (const i of n)
|
|
26088
|
-
i.removeConditional(i.identifier);
|
|
26089
|
-
this.fieldSections = this.initFields(n), this.notify(this);
|
|
26090
|
-
}
|
|
26091
|
-
moveFieldSection(t, n) {
|
|
26092
|
-
const i = [...this.fieldSections], [a] = i.splice(t, 1);
|
|
26093
|
-
i.splice(n, 0, a), this.fieldSections = this.initFields(i), this.notify(this);
|
|
26094
|
-
}
|
|
26095
|
-
getSectionDependencyGraph() {
|
|
26096
|
-
const t = new zs({ type: "directed" });
|
|
26097
|
-
for (const n of this.fieldSections)
|
|
26098
|
-
for (const i of Object.keys(n.conditions))
|
|
26099
|
-
t.mergeEdge(n.identifier, i);
|
|
26100
|
-
return t;
|
|
26101
|
-
}
|
|
26102
|
-
getDependenciesOfSection(t) {
|
|
26103
|
-
const n = this.getSectionDependencyGraph(), i = new Map(
|
|
26104
|
-
this.fieldSections.map((o) => [o.identifier, o])
|
|
26105
|
-
), a = [];
|
|
26106
|
-
return Us(
|
|
26107
|
-
n,
|
|
26108
|
-
t,
|
|
26109
|
-
(o, s, l) => {
|
|
26110
|
-
a.push(i.get(o));
|
|
26111
|
-
},
|
|
26112
|
-
{ mode: "in" }
|
|
26113
|
-
), a;
|
|
26114
|
-
}
|
|
26115
|
-
// Field Values methods
|
|
26116
|
-
cleanValues(t) {
|
|
26117
|
-
return mi(this.getFields(), t);
|
|
26118
|
-
}
|
|
26119
|
-
cleanSerializedValues(t) {
|
|
26120
|
-
return es(this.getFields(), t);
|
|
26121
|
-
}
|
|
26122
|
-
deserializeValues(t, n) {
|
|
26123
|
-
return Y1(this.getFields(), t, n);
|
|
26124
|
-
}
|
|
26125
|
-
serializeValues(t, n) {
|
|
26126
|
-
return j1(this.getFields(), t, n);
|
|
26127
|
-
}
|
|
26128
|
-
initializeValues(t) {
|
|
26129
|
-
return Q1(this.getFields(), t);
|
|
26130
|
-
}
|
|
26131
|
-
validateValues(t) {
|
|
26132
|
-
return is(this.getFieldSections(), t);
|
|
26133
|
-
}
|
|
26134
|
-
deserializeConditions(t) {
|
|
26135
|
-
return Ko(this.getFields(), t);
|
|
26136
|
-
}
|
|
26137
|
-
cleanConditions(t) {
|
|
26138
|
-
return Jo(this.getFields(), t);
|
|
26139
|
-
}
|
|
26140
|
-
serializeConditions(t) {
|
|
26141
|
-
return W1(this.getFields(), t);
|
|
26142
|
-
}
|
|
26143
|
-
cleanSerializedConditions(t) {
|
|
26144
|
-
return Qo(this.getFields(), t);
|
|
26145
|
-
}
|
|
26146
|
-
changedFieldValues(t, n) {
|
|
26147
|
-
return J1(this.getFields(), t, n);
|
|
26148
|
-
}
|
|
26149
|
-
unchangedFieldValues(t, n) {
|
|
26150
|
-
return e0(this.getFields(), t, n);
|
|
26151
|
-
}
|
|
26152
|
-
areValuesEqual(t, n) {
|
|
26153
|
-
return ts(this.getFields(), t, n);
|
|
26154
|
-
}
|
|
26155
|
-
areValuesBlank(t) {
|
|
26156
|
-
return t0(this.getFields(), t);
|
|
26157
|
-
}
|
|
26158
|
-
blankValues() {
|
|
26159
|
-
return rs(this.getFields());
|
|
26160
|
-
}
|
|
26161
|
-
extractFilesAndPromisesFromFieldValues(t) {
|
|
26162
|
-
return Z1(this.getFields(), t);
|
|
26163
|
-
}
|
|
26164
|
-
insertFilesAndPromisesToFieldValues(t, n) {
|
|
26165
|
-
return K1(this.getFields(), t, n);
|
|
26166
|
-
}
|
|
26167
|
-
}
|
|
26168
25967
|
const pt = Ur({}), fn = U((r) => {
|
|
26169
25968
|
const { children: e, variant: t, size: n, accentColor: i, onSelectFieldType: a, ...o } = r, s = ae(() => {
|
|
26170
25969
|
const l = {
|
|
@@ -26306,7 +26105,7 @@ const Ci = (r) => {
|
|
|
26306
26105
|
maxRating: 5
|
|
26307
26106
|
});
|
|
26308
26107
|
}
|
|
26309
|
-
},
|
|
26108
|
+
}, is = (r) => {
|
|
26310
26109
|
switch (r.type) {
|
|
26311
26110
|
case "text":
|
|
26312
26111
|
return new ln({ id: G(), conditionValue: void 0, conditionModifier: "equals", field: r });
|
|
@@ -26416,7 +26215,7 @@ const Ci = (r) => {
|
|
|
26416
26215
|
field: r
|
|
26417
26216
|
});
|
|
26418
26217
|
}
|
|
26419
|
-
},
|
|
26218
|
+
}, as = (r, e) => {
|
|
26420
26219
|
switch (r) {
|
|
26421
26220
|
case "checkbox-list":
|
|
26422
26221
|
return $t.getFieldCreationSchema(e);
|
|
@@ -26443,7 +26242,7 @@ const Ci = (r) => {
|
|
|
26443
26242
|
default:
|
|
26444
26243
|
return;
|
|
26445
26244
|
}
|
|
26446
|
-
},
|
|
26245
|
+
}, os = U((r) => {
|
|
26447
26246
|
const { popoverInputs: e, ...t } = r;
|
|
26448
26247
|
return /* @__PURE__ */ A(Te.Root, { children: [
|
|
26449
26248
|
/* @__PURE__ */ p(Te.Trigger, { asChild: !0, children: /* @__PURE__ */ A(L, { variant: "soft", type: "button", size: "sm", accentColor: "base", children: [
|
|
@@ -26453,8 +26252,8 @@ const Ci = (r) => {
|
|
|
26453
26252
|
/* @__PURE__ */ p(Te.Content, { size: "sm", ...t, children: /* @__PURE__ */ p("div", { className: At("flex w-full max-w-[350px] flex-col", wi({ size: "sm" })), children: e }) })
|
|
26454
26253
|
] });
|
|
26455
26254
|
});
|
|
26456
|
-
|
|
26457
|
-
const
|
|
26255
|
+
os.displayName = "FieldSettingsPopover";
|
|
26256
|
+
const ss = U((r) => {
|
|
26458
26257
|
const { parentPath: e, fieldIndex: t, field: n } = r, i = Kn(), { disableRequiredFields: a } = se(pt), [o, s] = ke(void 0);
|
|
26459
26258
|
ct(() => {
|
|
26460
26259
|
n.image instanceof Promise ? n.image.then(s).catch(console.error) : s(n.image);
|
|
@@ -26462,7 +26261,7 @@ const ls = U((r) => {
|
|
|
26462
26261
|
const l = I(() => {
|
|
26463
26262
|
n.setOptions({ image: void 0 });
|
|
26464
26263
|
}, [n]), [c, u] = ae(() => {
|
|
26465
|
-
const m = [], w = [], _ =
|
|
26264
|
+
const m = [], w = [], _ = as(n.type, `${e}.${t}`) ?? [];
|
|
26466
26265
|
for (const C of _)
|
|
26467
26266
|
C.showDirectly ? m.push(C.field) : w.push(C.field);
|
|
26468
26267
|
return [m, w];
|
|
@@ -26491,7 +26290,7 @@ const ls = U((r) => {
|
|
|
26491
26290
|
/* @__PURE__ */ p(ve, { size: "sm", accentColor: "base", children: "Required" })
|
|
26492
26291
|
] })
|
|
26493
26292
|
] }),
|
|
26494
|
-
h && /* @__PURE__ */ p(
|
|
26293
|
+
h && /* @__PURE__ */ p(os, { popoverInputs: d, align: "end" })
|
|
26495
26294
|
] }),
|
|
26496
26295
|
o && /* @__PURE__ */ A("div", { className: "group relative inline-block w-full min-w-[300px]", children: [
|
|
26497
26296
|
/* @__PURE__ */ p(
|
|
@@ -26542,7 +26341,7 @@ const ls = U((r) => {
|
|
|
26542
26341
|
c.length > 0 && /* @__PURE__ */ p("div", { className: At("w-full", wi({ size: "sm" })), children: f })
|
|
26543
26342
|
] });
|
|
26544
26343
|
});
|
|
26545
|
-
|
|
26344
|
+
ss.displayName = "FieldBuilder";
|
|
26546
26345
|
const _i = U((r) => {
|
|
26547
26346
|
const { field: e, fieldSection: t, fieldIndex: n, sectionIndex: i } = r, a = Hr(null), o = `fields.${i}.fields`, s = I(
|
|
26548
26347
|
(g) => {
|
|
@@ -26587,7 +26386,7 @@ const _i = U((r) => {
|
|
|
26587
26386
|
t.removeField(e);
|
|
26588
26387
|
}, [e, t]);
|
|
26589
26388
|
return /* @__PURE__ */ A(dt, { className: "flex items-center justify-between gap-4 w-full", size: "sm", children: [
|
|
26590
|
-
/* @__PURE__ */ p(
|
|
26389
|
+
/* @__PURE__ */ p(ss, { fieldIndex: n, field: e, parentPath: o }),
|
|
26591
26390
|
/* @__PURE__ */ A(ue, { className: "flex-col gap-0.5 flex", variant: "ghost", accentColor: "base", size: "sm", children: [
|
|
26592
26391
|
/* @__PURE__ */ p(fn, { onSelectFieldType: s, size: "sm", children: /* @__PURE__ */ p(te, { type: "button", children: /* @__PURE__ */ p(T, { icon: ut }) }) }),
|
|
26593
26392
|
/* @__PURE__ */ p(te, { type: "button", onClick: f, children: /* @__PURE__ */ p(T, { icon: Xa }) }),
|
|
@@ -26611,7 +26410,7 @@ const Ai = U((r) => {
|
|
|
26611
26410
|
] });
|
|
26612
26411
|
});
|
|
26613
26412
|
Ai.displayName = "IssueDataFilterMenu";
|
|
26614
|
-
const
|
|
26413
|
+
const ls = U((r) => {
|
|
26615
26414
|
const { children: e, variant: t, size: n, accentColor: i, fieldSections: a, onSelectFieldCondition: o, ...s } = r;
|
|
26616
26415
|
return /* @__PURE__ */ A(R.Root, { ...s, children: [
|
|
26617
26416
|
/* @__PURE__ */ p(R.ClickTrigger, { children: e }),
|
|
@@ -26621,13 +26420,13 @@ const cs = U((r) => {
|
|
|
26621
26420
|
] }, l.identifier)) })
|
|
26622
26421
|
] });
|
|
26623
26422
|
});
|
|
26624
|
-
|
|
26625
|
-
const
|
|
26423
|
+
ls.displayName = "IssueDataFilterMenu";
|
|
26424
|
+
const cs = U((r) => {
|
|
26626
26425
|
const { id: e, sourceX: t, sourceY: n, targetX: i, targetY: a, style: o, markerEnd: s, data: l } = r, { targetSection: c, sourceSection: u, layoutDirection: f } = l, d = ae(() => u.getConditions(c.identifier), [u, c.identifier]), h = I(() => {
|
|
26627
26426
|
u.removeConditional(c.identifier);
|
|
26628
26427
|
}, [u, c.identifier]), v = I(
|
|
26629
26428
|
(_) => {
|
|
26630
|
-
u.addCondition(c.identifier,
|
|
26429
|
+
u.addCondition(c.identifier, is(_));
|
|
26631
26430
|
},
|
|
26632
26431
|
[u, c.identifier]
|
|
26633
26432
|
), g = I(
|
|
@@ -26696,8 +26495,8 @@ const us = U((r) => {
|
|
|
26696
26495
|
) })
|
|
26697
26496
|
] });
|
|
26698
26497
|
});
|
|
26699
|
-
|
|
26700
|
-
const
|
|
26498
|
+
cs.displayName = "FieldSectionConditionEdgeComponent";
|
|
26499
|
+
const us = U((r) => {
|
|
26701
26500
|
const { data: e, selected: t } = r, { fieldSection: n, index: i, layoutDirection: a } = e, { fieldSchema: o } = se(pt), s = I(() => {
|
|
26702
26501
|
o.removeFieldSection(n);
|
|
26703
26502
|
}, [o, n]), l = I(
|
|
@@ -26805,12 +26604,12 @@ const fs = U((r) => {
|
|
|
26805
26604
|
}
|
|
26806
26605
|
);
|
|
26807
26606
|
});
|
|
26808
|
-
|
|
26809
|
-
const
|
|
26810
|
-
fieldSection:
|
|
26811
|
-
},
|
|
26812
|
-
fieldSectionCondition:
|
|
26813
|
-
},
|
|
26607
|
+
us.displayName = "CustomNode";
|
|
26608
|
+
const n0 = {
|
|
26609
|
+
fieldSection: us
|
|
26610
|
+
}, i0 = {
|
|
26611
|
+
fieldSectionCondition: cs
|
|
26612
|
+
}, a0 = (r, e, t) => {
|
|
26814
26613
|
const n = new bi.graphlib.Graph().setDefaultEdgeLabel(() => ({}));
|
|
26815
26614
|
return n.setGraph({ rankdir: t, nodesep: 200, edgesep: 500, ranksep: 500 }), e.forEach(
|
|
26816
26615
|
(i) => n.setEdge(i.source, i.target, {
|
|
@@ -26836,9 +26635,9 @@ const a0 = {
|
|
|
26836
26635
|
}),
|
|
26837
26636
|
e
|
|
26838
26637
|
];
|
|
26839
|
-
},
|
|
26638
|
+
}, o0 = {
|
|
26840
26639
|
hideAttribution: !0
|
|
26841
|
-
},
|
|
26640
|
+
}, fs = U(() => {
|
|
26842
26641
|
var N;
|
|
26843
26642
|
const { errors: r } = Na(), { handleSubmit: e } = Ta(), { onSave: t, onCancel: n } = se(pt), { fieldSchema: i } = se(pt), a = Hr(null), [o, s] = ke(), [l, c] = ke("TB");
|
|
26844
26643
|
Ss(() => {
|
|
@@ -26886,7 +26685,7 @@ const a0 = {
|
|
|
26886
26685
|
}, [u, h]), ct(() => {
|
|
26887
26686
|
y(f);
|
|
26888
26687
|
}, [f, y]);
|
|
26889
|
-
const [w, _] = ae(() =>
|
|
26688
|
+
const [w, _] = ae(() => a0(d, g, l), [g, l, d]), C = I(() => {
|
|
26890
26689
|
i.addFieldSection(new it({ identifier: G(), fields: [] }));
|
|
26891
26690
|
}, [i]), E = I(
|
|
26892
26691
|
(M) => {
|
|
@@ -26917,14 +26716,14 @@ const a0 = {
|
|
|
26917
26716
|
onNodesChange: v,
|
|
26918
26717
|
edges: _,
|
|
26919
26718
|
onEdgesChange: m,
|
|
26920
|
-
nodeTypes:
|
|
26921
|
-
edgeTypes:
|
|
26719
|
+
nodeTypes: n0,
|
|
26720
|
+
edgeTypes: i0,
|
|
26922
26721
|
onConnect: E,
|
|
26923
26722
|
attributionPosition: "bottom-left",
|
|
26924
26723
|
fitView: !0,
|
|
26925
26724
|
minZoom: 0,
|
|
26926
26725
|
isValidConnection: O,
|
|
26927
|
-
proOptions:
|
|
26726
|
+
proOptions: o0
|
|
26928
26727
|
}
|
|
26929
26728
|
),
|
|
26930
26729
|
/* @__PURE__ */ p(yn, { position: "top-left", children: /* @__PURE__ */ p(ue, { className: "flex items-center justify-end gap-2", size: "sm", children: /* @__PURE__ */ A(L, { type: "button", variant: "surface", onClick: C, children: [
|
|
@@ -26962,13 +26761,214 @@ const a0 = {
|
|
|
26962
26761
|
!!((N = r.fields) != null && N.message) && /* @__PURE__ */ p(ve, { size: "xs", accentColor: "danger", children: r.fields.message })
|
|
26963
26762
|
] });
|
|
26964
26763
|
});
|
|
26965
|
-
|
|
26764
|
+
fs.displayName = "FormBuilderFlowBuilder";
|
|
26765
|
+
const s0 = (r, e, t = {}) => {
|
|
26766
|
+
const { conditions: n = !1 } = t, i = r.get(e.identifier);
|
|
26767
|
+
if (!i)
|
|
26768
|
+
throw new Error(
|
|
26769
|
+
`Attempting to reseed serialized section with identifier ${e.identifier} which is not present in the reseeded identifier map`
|
|
26770
|
+
);
|
|
26771
|
+
const a = /* @__PURE__ */ new Map(), o = e.fields.map((l) => {
|
|
26772
|
+
const c = G(), { image: u, ...f } = l;
|
|
26773
|
+
return a.set(l.identifier, c), {
|
|
26774
|
+
...f,
|
|
26775
|
+
identifier: c
|
|
26776
|
+
};
|
|
26777
|
+
}), s = {};
|
|
26778
|
+
if (n)
|
|
26779
|
+
for (const [l, c] of Object.entries(e.conditions ?? {})) {
|
|
26780
|
+
const u = r.get(l);
|
|
26781
|
+
if (!u) continue;
|
|
26782
|
+
const f = c.map((d) => {
|
|
26783
|
+
const h = a.get(d.fieldId);
|
|
26784
|
+
if (!h)
|
|
26785
|
+
throw new Error(
|
|
26786
|
+
`Serialized condition referencing undefined field with identifier: ${d.fieldId}`
|
|
26787
|
+
);
|
|
26788
|
+
return { ...d, fieldId: h };
|
|
26789
|
+
});
|
|
26790
|
+
s[u] = f;
|
|
26791
|
+
}
|
|
26792
|
+
return {
|
|
26793
|
+
...e,
|
|
26794
|
+
identifier: i,
|
|
26795
|
+
conditions: s,
|
|
26796
|
+
fields: o
|
|
26797
|
+
};
|
|
26798
|
+
}, l0 = (r, e = {}) => {
|
|
26799
|
+
const t = new Map(
|
|
26800
|
+
r.map((n) => [n.identifier, G()])
|
|
26801
|
+
);
|
|
26802
|
+
return r.map((n) => s0(t, n, e));
|
|
26803
|
+
}, ds = (r, e) => {
|
|
26804
|
+
const t = {}, n = r.filter((i) => i instanceof it);
|
|
26805
|
+
for (const i of r)
|
|
26806
|
+
if (i instanceof it) {
|
|
26807
|
+
const a = n.filter((s) => i.identifier in s.conditions);
|
|
26808
|
+
if (a.length > 0 && !a.some((s) => {
|
|
26809
|
+
const l = s.getConditions(i.identifier);
|
|
26810
|
+
return new gi(l).applyConditions(e);
|
|
26811
|
+
}))
|
|
26812
|
+
continue;
|
|
26813
|
+
const o = i.getErrors(e);
|
|
26814
|
+
Object.assign(t, o);
|
|
26815
|
+
} else {
|
|
26816
|
+
if (!(i instanceof Je))
|
|
26817
|
+
throw new Error("Invalid field type");
|
|
26818
|
+
const a = i.identifier, o = i.getError(Va(e, a));
|
|
26819
|
+
o && Hs(t, a, o);
|
|
26820
|
+
}
|
|
26821
|
+
return t;
|
|
26822
|
+
}, V0 = async (r) => {
|
|
26823
|
+
const e = {}, t = [];
|
|
26824
|
+
for (const n of r) {
|
|
26825
|
+
const { fields: i } = n, a = [];
|
|
26826
|
+
for (const o of i) {
|
|
26827
|
+
if (o.image) {
|
|
26828
|
+
if (o.image instanceof Promise)
|
|
26829
|
+
try {
|
|
26830
|
+
e[o.identifier] = await o.image;
|
|
26831
|
+
} catch (s) {
|
|
26832
|
+
console.error("Failed to get image from promise", s);
|
|
26833
|
+
}
|
|
26834
|
+
else
|
|
26835
|
+
e[o.identifier] = o.image;
|
|
26836
|
+
delete o.image;
|
|
26837
|
+
}
|
|
26838
|
+
a.push(o);
|
|
26839
|
+
}
|
|
26840
|
+
t.push({ ...n, fields: a });
|
|
26841
|
+
}
|
|
26842
|
+
return { fields: t, images: e };
|
|
26843
|
+
};
|
|
26844
|
+
async function F0(r) {
|
|
26845
|
+
const e = {};
|
|
26846
|
+
for (const [t, n] of Object.entries(r))
|
|
26847
|
+
e[t] = await Promise.all(n);
|
|
26848
|
+
return e;
|
|
26849
|
+
}
|
|
26850
|
+
class rr extends Gr {
|
|
26851
|
+
constructor(t) {
|
|
26852
|
+
super();
|
|
26853
|
+
D(this, "fieldSections");
|
|
26854
|
+
// Fields
|
|
26855
|
+
D(this, "fieldObserver", () => {
|
|
26856
|
+
this.notify(this);
|
|
26857
|
+
});
|
|
26858
|
+
D(this, "initFields", (t) => {
|
|
26859
|
+
for (const n of t) n.observe(this.fieldObserver);
|
|
26860
|
+
return t;
|
|
26861
|
+
});
|
|
26862
|
+
this.fieldSections = this.initFields(t);
|
|
26863
|
+
}
|
|
26864
|
+
serialize() {
|
|
26865
|
+
return this.fieldSections.map((t) => t.serialize());
|
|
26866
|
+
}
|
|
26867
|
+
static deserialize(t) {
|
|
26868
|
+
return new rr(t.map(it.deserialize));
|
|
26869
|
+
}
|
|
26870
|
+
static reseedFieldSections(t, n) {
|
|
26871
|
+
return l0(t, n);
|
|
26872
|
+
}
|
|
26873
|
+
getFields() {
|
|
26874
|
+
return this.fieldSections.flatMap((t) => t.getFields());
|
|
26875
|
+
}
|
|
26876
|
+
getFieldSections() {
|
|
26877
|
+
return this.fieldSections;
|
|
26878
|
+
}
|
|
26879
|
+
addFieldSection(t, n) {
|
|
26880
|
+
const i = [...this.fieldSections];
|
|
26881
|
+
i.splice(n ?? this.fieldSections.length, 0, t), this.fieldSections = this.initFields(i), this.notify(this);
|
|
26882
|
+
}
|
|
26883
|
+
removeFieldSection(t) {
|
|
26884
|
+
const n = this.fieldSections.filter((i) => i.identifier !== t.identifier);
|
|
26885
|
+
for (const i of n)
|
|
26886
|
+
i.removeConditional(i.identifier);
|
|
26887
|
+
this.fieldSections = this.initFields(n), this.notify(this);
|
|
26888
|
+
}
|
|
26889
|
+
moveFieldSection(t, n) {
|
|
26890
|
+
const i = [...this.fieldSections], [a] = i.splice(t, 1);
|
|
26891
|
+
i.splice(n, 0, a), this.fieldSections = this.initFields(i), this.notify(this);
|
|
26892
|
+
}
|
|
26893
|
+
getSectionDependencyGraph() {
|
|
26894
|
+
const t = new zs({ type: "directed" });
|
|
26895
|
+
for (const n of this.fieldSections)
|
|
26896
|
+
for (const i of Object.keys(n.conditions))
|
|
26897
|
+
t.mergeEdge(n.identifier, i);
|
|
26898
|
+
return t;
|
|
26899
|
+
}
|
|
26900
|
+
getDependenciesOfSection(t) {
|
|
26901
|
+
const n = this.getSectionDependencyGraph(), i = new Map(
|
|
26902
|
+
this.fieldSections.map((o) => [o.identifier, o])
|
|
26903
|
+
), a = [];
|
|
26904
|
+
return Us(
|
|
26905
|
+
n,
|
|
26906
|
+
t,
|
|
26907
|
+
(o, s, l) => {
|
|
26908
|
+
a.push(i.get(o));
|
|
26909
|
+
},
|
|
26910
|
+
{ mode: "in" }
|
|
26911
|
+
), a;
|
|
26912
|
+
}
|
|
26913
|
+
// Field Values methods
|
|
26914
|
+
cleanValues(t) {
|
|
26915
|
+
return mi(this.getFields(), t);
|
|
26916
|
+
}
|
|
26917
|
+
cleanSerializedValues(t) {
|
|
26918
|
+
return es(this.getFields(), t);
|
|
26919
|
+
}
|
|
26920
|
+
deserializeValues(t, n) {
|
|
26921
|
+
return Y1(this.getFields(), t, n);
|
|
26922
|
+
}
|
|
26923
|
+
serializeValues(t, n) {
|
|
26924
|
+
return j1(this.getFields(), t, n);
|
|
26925
|
+
}
|
|
26926
|
+
initializeValues(t) {
|
|
26927
|
+
return Q1(this.getFields(), t);
|
|
26928
|
+
}
|
|
26929
|
+
validateValues(t) {
|
|
26930
|
+
return ds(this.getFieldSections(), t);
|
|
26931
|
+
}
|
|
26932
|
+
deserializeConditions(t) {
|
|
26933
|
+
return Ko(this.getFields(), t);
|
|
26934
|
+
}
|
|
26935
|
+
cleanConditions(t) {
|
|
26936
|
+
return Jo(this.getFields(), t);
|
|
26937
|
+
}
|
|
26938
|
+
serializeConditions(t) {
|
|
26939
|
+
return W1(this.getFields(), t);
|
|
26940
|
+
}
|
|
26941
|
+
cleanSerializedConditions(t) {
|
|
26942
|
+
return Qo(this.getFields(), t);
|
|
26943
|
+
}
|
|
26944
|
+
changedFieldValues(t, n) {
|
|
26945
|
+
return J1(this.getFields(), t, n);
|
|
26946
|
+
}
|
|
26947
|
+
unchangedFieldValues(t, n) {
|
|
26948
|
+
return e0(this.getFields(), t, n);
|
|
26949
|
+
}
|
|
26950
|
+
areValuesEqual(t, n) {
|
|
26951
|
+
return ts(this.getFields(), t, n);
|
|
26952
|
+
}
|
|
26953
|
+
areValuesBlank(t) {
|
|
26954
|
+
return t0(this.getFields(), t);
|
|
26955
|
+
}
|
|
26956
|
+
blankValues() {
|
|
26957
|
+
return rs(this.getFields());
|
|
26958
|
+
}
|
|
26959
|
+
extractFilesAndPromisesFromFieldValues(t) {
|
|
26960
|
+
return Z1(this.getFields(), t);
|
|
26961
|
+
}
|
|
26962
|
+
insertFilesAndPromisesToFieldValues(t, n) {
|
|
26963
|
+
return K1(this.getFields(), t, n);
|
|
26964
|
+
}
|
|
26965
|
+
}
|
|
26966
26966
|
const hs = U((r) => {
|
|
26967
26967
|
const { sourceFieldSection: e, targetFieldSection: t } = r, n = ae(() => e.getConditions(t.identifier), [e, t.identifier]), i = I(() => {
|
|
26968
26968
|
e.removeConditional(t.identifier);
|
|
26969
26969
|
}, [e, t.identifier]), a = I(
|
|
26970
26970
|
(s) => {
|
|
26971
|
-
e.addCondition(t.identifier,
|
|
26971
|
+
e.addCondition(t.identifier, is(s));
|
|
26972
26972
|
},
|
|
26973
26973
|
[e, t.identifier]
|
|
26974
26974
|
), o = I(
|
|
@@ -27035,7 +27035,7 @@ const ps = U((r) => {
|
|
|
27035
27035
|
/* @__PURE__ */ A("div", { className: "flex gap-2 justify-between", children: [
|
|
27036
27036
|
/* @__PURE__ */ p(ve, { accentColor: "base", children: "Conditions" }),
|
|
27037
27037
|
/* @__PURE__ */ p(
|
|
27038
|
-
|
|
27038
|
+
ls,
|
|
27039
27039
|
{
|
|
27040
27040
|
fieldSections: a,
|
|
27041
27041
|
onSelectFieldCondition: i,
|
|
@@ -27412,7 +27412,7 @@ const ms = U((r) => {
|
|
|
27412
27412
|
const y = [];
|
|
27413
27413
|
for (const [C, E] of v.fields.entries())
|
|
27414
27414
|
for (const [O, N] of E.fields.entries()) {
|
|
27415
|
-
const M = ((_ =
|
|
27415
|
+
const M = ((_ = as(N.type, `fields.${C}.fields.${O}`)) == null ? void 0 : _.map(
|
|
27416
27416
|
({ field: B }) => B
|
|
27417
27417
|
)) ?? [];
|
|
27418
27418
|
y.push(...M);
|
|
@@ -27420,7 +27420,7 @@ const ms = U((r) => {
|
|
|
27420
27420
|
const m = {};
|
|
27421
27421
|
for (const C of y)
|
|
27422
27422
|
m[C.identifier] = Va(v, C.identifier);
|
|
27423
|
-
const w =
|
|
27423
|
+
const w = ds(y, m);
|
|
27424
27424
|
return Object.keys(w).length > 0 && (g.fields = w.fields), Object.keys(g).length > 0 && Be.error({
|
|
27425
27425
|
title: "Some form settings are invalid",
|
|
27426
27426
|
description: "Please check settings highlighted in red."
|
|
@@ -27473,7 +27473,7 @@ const ms = U((r) => {
|
|
|
27473
27473
|
ms.displayName = "FormBuilderRoot";
|
|
27474
27474
|
const P0 = {
|
|
27475
27475
|
Root: ms,
|
|
27476
|
-
FlowBuilder:
|
|
27476
|
+
FlowBuilder: fs,
|
|
27477
27477
|
ListBuilder: gs,
|
|
27478
27478
|
Preview: ys
|
|
27479
27479
|
};
|
|
@@ -27618,7 +27618,7 @@ export {
|
|
|
27618
27618
|
mi as cleanFieldValues,
|
|
27619
27619
|
Qo as cleanSerializedConditions,
|
|
27620
27620
|
es as cleanSerializedFieldValues,
|
|
27621
|
-
|
|
27621
|
+
is as createCondition,
|
|
27622
27622
|
F as createConditionModifierConfig,
|
|
27623
27623
|
Ci as createField,
|
|
27624
27624
|
$1 as deserialize,
|
|
@@ -27659,5 +27659,5 @@ export {
|
|
|
27659
27659
|
Kn as useImageViewer,
|
|
27660
27660
|
Ya as useObjectUrl,
|
|
27661
27661
|
O0 as useScanner,
|
|
27662
|
-
|
|
27662
|
+
ds as validateFieldValues
|
|
27663
27663
|
};
|