dynamic-mui 2.4.1 → 2.5.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 +61 -0
- package/dist/{AIForm-DtRl0WdY.mjs → AIForm-BVJ7qhP5.mjs} +2984 -2778
- package/dist/AIForm-D8_6RVmA.js +44 -0
- package/dist/{accordion-BaiGxDcw.js → accordion-B3fSXKqC.js} +1 -1
- package/dist/{accordion-xg_TxxYS.mjs → accordion-BxTjyh5y.mjs} +1 -1
- package/dist/{addressfield-BvQEHdEk.mjs → addressfield-C9VaV9xw.mjs} +52 -40
- package/dist/addressfield-Cv8zK_sb.js +1 -0
- package/dist/ai/index.cjs +1 -1
- package/dist/ai/index.mjs +1 -1
- package/dist/asyncautocomplete-BveFRqpV.mjs +92 -0
- package/dist/asyncautocomplete-CoOb7mtv.js +1 -0
- package/dist/{bar-DNc7TMKj.mjs → bar-BfMaIpfo.mjs} +1 -1
- package/dist/{bar-BiIzbOC3.js → bar-CE_D8esp.js} +1 -1
- package/dist/cascadeselect-C53hT-C-.mjs +66 -0
- package/dist/cascadeselect-CWECmehh.js +1 -0
- package/dist/collection-Cf87KWZM.js +1 -0
- package/dist/collection-HUYkt74J.mjs +1140 -0
- package/dist/colorpicker-BRQPl_IL.mjs +111 -0
- package/dist/{colorpicker-DpLvK1WR.js → colorpicker-zE3r16Gc.js} +1 -1
- package/dist/components/controls/Collection/CollectionList.d.ts +22 -0
- package/dist/components/controls/Collection/ItemDialog.d.ts +20 -0
- package/dist/components/controls/Collection/collection.d.ts +9 -0
- package/dist/components/controls/Collection/parts.d.ts +39 -0
- package/dist/components/controls/Collection/tree.d.ts +18 -0
- package/dist/components/controls/Collection/ui.d.ts +49 -0
- package/dist/components/controls/index.d.ts +1 -0
- package/dist/{consentfield-B21l9tGo.js → consentfield-CEddOmCa.js} +1 -1
- package/dist/{consentfield-CGT98YbR.mjs → consentfield-Cylid9il.mjs} +13 -11
- package/dist/{datatable-Bv0Q37Zy.js → datatable-3MUZQhnx.js} +1 -1
- package/dist/{datatable-B_6wXh2g.mjs → datatable-BWimO7zD.mjs} +1 -1
- package/dist/dynamic-mui.cjs +1 -1
- package/dist/dynamic-mui.mjs +2 -2
- package/dist/editabletable--ow4E3bB.js +1 -0
- package/dist/{editabletable-YaFqdLvf.mjs → editabletable-CVJ14zrm.mjs} +19 -17
- package/dist/{fileupload--KzSGb5a.js → fileupload-B7f6VOb0.js} +1 -1
- package/dist/{fileupload-ZBi72f1R.mjs → fileupload-DHiYLdJ5.mjs} +16 -3
- package/dist/{formrepeater-Cwgtvz1c.mjs → formrepeater-BGZGTcVb.mjs} +25 -21
- package/dist/{formrepeater-BhUEa4BI.js → formrepeater-CvWeLug8.js} +1 -1
- package/dist/{formwizard-CYcgf5jL.mjs → formwizard-BeJK5mqc.mjs} +1 -1
- package/dist/{formwizard-BlozHDc_.js → formwizard-DrHKFPfN.js} +1 -1
- package/dist/{geofield-xqZy_DAY.mjs → geofield-Bchfb6__.mjs} +28 -24
- package/dist/geofield-thoXisie.js +1 -0
- package/dist/{group-Dtju1rHQ.js → group-B3QBe0YI.js} +1 -1
- package/dist/{group-DmLN-b09.mjs → group-DUnv46e_.mjs} +1 -1
- package/dist/{intlphone-CXUQP9Gp.mjs → intlphone-BY59PVDg.mjs} +12 -8
- package/dist/{intlphone-BeHXAcFi.js → intlphone-CMXEolsT.js} +1 -1
- package/dist/{keyvaluefield-BJoEbe4I.mjs → keyvaluefield-BAYbTkCY.mjs} +4 -2
- package/dist/{keyvaluefield-BZQDG0l5.js → keyvaluefield-FBaHQ8Ak.js} +1 -1
- package/dist/{line-tIm99vYW.js → line-Bk15u06y.js} +1 -1
- package/dist/{line-B3CAbZOo.mjs → line-Bzbkzk7f.mjs} +1 -1
- package/dist/lineitemlist-8NL2THwe.js +1 -0
- package/dist/{lineitemlist-CBSqoC9g.mjs → lineitemlist-PsoQ4LU4.mjs} +23 -19
- package/dist/{list-C8QMpJOJ.mjs → list-BGzVPlgh.mjs} +1 -1
- package/dist/{list-D_cawpPI.js → list-BmGiSIoi.js} +1 -1
- package/dist/locationfield-BG76gNbD.js +1 -0
- package/dist/locationfield-CupDmXsM.mjs +118 -0
- package/dist/{markdowneditor-DFOgRmdL.mjs → markdowneditor-4StkbrKV.mjs} +15 -11
- package/dist/markdowneditor-vDHguMtU.js +2 -0
- package/dist/{matrixfield-0lnuaEks.mjs → matrixfield-CeROIIAj.mjs} +34 -30
- package/dist/{matrixfield-nWt6Cug5.js → matrixfield-Vptf0zNH.js} +1 -1
- package/dist/{mixChart-ISf3Kbr-.mjs → mixChart-Doq4lt7Z.mjs} +2 -2
- package/dist/mixChart-rgyMCdnp.js +1 -0
- package/dist/{multitextbox-DmAWV163.mjs → multitextbox-DeVv6uzi.mjs} +1 -1
- package/dist/{multitextbox-oEgl2F8-.js → multitextbox-DtSydHcv.js} +1 -1
- package/dist/{npsscale-CdTEwERY.mjs → npsscale-Cd7PoCJS.mjs} +7 -3
- package/dist/{npsscale-DW4sxcLz.js → npsscale-Dwp2T0DQ.js} +1 -1
- package/dist/{numberstepper-BwQ5coLc.mjs → numberstepper-BFNTu3Ii.mjs} +6 -2
- package/dist/{numberstepper-cDosevJb.js → numberstepper-DBKq7hUm.js} +1 -1
- package/dist/{pie-gAfuDR1F.js → pie-CE4QV82D.js} +1 -1
- package/dist/{pie-CBRckgd4.mjs → pie-DKRRH37e.mjs} +1 -1
- package/dist/richtexteditor-B6lK2iIt.js +1 -0
- package/dist/{richtexteditor-xrbv8PXZ.mjs → richtexteditor-DdIfi0-T.mjs} +4 -2
- package/dist/schema.d.ts +10 -2
- package/dist/{signature-FM6L60nk.js → signature-B_drsWTj.js} +2 -2
- package/dist/{signature-CP_lA_Yh.mjs → signature-D9B8bFqg.mjs} +4 -2
- package/dist/{stepper-CjGNFyBz.js → stepper-CO6XiIaw.js} +1 -1
- package/dist/{stepper-BprezTzX.mjs → stepper-D6e9yWIr.mjs} +1 -1
- package/dist/{summaryfield-5mJRwVZ4.mjs → summaryfield-BIA2gc1w.mjs} +1 -1
- package/dist/{summaryfield-C3xmqZQp.js → summaryfield-CR3aNMZU.js} +1 -1
- package/dist/{tabs-B4P59kHX.js → tabs-B4ZbZQvt.js} +1 -1
- package/dist/{tabs-By-Mm8vm.mjs → tabs-PgOpdVX1.mjs} +1 -1
- package/dist/tagsinput-DtNb1IuV.js +1 -0
- package/dist/tagsinput-G_M0DbpI.mjs +58 -0
- package/dist/types.d.ts +188 -0
- package/dist/util/collection.d.ts +82 -0
- package/package.json +11 -11
- package/dist/AIForm-Dv8ahXyE.js +0 -43
- package/dist/addressfield-vVizrbZP.js +0 -1
- package/dist/asyncautocomplete-AmSRs7PY.mjs +0 -89
- package/dist/asyncautocomplete-Dtmxh4l1.js +0 -1
- package/dist/cascadeselect-BlznIKS6.mjs +0 -64
- package/dist/cascadeselect-DqLtG-W9.js +0 -1
- package/dist/colorpicker-hP3b7teC.mjs +0 -98
- package/dist/editabletable-D3c3DJxX.js +0 -1
- package/dist/geofield-BynrTSVm.js +0 -1
- package/dist/lineitemlist-RqStjYB-.js +0 -1
- package/dist/locationfield-BiLy-c09.js +0 -1
- package/dist/locationfield-KBbu-98L.mjs +0 -119
- package/dist/markdowneditor-Dy7Q01FM.js +0 -2
- package/dist/mixChart-C3o184UT.js +0 -1
- package/dist/richtexteditor-DI-h5Efn.js +0 -1
- package/dist/tagsinput-BwM3NYK_.js +0 -1
- package/dist/tagsinput-Ce4EWy4i.mjs +0 -58
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { jsxs as m, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import $ from "react";
|
|
3
|
+
import c from "@mui/material/Box";
|
|
4
|
+
import u from "@mui/material/Stack";
|
|
5
|
+
import A from "@mui/material/TextField";
|
|
6
|
+
import I from "@mui/material/FormControl";
|
|
7
|
+
import F from "@mui/material/FormLabel";
|
|
8
|
+
import { alpha as l } from "@mui/material/styles";
|
|
9
|
+
import { j as R, m as x, k as j } from "./AIForm-BVJ7qhP5.mjs";
|
|
10
|
+
const h = "#000000";
|
|
11
|
+
function q({ attributes: t = {}, rules: f = {}, onChange: b }) {
|
|
12
|
+
const { id: p = "", label: r, presets: n = [], MuiAttributes: g = {} } = t, { sx: w, ...v } = g, [a, d] = $.useState(
|
|
13
|
+
t.value || h
|
|
14
|
+
);
|
|
15
|
+
R(() => {
|
|
16
|
+
d(t.value || h);
|
|
17
|
+
}, [t.value]);
|
|
18
|
+
const y = f?.validation?.some(
|
|
19
|
+
(o) => o.rule === "mandatory" || o.rule === "mandatoryselect"
|
|
20
|
+
) || !1, s = (o) => {
|
|
21
|
+
d(o), b?.({ id: p, value: o });
|
|
22
|
+
}, k = (o) => {
|
|
23
|
+
s(o.target.value);
|
|
24
|
+
}, C = (o) => {
|
|
25
|
+
s(o.target.value);
|
|
26
|
+
}, S = (o) => {
|
|
27
|
+
s(o);
|
|
28
|
+
};
|
|
29
|
+
return /* @__PURE__ */ m(I, { required: y, component: "fieldset", fullWidth: !0, children: [
|
|
30
|
+
r && /* @__PURE__ */ e(F, { component: "legend", children: r }),
|
|
31
|
+
/* @__PURE__ */ m(
|
|
32
|
+
u,
|
|
33
|
+
{
|
|
34
|
+
direction: "row",
|
|
35
|
+
spacing: 1.5,
|
|
36
|
+
sx: {
|
|
37
|
+
alignItems: "center",
|
|
38
|
+
mt: r ? 1 : 0
|
|
39
|
+
},
|
|
40
|
+
children: [
|
|
41
|
+
/* @__PURE__ */ e(c, { sx: { ...{
|
|
42
|
+
width: 44,
|
|
43
|
+
height: 44,
|
|
44
|
+
borderRadius: "10px",
|
|
45
|
+
border: (o) => `1px solid ${l(o.palette.text.primary, 0.2)}`,
|
|
46
|
+
boxShadow: (o) => `0 2px 8px ${l(o.palette.common.black, 0.12)}`,
|
|
47
|
+
cursor: "pointer",
|
|
48
|
+
flexShrink: 0,
|
|
49
|
+
position: "relative",
|
|
50
|
+
overflow: "hidden"
|
|
51
|
+
}, backgroundColor: a }, children: /* @__PURE__ */ e(
|
|
52
|
+
"input",
|
|
53
|
+
{
|
|
54
|
+
type: "color",
|
|
55
|
+
"aria-label": r ? `${r} colour` : "colour",
|
|
56
|
+
value: a,
|
|
57
|
+
onChange: k,
|
|
58
|
+
...v,
|
|
59
|
+
style: {
|
|
60
|
+
position: "absolute",
|
|
61
|
+
inset: 0,
|
|
62
|
+
width: "100%",
|
|
63
|
+
height: "100%",
|
|
64
|
+
opacity: 0,
|
|
65
|
+
border: "none",
|
|
66
|
+
padding: 0,
|
|
67
|
+
cursor: "pointer"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
) }),
|
|
71
|
+
/* @__PURE__ */ e(
|
|
72
|
+
A,
|
|
73
|
+
{
|
|
74
|
+
id: p || void 0,
|
|
75
|
+
value: a,
|
|
76
|
+
onChange: C,
|
|
77
|
+
size: "small",
|
|
78
|
+
label: "Hex",
|
|
79
|
+
sx: x(j, x({ maxWidth: 160 }, w)),
|
|
80
|
+
slotProps: {
|
|
81
|
+
htmlInput: { "aria-label": "hex value" }
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
)
|
|
85
|
+
]
|
|
86
|
+
}
|
|
87
|
+
),
|
|
88
|
+
Array.isArray(n) && n.length > 0 && /* @__PURE__ */ e(u, { direction: "row", spacing: 1, sx: { mt: 1.5, flexWrap: "wrap", rowGap: 1 }, children: n.map((o) => /* @__PURE__ */ e(
|
|
89
|
+
c,
|
|
90
|
+
{
|
|
91
|
+
role: "button",
|
|
92
|
+
"aria-label": `preset ${o}`,
|
|
93
|
+
onClick: () => S(o),
|
|
94
|
+
sx: {
|
|
95
|
+
width: 26,
|
|
96
|
+
height: 26,
|
|
97
|
+
borderRadius: "8px",
|
|
98
|
+
backgroundColor: o,
|
|
99
|
+
cursor: "pointer",
|
|
100
|
+
flexShrink: 0,
|
|
101
|
+
border: (i) => a === o ? `2px solid ${i.palette.primary.main}` : `1px solid ${l(i.palette.text.primary, 0.2)}`,
|
|
102
|
+
boxShadow: (i) => `0 1px 4px ${l(i.palette.common.black, 0.12)}`
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
o
|
|
106
|
+
)) })
|
|
107
|
+
] });
|
|
108
|
+
}
|
|
109
|
+
export {
|
|
110
|
+
q as default
|
|
111
|
+
};
|
|
@@ -1 +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"),
|
|
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"),i=require("@mui/material/styles"),n=require("./AIForm-D8_6RVmA.js"),h="#000000";function I({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 ${i.alpha(e.palette.text.primary,.2)}`,boxShadow:e=>`0 2px 8px ${i.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,sx:{alignItems:"center",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",sx:n.mergeSx(n.premiumInputSx,n.mergeSx({maxWidth:160},y)),slotProps:{htmlInput:{"aria-label":"hex value"}}})]}),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:l=>a===e?`2px solid ${l.palette.primary.main}`:`1px solid ${i.alpha(l.palette.text.primary,.2)}`,boxShadow:l=>`0 1px 4px ${i.alpha(l.palette.common.black,.12)}`}},e))})]})}exports.default=I;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { CollectionConfig, CollectionTexts } from '../../../types';
|
|
2
|
+
import { CollectionIssue } from '../../../util/collection';
|
|
3
|
+
import { CollectionNode } from './tree';
|
|
4
|
+
export interface CollectionListProps {
|
|
5
|
+
config: CollectionConfig;
|
|
6
|
+
nodes: CollectionNode[];
|
|
7
|
+
onChange: (next: CollectionNode[]) => void;
|
|
8
|
+
/** Unique prefix for this level's dialog form store. */
|
|
9
|
+
guid: string;
|
|
10
|
+
depth?: number;
|
|
11
|
+
readOnly?: boolean;
|
|
12
|
+
/** Issues for this list, with paths relative to it. */
|
|
13
|
+
issues?: CollectionIssue[];
|
|
14
|
+
showErrors?: boolean;
|
|
15
|
+
/** Mark the heading as required. */
|
|
16
|
+
required?: boolean;
|
|
17
|
+
/** Title of the owning item, shown as context in the dialog. */
|
|
18
|
+
parentTitle?: string;
|
|
19
|
+
/** Texts inherited from the parent level. */
|
|
20
|
+
texts?: CollectionTexts;
|
|
21
|
+
}
|
|
22
|
+
export default function CollectionList({ config, nodes, onChange, guid, depth, readOnly, issues, showErrors, required, parentTitle, texts: inheritedTexts, }: CollectionListProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { CollectionUi } from './ui';
|
|
2
|
+
export type ItemDialogMode = 'add' | 'edit' | 'view';
|
|
3
|
+
interface ItemDialogProps {
|
|
4
|
+
ui: CollectionUi;
|
|
5
|
+
open: boolean;
|
|
6
|
+
mode: ItemDialogMode;
|
|
7
|
+
/** Unique per collection level; the inner form's store key derives from it. */
|
|
8
|
+
guid: string;
|
|
9
|
+
/** Changes on every open so the inner form always remounts fresh. */
|
|
10
|
+
session: number;
|
|
11
|
+
initial?: Record<string, any>;
|
|
12
|
+
/** Title of the parent item this one belongs to ("Acme Corp"). */
|
|
13
|
+
context?: string;
|
|
14
|
+
onClose: () => void;
|
|
15
|
+
onSave: (values: Record<string, any>, keepOpen: boolean) => void;
|
|
16
|
+
}
|
|
17
|
+
/** Add / edit / view dialog for one collection item, hosting a FormGenerator.
|
|
18
|
+
* Every part is styled through the level's `styles` (dialog* slots). */
|
|
19
|
+
export default function ItemDialog({ ui, open, mode, guid, session, initial, context, onClose, onSave }: ItemDialogProps): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ControlProps } from '../../../types';
|
|
2
|
+
/**
|
|
3
|
+
* `collection` — a nested, dialog-edited list. Each item is added/edited in a
|
|
4
|
+
* modal form and shown as a card; items can own nested collections (e.g.
|
|
5
|
+
* Customer Locations → Services + Backflow devices) to any depth.
|
|
6
|
+
*
|
|
7
|
+
* Value: `[{ ...fields, [child.id]: [{ ...childFields, ... }] }]`.
|
|
8
|
+
*/
|
|
9
|
+
export default function Collection({ attributes, rules, onChange, submitTick }: ControlProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { CollectionColor } from '../../../types';
|
|
2
|
+
import { ItemDetail } from '../../../util/collection';
|
|
3
|
+
import { CollectionUi } from './ui';
|
|
4
|
+
export declare const EASE = "cubic-bezier(0.4, 0, 0.2, 1)";
|
|
5
|
+
export declare function CountPill({ ui, n }: {
|
|
6
|
+
ui: CollectionUi;
|
|
7
|
+
n: number;
|
|
8
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
/** Optional leading avatar on cards (`display.avatar`; none by default). */
|
|
10
|
+
export declare function ItemAvatar({ ui, mode, title, index }: {
|
|
11
|
+
ui: CollectionUi;
|
|
12
|
+
mode: string;
|
|
13
|
+
title: string;
|
|
14
|
+
index: number;
|
|
15
|
+
}): import("react/jsx-runtime").JSX.Element | null;
|
|
16
|
+
export declare function StatusBadge({ ui, text, color }: {
|
|
17
|
+
ui: CollectionUi;
|
|
18
|
+
text: string;
|
|
19
|
+
color: CollectionColor | 'default';
|
|
20
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
/** An item's facts: a small icon in front of the label, the value underneath. */
|
|
22
|
+
export declare function Details({ ui, details }: {
|
|
23
|
+
ui: CollectionUi;
|
|
24
|
+
details: ItemDetail[];
|
|
25
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
/** The add action of a level ("+ Add Service"). */
|
|
27
|
+
export declare function AddButton({ ui, placement, empty, disabled, onClick }: {
|
|
28
|
+
ui: CollectionUi;
|
|
29
|
+
placement: 'header' | 'footer';
|
|
30
|
+
empty: boolean;
|
|
31
|
+
disabled: boolean;
|
|
32
|
+
onClick: () => void;
|
|
33
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
34
|
+
/** Shown when a level has no items yet. The add button stays the one action. */
|
|
35
|
+
export declare function EmptyState({ ui, readOnly, error }: {
|
|
36
|
+
ui: CollectionUi;
|
|
37
|
+
readOnly: boolean;
|
|
38
|
+
error: boolean;
|
|
39
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CollectionConfig } from '../../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Internal representation of a collection value. Each item carries a stable
|
|
4
|
+
* `key` (React identity across edits, moves and duplicates) and keeps its own
|
|
5
|
+
* field values apart from its nested lists. The consumer only ever sees the
|
|
6
|
+
* plain JSON produced by `toValue`.
|
|
7
|
+
*/
|
|
8
|
+
export interface CollectionNode {
|
|
9
|
+
key: string;
|
|
10
|
+
data: Record<string, any>;
|
|
11
|
+
children: Record<string, CollectionNode[]>;
|
|
12
|
+
}
|
|
13
|
+
export declare const nextKey: () => string;
|
|
14
|
+
export declare const emptyChildren: (config: Partial<CollectionConfig>) => Record<string, CollectionNode[]>;
|
|
15
|
+
export declare const toNodes: (value: any, config: Partial<CollectionConfig>) => CollectionNode[];
|
|
16
|
+
export declare const toValue: (nodes: CollectionNode[], config: Partial<CollectionConfig>) => Record<string, any>[];
|
|
17
|
+
/** Deep copy with fresh keys at every level (for "Duplicate"). */
|
|
18
|
+
export declare const cloneNode: (node: CollectionNode) => CollectionNode;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { SxProps, Theme } from '@mui/material/styles';
|
|
2
|
+
import { CollectionActions, CollectionAddButton, CollectionColumns, CollectionConfig, CollectionSlot, CollectionTexts } from '../../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Resolves one collection level's JSON into everything its UI needs: accent
|
|
5
|
+
* colours, wording, behaviour defaults, and `sx(slot, base)` — the built-in
|
|
6
|
+
* style of a part with the JSON `styles[slot]` override layered on top. Every
|
|
7
|
+
* visual and textual detail therefore comes from (or can be replaced by) JSON.
|
|
8
|
+
*/
|
|
9
|
+
export type Accent = {
|
|
10
|
+
main: string;
|
|
11
|
+
light: string;
|
|
12
|
+
dark: string;
|
|
13
|
+
contrastText: string;
|
|
14
|
+
};
|
|
15
|
+
/** Palette colour by name, or any CSS colour expanded into light/dark shades. */
|
|
16
|
+
export declare const accentOf: (theme: Theme, color?: string) => Accent;
|
|
17
|
+
/** Readable accent text on a tinted background, in light and dark mode. */
|
|
18
|
+
export declare const inkOf: (theme: Theme, accent: Accent) => string;
|
|
19
|
+
export declare const DEFAULT_TEXTS: Required<Omit<CollectionTexts, 'emptyText'>> & {
|
|
20
|
+
emptyText?: string;
|
|
21
|
+
};
|
|
22
|
+
/** Fill `{name}` placeholders; unknown ones are left as-is. */
|
|
23
|
+
export declare const fmt: (template: string, vars: Record<string, string | number | undefined>) => string;
|
|
24
|
+
/** MUI `sx` for a responsive grid with `columns` (or auto-fill at `minWidth`). */
|
|
25
|
+
export declare const gridColumns: (columns: CollectionColumns | undefined, minWidth: number) => string | {
|
|
26
|
+
[k: string]: string;
|
|
27
|
+
};
|
|
28
|
+
export interface CollectionUi {
|
|
29
|
+
config: CollectionConfig;
|
|
30
|
+
depth: number;
|
|
31
|
+
nested: boolean;
|
|
32
|
+
accent: Accent;
|
|
33
|
+
ink: string;
|
|
34
|
+
icon: string;
|
|
35
|
+
itemLabel: string;
|
|
36
|
+
plural: string;
|
|
37
|
+
texts: CollectionTexts;
|
|
38
|
+
layout: 'cards' | 'table';
|
|
39
|
+
variant: 'card' | 'outlined' | 'flat';
|
|
40
|
+
addButton: Required<Omit<CollectionAddButton, 'size' | 'fullWidth'>> & Pick<CollectionAddButton, 'size' | 'fullWidth'>;
|
|
41
|
+
actions: Required<CollectionActions>;
|
|
42
|
+
/** Text for `key` with this level's placeholders (+ `vars`) filled in. */
|
|
43
|
+
t: (key: keyof CollectionTexts, vars?: Record<string, string | number | undefined>) => string;
|
|
44
|
+
/** Built-in style for `slot` with the JSON override merged on top. */
|
|
45
|
+
sx: (slot: CollectionSlot, base?: SxProps<Theme>) => SxProps<Theme>;
|
|
46
|
+
/** Same as `sx`, deep-merged into ONE object (for nested selectors, which can't take arrays). */
|
|
47
|
+
merged: (slot: CollectionSlot, base?: Record<string, any>) => Record<string, any>;
|
|
48
|
+
}
|
|
49
|
+
export declare const resolveUi: (theme: Theme, config: CollectionConfig, depth: number, inheritedTexts?: CollectionTexts) => CollectionUi;
|
|
@@ -77,6 +77,7 @@ declare const Controls: {
|
|
|
77
77
|
MultiTextbox: import('react').LazyExoticComponent<typeof import('./MultiTextbox/multitextbox').default>;
|
|
78
78
|
LineItemList: import('react').LazyExoticComponent<typeof import('./LineItemList/lineitemlist').default>;
|
|
79
79
|
FormRepeater: import('react').LazyExoticComponent<typeof import('./FormRepeater/formrepeater').default>;
|
|
80
|
+
Collection: import('react').LazyExoticComponent<typeof import('./Collection/collection').default>;
|
|
80
81
|
Signature: import('react').LazyExoticComponent<typeof import('./Signature/signature').default>;
|
|
81
82
|
Group: import('react').LazyExoticComponent<typeof import('./Group/group').default>;
|
|
82
83
|
Accordion: import('react').LazyExoticComponent<typeof import('./Accordion/accordion').default>;
|
|
@@ -1 +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-
|
|
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-D8_6RVmA.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,slotProps:{input:{"aria-label":"consent-agree"}}})}),m&&t.jsx(I,{children:m})]})}exports.default=V;
|
|
@@ -6,21 +6,21 @@ 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 { j as P, m as f, l as U, n as W } from "./AIForm-
|
|
10
|
-
function Z({ attributes:
|
|
9
|
+
import { j as P, m as f, l as U, n as W } from "./AIForm-BVJ7qhP5.mjs";
|
|
10
|
+
function Z({ attributes: l = {}, rules: n = {}, onChange: h }) {
|
|
11
11
|
const {
|
|
12
12
|
MuiAttributes: g = {},
|
|
13
13
|
id: x = "",
|
|
14
14
|
text: S = "",
|
|
15
15
|
label: c = "I agree to the terms",
|
|
16
16
|
requireScroll: i = !0
|
|
17
|
-
} =
|
|
17
|
+
} = l, [C, d] = s.useState(!!l.value), [b, v] = s.useState(!i), [k, T] = s.useState(!1), [m, y] = s.useState("");
|
|
18
18
|
P(() => {
|
|
19
|
-
d(!!
|
|
20
|
-
}, [
|
|
21
|
-
const
|
|
19
|
+
d(!!l.value);
|
|
20
|
+
}, [l.value]);
|
|
21
|
+
const a = n?.validation?.some((e) => e.rule === "mandatory" || e.rule === "mandatoryselect") || !1, H = (e) => {
|
|
22
22
|
let r = !0, t = "";
|
|
23
|
-
return
|
|
23
|
+
return a && !e && (r = !1, t = n?.validation?.find(
|
|
24
24
|
(u) => u.rule === "mandatory" || u.rule === "mandatoryselect"
|
|
25
25
|
)?.message || "Required"), { isValid: r, message: t };
|
|
26
26
|
}, q = (e) => {
|
|
@@ -31,11 +31,11 @@ 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 && !b, { sx: L, ...j } = g, w =
|
|
34
|
+
}, F = i && !b, { sx: L, ...j } = g, w = a ? /* @__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
|
-
return /* @__PURE__ */ p(V, { required:
|
|
38
|
+
return /* @__PURE__ */ p(V, { required: a, error: k, component: "fieldset", fullWidth: !0, children: [
|
|
39
39
|
/* @__PURE__ */ o(
|
|
40
40
|
M,
|
|
41
41
|
{
|
|
@@ -64,8 +64,10 @@ function Z({ attributes: a = {}, rules: n = {}, onChange: h }) {
|
|
|
64
64
|
checked: C,
|
|
65
65
|
disabled: F,
|
|
66
66
|
onChange: E,
|
|
67
|
-
required:
|
|
68
|
-
|
|
67
|
+
required: a,
|
|
68
|
+
slotProps: {
|
|
69
|
+
input: { "aria-label": "consent-agree" }
|
|
70
|
+
}
|
|
69
71
|
}
|
|
70
72
|
)
|
|
71
73
|
}
|
|
@@ -1 +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-
|
|
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-D8_6RVmA.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;
|
|
@@ -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 { i as l } from "./AIForm-
|
|
5
|
+
import { i as l } from "./AIForm-BVJ7qhP5.mjs";
|
|
6
6
|
const m = e.lazy(
|
|
7
7
|
() => import("@mui/x-data-grid").then((r) => ({ default: r.DataGrid }))
|
|
8
8
|
);
|
package/dist/dynamic-mui.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./AIForm-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./AIForm-D8_6RVmA.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,5 +1,5 @@
|
|
|
1
|
-
import { y as I, z as k, B as Q, V as U, D as Z } from "./AIForm-
|
|
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-
|
|
1
|
+
import { y as I, z as k, B as Q, V as U, D as Z } from "./AIForm-BVJ7qhP5.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-BVJ7qhP5.mjs";
|
|
3
3
|
import { useMemo as V, useState as T, useRef as x, useCallback as A } from "react";
|
|
4
4
|
function te(e) {
|
|
5
5
|
return (n) => {
|
|
@@ -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"),I=require("@mui/material/TableContainer"),z=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-D8_6RVmA.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,t,n)=>{const s=l.map((b,T)=>T===r?{...b,[t]:n}:b);i(s),u(s)},A=()=>{const r=[...l,{}];i(r),u(r)},R=r=>{const t=l.filter((n,s)=>s!==r);i(t),u(t)};return e.jsxs(M,{component:"fieldset",fullWidth:!0,children:[m&&e.jsx(P,{component:"legend",sx:{mb:1},children:m}),e.jsx(I,{component:$,variant:"outlined",sx:{borderRadius:2,overflow:"hidden"},children:e.jsxs(w,{size:"small",children:[e.jsx(z,{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,t)=>e.jsxs(j,{sx:{transition:"background-color 150ms cubic-bezier(0.4, 0, 0.2, 1)","&:hover":{backgroundColor:"action.hover"}},children:[h.map(n=>e.jsx(a,{children:e.jsx(F,{...y,type:n.type==="number"?"number":"text",value:r[n.key]??"",onChange:s=>C(t,n.key,s.target.value),size:"small",variant:"standard",fullWidth:!0,sx:d.mergeSx(d.premiumInputSx,v),slotProps:{htmlInput:{"aria-label":`${n.label} row ${t+1}`}}})},n.key)),e.jsx(a,{align:"right",children:e.jsx(W,{"aria-label":`Remove row ${t+1}`,onClick:()=>R(t),size:"small",sx:{borderRadius:2,color:"text.secondary","&:hover":{color:"error.main"}},children:e.jsx(L,{fontSize:"small"})})})]},t))})]})}),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;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsxs as m, jsx as e } from "react/jsx-runtime";
|
|
2
2
|
import z from "react";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
3
|
+
import I from "@mui/material/Table";
|
|
4
|
+
import S from "@mui/material/TableBody";
|
|
5
5
|
import s from "@mui/material/TableCell";
|
|
6
6
|
import W from "@mui/material/TableContainer";
|
|
7
7
|
import j from "@mui/material/TableHead";
|
|
@@ -14,31 +14,31 @@ 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 { j as U, m as _, k as q } from "./AIForm-
|
|
17
|
+
import { j as U, m as _, k as q } from "./AIForm-BVJ7qhP5.mjs";
|
|
18
18
|
function x(n) {
|
|
19
19
|
return Array.isArray(n) ? n.map((d) => ({ ...d || {} })) : [];
|
|
20
20
|
}
|
|
21
|
-
function
|
|
21
|
+
function ar({ attributes: n = {}, onChange: d }) {
|
|
22
22
|
const {
|
|
23
23
|
MuiAttributes: g = {},
|
|
24
24
|
id: v = "",
|
|
25
25
|
columns: p = [],
|
|
26
26
|
addLabel: y = "Add row",
|
|
27
27
|
label: u
|
|
28
|
-
} = n, { sx: C, ...k } = g, f = Array.isArray(p) ? p : [], [
|
|
28
|
+
} = n, { sx: C, ...k } = g, f = Array.isArray(p) ? p : [], [a, i] = z.useState(() => x(n.value));
|
|
29
29
|
U(() => {
|
|
30
30
|
i(x(n.value));
|
|
31
31
|
}, [n.value]);
|
|
32
32
|
const c = (r) => {
|
|
33
33
|
d?.({ id: v, value: r });
|
|
34
34
|
}, w = (r, o, t) => {
|
|
35
|
-
const
|
|
36
|
-
i(
|
|
35
|
+
const l = a.map((h, T) => T === r ? { ...h, [o]: t } : h);
|
|
36
|
+
i(l), c(l);
|
|
37
37
|
}, A = () => {
|
|
38
|
-
const r = [...
|
|
38
|
+
const r = [...a, {}];
|
|
39
39
|
i(r), c(r);
|
|
40
40
|
}, R = (r) => {
|
|
41
|
-
const o =
|
|
41
|
+
const o = a.filter((t, l) => l !== r);
|
|
42
42
|
i(o), c(o);
|
|
43
43
|
};
|
|
44
44
|
return /* @__PURE__ */ m(E, { component: "fieldset", fullWidth: !0, children: [
|
|
@@ -52,12 +52,12 @@ function lr({ attributes: n = {}, onChange: d }) {
|
|
|
52
52
|
borderRadius: 2,
|
|
53
53
|
overflow: "hidden"
|
|
54
54
|
},
|
|
55
|
-
children: /* @__PURE__ */ m(
|
|
55
|
+
children: /* @__PURE__ */ m(I, { size: "small", children: [
|
|
56
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
|
] }) }),
|
|
60
|
-
/* @__PURE__ */ e(
|
|
60
|
+
/* @__PURE__ */ e(S, { children: a.map((r, o) => /* @__PURE__ */ m(
|
|
61
61
|
b,
|
|
62
62
|
{
|
|
63
63
|
sx: {
|
|
@@ -71,14 +71,16 @@ function lr({ attributes: n = {}, onChange: d }) {
|
|
|
71
71
|
...k,
|
|
72
72
|
type: t.type === "number" ? "number" : "text",
|
|
73
73
|
value: r[t.key] ?? "",
|
|
74
|
-
onChange: (
|
|
75
|
-
inputProps: {
|
|
76
|
-
"aria-label": `${t.label} row ${o + 1}`
|
|
77
|
-
},
|
|
74
|
+
onChange: (l) => w(o, t.key, l.target.value),
|
|
78
75
|
size: "small",
|
|
79
76
|
variant: "standard",
|
|
80
77
|
fullWidth: !0,
|
|
81
|
-
sx: _(q, C)
|
|
78
|
+
sx: _(q, C),
|
|
79
|
+
slotProps: {
|
|
80
|
+
htmlInput: {
|
|
81
|
+
"aria-label": `${t.label} row ${o + 1}`
|
|
82
|
+
}
|
|
83
|
+
}
|
|
82
84
|
}
|
|
83
85
|
) }, t.key)),
|
|
84
86
|
/* @__PURE__ */ e(s, { align: "right", children: /* @__PURE__ */ e(
|
|
@@ -122,5 +124,5 @@ function lr({ attributes: n = {}, onChange: d }) {
|
|
|
122
124
|
] });
|
|
123
125
|
}
|
|
124
126
|
export {
|
|
125
|
-
|
|
127
|
+
ar as default
|
|
126
128
|
};
|
|
@@ -1 +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-
|
|
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-D8_6RVmA.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",sx:{color:"text.secondary"},children:["Accepted: ",g]})]}),q&&r.jsx(c,{variant:"caption",sx:{color:"error.main",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 { j as Q, m as V, l as W } from "./AIForm-
|
|
10
|
+
import { j as Q, m as V, l as W } from "./AIForm-BVJ7qhP5.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();
|
|
@@ -106,14 +106,27 @@ function de({ attributes: r = {}, rules: u = {}, onChange: g }) {
|
|
|
106
106
|
p ? "files" : "a file",
|
|
107
107
|
" here, or click to browse"
|
|
108
108
|
] }),
|
|
109
|
-
h && /* @__PURE__ */ l(c, { variant: "caption",
|
|
109
|
+
h && /* @__PURE__ */ l(c, { variant: "caption", sx: {
|
|
110
|
+
color: "text.secondary"
|
|
111
|
+
}, children: [
|
|
110
112
|
"Accepted: ",
|
|
111
113
|
h
|
|
112
114
|
] })
|
|
113
115
|
]
|
|
114
116
|
}
|
|
115
117
|
),
|
|
116
|
-
k && /* @__PURE__ */ t(
|
|
118
|
+
k && /* @__PURE__ */ t(
|
|
119
|
+
c,
|
|
120
|
+
{
|
|
121
|
+
variant: "caption",
|
|
122
|
+
sx: {
|
|
123
|
+
color: "error.main",
|
|
124
|
+
display: "block",
|
|
125
|
+
mt: 1
|
|
126
|
+
},
|
|
127
|
+
children: k
|
|
128
|
+
}
|
|
129
|
+
),
|
|
117
130
|
d.length > 0 && /* @__PURE__ */ t(s, { sx: V(W, { mt: 1.5, p: 1 }), children: d.map((e, o) => /* @__PURE__ */ l(
|
|
118
131
|
s,
|
|
119
132
|
{
|