dynamic-mui 2.0.25 → 2.1.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.
Files changed (73) hide show
  1. package/dist/XmlShapeDeserializer-3yQdm0b0.mjs +237 -0
  2. package/dist/XmlShapeDeserializer-XKJAoqLc.js +1 -0
  3. package/dist/ai/client.d.ts +2 -0
  4. package/dist/ai/index.d.ts +4 -0
  5. package/dist/ai/mapping.d.ts +14 -0
  6. package/dist/ai/react/AIFill.d.ts +25 -0
  7. package/dist/ai/react/AIForm.d.ts +29 -0
  8. package/dist/ai/react/AIFormGenerator.d.ts +20 -0
  9. package/dist/ai/react/AISchemaReview.d.ts +18 -0
  10. package/dist/ai/react/AITextAssist.d.ts +35 -0
  11. package/dist/ai/react/AIVisionImport.d.ts +21 -0
  12. package/dist/ai/react/index.d.ts +6 -0
  13. package/dist/ai/types.d.ts +107 -0
  14. package/dist/components/FormGenerator.d.ts +14 -1
  15. package/dist/components/controls/AddressField/addressfield.d.ts +2 -0
  16. package/dist/components/controls/Alert/alert.d.ts +3 -0
  17. package/dist/components/controls/Button/button.d.ts +3 -0
  18. package/dist/components/controls/CascadeSelect/cascadeselect.d.ts +2 -0
  19. package/dist/components/controls/ChipSelect/chipselect.d.ts +3 -0
  20. package/dist/components/controls/ColorPicker/colorpicker.d.ts +3 -0
  21. package/dist/components/controls/Computed/computed.d.ts +7 -0
  22. package/dist/components/controls/ConsentField/consentfield.d.ts +3 -0
  23. package/dist/components/controls/CurrencyField/currencyfield.d.ts +2 -0
  24. package/dist/components/controls/DateRangePicker/daterangepicker.d.ts +3 -0
  25. package/dist/components/controls/FileUpload/fileupload.d.ts +3 -0
  26. package/dist/components/controls/FormWizard/formwizard.d.ts +2 -0
  27. package/dist/components/controls/GeoField/geofield.d.ts +6 -0
  28. package/dist/components/controls/KeyValueField/keyvaluefield.d.ts +2 -0
  29. package/dist/components/controls/MarkdownEditor/markdowneditor.d.ts +3 -0
  30. package/dist/components/controls/MatrixField/matrixfield.d.ts +3 -0
  31. package/dist/components/controls/NumberStepper/numberstepper.d.ts +2 -0
  32. package/dist/components/controls/OtpField/otpfield.d.ts +2 -0
  33. package/dist/components/controls/PasswordField/passwordfield.d.ts +2 -0
  34. package/dist/components/controls/PhoneField/phonefield.d.ts +2 -0
  35. package/dist/components/controls/Rating/rating.d.ts +3 -0
  36. package/dist/components/controls/Slider/slider.d.ts +3 -0
  37. package/dist/components/controls/SummaryField/summaryfield.d.ts +7 -0
  38. package/dist/components/controls/TagsInput/tagsinput.d.ts +3 -0
  39. package/dist/components/controls/ToggleButtons/togglebuttons.d.ts +3 -0
  40. package/dist/components/controls/index.d.ts +50 -0
  41. package/dist/date-utils-CFUUt6NL.js +4 -0
  42. package/dist/date-utils-pGzaKb0p.mjs +477 -0
  43. package/dist/dynamic-mui.cjs.js +469 -1
  44. package/dist/dynamic-mui.es.js +102548 -7
  45. package/dist/index-BW8_rRff.js +7 -0
  46. package/dist/index-BXFVK_GX.js +1 -0
  47. package/dist/index-CVqLvm8B.js +1 -0
  48. package/dist/index-Cr6Wp_S-.mjs +3141 -0
  49. package/dist/{index-Cu1h31y8.mjs → index-DA0XouZs.mjs} +16 -16
  50. package/dist/index-DKS5Sz9e.js +14 -0
  51. package/dist/index-DcWfyXJp.mjs +92 -0
  52. package/dist/index-MllWgTJ5.mjs +9372 -0
  53. package/dist/index.browser-BSu11T_q.mjs +363 -0
  54. package/dist/index.browser-By7-GABP.js +4 -0
  55. package/dist/index.d.ts +1 -0
  56. package/dist/loadCognitoIdentity-DtYTy-DW.js +1 -0
  57. package/dist/loadCognitoIdentity-DzdR91GB.mjs +872 -0
  58. package/dist/loadSts-Cic6UToN.mjs +593 -0
  59. package/dist/loadSts-csbFP6zX.js +1 -0
  60. package/dist/noAuth-B8ui2kBg.mjs +71 -0
  61. package/dist/noAuth-JPA2o4dt.js +1 -0
  62. package/dist/playground/AIContext.d.ts +18 -0
  63. package/dist/playground/AIPanel.d.ts +10 -0
  64. package/dist/types.d.ts +81 -10
  65. package/dist/util/helper.d.ts +2 -30
  66. package/dist/util/premiumStyles.d.ts +27 -0
  67. package/dist/util/rules.d.ts +35 -0
  68. package/package.json +2 -2
  69. package/dist/index-Bd7ELVvM.mjs +0 -102295
  70. package/dist/index-DIaEVD8W.js +0 -465
  71. package/dist/index-DzzNuBCt.js +0 -1
  72. package/dist/loadCognitoIdentity-5jZEsafg.js +0 -1
  73. package/dist/loadCognitoIdentity-C-Upg8iV.mjs +0 -935
