dynamic-mui 2.4.0 → 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/dist/{index-B7i3cvH0.mjs → AIForm-DtRl0WdY.mjs} +4186 -4359
- package/dist/AIForm-Dv8ahXyE.js +43 -0
- package/dist/accordion-BaiGxDcw.js +1 -0
- package/dist/{accordion-Bc3bEKtC.mjs → accordion-xg_TxxYS.mjs} +1 -1
- package/dist/{addressfield-bU-3Rnkq.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-BojHePYN.mjs → asyncautocomplete-AmSRs7PY.mjs} +19 -19
- package/dist/asyncautocomplete-Dtmxh4l1.js +1 -0
- package/dist/bar-BiIzbOC3.js +1 -0
- package/dist/{bar-DUZXtBln.mjs → bar-DNc7TMKj.mjs} +1 -1
- package/dist/{cascadeselect-CMqn7Tql.mjs → cascadeselect-BlznIKS6.mjs} +16 -16
- package/dist/cascadeselect-DqLtG-W9.js +1 -0
- package/dist/colorpicker-DpLvK1WR.js +1 -0
- package/dist/{colorpicker-CXWSUm_s.mjs → colorpicker-hP3b7teC.mjs} +2 -2
- package/dist/consentfield-B21l9tGo.js +1 -0
- package/dist/{consentfield-DxqzSUsQ.mjs → consentfield-CGT98YbR.mjs} +8 -8
- package/dist/{datatable-vq0d5mZg.mjs → datatable-B_6wXh2g.mjs} +1 -1
- 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 -33
- package/dist/editabletable-D3c3DJxX.js +1 -0
- package/dist/{editabletable-C5eH6sPe.mjs → editabletable-YaFqdLvf.mjs} +13 -13
- package/dist/fileupload--KzSGb5a.js +1 -0
- package/dist/{fileupload-XnztToJ2.mjs → fileupload-ZBi72f1R.mjs} +11 -11
- package/dist/formrepeater-BhUEa4BI.js +1 -0
- package/dist/{formrepeater-CDhYRFqz.mjs → formrepeater-Cwgtvz1c.mjs} +8 -8
- package/dist/formwizard-BlozHDc_.js +1 -0
- package/dist/{formwizard-C2QaC746.mjs → formwizard-CYcgf5jL.mjs} +1 -1
- package/dist/geofield-BynrTSVm.js +1 -0
- package/dist/{geofield-_dw7uIT2.mjs → geofield-xqZy_DAY.mjs} +12 -12
- package/dist/{group-CZgTXmJP.mjs → group-DmLN-b09.mjs} +1 -1
- package/dist/group-Dtju1rHQ.js +1 -0
- package/dist/intlphone-BeHXAcFi.js +1 -0
- package/dist/{intlphone-357BAzba.mjs → intlphone-CXUQP9Gp.mjs} +5 -5
- package/dist/{keyvaluefield-BRX83BRS.mjs → keyvaluefield-BJoEbe4I.mjs} +13 -13
- package/dist/keyvaluefield-BZQDG0l5.js +1 -0
- package/dist/{line-JDUXJ2fy.mjs → line-B3CAbZOo.mjs} +1 -1
- package/dist/line-tIm99vYW.js +1 -0
- package/dist/{lineitemlist-D84p4ZC5.mjs → lineitemlist-CBSqoC9g.mjs} +7 -7
- package/dist/lineitemlist-RqStjYB-.js +1 -0
- package/dist/{list-B6gocnmr.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-En3apdDQ.mjs → locationfield-KBbu-98L.mjs} +39 -39
- package/dist/{markdowneditor-B0CYYefE.mjs → markdowneditor-DFOgRmdL.mjs} +1 -1
- package/dist/markdowneditor-Dy7Q01FM.js +2 -0
- package/dist/{matrixfield-D9IJr1qQ.mjs → matrixfield-0lnuaEks.mjs} +7 -7
- package/dist/matrixfield-nWt6Cug5.js +1 -0
- package/dist/{multitextbox-CrHH_t_8.mjs → multitextbox-DmAWV163.mjs} +23 -23
- package/dist/multitextbox-oEgl2F8-.js +1 -0
- package/dist/{npsscale-BS-ooCks.mjs → npsscale-CdTEwERY.mjs} +12 -12
- package/dist/npsscale-DW4sxcLz.js +1 -0
- package/dist/{numberstepper-Dc7wEzfb.mjs → numberstepper-BwQ5coLc.mjs} +8 -8
- package/dist/numberstepper-cDosevJb.js +1 -0
- package/dist/{pie-BpGQ6Aor.mjs → pie-CBRckgd4.mjs} +1 -1
- package/dist/pie-gAfuDR1F.js +1 -0
- package/dist/richtexteditor-DI-h5Efn.js +1 -0
- package/dist/{richtexteditor-DHDVUoic.mjs → richtexteditor-xrbv8PXZ.mjs} +1 -1
- package/dist/{signature-Twiet_Pp.mjs → signature-CP_lA_Yh.mjs} +1 -1
- package/dist/{signature-CDaNiDTO.js → signature-FM6L60nk.js} +2 -2
- package/dist/{stepper-PK1xI0po.mjs → stepper-BprezTzX.mjs} +4 -4
- package/dist/stepper-CjGNFyBz.js +1 -0
- package/dist/{summaryfield-CDDYwbfV.mjs → summaryfield-5mJRwVZ4.mjs} +5 -5
- package/dist/summaryfield-C3xmqZQp.js +1 -0
- package/dist/tabs-B4P59kHX.js +1 -0
- package/dist/{tabs-BJ9HBvyr.mjs → tabs-By-Mm8vm.mjs} +1 -1
- package/dist/tagsinput-BwM3NYK_.js +1 -0
- package/dist/{tagsinput-B2W--DfP.mjs → tagsinput-Ce4EWy4i.mjs} +10 -10
- package/package.json +6 -1
- package/dist/accordion-CI-d8sBW.js +0 -1
- package/dist/addressfield-BVtAZyuA.js +0 -1
- package/dist/asyncautocomplete-CGUaYa8k.js +0 -1
- package/dist/bar-D-Mi7Kmk.js +0 -1
- package/dist/cascadeselect-Cu_sJIFt.js +0 -1
- package/dist/colorpicker-C6X7x0s_.js +0 -1
- package/dist/consentfield-BbwsP80E.js +0 -1
- package/dist/datatable-BThXDunv.js +0 -1
- package/dist/editabletable-Bv2TfEOc.js +0 -1
- package/dist/fileupload-CmWZnxyT.js +0 -1
- package/dist/formrepeater-COl6gNZi.js +0 -1
- package/dist/formwizard-hlQ_NCsd.js +0 -1
- package/dist/geofield-wtSTkcE0.js +0 -1
- package/dist/group-D95eDbtd.js +0 -1
- package/dist/index-DX3lZIKI.js +0 -43
- package/dist/intlphone-DR5-jK9f.js +0 -1
- package/dist/keyvaluefield-C89E1mqp.js +0 -1
- package/dist/line-B_-WceU1.js +0 -1
- package/dist/lineitemlist-VAV6uqyg.js +0 -1
- package/dist/list-DFdCIA2P.js +0 -1
- package/dist/locationfield-DSV_O6aK.js +0 -1
- package/dist/markdowneditor-LUCZHsC6.js +0 -2
- package/dist/matrixfield-BxngfAiS.js +0 -1
- package/dist/multitextbox-DETwPeJY.js +0 -1
- package/dist/npsscale-5fQ1nTCy.js +0 -1
- package/dist/numberstepper-FRaiyZz0.js +0 -1
- package/dist/pie-DvzqIIDM.js +0 -1
- package/dist/richtexteditor-B7iljrHN.js +0 -1
- package/dist/stepper-Cf2nMTEt.js +0 -1
- package/dist/summaryfield-XXHz95hU.js +0 -1
- package/dist/tabs-B3s52APG.js +0 -1
- package/dist/tagsinput-Dz7D54iz.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),u=require("react"),r=require("@mui/material"),a=require("./AIForm-Dv8ahXyE.js"),l=require("./v4-CqdK_b8Y.js");function m({attributes:o={},patch:c,onChange:n}){const{MuiAttributes:i={},label:t="Accordion",subFields:s=[]}=o,d=u.useMemo(()=>l.v4(),[]);return e.jsxs(r.Accordion,{...i,children:[e.jsx(r.AccordionSummary,{expandIcon:e.jsx(r.Icon,{children:"expand_more"}),children:e.jsx(r.Typography,{children:t})}),e.jsx(r.AccordionDetails,{children:e.jsx(a.FormGenerator,{guid:d,data:s,patch:c,onChange:n})})]})}exports.default=m;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsxs as a, jsx as o } from "react/jsx-runtime";
|
|
2
2
|
import m from "react";
|
|
3
3
|
import { Accordion as s, AccordionSummary as l, Typography as p, Icon as u, AccordionDetails as f } from "@mui/material";
|
|
4
|
-
import { F as A } from "./
|
|
4
|
+
import { F as A } from "./AIForm-DtRl0WdY.mjs";
|
|
5
5
|
import { v as h } from "./v4-BysszJq8.mjs";
|
|
6
6
|
function j({ attributes: r = {}, patch: c, onChange: i }) {
|
|
7
7
|
const { MuiAttributes: n = {}, label: e = "Accordion", subFields: t = [] } = r, d = m.useMemo(() => h(), []);
|
|
@@ -3,7 +3,7 @@ import S, { useCallback as A } from "react";
|
|
|
3
3
|
import r from "@mui/material/Grid";
|
|
4
4
|
import i from "@mui/material/TextField";
|
|
5
5
|
import g from "@mui/material/MenuItem";
|
|
6
|
-
import {
|
|
6
|
+
import { j as E, m as P, k as I } from "./AIForm-DtRl0WdY.mjs";
|
|
7
7
|
const N = [
|
|
8
8
|
{ value: "US", label: "United States" },
|
|
9
9
|
{ value: "CA", label: "Canada" },
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),h=require("react"),s=require("@mui/material/Grid"),n=require("@mui/material/TextField"),j=require("@mui/material/MenuItem"),c=require("./AIForm-Dv8ahXyE.js"),g=[{value:"US",label:"United States"},{value:"CA",label:"Canada"},{value:"MX",label:"Mexico"},{value:"GB",label:"United Kingdom"},{value:"IE",label:"Ireland"},{value:"FR",label:"France"},{value:"DE",label:"Germany"},{value:"ES",label:"Spain"},{value:"IT",label:"Italy"},{value:"NL",label:"Netherlands"},{value:"BE",label:"Belgium"},{value:"CH",label:"Switzerland"},{value:"SE",label:"Sweden"},{value:"NO",label:"Norway"},{value:"DK",label:"Denmark"},{value:"PT",label:"Portugal"},{value:"AU",label:"Australia"},{value:"NZ",label:"New Zealand"},{value:"IN",label:"India"},{value:"CN",label:"China"},{value:"JP",label:"Japan"},{value:"SG",label:"Singapore"},{value:"AE",label:"United Arab Emirates"},{value:"BR",label:"Brazil"},{value:"ZA",label:"South Africa"}],f={street1:"Street address",street2:"Apt, suite, etc. (optional)",city:"City",state:"State / Province",postalCode:"Postal code",country:"Country"};function P({attributes:i={},rules:m={},onChange:b}){const{id:v="",MuiAttributes:x={},countries:o,labels:C={}}=i,S=Array.isArray(o)&&o.length?o:g,l={...f,...C},d=m?.validation?.some(t=>t.rule==="mandatory"||t.rule==="mandatoryselect")||!1,[a,p]=h.useState(()=>({street1:"",street2:"",city:"",state:"",postalCode:"",country:"",...i?.value||{}}));c.useUpdateEffect(()=>{p({street1:"",street2:"",city:"",state:"",postalCode:"",country:"",...i?.value||{}})},[i?.value]);const r=h.useCallback(t=>A=>{const y={...a,[t]:A.target.value};p(y),b?.({id:v,value:y})},[a,v,b]),u=c.mergeSx(c.premiumInputSx,x?.sx);return e.jsxs(s,{container:!0,spacing:2,...x,children:[e.jsx(s,{size:{xs:12},children:e.jsx(n,{fullWidth:!0,label:l.street1,required:d,value:a.street1||"",onChange:r("street1"),inputProps:{"aria-label":l.street1},sx:u})}),e.jsx(s,{size:{xs:12},children:e.jsx(n,{fullWidth:!0,label:l.street2,value:a.street2||"",onChange:r("street2"),inputProps:{"aria-label":l.street2},sx:u})}),e.jsx(s,{size:{xs:12,sm:6,md:5},children:e.jsx(n,{fullWidth:!0,label:l.city,required:d,value:a.city||"",onChange:r("city"),inputProps:{"aria-label":l.city},sx:u})}),e.jsx(s,{size:{xs:12,sm:6,md:4},children:e.jsx(n,{fullWidth:!0,label:l.state,value:a.state||"",onChange:r("state"),inputProps:{"aria-label":l.state},sx:u})}),e.jsx(s,{size:{xs:12,sm:6,md:3},children:e.jsx(n,{fullWidth:!0,label:l.postalCode,value:a.postalCode||"",onChange:r("postalCode"),inputProps:{"aria-label":l.postalCode},sx:u})}),e.jsx(s,{size:{xs:12,sm:6},children:e.jsx(n,{select:!0,fullWidth:!0,label:l.country,required:d,value:a.country||"",onChange:r("country"),SelectProps:{inputProps:{"aria-label":l.country}},sx:u,children:S.map(t=>e.jsx(j,{value:t.value,children:t.label},t.value))})})]})}exports.default=P;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../AIForm-Dv8ahXyE.js");exports.AIFill=e.AIFill;exports.AIForm=e.AIForm;exports.AIFormGenerator=e.AIFormGenerator;exports.AISchemaReview=e.AISchemaReview;exports.AITextAssist=e.AITextAssist;exports.AIVisionImport=e.AIVisionImport;exports.createAIClient=e.createAIClient;exports.formFieldsToSimple=e.formFieldsToSimple;exports.simpleFieldsToFormFields=e.simpleFieldsToFormFields;exports.slug=e.slug;exports.useAIAssist=e.useAIAssist;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { A as a, a as i, b as o, c as A, d as r, e as l, f as m, g as I, s as t, h as F, u as d } from "../AIForm-DtRl0WdY.mjs";
|
|
2
|
+
export {
|
|
3
|
+
a as AIFill,
|
|
4
|
+
i as AIForm,
|
|
5
|
+
o as AIFormGenerator,
|
|
6
|
+
A as AISchemaReview,
|
|
7
|
+
r as AITextAssist,
|
|
8
|
+
l as AIVisionImport,
|
|
9
|
+
m as createAIClient,
|
|
10
|
+
I as formFieldsToSimple,
|
|
11
|
+
t as simpleFieldsToFormFields,
|
|
12
|
+
F as slug,
|
|
13
|
+
d as useAIAssist
|
|
14
|
+
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { jsx as c, jsxs as
|
|
2
|
-
import { useState as f, useRef as y, useEffect as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
import { jsx as c, jsxs as k, Fragment as F } from "react/jsx-runtime";
|
|
2
|
+
import { useState as f, useRef as y, useEffect as K, createElement as L } from "react";
|
|
3
|
+
import M from "@mui/material/Autocomplete";
|
|
4
|
+
import _ from "@mui/material/TextField";
|
|
5
5
|
import z from "@mui/material/CircularProgress";
|
|
6
|
-
import {
|
|
6
|
+
import { j as V, k as w } from "./AIForm-DtRl0WdY.mjs";
|
|
7
7
|
function Q({ attributes: t = {}, rules: v = {}, onChange: A }) {
|
|
8
8
|
const {
|
|
9
9
|
MuiAttributes: C = {},
|
|
@@ -11,18 +11,18 @@ function Q({ attributes: t = {}, rules: v = {}, onChange: A }) {
|
|
|
11
11
|
label: I = "Search",
|
|
12
12
|
placeholder: O = "",
|
|
13
13
|
minChars: S = 1,
|
|
14
|
-
debounceMs:
|
|
15
|
-
labelKey:
|
|
14
|
+
debounceMs: j = 300,
|
|
15
|
+
labelKey: q = "label",
|
|
16
16
|
valueKey: p = "value",
|
|
17
17
|
loadOptions: m,
|
|
18
18
|
optionsUrl: s
|
|
19
|
-
} = t, [
|
|
19
|
+
} = t, [P, d] = f(t.value ?? null), [T, a] = f([]), [h, o] = f(!1), u = y(0), r = y(null);
|
|
20
20
|
V(() => {
|
|
21
21
|
d(t.value ?? null);
|
|
22
|
-
}, [t.value]),
|
|
22
|
+
}, [t.value]), K(() => () => {
|
|
23
23
|
r.current && clearTimeout(r.current);
|
|
24
24
|
}, []);
|
|
25
|
-
const
|
|
25
|
+
const b = async (e) => {
|
|
26
26
|
if (typeof m == "function")
|
|
27
27
|
return m(e);
|
|
28
28
|
if (s) {
|
|
@@ -32,7 +32,7 @@ function Q({ attributes: t = {}, rules: v = {}, onChange: A }) {
|
|
|
32
32
|
return [];
|
|
33
33
|
}, E = (e) => {
|
|
34
34
|
const n = ++u.current;
|
|
35
|
-
o(!0),
|
|
35
|
+
o(!0), b(e).then((i) => {
|
|
36
36
|
n === u.current && (a(Array.isArray(i) ? i : []), o(!1));
|
|
37
37
|
}).catch(() => {
|
|
38
38
|
n === u.current && (a([]), o(!1));
|
|
@@ -44,28 +44,28 @@ function Q({ attributes: t = {}, rules: v = {}, onChange: A }) {
|
|
|
44
44
|
}
|
|
45
45
|
r.current = setTimeout(() => {
|
|
46
46
|
E(n);
|
|
47
|
-
},
|
|
47
|
+
}, j);
|
|
48
48
|
}, U = (e, n) => {
|
|
49
49
|
d(n), A?.({
|
|
50
50
|
id: x,
|
|
51
51
|
value: n != null ? n?.[p] ?? n : n,
|
|
52
52
|
option: n
|
|
53
53
|
});
|
|
54
|
-
}, l = (e) => typeof e == "string" ? e : e?.[
|
|
54
|
+
}, l = (e) => typeof e == "string" ? e : e?.[q] ?? "", $ = !!v?.validation?.some((e) => e.rule === "mandatory");
|
|
55
55
|
return /* @__PURE__ */ c(
|
|
56
|
-
|
|
56
|
+
M,
|
|
57
57
|
{
|
|
58
|
-
value:
|
|
58
|
+
value: P,
|
|
59
59
|
onChange: U,
|
|
60
60
|
onInputChange: R,
|
|
61
|
-
options:
|
|
61
|
+
options: T,
|
|
62
62
|
loading: h,
|
|
63
63
|
filterOptions: (e) => e,
|
|
64
64
|
getOptionLabel: l,
|
|
65
|
-
renderOption: (e, n) => /* @__PURE__ */
|
|
65
|
+
renderOption: (e, n) => /* @__PURE__ */ L("li", { ...e, key: (n && n[p]) ?? l(n) }, l(n)),
|
|
66
66
|
...C,
|
|
67
67
|
renderInput: (e) => /* @__PURE__ */ c(
|
|
68
|
-
|
|
68
|
+
_,
|
|
69
69
|
{
|
|
70
70
|
...e,
|
|
71
71
|
label: I,
|
|
@@ -74,7 +74,7 @@ function Q({ attributes: t = {}, rules: v = {}, onChange: A }) {
|
|
|
74
74
|
sx: w,
|
|
75
75
|
InputProps: {
|
|
76
76
|
...e.InputProps,
|
|
77
|
-
endAdornment: /* @__PURE__ */ F
|
|
77
|
+
endAdornment: /* @__PURE__ */ k(F, { children: [
|
|
78
78
|
h ? /* @__PURE__ */ c(z, { color: "inherit", size: 20 }) : null,
|
|
79
79
|
e.InputProps.endAdornment
|
|
80
80
|
] })
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),t=require("react"),U=require("@mui/material/Autocomplete"),$=require("@mui/material/TextField"),K=require("@mui/material/CircularProgress"),y=require("./AIForm-Dv8ahXyE.js");function L({attributes:o={},rules:v={},onChange:A}){const{MuiAttributes:q={},id:S="",label:x="Search",placeholder:j="",minChars:C=1,debounceMs:I=300,labelKey:O="label",valueKey:d="value",loadOptions:p,optionsUrl:a}=o,[R,h]=t.useState(o.value??null),[b,i]=t.useState([]),[m,s]=t.useState(!1),c=t.useRef(0),r=t.useRef(null);y.useUpdateEffect(()=>{h(o.value??null)},[o.value]),t.useEffect(()=>()=>{r.current&&clearTimeout(r.current)},[]);const P=async e=>{if(typeof p=="function")return p(e);if(a){const n=`${a}${a.includes("?")?"&":"?"}q=${encodeURIComponent(e)}`,g=await(await fetch(n)).json();return Array.isArray(g)?g:[]}return[]},T=e=>{const n=++c.current;s(!0),P(e).then(f=>{n===c.current&&(i(Array.isArray(f)?f:[]),s(!1))}).catch(()=>{n===c.current&&(i([]),s(!1))})},E=(e,n)=>{if(r.current&&clearTimeout(r.current),!n||n.length<C){c.current++,s(!1),i([]);return}r.current=setTimeout(()=>{T(n)},I)},F=(e,n)=>{h(n),A?.({id:S,value:n!=null?n?.[d]??n:n,option:n})},l=e=>typeof e=="string"?e:e?.[O]??"",M=!!v?.validation?.some(e=>e.rule==="mandatory");return u.jsx(U,{value:R,onChange:F,onInputChange:E,options:b,loading:m,filterOptions:e=>e,getOptionLabel:l,renderOption:(e,n)=>t.createElement("li",{...e,key:(n&&n[d])??l(n)},l(n)),...q,renderInput:e=>u.jsx($,{...e,label:x,placeholder:j,required:M,sx:y.premiumInputSx,InputProps:{...e.InputProps,endAdornment:u.jsxs(u.Fragment,{children:[m?u.jsx(K,{color:"inherit",size:20}):null,e.InputProps.endAdornment]})}})})}exports.default=L;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var o=Object.create;var a=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var h=Object.getPrototypeOf,d=Object.prototype.hasOwnProperty;var x=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of l(e))!d.call(t,s)&&s!==r&&a(t,s,{get:()=>e[s],enumerable:!(i=c(e,s))||i.enumerable});return t};var f=(t,e,r)=>(r=t!=null?o(h(t)):{},x(e||!t||!t.__esModule?a(r,"default",{value:t,enumerable:!0}):r,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),u=require("react"),j=require("@mui/material/Box"),C=require("@mui/material/CircularProgress"),y=require("./AIForm-Dv8ahXyE.js"),g=u.lazy(()=>import("@mui/x-charts/BarChart").then(t=>({default:t.BarChart})));function p({attributes:t={}}){const{MuiChartAttributes:e={},id:r=""}=t,i=y.getMuiX("BarChart")||g;return n.jsx(u.Suspense,{fallback:n.jsx(j,{sx:{display:"flex",justifyContent:"center",p:2},children:n.jsx(C,{})}),children:n.jsx(i,{height:300,...e},r)})}exports.default=p;
|
|
@@ -2,7 +2,7 @@ import { jsx as r } from "react/jsx-runtime";
|
|
|
2
2
|
import i, { Suspense as s } from "react";
|
|
3
3
|
import n from "@mui/material/Box";
|
|
4
4
|
import f from "@mui/material/CircularProgress";
|
|
5
|
-
import {
|
|
5
|
+
import { i as m } from "./AIForm-DtRl0WdY.mjs";
|
|
6
6
|
const c = i.lazy(
|
|
7
7
|
() => import("@mui/x-charts/BarChart").then((t) => ({ default: t.BarChart }))
|
|
8
8
|
);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import x, { useCallback as
|
|
3
|
-
import
|
|
1
|
+
import { jsxs as k, jsx as p } from "react/jsx-runtime";
|
|
2
|
+
import x, { useCallback as C } from "react";
|
|
3
|
+
import E from "@mui/material/TextField";
|
|
4
4
|
import S from "@mui/material/MenuItem";
|
|
5
|
-
import {
|
|
6
|
-
const
|
|
5
|
+
import { j as y, m as I, k as O } from "./AIForm-DtRl0WdY.mjs";
|
|
6
|
+
const P = (a) => Array.isArray(a) ? a.map(
|
|
7
7
|
(e) => e != null && typeof e == "object" ? { value: e.value, label: e.label ?? e.title ?? String(e.value) } : { value: e, label: String(e) }
|
|
8
8
|
) : [], h = (a, e, t) => {
|
|
9
9
|
const r = a && e != null && e !== "" ? a[e] : void 0;
|
|
10
|
-
return
|
|
10
|
+
return P(r ?? t ?? []);
|
|
11
11
|
};
|
|
12
12
|
function U({ attributes: a = {}, rules: e = {}, onChange: t }) {
|
|
13
13
|
const {
|
|
@@ -22,36 +22,36 @@ function U({ attributes: a = {}, rules: e = {}, onChange: t }) {
|
|
|
22
22
|
(l) => l.rule === "mandatory" || l.rule === "mandatoryselect"
|
|
23
23
|
) || !1, [m, g] = x.useState(
|
|
24
24
|
() => h(o, s, i)
|
|
25
|
-
), [
|
|
25
|
+
), [u, d] = x.useState(() => a?.value ?? "");
|
|
26
26
|
y(() => {
|
|
27
27
|
d(a?.value ?? "");
|
|
28
28
|
}, [a?.value]), y(() => {
|
|
29
29
|
const l = h(o, s, i);
|
|
30
|
-
g(l),
|
|
30
|
+
g(l), u !== "" && u != null && !l.some((n) => n.value === u) && (d(""), t?.({ id: r, value: "", option: null }));
|
|
31
31
|
}, [s, o, i]);
|
|
32
|
-
const
|
|
32
|
+
const j = C(
|
|
33
33
|
(l) => {
|
|
34
|
-
const
|
|
35
|
-
d(
|
|
34
|
+
const n = l.target.value, M = m.find((A) => A.value === n) ?? null;
|
|
35
|
+
d(n), t?.({ id: r, value: n, option: M });
|
|
36
36
|
},
|
|
37
37
|
[m, r, t]
|
|
38
38
|
);
|
|
39
|
-
return /* @__PURE__ */
|
|
40
|
-
|
|
39
|
+
return /* @__PURE__ */ k(
|
|
40
|
+
E,
|
|
41
41
|
{
|
|
42
42
|
select: !0,
|
|
43
43
|
fullWidth: !0,
|
|
44
44
|
label: v,
|
|
45
45
|
placeholder: c,
|
|
46
46
|
required: b,
|
|
47
|
-
value:
|
|
48
|
-
onChange:
|
|
47
|
+
value: u ?? "",
|
|
48
|
+
onChange: j,
|
|
49
49
|
SelectProps: {
|
|
50
50
|
displayEmpty: !0,
|
|
51
51
|
inputProps: { "aria-label": v || "cascade-select" }
|
|
52
52
|
},
|
|
53
53
|
...f,
|
|
54
|
-
sx: O
|
|
54
|
+
sx: I(O, f?.sx),
|
|
55
55
|
children: [
|
|
56
56
|
c ? /* @__PURE__ */ p(S, { value: "", children: /* @__PURE__ */ p("em", { children: c }) }) : null,
|
|
57
57
|
m.map((l) => /* @__PURE__ */ p(S, { value: l.value, children: l.label }, String(l.value)))
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),f=require("react"),A=require("@mui/material/TextField"),y=require("@mui/material/MenuItem"),i=require("./AIForm-Dv8ahXyE.js"),E=t=>Array.isArray(t)?t.map(e=>e!=null&&typeof e=="object"?{value:e.value,label:e.label??e.title??String(e.value)}:{value:e,label:String(e)}):[],b=(t,e,a)=>{const u=t&&e!=null&&e!==""?t[e]:void 0;return E(u??a??[])};function I({attributes:t={},rules:e={},onChange:a}){const{id:u="",parentValue:c,optionsMap:o,options:d,label:x="",placeholder:v="",MuiAttributes:S={}}=t,g=e?.validation?.some(l=>l.rule==="mandatory"||l.rule==="mandatoryselect")||!1,[p,h]=f.useState(()=>b(o,c,d)),[r,m]=f.useState(()=>t?.value??"");i.useUpdateEffect(()=>{m(t?.value??"")},[t?.value]),i.useUpdateEffect(()=>{const l=b(o,c,d);h(l),r!==""&&r!=null&&!l.some(n=>n.value===r)&&(m(""),a?.({id:u,value:"",option:null}))},[c,o,d]);const j=f.useCallback(l=>{const n=l.target.value,q=p.find(M=>M.value===n)??null;m(n),a?.({id:u,value:n,option:q})},[p,u,a]);return s.jsxs(A,{select:!0,fullWidth:!0,label:x,placeholder:v,required:g,value:r??"",onChange:j,SelectProps:{displayEmpty:!0,inputProps:{"aria-label":x||"cascade-select"}},...S,sx:i.mergeSx(i.premiumInputSx,S?.sx),children:[v?s.jsx(y,{value:"",children:s.jsx("em",{children:v})}):null,p.map(l=>s.jsx(y,{value:l.value,children:l.label},String(l.value)))]})}exports.default=I;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),k=require("react"),p=require("@mui/material/Box"),x=require("@mui/material/Stack"),C=require("@mui/material/TextField"),$=require("@mui/material/FormControl"),A=require("@mui/material/FormLabel"),l=require("@mui/material/styles"),n=require("./AIForm-Dv8ahXyE.js"),h="#000000";function F({attributes:t={},rules:m={},onChange:b}){const{id:u="",label:o,presets:s=[],MuiAttributes:g={}}=t,{sx:y,...f}=g,[a,d]=k.useState(t.value||h);n.useUpdateEffect(()=>{d(t.value||h)},[t.value]);const v=m?.validation?.some(e=>e.rule==="mandatory"||e.rule==="mandatoryselect")||!1,c=e=>{d(e),b?.({id:u,value:e})},S=e=>{c(e.target.value)},w=e=>{c(e.target.value)},j=e=>{c(e)},q={width:44,height:44,borderRadius:"10px",border:e=>`1px solid ${l.alpha(e.palette.text.primary,.2)}`,boxShadow:e=>`0 2px 8px ${l.alpha(e.palette.common.black,.12)}`,cursor:"pointer",flexShrink:0,position:"relative",overflow:"hidden"};return r.jsxs($,{required:v,component:"fieldset",fullWidth:!0,children:[o&&r.jsx(A,{component:"legend",children:o}),r.jsxs(x,{direction:"row",spacing:1.5,alignItems:"center",sx:{mt:o?1:0},children:[r.jsx(p,{sx:{...q,backgroundColor:a},children:r.jsx("input",{type:"color","aria-label":o?`${o} colour`:"colour",value:a,onChange:S,...f,style:{position:"absolute",inset:0,width:"100%",height:"100%",opacity:0,border:"none",padding:0,cursor:"pointer"}})}),r.jsx(C,{id:u||void 0,value:a,onChange:w,size:"small",label:"Hex",inputProps:{"aria-label":"hex value"},sx:n.mergeSx(n.premiumInputSx,n.mergeSx({maxWidth:160},y))})]}),Array.isArray(s)&&s.length>0&&r.jsx(x,{direction:"row",spacing:1,sx:{mt:1.5,flexWrap:"wrap",rowGap:1},children:s.map(e=>r.jsx(p,{role:"button","aria-label":`preset ${e}`,onClick:()=>j(e),sx:{width:26,height:26,borderRadius:"8px",backgroundColor:e,cursor:"pointer",flexShrink:0,border:i=>a===e?`2px solid ${i.palette.primary.main}`:`1px solid ${l.alpha(i.palette.text.primary,.2)}`,boxShadow:i=>`0 1px 4px ${l.alpha(i.palette.common.black,.12)}`}},e))})]})}exports.default=F;
|
|
@@ -6,7 +6,7 @@ import A from "@mui/material/TextField";
|
|
|
6
6
|
import F from "@mui/material/FormControl";
|
|
7
7
|
import I from "@mui/material/FormLabel";
|
|
8
8
|
import { alpha as l } from "@mui/material/styles";
|
|
9
|
-
import {
|
|
9
|
+
import { j as R, m as x, k as j } from "./AIForm-DtRl0WdY.mjs";
|
|
10
10
|
const h = "#000000";
|
|
11
11
|
function q({ attributes: t = {}, rules: f = {}, onChange: b }) {
|
|
12
12
|
const { id: p = "", label: r, presets: n = [], MuiAttributes: g = {} } = t, { sx: w, ...v } = g, [a, d] = $.useState(
|
|
@@ -68,7 +68,7 @@ function q({ attributes: t = {}, rules: f = {}, onChange: b }) {
|
|
|
68
68
|
size: "small",
|
|
69
69
|
label: "Hex",
|
|
70
70
|
inputProps: { "aria-label": "hex value" },
|
|
71
|
-
sx: x(
|
|
71
|
+
sx: x(j, x({ maxWidth: 160 }, w))
|
|
72
72
|
}
|
|
73
73
|
)
|
|
74
74
|
] }),
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),a=require("react"),M=require("@mui/material/Box"),w=require("@mui/material/Checkbox"),R=require("@mui/material/FormControl"),A=require("@mui/material/FormControlLabel"),I=require("@mui/material/FormHelperText"),P=require("@mui/material/styles"),s=require("./AIForm-Dv8ahXyE.js");function V({attributes:l={},rules:c={},onChange:x}){const{MuiAttributes:g={},id:p="",text:f="",label:i="I agree to the terms",requireScroll:u=!0}=l,[S,d]=a.useState(!!l.value),[q,b]=a.useState(!u),[C,j]=a.useState(!1),[m,v]=a.useState("");s.useUpdateEffect(()=>{d(!!l.value)},[l.value]);const n=c?.validation?.some(e=>e.rule==="mandatory"||e.rule==="mandatoryselect")||!1,y=e=>{let r=!0,o="";return n&&!e&&(r=!1,o=c?.validation?.find(h=>h.rule==="mandatory"||h.rule==="mandatoryselect")?.message||"Required"),{isValid:r,message:o}},T=e=>{const r=e.currentTarget;r.scrollTop+r.clientHeight>=r.scrollHeight-4&&b(!0)},k=e=>{const r=e.target.checked;d(r);const o=y(r);j(!o.isValid),v(o.message),x?.({id:p,value:r})},F=u&&!q,{sx:H,...E}=g,L=n?t.jsxs("span",{children:[i,t.jsx("span",{"aria-hidden":"true",style:{color:"#d32f2f",marginLeft:2},children:"*"})]}):i;return t.jsxs(R,{required:n,error:C,component:"fieldset",fullWidth:!0,children:[t.jsx(M,{"data-testid":"consent-terms",onScroll:T,sx:s.mergeSx(s.premiumSurfaceSx,{maxHeight:200,overflow:"auto",p:2,mb:1,whiteSpace:"pre-wrap",backgroundColor:e=>P.alpha(e.palette.background.paper,1)}),children:f}),t.jsx(A,{...E,sx:s.mergeSx(s.premiumControlLabelSx,H),label:L,control:t.jsx(w,{checked:S,disabled:F,onChange:k,required:n,inputProps:{"aria-label":"consent-agree"}})}),m&&t.jsx(I,{children:m})]})}exports.default=V;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsxs as p, jsx as o } from "react/jsx-runtime";
|
|
2
2
|
import s from "react";
|
|
3
|
-
import
|
|
3
|
+
import M from "@mui/material/Box";
|
|
4
4
|
import R from "@mui/material/Checkbox";
|
|
5
5
|
import V from "@mui/material/FormControl";
|
|
6
6
|
import A from "@mui/material/FormControlLabel";
|
|
7
7
|
import B from "@mui/material/FormHelperText";
|
|
8
8
|
import { alpha as I } from "@mui/material/styles";
|
|
9
|
-
import {
|
|
9
|
+
import { j as P, m as f, l as U, n as W } from "./AIForm-DtRl0WdY.mjs";
|
|
10
10
|
function Z({ attributes: a = {}, rules: n = {}, onChange: h }) {
|
|
11
11
|
const {
|
|
12
12
|
MuiAttributes: g = {},
|
|
@@ -14,7 +14,7 @@ function Z({ attributes: a = {}, rules: n = {}, onChange: h }) {
|
|
|
14
14
|
text: S = "",
|
|
15
15
|
label: c = "I agree to the terms",
|
|
16
16
|
requireScroll: i = !0
|
|
17
|
-
} = a, [
|
|
17
|
+
} = a, [C, d] = s.useState(!!a.value), [b, v] = s.useState(!i), [k, T] = s.useState(!1), [m, y] = s.useState("");
|
|
18
18
|
P(() => {
|
|
19
19
|
d(!!a.value);
|
|
20
20
|
}, [a.value]);
|
|
@@ -31,13 +31,13 @@ function Z({ attributes: a = {}, rules: n = {}, onChange: h }) {
|
|
|
31
31
|
d(r);
|
|
32
32
|
const t = H(r);
|
|
33
33
|
T(!t.isValid), y(t.message), h?.({ id: x, value: r });
|
|
34
|
-
}, F = i && !
|
|
34
|
+
}, F = i && !b, { sx: L, ...j } = g, w = l ? /* @__PURE__ */ p("span", { children: [
|
|
35
35
|
c,
|
|
36
36
|
/* @__PURE__ */ o("span", { "aria-hidden": "true", style: { color: "#d32f2f", marginLeft: 2 }, children: "*" })
|
|
37
37
|
] }) : c;
|
|
38
38
|
return /* @__PURE__ */ p(V, { required: l, error: k, component: "fieldset", fullWidth: !0, children: [
|
|
39
39
|
/* @__PURE__ */ o(
|
|
40
|
-
|
|
40
|
+
M,
|
|
41
41
|
{
|
|
42
42
|
"data-testid": "consent-terms",
|
|
43
43
|
onScroll: q,
|
|
@@ -55,13 +55,13 @@ function Z({ attributes: a = {}, rules: n = {}, onChange: h }) {
|
|
|
55
55
|
/* @__PURE__ */ o(
|
|
56
56
|
A,
|
|
57
57
|
{
|
|
58
|
-
...
|
|
58
|
+
...j,
|
|
59
59
|
sx: f(W, L),
|
|
60
|
-
label:
|
|
60
|
+
label: w,
|
|
61
61
|
control: /* @__PURE__ */ o(
|
|
62
62
|
R,
|
|
63
63
|
{
|
|
64
|
-
checked:
|
|
64
|
+
checked: C,
|
|
65
65
|
disabled: F,
|
|
66
66
|
onChange: E,
|
|
67
67
|
required: l,
|
|
@@ -2,7 +2,7 @@ import { jsx as t } from "react/jsx-runtime";
|
|
|
2
2
|
import e, { Suspense as n } from "react";
|
|
3
3
|
import s from "@mui/material/Box";
|
|
4
4
|
import c from "@mui/material/CircularProgress";
|
|
5
|
-
import {
|
|
5
|
+
import { i as l } from "./AIForm-DtRl0WdY.mjs";
|
|
6
6
|
const m = e.lazy(
|
|
7
7
|
() => import("@mui/x-data-grid").then((r) => ({ default: r.DataGrid }))
|
|
8
8
|
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var c=Object.create;var a=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var d=Object.getPrototypeOf,x=Object.prototype.hasOwnProperty;var j=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of l(t))!x.call(e,i)&&i!==r&&a(e,i,{get:()=>t[i],enumerable:!(n=u(t,i))||n.enumerable});return e};var f=(e,t,r)=>(r=e!=null?c(d(e)):{},j(t||!e||!e.__esModule?a(r,"default",{value:e,enumerable:!0}):r,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),o=require("react"),y=require("@mui/material/Box"),b=require("@mui/material/CircularProgress"),m=require("./AIForm-Dv8ahXyE.js"),p=o.lazy(()=>import("@mui/x-data-grid").then(e=>({default:e.DataGrid})));function q({attributes:e={}}){const{MuiAttributes:t={},container:r={}}=e,n=m.getMuiX("DataGrid")||p;return s.jsx("div",{...r,children:s.jsx(o.Suspense,{fallback:s.jsx(y,{sx:{display:"flex",justifyContent:"center",p:2},children:s.jsx(b,{})}),children:s.jsx(n,{rows:[],columns:[],...t})})})}exports.default=q;
|
package/dist/dynamic-mui.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./AIForm-Dv8ahXyE.js"),g=require("react");function U(e){return r=>{const i=e.safeParse(r);return!i||i.success?[]:(i.error?.issues||i.error?.errors||[]).map(p=>({id:String(p?.path?.[0]??""),message:p?.message||"Invalid value",rule:p?.code||"zod"})).filter(p=>p.id)}}function H(e){return r=>{try{return e.validateSync(r,{abortEarly:!1}),[]}catch(i){return(i?.inner?.length?i.inner:i?[i]:[]).map(p=>({id:String(p?.path??""),message:p?.message||"Invalid value",rule:p?.type||"yup"})).filter(p=>p.id)}}}const R=["mandatory","mandatoryselect"],I=(e,r)=>{const i=[];return(e||[]).forEach(h=>{if(i.push(h),Array.isArray(h.subforms)&&h.subforms.length){const p=h?.id||h?.props?.id,u=p?r[p]:void 0;h.subforms.forEach(a=>{(Array.isArray(u)?u.includes(a.conditionValue):a.conditionValue===u)&&i.push(...I(a.data||[],r))})}}),i},E=e=>e?.id||e?.props?.id||"",W=(e,r)=>!e?.visibleWhen||o.evaluateRule(e.visibleWhen,r),J=(e,r)=>e?.optionsMap&&e?.dependsOn?e.optionsMap[r[e.dependsOn]]||[]:e?.props?.options;function K(e,r={}){const{resolver:i}=r,h=r.messages?.required||"This field is required",p=g.useMemo(()=>{const t={...r.initialValues||{}};return I(e,t).forEach(s=>{const f=E(s),d=s?.props?.value;f&&t[f]===void 0&&d!==void 0&&(t[f]=d)}),t},[]),[u,a]=g.useState(p),[l,C]=g.useState([]),v=g.useRef(p),A=g.useCallback(t=>{const s={...t};return I(e,s).forEach(d=>{const n=E(d);if(n&&d.visibleWhen&&!o.evaluateRule(d.visibleWhen,s)&&delete s[n],n&&d.optionsMap&&d.dependsOn){const b=(d.optionsMap[s[d.dependsOn]]||[]).map(y=>typeof y=="string"?y:y?.value),F=s[n];F!=null&&F!==""&&!b.includes(F)&&delete s[n]}}),(e||[]).forEach(d=>{if(!Array.isArray(d.subforms)||!d.subforms.length)return;const n=E(d),c=n?s[n]:void 0,b=new Set,F=new Set;d.subforms.forEach(y=>{const M=Array.isArray(c)?c.includes(y.conditionValue):y.conditionValue===c;(y.data||[]).forEach(O=>{const m=E(O);m&&(M?b:F).add(m)})}),F.forEach(y=>{b.has(y)||delete s[y]})}),I(e,s).forEach(d=>{const n=E(d);n&&d.formula&&(s[n]=o.computeFormula(d.formula,s))}),s},[e]),L=g.useCallback((t,s)=>{a(f=>A({...f,[t]:s}))},[A]),_=g.useCallback(t=>{a(s=>A({...s,...t||{}}))},[A]),w=g.useCallback(t=>{const s=I(e,t),f=[],d=new Set;if(s.forEach(n=>{const c=E(n);c&&!W(n,t)&&d.add(c)}),s.forEach(n=>{const c=E(n);if(!c||d.has(c))return;const b=[...n?.rules?.validation||[]],F=b.some(m=>R.includes(m.rule));if(n.requiredWhen&&!F&&o.evaluateRule(n.requiredWhen,t)&&b.push({rule:"mandatory",message:n.requiredMessage||h}),!b.length)return;const y=t[c],M=y==null?"":String(y),O=b.some(m=>R.includes(m.rule));b.forEach(m=>{const $=o.CROSS_FIELD_VALIDATORS[m.rule];if($){if(!M&&!O)return;const q=t[m.field??m.value],B=q==null?"":String(q);$(M,B)||f.push({id:c,rule:m.rule,message:m.message});return}const V=o.Validation[m.rule];if(typeof V!="function")return;const k=R.includes(m.rule);if(!M&&!k)return;V(k?y:M,m.value)||f.push({id:c,rule:m.rule,message:m.message||(k?h:"")})})}),i){let n=[];try{n=i(t)||[]}catch{n=[]}n.forEach(c=>{c&&c.id&&!d.has(c.id)&&f.push({id:c.id,rule:c.rule||"schema",message:c.message})})}return f},[e,i,h]),G=g.useCallback(()=>{const t=w(u);return C(t),t},[w,u]),z=g.useCallback(t=>{const s=w(u);return C(s),s.length===0&&t&&t({...u}),s},[w,u]),P=g.useCallback(()=>{a({...v.current}),C([])},[]),S=g.useMemo(()=>{const t=new Map;return l.forEach(s=>{s.id&&!t.has(s.id)&&t.set(s.id,s.message)}),I(e,u).map(s=>{const f=E(s),n=(s?.rules?.validation||[]).some(b=>R.includes(b.rule))||!!(s.requiredWhen&&o.evaluateRule(s.requiredWhen,u)),c=s.formula?o.computeFormula(s.formula,u):u[f];return{id:f,field:s,value:c,visible:W(s,u),disabled:!!(s.disabledWhen&&o.evaluateRule(s.disabledWhen,u)),required:n,options:J(s,u),error:t.get(f)}})},[e,u,l]),Y=g.useMemo(()=>S.filter(t=>t.visible),[S]),j=g.useCallback(t=>S.find(s=>s.id===t),[S]),N=g.useMemo(()=>!o.isEqual(u,v.current),[u]);return{values:u,errors:l,fields:S,visibleFields:Y,getFieldState:j,setValue:L,setValues:_,validate:G,isValid:l.length===0,isDirty:N,reset:P,submit:z}}const Q=new Set(["typography","divider","alert","image","imagelist","hyperlink","button"]),D=e=>e?.id||e?.props?.id,T=(e,r=new Set)=>((e||[]).forEach(i=>{const h=D(i);h&&r.add(h),Array.isArray(i?.subforms)&&i.subforms.forEach(p=>T(p?.data||[],r))}),r),X=e=>{if(!e||typeof e!="object")return[];if(typeof e.field=="string")return[e.field];const r=e.all||e.any||e.none;return Array.isArray(r)?r.flatMap(X):[]},Z=e=>(Array.isArray(e)?e:[]).map(r=>typeof r=="string"?r:r?.value);function x(e){const r=[],i=T(e),h=p=>{const u=new Set;(p||[]).forEach(a=>{const l=D(a),C=a?.type;if(!l&&!Q.has(C)&&r.push({level:"warning",code:"missing-id",message:`A "${C||"field"}" has no id; its value can't be captured.`}),l&&(u.has(l)&&r.push({level:"error",code:"duplicate-id",field:l,message:`Duplicate field id "${l}" among siblings — their values will collide.`}),u.add(l)),a?.dependsOn&&!a?.optionsMap&&r.push({level:"warning",code:"depends-without-options",field:l,message:`"${l}" has \`dependsOn\` but no \`optionsMap\`, so its options never change.`}),a?.optionsMap&&!a?.dependsOn&&r.push({level:"warning",code:"options-without-depends",field:l,message:`"${l}" has \`optionsMap\` but no \`dependsOn\`, so it can't pick a branch.`}),a?.dependsOn&&!i.has(a.dependsOn)&&r.push({level:"error",code:"unknown-depends-target",field:l,message:`"${l}" dependsOn "${a.dependsOn}", which is not a field in this schema.`}),["visibleWhen","disabledWhen","requiredWhen"].forEach(v=>{X(a?.[v]).forEach(A=>{i.has(A)||r.push({level:"error",code:"unknown-rule-field",field:l,message:`"${l}" ${v} references field "${A}", which does not exist.`})})}),(a?.rules?.validation||[]).forEach(v=>{v?.field&&/Field$/.test(v?.rule||"")&&!i.has(v.field)&&r.push({level:"error",code:"unknown-cross-field",field:l,message:`"${l}" rule "${v.rule}" compares against "${v.field}", which does not exist.`})}),Array.isArray(a?.subforms)&&a.subforms.length){const v=Z(a?.props?.options);v.length&&a.subforms.forEach(A=>{A?.conditionValue!==void 0&&!v.includes(A.conditionValue)&&r.push({level:"warning",code:"subform-condition-not-an-option",field:l,message:`"${l}" has a subform for value "${A.conditionValue}", which isn't one of its options.`})}),a.subforms.forEach(A=>h(A?.data||[]))}})};return h(e),r}function ee(e){return e}exports.AIFill=o.AIFill;exports.AIForm=o.AIForm;exports.AIFormGenerator=o.AIFormGenerator;exports.AISchemaReview=o.AISchemaReview;exports.AITextAssist=o.AITextAssist;exports.AIVisionImport=o.AIVisionImport;exports.ClearFormData=o.ClearFormData;exports.Controls=o.Controls_default;exports.DynamicComponent=o.DynamicComponent;exports.FormData=o.FormData;exports.FormGenerator=o.FormGenerator;exports.MuiConfig=o.mui;exports.configureMuiX=o.configureMuiX;exports.createAIClient=o.createAIClient;exports.formFieldsToSimple=o.formFieldsToSimple;exports.getMuiX=o.getMuiX;exports.getRegisteredControl=o.getRegisteredControl;exports.hasRegisteredControl=o.hasRegisteredControl;exports.registerControl=o.registerControl;exports.registerControls=o.registerControls;exports.registeredControlTypes=o.registeredControlTypes;exports.resetMuiX=o.resetMuiX;exports.simpleFieldsToFormFields=o.simpleFieldsToFormFields;exports.slug=o.slug;exports.unregisterControl=o.unregisterControl;exports.useAIAssist=o.useAIAssist;exports.useForm=o.useForm;exports.defineForm=ee;exports.useFormEngine=K;exports.validateSchema=x;exports.yupResolver=H;exports.zodResolver=U;
|
package/dist/dynamic-mui.mjs
CHANGED
|
@@ -1,35 +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
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
|
35
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;
|