@notmrabhi/flowforge 0.1.21 → 0.1.23
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/GatewayBranchEdge-9YF32wwN.js +1 -0
- package/dist/GatewayBranchEdge-Dxoy5B1A.js +1264 -0
- package/dist/SchemaBuilderDrawer-157p-2Vj.js +1136 -0
- package/dist/SchemaBuilderDrawer-Wje7pVrn.js +1 -0
- package/dist/bpmn-CcuE2X_Q.js +2 -0
- package/dist/bpmn-CtfWDaOY.js +33 -0
- package/dist/canvas.cjs +1 -0
- package/dist/canvas.d.ts +809 -0
- package/dist/canvas.js +28 -0
- package/dist/canvasTokens-CAD6G24b.js +32 -0
- package/dist/canvasTokens-gKNYrPl4.js +1 -0
- package/dist/core.cjs +1 -0
- package/dist/core.d.ts +374 -0
- package/dist/core.js +24 -0
- package/dist/defaultUi.cjs +1 -0
- package/dist/defaultUi.d.ts +83 -0
- package/dist/defaultUi.js +18 -0
- package/dist/form.cjs +1 -0
- package/dist/form.d.ts +857 -0
- package/dist/form.js +44 -0
- package/dist/index-B31-Y5uO.js +11 -0
- package/dist/index-B3aHpb84.js +13 -0
- package/dist/index-BU09HbVh.js +10176 -0
- package/dist/index-BnzttJ4w.js +13758 -0
- package/dist/index-BysKSEtZ.js +1 -0
- package/dist/index-CQ0cVcHp.js +2 -0
- package/dist/index-CkjEllpd.js +1 -0
- package/dist/index-Codx5QwP.js +41 -0
- package/dist/index-Cw9DC-tf.js +76 -0
- package/dist/index-CzPi8KQC.js +1310 -0
- package/dist/index-D14V8rKX.js +1 -0
- package/dist/index-Da5NHCS2.js +8132 -0
- package/dist/index-a1IOaYsW.js +9 -0
- package/dist/index-a3QMaedZ.js +2553 -0
- package/dist/index-gtgq_241.js +3 -0
- package/dist/index-l6kvDx-m.js +1360 -0
- package/dist/index-lcviy90e.js +613 -0
- package/dist/index-wOnYb3DO.js +567 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +1409 -0
- package/dist/index.js +107 -0
- package/dist/messages-CO299wPN.js +22 -0
- package/dist/messages-O9Tw_XXR.js +1 -0
- package/dist/nodeRegistry.cjs +1 -0
- package/dist/nodeRegistry.d.ts +334 -0
- package/dist/nodeRegistry.js +555 -0
- package/dist/style.css +6 -0
- package/dist/templateRegistry.cjs +1 -0
- package/dist/templateRegistry.d.ts +83 -0
- package/dist/templateRegistry.js +43 -0
- package/dist/templateSkeletons-D2ecxpVH.js +2954 -0
- package/dist/templateSkeletons-D5dYuslG.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,1136 @@
|
|
|
1
|
+
import { useMemo as P, useState as T, useRef as M, useEffect as de, useCallback as te } from "react";
|
|
2
|
+
import { useFormik as ke } from "formik";
|
|
3
|
+
import { k as pe, C as Ne, g as oe, a as ue, b as ie, v as se, E as ze, d as Te, V as we } from "./index-BU09HbVh.js";
|
|
4
|
+
import { jsxs as t, Fragment as q, jsx as e } from "react/jsx-runtime";
|
|
5
|
+
import { Box as n, Collapse as Ie, Tooltip as A, Dialog as he, Typography as S, IconButton as Y, Stepper as Fe, Step as Oe, StepLabel as Re, Drawer as Ee, Chip as We, Divider as Ae } from "@mui/material";
|
|
6
|
+
import { MdCheck as G, MdClose as _, MdAdd as J, MdArrowBack as fe, MdEdit as De, MdDeleteOutline as Pe, MdSettings as be, MdArrowForward as Me } from "react-icons/md";
|
|
7
|
+
import { FaWpforms as _e } from "react-icons/fa6";
|
|
8
|
+
function sl({
|
|
9
|
+
schema: l,
|
|
10
|
+
initialValues: o,
|
|
11
|
+
onSubmit: p,
|
|
12
|
+
showErrorsImmediately: c = !1
|
|
13
|
+
}) {
|
|
14
|
+
const a = l.fields ?? [], i = P(
|
|
15
|
+
() => pe(a),
|
|
16
|
+
[a]
|
|
17
|
+
), h = P(() => {
|
|
18
|
+
if (c)
|
|
19
|
+
return a.reduce((f, C) => {
|
|
20
|
+
const g = Ne(C);
|
|
21
|
+
return g && (f[g] = !0), f;
|
|
22
|
+
}, {});
|
|
23
|
+
}, [a, c]), [s, d] = T({}), [x, y] = T({}), N = M(o);
|
|
24
|
+
de(() => {
|
|
25
|
+
N.current !== o && (N.current = o, d({}), y({}));
|
|
26
|
+
}, [o]);
|
|
27
|
+
const u = ke({
|
|
28
|
+
initialValues: o,
|
|
29
|
+
validationSchema: i,
|
|
30
|
+
initialTouched: h,
|
|
31
|
+
validateOnMount: c,
|
|
32
|
+
validateOnChange: !0,
|
|
33
|
+
validateOnBlur: !0,
|
|
34
|
+
enableReinitialize: !0,
|
|
35
|
+
onSubmit: async (f) => {
|
|
36
|
+
const C = oe({ values: f, conditionConfig: x });
|
|
37
|
+
await p(f, C);
|
|
38
|
+
}
|
|
39
|
+
}), r = te(() => {
|
|
40
|
+
u.submitForm();
|
|
41
|
+
}, [u]), b = te((f) => {
|
|
42
|
+
u.resetForm(f ? { values: f } : void 0), d({}), y({});
|
|
43
|
+
}, [u]);
|
|
44
|
+
return {
|
|
45
|
+
values: u.values,
|
|
46
|
+
errors: u.errors,
|
|
47
|
+
isValid: u.isValid,
|
|
48
|
+
isDirty: u.dirty,
|
|
49
|
+
isSubmitting: u.isSubmitting,
|
|
50
|
+
formulaConfig: s,
|
|
51
|
+
conditionConfig: x,
|
|
52
|
+
submit: r,
|
|
53
|
+
reset: b,
|
|
54
|
+
setFieldValue: u.setFieldValue,
|
|
55
|
+
// Internals for DynamicFormRenderer
|
|
56
|
+
_schema: l,
|
|
57
|
+
_formik: u,
|
|
58
|
+
_formulaConfig: s,
|
|
59
|
+
_onFormulaConfigChange: d,
|
|
60
|
+
_conditionConfig: x,
|
|
61
|
+
_onConditionConfigChange: y
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
const je = ue.getTypeOptions(), v = "form-control font-14", m = "text-14 text-dark fw-medium mb-1 align-items-center d-flex gap-1", R = {
|
|
65
|
+
fontSize: 10,
|
|
66
|
+
fontWeight: 700,
|
|
67
|
+
color: "#94a3b8",
|
|
68
|
+
textTransform: "uppercase",
|
|
69
|
+
letterSpacing: 0.6,
|
|
70
|
+
marginBottom: 8,
|
|
71
|
+
display: "block"
|
|
72
|
+
}, Le = [
|
|
73
|
+
{ value: "text", label: "Text" },
|
|
74
|
+
{ value: "number", label: "Number" },
|
|
75
|
+
{ value: "email", label: "Email" },
|
|
76
|
+
{ value: "url", label: "URL" },
|
|
77
|
+
{ value: "password", label: "Password" },
|
|
78
|
+
{ value: "select", label: "Select" },
|
|
79
|
+
{ value: "object", label: "Object (sub-fields)" },
|
|
80
|
+
{ value: "array", label: "Array (nested)" }
|
|
81
|
+
], Ve = [
|
|
82
|
+
{ value: 3, label: "1/4" },
|
|
83
|
+
{ value: 4, label: "1/3" },
|
|
84
|
+
{ value: 6, label: "1/2" },
|
|
85
|
+
{ value: 8, label: "2/3" },
|
|
86
|
+
{ value: 12, label: "Full" }
|
|
87
|
+
];
|
|
88
|
+
function $e({ value: l, onChange: o }) {
|
|
89
|
+
const p = l ?? 12;
|
|
90
|
+
return /* @__PURE__ */ t(n, { children: [
|
|
91
|
+
/* @__PURE__ */ e("span", { className: m, children: "Column width" }),
|
|
92
|
+
/* @__PURE__ */ e(n, { sx: { display: "flex", gap: 0.5 }, children: Ve.map((c) => /* @__PURE__ */ e(A, { title: `colSpan: ${c.value}`, placement: "top", children: /* @__PURE__ */ e(
|
|
93
|
+
n,
|
|
94
|
+
{
|
|
95
|
+
component: "button",
|
|
96
|
+
onClick: () => o(c.value),
|
|
97
|
+
sx: {
|
|
98
|
+
flex: 1,
|
|
99
|
+
border: "1px solid",
|
|
100
|
+
borderColor: p === c.value ? "#6366f1" : "#dee2e6",
|
|
101
|
+
borderRadius: "6px",
|
|
102
|
+
cursor: "pointer",
|
|
103
|
+
bgcolor: p === c.value ? "#eef2ff" : "#fff",
|
|
104
|
+
color: p === c.value ? "#6366f1" : "#6c757d",
|
|
105
|
+
fontSize: 11,
|
|
106
|
+
fontWeight: 600,
|
|
107
|
+
py: 0.6,
|
|
108
|
+
px: 0,
|
|
109
|
+
"&:hover": { borderColor: "#6366f1", bgcolor: "#f5f3ff" }
|
|
110
|
+
},
|
|
111
|
+
children: c.label
|
|
112
|
+
}
|
|
113
|
+
) }, c.value)) }),
|
|
114
|
+
/* @__PURE__ */ e(n, { sx: { display: "flex", gap: "3px", mt: 0.75 }, children: Array.from({ length: 12 }).map((c, a) => /* @__PURE__ */ e(n, { sx: { flex: 1, height: 4, borderRadius: "2px", bgcolor: a < p ? "#6366f1" : "#e2e8f0", transition: "background 0.12s" } }, a)) })
|
|
115
|
+
] });
|
|
116
|
+
}
|
|
117
|
+
function me({ options: l = [], onChange: o }) {
|
|
118
|
+
function p(c, a, i) {
|
|
119
|
+
o(l.map((h, s) => s === c ? { ...h, [a]: i } : h));
|
|
120
|
+
}
|
|
121
|
+
return /* @__PURE__ */ t(n, { children: [
|
|
122
|
+
/* @__PURE__ */ t("span", { className: m, children: [
|
|
123
|
+
"Options ",
|
|
124
|
+
/* @__PURE__ */ e("span", { style: { color: "#dc3545" }, children: "*" })
|
|
125
|
+
] }),
|
|
126
|
+
/* @__PURE__ */ e(n, { sx: { display: "flex", flexDirection: "column", gap: 0.5, mb: 0.75 }, children: l.map((c, a) => /* @__PURE__ */ t(n, { sx: { display: "flex", gap: 0.5, alignItems: "center" }, children: [
|
|
127
|
+
/* @__PURE__ */ e("input", { className: v, style: { flex: 1 }, placeholder: "Label", value: c.label, onChange: (i) => p(a, "label", i.target.value) }),
|
|
128
|
+
/* @__PURE__ */ e("input", { className: v, style: { flex: 1 }, placeholder: "Value", value: c.value, onChange: (i) => p(a, "value", i.target.value) }),
|
|
129
|
+
/* @__PURE__ */ e(n, { component: "button", onClick: () => o(l.filter((i, h) => h !== a)), sx: { background: "none", border: "none", cursor: "pointer", color: "#94a3b8", display: "flex", p: 0.25, "&:hover": { color: "#dc2626" } }, children: /* @__PURE__ */ e(_, { size: 13 }) })
|
|
130
|
+
] }, a)) }),
|
|
131
|
+
/* @__PURE__ */ t(n, { component: "button", onClick: () => o([...l, { label: "", value: "" }]), sx: { display: "flex", alignItems: "center", gap: 0.5, background: "none", border: "1px dashed #dee2e6", cursor: "pointer", fontSize: 11, fontWeight: 600, px: 1, py: 0.5, borderRadius: "6px", color: "#6366f1", width: "100%", "&:hover": { borderColor: "#6366f1", bgcolor: "#f5f3ff" } }, children: [
|
|
132
|
+
/* @__PURE__ */ e(J, { size: 13 }),
|
|
133
|
+
" Add option"
|
|
134
|
+
] })
|
|
135
|
+
] });
|
|
136
|
+
}
|
|
137
|
+
const xe = [
|
|
138
|
+
{ value: "operator", label: "Operator (predefined)" },
|
|
139
|
+
{ value: "select", label: "Select" },
|
|
140
|
+
{ value: "text", label: "Text" }
|
|
141
|
+
];
|
|
142
|
+
function Be({ col: l, onChange: o, onDelete: p }) {
|
|
143
|
+
const c = l.type === "select", a = l.type === "operator";
|
|
144
|
+
return /* @__PURE__ */ t(n, { sx: { border: "1px solid #e2e8f0", borderRadius: "7px", p: 1.25, bgcolor: "#fff", display: "flex", flexDirection: "column", gap: 1 }, children: [
|
|
145
|
+
/* @__PURE__ */ t(n, { sx: { display: "flex", alignItems: "center", gap: 0.75 }, children: [
|
|
146
|
+
/* @__PURE__ */ e(n, { sx: { fontSize: 10, fontWeight: 700, px: 0.75, py: 0.2, borderRadius: "4px", bgcolor: a ? "#fef9c3" : "#eef2ff", color: a ? "#92400e" : "#6366f1", flexShrink: 0 }, children: a ? "OPERATOR" : l.type.toUpperCase() }),
|
|
147
|
+
/* @__PURE__ */ e(n, { sx: { fontSize: 12, fontWeight: 600, color: "#0f172a", flex: 1 }, children: l.label || l.id || "Unnamed" }),
|
|
148
|
+
/* @__PURE__ */ e(n, { component: "button", onClick: p, sx: { background: "none", border: "none", cursor: "pointer", color: "#94a3b8", display: "flex", p: 0.25, "&:hover": { color: "#dc2626" } }, children: /* @__PURE__ */ e(_, { size: 13 }) })
|
|
149
|
+
] }),
|
|
150
|
+
/* @__PURE__ */ t(n, { sx: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 1 }, children: [
|
|
151
|
+
/* @__PURE__ */ t(n, { children: [
|
|
152
|
+
/* @__PURE__ */ e("label", { className: m, children: "Column type" }),
|
|
153
|
+
/* @__PURE__ */ e("select", { value: l.type, onChange: (i) => o({ ...l, type: i.target.value, options: void 0 }), className: v, style: { cursor: "pointer" }, children: xe.map((i) => /* @__PURE__ */ e("option", { value: i.value, children: i.label }, i.value)) })
|
|
154
|
+
] }),
|
|
155
|
+
/* @__PURE__ */ t(n, { children: [
|
|
156
|
+
/* @__PURE__ */ t("label", { className: m, children: [
|
|
157
|
+
"Column key ",
|
|
158
|
+
/* @__PURE__ */ e("span", { style: { color: "#dc3545" }, children: "*" })
|
|
159
|
+
] }),
|
|
160
|
+
/* @__PURE__ */ e("input", { className: `${v} ${l.id ? "" : "border-danger"}`, value: l.id, onChange: (i) => o({ ...l, id: i.target.value }), placeholder: "e.g. field, operator, value" }),
|
|
161
|
+
!l.id && /* @__PURE__ */ e("span", { style: { fontSize: 10, color: "#dc3545" }, children: "Required — used as data key" })
|
|
162
|
+
] })
|
|
163
|
+
] }),
|
|
164
|
+
!a && /* @__PURE__ */ t(n, { sx: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 1 }, children: [
|
|
165
|
+
/* @__PURE__ */ t(n, { children: [
|
|
166
|
+
/* @__PURE__ */ e("label", { className: m, children: "Label" }),
|
|
167
|
+
/* @__PURE__ */ e("input", { className: v, value: l.label ?? "", onChange: (i) => o({ ...l, label: i.target.value || void 0 }), placeholder: "Column label" })
|
|
168
|
+
] }),
|
|
169
|
+
/* @__PURE__ */ t(n, { children: [
|
|
170
|
+
/* @__PURE__ */ e("label", { className: m, children: "Placeholder" }),
|
|
171
|
+
/* @__PURE__ */ e("input", { className: v, value: l.placeholder ?? "", onChange: (i) => o({ ...l, placeholder: i.target.value || void 0 }), placeholder: "Hint…" })
|
|
172
|
+
] })
|
|
173
|
+
] }),
|
|
174
|
+
c && /* @__PURE__ */ e(me, { options: l.options ?? [], onChange: (i) => o({ ...l, options: i }) }),
|
|
175
|
+
a && /* @__PURE__ */ e(n, { sx: { bgcolor: "#fefce8", border: "1px solid #fef08a", borderRadius: "6px", px: 1.25, py: 0.75 }, children: /* @__PURE__ */ e(n, { sx: { fontSize: 11, color: "#78350f" }, children: "Predefined: equals, not equals, contains, starts with, ends with, is present, is not present, greater than, less than…" }) }),
|
|
176
|
+
!a && /* @__PURE__ */ t(n, { sx: { display: "flex", alignItems: "center", gap: 0.75 }, children: [
|
|
177
|
+
/* @__PURE__ */ e("input", { type: "checkbox", id: `formula-${l.id}`, checked: !!l.formula, onChange: (i) => o({ ...l, formula: i.target.checked || void 0 }), style: { cursor: "pointer", width: 14, height: 14 } }),
|
|
178
|
+
/* @__PURE__ */ e("label", { htmlFor: `formula-${l.id}`, className: m, style: { margin: 0, cursor: "pointer" }, children: "Formula input (chip editor)" })
|
|
179
|
+
] })
|
|
180
|
+
] });
|
|
181
|
+
}
|
|
182
|
+
function He({ condition: l, onChange: o }) {
|
|
183
|
+
const p = !!l;
|
|
184
|
+
function c() {
|
|
185
|
+
o(p ? void 0 : { fields: [] });
|
|
186
|
+
}
|
|
187
|
+
function a(s) {
|
|
188
|
+
if (!l) return;
|
|
189
|
+
const d = s === "operator" ? "operator" : l.fields.filter((x) => x.type !== "operator").length === 0 ? "field" : "value";
|
|
190
|
+
o({ ...l, fields: [...l.fields, { id: d, type: s }] });
|
|
191
|
+
}
|
|
192
|
+
function i(s, d) {
|
|
193
|
+
if (!l) return;
|
|
194
|
+
const x = [...l.fields];
|
|
195
|
+
x[s] = d, o({ ...l, fields: x });
|
|
196
|
+
}
|
|
197
|
+
function h(s) {
|
|
198
|
+
l && o({ ...l, fields: l.fields.filter((d, x) => x !== s) });
|
|
199
|
+
}
|
|
200
|
+
return /* @__PURE__ */ t(n, { sx: { borderTop: "1px solid #e2e8f0", pt: 1.5 }, children: [
|
|
201
|
+
/* @__PURE__ */ t(n, { sx: { display: "flex", alignItems: "center", gap: 0.75, mb: p ? 1.25 : 0 }, children: [
|
|
202
|
+
/* @__PURE__ */ e("input", { type: "checkbox", id: "enable-condition", checked: p, onChange: c, style: { cursor: "pointer", width: 14, height: 14 } }),
|
|
203
|
+
/* @__PURE__ */ e("span", { style: { ...R, margin: 0, color: p ? "#6366f1" : "#94a3b8" }, children: "Condition row" })
|
|
204
|
+
] }),
|
|
205
|
+
p && l && /* @__PURE__ */ t(n, { sx: { display: "flex", flexDirection: "column", gap: 1 }, children: [
|
|
206
|
+
l.fields.map((s, d) => /* @__PURE__ */ e(Be, { col: s, onChange: (x) => i(d, x), onDelete: () => h(d) }, d)),
|
|
207
|
+
/* @__PURE__ */ e(n, { sx: { display: "flex", gap: 0.5 }, children: xe.map((s) => /* @__PURE__ */ t(n, { component: "button", onClick: () => a(s.value), sx: { flex: 1, background: "none", border: "1px dashed #dee2e6", cursor: "pointer", fontSize: 11, fontWeight: 600, py: 0.5, borderRadius: "6px", color: s.value === "operator" ? "#92400e" : "#6366f1", "&:hover": { borderColor: "#6366f1", bgcolor: "#f5f3ff" } }, children: [
|
|
208
|
+
"+ ",
|
|
209
|
+
s.value === "operator" ? "Operator" : s.label.split(" ")[0]
|
|
210
|
+
] }, s.value)) }),
|
|
211
|
+
/* @__PURE__ */ t(n, { sx: { display: "flex", alignItems: "center", gap: 2, flexWrap: "wrap" }, children: [
|
|
212
|
+
/* @__PURE__ */ t(n, { sx: { display: "flex", alignItems: "center", gap: 0.75 }, children: [
|
|
213
|
+
/* @__PURE__ */ e("input", { type: "checkbox", id: "allow-groups", checked: !!l.allowGroups, onChange: (s) => o({ ...l, allowGroups: s.target.checked || void 0 }), style: { cursor: "pointer", width: 14, height: 14 } }),
|
|
214
|
+
/* @__PURE__ */ e("label", { htmlFor: "allow-groups", className: m, style: { margin: 0, cursor: "pointer" }, children: "Allow nested groups" })
|
|
215
|
+
] }),
|
|
216
|
+
l.allowGroups && /* @__PURE__ */ t(n, { sx: { display: "flex", alignItems: "center", gap: 0.75 }, children: [
|
|
217
|
+
/* @__PURE__ */ e("label", { className: m, style: { margin: 0 }, children: "Max depth" }),
|
|
218
|
+
/* @__PURE__ */ e("input", { type: "number", min: 1, max: 5, className: v, style: { width: 60, textAlign: "center" }, value: l.maxGroupDepth ?? "", onChange: (s) => o({ ...l, maxGroupDepth: s.target.value ? Number(s.target.value) : void 0 }), placeholder: "∞" })
|
|
219
|
+
] })
|
|
220
|
+
] })
|
|
221
|
+
] })
|
|
222
|
+
] });
|
|
223
|
+
}
|
|
224
|
+
function D({ id: l, label: o, checked: p, onChange: c }) {
|
|
225
|
+
return /* @__PURE__ */ t(n, { sx: { display: "flex", alignItems: "center", gap: 0.75 }, children: [
|
|
226
|
+
/* @__PURE__ */ e("input", { type: "checkbox", id: l, checked: p, onChange: (a) => c(a.target.checked), style: { cursor: "pointer", width: 14, height: 14, flexShrink: 0 } }),
|
|
227
|
+
/* @__PURE__ */ e("label", { htmlFor: l, className: m, style: { margin: 0, cursor: "pointer" }, children: o })
|
|
228
|
+
] });
|
|
229
|
+
}
|
|
230
|
+
function Ue({ views: l = [], onChange: o }) {
|
|
231
|
+
function p(a, i, h) {
|
|
232
|
+
o(l.map((s, d) => d === a ? { ...s, [i]: h } : s));
|
|
233
|
+
}
|
|
234
|
+
function c() {
|
|
235
|
+
const a = `tab${l.length + 1}`;
|
|
236
|
+
o([...l, { id: a, label: `Tab ${l.length + 1}` }]);
|
|
237
|
+
}
|
|
238
|
+
return /* @__PURE__ */ t(n, { children: [
|
|
239
|
+
/* @__PURE__ */ e("span", { className: m, children: "Views" }),
|
|
240
|
+
/* @__PURE__ */ e(n, { sx: { display: "flex", flexDirection: "column", gap: 0.5, mb: 0.75 }, children: l.map((a, i) => /* @__PURE__ */ t(n, { sx: { display: "flex", gap: 0.5, alignItems: "center" }, children: [
|
|
241
|
+
/* @__PURE__ */ e("input", { className: v, style: { flex: 1 }, placeholder: "Label", value: a.label, onChange: (h) => p(i, "label", h.target.value) }),
|
|
242
|
+
/* @__PURE__ */ e("input", { className: v, style: { flex: 1 }, placeholder: "ID (no spaces)", value: a.id, onChange: (h) => p(i, "id", h.target.value.replace(/\s/g, "_")) }),
|
|
243
|
+
/* @__PURE__ */ e(n, { component: "button", onClick: () => o(l.filter((h, s) => s !== i)), sx: { background: "none", border: "none", cursor: "pointer", color: "#94a3b8", display: "flex", p: 0.25, "&:hover": { color: "#dc2626" } }, children: /* @__PURE__ */ e(_, { size: 13 }) })
|
|
244
|
+
] }, i)) }),
|
|
245
|
+
/* @__PURE__ */ t(n, { component: "button", onClick: c, sx: { display: "flex", alignItems: "center", gap: 0.5, background: "none", border: "1px dashed #dee2e6", cursor: "pointer", fontSize: 11, fontWeight: 600, px: 1, py: 0.5, borderRadius: "6px", color: "#6366f1", width: "100%", "&:hover": { borderColor: "#6366f1", bgcolor: "#f5f3ff" } }, children: [
|
|
246
|
+
/* @__PURE__ */ e(J, { size: 13 }),
|
|
247
|
+
" Add view"
|
|
248
|
+
] })
|
|
249
|
+
] });
|
|
250
|
+
}
|
|
251
|
+
function B({ label: l, value: o, options: p, onChange: c }) {
|
|
252
|
+
return /* @__PURE__ */ t(n, { children: [
|
|
253
|
+
/* @__PURE__ */ e("span", { className: m, children: l }),
|
|
254
|
+
/* @__PURE__ */ e(n, { sx: { display: "flex", border: "1px solid #dee2e6", borderRadius: "7px", overflow: "hidden" }, children: p.map((a) => /* @__PURE__ */ e(
|
|
255
|
+
n,
|
|
256
|
+
{
|
|
257
|
+
component: "button",
|
|
258
|
+
onClick: () => c(a.value),
|
|
259
|
+
sx: {
|
|
260
|
+
flex: 1,
|
|
261
|
+
border: "none",
|
|
262
|
+
borderRight: "1px solid #dee2e6",
|
|
263
|
+
cursor: "pointer",
|
|
264
|
+
fontSize: 12,
|
|
265
|
+
fontWeight: 600,
|
|
266
|
+
py: 0.6,
|
|
267
|
+
bgcolor: o === a.value ? "#eef2ff" : "#fff",
|
|
268
|
+
color: o === a.value ? "#6366f1" : "#6c757d",
|
|
269
|
+
"&:last-child": { borderRight: "none" },
|
|
270
|
+
"&:hover": { bgcolor: "#f5f3ff" }
|
|
271
|
+
},
|
|
272
|
+
children: a.label
|
|
273
|
+
},
|
|
274
|
+
a.value
|
|
275
|
+
)) })
|
|
276
|
+
] });
|
|
277
|
+
}
|
|
278
|
+
function ge({ field: l, onChange: o, onSave: p, onCancel: c, noFooter: a }) {
|
|
279
|
+
const [i, h] = T(!1), s = l.id ?? l.name ?? "", d = l, x = l.type === "select" || l.type === "descriptive-select" || l.type === "radio-group", y = ue.get(l.type), N = y == null ? void 0 : y.configSchema;
|
|
280
|
+
function u(r, b) {
|
|
281
|
+
o({ ...l, [r]: b });
|
|
282
|
+
}
|
|
283
|
+
return /* @__PURE__ */ t(q, { children: [
|
|
284
|
+
/* @__PURE__ */ t(n, { sx: { flex: 1, overflowY: "auto", px: 2.5, py: 2, display: "flex", flexDirection: "column", gap: 1.75 }, children: [
|
|
285
|
+
/* @__PURE__ */ t(n, { children: [
|
|
286
|
+
/* @__PURE__ */ e("span", { style: R, children: "Required" }),
|
|
287
|
+
/* @__PURE__ */ t(n, { sx: { display: "flex", flexDirection: "column", gap: 1 }, children: [
|
|
288
|
+
/* @__PURE__ */ t(n, { children: [
|
|
289
|
+
/* @__PURE__ */ e("label", { className: m, children: "Type" }),
|
|
290
|
+
/* @__PURE__ */ e("select", { value: l.type, onChange: (r) => u("type", r.target.value), className: v, style: { cursor: "pointer" }, children: je.map((r) => /* @__PURE__ */ e("option", { value: r.value, children: r.label }, r.value)) })
|
|
291
|
+
] }),
|
|
292
|
+
/* @__PURE__ */ t(n, { sx: { display: "grid", gridTemplateColumns: l.type === "tabs" ? "1fr" : "1fr 1fr", gap: 1 }, children: [
|
|
293
|
+
/* @__PURE__ */ t(n, { children: [
|
|
294
|
+
/* @__PURE__ */ t("label", { className: m, children: [
|
|
295
|
+
"Field ID ",
|
|
296
|
+
/* @__PURE__ */ e("span", { style: { color: "#dc3545" }, children: "*" })
|
|
297
|
+
] }),
|
|
298
|
+
/* @__PURE__ */ e("input", { className: v, value: l.id ?? l.name ?? "", onChange: (r) => u("id", r.target.value), placeholder: "e.g. email" })
|
|
299
|
+
] }),
|
|
300
|
+
l.type !== "tabs" && /* @__PURE__ */ t(n, { children: [
|
|
301
|
+
/* @__PURE__ */ t("label", { className: m, children: [
|
|
302
|
+
"Label ",
|
|
303
|
+
/* @__PURE__ */ e("span", { style: { color: "#dc3545" }, children: "*" })
|
|
304
|
+
] }),
|
|
305
|
+
/* @__PURE__ */ e("input", { className: v, value: l.label ?? "", onChange: (r) => u("label", r.target.value), placeholder: "Display label" })
|
|
306
|
+
] })
|
|
307
|
+
] }),
|
|
308
|
+
l.type !== "tabs" && /* @__PURE__ */ e($e, { value: l.colSpan, onChange: (r) => u("colSpan", r === 12 ? void 0 : r) })
|
|
309
|
+
] })
|
|
310
|
+
] }),
|
|
311
|
+
N && /* @__PURE__ */ t(n, { sx: { borderTop: "1px solid #e2e8f0", pt: 1.5 }, children: [
|
|
312
|
+
/* @__PURE__ */ e("span", { style: R, children: "Specific Settings" }),
|
|
313
|
+
/* @__PURE__ */ e(
|
|
314
|
+
ie,
|
|
315
|
+
{
|
|
316
|
+
schema: { layout: "flat", compact: !0, fields: N.fields },
|
|
317
|
+
initialValues: l,
|
|
318
|
+
onValuesChange: (r) => o({ ...l, ...r }),
|
|
319
|
+
onSubmit: () => {
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
)
|
|
323
|
+
] }),
|
|
324
|
+
l.type === "tabs" && /* @__PURE__ */ t(n, { sx: { borderTop: "1px solid #e2e8f0", pt: 1.5, display: "flex", flexDirection: "column", gap: 1.5 }, children: [
|
|
325
|
+
/* @__PURE__ */ e("span", { style: R, children: "Content" }),
|
|
326
|
+
/* @__PURE__ */ e(
|
|
327
|
+
Ue,
|
|
328
|
+
{
|
|
329
|
+
views: (d.tabs ?? []).map((r) => ({ id: r.id, label: r.label })),
|
|
330
|
+
onChange: (r) => {
|
|
331
|
+
const b = d.tabs ?? [], f = r.map((C) => {
|
|
332
|
+
const g = b.find((I) => I.id === C.id);
|
|
333
|
+
return g ? { ...g, ...C } : { ...C, fields: [] };
|
|
334
|
+
});
|
|
335
|
+
o({ ...l, tabs: f });
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
),
|
|
339
|
+
/* @__PURE__ */ e("span", { style: { ...R, marginTop: 4 }, children: "Interaction" }),
|
|
340
|
+
/* @__PURE__ */ t(n, { children: [
|
|
341
|
+
/* @__PURE__ */ e("label", { className: m, children: "Disabled" }),
|
|
342
|
+
/* @__PURE__ */ e("input", { className: v, value: d.disabledExpr ?? "", onChange: (r) => o({ ...l, disabledExpr: r.target.value || void 0 }), placeholder: "false" })
|
|
343
|
+
] }),
|
|
344
|
+
/* @__PURE__ */ e("span", { style: { ...R, marginTop: 4 }, children: "Appearance" }),
|
|
345
|
+
/* @__PURE__ */ e(
|
|
346
|
+
B,
|
|
347
|
+
{
|
|
348
|
+
label: "Alignment",
|
|
349
|
+
value: d.alignment ?? "left",
|
|
350
|
+
options: [
|
|
351
|
+
{ value: "left", label: "|←" },
|
|
352
|
+
{ value: "center-left", label: "←|" },
|
|
353
|
+
{ value: "center", label: "|·|" },
|
|
354
|
+
{ value: "center-right", label: "|→" },
|
|
355
|
+
{ value: "right", label: "→|" }
|
|
356
|
+
],
|
|
357
|
+
onChange: (r) => o({ ...l, alignment: r })
|
|
358
|
+
}
|
|
359
|
+
),
|
|
360
|
+
/* @__PURE__ */ t(n, { children: [
|
|
361
|
+
/* @__PURE__ */ e("label", { className: m, children: "Hidden" }),
|
|
362
|
+
/* @__PURE__ */ e("input", { className: v, value: d.hiddenExpr ?? "", onChange: (r) => o({ ...l, hiddenExpr: r.target.value || void 0 }), placeholder: "false" })
|
|
363
|
+
] }),
|
|
364
|
+
/* @__PURE__ */ e(
|
|
365
|
+
B,
|
|
366
|
+
{
|
|
367
|
+
label: "Variant",
|
|
368
|
+
value: d.variant ?? "line",
|
|
369
|
+
options: [{ value: "pill", label: "Pill" }, { value: "line", label: "Line" }],
|
|
370
|
+
onChange: (r) => o({ ...l, variant: r })
|
|
371
|
+
}
|
|
372
|
+
),
|
|
373
|
+
/* @__PURE__ */ t(n, { sx: { display: "grid", gridTemplateColumns: "1fr 1fr 1fr", gap: 1 }, children: [
|
|
374
|
+
/* @__PURE__ */ t(n, { children: [
|
|
375
|
+
/* @__PURE__ */ e("label", { className: m, children: "Active color" }),
|
|
376
|
+
/* @__PURE__ */ t(n, { sx: { display: "flex", alignItems: "center", gap: 0.5 }, children: [
|
|
377
|
+
/* @__PURE__ */ e("input", { type: "color", value: d.activeColor ?? "#6366f1", onChange: (r) => o({ ...l, activeColor: r.target.value }), style: { width: 28, height: 28, border: "1px solid #dee2e6", borderRadius: 6, cursor: "pointer", padding: 2, background: "#fff" } }),
|
|
378
|
+
/* @__PURE__ */ e("input", { className: v, value: d.activeColor ?? "", onChange: (r) => o({ ...l, activeColor: r.target.value || void 0 }), placeholder: "#6366f1", style: { flex: 1 } })
|
|
379
|
+
] })
|
|
380
|
+
] }),
|
|
381
|
+
/* @__PURE__ */ t(n, { children: [
|
|
382
|
+
/* @__PURE__ */ e("label", { className: m, children: "Active text" }),
|
|
383
|
+
/* @__PURE__ */ t(n, { sx: { display: "flex", alignItems: "center", gap: 0.5 }, children: [
|
|
384
|
+
/* @__PURE__ */ e("input", { type: "color", value: d.activeTextColor ?? "#ffffff", onChange: (r) => o({ ...l, activeTextColor: r.target.value }), style: { width: 28, height: 28, border: "1px solid #dee2e6", borderRadius: 6, cursor: "pointer", padding: 2, background: "#fff" } }),
|
|
385
|
+
/* @__PURE__ */ e("input", { className: v, value: d.activeTextColor ?? "", onChange: (r) => o({ ...l, activeTextColor: r.target.value || void 0 }), placeholder: "auto", style: { flex: 1 } })
|
|
386
|
+
] })
|
|
387
|
+
] }),
|
|
388
|
+
/* @__PURE__ */ t(n, { children: [
|
|
389
|
+
/* @__PURE__ */ e("label", { className: m, children: "Inactive text" }),
|
|
390
|
+
/* @__PURE__ */ t(n, { sx: { display: "flex", alignItems: "center", gap: 0.5 }, children: [
|
|
391
|
+
/* @__PURE__ */ e("input", { type: "color", value: d.inactiveTextColor ?? "#64748b", onChange: (r) => o({ ...l, inactiveTextColor: r.target.value }), style: { width: 28, height: 28, border: "1px solid #dee2e6", borderRadius: 6, cursor: "pointer", padding: 2, background: "#fff" } }),
|
|
392
|
+
/* @__PURE__ */ e("input", { className: v, value: d.inactiveTextColor ?? "", onChange: (r) => o({ ...l, inactiveTextColor: r.target.value || void 0 }), placeholder: "#64748b", style: { flex: 1 } })
|
|
393
|
+
] })
|
|
394
|
+
] })
|
|
395
|
+
] }),
|
|
396
|
+
/* @__PURE__ */ t(n, { children: [
|
|
397
|
+
/* @__PURE__ */ e("label", { className: m, children: "Styles" }),
|
|
398
|
+
/* @__PURE__ */ e("input", { className: v, value: d.styles ?? "", onChange: (r) => o({ ...l, styles: r.target.value || void 0 }), placeholder: "None" })
|
|
399
|
+
] }),
|
|
400
|
+
/* @__PURE__ */ e("span", { style: { ...R, marginTop: 4 }, children: "Spacing" }),
|
|
401
|
+
/* @__PURE__ */ e(
|
|
402
|
+
B,
|
|
403
|
+
{
|
|
404
|
+
label: "Height",
|
|
405
|
+
value: d.height ?? "auto",
|
|
406
|
+
options: [{ value: "auto", label: "Auto" }, { value: "fixed", label: "Fixed" }],
|
|
407
|
+
onChange: (r) => o({ ...l, height: r })
|
|
408
|
+
}
|
|
409
|
+
),
|
|
410
|
+
/* @__PURE__ */ e(
|
|
411
|
+
B,
|
|
412
|
+
{
|
|
413
|
+
label: "Margin",
|
|
414
|
+
value: d.margin ?? "normal",
|
|
415
|
+
options: [{ value: "normal", label: "Normal" }, { value: "none", label: "None" }],
|
|
416
|
+
onChange: (r) => o({ ...l, margin: r })
|
|
417
|
+
}
|
|
418
|
+
)
|
|
419
|
+
] }),
|
|
420
|
+
x && /* @__PURE__ */ t(n, { sx: { borderTop: "1px solid #e2e8f0", pt: 1.5 }, children: [
|
|
421
|
+
/* @__PURE__ */ e("span", { style: R, children: "Options" }),
|
|
422
|
+
/* @__PURE__ */ e(me, { options: d.options ?? [], onChange: (r) => o({ ...l, options: r }) })
|
|
423
|
+
] }),
|
|
424
|
+
l.type === "array" && /* @__PURE__ */ t(n, { sx: { borderTop: "1px solid #e2e8f0", pt: 1.5, display: "flex", flexDirection: "column", gap: 1 }, children: [
|
|
425
|
+
/* @__PURE__ */ e("span", { style: R, children: "Array settings" }),
|
|
426
|
+
/* @__PURE__ */ t(n, { children: [
|
|
427
|
+
/* @__PURE__ */ e("label", { className: m, children: "Item type" }),
|
|
428
|
+
/* @__PURE__ */ e("select", { className: v, style: { cursor: "pointer" }, value: d.itemType ?? "text", onChange: (r) => o({ ...l, itemType: r.target.value }), children: Le.map((r) => /* @__PURE__ */ e("option", { value: r.value, children: r.label }, r.value)) })
|
|
429
|
+
] }),
|
|
430
|
+
/* @__PURE__ */ t(n, { sx: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 1 }, children: [
|
|
431
|
+
/* @__PURE__ */ t(n, { children: [
|
|
432
|
+
/* @__PURE__ */ e("label", { className: m, children: "Item label" }),
|
|
433
|
+
/* @__PURE__ */ e("input", { className: v, value: d.itemLabel ?? "", onChange: (r) => o({ ...l, itemLabel: r.target.value || void 0 }), placeholder: 'e.g. "Member"' })
|
|
434
|
+
] }),
|
|
435
|
+
/* @__PURE__ */ t(n, { children: [
|
|
436
|
+
/* @__PURE__ */ e("label", { className: m, children: "Add button label" }),
|
|
437
|
+
/* @__PURE__ */ e("input", { className: v, value: d.addLabel ?? "", onChange: (r) => o({ ...l, addLabel: r.target.value || void 0 }), placeholder: "Add item" })
|
|
438
|
+
] })
|
|
439
|
+
] }),
|
|
440
|
+
/* @__PURE__ */ t(n, { sx: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 1 }, children: [
|
|
441
|
+
/* @__PURE__ */ t(n, { children: [
|
|
442
|
+
/* @__PURE__ */ e("label", { className: m, children: "Min items" }),
|
|
443
|
+
/* @__PURE__ */ e("input", { type: "number", min: 0, className: v, value: d.minItems ?? "", onChange: (r) => o({ ...l, minItems: r.target.value ? Number(r.target.value) : void 0 }), placeholder: "0" })
|
|
444
|
+
] }),
|
|
445
|
+
/* @__PURE__ */ t(n, { children: [
|
|
446
|
+
/* @__PURE__ */ e("label", { className: m, children: "Max items" }),
|
|
447
|
+
/* @__PURE__ */ e("input", { type: "number", min: 1, className: v, value: d.maxItems ?? "", onChange: (r) => o({ ...l, maxItems: r.target.value ? Number(r.target.value) : void 0 }), placeholder: "∞" })
|
|
448
|
+
] })
|
|
449
|
+
] }),
|
|
450
|
+
!["object", "array", "select"].includes(d.itemType ?? "text") && /* @__PURE__ */ t(n, { children: [
|
|
451
|
+
/* @__PURE__ */ e("label", { className: m, children: "Item placeholder" }),
|
|
452
|
+
/* @__PURE__ */ e("input", { className: v, value: d.itemPlaceholder ?? "", onChange: (r) => o({ ...l, itemPlaceholder: r.target.value || void 0 }), placeholder: "Enter value…" })
|
|
453
|
+
] })
|
|
454
|
+
] }),
|
|
455
|
+
/* @__PURE__ */ e(
|
|
456
|
+
He,
|
|
457
|
+
{
|
|
458
|
+
condition: l.condition,
|
|
459
|
+
onChange: (r) => o({ ...l, condition: r })
|
|
460
|
+
}
|
|
461
|
+
),
|
|
462
|
+
/* @__PURE__ */ t(n, { sx: { borderTop: "1px solid #e2e8f0", pt: 1.5 }, children: [
|
|
463
|
+
/* @__PURE__ */ e(n, { component: "button", onClick: () => h((r) => !r), sx: { background: "none", border: "none", cursor: "pointer", display: "flex", alignItems: "center", gap: 0.5, p: 0, mb: i ? 1.25 : 0 }, children: /* @__PURE__ */ t("span", { style: { ...R, margin: 0, color: i ? "#6366f1" : "#94a3b8" }, children: [
|
|
464
|
+
i ? "▾" : "▸",
|
|
465
|
+
" Optional settings"
|
|
466
|
+
] }) }),
|
|
467
|
+
/* @__PURE__ */ e(Ie, { in: i, children: /* @__PURE__ */ t(n, { sx: { display: "flex", flexDirection: "column", gap: 1.25 }, children: [
|
|
468
|
+
/* @__PURE__ */ t(n, { sx: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 1 }, children: [
|
|
469
|
+
/* @__PURE__ */ t(n, { children: [
|
|
470
|
+
/* @__PURE__ */ e("label", { className: m, children: "Placeholder" }),
|
|
471
|
+
/* @__PURE__ */ e("input", { className: v, value: l.placeholder ?? "", onChange: (r) => u("placeholder", r.target.value || void 0), placeholder: "Hint text…" })
|
|
472
|
+
] }),
|
|
473
|
+
/* @__PURE__ */ t(n, { children: [
|
|
474
|
+
/* @__PURE__ */ e("label", { className: m, children: "Helper text" }),
|
|
475
|
+
/* @__PURE__ */ e("input", { className: v, value: l.helperText ?? "", onChange: (r) => u("helperText", r.target.value || void 0), placeholder: "Description…" })
|
|
476
|
+
] })
|
|
477
|
+
] }),
|
|
478
|
+
/* @__PURE__ */ t(n, { children: [
|
|
479
|
+
/* @__PURE__ */ e("label", { className: m, children: "Info tooltip" }),
|
|
480
|
+
/* @__PURE__ */ e("input", { className: v, value: l.info ?? "", onChange: (r) => u("info", r.target.value || void 0), placeholder: "Shown in ℹ tooltip" })
|
|
481
|
+
] }),
|
|
482
|
+
/* @__PURE__ */ t(n, { sx: { display: "flex", flexWrap: "wrap", gap: 1.5 }, children: [
|
|
483
|
+
/* @__PURE__ */ e(D, { id: `${s}-req`, label: "Required", checked: !!l.required, onChange: (r) => u("required", r || void 0) }),
|
|
484
|
+
/* @__PURE__ */ e(D, { id: `${s}-dis`, label: "Disabled", checked: !!l.disabled, onChange: (r) => u("disabled", r || void 0) }),
|
|
485
|
+
/* @__PURE__ */ e(D, { id: `${s}-hid`, label: "Hidden", checked: !!l.hidden, onChange: (r) => u("hidden", r || void 0) }),
|
|
486
|
+
/* @__PURE__ */ e(D, { id: `${s}-opt`, label: "Show optional", checked: !!l.showOptional, onChange: (r) => u("showOptional", r || void 0) }),
|
|
487
|
+
/* @__PURE__ */ e(D, { id: `${s}-div`, label: "Divider after", checked: !!l.dividerAfter, onChange: (r) => u("dividerAfter", r || void 0) }),
|
|
488
|
+
/* @__PURE__ */ e(D, { id: `${s}-frm`, label: "Formula input", checked: !!l.formula, onChange: (r) => u("formula", r || void 0) })
|
|
489
|
+
] })
|
|
490
|
+
] }) })
|
|
491
|
+
] })
|
|
492
|
+
] }),
|
|
493
|
+
!a && /* @__PURE__ */ t(n, { sx: { borderTop: "1px solid #e2e8f0", px: 2.5, py: 1.5, display: "flex", gap: 1, justifyContent: "flex-end", bgcolor: "#f8fafc", flexShrink: 0 }, children: [
|
|
494
|
+
/* @__PURE__ */ e(n, { component: "button", onClick: c, sx: { background: "none", border: "1px solid #dee2e6", cursor: "pointer", fontSize: 13, fontWeight: 500, px: 2, py: 0.75, borderRadius: "7px", color: "#6c757d", "&:hover": { bgcolor: "#f8f9fa" } }, children: "Cancel" }),
|
|
495
|
+
/* @__PURE__ */ t(n, { component: "button", onClick: p, sx: { border: "none", cursor: "pointer", fontSize: 13, fontWeight: 600, px: 2.5, py: 0.75, borderRadius: "7px", bgcolor: "#6366f1", color: "#fff", display: "flex", alignItems: "center", gap: 0.75, "&:hover": { bgcolor: "#4f46e5" } }, children: [
|
|
496
|
+
/* @__PURE__ */ e(G, { size: 15 }),
|
|
497
|
+
" Save"
|
|
498
|
+
] })
|
|
499
|
+
] })
|
|
500
|
+
] });
|
|
501
|
+
}
|
|
502
|
+
const H = {
|
|
503
|
+
text: "#0f172a",
|
|
504
|
+
textMuted: "#64748b",
|
|
505
|
+
borderInput: "rgba(0,0,0,0.23)",
|
|
506
|
+
bg: "#ffffff"
|
|
507
|
+
}, qe = {
|
|
508
|
+
md: "6px"
|
|
509
|
+
}, ve = {
|
|
510
|
+
sm: 11,
|
|
511
|
+
md: 13
|
|
512
|
+
}, ne = {
|
|
513
|
+
width: "100%",
|
|
514
|
+
fontSize: ve.md,
|
|
515
|
+
fontFamily: "inherit",
|
|
516
|
+
padding: "8px 12px",
|
|
517
|
+
border: `1px solid ${H.borderInput}`,
|
|
518
|
+
borderRadius: qe.md,
|
|
519
|
+
outline: "none",
|
|
520
|
+
background: H.bg,
|
|
521
|
+
color: H.text,
|
|
522
|
+
boxSizing: "border-box",
|
|
523
|
+
transition: "border-color 0.15s, box-shadow 0.15s"
|
|
524
|
+
};
|
|
525
|
+
function ce() {
|
|
526
|
+
return { type: "text", id: "", label: "", colSpan: 12 };
|
|
527
|
+
}
|
|
528
|
+
function Ye(l) {
|
|
529
|
+
return l.type === "object" || l.type === "array" || l.type === "schema";
|
|
530
|
+
}
|
|
531
|
+
function Ge(l) {
|
|
532
|
+
if (l.type === "object") return "Child Fields";
|
|
533
|
+
if (l.type === "schema") return "Schema Fields";
|
|
534
|
+
const o = l.itemType ?? "text";
|
|
535
|
+
return o === "object" ? "Item Fields" : o === "select" ? "Item Options" : "Item Config";
|
|
536
|
+
}
|
|
537
|
+
function Je({ field: l, onChange: o }) {
|
|
538
|
+
var a;
|
|
539
|
+
const p = l, c = p.itemType ?? "text";
|
|
540
|
+
if (l.type === "object")
|
|
541
|
+
return /* @__PURE__ */ t(n, { sx: { p: 2.5 }, children: [
|
|
542
|
+
/* @__PURE__ */ e(S, { sx: { fontSize: 12, color: "#64748b", mb: 2 }, children: "Define the fields nested inside this object. Each child field can itself be an object or array." }),
|
|
543
|
+
/* @__PURE__ */ e(
|
|
544
|
+
U,
|
|
545
|
+
{
|
|
546
|
+
value: l.children ?? [],
|
|
547
|
+
onChange: (i) => o({ ...l, children: i }),
|
|
548
|
+
label: "Child fields"
|
|
549
|
+
}
|
|
550
|
+
)
|
|
551
|
+
] });
|
|
552
|
+
if (l.type === "schema")
|
|
553
|
+
return /* @__PURE__ */ t(n, { sx: { p: 2.5 }, children: [
|
|
554
|
+
/* @__PURE__ */ e(S, { sx: { fontSize: 12, color: "#64748b", mb: 2 }, children: "Define the fields inside this schema. When the form is filled, their values are collected into a single object as this field's value." }),
|
|
555
|
+
/* @__PURE__ */ e(
|
|
556
|
+
U,
|
|
557
|
+
{
|
|
558
|
+
value: l.children ?? [],
|
|
559
|
+
onChange: (i) => o({ ...l, children: i }),
|
|
560
|
+
label: "Schema fields"
|
|
561
|
+
}
|
|
562
|
+
)
|
|
563
|
+
] });
|
|
564
|
+
if (l.type === "array") {
|
|
565
|
+
if (c === "object")
|
|
566
|
+
return /* @__PURE__ */ t(n, { sx: { p: 2.5 }, children: [
|
|
567
|
+
/* @__PURE__ */ e(S, { sx: { fontSize: 12, color: "#64748b", mb: 2 }, children: "Define the fields for each item in the array. Each item will be an object with these fields." }),
|
|
568
|
+
/* @__PURE__ */ e(
|
|
569
|
+
U,
|
|
570
|
+
{
|
|
571
|
+
value: p.itemFields ?? [],
|
|
572
|
+
onChange: (i) => o({ ...l, itemFields: i }),
|
|
573
|
+
label: "Item fields"
|
|
574
|
+
}
|
|
575
|
+
)
|
|
576
|
+
] });
|
|
577
|
+
if (c === "select") {
|
|
578
|
+
const i = p.itemOptions ?? [];
|
|
579
|
+
return /* @__PURE__ */ t(n, { sx: { p: 2.5 }, children: [
|
|
580
|
+
/* @__PURE__ */ e(S, { sx: { fontSize: 12, color: "#64748b", mb: 2 }, children: "Options available in each select item." }),
|
|
581
|
+
/* @__PURE__ */ e(n, { sx: { display: "flex", flexDirection: "column", gap: 0.5, mb: 0.75 }, children: i.map((h, s) => /* @__PURE__ */ t(n, { sx: { display: "flex", gap: 0.5, alignItems: "center" }, children: [
|
|
582
|
+
/* @__PURE__ */ e(
|
|
583
|
+
"input",
|
|
584
|
+
{
|
|
585
|
+
style: { ...ne, flex: 1, padding: "6px 10px" },
|
|
586
|
+
placeholder: "Label",
|
|
587
|
+
value: h.label,
|
|
588
|
+
onChange: (d) => {
|
|
589
|
+
const x = i.map((y, N) => N === s ? { ...y, label: d.target.value } : y);
|
|
590
|
+
o({ ...l, itemOptions: x });
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
),
|
|
594
|
+
/* @__PURE__ */ e(
|
|
595
|
+
"input",
|
|
596
|
+
{
|
|
597
|
+
style: { ...ne, flex: 1, padding: "6px 10px" },
|
|
598
|
+
placeholder: "Value",
|
|
599
|
+
value: h.value,
|
|
600
|
+
onChange: (d) => {
|
|
601
|
+
const x = i.map((y, N) => N === s ? { ...y, value: d.target.value } : y);
|
|
602
|
+
o({ ...l, itemOptions: x });
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
),
|
|
606
|
+
/* @__PURE__ */ e(
|
|
607
|
+
n,
|
|
608
|
+
{
|
|
609
|
+
component: "button",
|
|
610
|
+
onClick: () => o({ ...l, itemOptions: i.filter((d, x) => x !== s) }),
|
|
611
|
+
sx: { background: "none", border: "none", cursor: "pointer", color: "#94a3b8", display: "flex", p: 0.25, "&:hover": { color: "#dc2626" } },
|
|
612
|
+
children: "✕"
|
|
613
|
+
}
|
|
614
|
+
)
|
|
615
|
+
] }, s)) }),
|
|
616
|
+
/* @__PURE__ */ e(
|
|
617
|
+
n,
|
|
618
|
+
{
|
|
619
|
+
component: "button",
|
|
620
|
+
onClick: () => o({ ...l, itemOptions: [...i, { label: "", value: "" }] }),
|
|
621
|
+
sx: { display: "flex", alignItems: "center", gap: 0.5, background: "none", border: "1px dashed #dee2e6", cursor: "pointer", fontSize: 11, fontWeight: 600, px: 1, py: 0.5, borderRadius: "6px", color: "#6366f1", width: "100%", justifyContent: "center", "&:hover": { borderColor: "#6366f1", bgcolor: "#f5f3ff" } },
|
|
622
|
+
children: "+ Add option"
|
|
623
|
+
}
|
|
624
|
+
)
|
|
625
|
+
] });
|
|
626
|
+
}
|
|
627
|
+
if (c === "array") {
|
|
628
|
+
const i = ((a = p.itemSchema) == null ? void 0 : a.itemType) ?? "text", h = [
|
|
629
|
+
{ value: "text", label: "Text" },
|
|
630
|
+
{ value: "number", label: "Number" },
|
|
631
|
+
{ value: "email", label: "Email" },
|
|
632
|
+
{ value: "url", label: "URL" },
|
|
633
|
+
{ value: "password", label: "Password" },
|
|
634
|
+
{ value: "select", label: "Select" },
|
|
635
|
+
{ value: "object", label: "Object" }
|
|
636
|
+
];
|
|
637
|
+
return /* @__PURE__ */ t(n, { sx: { p: 2.5 }, children: [
|
|
638
|
+
/* @__PURE__ */ e(S, { sx: { fontSize: 12, color: "#64748b", mb: 2 }, children: "Each item is itself an array. Configure the type of items inside the nested array." }),
|
|
639
|
+
/* @__PURE__ */ e("label", { style: { fontSize: ve.sm, fontWeight: 600, color: H.textMuted, display: "block", marginBottom: 3 }, children: "Nested item type" }),
|
|
640
|
+
/* @__PURE__ */ e(
|
|
641
|
+
"select",
|
|
642
|
+
{
|
|
643
|
+
style: { ...ne, padding: "6px 10px", cursor: "pointer" },
|
|
644
|
+
value: i,
|
|
645
|
+
onChange: (s) => o({ ...l, itemSchema: { ...p.itemSchema ?? {}, itemType: s.target.value } }),
|
|
646
|
+
children: h.map((s) => /* @__PURE__ */ e("option", { value: s.value, children: s.label }, s.value))
|
|
647
|
+
}
|
|
648
|
+
)
|
|
649
|
+
] });
|
|
650
|
+
}
|
|
651
|
+
return /* @__PURE__ */ e(n, { sx: { p: 2.5 }, children: /* @__PURE__ */ t(n, { sx: { border: "1.5px dashed #e2e8f0", borderRadius: "8px", py: 3, textAlign: "center" }, children: [
|
|
652
|
+
/* @__PURE__ */ t(S, { sx: { fontSize: 13, color: "#94a3b8" }, children: [
|
|
653
|
+
"No extra configuration needed for ",
|
|
654
|
+
/* @__PURE__ */ e("strong", { children: c }),
|
|
655
|
+
" items."
|
|
656
|
+
] }),
|
|
657
|
+
/* @__PURE__ */ e(S, { sx: { fontSize: 11, color: "#cbd5e1", mt: 0.5 }, children: "Item placeholder and labels are set in the previous step." })
|
|
658
|
+
] }) });
|
|
659
|
+
}
|
|
660
|
+
return null;
|
|
661
|
+
}
|
|
662
|
+
function Ke({ field: l }) {
|
|
663
|
+
var h;
|
|
664
|
+
const [o, p] = T({}), c = l.id ?? l.name ?? "preview", a = [
|
|
665
|
+
{ value: 3, label: "1/4" },
|
|
666
|
+
{ value: 4, label: "1/3" },
|
|
667
|
+
{ value: 6, label: "1/2" },
|
|
668
|
+
{ value: 8, label: "2/3" },
|
|
669
|
+
{ value: 12, label: "Full" }
|
|
670
|
+
], i = l.colSpan && l.colSpan < 12 ? ((h = a.find((s) => s.value === l.colSpan)) == null ? void 0 : h.label) ?? l.colSpan : "Full";
|
|
671
|
+
return /* @__PURE__ */ t(n, { sx: { p: 2.5 }, children: [
|
|
672
|
+
/* @__PURE__ */ t(n, { sx: { display: "flex", alignItems: "center", mb: 2, px: 1.25, py: 0.75, bgcolor: "#f0fdf4", border: "1px solid #bbf7d0", borderRadius: "7px" }, children: [
|
|
673
|
+
/* @__PURE__ */ e(S, { sx: { fontSize: 11, color: "#15803d", fontWeight: 500, flex: 1 }, children: "Live preview — interact to test the field" }),
|
|
674
|
+
/* @__PURE__ */ t(S, { sx: { fontSize: 11, color: "#64748b" }, children: [
|
|
675
|
+
"Width: ",
|
|
676
|
+
i
|
|
677
|
+
] })
|
|
678
|
+
] }),
|
|
679
|
+
/* @__PURE__ */ e(
|
|
680
|
+
ie,
|
|
681
|
+
{
|
|
682
|
+
schema: { layout: "flat", fields: [l] },
|
|
683
|
+
initialValues: { [c]: l.type === "array" ? [] : l.type === "object" || l.type === "schema" ? {} : "" },
|
|
684
|
+
onSubmit: () => {
|
|
685
|
+
},
|
|
686
|
+
conditionConfig: o,
|
|
687
|
+
onConditionConfigChange: p
|
|
688
|
+
}
|
|
689
|
+
)
|
|
690
|
+
] });
|
|
691
|
+
}
|
|
692
|
+
function re({ open: l, initial: o, onSave: p, onClose: c, editMode: a = !1 }) {
|
|
693
|
+
const [i, h] = T(1), [s, d] = T(() => o ?? ce());
|
|
694
|
+
function x() {
|
|
695
|
+
d(o ?? ce()), h(1);
|
|
696
|
+
}
|
|
697
|
+
const y = Ye(s), N = y ? 3 : 2, u = y ? ["Configure", Ge(s), "Preview"] : ["Configure", "Preview"], r = !!(s.id || s.name) && !!s.type;
|
|
698
|
+
function b() {
|
|
699
|
+
h((z) => Math.min(z + 1, N));
|
|
700
|
+
}
|
|
701
|
+
function f() {
|
|
702
|
+
h((z) => Math.max(z - 1, 1));
|
|
703
|
+
}
|
|
704
|
+
function C() {
|
|
705
|
+
p(s), c();
|
|
706
|
+
}
|
|
707
|
+
const g = i - 1, I = i === N, w = y && i === 3 || !y && i === 2;
|
|
708
|
+
return /* @__PURE__ */ t(
|
|
709
|
+
he,
|
|
710
|
+
{
|
|
711
|
+
open: l,
|
|
712
|
+
onClose: c,
|
|
713
|
+
TransitionProps: { onEnter: x },
|
|
714
|
+
maxWidth: "sm",
|
|
715
|
+
fullWidth: !0,
|
|
716
|
+
PaperProps: { sx: { borderRadius: "12px", overflow: "hidden", display: "flex", flexDirection: "column", maxHeight: "90vh" } },
|
|
717
|
+
children: [
|
|
718
|
+
/* @__PURE__ */ t(n, { sx: { px: 2.5, pt: 1.75, pb: 0, borderBottom: "1px solid #e2e8f0", flexShrink: 0 }, children: [
|
|
719
|
+
/* @__PURE__ */ t(n, { sx: { display: "flex", alignItems: "center", mb: 1.5 }, children: [
|
|
720
|
+
/* @__PURE__ */ e(S, { sx: { fontSize: 14, fontWeight: 700, color: "#0f172a", flex: 1 }, children: a ? "Edit Field" : "Add Field" }),
|
|
721
|
+
/* @__PURE__ */ e(Y, { size: "small", onClick: c, sx: { color: "#94a3b8" }, children: /* @__PURE__ */ e(_, { size: 17 }) })
|
|
722
|
+
] }),
|
|
723
|
+
/* @__PURE__ */ e(Fe, { activeStep: g, sx: { pb: 1.5 }, children: u.map((z, E) => /* @__PURE__ */ e(Oe, { completed: g > E, children: /* @__PURE__ */ e(Re, { children: z }) }, z)) })
|
|
724
|
+
] }),
|
|
725
|
+
/* @__PURE__ */ t(n, { sx: { flex: 1, overflowY: "auto" }, children: [
|
|
726
|
+
i === 1 && /* @__PURE__ */ e(ge, { field: s, onChange: d, onSave: b, onCancel: c, noFooter: !0 }),
|
|
727
|
+
i === 2 && y && /* @__PURE__ */ e(Je, { field: s, onChange: d }),
|
|
728
|
+
w && /* @__PURE__ */ e(Ke, { field: s })
|
|
729
|
+
] }),
|
|
730
|
+
/* @__PURE__ */ t(n, { sx: { borderTop: "1px solid #e2e8f0", px: 2.5, py: 1.5, display: "flex", alignItems: "center", gap: 1, flexShrink: 0, bgcolor: "#f8fafc" }, children: [
|
|
731
|
+
i > 1 && /* @__PURE__ */ t(n, { component: "button", onClick: f, sx: { display: "flex", alignItems: "center", gap: 0.5, background: "none", border: "none", cursor: "pointer", fontSize: 13, fontWeight: 500, color: "#6c757d", px: 0, "&:hover": { color: "#0f172a" } }, children: [
|
|
732
|
+
/* @__PURE__ */ e(fe, { size: 14 }),
|
|
733
|
+
" Back"
|
|
734
|
+
] }),
|
|
735
|
+
/* @__PURE__ */ e(n, { sx: { flex: 1 } }),
|
|
736
|
+
/* @__PURE__ */ e(n, { component: "button", onClick: c, sx: { background: "none", border: "1px solid #dee2e6", cursor: "pointer", fontSize: 13, fontWeight: 500, px: 2, py: 0.75, borderRadius: "7px", color: "#6c757d", "&:hover": { bgcolor: "#f8f9fa" } }, children: "Cancel" }),
|
|
737
|
+
I ? /* @__PURE__ */ t(n, { component: "button", onClick: C, sx: { border: "none", cursor: "pointer", fontSize: 13, fontWeight: 600, px: 2.5, py: 0.75, borderRadius: "7px", bgcolor: "#6366f1", color: "#fff", display: "flex", alignItems: "center", gap: 0.75, "&:hover": { bgcolor: "#4f46e5" } }, children: [
|
|
738
|
+
/* @__PURE__ */ e(G, { size: 15 }),
|
|
739
|
+
" ",
|
|
740
|
+
a ? "Save changes" : "Add field"
|
|
741
|
+
] }) : /* @__PURE__ */ e(n, { component: "button", onClick: b, disabled: !r, sx: { border: "none", cursor: r ? "pointer" : "not-allowed", fontSize: 13, fontWeight: 600, px: 2.5, py: 0.75, borderRadius: "7px", bgcolor: r ? "#6366f1" : "#c7d2fe", color: "#fff", "&:hover": { bgcolor: r ? "#4f46e5" : "#c7d2fe" } }, children: "Next →" })
|
|
742
|
+
] })
|
|
743
|
+
]
|
|
744
|
+
}
|
|
745
|
+
);
|
|
746
|
+
}
|
|
747
|
+
function Xe({ field: l, index: o, total: p, onEdit: c, onDelete: a, onMoveUp: i, onMoveDown: h }) {
|
|
748
|
+
const s = l.label || l.id || l.name || "Untitled", d = l.id ?? l.name ?? "";
|
|
749
|
+
return /* @__PURE__ */ t(n, { sx: { display: "flex", alignItems: "center", gap: 1, px: 1.5, py: 1, border: "1px solid #e2e8f0", borderRadius: "8px", bgcolor: "#fff" }, children: [
|
|
750
|
+
/* @__PURE__ */ t(n, { sx: { display: "flex", flexDirection: "column", gap: 0.25, color: "#cbd5e1" }, children: [
|
|
751
|
+
/* @__PURE__ */ e(n, { component: "button", onClick: i, disabled: o === 0, sx: { background: "none", border: "none", p: 0, cursor: o === 0 ? "default" : "pointer", color: o === 0 ? "#e2e8f0" : "#94a3b8", lineHeight: 1, fontSize: 10, "&:hover": { color: o === 0 ? "#e2e8f0" : "#475569" } }, children: "▲" }),
|
|
752
|
+
/* @__PURE__ */ e(n, { component: "button", onClick: h, disabled: o === p - 1, sx: { background: "none", border: "none", p: 0, cursor: o === p - 1 ? "default" : "pointer", color: o === p - 1 ? "#e2e8f0" : "#94a3b8", lineHeight: 1, fontSize: 10, "&:hover": { color: o === p - 1 ? "#e2e8f0" : "#475569" } }, children: "▼" })
|
|
753
|
+
] }),
|
|
754
|
+
/* @__PURE__ */ e(n, { sx: { fontSize: 10, fontWeight: 700, px: 0.75, py: 0.2, borderRadius: "4px", bgcolor: "#eef2ff", color: "#6366f1", flexShrink: 0 }, children: l.type }),
|
|
755
|
+
/* @__PURE__ */ t(n, { sx: { flex: 1, minWidth: 0 }, children: [
|
|
756
|
+
/* @__PURE__ */ t(S, { sx: { fontSize: 13, fontWeight: 600, color: "#0f172a", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: [
|
|
757
|
+
s,
|
|
758
|
+
l.required && /* @__PURE__ */ e(n, { component: "span", sx: { color: "#dc3545", ml: 0.25 }, children: "*" })
|
|
759
|
+
] }),
|
|
760
|
+
/* @__PURE__ */ e(S, { sx: { fontSize: 11, color: "#94a3b8", fontFamily: "monospace" }, children: d })
|
|
761
|
+
] }),
|
|
762
|
+
/* @__PURE__ */ e(A, { title: "Edit field", placement: "top", children: /* @__PURE__ */ e(n, { component: "button", onClick: c, sx: { background: "none", border: "none", cursor: "pointer", display: "flex", alignItems: "center", justifyContent: "center", width: 28, height: 28, borderRadius: "6px", p: 0, color: "#94a3b8", "&:hover": { bgcolor: "#f1f5f9", color: "#475569" } }, children: /* @__PURE__ */ e(De, { size: 14 }) }) }),
|
|
763
|
+
/* @__PURE__ */ e(A, { title: "Remove field", placement: "top", children: /* @__PURE__ */ e(n, { component: "button", onClick: a, sx: { background: "none", border: "none", cursor: "pointer", display: "flex", alignItems: "center", justifyContent: "center", width: 28, height: 28, borderRadius: "6px", p: 0, color: "#94a3b8", "&:hover": { bgcolor: "#fee2e2", color: "#dc2626" } }, children: /* @__PURE__ */ e(Pe, { size: 16 }) }) })
|
|
764
|
+
] });
|
|
765
|
+
}
|
|
766
|
+
function Ze({ open: l, value: o, onSave: p, onClose: c }) {
|
|
767
|
+
const [a, i] = T(o), [h, s] = T(null);
|
|
768
|
+
function d() {
|
|
769
|
+
i(o), s(null);
|
|
770
|
+
}
|
|
771
|
+
function x(b) {
|
|
772
|
+
i((f) => f.filter((C, g) => g !== b));
|
|
773
|
+
}
|
|
774
|
+
function y(b, f) {
|
|
775
|
+
i((C) => {
|
|
776
|
+
const g = [...C], I = b + f;
|
|
777
|
+
return I < 0 || I >= g.length ? C : ([g[b], g[I]] = [g[I], g[b]], g);
|
|
778
|
+
});
|
|
779
|
+
}
|
|
780
|
+
function N(b) {
|
|
781
|
+
h !== null && (i((f) => {
|
|
782
|
+
const C = [...f];
|
|
783
|
+
return C[h] = b, C;
|
|
784
|
+
}), s(null));
|
|
785
|
+
}
|
|
786
|
+
function u() {
|
|
787
|
+
p(a), c();
|
|
788
|
+
}
|
|
789
|
+
const r = JSON.stringify(a) !== JSON.stringify(o);
|
|
790
|
+
return /* @__PURE__ */ t(q, { children: [
|
|
791
|
+
/* @__PURE__ */ t(
|
|
792
|
+
he,
|
|
793
|
+
{
|
|
794
|
+
open: l,
|
|
795
|
+
onClose: c,
|
|
796
|
+
TransitionProps: { onEnter: d },
|
|
797
|
+
maxWidth: "sm",
|
|
798
|
+
fullWidth: !0,
|
|
799
|
+
PaperProps: { sx: { borderRadius: "12px", overflow: "hidden", display: "flex", flexDirection: "column", maxHeight: "85vh" } },
|
|
800
|
+
children: [
|
|
801
|
+
/* @__PURE__ */ t(n, { sx: { display: "flex", alignItems: "center", px: 2.5, py: 1.75, borderBottom: "1px solid #e2e8f0", flexShrink: 0 }, children: [
|
|
802
|
+
/* @__PURE__ */ t(n, { sx: { flex: 1 }, children: [
|
|
803
|
+
/* @__PURE__ */ e(S, { sx: { fontSize: 14, fontWeight: 700, color: "#0f172a" }, children: "Edit Schema" }),
|
|
804
|
+
/* @__PURE__ */ t(S, { sx: { fontSize: 11, color: "#94a3b8" }, children: [
|
|
805
|
+
a.length,
|
|
806
|
+
" field",
|
|
807
|
+
a.length !== 1 ? "s" : "",
|
|
808
|
+
" defined"
|
|
809
|
+
] })
|
|
810
|
+
] }),
|
|
811
|
+
/* @__PURE__ */ e(Y, { size: "small", onClick: c, sx: { color: "#94a3b8" }, children: /* @__PURE__ */ e(_, { size: 17 }) })
|
|
812
|
+
] }),
|
|
813
|
+
/* @__PURE__ */ e(n, { sx: { flex: 1, overflowY: "auto", p: 2.5 }, children: a.length === 0 ? /* @__PURE__ */ e(n, { sx: { border: "1.5px dashed rgba(0,0,0,0.12)", borderRadius: "8px", py: 4, textAlign: "center" }, children: /* @__PURE__ */ e(S, { sx: { fontSize: 13, color: "#94a3b8" }, children: "No fields defined yet" }) }) : /* @__PURE__ */ e(n, { sx: { display: "flex", flexDirection: "column", gap: 0.75 }, children: a.map((b, f) => /* @__PURE__ */ e(
|
|
814
|
+
Xe,
|
|
815
|
+
{
|
|
816
|
+
field: b,
|
|
817
|
+
index: f,
|
|
818
|
+
total: a.length,
|
|
819
|
+
onEdit: () => s(f),
|
|
820
|
+
onDelete: () => x(f),
|
|
821
|
+
onMoveUp: () => y(f, -1),
|
|
822
|
+
onMoveDown: () => y(f, 1)
|
|
823
|
+
},
|
|
824
|
+
`${b.id ?? b.name}-${f}`
|
|
825
|
+
)) }) }),
|
|
826
|
+
/* @__PURE__ */ t(n, { sx: { borderTop: "1px solid #e2e8f0", px: 2.5, py: 1.5, display: "flex", alignItems: "center", gap: 1, flexShrink: 0, bgcolor: "#f8fafc" }, children: [
|
|
827
|
+
r ? /* @__PURE__ */ e(S, { sx: { fontSize: 11, color: "#f59e0b", fontWeight: 500, flex: 1 }, children: "Unsaved changes" }) : /* @__PURE__ */ e(n, { sx: { flex: 1 } }),
|
|
828
|
+
/* @__PURE__ */ e(n, { component: "button", onClick: c, sx: { background: "none", border: "1px solid #dee2e6", cursor: "pointer", fontSize: 13, fontWeight: 500, px: 2, py: 0.75, borderRadius: "7px", color: "#6c757d", "&:hover": { bgcolor: "#f8f9fa" } }, children: "Cancel" }),
|
|
829
|
+
/* @__PURE__ */ t(n, { component: "button", onClick: u, sx: { border: "none", cursor: "pointer", fontSize: 13, fontWeight: 600, px: 2.5, py: 0.75, borderRadius: "7px", bgcolor: "#6366f1", color: "#fff", display: "flex", alignItems: "center", gap: 0.75, "&:hover": { bgcolor: "#4f46e5" } }, children: [
|
|
830
|
+
/* @__PURE__ */ e(G, { size: 15 }),
|
|
831
|
+
" Done"
|
|
832
|
+
] })
|
|
833
|
+
] })
|
|
834
|
+
]
|
|
835
|
+
}
|
|
836
|
+
),
|
|
837
|
+
h !== null && /* @__PURE__ */ e(
|
|
838
|
+
re,
|
|
839
|
+
{
|
|
840
|
+
open: h !== null,
|
|
841
|
+
initial: a[h],
|
|
842
|
+
onSave: N,
|
|
843
|
+
onClose: () => s(null),
|
|
844
|
+
editMode: !0
|
|
845
|
+
}
|
|
846
|
+
)
|
|
847
|
+
] });
|
|
848
|
+
}
|
|
849
|
+
function ye(l) {
|
|
850
|
+
const o = {};
|
|
851
|
+
for (const p of l) {
|
|
852
|
+
const c = p.id ?? p.name ?? "";
|
|
853
|
+
c && (p.type === "array" ? o[c] = [] : p.type === "object" || p.type === "schema" ? o[c] = ye(p.children ?? []) : o[c] = "");
|
|
854
|
+
}
|
|
855
|
+
return o;
|
|
856
|
+
}
|
|
857
|
+
function U({
|
|
858
|
+
value: l,
|
|
859
|
+
onChange: o,
|
|
860
|
+
suggestions: p,
|
|
861
|
+
label: c = "Fields",
|
|
862
|
+
onPayload: a,
|
|
863
|
+
validate: i = !0,
|
|
864
|
+
onValidityChange: h,
|
|
865
|
+
variableGroups: s,
|
|
866
|
+
initialValues: d,
|
|
867
|
+
initialFormulaConfig: x,
|
|
868
|
+
initialConditionConfig: y
|
|
869
|
+
}) {
|
|
870
|
+
const [N, u] = T(!1), [r, b] = T(!1), [f, C] = T(null), [g, I] = T(x ?? {}), [w, z] = T(y ?? {}), E = M(d ?? {}), j = P(() => ye(l), [l]), K = P(
|
|
871
|
+
() => d && Object.keys(d).length > 0 ? { ...j, ...d } : j,
|
|
872
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
873
|
+
[j, d]
|
|
874
|
+
), L = P(
|
|
875
|
+
() => i ? pe(l) : void 0,
|
|
876
|
+
[i, l]
|
|
877
|
+
);
|
|
878
|
+
de(() => {
|
|
879
|
+
a && a({
|
|
880
|
+
schema: l,
|
|
881
|
+
formulaConfig: g,
|
|
882
|
+
conditionConfig: w,
|
|
883
|
+
conditionExpressions: se(w),
|
|
884
|
+
values: E.current,
|
|
885
|
+
evaluationPayload: oe({ values: E.current, conditionConfig: w })
|
|
886
|
+
});
|
|
887
|
+
}, [w, g, l]);
|
|
888
|
+
const X = te((F) => {
|
|
889
|
+
E.current = F, a && a({
|
|
890
|
+
schema: l,
|
|
891
|
+
formulaConfig: g,
|
|
892
|
+
conditionConfig: w,
|
|
893
|
+
conditionExpressions: se(w),
|
|
894
|
+
values: F,
|
|
895
|
+
evaluationPayload: oe({ values: F, conditionConfig: w })
|
|
896
|
+
});
|
|
897
|
+
}, [l, g, w, a]);
|
|
898
|
+
function $(F) {
|
|
899
|
+
o([...l, F]);
|
|
900
|
+
}
|
|
901
|
+
function Z(F) {
|
|
902
|
+
if (!f) return;
|
|
903
|
+
const { containerFieldId: V, tabId: Q } = f, ee = l.map((O) => {
|
|
904
|
+
if ((O.id ?? O.name) !== V) return O;
|
|
905
|
+
const le = O.tabs ?? [];
|
|
906
|
+
return {
|
|
907
|
+
...O,
|
|
908
|
+
tabs: le.map(
|
|
909
|
+
(W) => W.id === Q ? { ...W, fields: [...W.fields ?? [], F] } : W
|
|
910
|
+
)
|
|
911
|
+
};
|
|
912
|
+
});
|
|
913
|
+
o(ee), C(null);
|
|
914
|
+
}
|
|
915
|
+
function k(F, V, Q) {
|
|
916
|
+
const ee = l.map((O) => {
|
|
917
|
+
if ((O.id ?? O.name) !== F) return O;
|
|
918
|
+
const le = O.tabs ?? [];
|
|
919
|
+
return {
|
|
920
|
+
...O,
|
|
921
|
+
tabs: le.map(
|
|
922
|
+
(W) => W.id === V ? { ...W, fields: (W.fields ?? []).filter((el, Se) => Se !== Q) } : W
|
|
923
|
+
)
|
|
924
|
+
};
|
|
925
|
+
});
|
|
926
|
+
o(ee);
|
|
927
|
+
}
|
|
928
|
+
const Ce = P(() => ({
|
|
929
|
+
openAddFieldDialog: (F, V) => C({ containerFieldId: F, tabId: V }),
|
|
930
|
+
removeFieldFromTab: k
|
|
931
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
932
|
+
}), [l, o]), ae = /* @__PURE__ */ t("div", { className: "schema-builder-root", children: [
|
|
933
|
+
l.length > 0 && /* @__PURE__ */ e("div", { className: "schema-builder-header", children: /* @__PURE__ */ t("div", { className: "schema-builder-actions", children: [
|
|
934
|
+
/* @__PURE__ */ e(A, { title: "Edit schema", placement: "top", children: /* @__PURE__ */ t(
|
|
935
|
+
"button",
|
|
936
|
+
{
|
|
937
|
+
className: "sb-btn sb-btn-outline",
|
|
938
|
+
onClick: () => b(!0),
|
|
939
|
+
children: [
|
|
940
|
+
/* @__PURE__ */ e(be, { size: 13 }),
|
|
941
|
+
" Edit Schema"
|
|
942
|
+
]
|
|
943
|
+
}
|
|
944
|
+
) }),
|
|
945
|
+
/* @__PURE__ */ e(A, { title: "Add a new field", placement: "top", children: /* @__PURE__ */ t(
|
|
946
|
+
"button",
|
|
947
|
+
{
|
|
948
|
+
className: "sb-btn sb-btn-primary",
|
|
949
|
+
onClick: () => u(!0),
|
|
950
|
+
children: [
|
|
951
|
+
/* @__PURE__ */ e(J, { size: 14 }),
|
|
952
|
+
" Add Field"
|
|
953
|
+
]
|
|
954
|
+
}
|
|
955
|
+
) })
|
|
956
|
+
] }) }),
|
|
957
|
+
l.length > 0 ? /* @__PURE__ */ e(ze.Provider, { value: Ce, children: /* @__PURE__ */ e(
|
|
958
|
+
ie,
|
|
959
|
+
{
|
|
960
|
+
schema: { layout: "flat", fields: l },
|
|
961
|
+
initialValues: K,
|
|
962
|
+
onSubmit: () => {
|
|
963
|
+
},
|
|
964
|
+
validationSchema: L,
|
|
965
|
+
onValidityChange: h,
|
|
966
|
+
onValuesChange: a ? X : void 0,
|
|
967
|
+
formulaConfig: g,
|
|
968
|
+
onFormulaConfigChange: I,
|
|
969
|
+
conditionConfig: w,
|
|
970
|
+
onConditionConfigChange: z
|
|
971
|
+
}
|
|
972
|
+
) }) : /* @__PURE__ */ t("div", { className: "schema-builder-empty-state", children: [
|
|
973
|
+
/* @__PURE__ */ e(_e, { size: 40, className: "schema-builder-empty-icon" }),
|
|
974
|
+
/* @__PURE__ */ e("p", { className: "schema-builder-empty-title", children: "Tell us what fields should be in the list, and assign values to them." }),
|
|
975
|
+
/* @__PURE__ */ e("div", { className: "schema-builder-empty-actions", children: /* @__PURE__ */ e(
|
|
976
|
+
"button",
|
|
977
|
+
{
|
|
978
|
+
className: "btn",
|
|
979
|
+
onClick: () => u(!0),
|
|
980
|
+
children: "Add field"
|
|
981
|
+
}
|
|
982
|
+
) })
|
|
983
|
+
] }),
|
|
984
|
+
/* @__PURE__ */ e(
|
|
985
|
+
re,
|
|
986
|
+
{
|
|
987
|
+
open: N,
|
|
988
|
+
onSave: $,
|
|
989
|
+
onClose: () => u(!1)
|
|
990
|
+
}
|
|
991
|
+
),
|
|
992
|
+
/* @__PURE__ */ e(
|
|
993
|
+
Ze,
|
|
994
|
+
{
|
|
995
|
+
open: r,
|
|
996
|
+
value: l,
|
|
997
|
+
onSave: o,
|
|
998
|
+
onClose: () => b(!1)
|
|
999
|
+
}
|
|
1000
|
+
),
|
|
1001
|
+
/* @__PURE__ */ e(
|
|
1002
|
+
re,
|
|
1003
|
+
{
|
|
1004
|
+
open: !!f,
|
|
1005
|
+
onSave: Z,
|
|
1006
|
+
onClose: () => C(null)
|
|
1007
|
+
}
|
|
1008
|
+
)
|
|
1009
|
+
] });
|
|
1010
|
+
return s ? /* @__PURE__ */ t(Te, { groups: s, children: [
|
|
1011
|
+
/* @__PURE__ */ e(we, { width: 260, mode: "popover" }),
|
|
1012
|
+
ae
|
|
1013
|
+
] }) : ae;
|
|
1014
|
+
}
|
|
1015
|
+
function Qe({ fields: l, onOpen: o }) {
|
|
1016
|
+
return /* @__PURE__ */ t(n, { sx: { border: "1px solid #e2e8f0", borderRadius: "8px", bgcolor: "#fff", overflow: "hidden" }, children: [
|
|
1017
|
+
l.length > 0 ? /* @__PURE__ */ e(n, { sx: { px: 1.5, py: 1.25, display: "flex", flexWrap: "wrap", gap: 0.5 }, children: l.map((p, c) => {
|
|
1018
|
+
const a = p.id ?? p.name ?? "";
|
|
1019
|
+
return /* @__PURE__ */ e(A, { title: `${p.type} · ${a}`, placement: "top", children: /* @__PURE__ */ e(
|
|
1020
|
+
We,
|
|
1021
|
+
{
|
|
1022
|
+
label: p.label || a,
|
|
1023
|
+
size: "small",
|
|
1024
|
+
sx: { fontSize: 11, fontWeight: 500, height: 22, bgcolor: "#f1f5f9", color: "#334155", border: "1px solid #e2e8f0", "& .MuiChip-label": { px: 1 } }
|
|
1025
|
+
}
|
|
1026
|
+
) }, c);
|
|
1027
|
+
}) }) : /* @__PURE__ */ e(n, { sx: { px: 1.5, py: 1.5 }, children: /* @__PURE__ */ e(S, { sx: { fontSize: 12, color: "#94a3b8" }, children: "No fields defined yet" }) }),
|
|
1028
|
+
/* @__PURE__ */ e(Ae, { sx: { borderColor: "#f1f5f9" } }),
|
|
1029
|
+
/* @__PURE__ */ t(n, { onClick: o, sx: { display: "flex", alignItems: "center", gap: 0.75, px: 1.5, py: 1, cursor: "pointer", "&:hover": { bgcolor: "#f8fafc" }, transition: "background 0.12s" }, children: [
|
|
1030
|
+
l.length === 0 ? /* @__PURE__ */ e(J, { size: 14, color: "#6366f1" }) : /* @__PURE__ */ e(be, { size: 13, color: "#6366f1" }),
|
|
1031
|
+
/* @__PURE__ */ e(S, { sx: { fontSize: 12, fontWeight: 600, color: "#6366f1", flex: 1 }, children: l.length === 0 ? "Add fields" : "Configure fields" }),
|
|
1032
|
+
/* @__PURE__ */ e(Me, { size: 13, color: "#94a3b8" })
|
|
1033
|
+
] })
|
|
1034
|
+
] });
|
|
1035
|
+
}
|
|
1036
|
+
function cl({
|
|
1037
|
+
value: l,
|
|
1038
|
+
onChange: o,
|
|
1039
|
+
suggestions: p,
|
|
1040
|
+
onPayload: c,
|
|
1041
|
+
onDone: a,
|
|
1042
|
+
validate: i,
|
|
1043
|
+
onValidityChange: h,
|
|
1044
|
+
label: s = "Fields",
|
|
1045
|
+
drawerTitle: d = "Configure Fields",
|
|
1046
|
+
drawerWidth: x = 580
|
|
1047
|
+
}) {
|
|
1048
|
+
const [y, N] = T(!1), [u, r] = T({ type: "list" }), [b, f] = T(l), C = M(null), g = M(void 0), I = M(void 0), w = M(void 0), [z, E] = T(null);
|
|
1049
|
+
function j() {
|
|
1050
|
+
f(l), r({ type: "list" }), N(!0);
|
|
1051
|
+
}
|
|
1052
|
+
function K() {
|
|
1053
|
+
const k = C.current;
|
|
1054
|
+
k && (g.current = k.values, I.current = k.formulaConfig, w.current = k.conditionConfig), o(b), N(!1), a == null || a(b, k);
|
|
1055
|
+
}
|
|
1056
|
+
function L() {
|
|
1057
|
+
const k = C.current;
|
|
1058
|
+
k && (g.current = k.values, I.current = k.formulaConfig, w.current = k.conditionConfig), f(l), N(!1);
|
|
1059
|
+
}
|
|
1060
|
+
function X() {
|
|
1061
|
+
if (u.type !== "edit" || !z) return;
|
|
1062
|
+
const k = [...b];
|
|
1063
|
+
k[u.index] = z, f(k), r({ type: "list" }), E(null);
|
|
1064
|
+
}
|
|
1065
|
+
function $() {
|
|
1066
|
+
r({ type: "list" }), E(null);
|
|
1067
|
+
}
|
|
1068
|
+
const Z = JSON.stringify(b) !== JSON.stringify(l);
|
|
1069
|
+
return u.type === "edit" && b[u.index], /* @__PURE__ */ t(q, { children: [
|
|
1070
|
+
/* @__PURE__ */ t(n, { children: [
|
|
1071
|
+
/* @__PURE__ */ e(S, { sx: { fontSize: 12, fontWeight: 700, color: "#64748b", textTransform: "uppercase", letterSpacing: 0.5, mb: 0.75 }, children: s }),
|
|
1072
|
+
/* @__PURE__ */ e(Qe, { fields: l, onOpen: j })
|
|
1073
|
+
] }),
|
|
1074
|
+
/* @__PURE__ */ t(
|
|
1075
|
+
Ee,
|
|
1076
|
+
{
|
|
1077
|
+
anchor: "right",
|
|
1078
|
+
open: y,
|
|
1079
|
+
onClose: L,
|
|
1080
|
+
PaperProps: { sx: { width: x, display: "flex", flexDirection: "column", boxShadow: "-4px 0 24px rgba(0,0,0,0.12)", overflow: "hidden" } },
|
|
1081
|
+
children: [
|
|
1082
|
+
/* @__PURE__ */ t(n, { sx: { display: "flex", alignItems: "center", px: 2, py: 1.5, borderBottom: "1px solid #e2e8f0", flexShrink: 0, gap: 1 }, children: [
|
|
1083
|
+
u.type === "edit" && /* @__PURE__ */ e(A, { title: "Back to fields", placement: "bottom", children: /* @__PURE__ */ e(Y, { size: "small", onClick: $, sx: { color: "#64748b" }, children: /* @__PURE__ */ e(fe, { size: 17 }) }) }),
|
|
1084
|
+
/* @__PURE__ */ t(n, { sx: { flex: 1 }, children: [
|
|
1085
|
+
/* @__PURE__ */ e(S, { sx: { fontSize: 14, fontWeight: 700, color: "#0f172a" }, children: u.type === "edit" ? (z == null ? void 0 : z.label) || (z == null ? void 0 : z.id) || "Edit field" : d }),
|
|
1086
|
+
/* @__PURE__ */ e(S, { sx: { fontSize: 11, color: "#94a3b8" }, children: u.type === "edit" ? "Configure field properties" : `${b.length} field${b.length !== 1 ? "s" : ""} defined` })
|
|
1087
|
+
] }),
|
|
1088
|
+
u.type === "list" && /* @__PURE__ */ e(A, { title: "Close", placement: "bottom", children: /* @__PURE__ */ e(Y, { size: "small", onClick: L, sx: { color: "#94a3b8" }, children: /* @__PURE__ */ e(_, { size: 17 }) }) })
|
|
1089
|
+
] }),
|
|
1090
|
+
u.type === "list" && /* @__PURE__ */ t(q, { children: [
|
|
1091
|
+
/* @__PURE__ */ e(n, { sx: { flex: 1, overflowY: "auto", p: 2.5 }, children: /* @__PURE__ */ e(
|
|
1092
|
+
U,
|
|
1093
|
+
{
|
|
1094
|
+
value: b,
|
|
1095
|
+
onChange: f,
|
|
1096
|
+
suggestions: p,
|
|
1097
|
+
onPayload: (k) => {
|
|
1098
|
+
C.current = k, g.current = k.values, I.current = k.formulaConfig, w.current = k.conditionConfig, c == null || c(k);
|
|
1099
|
+
},
|
|
1100
|
+
validate: i,
|
|
1101
|
+
onValidityChange: h,
|
|
1102
|
+
label: s,
|
|
1103
|
+
initialValues: g.current,
|
|
1104
|
+
initialFormulaConfig: I.current,
|
|
1105
|
+
initialConditionConfig: w.current
|
|
1106
|
+
}
|
|
1107
|
+
) }),
|
|
1108
|
+
/* @__PURE__ */ t(n, { sx: { borderTop: "1px solid #e2e8f0", px: 2.5, py: 1.5, display: "flex", alignItems: "center", gap: 1, flexShrink: 0, bgcolor: "#f8fafc" }, children: [
|
|
1109
|
+
Z ? /* @__PURE__ */ e(S, { sx: { fontSize: 11, color: "#f59e0b", fontWeight: 500, flex: 1 }, children: "Unsaved changes" }) : /* @__PURE__ */ e(n, { sx: { flex: 1 } }),
|
|
1110
|
+
/* @__PURE__ */ e(n, { component: "button", onClick: L, sx: { background: "none", border: "1px solid #dee2e6", cursor: "pointer", fontSize: 13, fontWeight: 500, px: 2, py: 0.75, borderRadius: "7px", color: "#6c757d", "&:hover": { bgcolor: "#f8f9fa" } }, children: "Cancel" }),
|
|
1111
|
+
/* @__PURE__ */ t(n, { component: "button", onClick: K, sx: { border: "none", cursor: "pointer", fontSize: 13, fontWeight: 600, px: 2.5, py: 0.75, borderRadius: "7px", bgcolor: "#6366f1", color: "#fff", display: "flex", alignItems: "center", gap: 0.75, "&:hover": { bgcolor: "#4f46e5" } }, children: [
|
|
1112
|
+
/* @__PURE__ */ e(G, { size: 15 }),
|
|
1113
|
+
" Done"
|
|
1114
|
+
] })
|
|
1115
|
+
] })
|
|
1116
|
+
] }),
|
|
1117
|
+
u.type === "edit" && z && /* @__PURE__ */ e(
|
|
1118
|
+
ge,
|
|
1119
|
+
{
|
|
1120
|
+
field: z,
|
|
1121
|
+
onChange: E,
|
|
1122
|
+
onSave: X,
|
|
1123
|
+
onCancel: $
|
|
1124
|
+
}
|
|
1125
|
+
)
|
|
1126
|
+
]
|
|
1127
|
+
}
|
|
1128
|
+
)
|
|
1129
|
+
] });
|
|
1130
|
+
}
|
|
1131
|
+
export {
|
|
1132
|
+
je as F,
|
|
1133
|
+
U as S,
|
|
1134
|
+
cl as a,
|
|
1135
|
+
sl as u
|
|
1136
|
+
};
|