pxengine 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +90 -234
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +97 -235
- package/dist/registry.json +1 -1
- package/package.json +1 -1
- package/src/render/PXEngineRenderer.tsx +69 -247
package/dist/index.cjs
CHANGED
|
@@ -3023,6 +3023,42 @@ function Spinner({ className, ...props }) {
|
|
|
3023
3023
|
);
|
|
3024
3024
|
}
|
|
3025
3025
|
|
|
3026
|
+
// src/render/PXEngineRenderer.tsx
|
|
3027
|
+
var import_react25 = __toESM(require("react"), 1);
|
|
3028
|
+
|
|
3029
|
+
// src/atoms/index.ts
|
|
3030
|
+
var atoms_exports = {};
|
|
3031
|
+
__export(atoms_exports, {
|
|
3032
|
+
AccordionAtom: () => AccordionAtom,
|
|
3033
|
+
AlertAtom: () => AlertAtom,
|
|
3034
|
+
AlertDialogAtom: () => AlertDialogAtom,
|
|
3035
|
+
AspectRatioAtom: () => AspectRatioAtom,
|
|
3036
|
+
AvatarAtom: () => AvatarAtom,
|
|
3037
|
+
BadgeAtom: () => BadgeAtom,
|
|
3038
|
+
BreadcrumbAtom: () => BreadcrumbAtom,
|
|
3039
|
+
ButtonAtom: () => ButtonAtom,
|
|
3040
|
+
CalendarAtom: () => CalendarAtom,
|
|
3041
|
+
CardAtom: () => CardAtom,
|
|
3042
|
+
CarouselAtom: () => CarouselAtom,
|
|
3043
|
+
CollapsibleAtom: () => CollapsibleAtom,
|
|
3044
|
+
CommandAtom: () => CommandAtom,
|
|
3045
|
+
DialogAtom: () => DialogAtom,
|
|
3046
|
+
InputAtom: () => InputAtom,
|
|
3047
|
+
LayoutAtom: () => LayoutAtom,
|
|
3048
|
+
PaginationAtom: () => PaginationAtom,
|
|
3049
|
+
PopoverAtom: () => PopoverAtom,
|
|
3050
|
+
ProgressAtom: () => ProgressAtom,
|
|
3051
|
+
ScrollAreaAtom: () => ScrollAreaAtom,
|
|
3052
|
+
SeparatorAtom: () => SeparatorAtom,
|
|
3053
|
+
SheetAtom: () => SheetAtom,
|
|
3054
|
+
SkeletonAtom: () => SkeletonAtom,
|
|
3055
|
+
SpinnerAtom: () => SpinnerAtom,
|
|
3056
|
+
TableAtom: () => TableAtom,
|
|
3057
|
+
TabsAtom: () => TabsAtom,
|
|
3058
|
+
TextAtom: () => TextAtom,
|
|
3059
|
+
TooltipAtom: () => TooltipAtom
|
|
3060
|
+
});
|
|
3061
|
+
|
|
3026
3062
|
// src/atoms/TextAtom.tsx
|
|
3027
3063
|
var import_jsx_runtime41 = require("react/jsx-runtime");
|
|
3028
3064
|
var TextAtom = ({
|
|
@@ -3763,6 +3799,23 @@ var CommandAtom = ({
|
|
|
3763
3799
|
);
|
|
3764
3800
|
};
|
|
3765
3801
|
|
|
3802
|
+
// src/molecules/index.ts
|
|
3803
|
+
var molecules_exports = {};
|
|
3804
|
+
__export(molecules_exports, {
|
|
3805
|
+
ActionButton: () => ActionButton,
|
|
3806
|
+
CAMPAIGN_SEED_FIELDS: () => CAMPAIGN_SEED_FIELDS,
|
|
3807
|
+
CampaignSeedCard: () => CampaignSeedCard,
|
|
3808
|
+
CountrySelectDisplay: () => CountrySelectDisplay,
|
|
3809
|
+
CountrySelectEdit: () => CountrySelectEdit,
|
|
3810
|
+
EditableField: () => EditableField,
|
|
3811
|
+
FormCard: () => FormCard,
|
|
3812
|
+
KeywordBundlesDisplay: () => KeywordBundlesDisplay,
|
|
3813
|
+
KeywordBundlesEdit: () => KeywordBundlesEdit,
|
|
3814
|
+
MCQCard: () => MCQCard,
|
|
3815
|
+
SEARCH_SPEC_FIELDS: () => SEARCH_SPEC_FIELDS,
|
|
3816
|
+
SearchSpecCard: () => SearchSpecCard
|
|
3817
|
+
});
|
|
3818
|
+
|
|
3766
3819
|
// src/molecules/generic/EditableField/EditableField.tsx
|
|
3767
3820
|
var import_react18 = __toESM(require("react"), 1);
|
|
3768
3821
|
var import_jsx_runtime69 = require("react/jsx-runtime");
|
|
@@ -4911,243 +4964,46 @@ var PXEngineRenderer = ({
|
|
|
4911
4964
|
schema,
|
|
4912
4965
|
onAction
|
|
4913
4966
|
}) => {
|
|
4914
|
-
|
|
4915
|
-
const
|
|
4916
|
-
|
|
4917
|
-
|
|
4918
|
-
|
|
4919
|
-
return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
|
|
4920
|
-
LayoutAtom,
|
|
4921
|
-
{
|
|
4922
|
-
...atom,
|
|
4923
|
-
renderComponent: renderComponent2
|
|
4924
|
-
},
|
|
4925
|
-
id
|
|
4926
|
-
);
|
|
4927
|
-
case "card":
|
|
4928
|
-
return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
|
|
4929
|
-
CardAtom,
|
|
4930
|
-
{
|
|
4931
|
-
...atom,
|
|
4932
|
-
renderComponent: renderComponent2
|
|
4933
|
-
},
|
|
4934
|
-
id
|
|
4935
|
-
);
|
|
4936
|
-
case "text":
|
|
4937
|
-
return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(TextAtom, { ...atom }, id);
|
|
4938
|
-
case "button":
|
|
4939
|
-
return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(ButtonAtom, { ...atom, onAction }, id);
|
|
4940
|
-
case "input":
|
|
4941
|
-
return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(InputAtom, { ...atom }, id);
|
|
4942
|
-
case "badge":
|
|
4943
|
-
return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(BadgeAtom, { ...atom }, id);
|
|
4944
|
-
case "avatar":
|
|
4945
|
-
return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(AvatarAtom, { ...atom }, id);
|
|
4946
|
-
case "progress":
|
|
4947
|
-
return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(ProgressAtom, { ...atom }, id);
|
|
4948
|
-
case "skeleton":
|
|
4949
|
-
return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(SkeletonAtom, { ...atom }, id);
|
|
4950
|
-
case "alert":
|
|
4951
|
-
return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(AlertAtom, { ...atom }, id);
|
|
4952
|
-
case "separator":
|
|
4953
|
-
return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(SeparatorAtom, { ...atom }, id);
|
|
4954
|
-
case "table":
|
|
4955
|
-
return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(TableAtom, { ...atom }, id);
|
|
4956
|
-
case "tabs":
|
|
4957
|
-
return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
|
|
4958
|
-
TabsAtom,
|
|
4959
|
-
{
|
|
4960
|
-
...atom,
|
|
4961
|
-
renderComponent: renderComponent2
|
|
4962
|
-
},
|
|
4963
|
-
id
|
|
4964
|
-
);
|
|
4965
|
-
case "accordion":
|
|
4966
|
-
return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
|
|
4967
|
-
AccordionAtom,
|
|
4968
|
-
{
|
|
4969
|
-
...atom,
|
|
4970
|
-
renderComponent: renderComponent2
|
|
4971
|
-
},
|
|
4972
|
-
id
|
|
4973
|
-
);
|
|
4974
|
-
case "scroll-area":
|
|
4975
|
-
return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
|
|
4976
|
-
ScrollAreaAtom,
|
|
4977
|
-
{
|
|
4978
|
-
...atom,
|
|
4979
|
-
renderComponent: renderComponent2
|
|
4980
|
-
},
|
|
4981
|
-
id
|
|
4982
|
-
);
|
|
4983
|
-
case "carousel":
|
|
4984
|
-
return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
|
|
4985
|
-
CarouselAtom,
|
|
4986
|
-
{
|
|
4987
|
-
...atom,
|
|
4988
|
-
renderComponent: renderComponent2
|
|
4989
|
-
},
|
|
4990
|
-
id
|
|
4991
|
-
);
|
|
4992
|
-
case "aspect-ratio":
|
|
4993
|
-
return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
|
|
4994
|
-
AspectRatioAtom,
|
|
4995
|
-
{
|
|
4996
|
-
...atom,
|
|
4997
|
-
renderComponent: renderComponent2
|
|
4998
|
-
},
|
|
4999
|
-
id
|
|
5000
|
-
);
|
|
5001
|
-
case "collapsible":
|
|
5002
|
-
return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
|
|
5003
|
-
CollapsibleAtom,
|
|
5004
|
-
{
|
|
5005
|
-
...atom,
|
|
5006
|
-
renderComponent: renderComponent2
|
|
5007
|
-
},
|
|
5008
|
-
id
|
|
5009
|
-
);
|
|
5010
|
-
case "tooltip":
|
|
5011
|
-
return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
|
|
5012
|
-
TooltipAtom,
|
|
5013
|
-
{
|
|
5014
|
-
...atom,
|
|
5015
|
-
renderComponent: renderComponent2
|
|
5016
|
-
},
|
|
5017
|
-
id
|
|
5018
|
-
);
|
|
5019
|
-
case "popover":
|
|
5020
|
-
return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
|
|
5021
|
-
PopoverAtom,
|
|
5022
|
-
{
|
|
5023
|
-
...atom,
|
|
5024
|
-
renderComponent: renderComponent2
|
|
5025
|
-
},
|
|
5026
|
-
id
|
|
5027
|
-
);
|
|
5028
|
-
case "dialog":
|
|
5029
|
-
return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
|
|
5030
|
-
DialogAtom,
|
|
5031
|
-
{
|
|
5032
|
-
...atom,
|
|
5033
|
-
renderComponent: renderComponent2
|
|
5034
|
-
},
|
|
5035
|
-
id
|
|
5036
|
-
);
|
|
5037
|
-
case "sheet":
|
|
5038
|
-
return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
|
|
5039
|
-
SheetAtom,
|
|
5040
|
-
{
|
|
5041
|
-
...atom,
|
|
5042
|
-
renderComponent: renderComponent2
|
|
5043
|
-
},
|
|
5044
|
-
id
|
|
5045
|
-
);
|
|
5046
|
-
case "alert-dialog":
|
|
5047
|
-
return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
|
|
5048
|
-
AlertDialogAtom,
|
|
5049
|
-
{
|
|
5050
|
-
...atom,
|
|
5051
|
-
onAction,
|
|
5052
|
-
renderComponent: renderComponent2
|
|
5053
|
-
},
|
|
5054
|
-
id
|
|
5055
|
-
);
|
|
5056
|
-
case "breadcrumb":
|
|
5057
|
-
return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(BreadcrumbAtom, { ...atom }, id);
|
|
5058
|
-
case "spinner":
|
|
5059
|
-
return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(SpinnerAtom, { ...atom }, id);
|
|
5060
|
-
case "calendar":
|
|
5061
|
-
return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(CalendarAtom, { ...atom }, id);
|
|
5062
|
-
case "pagination":
|
|
5063
|
-
return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(PaginationAtom, { ...atom }, id);
|
|
5064
|
-
case "command":
|
|
5065
|
-
return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(CommandAtom, { ...atom }, id);
|
|
5066
|
-
default:
|
|
5067
|
-
return null;
|
|
4967
|
+
if (!schema) return null;
|
|
4968
|
+
const root = schema.root || schema;
|
|
4969
|
+
const renderRecursive = (component) => {
|
|
4970
|
+
if (typeof component === "string" || typeof component === "number") {
|
|
4971
|
+
return component;
|
|
5068
4972
|
}
|
|
5069
|
-
|
|
5070
|
-
|
|
5071
|
-
const
|
|
5072
|
-
|
|
5073
|
-
|
|
5074
|
-
|
|
5075
|
-
|
|
5076
|
-
|
|
5077
|
-
|
|
5078
|
-
|
|
5079
|
-
|
|
5080
|
-
|
|
5081
|
-
|
|
5082
|
-
|
|
5083
|
-
|
|
5084
|
-
|
|
5085
|
-
|
|
5086
|
-
|
|
5087
|
-
|
|
5088
|
-
|
|
5089
|
-
id
|
|
5090
|
-
);
|
|
5091
|
-
case "mcq":
|
|
5092
|
-
return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
|
|
5093
|
-
MCQCard,
|
|
5094
|
-
{
|
|
5095
|
-
...molecule,
|
|
5096
|
-
onProceed: () => onAction?.(molecule.proceedAction || "proceed")
|
|
5097
|
-
},
|
|
5098
|
-
id
|
|
5099
|
-
);
|
|
5100
|
-
case "action-button":
|
|
5101
|
-
return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
|
|
5102
|
-
ActionButton,
|
|
5103
|
-
{
|
|
5104
|
-
...molecule,
|
|
5105
|
-
onProceed: () => onAction?.(molecule.action || "proceed")
|
|
5106
|
-
},
|
|
5107
|
-
id
|
|
5108
|
-
);
|
|
5109
|
-
default:
|
|
5110
|
-
return null;
|
|
5111
|
-
}
|
|
5112
|
-
};
|
|
5113
|
-
const renderComponent = (component) => {
|
|
5114
|
-
const { type } = component;
|
|
5115
|
-
const isAtom = [
|
|
5116
|
-
"layout",
|
|
5117
|
-
"card",
|
|
5118
|
-
"text",
|
|
5119
|
-
"button",
|
|
5120
|
-
"input",
|
|
5121
|
-
"badge",
|
|
5122
|
-
"avatar",
|
|
5123
|
-
"progress",
|
|
5124
|
-
"skeleton",
|
|
5125
|
-
"alert",
|
|
5126
|
-
"separator",
|
|
5127
|
-
"table",
|
|
5128
|
-
"tabs",
|
|
5129
|
-
"accordion",
|
|
5130
|
-
"scroll-area",
|
|
5131
|
-
"carousel",
|
|
5132
|
-
"aspect-ratio",
|
|
5133
|
-
"collapsible",
|
|
5134
|
-
"tooltip",
|
|
5135
|
-
"popover",
|
|
5136
|
-
"dialog",
|
|
5137
|
-
"sheet",
|
|
5138
|
-
"alert-dialog",
|
|
5139
|
-
"breadcrumb",
|
|
5140
|
-
"spinner",
|
|
5141
|
-
"calendar",
|
|
5142
|
-
"pagination",
|
|
5143
|
-
"command"
|
|
5144
|
-
].includes(type);
|
|
5145
|
-
if (isAtom) {
|
|
5146
|
-
return renderAtom(component, renderComponent);
|
|
4973
|
+
if (!component) return null;
|
|
4974
|
+
const { type, name, props = {}, children = [], id } = component;
|
|
4975
|
+
const componentName = name || type;
|
|
4976
|
+
if (!componentName) return null;
|
|
4977
|
+
const normalizedName = componentName.charAt(0).toUpperCase() + componentName.slice(1);
|
|
4978
|
+
const atomName = normalizedName.endsWith("Atom") ? normalizedName : `${normalizedName}Atom`;
|
|
4979
|
+
const TargetComponent = atoms_exports[atomName] || atoms_exports[normalizedName] || atoms_exports[componentName] || molecules_exports[normalizedName] || molecules_exports[componentName];
|
|
4980
|
+
if (!TargetComponent) {
|
|
4981
|
+
console.warn(`[PXEngineRenderer] Component not found: ${componentName}`);
|
|
4982
|
+
return /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)(
|
|
4983
|
+
"div",
|
|
4984
|
+
{
|
|
4985
|
+
className: "p-2 border border-dashed border-red-500/50 text-red-500 text-[10px] rounded",
|
|
4986
|
+
children: [
|
|
4987
|
+
"Unknown: ",
|
|
4988
|
+
componentName
|
|
4989
|
+
]
|
|
4990
|
+
},
|
|
4991
|
+
id
|
|
4992
|
+
);
|
|
5147
4993
|
}
|
|
5148
|
-
return
|
|
4994
|
+
return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
|
|
4995
|
+
TargetComponent,
|
|
4996
|
+
{
|
|
4997
|
+
...props,
|
|
4998
|
+
onAction,
|
|
4999
|
+
renderComponent: renderRecursive,
|
|
5000
|
+
children: Array.isArray(children) ? children : void 0,
|
|
5001
|
+
children: Array.isArray(children) ? children.map((child, idx) => /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(import_react25.default.Fragment, { children: renderRecursive(child) }, idx)) : typeof children === "string" ? children : null
|
|
5002
|
+
},
|
|
5003
|
+
id || Math.random().toString(36).substr(2, 9)
|
|
5004
|
+
);
|
|
5149
5005
|
};
|
|
5150
|
-
return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
|
|
5006
|
+
return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)("div", { className: "px-engine-root", children: renderRecursive(root) });
|
|
5151
5007
|
};
|
|
5152
5008
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5153
5009
|
0 && (module.exports = {
|
package/dist/index.d.cts
CHANGED
|
@@ -723,16 +723,16 @@ interface UISchema {
|
|
|
723
723
|
root: UIComponent;
|
|
724
724
|
}
|
|
725
725
|
|
|
726
|
-
interface PXEngineRendererProps {
|
|
727
|
-
schema: UISchema | UIComponent;
|
|
728
|
-
onAction?: (action: string, payload?: any) => void;
|
|
729
|
-
}
|
|
730
726
|
/**
|
|
731
727
|
* PXEngineRenderer
|
|
732
728
|
*
|
|
733
|
-
*
|
|
734
|
-
*
|
|
729
|
+
* Handles both the full schema { version, root } and individual components.
|
|
730
|
+
* Dynamically resolves components from the Atoms/Molecules registry.
|
|
735
731
|
*/
|
|
732
|
+
interface PXEngineRendererProps {
|
|
733
|
+
schema: UISchema | UIComponent;
|
|
734
|
+
onAction?: (action: string, payload?: any) => void;
|
|
735
|
+
}
|
|
736
736
|
declare const PXEngineRenderer: React__default.FC<PXEngineRendererProps>;
|
|
737
737
|
|
|
738
738
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -723,16 +723,16 @@ interface UISchema {
|
|
|
723
723
|
root: UIComponent;
|
|
724
724
|
}
|
|
725
725
|
|
|
726
|
-
interface PXEngineRendererProps {
|
|
727
|
-
schema: UISchema | UIComponent;
|
|
728
|
-
onAction?: (action: string, payload?: any) => void;
|
|
729
|
-
}
|
|
730
726
|
/**
|
|
731
727
|
* PXEngineRenderer
|
|
732
728
|
*
|
|
733
|
-
*
|
|
734
|
-
*
|
|
729
|
+
* Handles both the full schema { version, root } and individual components.
|
|
730
|
+
* Dynamically resolves components from the Atoms/Molecules registry.
|
|
735
731
|
*/
|
|
732
|
+
interface PXEngineRendererProps {
|
|
733
|
+
schema: UISchema | UIComponent;
|
|
734
|
+
onAction?: (action: string, payload?: any) => void;
|
|
735
|
+
}
|
|
736
736
|
declare const PXEngineRenderer: React__default.FC<PXEngineRendererProps>;
|
|
737
737
|
|
|
738
738
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __export = (target, all) => {
|
|
3
|
+
for (var name in all)
|
|
4
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
|
+
};
|
|
6
|
+
|
|
1
7
|
// src/components/ui/button.tsx
|
|
2
8
|
import * as React from "react";
|
|
3
9
|
import { Slot } from "@radix-ui/react-slot";
|
|
@@ -2774,6 +2780,42 @@ function Spinner({ className, ...props }) {
|
|
|
2774
2780
|
);
|
|
2775
2781
|
}
|
|
2776
2782
|
|
|
2783
|
+
// src/render/PXEngineRenderer.tsx
|
|
2784
|
+
import React58 from "react";
|
|
2785
|
+
|
|
2786
|
+
// src/atoms/index.ts
|
|
2787
|
+
var atoms_exports = {};
|
|
2788
|
+
__export(atoms_exports, {
|
|
2789
|
+
AccordionAtom: () => AccordionAtom,
|
|
2790
|
+
AlertAtom: () => AlertAtom,
|
|
2791
|
+
AlertDialogAtom: () => AlertDialogAtom,
|
|
2792
|
+
AspectRatioAtom: () => AspectRatioAtom,
|
|
2793
|
+
AvatarAtom: () => AvatarAtom,
|
|
2794
|
+
BadgeAtom: () => BadgeAtom,
|
|
2795
|
+
BreadcrumbAtom: () => BreadcrumbAtom,
|
|
2796
|
+
ButtonAtom: () => ButtonAtom,
|
|
2797
|
+
CalendarAtom: () => CalendarAtom,
|
|
2798
|
+
CardAtom: () => CardAtom,
|
|
2799
|
+
CarouselAtom: () => CarouselAtom,
|
|
2800
|
+
CollapsibleAtom: () => CollapsibleAtom,
|
|
2801
|
+
CommandAtom: () => CommandAtom,
|
|
2802
|
+
DialogAtom: () => DialogAtom,
|
|
2803
|
+
InputAtom: () => InputAtom,
|
|
2804
|
+
LayoutAtom: () => LayoutAtom,
|
|
2805
|
+
PaginationAtom: () => PaginationAtom,
|
|
2806
|
+
PopoverAtom: () => PopoverAtom,
|
|
2807
|
+
ProgressAtom: () => ProgressAtom,
|
|
2808
|
+
ScrollAreaAtom: () => ScrollAreaAtom,
|
|
2809
|
+
SeparatorAtom: () => SeparatorAtom,
|
|
2810
|
+
SheetAtom: () => SheetAtom,
|
|
2811
|
+
SkeletonAtom: () => SkeletonAtom,
|
|
2812
|
+
SpinnerAtom: () => SpinnerAtom,
|
|
2813
|
+
TableAtom: () => TableAtom,
|
|
2814
|
+
TabsAtom: () => TabsAtom,
|
|
2815
|
+
TextAtom: () => TextAtom,
|
|
2816
|
+
TooltipAtom: () => TooltipAtom
|
|
2817
|
+
});
|
|
2818
|
+
|
|
2777
2819
|
// src/atoms/TextAtom.tsx
|
|
2778
2820
|
import { jsx as jsx41 } from "react/jsx-runtime";
|
|
2779
2821
|
var TextAtom = ({
|
|
@@ -3514,6 +3556,23 @@ var CommandAtom = ({
|
|
|
3514
3556
|
);
|
|
3515
3557
|
};
|
|
3516
3558
|
|
|
3559
|
+
// src/molecules/index.ts
|
|
3560
|
+
var molecules_exports = {};
|
|
3561
|
+
__export(molecules_exports, {
|
|
3562
|
+
ActionButton: () => ActionButton,
|
|
3563
|
+
CAMPAIGN_SEED_FIELDS: () => CAMPAIGN_SEED_FIELDS,
|
|
3564
|
+
CampaignSeedCard: () => CampaignSeedCard,
|
|
3565
|
+
CountrySelectDisplay: () => CountrySelectDisplay,
|
|
3566
|
+
CountrySelectEdit: () => CountrySelectEdit,
|
|
3567
|
+
EditableField: () => EditableField,
|
|
3568
|
+
FormCard: () => FormCard,
|
|
3569
|
+
KeywordBundlesDisplay: () => KeywordBundlesDisplay,
|
|
3570
|
+
KeywordBundlesEdit: () => KeywordBundlesEdit,
|
|
3571
|
+
MCQCard: () => MCQCard,
|
|
3572
|
+
SEARCH_SPEC_FIELDS: () => SEARCH_SPEC_FIELDS,
|
|
3573
|
+
SearchSpecCard: () => SearchSpecCard
|
|
3574
|
+
});
|
|
3575
|
+
|
|
3517
3576
|
// src/molecules/generic/EditableField/EditableField.tsx
|
|
3518
3577
|
import React52, { useState as useState2, useEffect as useEffect3, useRef as useRef2 } from "react";
|
|
3519
3578
|
import { jsx as jsx69, jsxs as jsxs37 } from "react/jsx-runtime";
|
|
@@ -4657,248 +4716,51 @@ var MCQCard = React57.memo(
|
|
|
4657
4716
|
MCQCard.displayName = "MCQCard";
|
|
4658
4717
|
|
|
4659
4718
|
// src/render/PXEngineRenderer.tsx
|
|
4660
|
-
import {
|
|
4719
|
+
import { jsx as jsx76, jsxs as jsxs44 } from "react/jsx-runtime";
|
|
4661
4720
|
var PXEngineRenderer = ({
|
|
4662
4721
|
schema,
|
|
4663
4722
|
onAction
|
|
4664
4723
|
}) => {
|
|
4665
|
-
|
|
4666
|
-
const
|
|
4667
|
-
|
|
4668
|
-
|
|
4669
|
-
|
|
4670
|
-
return /* @__PURE__ */ jsx76(
|
|
4671
|
-
LayoutAtom,
|
|
4672
|
-
{
|
|
4673
|
-
...atom,
|
|
4674
|
-
renderComponent: renderComponent2
|
|
4675
|
-
},
|
|
4676
|
-
id
|
|
4677
|
-
);
|
|
4678
|
-
case "card":
|
|
4679
|
-
return /* @__PURE__ */ jsx76(
|
|
4680
|
-
CardAtom,
|
|
4681
|
-
{
|
|
4682
|
-
...atom,
|
|
4683
|
-
renderComponent: renderComponent2
|
|
4684
|
-
},
|
|
4685
|
-
id
|
|
4686
|
-
);
|
|
4687
|
-
case "text":
|
|
4688
|
-
return /* @__PURE__ */ jsx76(TextAtom, { ...atom }, id);
|
|
4689
|
-
case "button":
|
|
4690
|
-
return /* @__PURE__ */ jsx76(ButtonAtom, { ...atom, onAction }, id);
|
|
4691
|
-
case "input":
|
|
4692
|
-
return /* @__PURE__ */ jsx76(InputAtom, { ...atom }, id);
|
|
4693
|
-
case "badge":
|
|
4694
|
-
return /* @__PURE__ */ jsx76(BadgeAtom, { ...atom }, id);
|
|
4695
|
-
case "avatar":
|
|
4696
|
-
return /* @__PURE__ */ jsx76(AvatarAtom, { ...atom }, id);
|
|
4697
|
-
case "progress":
|
|
4698
|
-
return /* @__PURE__ */ jsx76(ProgressAtom, { ...atom }, id);
|
|
4699
|
-
case "skeleton":
|
|
4700
|
-
return /* @__PURE__ */ jsx76(SkeletonAtom, { ...atom }, id);
|
|
4701
|
-
case "alert":
|
|
4702
|
-
return /* @__PURE__ */ jsx76(AlertAtom, { ...atom }, id);
|
|
4703
|
-
case "separator":
|
|
4704
|
-
return /* @__PURE__ */ jsx76(SeparatorAtom, { ...atom }, id);
|
|
4705
|
-
case "table":
|
|
4706
|
-
return /* @__PURE__ */ jsx76(TableAtom, { ...atom }, id);
|
|
4707
|
-
case "tabs":
|
|
4708
|
-
return /* @__PURE__ */ jsx76(
|
|
4709
|
-
TabsAtom,
|
|
4710
|
-
{
|
|
4711
|
-
...atom,
|
|
4712
|
-
renderComponent: renderComponent2
|
|
4713
|
-
},
|
|
4714
|
-
id
|
|
4715
|
-
);
|
|
4716
|
-
case "accordion":
|
|
4717
|
-
return /* @__PURE__ */ jsx76(
|
|
4718
|
-
AccordionAtom,
|
|
4719
|
-
{
|
|
4720
|
-
...atom,
|
|
4721
|
-
renderComponent: renderComponent2
|
|
4722
|
-
},
|
|
4723
|
-
id
|
|
4724
|
-
);
|
|
4725
|
-
case "scroll-area":
|
|
4726
|
-
return /* @__PURE__ */ jsx76(
|
|
4727
|
-
ScrollAreaAtom,
|
|
4728
|
-
{
|
|
4729
|
-
...atom,
|
|
4730
|
-
renderComponent: renderComponent2
|
|
4731
|
-
},
|
|
4732
|
-
id
|
|
4733
|
-
);
|
|
4734
|
-
case "carousel":
|
|
4735
|
-
return /* @__PURE__ */ jsx76(
|
|
4736
|
-
CarouselAtom,
|
|
4737
|
-
{
|
|
4738
|
-
...atom,
|
|
4739
|
-
renderComponent: renderComponent2
|
|
4740
|
-
},
|
|
4741
|
-
id
|
|
4742
|
-
);
|
|
4743
|
-
case "aspect-ratio":
|
|
4744
|
-
return /* @__PURE__ */ jsx76(
|
|
4745
|
-
AspectRatioAtom,
|
|
4746
|
-
{
|
|
4747
|
-
...atom,
|
|
4748
|
-
renderComponent: renderComponent2
|
|
4749
|
-
},
|
|
4750
|
-
id
|
|
4751
|
-
);
|
|
4752
|
-
case "collapsible":
|
|
4753
|
-
return /* @__PURE__ */ jsx76(
|
|
4754
|
-
CollapsibleAtom,
|
|
4755
|
-
{
|
|
4756
|
-
...atom,
|
|
4757
|
-
renderComponent: renderComponent2
|
|
4758
|
-
},
|
|
4759
|
-
id
|
|
4760
|
-
);
|
|
4761
|
-
case "tooltip":
|
|
4762
|
-
return /* @__PURE__ */ jsx76(
|
|
4763
|
-
TooltipAtom,
|
|
4764
|
-
{
|
|
4765
|
-
...atom,
|
|
4766
|
-
renderComponent: renderComponent2
|
|
4767
|
-
},
|
|
4768
|
-
id
|
|
4769
|
-
);
|
|
4770
|
-
case "popover":
|
|
4771
|
-
return /* @__PURE__ */ jsx76(
|
|
4772
|
-
PopoverAtom,
|
|
4773
|
-
{
|
|
4774
|
-
...atom,
|
|
4775
|
-
renderComponent: renderComponent2
|
|
4776
|
-
},
|
|
4777
|
-
id
|
|
4778
|
-
);
|
|
4779
|
-
case "dialog":
|
|
4780
|
-
return /* @__PURE__ */ jsx76(
|
|
4781
|
-
DialogAtom,
|
|
4782
|
-
{
|
|
4783
|
-
...atom,
|
|
4784
|
-
renderComponent: renderComponent2
|
|
4785
|
-
},
|
|
4786
|
-
id
|
|
4787
|
-
);
|
|
4788
|
-
case "sheet":
|
|
4789
|
-
return /* @__PURE__ */ jsx76(
|
|
4790
|
-
SheetAtom,
|
|
4791
|
-
{
|
|
4792
|
-
...atom,
|
|
4793
|
-
renderComponent: renderComponent2
|
|
4794
|
-
},
|
|
4795
|
-
id
|
|
4796
|
-
);
|
|
4797
|
-
case "alert-dialog":
|
|
4798
|
-
return /* @__PURE__ */ jsx76(
|
|
4799
|
-
AlertDialogAtom,
|
|
4800
|
-
{
|
|
4801
|
-
...atom,
|
|
4802
|
-
onAction,
|
|
4803
|
-
renderComponent: renderComponent2
|
|
4804
|
-
},
|
|
4805
|
-
id
|
|
4806
|
-
);
|
|
4807
|
-
case "breadcrumb":
|
|
4808
|
-
return /* @__PURE__ */ jsx76(BreadcrumbAtom, { ...atom }, id);
|
|
4809
|
-
case "spinner":
|
|
4810
|
-
return /* @__PURE__ */ jsx76(SpinnerAtom, { ...atom }, id);
|
|
4811
|
-
case "calendar":
|
|
4812
|
-
return /* @__PURE__ */ jsx76(CalendarAtom, { ...atom }, id);
|
|
4813
|
-
case "pagination":
|
|
4814
|
-
return /* @__PURE__ */ jsx76(PaginationAtom, { ...atom }, id);
|
|
4815
|
-
case "command":
|
|
4816
|
-
return /* @__PURE__ */ jsx76(CommandAtom, { ...atom }, id);
|
|
4817
|
-
default:
|
|
4818
|
-
return null;
|
|
4819
|
-
}
|
|
4820
|
-
};
|
|
4821
|
-
const renderMolecule = (molecule) => {
|
|
4822
|
-
const { type, id } = molecule;
|
|
4823
|
-
switch (type) {
|
|
4824
|
-
case "campaign-seed":
|
|
4825
|
-
return /* @__PURE__ */ jsx76(
|
|
4826
|
-
CampaignSeedCard,
|
|
4827
|
-
{
|
|
4828
|
-
...molecule,
|
|
4829
|
-
onProceed: () => onAction?.(molecule.proceedAction || "proceed")
|
|
4830
|
-
},
|
|
4831
|
-
id
|
|
4832
|
-
);
|
|
4833
|
-
case "search-spec":
|
|
4834
|
-
return /* @__PURE__ */ jsx76(
|
|
4835
|
-
SearchSpecCard,
|
|
4836
|
-
{
|
|
4837
|
-
...molecule,
|
|
4838
|
-
onProceed: () => onAction?.(molecule.proceedAction || "proceed")
|
|
4839
|
-
},
|
|
4840
|
-
id
|
|
4841
|
-
);
|
|
4842
|
-
case "mcq":
|
|
4843
|
-
return /* @__PURE__ */ jsx76(
|
|
4844
|
-
MCQCard,
|
|
4845
|
-
{
|
|
4846
|
-
...molecule,
|
|
4847
|
-
onProceed: () => onAction?.(molecule.proceedAction || "proceed")
|
|
4848
|
-
},
|
|
4849
|
-
id
|
|
4850
|
-
);
|
|
4851
|
-
case "action-button":
|
|
4852
|
-
return /* @__PURE__ */ jsx76(
|
|
4853
|
-
ActionButton,
|
|
4854
|
-
{
|
|
4855
|
-
...molecule,
|
|
4856
|
-
onProceed: () => onAction?.(molecule.action || "proceed")
|
|
4857
|
-
},
|
|
4858
|
-
id
|
|
4859
|
-
);
|
|
4860
|
-
default:
|
|
4861
|
-
return null;
|
|
4724
|
+
if (!schema) return null;
|
|
4725
|
+
const root = schema.root || schema;
|
|
4726
|
+
const renderRecursive = (component) => {
|
|
4727
|
+
if (typeof component === "string" || typeof component === "number") {
|
|
4728
|
+
return component;
|
|
4862
4729
|
}
|
|
4863
|
-
|
|
4864
|
-
|
|
4865
|
-
const
|
|
4866
|
-
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
|
|
4872
|
-
|
|
4873
|
-
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
|
|
4879
|
-
|
|
4880
|
-
|
|
4881
|
-
|
|
4882
|
-
|
|
4883
|
-
"aspect-ratio",
|
|
4884
|
-
"collapsible",
|
|
4885
|
-
"tooltip",
|
|
4886
|
-
"popover",
|
|
4887
|
-
"dialog",
|
|
4888
|
-
"sheet",
|
|
4889
|
-
"alert-dialog",
|
|
4890
|
-
"breadcrumb",
|
|
4891
|
-
"spinner",
|
|
4892
|
-
"calendar",
|
|
4893
|
-
"pagination",
|
|
4894
|
-
"command"
|
|
4895
|
-
].includes(type);
|
|
4896
|
-
if (isAtom) {
|
|
4897
|
-
return renderAtom(component, renderComponent);
|
|
4730
|
+
if (!component) return null;
|
|
4731
|
+
const { type, name, props = {}, children = [], id } = component;
|
|
4732
|
+
const componentName = name || type;
|
|
4733
|
+
if (!componentName) return null;
|
|
4734
|
+
const normalizedName = componentName.charAt(0).toUpperCase() + componentName.slice(1);
|
|
4735
|
+
const atomName = normalizedName.endsWith("Atom") ? normalizedName : `${normalizedName}Atom`;
|
|
4736
|
+
const TargetComponent = atoms_exports[atomName] || atoms_exports[normalizedName] || atoms_exports[componentName] || molecules_exports[normalizedName] || molecules_exports[componentName];
|
|
4737
|
+
if (!TargetComponent) {
|
|
4738
|
+
console.warn(`[PXEngineRenderer] Component not found: ${componentName}`);
|
|
4739
|
+
return /* @__PURE__ */ jsxs44(
|
|
4740
|
+
"div",
|
|
4741
|
+
{
|
|
4742
|
+
className: "p-2 border border-dashed border-red-500/50 text-red-500 text-[10px] rounded",
|
|
4743
|
+
children: [
|
|
4744
|
+
"Unknown: ",
|
|
4745
|
+
componentName
|
|
4746
|
+
]
|
|
4747
|
+
},
|
|
4748
|
+
id
|
|
4749
|
+
);
|
|
4898
4750
|
}
|
|
4899
|
-
return
|
|
4751
|
+
return /* @__PURE__ */ jsx76(
|
|
4752
|
+
TargetComponent,
|
|
4753
|
+
{
|
|
4754
|
+
...props,
|
|
4755
|
+
onAction,
|
|
4756
|
+
renderComponent: renderRecursive,
|
|
4757
|
+
children: Array.isArray(children) ? children : void 0,
|
|
4758
|
+
children: Array.isArray(children) ? children.map((child, idx) => /* @__PURE__ */ jsx76(React58.Fragment, { children: renderRecursive(child) }, idx)) : typeof children === "string" ? children : null
|
|
4759
|
+
},
|
|
4760
|
+
id || Math.random().toString(36).substr(2, 9)
|
|
4761
|
+
);
|
|
4900
4762
|
};
|
|
4901
|
-
return /* @__PURE__ */ jsx76(
|
|
4763
|
+
return /* @__PURE__ */ jsx76("div", { className: "px-engine-root", children: renderRecursive(root) });
|
|
4902
4764
|
};
|
|
4903
4765
|
export {
|
|
4904
4766
|
Accordion,
|
package/dist/registry.json
CHANGED
package/package.json
CHANGED
|
@@ -1,272 +1,94 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { UIComponent, UISchema
|
|
2
|
+
import { UIComponent, UISchema } from "../types/schema";
|
|
3
3
|
import * as Atoms from "../atoms";
|
|
4
|
-
import * as Molecules from "../molecules/index";
|
|
5
|
-
|
|
6
|
-
// NOTE: This renderer will be used by the frontend to interpret JSON schemas
|
|
7
|
-
// generated by the AI agent via the MCP server.
|
|
4
|
+
import * as Molecules from "../molecules/index";
|
|
8
5
|
|
|
6
|
+
/**
|
|
7
|
+
* PXEngineRenderer
|
|
8
|
+
*
|
|
9
|
+
* Handles both the full schema { version, root } and individual components.
|
|
10
|
+
* Dynamically resolves components from the Atoms/Molecules registry.
|
|
11
|
+
*/
|
|
9
12
|
interface PXEngineRendererProps {
|
|
10
13
|
schema: UISchema | UIComponent;
|
|
11
14
|
onAction?: (action: string, payload?: any) => void;
|
|
12
15
|
}
|
|
13
16
|
|
|
14
|
-
/**
|
|
15
|
-
* PXEngineRenderer
|
|
16
|
-
*
|
|
17
|
-
* The core engine of the @pxengine-ui library.
|
|
18
|
-
* Recursively renders Atoms and Molecules based on the provided JSON schema.
|
|
19
|
-
*/
|
|
20
17
|
export const PXEngineRenderer: React.FC<PXEngineRendererProps> = ({
|
|
21
18
|
schema,
|
|
22
19
|
onAction,
|
|
23
20
|
}) => {
|
|
24
|
-
|
|
25
|
-
const root = "root" in schema ? schema.root : schema;
|
|
21
|
+
if (!schema) return null;
|
|
26
22
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
*/
|
|
30
|
-
const renderAtom = (
|
|
31
|
-
atom: UIAtom,
|
|
32
|
-
renderComponent: (c: UIComponent) => React.ReactNode,
|
|
33
|
-
): React.ReactNode => {
|
|
34
|
-
const { type, id } = atom;
|
|
23
|
+
// Extract root if it's a full UISchema
|
|
24
|
+
const root = (schema as any).root || (schema as UIComponent);
|
|
35
25
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
renderComponent={renderComponent}
|
|
43
|
-
/>
|
|
44
|
-
);
|
|
45
|
-
case "card":
|
|
46
|
-
return (
|
|
47
|
-
<Atoms.CardAtom
|
|
48
|
-
key={id}
|
|
49
|
-
{...(atom as any)}
|
|
50
|
-
renderComponent={renderComponent}
|
|
51
|
-
/>
|
|
52
|
-
);
|
|
53
|
-
case "text":
|
|
54
|
-
return <Atoms.TextAtom key={id} {...(atom as any)} />;
|
|
55
|
-
case "button":
|
|
56
|
-
return (
|
|
57
|
-
<Atoms.ButtonAtom key={id} {...(atom as any)} onAction={onAction} />
|
|
58
|
-
);
|
|
59
|
-
case "input":
|
|
60
|
-
return <Atoms.InputAtom key={id} {...(atom as any)} />;
|
|
61
|
-
case "badge":
|
|
62
|
-
return <Atoms.BadgeAtom key={id} {...(atom as any)} />;
|
|
63
|
-
case "avatar":
|
|
64
|
-
return <Atoms.AvatarAtom key={id} {...(atom as any)} />;
|
|
65
|
-
case "progress":
|
|
66
|
-
return <Atoms.ProgressAtom key={id} {...(atom as any)} />;
|
|
67
|
-
case "skeleton":
|
|
68
|
-
return <Atoms.SkeletonAtom key={id} {...(atom as any)} />;
|
|
69
|
-
case "alert":
|
|
70
|
-
return <Atoms.AlertAtom key={id} {...(atom as any)} />;
|
|
71
|
-
case "separator":
|
|
72
|
-
return <Atoms.SeparatorAtom key={id} {...(atom as any)} />;
|
|
73
|
-
case "table":
|
|
74
|
-
return <Atoms.TableAtom key={id} {...(atom as any)} />;
|
|
75
|
-
case "tabs":
|
|
76
|
-
return (
|
|
77
|
-
<Atoms.TabsAtom
|
|
78
|
-
key={id}
|
|
79
|
-
{...(atom as any)}
|
|
80
|
-
renderComponent={renderComponent}
|
|
81
|
-
/>
|
|
82
|
-
);
|
|
83
|
-
case "accordion":
|
|
84
|
-
return (
|
|
85
|
-
<Atoms.AccordionAtom
|
|
86
|
-
key={id}
|
|
87
|
-
{...(atom as any)}
|
|
88
|
-
renderComponent={renderComponent}
|
|
89
|
-
/>
|
|
90
|
-
);
|
|
91
|
-
case "scroll-area":
|
|
92
|
-
return (
|
|
93
|
-
<Atoms.ScrollAreaAtom
|
|
94
|
-
key={id}
|
|
95
|
-
{...(atom as any)}
|
|
96
|
-
renderComponent={renderComponent}
|
|
97
|
-
/>
|
|
98
|
-
);
|
|
99
|
-
case "carousel":
|
|
100
|
-
return (
|
|
101
|
-
<Atoms.CarouselAtom
|
|
102
|
-
key={id}
|
|
103
|
-
{...(atom as any)}
|
|
104
|
-
renderComponent={renderComponent}
|
|
105
|
-
/>
|
|
106
|
-
);
|
|
107
|
-
case "aspect-ratio":
|
|
108
|
-
return (
|
|
109
|
-
<Atoms.AspectRatioAtom
|
|
110
|
-
key={id}
|
|
111
|
-
{...(atom as any)}
|
|
112
|
-
renderComponent={renderComponent}
|
|
113
|
-
/>
|
|
114
|
-
);
|
|
115
|
-
case "collapsible":
|
|
116
|
-
return (
|
|
117
|
-
<Atoms.CollapsibleAtom
|
|
118
|
-
key={id}
|
|
119
|
-
{...(atom as any)}
|
|
120
|
-
renderComponent={renderComponent}
|
|
121
|
-
/>
|
|
122
|
-
);
|
|
123
|
-
case "tooltip":
|
|
124
|
-
return (
|
|
125
|
-
<Atoms.TooltipAtom
|
|
126
|
-
key={id}
|
|
127
|
-
{...(atom as any)}
|
|
128
|
-
renderComponent={renderComponent}
|
|
129
|
-
/>
|
|
130
|
-
);
|
|
131
|
-
case "popover":
|
|
132
|
-
return (
|
|
133
|
-
<Atoms.PopoverAtom
|
|
134
|
-
key={id}
|
|
135
|
-
{...(atom as any)}
|
|
136
|
-
renderComponent={renderComponent}
|
|
137
|
-
/>
|
|
138
|
-
);
|
|
139
|
-
case "dialog":
|
|
140
|
-
return (
|
|
141
|
-
<Atoms.DialogAtom
|
|
142
|
-
key={id}
|
|
143
|
-
{...(atom as any)}
|
|
144
|
-
renderComponent={renderComponent}
|
|
145
|
-
/>
|
|
146
|
-
);
|
|
147
|
-
case "sheet":
|
|
148
|
-
return (
|
|
149
|
-
<Atoms.SheetAtom
|
|
150
|
-
key={id}
|
|
151
|
-
{...(atom as any)}
|
|
152
|
-
renderComponent={renderComponent}
|
|
153
|
-
/>
|
|
154
|
-
);
|
|
155
|
-
case "alert-dialog":
|
|
156
|
-
return (
|
|
157
|
-
<Atoms.AlertDialogAtom
|
|
158
|
-
key={id}
|
|
159
|
-
{...(atom as any)}
|
|
160
|
-
onAction={onAction}
|
|
161
|
-
renderComponent={renderComponent}
|
|
162
|
-
/>
|
|
163
|
-
);
|
|
164
|
-
case "breadcrumb":
|
|
165
|
-
return <Atoms.BreadcrumbAtom key={id} {...(atom as any)} />;
|
|
166
|
-
case "spinner":
|
|
167
|
-
return <Atoms.SpinnerAtom key={id} {...(atom as any)} />;
|
|
168
|
-
case "calendar":
|
|
169
|
-
return <Atoms.CalendarAtom key={id} {...(atom as any)} />;
|
|
170
|
-
case "pagination":
|
|
171
|
-
return <Atoms.PaginationAtom key={id} {...(atom as any)} />;
|
|
172
|
-
case "command":
|
|
173
|
-
return <Atoms.CommandAtom key={id} {...(atom as any)} />;
|
|
174
|
-
default:
|
|
175
|
-
return null;
|
|
26
|
+
const renderRecursive = (
|
|
27
|
+
component: UIComponent | string | any,
|
|
28
|
+
): React.ReactNode => {
|
|
29
|
+
// 1. Handle text nodes (string or number)
|
|
30
|
+
if (typeof component === "string" || typeof component === "number") {
|
|
31
|
+
return component;
|
|
176
32
|
}
|
|
177
|
-
};
|
|
178
33
|
|
|
179
|
-
|
|
180
|
-
* Render Molecule components (Domain-specific / Complex)
|
|
181
|
-
*/
|
|
182
|
-
const renderMolecule = (molecule: UIMolecule): React.ReactNode => {
|
|
183
|
-
const { type, id } = molecule;
|
|
34
|
+
if (!component) return null;
|
|
184
35
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
{...(molecule as any)}
|
|
191
|
-
onProceed={() =>
|
|
192
|
-
onAction?.((molecule as any).proceedAction || "proceed")
|
|
193
|
-
}
|
|
194
|
-
/>
|
|
195
|
-
);
|
|
196
|
-
case "search-spec":
|
|
197
|
-
return (
|
|
198
|
-
<Molecules.SearchSpecCard
|
|
199
|
-
key={id}
|
|
200
|
-
{...(molecule as any)}
|
|
201
|
-
onProceed={() =>
|
|
202
|
-
onAction?.((molecule as any).proceedAction || "proceed")
|
|
203
|
-
}
|
|
204
|
-
/>
|
|
205
|
-
);
|
|
206
|
-
case "mcq":
|
|
207
|
-
return (
|
|
208
|
-
<Molecules.MCQCard
|
|
209
|
-
key={id}
|
|
210
|
-
{...(molecule as any)}
|
|
211
|
-
onProceed={() =>
|
|
212
|
-
onAction?.((molecule as any).proceedAction || "proceed")
|
|
213
|
-
}
|
|
214
|
-
/>
|
|
215
|
-
);
|
|
216
|
-
case "action-button":
|
|
217
|
-
return (
|
|
218
|
-
<Molecules.ActionButton
|
|
219
|
-
key={id}
|
|
220
|
-
{...(molecule as any)}
|
|
221
|
-
onProceed={() => onAction?.((molecule as any).action || "proceed")}
|
|
222
|
-
/>
|
|
223
|
-
);
|
|
224
|
-
default:
|
|
225
|
-
return null;
|
|
226
|
-
}
|
|
227
|
-
};
|
|
36
|
+
const { type, name, props = {}, children = [], id } = component;
|
|
37
|
+
|
|
38
|
+
// Determine the component name to search for
|
|
39
|
+
const componentName = name || type;
|
|
40
|
+
if (!componentName) return null;
|
|
228
41
|
|
|
229
|
-
|
|
230
|
-
const
|
|
42
|
+
// Normalize name to PascalCase and check for "Atom" suffix
|
|
43
|
+
const normalizedName =
|
|
44
|
+
componentName.charAt(0).toUpperCase() + componentName.slice(1);
|
|
45
|
+
const atomName = normalizedName.endsWith("Atom")
|
|
46
|
+
? normalizedName
|
|
47
|
+
: `${normalizedName}Atom`;
|
|
231
48
|
|
|
232
|
-
//
|
|
233
|
-
const
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
"badge",
|
|
240
|
-
"avatar",
|
|
241
|
-
"progress",
|
|
242
|
-
"skeleton",
|
|
243
|
-
"alert",
|
|
244
|
-
"separator",
|
|
245
|
-
"table",
|
|
246
|
-
"tabs",
|
|
247
|
-
"accordion",
|
|
248
|
-
"scroll-area",
|
|
249
|
-
"carousel",
|
|
250
|
-
"aspect-ratio",
|
|
251
|
-
"collapsible",
|
|
252
|
-
"tooltip",
|
|
253
|
-
"popover",
|
|
254
|
-
"dialog",
|
|
255
|
-
"sheet",
|
|
256
|
-
"alert-dialog",
|
|
257
|
-
"breadcrumb",
|
|
258
|
-
"spinner",
|
|
259
|
-
"calendar",
|
|
260
|
-
"pagination",
|
|
261
|
-
"command",
|
|
262
|
-
].includes(type);
|
|
49
|
+
// 2. Resolve Component from library registry
|
|
50
|
+
const TargetComponent =
|
|
51
|
+
(Atoms as any)[atomName] ||
|
|
52
|
+
(Atoms as any)[normalizedName] ||
|
|
53
|
+
(Atoms as any)[componentName] ||
|
|
54
|
+
(Molecules as any)[normalizedName] ||
|
|
55
|
+
(Molecules as any)[componentName];
|
|
263
56
|
|
|
264
|
-
if (
|
|
265
|
-
|
|
57
|
+
if (!TargetComponent) {
|
|
58
|
+
console.warn(`[PXEngineRenderer] Component not found: ${componentName}`);
|
|
59
|
+
return (
|
|
60
|
+
<div
|
|
61
|
+
key={id}
|
|
62
|
+
className="p-2 border border-dashed border-red-500/50 text-red-500 text-[10px] rounded"
|
|
63
|
+
>
|
|
64
|
+
Unknown: {componentName}
|
|
65
|
+
</div>
|
|
66
|
+
);
|
|
266
67
|
}
|
|
267
68
|
|
|
268
|
-
|
|
69
|
+
// 3. Render Component
|
|
70
|
+
// We pass 'renderComponent' for components that handle their own child rendering (like Layout/Card)
|
|
71
|
+
// We also pass children as props for standard React children behavior
|
|
72
|
+
return (
|
|
73
|
+
<TargetComponent
|
|
74
|
+
key={id || Math.random().toString(36).substr(2, 9)}
|
|
75
|
+
{...props}
|
|
76
|
+
onAction={onAction}
|
|
77
|
+
renderComponent={renderRecursive}
|
|
78
|
+
children={Array.isArray(children) ? children : undefined}
|
|
79
|
+
>
|
|
80
|
+
{Array.isArray(children)
|
|
81
|
+
? children.map((child, idx) => (
|
|
82
|
+
<React.Fragment key={idx}>
|
|
83
|
+
{renderRecursive(child)}
|
|
84
|
+
</React.Fragment>
|
|
85
|
+
))
|
|
86
|
+
: typeof children === "string"
|
|
87
|
+
? children
|
|
88
|
+
: null}
|
|
89
|
+
</TargetComponent>
|
|
90
|
+
);
|
|
269
91
|
};
|
|
270
92
|
|
|
271
|
-
return
|
|
93
|
+
return <div className="px-engine-root">{renderRecursive(root)}</div>;
|
|
272
94
|
};
|