dynamic-mui 2.0.26 → 2.2.0
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 +218 -37
- package/dist/AxisSharedComponents-BbsKw1BT.js +3 -0
- package/dist/AxisSharedComponents-xLtpOLH_.mjs +605 -0
- package/dist/ChartsAxis-CANvBdY9.mjs +47 -0
- package/dist/ChartsAxis-EZ7m_KrU.js +1 -0
- package/dist/ChartsGrid-BCRTvNTr.js +3 -0
- package/dist/ChartsGrid-C_HT7qpL.mjs +381 -0
- package/dist/ChartsWrapper-CM7EDyAK.js +5 -0
- package/dist/ChartsWrapper-CO5_Z6BD.mjs +1878 -0
- package/dist/ChartsXAxis-CPmuCRhq.mjs +487 -0
- package/dist/ChartsXAxis-DFFY1sPg.js +3 -0
- package/dist/ChartsYAxis-DLUMr9vG.mjs +392 -0
- package/dist/ChartsYAxis-fpevi1sP.js +1 -0
- package/dist/XmlShapeDeserializer-3yQdm0b0.mjs +237 -0
- package/dist/XmlShapeDeserializer-XKJAoqLc.js +1 -0
- package/dist/ai/client.d.ts +2 -0
- package/dist/ai/index.d.ts +4 -0
- package/dist/ai/mapping.d.ts +14 -0
- package/dist/ai/react/AIFill.d.ts +25 -0
- package/dist/ai/react/AIForm.d.ts +29 -0
- package/dist/ai/react/AIFormGenerator.d.ts +20 -0
- package/dist/ai/react/AISchemaReview.d.ts +18 -0
- package/dist/ai/react/AITextAssist.d.ts +35 -0
- package/dist/ai/react/AIVisionImport.d.ts +21 -0
- package/dist/ai/react/index.d.ts +6 -0
- package/dist/ai/types.d.ts +107 -0
- package/dist/clampAngle-BvZjnf53.mjs +11 -0
- package/dist/clampAngle-DpAsDoeT.js +1 -0
- package/dist/components/FormGenerator.d.ts +46 -1
- package/dist/components/controls/AddressField/addressfield.d.ts +2 -0
- package/dist/components/controls/Alert/alert.d.ts +3 -0
- package/dist/components/controls/AsyncAutocomplete/asyncautocomplete.d.ts +9 -0
- package/dist/components/controls/Button/button.d.ts +3 -0
- package/dist/components/controls/CascadeSelect/cascadeselect.d.ts +2 -0
- package/dist/components/controls/CheckBox/checkbox.d.ts +1 -1
- package/dist/components/controls/ChipSelect/chipselect.d.ts +3 -0
- package/dist/components/controls/ColorPicker/colorpicker.d.ts +3 -0
- package/dist/components/controls/Computed/computed.d.ts +7 -0
- package/dist/components/controls/ConsentField/consentfield.d.ts +3 -0
- package/dist/components/controls/CurrencyField/currencyfield.d.ts +2 -0
- package/dist/components/controls/DateRangePicker/daterangepicker.d.ts +3 -0
- package/dist/components/controls/EditableTable/editabletable.d.ts +2 -0
- package/dist/components/controls/FileUpload/fileupload.d.ts +3 -0
- package/dist/components/controls/FormWizard/formwizard.d.ts +2 -0
- package/dist/components/controls/GeoField/geofield.d.ts +6 -0
- package/dist/components/controls/IntlPhone/intlphone.d.ts +2 -0
- package/dist/components/controls/KeyValueField/keyvaluefield.d.ts +2 -0
- package/dist/components/controls/LocationField/locationfield.d.ts +1 -1
- package/dist/components/controls/MarkdownEditor/markdowneditor.d.ts +3 -0
- package/dist/components/controls/MatrixField/matrixfield.d.ts +3 -0
- package/dist/components/controls/MultiTextbox/multitextbox.d.ts +1 -1
- package/dist/components/controls/NpsScale/npsscale.d.ts +3 -0
- package/dist/components/controls/NumberField/numberfield.d.ts +1 -1
- package/dist/components/controls/NumberStepper/numberstepper.d.ts +2 -0
- package/dist/components/controls/OtpField/otpfield.d.ts +2 -0
- package/dist/components/controls/PasswordField/passwordfield.d.ts +2 -0
- package/dist/components/controls/PhoneField/phonefield.d.ts +2 -0
- package/dist/components/controls/Radio/radio.d.ts +1 -1
- package/dist/components/controls/Rating/rating.d.ts +3 -0
- package/dist/components/controls/RichTextEditor/richtexteditor.d.ts +3 -0
- package/dist/components/controls/Select/select.d.ts +1 -1
- package/dist/components/controls/Slider/slider.d.ts +3 -0
- package/dist/components/controls/SummaryField/summaryfield.d.ts +7 -0
- package/dist/components/controls/Switch/switch.d.ts +1 -1
- package/dist/components/controls/TagsInput/tagsinput.d.ts +3 -0
- package/dist/components/controls/TextField/textfield.d.ts +1 -1
- package/dist/components/controls/ToggleButtons/togglebuttons.d.ts +3 -0
- package/dist/components/controls/index.d.ts +60 -0
- package/dist/createSelector-B-9FwV16.mjs +430 -0
- package/dist/createSelector-f0oqn8Lr.js +7 -0
- package/dist/date-utils-CFUUt6NL.js +4 -0
- package/dist/date-utils-pGzaKb0p.mjs +477 -0
- package/dist/dynamic-mui.cjs.js +1 -1
- package/dist/dynamic-mui.es.js +19 -6
- package/dist/index--8Zky9Oh.js +299 -0
- package/dist/index-6WTs1Xy_.js +1 -0
- package/dist/index-B1R1akM2.js +1 -0
- package/dist/index-BW8_rRff.js +7 -0
- package/dist/index-BXFVK_GX.js +1 -0
- package/dist/index-B_KNUTjy.js +1 -0
- package/dist/index-BhaKvHkU.mjs +62051 -0
- package/dist/index-Bif92ima.js +1 -0
- package/dist/index-BnZOu8CL.js +1 -0
- package/dist/index-CDxpgRlR.mjs +7 -0
- package/dist/index-CThMfvtJ.mjs +2555 -0
- package/dist/index-CVqLvm8B.js +1 -0
- package/dist/index-CodJBIn6.mjs +1665 -0
- package/dist/index-Cr6Wp_S-.mjs +3141 -0
- package/dist/index-CslPwsrf.mjs +4 -0
- package/dist/index-CuV0MQzZ.mjs +1173 -0
- package/dist/{index-BGfWFaIb.mjs → index-DA0XouZs.mjs} +16 -16
- package/dist/index-DKS5Sz9e.js +14 -0
- package/dist/index-DSkYYZuW.mjs +4 -0
- package/dist/index-DU78_FiA.js +1 -0
- package/dist/index-D_mYhgJ0.js +10 -0
- package/dist/index-DcWfyXJp.mjs +92 -0
- package/dist/index-Dlimbnxj.mjs +2965 -0
- package/dist/index-MllWgTJ5.mjs +9372 -0
- package/dist/index-in5z9hUb.js +133 -0
- package/dist/index-qUW7FnZ-.mjs +20540 -0
- package/dist/index.browser-BSu11T_q.mjs +363 -0
- package/dist/index.browser-By7-GABP.js +4 -0
- package/dist/index.d.ts +4 -1
- package/dist/isDeepEqual-BHfPvf9U.mjs +393 -0
- package/dist/isDeepEqual-CqxZGVRk.js +1 -0
- package/dist/loadCognitoIdentity-DtYTy-DW.js +1 -0
- package/dist/loadCognitoIdentity-DzdR91GB.mjs +872 -0
- package/dist/loadSts-Cic6UToN.mjs +593 -0
- package/dist/loadSts-csbFP6zX.js +1 -0
- package/dist/noAuth-B8ui2kBg.mjs +71 -0
- package/dist/noAuth-JPA2o4dt.js +1 -0
- package/dist/playground/AIContext.d.ts +18 -0
- package/dist/playground/AIPanel.d.ts +10 -0
- package/dist/playground/DemoGallery.d.ts +6 -0
- package/dist/playground/Sidebar.d.ts +9 -1
- package/dist/playground/demoForms.d.ts +3 -0
- package/dist/playground/demoRecipes.d.ts +15 -0
- package/dist/playground/demoVariants.d.ts +11 -0
- package/dist/schema.d.ts +404 -0
- package/dist/theme/theme.d.ts +5 -0
- package/dist/types.d.ts +97 -10
- package/dist/useAxis-DSbfEtO7.js +3 -0
- package/dist/useAxis-SiNBMMWq.mjs +3010 -0
- package/dist/useChartContainerProps-Bl3hO-r1.mjs +5418 -0
- package/dist/useChartContainerProps-C_C_PZoi.js +12 -0
- package/dist/useItemHighlightedGetter-9CIwqsGj.js +1 -0
- package/dist/useItemHighlightedGetter-CTISrNdV.mjs +88 -0
- package/dist/util/helper.d.ts +2 -30
- package/dist/util/premiumStyles.d.ts +27 -0
- package/dist/util/rules.d.ts +35 -0
- package/package.json +2 -2
- package/dist/index-BHROoqH4.js +0 -1
- package/dist/index-S6BQaF_5.js +0 -465
- package/dist/index-Wtsz8Yiv.mjs +0 -102315
- package/dist/loadCognitoIdentity-CiUaDv6q.mjs +0 -935
- package/dist/loadCognitoIdentity-DN_MCNUl.js +0 -1
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { H as g, N as y, c as b } from "./index-Cr6Wp_S-.mjs";
|
|
2
|
+
import { H as z } from "./date-utils-pGzaKb0p.mjs";
|
|
3
|
+
class q extends g {
|
|
4
|
+
async serializeRequest(i, r, e) {
|
|
5
|
+
const s = this.serializer, n = {}, a = {}, d = await e.endpoint(), t = y.of(i?.input), m = t.getSchema();
|
|
6
|
+
let f;
|
|
7
|
+
const o = new z({
|
|
8
|
+
protocol: "",
|
|
9
|
+
hostname: "",
|
|
10
|
+
port: void 0,
|
|
11
|
+
path: "/",
|
|
12
|
+
fragment: void 0,
|
|
13
|
+
query: n,
|
|
14
|
+
headers: a,
|
|
15
|
+
body: void 0
|
|
16
|
+
});
|
|
17
|
+
d && (this.updateServiceEndpoint(o, d), this.setHostPrefix(o, i, r));
|
|
18
|
+
const c = {
|
|
19
|
+
...r
|
|
20
|
+
};
|
|
21
|
+
if (r) {
|
|
22
|
+
const h = t.getEventStreamMember();
|
|
23
|
+
if (h) {
|
|
24
|
+
if (c[h]) {
|
|
25
|
+
const u = {};
|
|
26
|
+
for (const [l, S] of t.structIterator())
|
|
27
|
+
l !== h && c[l] && (s.write(S, c[l]), u[l] = s.flush());
|
|
28
|
+
f = await this.serializeEventStream({
|
|
29
|
+
eventStream: c[h],
|
|
30
|
+
requestSchema: t,
|
|
31
|
+
initialRequest: u
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
} else
|
|
35
|
+
s.write(m, c), f = s.flush();
|
|
36
|
+
}
|
|
37
|
+
return o.headers = a, o.query = n, o.body = f, o.method = "POST", o;
|
|
38
|
+
}
|
|
39
|
+
async deserializeResponse(i, r, e) {
|
|
40
|
+
const s = this.deserializer, n = y.of(i.output), a = {};
|
|
41
|
+
if (e.statusCode >= 300) {
|
|
42
|
+
const t = await b(e.body, r);
|
|
43
|
+
throw t.byteLength > 0 && Object.assign(a, await s.read(15, t)), await this.handleError(i, r, e, a, this.deserializeMetadata(e)), new Error("@smithy/core/protocols - RPC Protocol error handler failed to throw.");
|
|
44
|
+
}
|
|
45
|
+
for (const t in e.headers) {
|
|
46
|
+
const m = e.headers[t];
|
|
47
|
+
delete e.headers[t], e.headers[t.toLowerCase()] = m;
|
|
48
|
+
}
|
|
49
|
+
const d = n.getEventStreamMember();
|
|
50
|
+
if (d)
|
|
51
|
+
a[d] = await this.deserializeEventStream({
|
|
52
|
+
response: e,
|
|
53
|
+
responseSchema: n,
|
|
54
|
+
initialResponseContainer: a
|
|
55
|
+
});
|
|
56
|
+
else {
|
|
57
|
+
const t = await b(e.body, r);
|
|
58
|
+
t.byteLength > 0 && Object.assign(a, await s.read(n, t));
|
|
59
|
+
}
|
|
60
|
+
return a.$metadata = this.deserializeMetadata(e), a;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
class R {
|
|
64
|
+
async sign(i, r, e) {
|
|
65
|
+
return i;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
export {
|
|
69
|
+
R as N,
|
|
70
|
+
q as R
|
|
71
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const l=require("./index-DKS5Sz9e.js"),S=require("./date-utils-CFUUt6NL.js");class g extends l.HttpProtocol{async serializeRequest(r,i,e){const s=this.serializer,n={},a={},d=await e.endpoint(),t=l.NormalizedSchema.of(r?.input),u=t.getSchema();let f;const o=new S.HttpRequest({protocol:"",hostname:"",port:void 0,path:"/",fragment:void 0,query:n,headers:a,body:void 0});d&&(this.updateServiceEndpoint(o,d),this.setHostPrefix(o,r,i));const c={...i};if(i){const h=t.getEventStreamMember();if(h){if(c[h]){const y={};for(const[m,w]of t.structIterator())m!==h&&c[m]&&(s.write(w,c[m]),y[m]=s.flush());f=await this.serializeEventStream({eventStream:c[h],requestSchema:t,initialRequest:y})}}else s.write(u,c),f=s.flush()}return o.headers=a,o.query=n,o.body=f,o.method="POST",o}async deserializeResponse(r,i,e){const s=this.deserializer,n=l.NormalizedSchema.of(r.output),a={};if(e.statusCode>=300){const t=await l.collectBody(e.body,i);throw t.byteLength>0&&Object.assign(a,await s.read(15,t)),await this.handleError(r,i,e,a,this.deserializeMetadata(e)),new Error("@smithy/core/protocols - RPC Protocol error handler failed to throw.")}for(const t in e.headers){const u=e.headers[t];delete e.headers[t],e.headers[t.toLowerCase()]=u}const d=n.getEventStreamMember();if(d)a[d]=await this.deserializeEventStream({response:e,responseSchema:n,initialResponseContainer:a});else{const t=await l.collectBody(e.body,i);t.byteLength>0&&Object.assign(a,await s.read(n,t))}return a.$metadata=this.deserializeMetadata(e),a}}class z{async sign(r,i,e){return r}}exports.NoAuthSigner=z;exports.RpcProtocol=g;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { AIClient } from '../ai';
|
|
3
|
+
interface AICtx {
|
|
4
|
+
endpoint: string;
|
|
5
|
+
apiKey: string;
|
|
6
|
+
setEndpoint: (v: string) => void;
|
|
7
|
+
setApiKey: (v: string) => void;
|
|
8
|
+
client: AIClient | null;
|
|
9
|
+
configured: boolean;
|
|
10
|
+
}
|
|
11
|
+
/** Holds the AI config (URL + key) once, shared by every AI feature in the builder. */
|
|
12
|
+
export declare const AIProvider: ({ children }: {
|
|
13
|
+
children: ReactNode;
|
|
14
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export declare const useAI: () => AICtx;
|
|
16
|
+
/** Reusable URL + key inputs bound to the shared config. */
|
|
17
|
+
export declare const AIConfigFields: () => import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FormField } from '../util/helper';
|
|
2
|
+
interface AIPanelProps {
|
|
3
|
+
open: boolean;
|
|
4
|
+
onClose: () => void;
|
|
5
|
+
currentFields: FormField[];
|
|
6
|
+
onApply: (fields: FormField[]) => void;
|
|
7
|
+
}
|
|
8
|
+
/** Playground-only panel: generate / digitize / review a form with AI. */
|
|
9
|
+
export declare const AIPanel: ({ open, onClose, currentFields, onApply }: AIPanelProps) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { FormField } from '../util/helper';
|
|
2
|
+
/** Full-width live gallery: patterns + every component in multiple config variants, with props, code, and add-to-builder. */
|
|
3
|
+
export declare const DemoGallery: ({ onAddField, onAddFields }: {
|
|
4
|
+
onAddField: (field: FormField) => void;
|
|
5
|
+
onAddFields: (fields: FormField[]) => void;
|
|
6
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1,9 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const CATEGORIES: Record<string, string[]>;
|
|
2
|
+
export declare const CATEGORY_META: Record<string, {
|
|
3
|
+
color: string;
|
|
4
|
+
icon: string;
|
|
5
|
+
grad: [string, string];
|
|
6
|
+
}>;
|
|
7
|
+
export declare const Sidebar: ({ onAdd }: {
|
|
8
|
+
onAdd?: (type: string) => void;
|
|
9
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { FormField } from '../util/helper';
|
|
2
|
+
export interface DemoRecipe {
|
|
3
|
+
id: string;
|
|
4
|
+
title: string;
|
|
5
|
+
description: string;
|
|
6
|
+
icon: string;
|
|
7
|
+
data: FormField[];
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Practical, multi-field examples that show the DYNAMIC engine at work —
|
|
11
|
+
* live formulas, conditional visibility, dependent selects (subforms),
|
|
12
|
+
* required-when, disabled-when, and cross-field validation. These are the
|
|
13
|
+
* real-world patterns single-component demos can't show.
|
|
14
|
+
*/
|
|
15
|
+
export declare const DEMO_RECIPES: DemoRecipe[];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { FormField } from '../util/helper';
|
|
2
|
+
export type DemoVariant = {
|
|
3
|
+
label: string;
|
|
4
|
+
field: FormField;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Curated config variants per component so the Demo gallery shows "what this
|
|
8
|
+
* component can do". Any component NOT listed here falls back to its single
|
|
9
|
+
* playground template (see DemoCard).
|
|
10
|
+
*/
|
|
11
|
+
export declare const DEMO_VARIANTS: Record<string, DemoVariant[]>;
|
package/dist/schema.d.ts
ADDED
|
@@ -0,0 +1,404 @@
|
|
|
1
|
+
import { FormField, RuleExpression } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* TYPED SCHEMA LAYER (additive, authoring-only)
|
|
4
|
+
* ---------------------------------------------
|
|
5
|
+
* A convenience, compile-time layer on top of the loose runtime `FormField`.
|
|
6
|
+
* Authors get autocomplete + type-checking for the common controls, while
|
|
7
|
+
* `defineForm` erases the extra typing and hands FormGenerator the exact
|
|
8
|
+
* `FormField[]` it already expects. Nothing here changes runtime behaviour.
|
|
9
|
+
*/
|
|
10
|
+
/** An option entry accepted by option-based controls. */
|
|
11
|
+
export interface TypedOption {
|
|
12
|
+
value: any;
|
|
13
|
+
label: string;
|
|
14
|
+
[k: string]: any;
|
|
15
|
+
}
|
|
16
|
+
/** Options that may be given as bare strings or {value,label} objects. */
|
|
17
|
+
export type LooseOption = string | TypedOption;
|
|
18
|
+
/** Per-field grid/layout hints (subset of runtime `LayoutConfig`). */
|
|
19
|
+
export interface TypedLayout {
|
|
20
|
+
row?: number;
|
|
21
|
+
xs?: number;
|
|
22
|
+
sm?: number;
|
|
23
|
+
md?: number;
|
|
24
|
+
lg?: number;
|
|
25
|
+
xl?: number;
|
|
26
|
+
[k: string]: any;
|
|
27
|
+
}
|
|
28
|
+
/** Typed validation rule for the `rules.validation` array. */
|
|
29
|
+
export interface TypedValidationRule {
|
|
30
|
+
rule: string;
|
|
31
|
+
message?: string;
|
|
32
|
+
value?: any;
|
|
33
|
+
[k: string]: any;
|
|
34
|
+
}
|
|
35
|
+
export interface TypedRules {
|
|
36
|
+
validation?: TypedValidationRule[];
|
|
37
|
+
[k: string]: any;
|
|
38
|
+
}
|
|
39
|
+
/** MUI attribute bag — kept open so any MUI prop still type-checks. */
|
|
40
|
+
export interface TypedMuiAttributes {
|
|
41
|
+
label?: string;
|
|
42
|
+
placeholder?: string;
|
|
43
|
+
helperText?: string;
|
|
44
|
+
variant?: string;
|
|
45
|
+
fullWidth?: boolean;
|
|
46
|
+
[k: string]: any;
|
|
47
|
+
}
|
|
48
|
+
/** Fields shared by every typed variant. */
|
|
49
|
+
export interface TypedFieldBase {
|
|
50
|
+
id: string;
|
|
51
|
+
layout?: TypedLayout;
|
|
52
|
+
rules?: TypedRules;
|
|
53
|
+
visible?: boolean;
|
|
54
|
+
visibleWhen?: RuleExpression | any;
|
|
55
|
+
disabledWhen?: RuleExpression | any;
|
|
56
|
+
requiredWhen?: RuleExpression | any;
|
|
57
|
+
requiredMessage?: string;
|
|
58
|
+
}
|
|
59
|
+
export interface TextFieldField extends TypedFieldBase {
|
|
60
|
+
type: 'textfield';
|
|
61
|
+
props: {
|
|
62
|
+
id: string;
|
|
63
|
+
value?: string;
|
|
64
|
+
multiline?: boolean;
|
|
65
|
+
rows?: number;
|
|
66
|
+
MuiAttributes?: TypedMuiAttributes;
|
|
67
|
+
[k: string]: any;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
export interface NumberFieldField extends TypedFieldBase {
|
|
71
|
+
type: 'numberfield';
|
|
72
|
+
props: {
|
|
73
|
+
id: string;
|
|
74
|
+
value?: number;
|
|
75
|
+
min?: number;
|
|
76
|
+
max?: number;
|
|
77
|
+
step?: number;
|
|
78
|
+
MuiAttributes?: TypedMuiAttributes;
|
|
79
|
+
[k: string]: any;
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
export interface PasswordField extends TypedFieldBase {
|
|
83
|
+
type: 'password';
|
|
84
|
+
props: {
|
|
85
|
+
id: string;
|
|
86
|
+
value?: string;
|
|
87
|
+
MuiAttributes?: TypedMuiAttributes;
|
|
88
|
+
[k: string]: any;
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
export interface CurrencyField extends TypedFieldBase {
|
|
92
|
+
type: 'currency';
|
|
93
|
+
props: {
|
|
94
|
+
id: string;
|
|
95
|
+
value?: number;
|
|
96
|
+
currency?: string;
|
|
97
|
+
locale?: string;
|
|
98
|
+
MuiAttributes?: TypedMuiAttributes;
|
|
99
|
+
[k: string]: any;
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
export interface PhoneField extends TypedFieldBase {
|
|
103
|
+
type: 'phone';
|
|
104
|
+
props: {
|
|
105
|
+
id: string;
|
|
106
|
+
value?: string;
|
|
107
|
+
defaultCountry?: string;
|
|
108
|
+
MuiAttributes?: TypedMuiAttributes;
|
|
109
|
+
[k: string]: any;
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
export interface OtpField extends TypedFieldBase {
|
|
113
|
+
type: 'otp';
|
|
114
|
+
props: {
|
|
115
|
+
id: string;
|
|
116
|
+
value?: string;
|
|
117
|
+
length?: number;
|
|
118
|
+
MuiAttributes?: TypedMuiAttributes;
|
|
119
|
+
[k: string]: any;
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
export interface SelectField extends TypedFieldBase {
|
|
123
|
+
type: 'select';
|
|
124
|
+
props: {
|
|
125
|
+
id: string;
|
|
126
|
+
value?: any;
|
|
127
|
+
options: TypedOption[];
|
|
128
|
+
multiple?: boolean;
|
|
129
|
+
MuiAttributes?: TypedMuiAttributes;
|
|
130
|
+
MuiBoxAttributes?: any;
|
|
131
|
+
[k: string]: any;
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
export interface AutoCompleteField extends TypedFieldBase {
|
|
135
|
+
type: 'autocomplete';
|
|
136
|
+
props: {
|
|
137
|
+
id: string;
|
|
138
|
+
value?: any;
|
|
139
|
+
options: LooseOption[];
|
|
140
|
+
multiple?: boolean;
|
|
141
|
+
MuiAttributes?: TypedMuiAttributes;
|
|
142
|
+
[k: string]: any;
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
export interface RadioField extends TypedFieldBase {
|
|
146
|
+
type: 'radio';
|
|
147
|
+
props: {
|
|
148
|
+
id: string;
|
|
149
|
+
value?: any;
|
|
150
|
+
options: LooseOption[];
|
|
151
|
+
row?: boolean;
|
|
152
|
+
MuiAttributes?: TypedMuiAttributes;
|
|
153
|
+
[k: string]: any;
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
export interface CheckBoxField extends TypedFieldBase {
|
|
157
|
+
type: 'checkbox';
|
|
158
|
+
props: {
|
|
159
|
+
id: string;
|
|
160
|
+
value?: boolean;
|
|
161
|
+
label?: string;
|
|
162
|
+
MuiAttributes?: TypedMuiAttributes;
|
|
163
|
+
[k: string]: any;
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
export interface SwitchField extends TypedFieldBase {
|
|
167
|
+
type: 'switch';
|
|
168
|
+
props: {
|
|
169
|
+
id: string;
|
|
170
|
+
value?: boolean;
|
|
171
|
+
label?: string;
|
|
172
|
+
MuiAttributes?: TypedMuiAttributes;
|
|
173
|
+
[k: string]: any;
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
export interface ConsentField extends TypedFieldBase {
|
|
177
|
+
type: 'consent';
|
|
178
|
+
props: {
|
|
179
|
+
id: string;
|
|
180
|
+
value?: boolean;
|
|
181
|
+
label?: string;
|
|
182
|
+
text?: string;
|
|
183
|
+
MuiAttributes?: TypedMuiAttributes;
|
|
184
|
+
[k: string]: any;
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
export interface ChipSelectOrToggleField extends TypedFieldBase {
|
|
188
|
+
type: 'chipselect' | 'togglebuttons';
|
|
189
|
+
props: {
|
|
190
|
+
id: string;
|
|
191
|
+
value?: any;
|
|
192
|
+
label?: string;
|
|
193
|
+
options: LooseOption[];
|
|
194
|
+
multiple?: boolean;
|
|
195
|
+
[k: string]: any;
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
export interface TagsInputField extends TypedFieldBase {
|
|
199
|
+
type: 'tagsinput';
|
|
200
|
+
props: {
|
|
201
|
+
id: string;
|
|
202
|
+
value?: string[];
|
|
203
|
+
label?: string;
|
|
204
|
+
MuiAttributes?: TypedMuiAttributes;
|
|
205
|
+
[k: string]: any;
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
export interface RatingField extends TypedFieldBase {
|
|
209
|
+
type: 'rating';
|
|
210
|
+
props: {
|
|
211
|
+
id: string;
|
|
212
|
+
value?: number;
|
|
213
|
+
max?: number;
|
|
214
|
+
precision?: number;
|
|
215
|
+
label?: string;
|
|
216
|
+
[k: string]: any;
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
export interface SliderField extends TypedFieldBase {
|
|
220
|
+
type: 'slider';
|
|
221
|
+
props: {
|
|
222
|
+
id: string;
|
|
223
|
+
value?: number | number[];
|
|
224
|
+
min?: number;
|
|
225
|
+
max?: number;
|
|
226
|
+
step?: number;
|
|
227
|
+
marks?: boolean | {
|
|
228
|
+
value: number;
|
|
229
|
+
label?: string;
|
|
230
|
+
}[];
|
|
231
|
+
label?: string;
|
|
232
|
+
[k: string]: any;
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
export interface ColorPickerField extends TypedFieldBase {
|
|
236
|
+
type: 'colorpicker';
|
|
237
|
+
props: {
|
|
238
|
+
id: string;
|
|
239
|
+
value?: string;
|
|
240
|
+
label?: string;
|
|
241
|
+
[k: string]: any;
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
export interface DateTimeField extends TypedFieldBase {
|
|
245
|
+
type: 'datetime' | 'datetimepicker' | 'timepicker' | 'daterangepicker';
|
|
246
|
+
props: {
|
|
247
|
+
id: string;
|
|
248
|
+
value?: any;
|
|
249
|
+
format?: string;
|
|
250
|
+
MuiAttributes?: TypedMuiAttributes;
|
|
251
|
+
[k: string]: any;
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
export interface FileUploadField extends TypedFieldBase {
|
|
255
|
+
type: 'fileupload';
|
|
256
|
+
props: {
|
|
257
|
+
id: string;
|
|
258
|
+
value?: any;
|
|
259
|
+
accept?: string;
|
|
260
|
+
multiple?: boolean;
|
|
261
|
+
MuiAttributes?: TypedMuiAttributes;
|
|
262
|
+
[k: string]: any;
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
export interface SignatureField extends TypedFieldBase {
|
|
266
|
+
type: 'signature';
|
|
267
|
+
props: {
|
|
268
|
+
id: string;
|
|
269
|
+
value?: any;
|
|
270
|
+
MuiAttributes?: TypedMuiAttributes;
|
|
271
|
+
[k: string]: any;
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
export interface MarkdownField extends TypedFieldBase {
|
|
275
|
+
type: 'markdown';
|
|
276
|
+
props: {
|
|
277
|
+
id: string;
|
|
278
|
+
value?: string;
|
|
279
|
+
MuiAttributes?: TypedMuiAttributes;
|
|
280
|
+
[k: string]: any;
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
export interface KeyValueField extends TypedFieldBase {
|
|
284
|
+
type: 'keyvalue';
|
|
285
|
+
props: {
|
|
286
|
+
id: string;
|
|
287
|
+
value?: Record<string, any> | {
|
|
288
|
+
key: string;
|
|
289
|
+
value: any;
|
|
290
|
+
}[];
|
|
291
|
+
label?: string;
|
|
292
|
+
[k: string]: any;
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
export interface MatrixField extends TypedFieldBase {
|
|
296
|
+
type: 'matrix';
|
|
297
|
+
props: {
|
|
298
|
+
id: string;
|
|
299
|
+
value?: any;
|
|
300
|
+
rows?: LooseOption[];
|
|
301
|
+
columns?: LooseOption[];
|
|
302
|
+
[k: string]: any;
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
export interface AddressField extends TypedFieldBase {
|
|
306
|
+
type: 'address';
|
|
307
|
+
props: {
|
|
308
|
+
id: string;
|
|
309
|
+
value?: any;
|
|
310
|
+
MuiAttributes?: TypedMuiAttributes;
|
|
311
|
+
[k: string]: any;
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
export interface GeoField extends TypedFieldBase {
|
|
315
|
+
type: 'geo';
|
|
316
|
+
props: {
|
|
317
|
+
id: string;
|
|
318
|
+
value?: any;
|
|
319
|
+
[k: string]: any;
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
export interface CascadeSelectField extends TypedFieldBase {
|
|
323
|
+
type: 'cascadeselect';
|
|
324
|
+
props: {
|
|
325
|
+
id: string;
|
|
326
|
+
value?: any;
|
|
327
|
+
options: any[];
|
|
328
|
+
[k: string]: any;
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
export interface ComputedField extends TypedFieldBase {
|
|
332
|
+
type: 'computed';
|
|
333
|
+
props: {
|
|
334
|
+
id: string;
|
|
335
|
+
formula: string;
|
|
336
|
+
MuiAttributes?: TypedMuiAttributes;
|
|
337
|
+
[k: string]: any;
|
|
338
|
+
};
|
|
339
|
+
formula?: string;
|
|
340
|
+
}
|
|
341
|
+
export interface AlertField extends TypedFieldBase {
|
|
342
|
+
type: 'alert';
|
|
343
|
+
props: {
|
|
344
|
+
id: string;
|
|
345
|
+
severity?: 'error' | 'warning' | 'info' | 'success';
|
|
346
|
+
message?: string;
|
|
347
|
+
MuiAttributes?: TypedMuiAttributes;
|
|
348
|
+
[k: string]: any;
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
export interface TypographyField extends TypedFieldBase {
|
|
352
|
+
type: 'typography';
|
|
353
|
+
props: {
|
|
354
|
+
id: string;
|
|
355
|
+
value?: string;
|
|
356
|
+
variant?: string;
|
|
357
|
+
MuiAttributes?: TypedMuiAttributes;
|
|
358
|
+
[k: string]: any;
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
export interface ButtonField extends TypedFieldBase {
|
|
362
|
+
type: 'button';
|
|
363
|
+
props: {
|
|
364
|
+
id: string;
|
|
365
|
+
label?: string;
|
|
366
|
+
action?: string;
|
|
367
|
+
MuiAttributes?: TypedMuiAttributes;
|
|
368
|
+
[k: string]: any;
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
export interface DividerField extends TypedFieldBase {
|
|
372
|
+
type: 'divider';
|
|
373
|
+
props?: {
|
|
374
|
+
id?: string;
|
|
375
|
+
[k: string]: any;
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* Catch-all — any control key still type-checks (e.g. the less-common ones in
|
|
380
|
+
* `config/mui.ts`). Kept permissive on purpose so authors are never blocked.
|
|
381
|
+
* Listed LAST so the specific variants win discrimination when they match.
|
|
382
|
+
*/
|
|
383
|
+
export interface GenericField {
|
|
384
|
+
type: string;
|
|
385
|
+
id?: string;
|
|
386
|
+
props?: Record<string, any>;
|
|
387
|
+
layout?: TypedLayout;
|
|
388
|
+
rules?: TypedRules;
|
|
389
|
+
visibleWhen?: RuleExpression | any;
|
|
390
|
+
disabledWhen?: RuleExpression | any;
|
|
391
|
+
requiredWhen?: RuleExpression | any;
|
|
392
|
+
[k: string]: any;
|
|
393
|
+
}
|
|
394
|
+
/** Discriminated union across the common controls (+ a permissive fallback). */
|
|
395
|
+
export type TypedField = TextFieldField | NumberFieldField | PasswordField | CurrencyField | PhoneField | OtpField | SelectField | AutoCompleteField | RadioField | CheckBoxField | SwitchField | ConsentField | ChipSelectOrToggleField | TagsInputField | RatingField | SliderField | ColorPickerField | DateTimeField | FileUploadField | SignatureField | MarkdownField | KeyValueField | MatrixField | AddressField | GeoField | CascadeSelectField | ComputedField | AlertField | TypographyField | ButtonField | DividerField | GenericField;
|
|
396
|
+
/** A complete typed form. */
|
|
397
|
+
export type TypedSchema = TypedField[];
|
|
398
|
+
/**
|
|
399
|
+
* Typed authoring entry point. Accepts a `TypedSchema` (autocompleted +
|
|
400
|
+
* type-checked) and returns the runtime `FormField[]` that FormGenerator
|
|
401
|
+
* consumes. Purely a compile-time convenience — no runtime transformation.
|
|
402
|
+
*/
|
|
403
|
+
export declare function defineForm(schema: TypedSchema): FormField[];
|
|
404
|
+
export type { FormField, RuleExpression } from './types';
|
package/dist/theme/theme.d.ts
CHANGED
package/dist/types.d.ts
CHANGED
|
@@ -1,19 +1,106 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
/** A single validation rule attached to a field. `rule` maps to a key in the
|
|
3
|
+
* validation utility (e.g. 'mandatory', 'email', 'length'). */
|
|
4
|
+
export interface ValidationRule {
|
|
5
|
+
rule: string;
|
|
6
|
+
message?: string;
|
|
7
|
+
/** Optional argument forwarded to the validator (e.g. length options). */
|
|
8
|
+
value?: any;
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
}
|
|
11
|
+
export interface FieldRules {
|
|
12
|
+
validation?: ValidationRule[];
|
|
13
|
+
[key: string]: any;
|
|
14
|
+
}
|
|
15
|
+
/** Conditionally-rendered sub-form shown when the parent field equals
|
|
16
|
+
* `conditionValue` (or, for multi-value fields, includes it). */
|
|
17
|
+
export interface SubForm {
|
|
18
|
+
conditionValue: any;
|
|
19
|
+
data: FormField[];
|
|
20
|
+
}
|
|
21
|
+
export interface LayoutConfig {
|
|
22
|
+
row?: number;
|
|
23
|
+
xs?: number;
|
|
24
|
+
sm?: number;
|
|
25
|
+
md?: number;
|
|
26
|
+
lg?: number;
|
|
27
|
+
xl?: number;
|
|
28
|
+
size?: any;
|
|
29
|
+
[key: string]: any;
|
|
30
|
+
}
|
|
31
|
+
export interface FieldProps {
|
|
32
|
+
id?: string;
|
|
33
|
+
value?: any;
|
|
34
|
+
MuiAttributes?: any;
|
|
35
|
+
InputProps?: any;
|
|
36
|
+
options?: any[];
|
|
37
|
+
format?: string;
|
|
38
|
+
[key: string]: any;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* A condition (or nested AND/OR/NOR group) evaluated against the form's live
|
|
42
|
+
* values to drive reactive behaviour. See `util/rules` for the full shape.
|
|
43
|
+
*/
|
|
44
|
+
export type RuleExpression = {
|
|
45
|
+
field: string;
|
|
46
|
+
op?: string;
|
|
47
|
+
value?: any;
|
|
48
|
+
} | {
|
|
49
|
+
all?: RuleExpression[];
|
|
50
|
+
any?: RuleExpression[];
|
|
51
|
+
none?: RuleExpression[];
|
|
52
|
+
};
|
|
53
|
+
/** The JSON schema entry describing one field/control in a form. */
|
|
54
|
+
export interface FormField {
|
|
55
|
+
id?: string;
|
|
56
|
+
type?: string;
|
|
57
|
+
layout?: LayoutConfig;
|
|
58
|
+
props?: FieldProps;
|
|
59
|
+
visible?: boolean;
|
|
60
|
+
style?: CSSProperties;
|
|
61
|
+
className?: string;
|
|
62
|
+
rules?: FieldRules;
|
|
63
|
+
subforms?: SubForm[];
|
|
64
|
+
/** Show this field only when the condition holds (else it renders nothing). */
|
|
65
|
+
visibleWhen?: RuleExpression;
|
|
66
|
+
/** Disable this field's control when the condition holds. */
|
|
67
|
+
disabledWhen?: RuleExpression;
|
|
68
|
+
/** Make this field mandatory only when the condition holds. */
|
|
69
|
+
requiredWhen?: RuleExpression;
|
|
70
|
+
/** Error message used by `requiredWhen`. */
|
|
71
|
+
requiredMessage?: string;
|
|
72
|
+
/** Arithmetic formula (e.g. "qty * price") computed from other field values. */
|
|
73
|
+
formula?: string;
|
|
74
|
+
/**
|
|
75
|
+
* Dynamic options: the id of another field whose value selects this field's
|
|
76
|
+
* options from `optionsMap`. Keeps ONE control whose options change (e.g. a
|
|
77
|
+
* single State select driven by Country) instead of duplicating fields.
|
|
78
|
+
*/
|
|
79
|
+
dependsOn?: string;
|
|
80
|
+
/** Map of `dependsOn` value → options for this field. */
|
|
81
|
+
optionsMap?: Record<string, any[]>;
|
|
82
|
+
[key: string]: any;
|
|
83
|
+
}
|
|
84
|
+
/** An unmet validation rule reported back through `onSubmit`. */
|
|
85
|
+
export interface FormError extends ValidationRule {
|
|
86
|
+
id?: string;
|
|
87
|
+
}
|
|
1
88
|
export interface ControlChangeProps {
|
|
2
89
|
id?: string;
|
|
3
90
|
value: any;
|
|
4
91
|
option?: any;
|
|
5
92
|
}
|
|
6
93
|
export interface ControlProps {
|
|
7
|
-
attributes?:
|
|
8
|
-
|
|
9
|
-
value?: any;
|
|
10
|
-
MuiAttributes?: any;
|
|
11
|
-
InputProps?: any;
|
|
12
|
-
options?: any[];
|
|
13
|
-
format?: string;
|
|
14
|
-
[key: string]: any;
|
|
15
|
-
};
|
|
16
|
-
rules?: any;
|
|
94
|
+
attributes?: FieldProps;
|
|
95
|
+
rules?: FieldRules;
|
|
17
96
|
patch?: Record<string, any>;
|
|
18
97
|
onChange?: (args: ControlChangeProps) => void;
|
|
98
|
+
/** Incremented by FormGenerator on each submit attempt — controls re-run their
|
|
99
|
+
* validation and display the error (so untouched invalid fields turn red). */
|
|
100
|
+
submitTick?: number;
|
|
101
|
+
/** Localizable built-in messages (e.g. `{ required: '…' }`). */
|
|
102
|
+
messages?: {
|
|
103
|
+
required?: string;
|
|
104
|
+
[key: string]: any;
|
|
105
|
+
};
|
|
19
106
|
}
|