@@ -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 {};
package/dist/types.d.ts CHANGED
@@ -1,19 +1,90 @@
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
+ [key: string]: any;
75
+ }
76
+ /** An unmet validation rule reported back through `onSubmit`. */
77
+ export interface FormError extends ValidationRule {
78
+ id?: string;
79
+ }
1
80
  export interface ControlChangeProps {
2
81
  id?: string;
3
82
  value: any;
4
83
  option?: any;
5
84
  }
6
85
  export interface ControlProps {
7
- attributes?: {
8
- id?: string;
9
- value?: any;
10
- MuiAttributes?: any;
11
- InputProps?: any;
12
- options?: any[];
13
- format?: string;
14
- [key: string]: any;
15
- };
16
- rules?: any;
86
+ attributes?: FieldProps;
87
+ rules?: FieldRules;
17
88
  patch?: Record<string, any>;
18
89
  onChange?: (args: ControlChangeProps) => void;
19
90
  }
@@ -1,34 +1,6 @@
1
1
  import { CSSProperties } from 'react';
2
- export interface LayoutConfig {
3
- row?: number;
4
- xs?: number;
5
- sm?: number;
6
- md?: number;
7
- lg?: number;
8
- xl?: number;
9
- size?: any;
10
- [key: string]: any;
11
- }
12
- export interface FormField {
13
- id?: string;
14
- type?: string;
15
- layout?: LayoutConfig;
16
- props?: {
17
- id?: string;
18
- value?: any;
19
- MuiAttributes?: Record<string, any>;
20
- [key: string]: any;
21
- };
22
- visible?: boolean;
23
- style?: CSSProperties;
24
- className?: string;
25
- rules?: any;
26
- subforms?: {
27
- conditionValue: any;
28
- data: FormField[];
29
- }[];
30
- [key: string]: any;
31
- }
2
+ import { FormField } from '../types';
3
+ export type { FormField, LayoutConfig } from '../types';
32
4
  export interface LayoutResult {
33
5
  wrows: FormField[][];
34
6
  worows: FormField[];
@@ -0,0 +1,27 @@
1
+ import { Theme } from '@mui/material/styles';
2
+ import { SxProps } from '@mui/material';
3
+ /**
4
+ * Shared "premium" design language for every control.
5
+ *
6
+ * The published controls render under the *consumer's* MUI ThemeProvider, so
7
+ * these styles are applied inline via `sx` (not global theme overrides) and are
8
+ * written against palette tokens (primary/error/background/text) so they adapt
9
+ * to whatever theme the host app provides — light or dark.
10
+ *
11
+ * Each export is a theme-aware `sx` function. Compose with a control's existing
12
+ * user `sx` via `mergeSx(premiumX, userSx)` so consumer overrides always win.
13
+ */
14
+ export declare const PREMIUM_EASING = "cubic-bezier(0.4, 0, 0.2, 1)";
15
+ export declare const PREMIUM_RADIUS = 10;
16
+ /** Compose base premium sx with user-provided sx (user wins, later in array). */
17
+ export declare const mergeSx: (base?: SxProps<Theme>, userSx?: SxProps<Theme>) => SxProps<Theme>;
18
+ /** Text-like inputs: TextField, NumberField, MultiTextbox, Select, pickers. */
19
+ export declare const premiumInputSx: (theme: Theme) => SxProps<Theme>;
20
+ /** A single selectable row (FormControlLabel) for radio / checkbox groups. */
21
+ export declare const premiumControlLabelSx: (theme: Theme) => SxProps<Theme>;
22
+ /** Switch: refined track + thumb with smooth motion. */
23
+ export declare const premiumSwitchSx: (theme: Theme) => SxProps<Theme>;
24
+ /** Pill-shaped chip with a soft lift on hover. */
25
+ export declare const premiumChipSx: (theme: Theme) => SxProps<Theme>;
26
+ /** Surfaces: List / Paper-like containers with a crisp, soft border. */
27
+ export declare const premiumSurfaceSx: (theme: Theme) => SxProps<Theme>;
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Dynamic-form rule engine: condition evaluation + safe formula computation.
3
+ *
4
+ * Used by FormGenerator to power reactive behaviour (visibleWhen / disabledWhen /
5
+ * requiredWhen) and computed (formula) fields. Pure and dependency-free so it is
6
+ * trivially testable and safe to run on every render.
7
+ */
8
+ export type Operator = 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'in' | 'nin' | 'contains' | 'startsWith' | 'endsWith' | 'empty' | 'notEmpty' | 'truthy' | 'falsy';
9
+ export interface Condition {
10
+ /** Field id whose current value is tested. */
11
+ field: string;
12
+ /** Comparison operator. Defaults to 'eq' when `value` is given, else 'truthy'. */
13
+ op?: Operator;
14
+ /** Value (or array, for in/nin) to compare against. */
15
+ value?: any;
16
+ }
17
+ export interface ConditionGroup {
18
+ /** All must be true (AND). */
19
+ all?: RuleExpr[];
20
+ /** Any may be true (OR). */
21
+ any?: RuleExpr[];
22
+ /** None may be true (NOR). */
23
+ none?: RuleExpr[];
24
+ }
25
+ export type RuleExpr = Condition | ConditionGroup;
26
+ /** Evaluate a condition or nested AND/OR/NOR group against a values map. */
27
+ export declare function evaluateRule(expr: RuleExpr | undefined, values: Record<string, any>): boolean;
28
+ /**
29
+ * Compute a numeric formula string against a values map. Supports + - * / %,
30
+ * parentheses, unary minus, field references (resolved to numbers, missing → 0),
31
+ * and functions SUM/AVG/MIN/MAX/ROUND/ABS/FLOOR/CEIL. Returns '' on error.
32
+ */
33
+ export declare function computeFormula(formula: string, values: Record<string, any>): number | '';
34
+ /** Field-comparison validators (evaluated at the form level where sibling values exist). */
35
+ export declare const CROSS_FIELD_VALIDATORS: Record<string, (a: string, b: string) => boolean>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dynamic-mui",
3
- "version": "2.0.25",
3
+ "version": "2.1.0",
4
4
  "author": "Dinakaran S",
5
5
  "user": "dinakarans",
6
6
  "repository": {
@@ -54,7 +54,7 @@
54
54
  "lint": "eslint . --max-warnings 0",
55
55
  "preview": "vite preview",
56
56
  "test": "vitest run",
57
- "prepublishOnly": "yarn run build"
57
+ "prepublishOnly": "yarn run lint && yarn run test && yarn run build"
58
58
  },
59
59
  "browserslist": {
60
60
  "production": [