dynamic-mui 2.3.1 → 2.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -0
- package/dist/{index-Bh6BLrzq.mjs → AIForm-DtRl0WdY.mjs} +4213 -4371
- package/dist/AIForm-Dv8ahXyE.js +43 -0
- package/dist/accordion-BaiGxDcw.js +1 -0
- package/dist/{accordion-DEd2a2Ps.mjs → accordion-xg_TxxYS.mjs} +1 -1
- package/dist/{addressfield-FjNJCCuC.mjs → addressfield-BvQEHdEk.mjs} +1 -1
- package/dist/addressfield-vVizrbZP.js +1 -0
- package/dist/ai/index.cjs +1 -0
- package/dist/ai/index.mjs +14 -0
- package/dist/{asyncautocomplete-B8qI_lz9.mjs → asyncautocomplete-AmSRs7PY.mjs} +19 -19
- package/dist/asyncautocomplete-Dtmxh4l1.js +1 -0
- package/dist/bar-BiIzbOC3.js +1 -0
- package/dist/bar-DNc7TMKj.mjs +21 -0
- package/dist/{cascadeselect-D8sVXV1g.mjs → cascadeselect-BlznIKS6.mjs} +16 -16
- package/dist/cascadeselect-DqLtG-W9.js +1 -0
- package/dist/colorpicker-DpLvK1WR.js +1 -0
- package/dist/{colorpicker-DcyceL6g.mjs → colorpicker-hP3b7teC.mjs} +2 -2
- package/dist/consentfield-B21l9tGo.js +1 -0
- package/dist/{consentfield-B_qBOIuX.mjs → consentfield-CGT98YbR.mjs} +8 -8
- package/dist/datatable-B_6wXh2g.mjs +21 -0
- package/dist/datatable-Bv0Q37Zy.js +1 -0
- package/dist/dynamic-mui.cjs +1 -1
- package/dist/dynamic-mui.d.ts +2 -0
- package/dist/dynamic-mui.mjs +207 -30
- package/dist/editabletable-D3c3DJxX.js +1 -0
- package/dist/{editabletable-D6_U9op8.mjs → editabletable-YaFqdLvf.mjs} +13 -13
- package/dist/fileupload--KzSGb5a.js +1 -0
- package/dist/{fileupload-CugTpR-B.mjs → fileupload-ZBi72f1R.mjs} +11 -11
- package/dist/formrepeater-BhUEa4BI.js +1 -0
- package/dist/{formrepeater-Cxawn2sQ.mjs → formrepeater-Cwgtvz1c.mjs} +8 -8
- package/dist/formwizard-BlozHDc_.js +1 -0
- package/dist/{formwizard-Cfd5IPkE.mjs → formwizard-CYcgf5jL.mjs} +1 -1
- package/dist/geofield-BynrTSVm.js +1 -0
- package/dist/{geofield-k2V0hglK.mjs → geofield-xqZy_DAY.mjs} +12 -12
- package/dist/{group-D40b3E1V.mjs → group-DmLN-b09.mjs} +1 -1
- package/dist/group-Dtju1rHQ.js +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/intlphone-BeHXAcFi.js +1 -0
- package/dist/{intlphone-BbTprmmA.mjs → intlphone-CXUQP9Gp.mjs} +5 -5
- package/dist/{keyvaluefield-zD6Kf4D0.mjs → keyvaluefield-BJoEbe4I.mjs} +13 -13
- package/dist/keyvaluefield-BZQDG0l5.js +1 -0
- package/dist/line-B3CAbZOo.mjs +21 -0
- package/dist/line-tIm99vYW.js +1 -0
- package/dist/{lineitemlist-BZbAId8H.mjs → lineitemlist-CBSqoC9g.mjs} +7 -7
- package/dist/lineitemlist-RqStjYB-.js +1 -0
- package/dist/{list-BhTzYFrR.mjs → list-C8QMpJOJ.mjs} +2 -2
- package/dist/list-D_cawpPI.js +1 -0
- package/dist/locationfield-BiLy-c09.js +1 -0
- package/dist/{locationfield-BZpGC10B.mjs → locationfield-KBbu-98L.mjs} +19 -19
- package/dist/{markdowneditor-B5F4okCW.mjs → markdowneditor-DFOgRmdL.mjs} +1 -1
- package/dist/markdowneditor-Dy7Q01FM.js +2 -0
- package/dist/{matrixfield-CUo7zFWC.mjs → matrixfield-0lnuaEks.mjs} +7 -7
- package/dist/matrixfield-nWt6Cug5.js +1 -0
- package/dist/{multitextbox-CsNOrHZP.mjs → multitextbox-DmAWV163.mjs} +23 -23
- package/dist/multitextbox-oEgl2F8-.js +1 -0
- package/dist/{npsscale-Cb8NxADb.mjs → npsscale-CdTEwERY.mjs} +12 -12
- package/dist/npsscale-DW4sxcLz.js +1 -0
- package/dist/{numberstepper-DLk_r1HM.mjs → numberstepper-BwQ5coLc.mjs} +8 -8
- package/dist/numberstepper-cDosevJb.js +1 -0
- package/dist/pie-CBRckgd4.mjs +21 -0
- package/dist/pie-gAfuDR1F.js +1 -0
- package/dist/richtexteditor-DI-h5Efn.js +1 -0
- package/dist/{richtexteditor-pQIK2f-6.mjs → richtexteditor-xrbv8PXZ.mjs} +1 -1
- package/dist/{signature-CFv0jhVN.mjs → signature-CP_lA_Yh.mjs} +1 -1
- package/dist/{signature-G-XCOszC.js → signature-FM6L60nk.js} +2 -2
- package/dist/{stepper-U0kv127E.mjs → stepper-BprezTzX.mjs} +4 -4
- package/dist/stepper-CjGNFyBz.js +1 -0
- package/dist/{summaryfield-QcpYr9Xt.mjs → summaryfield-5mJRwVZ4.mjs} +5 -5
- package/dist/summaryfield-C3xmqZQp.js +1 -0
- package/dist/tabs-B4P59kHX.js +1 -0
- package/dist/{tabs-DCLyTKVm.mjs → tabs-By-Mm8vm.mjs} +1 -1
- package/dist/tagsinput-BwM3NYK_.js +1 -0
- package/dist/{tagsinput-D1VP8Bjq.mjs → tagsinput-Ce4EWy4i.mjs} +10 -10
- package/dist/util/muiX.d.ts +45 -0
- package/package.json +6 -1
- package/dist/accordion-Bf0VwGuE.js +0 -1
- package/dist/addressfield-Dfd9ilpe.js +0 -1
- package/dist/asyncautocomplete-9O6nwGP_.js +0 -1
- package/dist/bar-BzO7tvYJ.mjs +0 -20
- package/dist/bar-DEVxyUVS.js +0 -1
- package/dist/cascadeselect-DeoPn4_V.js +0 -1
- package/dist/colorpicker-BcnqB34i.js +0 -1
- package/dist/consentfield-CR69IP1l.js +0 -1
- package/dist/datatable-BIQznwQe.mjs +0 -20
- package/dist/datatable-BWlcUP0M.js +0 -1
- package/dist/editabletable-BdywdA42.js +0 -1
- package/dist/fileupload-YzpAUgok.js +0 -1
- package/dist/formrepeater-B_2UOIBm.js +0 -1
- package/dist/formwizard-CCBY6s19.js +0 -1
- package/dist/geofield-CJm8hivf.js +0 -1
- package/dist/group-IFZTzo-g.js +0 -1
- package/dist/index-eJceCjKS.js +0 -43
- package/dist/intlphone-CmiRFHv-.js +0 -1
- package/dist/keyvaluefield-CoOmou7m.js +0 -1
- package/dist/line-B-DwR1hm.mjs +0 -20
- package/dist/line-BkymZu31.js +0 -1
- package/dist/lineitemlist-BRsW0O7Z.js +0 -1
- package/dist/list-DWf2NWix.js +0 -1
- package/dist/locationfield-DC_2IN-B.js +0 -1
- package/dist/markdowneditor-Coi3sksx.js +0 -2
- package/dist/matrixfield-DAjfXU96.js +0 -1
- package/dist/multitextbox-Cq7vt1-g.js +0 -1
- package/dist/npsscale-BWpMrK_O.js +0 -1
- package/dist/numberstepper-BqQeBbR9.js +0 -1
- package/dist/pie-CJSL8Sv5.js +0 -1
- package/dist/pie-CL29dlh5.mjs +0 -20
- package/dist/richtexteditor-BUrvVR_T.js +0 -1
- package/dist/stepper-Bc9NlbU7.js +0 -1
- package/dist/summaryfield-B_bePxLk.js +0 -1
- package/dist/tabs-Cs9eNEbR.js +0 -1
- package/dist/tagsinput-DlopThdw.js +0 -1
package/dist/dynamic-mui.mjs
CHANGED
|
@@ -1,32 +1,209 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { y as I, z as k, B as Q, V as U, D as Z } from "./AIForm-DtRl0WdY.mjs";
|
|
2
|
+
import { A as pe, a as fe, b as me, c as ge, d as ve, e as ye, E as be, C as Ae, G as Ee, q as we, F as Me, w as Se, H as Fe, f as Ie, g as Oe, i as Ve, I as $e, J as Ce, K as We, L as qe, M as Re, N as De, s as ke, h as Te, O as Le, u as _e, Q as ze } from "./AIForm-DtRl0WdY.mjs";
|
|
3
|
+
import { useMemo as V, useState as T, useRef as x, useCallback as A } from "react";
|
|
4
|
+
function te(e) {
|
|
5
|
+
return (n) => {
|
|
6
|
+
const r = e.safeParse(n);
|
|
7
|
+
return !r || r.success ? [] : (r.error?.issues || r.error?.errors || []).map((u) => ({ id: String(u?.path?.[0] ?? ""), message: u?.message || "Invalid value", rule: u?.code || "zod" })).filter((u) => u.id);
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
function ae(e) {
|
|
11
|
+
return (n) => {
|
|
12
|
+
try {
|
|
13
|
+
return e.validateSync(n, { abortEarly: !1 }), [];
|
|
14
|
+
} catch (r) {
|
|
15
|
+
return (r?.inner?.length ? r.inner : r ? [r] : []).map((u) => ({ id: String(u?.path ?? ""), message: u?.message || "Invalid value", rule: u?.type || "yup" })).filter((u) => u.id);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
const $ = ["mandatory", "mandatoryselect"], S = (e, n) => {
|
|
20
|
+
const r = [];
|
|
21
|
+
return (e || []).forEach((h) => {
|
|
22
|
+
if (r.push(h), Array.isArray(h.subforms) && h.subforms.length) {
|
|
23
|
+
const u = h?.id || h?.props?.id, l = u ? n[u] : void 0;
|
|
24
|
+
h.subforms.forEach((t) => {
|
|
25
|
+
(Array.isArray(l) ? l.includes(t.conditionValue) : t.conditionValue === l) && r.push(...S(t.data || [], n));
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}), r;
|
|
29
|
+
}, E = (e) => e?.id || e?.props?.id || "", L = (e, n) => !e?.visibleWhen || I(e.visibleWhen, n), ee = (e, n) => e?.optionsMap && e?.dependsOn ? e.optionsMap[n[e.dependsOn]] || [] : e?.props?.options;
|
|
30
|
+
function de(e, n = {}) {
|
|
31
|
+
const { resolver: r } = n, h = n.messages?.required || "This field is required", u = V(() => {
|
|
32
|
+
const i = { ...n.initialValues || {} };
|
|
33
|
+
return S(e, i).forEach((s) => {
|
|
34
|
+
const f = E(s), d = s?.props?.value;
|
|
35
|
+
f && i[f] === void 0 && d !== void 0 && (i[f] = d);
|
|
36
|
+
}), i;
|
|
37
|
+
}, []), [l, t] = T(u), [a, w] = T([]), m = x(u), v = A((i) => {
|
|
38
|
+
const s = { ...i };
|
|
39
|
+
return S(e, s).forEach((d) => {
|
|
40
|
+
const o = E(d);
|
|
41
|
+
if (o && d.visibleWhen && !I(d.visibleWhen, s) && delete s[o], o && d.optionsMap && d.dependsOn) {
|
|
42
|
+
const y = (d.optionsMap[s[d.dependsOn]] || []).map((g) => typeof g == "string" ? g : g?.value), b = s[o];
|
|
43
|
+
b != null && b !== "" && !y.includes(b) && delete s[o];
|
|
44
|
+
}
|
|
45
|
+
}), (e || []).forEach((d) => {
|
|
46
|
+
if (!Array.isArray(d.subforms) || !d.subforms.length) return;
|
|
47
|
+
const o = E(d), c = o ? s[o] : void 0, y = /* @__PURE__ */ new Set(), b = /* @__PURE__ */ new Set();
|
|
48
|
+
d.subforms.forEach((g) => {
|
|
49
|
+
const M = Array.isArray(c) ? c.includes(g.conditionValue) : g.conditionValue === c;
|
|
50
|
+
(g.data || []).forEach((C) => {
|
|
51
|
+
const p = E(C);
|
|
52
|
+
p && (M ? y : b).add(p);
|
|
53
|
+
});
|
|
54
|
+
}), b.forEach((g) => {
|
|
55
|
+
y.has(g) || delete s[g];
|
|
56
|
+
});
|
|
57
|
+
}), S(e, s).forEach((d) => {
|
|
58
|
+
const o = E(d);
|
|
59
|
+
o && d.formula && (s[o] = k(d.formula, s));
|
|
60
|
+
}), s;
|
|
61
|
+
}, [e]), N = A((i, s) => {
|
|
62
|
+
t((f) => v({ ...f, [i]: s }));
|
|
63
|
+
}, [v]), X = A((i) => {
|
|
64
|
+
t((s) => v({ ...s, ...i || {} }));
|
|
65
|
+
}, [v]), O = A((i) => {
|
|
66
|
+
const s = S(e, i), f = [], d = /* @__PURE__ */ new Set();
|
|
67
|
+
if (s.forEach((o) => {
|
|
68
|
+
const c = E(o);
|
|
69
|
+
c && !L(o, i) && d.add(c);
|
|
70
|
+
}), s.forEach((o) => {
|
|
71
|
+
const c = E(o);
|
|
72
|
+
if (!c || d.has(c)) return;
|
|
73
|
+
const y = [...o?.rules?.validation || []], b = y.some((p) => $.includes(p.rule));
|
|
74
|
+
if (o.requiredWhen && !b && I(o.requiredWhen, i) && y.push({ rule: "mandatory", message: o.requiredMessage || h }), !y.length) return;
|
|
75
|
+
const g = i[c], M = g == null ? "" : String(g), C = y.some((p) => $.includes(p.rule));
|
|
76
|
+
y.forEach((p) => {
|
|
77
|
+
const R = Q[p.rule];
|
|
78
|
+
if (R) {
|
|
79
|
+
if (!M && !C) return;
|
|
80
|
+
const D = i[p.field ?? p.value], K = D == null ? "" : String(D);
|
|
81
|
+
R(M, K) || f.push({ id: c, rule: p.rule, message: p.message });
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const W = U[p.rule];
|
|
85
|
+
if (typeof W != "function") return;
|
|
86
|
+
const q = $.includes(p.rule);
|
|
87
|
+
if (!M && !q) return;
|
|
88
|
+
W(q ? g : M, p.value) || f.push({ id: c, rule: p.rule, message: p.message || (q ? h : "") });
|
|
89
|
+
});
|
|
90
|
+
}), r) {
|
|
91
|
+
let o = [];
|
|
92
|
+
try {
|
|
93
|
+
o = r(i) || [];
|
|
94
|
+
} catch {
|
|
95
|
+
o = [];
|
|
96
|
+
}
|
|
97
|
+
o.forEach((c) => {
|
|
98
|
+
c && c.id && !d.has(c.id) && f.push({ id: c.id, rule: c.rule || "schema", message: c.message });
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
return f;
|
|
102
|
+
}, [e, r, h]), Y = A(() => {
|
|
103
|
+
const i = O(l);
|
|
104
|
+
return w(i), i;
|
|
105
|
+
}, [O, l]), B = A((i) => {
|
|
106
|
+
const s = O(l);
|
|
107
|
+
return w(s), s.length === 0 && i && i({ ...l }), s;
|
|
108
|
+
}, [O, l]), P = A(() => {
|
|
109
|
+
t({ ...m.current }), w([]);
|
|
110
|
+
}, []), F = V(() => {
|
|
111
|
+
const i = /* @__PURE__ */ new Map();
|
|
112
|
+
return a.forEach((s) => {
|
|
113
|
+
s.id && !i.has(s.id) && i.set(s.id, s.message);
|
|
114
|
+
}), S(e, l).map((s) => {
|
|
115
|
+
const f = E(s), o = (s?.rules?.validation || []).some((y) => $.includes(y.rule)) || !!(s.requiredWhen && I(s.requiredWhen, l)), c = s.formula ? k(s.formula, l) : l[f];
|
|
116
|
+
return {
|
|
117
|
+
id: f,
|
|
118
|
+
field: s,
|
|
119
|
+
value: c,
|
|
120
|
+
visible: L(s, l),
|
|
121
|
+
disabled: !!(s.disabledWhen && I(s.disabledWhen, l)),
|
|
122
|
+
required: o,
|
|
123
|
+
options: ee(s, l),
|
|
124
|
+
error: i.get(f)
|
|
125
|
+
};
|
|
126
|
+
});
|
|
127
|
+
}, [e, l, a]), j = V(() => F.filter((i) => i.visible), [F]), H = A((i) => F.find((s) => s.id === i), [F]), J = V(() => !Z(l, m.current), [l]);
|
|
128
|
+
return {
|
|
129
|
+
values: l,
|
|
130
|
+
errors: a,
|
|
131
|
+
fields: F,
|
|
132
|
+
visibleFields: j,
|
|
133
|
+
getFieldState: H,
|
|
134
|
+
setValue: N,
|
|
135
|
+
setValues: X,
|
|
136
|
+
validate: Y,
|
|
137
|
+
isValid: a.length === 0,
|
|
138
|
+
isDirty: J,
|
|
139
|
+
reset: P,
|
|
140
|
+
submit: B
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
const se = /* @__PURE__ */ new Set(["typography", "divider", "alert", "image", "imagelist", "hyperlink", "button"]), _ = (e) => e?.id || e?.props?.id, z = (e, n = /* @__PURE__ */ new Set()) => ((e || []).forEach((r) => {
|
|
144
|
+
const h = _(r);
|
|
145
|
+
h && n.add(h), Array.isArray(r?.subforms) && r.subforms.forEach((u) => z(u?.data || [], n));
|
|
146
|
+
}), n), G = (e) => {
|
|
147
|
+
if (!e || typeof e != "object") return [];
|
|
148
|
+
if (typeof e.field == "string") return [e.field];
|
|
149
|
+
const n = e.all || e.any || e.none;
|
|
150
|
+
return Array.isArray(n) ? n.flatMap(G) : [];
|
|
151
|
+
}, ne = (e) => (Array.isArray(e) ? e : []).map((n) => typeof n == "string" ? n : n?.value);
|
|
152
|
+
function le(e) {
|
|
153
|
+
const n = [], r = z(e), h = (u) => {
|
|
154
|
+
const l = /* @__PURE__ */ new Set();
|
|
155
|
+
(u || []).forEach((t) => {
|
|
156
|
+
const a = _(t), w = t?.type;
|
|
157
|
+
if (!a && !se.has(w) && n.push({ level: "warning", code: "missing-id", message: `A "${w || "field"}" has no id; its value can't be captured.` }), a && (l.has(a) && n.push({ level: "error", code: "duplicate-id", field: a, message: `Duplicate field id "${a}" among siblings — their values will collide.` }), l.add(a)), t?.dependsOn && !t?.optionsMap && n.push({ level: "warning", code: "depends-without-options", field: a, message: `"${a}" has \`dependsOn\` but no \`optionsMap\`, so its options never change.` }), t?.optionsMap && !t?.dependsOn && n.push({ level: "warning", code: "options-without-depends", field: a, message: `"${a}" has \`optionsMap\` but no \`dependsOn\`, so it can't pick a branch.` }), t?.dependsOn && !r.has(t.dependsOn) && n.push({ level: "error", code: "unknown-depends-target", field: a, message: `"${a}" dependsOn "${t.dependsOn}", which is not a field in this schema.` }), ["visibleWhen", "disabledWhen", "requiredWhen"].forEach((m) => {
|
|
158
|
+
G(t?.[m]).forEach((v) => {
|
|
159
|
+
r.has(v) || n.push({ level: "error", code: "unknown-rule-field", field: a, message: `"${a}" ${m} references field "${v}", which does not exist.` });
|
|
160
|
+
});
|
|
161
|
+
}), (t?.rules?.validation || []).forEach((m) => {
|
|
162
|
+
m?.field && /Field$/.test(m?.rule || "") && !r.has(m.field) && n.push({ level: "error", code: "unknown-cross-field", field: a, message: `"${a}" rule "${m.rule}" compares against "${m.field}", which does not exist.` });
|
|
163
|
+
}), Array.isArray(t?.subforms) && t.subforms.length) {
|
|
164
|
+
const m = ne(t?.props?.options);
|
|
165
|
+
m.length && t.subforms.forEach((v) => {
|
|
166
|
+
v?.conditionValue !== void 0 && !m.includes(v.conditionValue) && n.push({ level: "warning", code: "subform-condition-not-an-option", field: a, message: `"${a}" has a subform for value "${v.conditionValue}", which isn't one of its options.` });
|
|
167
|
+
}), t.subforms.forEach((v) => h(v?.data || []));
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
};
|
|
171
|
+
return h(e), n;
|
|
172
|
+
}
|
|
173
|
+
function ce(e) {
|
|
174
|
+
return e;
|
|
175
|
+
}
|
|
2
176
|
export {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
177
|
+
pe as AIFill,
|
|
178
|
+
fe as AIForm,
|
|
179
|
+
me as AIFormGenerator,
|
|
180
|
+
ge as AISchemaReview,
|
|
181
|
+
ve as AITextAssist,
|
|
182
|
+
ye as AIVisionImport,
|
|
183
|
+
be as ClearFormData,
|
|
184
|
+
Ae as Controls,
|
|
185
|
+
Ee as DynamicComponent,
|
|
186
|
+
we as FormData,
|
|
187
|
+
Me as FormGenerator,
|
|
188
|
+
Se as MuiConfig,
|
|
189
|
+
Fe as configureMuiX,
|
|
190
|
+
Ie as createAIClient,
|
|
191
|
+
ce as defineForm,
|
|
192
|
+
Oe as formFieldsToSimple,
|
|
193
|
+
Ve as getMuiX,
|
|
194
|
+
$e as getRegisteredControl,
|
|
195
|
+
Ce as hasRegisteredControl,
|
|
196
|
+
We as registerControl,
|
|
197
|
+
qe as registerControls,
|
|
198
|
+
Re as registeredControlTypes,
|
|
199
|
+
De as resetMuiX,
|
|
200
|
+
ke as simpleFieldsToFormFields,
|
|
201
|
+
Te as slug,
|
|
202
|
+
Le as unregisterControl,
|
|
203
|
+
_e as useAIAssist,
|
|
204
|
+
ze as useForm,
|
|
205
|
+
de as useFormEngine,
|
|
206
|
+
le as validateSchema,
|
|
207
|
+
ae as yupResolver,
|
|
208
|
+
te as zodResolver
|
|
32
209
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),k=require("react"),w=require("@mui/material/Table"),S=require("@mui/material/TableBody"),a=require("@mui/material/TableCell"),z=require("@mui/material/TableContainer"),I=require("@mui/material/TableHead"),j=require("@mui/material/TableRow"),F=require("@mui/material/TextField"),W=require("@mui/material/IconButton"),B=require("@mui/material/Button"),M=require("@mui/material/FormControl"),P=require("@mui/material/FormLabel"),$=require("@mui/material/Paper"),E=require("@mui/icons-material/Add"),L=require("@mui/icons-material/Close"),d=require("./AIForm-Dv8ahXyE.js");function f(o){return Array.isArray(o)?o.map(c=>({...c||{}})):[]}function H({attributes:o={},onChange:c}){const{MuiAttributes:g={},id:p="",columns:x=[],addLabel:q="Add row",label:m}=o,{sx:v,...y}=g,h=Array.isArray(x)?x:[],[l,i]=k.useState(()=>f(o.value));d.useUpdateEffect(()=>{i(f(o.value))},[o.value]);const u=r=>{c?.({id:p,value:r})},C=(r,n,t)=>{const s=l.map((b,T)=>T===r?{...b,[n]:t}:b);i(s),u(s)},A=()=>{const r=[...l,{}];i(r),u(r)},R=r=>{const n=l.filter((t,s)=>s!==r);i(n),u(n)};return e.jsxs(M,{component:"fieldset",fullWidth:!0,children:[m&&e.jsx(P,{component:"legend",sx:{mb:1},children:m}),e.jsx(z,{component:$,variant:"outlined",sx:{borderRadius:2,overflow:"hidden"},children:e.jsxs(w,{size:"small",children:[e.jsx(I,{children:e.jsxs(j,{sx:{backgroundColor:"action.hover"},children:[h.map(r=>e.jsx(a,{sx:{fontWeight:600},children:r.label},r.key)),e.jsx(a,{align:"right",sx:{width:48}})]})}),e.jsx(S,{children:l.map((r,n)=>e.jsxs(j,{sx:{transition:"background-color 150ms cubic-bezier(0.4, 0, 0.2, 1)","&:hover":{backgroundColor:"action.hover"}},children:[h.map(t=>e.jsx(a,{children:e.jsx(F,{...y,type:t.type==="number"?"number":"text",value:r[t.key]??"",onChange:s=>C(n,t.key,s.target.value),inputProps:{"aria-label":`${t.label} row ${n+1}`},size:"small",variant:"standard",fullWidth:!0,sx:d.mergeSx(d.premiumInputSx,v)})},t.key)),e.jsx(a,{align:"right",children:e.jsx(W,{"aria-label":`Remove row ${n+1}`,onClick:()=>R(n),size:"small",sx:{borderRadius:2,color:"text.secondary","&:hover":{color:"error.main"}},children:e.jsx(L,{fontSize:"small"})})})]},n))})]})}),e.jsx(B,{onClick:A,startIcon:e.jsx(E,{}),size:"small",variant:"text",sx:{alignSelf:"flex-start",mt:1,borderRadius:2,textTransform:"none",fontWeight:600},children:q})]})}exports.default=H;
|
|
@@ -4,17 +4,17 @@ import S from "@mui/material/Table";
|
|
|
4
4
|
import I from "@mui/material/TableBody";
|
|
5
5
|
import s from "@mui/material/TableCell";
|
|
6
6
|
import W from "@mui/material/TableContainer";
|
|
7
|
-
import
|
|
7
|
+
import j from "@mui/material/TableHead";
|
|
8
8
|
import b from "@mui/material/TableRow";
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
9
|
+
import B from "@mui/material/TextField";
|
|
10
|
+
import F from "@mui/material/IconButton";
|
|
11
|
+
import $ from "@mui/material/Button";
|
|
12
12
|
import E from "@mui/material/FormControl";
|
|
13
13
|
import L from "@mui/material/FormLabel";
|
|
14
14
|
import M from "@mui/material/Paper";
|
|
15
15
|
import P from "@mui/icons-material/Add";
|
|
16
16
|
import H from "@mui/icons-material/Close";
|
|
17
|
-
import {
|
|
17
|
+
import { j as U, m as _, k as q } from "./AIForm-DtRl0WdY.mjs";
|
|
18
18
|
function x(n) {
|
|
19
19
|
return Array.isArray(n) ? n.map((d) => ({ ...d || {} })) : [];
|
|
20
20
|
}
|
|
@@ -22,10 +22,10 @@ function lr({ attributes: n = {}, onChange: d }) {
|
|
|
22
22
|
const {
|
|
23
23
|
MuiAttributes: g = {},
|
|
24
24
|
id: v = "",
|
|
25
|
-
columns:
|
|
25
|
+
columns: p = [],
|
|
26
26
|
addLabel: y = "Add row",
|
|
27
|
-
label:
|
|
28
|
-
} = n, { sx: C, ...k } = g, f = Array.isArray(
|
|
27
|
+
label: u
|
|
28
|
+
} = n, { sx: C, ...k } = g, f = Array.isArray(p) ? p : [], [l, i] = z.useState(() => x(n.value));
|
|
29
29
|
U(() => {
|
|
30
30
|
i(x(n.value));
|
|
31
31
|
}, [n.value]);
|
|
@@ -42,7 +42,7 @@ function lr({ attributes: n = {}, onChange: d }) {
|
|
|
42
42
|
i(o), c(o);
|
|
43
43
|
};
|
|
44
44
|
return /* @__PURE__ */ m(E, { component: "fieldset", fullWidth: !0, children: [
|
|
45
|
-
|
|
45
|
+
u && /* @__PURE__ */ e(L, { component: "legend", sx: { mb: 1 }, children: u }),
|
|
46
46
|
/* @__PURE__ */ e(
|
|
47
47
|
W,
|
|
48
48
|
{
|
|
@@ -53,7 +53,7 @@ function lr({ attributes: n = {}, onChange: d }) {
|
|
|
53
53
|
overflow: "hidden"
|
|
54
54
|
},
|
|
55
55
|
children: /* @__PURE__ */ m(S, { size: "small", children: [
|
|
56
|
-
/* @__PURE__ */ e(
|
|
56
|
+
/* @__PURE__ */ e(j, { children: /* @__PURE__ */ m(b, { sx: { backgroundColor: "action.hover" }, children: [
|
|
57
57
|
f.map((r) => /* @__PURE__ */ e(s, { sx: { fontWeight: 600 }, children: r.label }, r.key)),
|
|
58
58
|
/* @__PURE__ */ e(s, { align: "right", sx: { width: 48 } })
|
|
59
59
|
] }) }),
|
|
@@ -66,7 +66,7 @@ function lr({ attributes: n = {}, onChange: d }) {
|
|
|
66
66
|
},
|
|
67
67
|
children: [
|
|
68
68
|
f.map((t) => /* @__PURE__ */ e(s, { children: /* @__PURE__ */ e(
|
|
69
|
-
|
|
69
|
+
B,
|
|
70
70
|
{
|
|
71
71
|
...k,
|
|
72
72
|
type: t.type === "number" ? "number" : "text",
|
|
@@ -82,7 +82,7 @@ function lr({ attributes: n = {}, onChange: d }) {
|
|
|
82
82
|
}
|
|
83
83
|
) }, t.key)),
|
|
84
84
|
/* @__PURE__ */ e(s, { align: "right", children: /* @__PURE__ */ e(
|
|
85
|
-
|
|
85
|
+
F,
|
|
86
86
|
{
|
|
87
87
|
"aria-label": `Remove row ${o + 1}`,
|
|
88
88
|
onClick: () => R(o),
|
|
@@ -103,7 +103,7 @@ function lr({ attributes: n = {}, onChange: d }) {
|
|
|
103
103
|
}
|
|
104
104
|
),
|
|
105
105
|
/* @__PURE__ */ e(
|
|
106
|
-
|
|
106
|
+
$,
|
|
107
107
|
{
|
|
108
108
|
onClick: A,
|
|
109
109
|
startIcon: /* @__PURE__ */ e(P, {}),
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),l=require("react"),i=require("@mui/material/Box"),c=require("@mui/material/Typography"),G=require("@mui/material/IconButton"),_=require("@mui/material/CircularProgress"),H=require("@mui/icons-material/CloudUpload"),J=require("@mui/icons-material/Close"),K=require("@mui/icons-material/InsertDriveFile"),b=require("./AIForm-Dv8ahXyE.js"),N=require("./s3Upload-B0JeoLkS.js"),R=o=>o?Array.isArray(o)?o.filter(Boolean):[o]:[],Q=o=>/^data:image\//i.test(o)||/\.(png|jpe?g|gif|webp|bmp|svg)(\?.*)?$/i.test(o),V=o=>new Promise((f,x)=>{const s=new FileReader;s.onload=()=>f(s.result||""),s.onerror=()=>x(s.error),s.readAsDataURL(o)});function W({attributes:o={},rules:f={},onChange:x}){const{id:s="",multiple:d=!1,accept:g="",bucket:A="",region:C="",identityPoolId:F="",path:z="",maxSizeMB:h=0,label:j="Upload file",MuiAttributes:B={}}=o,S=l.useRef(null),[p,m]=l.useState(R(o.value)),[w,v]=l.useState(!1),[P,U]=l.useState(!1),[q,y]=l.useState(""),$=f?.validation?.some(e=>e.rule==="mandatory"||e.rule==="mandatoryselect")||!1;b.useUpdateEffect(()=>{m(R(o.value))},[o.value]);const D=(e,t)=>{x?.({id:s,value:d?e:e[0]??"",option:t})},k=async e=>{const t=Array.from(e);if(!t.length)return;y(""),U(!0);const a=[],u=[];try{for(const n of t){if(h&&n.size>h*1024*1024){y(`"${n.name}" exceeds the ${h}MB limit.`);continue}const O=await V(n),E=await N.uploadToS3(O,n.name,A,C,F,z);a.push(E),u.push(n)}}catch(n){console.error("FileUpload failed",n),y("Upload failed. Please try again.")}finally{U(!1)}if(!a.length)return;const I=d?[...p,...a]:a.slice(0,1);m(I),D(I,u)},M=e=>{e.target.files&&k(e.target.files),e.target.value=""},T=e=>{e.preventDefault(),v(!1),e.dataTransfer?.files?.length&&k(e.dataTransfer.files)},L=e=>{const t=p.filter((a,u)=>u!==e);m(t),D(t)};return r.jsxs(i,{sx:{width:"100%",...B.sx},children:[r.jsxs(c,{variant:"subtitle2",gutterBottom:!0,sx:{display:"flex"},children:[j,$&&r.jsx(i,{component:"span",sx:{color:"error.main",ml:.5},children:"*"})]}),r.jsx("input",{ref:S,type:"file",hidden:!0,multiple:d,accept:g||void 0,onChange:M}),r.jsxs(i,{role:"button","aria-label":j,onClick:()=>S.current?.click(),onDragOver:e=>{e.preventDefault(),v(!0)},onDragLeave:()=>v(!1),onDrop:T,sx:{border:"2px dashed",borderColor:w?"primary.main":"divider",borderRadius:"12px",p:3,textAlign:"center",cursor:"pointer",transition:"all .2s",bgcolor:w?"action.hover":"background.paper","&:hover":{borderColor:"primary.main",bgcolor:"action.hover"}},children:[P?r.jsx(_,{size:28}):r.jsx(H,{sx:{fontSize:40,color:"primary.main"}}),r.jsxs(c,{variant:"body2",sx:{mt:1},children:["Drag & drop ",d?"files":"a file"," here, or click to browse"]}),g&&r.jsxs(c,{variant:"caption",color:"text.secondary",children:["Accepted: ",g]})]}),q&&r.jsx(c,{variant:"caption",color:"error.main",sx:{display:"block",mt:1},children:q}),p.length>0&&r.jsx(i,{sx:b.mergeSx(b.premiumSurfaceSx,{mt:1.5,p:1}),children:p.map((e,t)=>r.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:1.5,p:1,borderRadius:"8px",transition:"background-color .18s","&:hover":{bgcolor:"action.hover"}},children:[Q(e)?r.jsx(i,{component:"img",src:e,alt:`upload-${t}`,sx:{width:40,height:40,objectFit:"cover",borderRadius:"8px",flexShrink:0}}):r.jsx(K,{color:"action",sx:{flexShrink:0}}),r.jsx(c,{variant:"body2",sx:{flexGrow:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.split("/").pop()?.split("?")[0]||e}),r.jsx(G,{size:"small","aria-label":"remove",onClick:a=>{a.stopPropagation(),L(t)},children:r.jsx(J,{fontSize:"small"})})]},`${e}-${t}`))})]})}exports.default=W;
|
|
@@ -7,7 +7,7 @@ import H from "@mui/material/CircularProgress";
|
|
|
7
7
|
import J from "@mui/icons-material/CloudUpload";
|
|
8
8
|
import K from "@mui/icons-material/Close";
|
|
9
9
|
import N from "@mui/icons-material/InsertDriveFile";
|
|
10
|
-
import {
|
|
10
|
+
import { j as Q, m as V, l as W } from "./AIForm-DtRl0WdY.mjs";
|
|
11
11
|
import { u as X } from "./s3Upload-dpioZ2c8.mjs";
|
|
12
12
|
const R = (r) => r ? Array.isArray(r) ? r.filter(Boolean) : [r] : [], Y = (r) => /^data:image\//i.test(r) || /\.(png|jpe?g|gif|webp|bmp|svg)(\?.*)?$/i.test(r), Z = (r) => new Promise((u, g) => {
|
|
13
13
|
const a = new FileReader();
|
|
@@ -24,8 +24,8 @@ function de({ attributes: r = {}, rules: u = {}, onChange: g }) {
|
|
|
24
24
|
path: $ = "",
|
|
25
25
|
maxSizeMB: x = 0,
|
|
26
26
|
label: w = "Upload file",
|
|
27
|
-
MuiAttributes:
|
|
28
|
-
} = r, D = _(null), [d, v] = m(R(r.value)), [S,
|
|
27
|
+
MuiAttributes: j = {}
|
|
28
|
+
} = r, D = _(null), [d, v] = m(R(r.value)), [S, y] = m(!1), [P, U] = m(!1), [k, b] = m(""), L = u?.validation?.some((e) => e.rule === "mandatory" || e.rule === "mandatoryselect") || !1;
|
|
29
29
|
Q(() => {
|
|
30
30
|
v(R(r.value));
|
|
31
31
|
}, [r.value]);
|
|
@@ -34,19 +34,19 @@ function de({ attributes: r = {}, rules: u = {}, onChange: g }) {
|
|
|
34
34
|
}, I = async (e) => {
|
|
35
35
|
const o = Array.from(e);
|
|
36
36
|
if (!o.length) return;
|
|
37
|
-
|
|
37
|
+
b(""), U(!0);
|
|
38
38
|
const i = [], f = [];
|
|
39
39
|
try {
|
|
40
40
|
for (const n of o) {
|
|
41
41
|
if (x && n.size > x * 1024 * 1024) {
|
|
42
|
-
|
|
42
|
+
b(`"${n.name}" exceeds the ${x}MB limit.`);
|
|
43
43
|
continue;
|
|
44
44
|
}
|
|
45
45
|
const O = await Z(n), G = await X(O, n.name, z, B, F, $);
|
|
46
46
|
i.push(G), f.push(n);
|
|
47
47
|
}
|
|
48
48
|
} catch (n) {
|
|
49
|
-
console.error("FileUpload failed", n),
|
|
49
|
+
console.error("FileUpload failed", n), b("Upload failed. Please try again.");
|
|
50
50
|
} finally {
|
|
51
51
|
U(!1);
|
|
52
52
|
}
|
|
@@ -56,12 +56,12 @@ function de({ attributes: r = {}, rules: u = {}, onChange: g }) {
|
|
|
56
56
|
}, M = (e) => {
|
|
57
57
|
e.target.files && I(e.target.files), e.target.value = "";
|
|
58
58
|
}, T = (e) => {
|
|
59
|
-
e.preventDefault(),
|
|
59
|
+
e.preventDefault(), y(!1), e.dataTransfer?.files?.length && I(e.dataTransfer.files);
|
|
60
60
|
}, E = (e) => {
|
|
61
61
|
const o = d.filter((i, f) => f !== e);
|
|
62
62
|
v(o), C(o);
|
|
63
63
|
};
|
|
64
|
-
return /* @__PURE__ */ l(s, { sx: { width: "100%", ...
|
|
64
|
+
return /* @__PURE__ */ l(s, { sx: { width: "100%", ...j.sx }, children: [
|
|
65
65
|
/* @__PURE__ */ l(c, { variant: "subtitle2", gutterBottom: !0, sx: { display: "flex" }, children: [
|
|
66
66
|
w,
|
|
67
67
|
L && /* @__PURE__ */ t(s, { component: "span", sx: { color: "error.main", ml: 0.5 }, children: "*" })
|
|
@@ -84,9 +84,9 @@ function de({ attributes: r = {}, rules: u = {}, onChange: g }) {
|
|
|
84
84
|
"aria-label": w,
|
|
85
85
|
onClick: () => D.current?.click(),
|
|
86
86
|
onDragOver: (e) => {
|
|
87
|
-
e.preventDefault(),
|
|
87
|
+
e.preventDefault(), y(!0);
|
|
88
88
|
},
|
|
89
|
-
onDragLeave: () =>
|
|
89
|
+
onDragLeave: () => y(!1),
|
|
90
90
|
onDrop: T,
|
|
91
91
|
sx: {
|
|
92
92
|
border: "2px dashed",
|
|
@@ -100,7 +100,7 @@ function de({ attributes: r = {}, rules: u = {}, onChange: g }) {
|
|
|
100
100
|
"&:hover": { borderColor: "primary.main", bgcolor: "action.hover" }
|
|
101
101
|
},
|
|
102
102
|
children: [
|
|
103
|
-
|
|
103
|
+
P ? /* @__PURE__ */ t(H, { size: 28 }) : /* @__PURE__ */ t(J, { sx: { fontSize: 40, color: "primary.main" } }),
|
|
104
104
|
/* @__PURE__ */ l(c, { variant: "body2", sx: { mt: 1 }, children: [
|
|
105
105
|
"Drag & drop ",
|
|
106
106
|
p ? "files" : "a file",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),i=require("react"),n=require("@mui/material"),b=require("./AIForm-Dv8ahXyE.js"),C=require("./v4-CqdK_b8Y.js");function N({attributes:f={},rules:j={},onChange:o}){const{id:c="",label:g="Group",min:s=1,max:u,subFields:A=[],value:a}=f,v=j?.validation?.some(e=>e.rule==="mandatory")||!1,F=i.useMemo(()=>{if(Array.isArray(a)&&a.length>0)return a.length;const e=Number(f.count);return!isNaN(e)&&e>=s?e:s},[]),[l,I]=i.useState(F),d=i.useRef([]),m=i.useCallback(e=>(d.current[e]||(d.current[e]=C.v4()),d.current[e]),[]),y=i.useCallback(e=>{if(!o)return;const r=Array.from({length:e},(p,x)=>{const h=`${c}-group-${m(x)}`;return b.FormData(h)??{}});o({id:c,value:r})},[c,m,o]),q=e=>{let r=parseInt(e,10);(isNaN(r)||r<s)&&(r=s),u!==void 0&&r>u&&(r=u),I(r),setTimeout(()=>y(r),0)};return t.jsxs(n.Box,{sx:{width:"100%"},children:[t.jsx(n.TextField,{type:"number",size:"small",label:`Number of ${g}s`,value:l,onChange:e=>q(e.target.value),required:v,inputProps:{min:s,...u!==void 0?{max:u}:{}},InputProps:{startAdornment:t.jsx(n.InputAdornment,{position:"start",children:t.jsx(n.Icon,{fontSize:"small",children:"format_list_numbered"})})},sx:{mb:2,minWidth:200}}),Array.from({length:l},(e,r)=>{const p=`${c}-group-${m(r)}`,x=Array.isArray(a)?a[r]:void 0;return t.jsxs(n.Accordion,{defaultExpanded:r===0,sx:{mb:1},children:[t.jsx(n.AccordionSummary,{expandIcon:t.jsx(n.Icon,{children:"expand_more"}),children:t.jsxs(n.Typography,{fontWeight:600,children:[g," ",r+1]})}),t.jsx(n.AccordionDetails,{children:t.jsx(b.FormGenerator,{guid:p,data:A,patch:x??{},onChange:h=>{y(l),o&&o(h)}})})]},p)})]})}exports.default=N;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsxs as f, jsx as e } from "react/jsx-runtime";
|
|
2
2
|
import { useMemo as _, useState as $, useRef as G, useCallback as y } from "react";
|
|
3
|
-
import { Box as P, TextField as R, InputAdornment as S, Icon as A, Accordion as T, AccordionSummary as j, Typography as
|
|
4
|
-
import {
|
|
5
|
-
import { v as
|
|
3
|
+
import { Box as P, TextField as R, InputAdornment as S, Icon as A, Accordion as T, AccordionSummary as j, Typography as q, AccordionDetails as z } from "@mui/material";
|
|
4
|
+
import { q as D, F as M } from "./AIForm-DtRl0WdY.mjs";
|
|
5
|
+
import { v as W } from "./v4-BysszJq8.mjs";
|
|
6
6
|
function H({ attributes: h = {}, rules: v = {}, onChange: o }) {
|
|
7
7
|
const {
|
|
8
8
|
id: s = "",
|
|
@@ -15,11 +15,11 @@ function H({ attributes: h = {}, rules: v = {}, onChange: o }) {
|
|
|
15
15
|
if (Array.isArray(i) && i.length > 0) return i.length;
|
|
16
16
|
const r = Number(h.count);
|
|
17
17
|
return !isNaN(r) && r >= n ? r : n;
|
|
18
|
-
}, []), [u, C] = $(N), c = G([]), d = y((r) => (c.current[r] || (c.current[r] =
|
|
18
|
+
}, []), [u, C] = $(N), c = G([]), d = y((r) => (c.current[r] || (c.current[r] = W()), c.current[r]), []), x = y((r) => {
|
|
19
19
|
if (!o) return;
|
|
20
20
|
const t = Array.from({ length: r }, (l, m) => {
|
|
21
21
|
const p = `${s}-group-${d(m)}`;
|
|
22
|
-
return
|
|
22
|
+
return D(p) ?? {};
|
|
23
23
|
});
|
|
24
24
|
o({ id: s, value: t });
|
|
25
25
|
}, [s, d, o]), I = (r) => {
|
|
@@ -46,13 +46,13 @@ function H({ attributes: h = {}, rules: v = {}, onChange: o }) {
|
|
|
46
46
|
Array.from({ length: u }, (r, t) => {
|
|
47
47
|
const l = `${s}-group-${d(t)}`, m = Array.isArray(i) ? i[t] : void 0;
|
|
48
48
|
return /* @__PURE__ */ f(T, { defaultExpanded: t === 0, sx: { mb: 1 }, children: [
|
|
49
|
-
/* @__PURE__ */ e(j, { expandIcon: /* @__PURE__ */ e(A, { children: "expand_more" }), children: /* @__PURE__ */ f(
|
|
49
|
+
/* @__PURE__ */ e(j, { expandIcon: /* @__PURE__ */ e(A, { children: "expand_more" }), children: /* @__PURE__ */ f(q, { fontWeight: 600, children: [
|
|
50
50
|
g,
|
|
51
51
|
" ",
|
|
52
52
|
t + 1
|
|
53
53
|
] }) }),
|
|
54
|
-
/* @__PURE__ */ e(
|
|
55
|
-
|
|
54
|
+
/* @__PURE__ */ e(z, { children: /* @__PURE__ */ e(
|
|
55
|
+
M,
|
|
56
56
|
{
|
|
57
57
|
guid: l,
|
|
58
58
|
data: b,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),a=require("react"),n=require("@mui/material"),i=require("./AIForm-Dv8ahXyE.js"),y=require("./v4-CqdK_b8Y.js");function B({attributes:f={},onChange:l}){const{id:c="",guid:M,steps:x=[],patch:v={},finishLabel:j="Finish",validateSteps:d=!1,MuiAttributes:$={}}=f,[e,p]=a.useState(0),u=a.useRef(null),h=a.useMemo(()=>M||`${c}-${y.v4()}`,[]),r=Array.isArray(x)?x:[],o=Math.max(r.length-1,0),I=e>=o,R=e<=0,m=`${h}-step-${e}`,A=a.useCallback(()=>{p(t=>Math.max(t-1,0))},[]),g=a.useCallback(()=>{if(!(d&&u.current&&!u.current.validate())){if(e>=o){l?.({id:c,value:"complete",option:e});return}p(t=>Math.min(t+1,o))}},[e,o,c,l,d]),b=(t=>({borderRadius:`${i.PREMIUM_RADIUS+8}px`,textTransform:"none",fontWeight:600,px:3,transition:`box-shadow .18s ${i.PREMIUM_EASING}, transform .18s ${i.PREMIUM_EASING}`,"&:hover":{transform:"translateY(-1px)",boxShadow:`0 4px 12px ${t.palette.primary.main}22`}}));return s.jsxs(n.Box,{sx:{width:"100%"},...$,children:[s.jsx(n.Stepper,{activeStep:e,alternativeLabel:!0,sx:{mb:3,"& .MuiStepLabel-label":{fontWeight:500},"& .MuiStepIcon-root.Mui-active":{transition:`color .2s ${i.PREMIUM_EASING}`}},children:r.map((t,S)=>s.jsx(n.Step,{children:s.jsx(n.StepLabel,{children:t?.label??`Step ${S+1}`})},`${h}-label-${S}`))}),s.jsx(n.Box,{sx:{mb:3},children:r[e]&&s.jsx(i.FormGenerator,{guid:m,data:r[e].fields??[],patch:v,persistOnUnmount:!0,apiRef:u,onChange:t=>{l?.(t)}},m)}),s.jsxs(n.Box,{sx:{display:"flex",justifyContent:"space-between",gap:2},children:[s.jsx(n.Button,{variant:"outlined",onClick:A,disabled:R,sx:i.mergeSx(b),children:"Back"}),s.jsx(n.Button,{variant:"contained",onClick:g,sx:i.mergeSx(b),children:I?j:"Next"})]})]})}exports.default=B;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsxs as b, jsx as a } from "react/jsx-runtime";
|
|
2
2
|
import { useState as G, useRef as w, useMemo as B, useCallback as S } from "react";
|
|
3
3
|
import { Box as l, Stepper as U, Step as j, StepLabel as C, Button as v } from "@mui/material";
|
|
4
|
-
import { P as c, F as E, m as M,
|
|
4
|
+
import { P as c, F as E, m as M, o as N } from "./AIForm-DtRl0WdY.mjs";
|
|
5
5
|
import { v as P } from "./v4-BysszJq8.mjs";
|
|
6
6
|
function T({ attributes: $ = {}, onChange: n }) {
|
|
7
7
|
const {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),S=require("react"),i=require("@mui/material/Box"),$=require("@mui/material/Link"),m=require("@mui/material/TextField"),w=require("@mui/material/Typography"),o=require("./AIForm-Dv8ahXyE.js"),b=t=>{if(t&&typeof t=="object")return{lat:t.lat!==void 0&&t.lat!==null?String(t.lat):"",lng:t.lng!==void 0&&t.lng!==null?String(t.lng):""};if(typeof t=="string"&&t.includes(",")){const[c="",a=""]=t.split(",");return{lat:c.trim(),lng:a.trim()}}return{lat:"",lng:""}};function q({attributes:t={},onChange:c}){const{id:a="",label:g="",showMap:h=!1,MuiAttributes:p={}}=t,[n,u]=S.useState(()=>b(t.value));o.useUpdateEffect(()=>{u(b(t.value))},[t.value]);const f=e=>{c?.({id:a,value:{lat:e.lat,lng:e.lng},option:`${e.lat},${e.lng}`})},d=e=>s=>{const r={...n,[e]:s.target.value};u(r),f(r)},y=n.lat!==""&&n.lng!=="",x=o.mergeSx(o.premiumInputSx,p.sx),j=()=>{const e=parseFloat(n.lat),s=parseFloat(n.lng),r=.01;return`https://www.openstreetmap.org/export/embed.html?bbox=${`${s-r},${e-r},${s+r},${e+r}`}&marker=${e},${s}`};return l.jsxs(i,{id:a,children:[g?l.jsx(w,{variant:"body2",sx:{mb:.75,fontWeight:500},children:g}):null,l.jsxs(i,{sx:{display:"flex",gap:1.5,flexWrap:"wrap"},children:[l.jsx(m,{type:"number",...p,label:"Latitude",value:n.lat,onChange:d("lat"),inputProps:{"aria-label":"Latitude",step:"any"},sx:x}),l.jsx(m,{type:"number",...p,label:"Longitude",value:n.lng,onChange:d("lng"),inputProps:{"aria-label":"Longitude",step:"any"},sx:x})]}),l.jsx(i,{sx:{mt:1},children:l.jsx($,{href:`https://www.google.com/maps?q=${n.lat},${n.lng}`,target:"_blank",rel:"noreferrer",variant:"body2",children:"Open in Maps"})}),h&&y?l.jsx(i,{sx:o.mergeSx(e=>({...o.premiumSurfaceSx(e),mt:1.5})),children:l.jsx("iframe",{title:"map",width:"100%",height:"240",style:{border:0,display:"block"},src:j()})}):null]})}exports.default=q;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsxs as u, jsx as r } from "react/jsx-runtime";
|
|
2
2
|
import S from "react";
|
|
3
3
|
import s from "@mui/material/Box";
|
|
4
|
-
import
|
|
4
|
+
import k from "@mui/material/Link";
|
|
5
5
|
import f from "@mui/material/TextField";
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
const
|
|
6
|
+
import L from "@mui/material/Typography";
|
|
7
|
+
import { j, m as h, k as C, l as F } from "./AIForm-DtRl0WdY.mjs";
|
|
8
|
+
const b = (t) => {
|
|
9
9
|
if (t && typeof t == "object")
|
|
10
10
|
return {
|
|
11
11
|
lat: t.lat !== void 0 && t.lat !== null ? String(t.lat) : "",
|
|
@@ -23,9 +23,9 @@ function A({ attributes: t = {}, onChange: i }) {
|
|
|
23
23
|
label: m = "",
|
|
24
24
|
showMap: x = !1,
|
|
25
25
|
MuiAttributes: p = {}
|
|
26
|
-
} = t, [l, g] = S.useState(() =>
|
|
27
|
-
|
|
28
|
-
g(
|
|
26
|
+
} = t, [l, g] = S.useState(() => b(t.value));
|
|
27
|
+
j(() => {
|
|
28
|
+
g(b(t.value));
|
|
29
29
|
}, [t.value]);
|
|
30
30
|
const y = (e) => {
|
|
31
31
|
i?.({
|
|
@@ -36,12 +36,12 @@ function A({ attributes: t = {}, onChange: i }) {
|
|
|
36
36
|
}, c = (e) => (o) => {
|
|
37
37
|
const n = { ...l, [e]: o.target.value };
|
|
38
38
|
g(n), y(n);
|
|
39
|
-
}, $ = l.lat !== "" && l.lng !== "", d =
|
|
39
|
+
}, $ = l.lat !== "" && l.lng !== "", d = h(C, p.sx), w = () => {
|
|
40
40
|
const e = parseFloat(l.lat), o = parseFloat(l.lng), n = 0.01;
|
|
41
41
|
return `https://www.openstreetmap.org/export/embed.html?bbox=${`${o - n},${e - n},${o + n},${e + n}`}&marker=${e},${o}`;
|
|
42
42
|
};
|
|
43
43
|
return /* @__PURE__ */ u(s, { id: a, children: [
|
|
44
|
-
m ? /* @__PURE__ */ r(
|
|
44
|
+
m ? /* @__PURE__ */ r(L, { variant: "body2", sx: { mb: 0.75, fontWeight: 500 }, children: m }) : null,
|
|
45
45
|
/* @__PURE__ */ u(s, { sx: { display: "flex", gap: 1.5, flexWrap: "wrap" }, children: [
|
|
46
46
|
/* @__PURE__ */ r(
|
|
47
47
|
f,
|
|
@@ -69,7 +69,7 @@ function A({ attributes: t = {}, onChange: i }) {
|
|
|
69
69
|
)
|
|
70
70
|
] }),
|
|
71
71
|
/* @__PURE__ */ r(s, { sx: { mt: 1 }, children: /* @__PURE__ */ r(
|
|
72
|
-
|
|
72
|
+
k,
|
|
73
73
|
{
|
|
74
74
|
href: `https://www.google.com/maps?q=${l.lat},${l.lng}`,
|
|
75
75
|
target: "_blank",
|
|
@@ -81,8 +81,8 @@ function A({ attributes: t = {}, onChange: i }) {
|
|
|
81
81
|
x && $ ? /* @__PURE__ */ r(
|
|
82
82
|
s,
|
|
83
83
|
{
|
|
84
|
-
sx:
|
|
85
|
-
...
|
|
84
|
+
sx: h((e) => ({
|
|
85
|
+
...F(e),
|
|
86
86
|
mt: 1.5
|
|
87
87
|
})),
|
|
88
88
|
children: /* @__PURE__ */ r(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsxs as u, jsx as t } from "react/jsx-runtime";
|
|
2
2
|
import n from "react";
|
|
3
3
|
import { Paper as p, Typography as l, Box as f } from "@mui/material";
|
|
4
|
-
import { F as c } from "./
|
|
4
|
+
import { F as c } from "./AIForm-DtRl0WdY.mjs";
|
|
5
5
|
import { v as d } from "./v4-BysszJq8.mjs";
|
|
6
6
|
function F({ attributes: o = {}, patch: e, onChange: i }) {
|
|
7
7
|
const { MuiAttributes: r = {}, label: s = "Group", subFields: a = [] } = o, m = n.useMemo(() => d(), []);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),c=require("react"),t=require("@mui/material"),l=require("./AIForm-Dv8ahXyE.js"),d=require("./v4-CqdK_b8Y.js");function x({attributes:o={},patch:s,onChange:i}){const{MuiAttributes:r={},label:u="Group",subFields:n=[]}=o,a=c.useMemo(()=>d.v4(),[]);return e.jsxs(t.Paper,{elevation:1,sx:{p:2,mb:2,...r.sx},...r,children:[e.jsx(t.Typography,{variant:"subtitle1",gutterBottom:!0,sx:{fontWeight:600},children:u}),e.jsx(t.Box,{children:e.jsx(l.FormGenerator,{guid:a,data:n,patch:s,onChange:i})})]})}exports.default=x;
|
package/dist/index.d.ts
CHANGED
|
@@ -11,6 +11,8 @@ export { useFormEngine } from './util/useFormEngine';
|
|
|
11
11
|
export type { FormEngine, FieldState, UseFormEngineOptions } from './util/useFormEngine';
|
|
12
12
|
export { validateSchema } from './util/validateSchema';
|
|
13
13
|
export type { SchemaIssue } from './util/validateSchema';
|
|
14
|
+
export { configureMuiX, getMuiX, resetMuiX } from './util/muiX';
|
|
15
|
+
export type { MuiXOverrides } from './util/muiX';
|
|
14
16
|
export * from './types';
|
|
15
17
|
export * from './ai';
|
|
16
18
|
export * from './schema';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),C=require("react"),t=require("./AIForm-Dv8ahXyE.js"),U=require("@mui/material/Stack"),I=require("@mui/material/TextField"),M=require("@mui/material/MenuItem"),T=require("@mui/material/FormControl"),j=require("@mui/material/FormLabel"),n=[{code:"US",name:"United States",dial:"+1",flag:"🇺🇸"},{code:"GB",name:"United Kingdom",dial:"+44",flag:"🇬🇧"},{code:"IN",name:"India",dial:"+91",flag:"🇮🇳"},{code:"CA",name:"Canada",dial:"+1",flag:"🇨🇦"},{code:"AU",name:"Australia",dial:"+61",flag:"🇦🇺"},{code:"DE",name:"Germany",dial:"+49",flag:"🇩🇪"},{code:"FR",name:"France",dial:"+33",flag:"🇫🇷"},{code:"IT",name:"Italy",dial:"+39",flag:"🇮🇹"},{code:"ES",name:"Spain",dial:"+34",flag:"🇪🇸"},{code:"BR",name:"Brazil",dial:"+55",flag:"🇧🇷"},{code:"MX",name:"Mexico",dial:"+52",flag:"🇲🇽"},{code:"JP",name:"Japan",dial:"+81",flag:"🇯🇵"},{code:"CN",name:"China",dial:"+86",flag:"🇨🇳"},{code:"RU",name:"Russia",dial:"+7",flag:"🇷🇺"},{code:"ZA",name:"South Africa",dial:"+27",flag:"🇿🇦"},{code:"NG",name:"Nigeria",dial:"+234",flag:"🇳🇬"},{code:"KE",name:"Kenya",dial:"+254",flag:"🇰🇪"},{code:"AE",name:"United Arab Emirates",dial:"+971",flag:"🇦🇪"},{code:"SA",name:"Saudi Arabia",dial:"+966",flag:"🇸🇦"},{code:"SG",name:"Singapore",dial:"+65",flag:"🇸🇬"},{code:"MY",name:"Malaysia",dial:"+60",flag:"🇲🇾"},{code:"ID",name:"Indonesia",dial:"+62",flag:"🇮🇩"},{code:"PH",name:"Philippines",dial:"+63",flag:"🇵🇭"},{code:"TH",name:"Thailand",dial:"+66",flag:"🇹🇭"},{code:"VN",name:"Vietnam",dial:"+84",flag:"🇻🇳"},{code:"KR",name:"South Korea",dial:"+82",flag:"🇰🇷"},{code:"NZ",name:"New Zealand",dial:"+64",flag:"🇳🇿"},{code:"IE",name:"Ireland",dial:"+353",flag:"🇮🇪"},{code:"NL",name:"Netherlands",dial:"+31",flag:"🇳🇱"},{code:"SE",name:"Sweden",dial:"+46",flag:"🇸🇪"},{code:"NO",name:"Norway",dial:"+47",flag:"🇳🇴"},{code:"DK",name:"Denmark",dial:"+45",flag:"🇩🇰"},{code:"CH",name:"Switzerland",dial:"+41",flag:"🇨🇭"},{code:"PL",name:"Poland",dial:"+48",flag:"🇵🇱"},{code:"PT",name:"Portugal",dial:"+351",flag:"🇵🇹"},{code:"GR",name:"Greece",dial:"+30",flag:"🇬🇷"},{code:"TR",name:"Turkey",dial:"+90",flag:"🇹🇷"},{code:"EG",name:"Egypt",dial:"+20",flag:"🇪🇬"},{code:"AR",name:"Argentina",dial:"+54",flag:"🇦🇷"},{code:"CL",name:"Chile",dial:"+56",flag:"🇨🇱"}];function A(a,m){if(typeof a=="string"&&a.trim()){const d=[...n].sort((i,c)=>c.dial.length-i.dial.length).find(i=>a.startsWith(i.dial));if(d)return{code:d.code,number:a.slice(d.dial.length).trim()}}return{code:m,number:""}}function v({attributes:a={},rules:m={},onChange:s}){const{id:d="",defaultCountry:i="US",label:c,MuiAttributes:N={}}=a,{sx:u,...P}=N,f=n.some(e=>e.code===i)?i:"US",g=A(a.value,f),[h,S]=C.useState(g.code),[p,x]=C.useState(g.number);t.useUpdateEffect(()=>{const e=A(a.value,f);S(e.code),x(e.number)},[a.value]);const b=m?.validation?.some(e=>e.rule==="mandatory"||e.rule==="mandatoryselect")||!1,y=(e,l)=>{const r=n.find(q=>q.code===e)||n[0];s?.({id:d,value:`${r.dial} ${l}`.trim(),option:{country:r.code,dial:r.dial,number:l}})},E=e=>{const l=e.target.value;S(l),y(l,p)},R=e=>{x(e.value),y(h,e.value)};return o.jsxs(T,{component:"fieldset",fullWidth:!0,children:[c&&o.jsx(j,{component:"legend",required:b,sx:{mb:1},children:c}),o.jsxs(U,{direction:"row",spacing:1,alignItems:"flex-start",children:[o.jsx(I,{select:!0,value:h,onChange:E,size:"small",label:"Country","aria-label":"Country dial code",SelectProps:{renderValue:e=>{const l=n.find(r=>r.code===e)||n[0];return`${l.flag} ${l.dial}`}},sx:t.mergeSx(t.premiumInputSx,{minWidth:120,flexShrink:0,...u}),children:n.map(e=>o.jsxs(M,{value:e.code,children:[e.flag," ",e.name," (",e.dial,")"]},e.code))}),o.jsx(t.PatternFormat,{customInput:I,format:"### ### ####",mask:"_",value:p,onValueChange:R,fullWidth:!0,required:b,label:"Phone number",id:d,name:"intlphone",...P,sx:t.mergeSx(t.premiumInputSx,u)})]})]})}exports.default=v;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsxs as m, jsx as c } from "react/jsx-runtime";
|
|
2
2
|
import x from "react";
|
|
3
|
-
import {
|
|
3
|
+
import { j as k, m as I, k as A, r as G } from "./AIForm-DtRl0WdY.mjs";
|
|
4
4
|
import v from "@mui/material/Stack";
|
|
5
5
|
import N from "@mui/material/TextField";
|
|
6
6
|
import F from "@mui/material/MenuItem";
|
|
@@ -56,14 +56,14 @@ function E(e, r) {
|
|
|
56
56
|
}
|
|
57
57
|
return { code: r, number: "" };
|
|
58
58
|
}
|
|
59
|
-
function
|
|
59
|
+
function H({ attributes: e = {}, rules: r = {}, onChange: f }) {
|
|
60
60
|
const {
|
|
61
61
|
id: d = "",
|
|
62
62
|
defaultCountry: o = "US",
|
|
63
63
|
label: t,
|
|
64
64
|
MuiAttributes: P = {}
|
|
65
65
|
} = e, { sx: s, ...R } = P, g = n.some((a) => a.code === o) ? o : "US", u = E(e.value, g), [p, h] = x.useState(u.code), [S, b] = x.useState(u.number);
|
|
66
|
-
|
|
66
|
+
k(() => {
|
|
67
67
|
const a = E(e.value, g);
|
|
68
68
|
h(a.code), b(a.number);
|
|
69
69
|
}, [e.value]);
|
|
@@ -116,7 +116,7 @@ function Z({ attributes: e = {}, rules: r = {}, onChange: f }) {
|
|
|
116
116
|
}
|
|
117
117
|
),
|
|
118
118
|
/* @__PURE__ */ c(
|
|
119
|
-
|
|
119
|
+
G,
|
|
120
120
|
{
|
|
121
121
|
customInput: N,
|
|
122
122
|
format: "### ### ####",
|
|
@@ -136,5 +136,5 @@ function Z({ attributes: e = {}, rules: r = {}, onChange: f }) {
|
|
|
136
136
|
] });
|
|
137
137
|
}
|
|
138
138
|
export {
|
|
139
|
-
|
|
139
|
+
H as default
|
|
140
140
|
};
|