pxengine 0.1.6 → 0.1.9

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 CHANGED
@@ -8384,16 +8384,17 @@ var FormInputAtom = ({
8384
8384
  className,
8385
8385
  id
8386
8386
  }) => {
8387
+ const fieldName = name || id || `input-${Math.random().toString(36).substring(2, 9)}`;
8387
8388
  const form = (0, import_react_hook_form2.useForm)({
8388
8389
  defaultValues: {
8389
- [name]: defaultValue
8390
+ [fieldName]: defaultValue
8390
8391
  }
8391
8392
  });
8392
8393
  return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(Form, { ...form, children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
8393
8394
  FormField,
8394
8395
  {
8395
8396
  control: form.control,
8396
- name,
8397
+ name: fieldName,
8397
8398
  rules: {
8398
8399
  required: required ? `${label || name} is required` : void 0
8399
8400
  },
@@ -8429,23 +8430,24 @@ var FormSelectAtom = ({
8429
8430
  className,
8430
8431
  id
8431
8432
  }) => {
8433
+ const fieldName = name || id || `select-${Math.random().toString(36).substring(2, 9)}`;
8432
8434
  const form = (0, import_react_hook_form3.useForm)({
8433
8435
  defaultValues: {
8434
- [name]: defaultValue
8436
+ [fieldName]: defaultValue
8435
8437
  }
8436
8438
  });
8437
8439
  return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Form, { ...form, children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
8438
8440
  FormField,
8439
8441
  {
8440
8442
  control: form.control,
8441
- name,
8443
+ name: fieldName,
8442
8444
  rules: {
8443
8445
  required: required ? `${label || name} is required` : void 0
8444
8446
  },
8445
8447
  render: ({ field }) => /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)(FormItem, { className: cn("w-full", className), children: [
8446
8448
  label && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(FormLabel, { children: label }),
8447
8449
  /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)(Select, { onValueChange: field.onChange, defaultValue: field.value, children: [
8448
- /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(FormControl, { children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(SelectTrigger, { id: id || `form-select-${name}`, children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(SelectValue, { placeholder }) }) }),
8450
+ /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(FormControl, { children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(SelectTrigger, { id: id || `form-select-${fieldName}`, children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(SelectValue, { placeholder }) }) }),
8449
8451
  /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(SelectContent, { children: options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(SelectItem, { value: option.value, children: option.label }, option.value)) })
8450
8452
  ] }),
8451
8453
  description && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(FormDescription, { children: description }),
@@ -8469,16 +8471,17 @@ var FormTextareaAtom = ({
8469
8471
  className,
8470
8472
  id
8471
8473
  }) => {
8474
+ const fieldName = name || id || `textarea-${Math.random().toString(36).substring(2, 9)}`;
8472
8475
  const form = (0, import_react_hook_form4.useForm)({
8473
8476
  defaultValues: {
8474
- [name]: defaultValue
8477
+ [fieldName]: defaultValue
8475
8478
  }
8476
8479
  });
8477
8480
  return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(Form, { ...form, children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
8478
8481
  FormField,
8479
8482
  {
8480
8483
  control: form.control,
8481
- name,
8484
+ name: fieldName,
8482
8485
  rules: {
8483
8486
  required: required ? `${label || name} is required` : void 0
8484
8487
  },
@@ -8489,7 +8492,7 @@ var FormTextareaAtom = ({
8489
8492
  {
8490
8493
  placeholder,
8491
8494
  rows,
8492
- id: id || `form-textarea-${name}`,
8495
+ id: id || `form-textarea-${fieldName}`,
8493
8496
  ...field
8494
8497
  }
8495
8498
  ) }),
@@ -11745,18 +11748,42 @@ var PXEngineRenderer = ({
11745
11748
  return component;
11746
11749
  }
11747
11750
  if (!component || typeof component !== "object") return null;
11748
- const { type, name, props = {}, children = [], id } = component;
11749
- const componentName = name || type;
11751
+ const {
11752
+ type,
11753
+ name,
11754
+ component: componentType,
11755
+ props = {},
11756
+ children = [],
11757
+ id,
11758
+ ...remainingProps
11759
+ } = component;
11760
+ const componentName = name || type || componentType;
11750
11761
  if (!componentName || typeof componentName !== "string") return null;
11762
+ const finalProps = { ...remainingProps, ...props };
11763
+ if (id && !finalProps.id) {
11764
+ finalProps.id = id;
11765
+ }
11751
11766
  const uniqueKey = id || `${componentName}-${index || Math.random().toString(36).substr(2, 9)}`;
11752
11767
  const normalizedName = componentName.charAt(0).toUpperCase() + componentName.slice(1);
11753
- const atomName = normalizedName.endsWith("Atom") ? normalizedName : `${normalizedName}Atom`;
11754
- let TargetComponent = atoms_exports[atomName] || atoms_exports[normalizedName] || atoms_exports[componentName];
11755
- if (!TargetComponent) {
11756
- TargetComponent = molecules_exports[normalizedName] || molecules_exports[componentName];
11757
- }
11758
- if (!TargetComponent && !CONTEXT_DEPENDENT_COMPONENTS.has(normalizedName)) {
11759
- TargetComponent = ui_exports[normalizedName] || ui_exports[componentName];
11768
+ const resolveComponent = (identifier) => {
11769
+ const normalized = identifier.charAt(0).toUpperCase() + identifier.slice(1);
11770
+ const atomName2 = normalized.endsWith("Atom") ? normalized : `${normalized}Atom`;
11771
+ let Comp = atoms_exports[atomName2] || atoms_exports[normalized] || atoms_exports[identifier];
11772
+ if (!Comp) {
11773
+ Comp = molecules_exports[normalized] || molecules_exports[identifier];
11774
+ }
11775
+ if (!Comp && !CONTEXT_DEPENDENT_COMPONENTS.has(normalized)) {
11776
+ Comp = ui_exports[normalized] || ui_exports[identifier];
11777
+ }
11778
+ return Comp;
11779
+ };
11780
+ let TargetComponent = resolveComponent(componentName);
11781
+ let resolvedIdentifier = componentName;
11782
+ if (!TargetComponent && type && type !== componentName) {
11783
+ TargetComponent = resolveComponent(type);
11784
+ if (TargetComponent) {
11785
+ resolvedIdentifier = type;
11786
+ }
11760
11787
  }
11761
11788
  if (!TargetComponent) {
11762
11789
  if (CONTEXT_DEPENDENT_COMPONENTS.has(normalizedName)) {
@@ -11777,12 +11804,14 @@ var PXEngineRenderer = ({
11777
11804
  return renderNotFoundError(componentName, uniqueKey);
11778
11805
  }
11779
11806
  }
11807
+ const resolvedNormalized = resolvedIdentifier.charAt(0).toUpperCase() + resolvedIdentifier.slice(1);
11808
+ const atomName = resolvedNormalized.endsWith("Atom") ? resolvedNormalized : `${resolvedNormalized}Atom`;
11780
11809
  const isAtomWithRenderProp = atomName in atoms_exports;
11781
11810
  if (isAtomWithRenderProp) {
11782
11811
  return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
11783
11812
  TargetComponent,
11784
11813
  {
11785
- ...props,
11814
+ ...finalProps,
11786
11815
  onAction,
11787
11816
  renderComponent: renderRecursive,
11788
11817
  children
@@ -11790,10 +11819,10 @@ var PXEngineRenderer = ({
11790
11819
  uniqueKey
11791
11820
  );
11792
11821
  } else {
11793
- return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(TargetComponent, { ...props, children: Array.isArray(children) ? children.map((child, idx) => renderRecursive(child, idx)) : children }, uniqueKey);
11822
+ return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(TargetComponent, { ...finalProps, children: Array.isArray(children) ? children.map((child, idx) => renderRecursive(child, idx)) : children }, uniqueKey);
11794
11823
  }
11795
11824
  };
11796
- return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("div", { className: "px-engine-root", children: renderRecursive(root) });
11825
+ return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("div", { className: "px-engine-root relative w-full h-full min-h-[300px]", children: renderRecursive(root) });
11797
11826
  };
11798
11827
  // Annotate the CommonJS export names for ESM import in node:
11799
11828
  0 && (module.exports = {
package/dist/index.js CHANGED
@@ -8138,16 +8138,17 @@ var FormInputAtom = ({
8138
8138
  className,
8139
8139
  id
8140
8140
  }) => {
8141
+ const fieldName = name || id || `input-${Math.random().toString(36).substring(2, 9)}`;
8141
8142
  const form = useForm({
8142
8143
  defaultValues: {
8143
- [name]: defaultValue
8144
+ [fieldName]: defaultValue
8144
8145
  }
8145
8146
  });
8146
8147
  return /* @__PURE__ */ jsx69(Form, { ...form, children: /* @__PURE__ */ jsx69(
8147
8148
  FormField,
8148
8149
  {
8149
8150
  control: form.control,
8150
- name,
8151
+ name: fieldName,
8151
8152
  rules: {
8152
8153
  required: required ? `${label || name} is required` : void 0
8153
8154
  },
@@ -8183,23 +8184,24 @@ var FormSelectAtom = ({
8183
8184
  className,
8184
8185
  id
8185
8186
  }) => {
8187
+ const fieldName = name || id || `select-${Math.random().toString(36).substring(2, 9)}`;
8186
8188
  const form = useForm2({
8187
8189
  defaultValues: {
8188
- [name]: defaultValue
8190
+ [fieldName]: defaultValue
8189
8191
  }
8190
8192
  });
8191
8193
  return /* @__PURE__ */ jsx70(Form, { ...form, children: /* @__PURE__ */ jsx70(
8192
8194
  FormField,
8193
8195
  {
8194
8196
  control: form.control,
8195
- name,
8197
+ name: fieldName,
8196
8198
  rules: {
8197
8199
  required: required ? `${label || name} is required` : void 0
8198
8200
  },
8199
8201
  render: ({ field }) => /* @__PURE__ */ jsxs38(FormItem, { className: cn("w-full", className), children: [
8200
8202
  label && /* @__PURE__ */ jsx70(FormLabel, { children: label }),
8201
8203
  /* @__PURE__ */ jsxs38(Select, { onValueChange: field.onChange, defaultValue: field.value, children: [
8202
- /* @__PURE__ */ jsx70(FormControl, { children: /* @__PURE__ */ jsx70(SelectTrigger, { id: id || `form-select-${name}`, children: /* @__PURE__ */ jsx70(SelectValue, { placeholder }) }) }),
8204
+ /* @__PURE__ */ jsx70(FormControl, { children: /* @__PURE__ */ jsx70(SelectTrigger, { id: id || `form-select-${fieldName}`, children: /* @__PURE__ */ jsx70(SelectValue, { placeholder }) }) }),
8203
8205
  /* @__PURE__ */ jsx70(SelectContent, { children: options.map((option) => /* @__PURE__ */ jsx70(SelectItem, { value: option.value, children: option.label }, option.value)) })
8204
8206
  ] }),
8205
8207
  description && /* @__PURE__ */ jsx70(FormDescription, { children: description }),
@@ -8223,16 +8225,17 @@ var FormTextareaAtom = ({
8223
8225
  className,
8224
8226
  id
8225
8227
  }) => {
8228
+ const fieldName = name || id || `textarea-${Math.random().toString(36).substring(2, 9)}`;
8226
8229
  const form = useForm3({
8227
8230
  defaultValues: {
8228
- [name]: defaultValue
8231
+ [fieldName]: defaultValue
8229
8232
  }
8230
8233
  });
8231
8234
  return /* @__PURE__ */ jsx71(Form, { ...form, children: /* @__PURE__ */ jsx71(
8232
8235
  FormField,
8233
8236
  {
8234
8237
  control: form.control,
8235
- name,
8238
+ name: fieldName,
8236
8239
  rules: {
8237
8240
  required: required ? `${label || name} is required` : void 0
8238
8241
  },
@@ -8243,7 +8246,7 @@ var FormTextareaAtom = ({
8243
8246
  {
8244
8247
  placeholder,
8245
8248
  rows,
8246
- id: id || `form-textarea-${name}`,
8249
+ id: id || `form-textarea-${fieldName}`,
8247
8250
  ...field
8248
8251
  }
8249
8252
  ) }),
@@ -11499,18 +11502,42 @@ var PXEngineRenderer = ({
11499
11502
  return component;
11500
11503
  }
11501
11504
  if (!component || typeof component !== "object") return null;
11502
- const { type, name, props = {}, children = [], id } = component;
11503
- const componentName = name || type;
11505
+ const {
11506
+ type,
11507
+ name,
11508
+ component: componentType,
11509
+ props = {},
11510
+ children = [],
11511
+ id,
11512
+ ...remainingProps
11513
+ } = component;
11514
+ const componentName = name || type || componentType;
11504
11515
  if (!componentName || typeof componentName !== "string") return null;
11516
+ const finalProps = { ...remainingProps, ...props };
11517
+ if (id && !finalProps.id) {
11518
+ finalProps.id = id;
11519
+ }
11505
11520
  const uniqueKey = id || `${componentName}-${index || Math.random().toString(36).substr(2, 9)}`;
11506
11521
  const normalizedName = componentName.charAt(0).toUpperCase() + componentName.slice(1);
11507
- const atomName = normalizedName.endsWith("Atom") ? normalizedName : `${normalizedName}Atom`;
11508
- let TargetComponent = atoms_exports[atomName] || atoms_exports[normalizedName] || atoms_exports[componentName];
11509
- if (!TargetComponent) {
11510
- TargetComponent = molecules_exports[normalizedName] || molecules_exports[componentName];
11511
- }
11512
- if (!TargetComponent && !CONTEXT_DEPENDENT_COMPONENTS.has(normalizedName)) {
11513
- TargetComponent = ui_exports[normalizedName] || ui_exports[componentName];
11522
+ const resolveComponent = (identifier) => {
11523
+ const normalized = identifier.charAt(0).toUpperCase() + identifier.slice(1);
11524
+ const atomName2 = normalized.endsWith("Atom") ? normalized : `${normalized}Atom`;
11525
+ let Comp = atoms_exports[atomName2] || atoms_exports[normalized] || atoms_exports[identifier];
11526
+ if (!Comp) {
11527
+ Comp = molecules_exports[normalized] || molecules_exports[identifier];
11528
+ }
11529
+ if (!Comp && !CONTEXT_DEPENDENT_COMPONENTS.has(normalized)) {
11530
+ Comp = ui_exports[normalized] || ui_exports[identifier];
11531
+ }
11532
+ return Comp;
11533
+ };
11534
+ let TargetComponent = resolveComponent(componentName);
11535
+ let resolvedIdentifier = componentName;
11536
+ if (!TargetComponent && type && type !== componentName) {
11537
+ TargetComponent = resolveComponent(type);
11538
+ if (TargetComponent) {
11539
+ resolvedIdentifier = type;
11540
+ }
11514
11541
  }
11515
11542
  if (!TargetComponent) {
11516
11543
  if (CONTEXT_DEPENDENT_COMPONENTS.has(normalizedName)) {
@@ -11531,12 +11558,14 @@ var PXEngineRenderer = ({
11531
11558
  return renderNotFoundError(componentName, uniqueKey);
11532
11559
  }
11533
11560
  }
11561
+ const resolvedNormalized = resolvedIdentifier.charAt(0).toUpperCase() + resolvedIdentifier.slice(1);
11562
+ const atomName = resolvedNormalized.endsWith("Atom") ? resolvedNormalized : `${resolvedNormalized}Atom`;
11534
11563
  const isAtomWithRenderProp = atomName in atoms_exports;
11535
11564
  if (isAtomWithRenderProp) {
11536
11565
  return /* @__PURE__ */ jsx90(
11537
11566
  TargetComponent,
11538
11567
  {
11539
- ...props,
11568
+ ...finalProps,
11540
11569
  onAction,
11541
11570
  renderComponent: renderRecursive,
11542
11571
  children
@@ -11544,10 +11573,10 @@ var PXEngineRenderer = ({
11544
11573
  uniqueKey
11545
11574
  );
11546
11575
  } else {
11547
- return /* @__PURE__ */ jsx90(TargetComponent, { ...props, children: Array.isArray(children) ? children.map((child, idx) => renderRecursive(child, idx)) : children }, uniqueKey);
11576
+ return /* @__PURE__ */ jsx90(TargetComponent, { ...finalProps, children: Array.isArray(children) ? children.map((child, idx) => renderRecursive(child, idx)) : children }, uniqueKey);
11548
11577
  }
11549
11578
  };
11550
- return /* @__PURE__ */ jsx90("div", { className: "px-engine-root", children: renderRecursive(root) });
11579
+ return /* @__PURE__ */ jsx90("div", { className: "px-engine-root relative w-full h-full min-h-[300px]", children: renderRecursive(root) });
11551
11580
  };
11552
11581
  export {
11553
11582
  Accordion,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pxengine/ui",
3
3
  "version": "1.0.0",
4
- "lastUpdated": "2026-01-29T11:11:35.549Z",
4
+ "lastUpdated": "2026-01-30T13:41:14.195Z",
5
5
  "components": {
6
6
  "AccordionAtom": {
7
7
  "name": "AccordionAtom",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pxengine",
3
- "version": "0.1.6",
3
+ "version": "0.1.9",
4
4
  "type": "module",
5
5
  "description": "Shadcn-based UI component library for agent-driven interfaces",
6
6
  "main": "./dist/index.cjs",
@@ -61,10 +61,14 @@ export const FormInputAtom: React.FC<FormInputAtomProps> = ({
61
61
  className,
62
62
  id,
63
63
  }) => {
64
+ // Safe fallback for name to prevent RHF crash
65
+ const fieldName =
66
+ name || id || `input-${Math.random().toString(36).substring(2, 9)}`;
67
+
64
68
  // Create a local form context for this field
65
69
  const form = useForm({
66
70
  defaultValues: {
67
- [name]: defaultValue,
71
+ [fieldName]: defaultValue,
68
72
  },
69
73
  });
70
74
 
@@ -72,7 +76,7 @@ export const FormInputAtom: React.FC<FormInputAtomProps> = ({
72
76
  <Form {...form}>
73
77
  <FormField
74
78
  control={form.control}
75
- name={name}
79
+ name={fieldName}
76
80
  rules={{
77
81
  required: required ? `${label || name} is required` : undefined,
78
82
  }}
@@ -64,10 +64,14 @@ export const FormSelectAtom: React.FC<FormSelectAtomProps> = ({
64
64
  className,
65
65
  id,
66
66
  }) => {
67
+ // Safe fallback for name to prevent RHF crash
68
+ const fieldName =
69
+ name || id || `select-${Math.random().toString(36).substring(2, 9)}`;
70
+
67
71
  // Create a local form context for this field
68
72
  const form = useForm({
69
73
  defaultValues: {
70
- [name]: defaultValue,
74
+ [fieldName]: defaultValue,
71
75
  },
72
76
  });
73
77
 
@@ -75,7 +79,7 @@ export const FormSelectAtom: React.FC<FormSelectAtomProps> = ({
75
79
  <Form {...form}>
76
80
  <FormField
77
81
  control={form.control}
78
- name={name}
82
+ name={fieldName}
79
83
  rules={{
80
84
  required: required ? `${label || name} is required` : undefined,
81
85
  }}
@@ -84,7 +88,7 @@ export const FormSelectAtom: React.FC<FormSelectAtomProps> = ({
84
88
  {label && <FormLabel>{label}</FormLabel>}
85
89
  <Select onValueChange={field.onChange} defaultValue={field.value}>
86
90
  <FormControl>
87
- <SelectTrigger id={id || `form-select-${name}`}>
91
+ <SelectTrigger id={id || `form-select-${fieldName}`}>
88
92
  <SelectValue placeholder={placeholder} />
89
93
  </SelectTrigger>
90
94
  </FormControl>
@@ -53,10 +53,14 @@ export const FormTextareaAtom: React.FC<FormTextareaAtomProps> = ({
53
53
  className,
54
54
  id,
55
55
  }) => {
56
+ // Safe fallback for name to prevent RHF crash
57
+ const fieldName =
58
+ name || id || `textarea-${Math.random().toString(36).substring(2, 9)}`;
59
+
56
60
  // Create a local form context for this field
57
61
  const form = useForm({
58
62
  defaultValues: {
59
- [name]: defaultValue,
63
+ [fieldName]: defaultValue,
60
64
  },
61
65
  });
62
66
 
@@ -64,7 +68,7 @@ export const FormTextareaAtom: React.FC<FormTextareaAtomProps> = ({
64
68
  <Form {...form}>
65
69
  <FormField
66
70
  control={form.control}
67
- name={name}
71
+ name={fieldName}
68
72
  rules={{
69
73
  required: required ? `${label || name} is required` : undefined,
70
74
  }}
@@ -75,7 +79,7 @@ export const FormTextareaAtom: React.FC<FormTextareaAtomProps> = ({
75
79
  <Textarea
76
80
  placeholder={placeholder}
77
81
  rows={rows}
78
- id={id || `form-textarea-${name}`}
82
+ id={id || `form-textarea-${fieldName}`}
79
83
  {...field}
80
84
  />
81
85
  </FormControl>
@@ -201,43 +201,81 @@ export const PXEngineRenderer: React.FC<PXEngineRendererProps> = ({
201
201
 
202
202
  if (!component || typeof component !== "object") return null;
203
203
 
204
- const { type, name, props = {}, children = [], id } = component;
204
+ // Support 'component' alias for name/type
205
+ const {
206
+ type,
207
+ name,
208
+ component: componentType,
209
+ props = {},
210
+ children = [],
211
+ id,
212
+ ...remainingProps
213
+ } = component;
205
214
 
206
- // Determine the component name to search for
207
- const componentName = name || type;
215
+ // Determine the component logic name to search for
216
+ const componentName = name || type || componentType;
208
217
  if (!componentName || typeof componentName !== "string") return null;
209
218
 
219
+ // Merge explicit props with flattened props (remainingProps)
220
+ // Priority: explicit props > flattened props
221
+ const finalProps = { ...remainingProps, ...props };
222
+
223
+ // Also pass ID if not already in props
224
+ if (id && !finalProps.id) {
225
+ finalProps.id = id;
226
+ }
227
+
210
228
  // Generate a unique key from id, index, or random
211
229
  const uniqueKey =
212
230
  id ||
213
231
  `${componentName}-${index || Math.random().toString(36).substr(2, 9)}`;
214
232
 
215
- // Normalize name to PascalCase
233
+ // Normalize name to PascalCase for the *primary* identifier
216
234
  const normalizedName =
217
235
  componentName.charAt(0).toUpperCase() + componentName.slice(1);
218
- const atomName = normalizedName.endsWith("Atom")
219
- ? normalizedName
220
- : `${normalizedName}Atom`;
221
236
 
222
- // 3. Resolve Component from registries (PRIORITY ORDER - safest first)
237
+ /**
238
+ * Helper to resolve a component by a given identifier string.
239
+ * Checks Atoms -> Molecules -> UI Components.
240
+ */
241
+ const resolveComponent = (identifier: string) => {
242
+ const normalized =
243
+ identifier.charAt(0).toUpperCase() + identifier.slice(1);
244
+ const atomName = normalized.endsWith("Atom")
245
+ ? normalized
246
+ : `${normalized}Atom`;
223
247
 
224
- // Priority 1: Atoms (schema-safe, self-contained)
225
- let TargetComponent =
226
- (Atoms as any)[atomName] ||
227
- (Atoms as any)[normalizedName] ||
228
- (Atoms as any)[componentName];
248
+ // Priority 1: Atoms
249
+ let Comp =
250
+ (Atoms as any)[atomName] ||
251
+ (Atoms as any)[normalized] ||
252
+ (Atoms as any)[identifier];
229
253
 
230
- // Priority 2: Molecules (schema-safe, composite)
231
- if (!TargetComponent) {
232
- TargetComponent =
233
- (Molecules as any)[normalizedName] || (Molecules as any)[componentName];
234
- }
254
+ // Priority 2: Molecules
255
+ if (!Comp) {
256
+ Comp = (Molecules as any)[normalized] || (Molecules as any)[identifier];
257
+ }
258
+
259
+ // Priority 3: UI Components
260
+ if (!Comp && !CONTEXT_DEPENDENT_COMPONENTS.has(normalized)) {
261
+ Comp =
262
+ (UIComponents as any)[normalized] ||
263
+ (UIComponents as any)[identifier];
264
+ }
265
+ return Comp;
266
+ };
267
+
268
+ // 1. Attempt using 'name' (or 'type' if name matches)
269
+ let TargetComponent = resolveComponent(componentName);
270
+ let resolvedIdentifier = componentName;
235
271
 
236
- // Priority 3: UI Components (ONLY if NOT context-dependent)
237
- if (!TargetComponent && !CONTEXT_DEPENDENT_COMPONENTS.has(normalizedName)) {
238
- TargetComponent =
239
- (UIComponents as any)[normalizedName] ||
240
- (UIComponents as any)[componentName];
272
+ // 2. FALLBACK: If 'name' failed but 'type' is different, try 'type'
273
+ // This allows "name": "Dashboard" (descriptive) with "type": "layout" (functional)
274
+ if (!TargetComponent && type && type !== componentName) {
275
+ TargetComponent = resolveComponent(type);
276
+ if (TargetComponent) {
277
+ resolvedIdentifier = type;
278
+ }
241
279
  }
242
280
 
243
281
  // 4. Handle component not found or context-dependent
@@ -264,6 +302,13 @@ export const PXEngineRenderer: React.FC<PXEngineRendererProps> = ({
264
302
  }
265
303
  }
266
304
 
305
+ // Calculate atom name for the *resolved* component to check for render props
306
+ const resolvedNormalized =
307
+ resolvedIdentifier.charAt(0).toUpperCase() + resolvedIdentifier.slice(1);
308
+ const atomName = resolvedNormalized.endsWith("Atom")
309
+ ? resolvedNormalized
310
+ : `${resolvedNormalized}Atom`;
311
+
267
312
  // 4. Determine if component expects 'renderComponent' prop (for Atoms with children management)
268
313
  const isAtomWithRenderProp = atomName in Atoms;
269
314
 
@@ -273,7 +318,7 @@ export const PXEngineRenderer: React.FC<PXEngineRendererProps> = ({
273
318
  return (
274
319
  <TargetComponent
275
320
  key={uniqueKey}
276
- {...props}
321
+ {...finalProps}
277
322
  onAction={onAction}
278
323
  renderComponent={renderRecursive}
279
324
  children={children}
@@ -282,7 +327,7 @@ export const PXEngineRenderer: React.FC<PXEngineRendererProps> = ({
282
327
  } else {
283
328
  // Standard shadcn components - pass children as React children
284
329
  return (
285
- <TargetComponent key={uniqueKey} {...props}>
330
+ <TargetComponent key={uniqueKey} {...finalProps}>
286
331
  {Array.isArray(children)
287
332
  ? children.map((child, idx) => renderRecursive(child, idx))
288
333
  : children}
@@ -291,5 +336,9 @@ export const PXEngineRenderer: React.FC<PXEngineRendererProps> = ({
291
336
  }
292
337
  };
293
338
 
294
- return <div className="px-engine-root">{renderRecursive(root)}</div>;
339
+ return (
340
+ <div className="px-engine-root relative w-full h-full min-h-[300px]">
341
+ {renderRecursive(root)}
342
+ </div>
343
+ );
295
344
  };