@almadar/ui 4.6.1 → 4.6.3

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.
@@ -4094,6 +4094,7 @@ var init_ThemeContext = __esm({
4094
4094
  });
4095
4095
  function EntitySchemaProvider({
4096
4096
  entities,
4097
+ traitLinkedEntities,
4097
4098
  children
4098
4099
  }) {
4099
4100
  const entitiesMap = React126.useMemo(() => {
@@ -4103,11 +4104,15 @@ function EntitySchemaProvider({
4103
4104
  }
4104
4105
  return map;
4105
4106
  }, [entities]);
4107
+ const linkedMap = React126.useMemo(() => {
4108
+ return traitLinkedEntities ?? /* @__PURE__ */ new Map();
4109
+ }, [traitLinkedEntities]);
4106
4110
  const contextValue = React126.useMemo(
4107
4111
  () => ({
4108
- entities: entitiesMap
4112
+ entities: entitiesMap,
4113
+ traitLinkedEntities: linkedMap
4109
4114
  }),
4110
- [entitiesMap]
4115
+ [entitiesMap, linkedMap]
4111
4116
  );
4112
4117
  return /* @__PURE__ */ jsxRuntime.jsx(EntitySchemaContext.Provider, { value: contextValue, children });
4113
4118
  }
@@ -46685,7 +46690,7 @@ function getToastPosition(position) {
46685
46690
  return "top-4 right-4";
46686
46691
  }
46687
46692
  }
46688
- function renderPatternChildren(children, onDismiss, parentId = "root", parentPath = "root") {
46693
+ function renderPatternChildren(children, onDismiss, parentId = "root", parentPath = "root", sourceTrait) {
46689
46694
  if (!children || !Array.isArray(children) || children.length === 0) {
46690
46695
  return null;
46691
46696
  }
@@ -46712,7 +46717,11 @@ function renderPatternChildren(children, onDismiss, parentId = "root", parentPat
46712
46717
  pattern: child.type,
46713
46718
  props: resolvedProps,
46714
46719
  priority: 0,
46715
- nodeId: child._id
46720
+ nodeId: child._id,
46721
+ // Inherit sourceTrait from the parent slot so nested patterns
46722
+ // (e.g. form-section inside a stack) can resolve entityDef via
46723
+ // the trait's linkedEntity for form-field enrichment.
46724
+ ...sourceTrait !== void 0 && { sourceTrait }
46716
46725
  };
46717
46726
  return /* @__PURE__ */ jsxRuntime.jsx(
46718
46727
  SlotContentRenderer,
@@ -46763,13 +46772,21 @@ function SlotContentRenderer({
46763
46772
  }
46764
46773
  }
46765
46774
  const schemaCtx = useEntitySchemaOptional();
46766
- const entityDef = typeof entityProp === "string" && entityProp.length > 0 && schemaCtx ? schemaCtx.entities.get(entityProp) : void 0;
46775
+ let entityDef;
46776
+ if (typeof entityProp === "string" && entityProp.length > 0 && schemaCtx) {
46777
+ entityDef = schemaCtx.entities.get(entityProp);
46778
+ } else if (schemaCtx && content.sourceTrait !== void 0) {
46779
+ const linkedEntity = schemaCtx.traitLinkedEntities.get(content.sourceTrait);
46780
+ if (linkedEntity !== void 0) {
46781
+ entityDef = schemaCtx.entities.get(linkedEntity);
46782
+ }
46783
+ }
46767
46784
  const PatternComponent = getComponentForPattern(content.pattern);
46768
46785
  if (PatternComponent) {
46769
46786
  const childrenConfig = content.props.children;
46770
46787
  const hasChildren = PATTERNS_WITH_CHILDREN.has(content.pattern) || Array.isArray(childrenConfig) && childrenConfig.length > 0;
46771
46788
  const myPath = patternPath ?? "root";
46772
- const renderedChildren = hasChildren ? renderPatternChildren(childrenConfig, onDismiss, content.id, myPath) : void 0;
46789
+ const renderedChildren = hasChildren ? renderPatternChildren(childrenConfig, onDismiss, content.id, myPath, content.sourceTrait) : void 0;
46773
46790
  const { children: _childrenConfig, ...restProps } = content.props;
46774
46791
  const renderedProps = renderPatternProps(restProps, onDismiss);
46775
46792
  const finalProps = renderedProps;
@@ -52250,20 +52267,39 @@ function SchemaRunner({ schema, serverUrl, mockData, pageName, onNavigate, onLoc
52250
52267
  if (!orbitals) return [];
52251
52268
  return orbitals.filter((o) => typeof o.name === "string").map((o) => o.name);
52252
52269
  }, [schema]);
52253
- const inner = /* @__PURE__ */ jsxRuntime.jsx(VerificationProvider, { enabled: true, children: /* @__PURE__ */ jsxRuntime.jsx(SlotsProvider, { children: /* @__PURE__ */ jsxRuntime.jsxs(EntitySchemaProvider, { entities: Array.from(allEntities.values()), children: [
52254
- /* @__PURE__ */ jsxRuntime.jsx(
52255
- TraitInitializer,
52256
- {
52257
- traits: allPageTraits,
52258
- orbitalNames: serverUrl ? orbitalNames : void 0,
52259
- onNavigate,
52260
- onLocalFallback,
52261
- persistence
52262
- }
52263
- ),
52264
- /* @__PURE__ */ jsxRuntime.jsx(SlotBridge, {}),
52265
- /* @__PURE__ */ jsxRuntime.jsx(Box, { className: "h-full p-4", children: /* @__PURE__ */ jsxRuntime.jsx(UISlotRenderer, { includeHud: true, hudMode: "inline", includeFloating: true }) })
52266
- ] }) }) });
52270
+ const inner = /* @__PURE__ */ jsxRuntime.jsx(VerificationProvider, { enabled: true, children: /* @__PURE__ */ jsxRuntime.jsx(SlotsProvider, { children: /* @__PURE__ */ jsxRuntime.jsxs(
52271
+ EntitySchemaProvider,
52272
+ {
52273
+ entities: Array.from(allEntities.values()),
52274
+ traitLinkedEntities: (() => {
52275
+ const map = /* @__PURE__ */ new Map();
52276
+ if (ir) {
52277
+ for (const page of ir.pages.values()) {
52278
+ for (const binding of page.traits) {
52279
+ if (binding.linkedEntity) {
52280
+ map.set(binding.trait.name, binding.linkedEntity);
52281
+ }
52282
+ }
52283
+ }
52284
+ }
52285
+ return map;
52286
+ })(),
52287
+ children: [
52288
+ /* @__PURE__ */ jsxRuntime.jsx(
52289
+ TraitInitializer,
52290
+ {
52291
+ traits: allPageTraits,
52292
+ orbitalNames: serverUrl ? orbitalNames : void 0,
52293
+ onNavigate,
52294
+ onLocalFallback,
52295
+ persistence
52296
+ }
52297
+ ),
52298
+ /* @__PURE__ */ jsxRuntime.jsx(SlotBridge, {}),
52299
+ /* @__PURE__ */ jsxRuntime.jsx(Box, { className: "h-full p-4", children: /* @__PURE__ */ jsxRuntime.jsx(UISlotRenderer, { includeHud: true, hudMode: "inline", includeFloating: true }) })
52300
+ ]
52301
+ }
52302
+ ) }) });
52267
52303
  if (serverUrl) {
52268
52304
  return /* @__PURE__ */ jsxRuntime.jsx(ServerBridgeProvider, { schema, serverUrl, children: inner });
52269
52305
  }
package/dist/avl/index.js CHANGED
@@ -4048,6 +4048,7 @@ var init_ThemeContext = __esm({
4048
4048
  });
4049
4049
  function EntitySchemaProvider({
4050
4050
  entities,
4051
+ traitLinkedEntities,
4051
4052
  children
4052
4053
  }) {
4053
4054
  const entitiesMap = useMemo(() => {
@@ -4057,11 +4058,15 @@ function EntitySchemaProvider({
4057
4058
  }
4058
4059
  return map;
4059
4060
  }, [entities]);
4061
+ const linkedMap = useMemo(() => {
4062
+ return traitLinkedEntities ?? /* @__PURE__ */ new Map();
4063
+ }, [traitLinkedEntities]);
4060
4064
  const contextValue = useMemo(
4061
4065
  () => ({
4062
- entities: entitiesMap
4066
+ entities: entitiesMap,
4067
+ traitLinkedEntities: linkedMap
4063
4068
  }),
4064
- [entitiesMap]
4069
+ [entitiesMap, linkedMap]
4065
4070
  );
4066
4071
  return /* @__PURE__ */ jsx(EntitySchemaContext.Provider, { value: contextValue, children });
4067
4072
  }
@@ -46639,7 +46644,7 @@ function getToastPosition(position) {
46639
46644
  return "top-4 right-4";
46640
46645
  }
46641
46646
  }
46642
- function renderPatternChildren(children, onDismiss, parentId = "root", parentPath = "root") {
46647
+ function renderPatternChildren(children, onDismiss, parentId = "root", parentPath = "root", sourceTrait) {
46643
46648
  if (!children || !Array.isArray(children) || children.length === 0) {
46644
46649
  return null;
46645
46650
  }
@@ -46666,7 +46671,11 @@ function renderPatternChildren(children, onDismiss, parentId = "root", parentPat
46666
46671
  pattern: child.type,
46667
46672
  props: resolvedProps,
46668
46673
  priority: 0,
46669
- nodeId: child._id
46674
+ nodeId: child._id,
46675
+ // Inherit sourceTrait from the parent slot so nested patterns
46676
+ // (e.g. form-section inside a stack) can resolve entityDef via
46677
+ // the trait's linkedEntity for form-field enrichment.
46678
+ ...sourceTrait !== void 0 && { sourceTrait }
46670
46679
  };
46671
46680
  return /* @__PURE__ */ jsx(
46672
46681
  SlotContentRenderer,
@@ -46717,13 +46726,21 @@ function SlotContentRenderer({
46717
46726
  }
46718
46727
  }
46719
46728
  const schemaCtx = useEntitySchemaOptional();
46720
- const entityDef = typeof entityProp === "string" && entityProp.length > 0 && schemaCtx ? schemaCtx.entities.get(entityProp) : void 0;
46729
+ let entityDef;
46730
+ if (typeof entityProp === "string" && entityProp.length > 0 && schemaCtx) {
46731
+ entityDef = schemaCtx.entities.get(entityProp);
46732
+ } else if (schemaCtx && content.sourceTrait !== void 0) {
46733
+ const linkedEntity = schemaCtx.traitLinkedEntities.get(content.sourceTrait);
46734
+ if (linkedEntity !== void 0) {
46735
+ entityDef = schemaCtx.entities.get(linkedEntity);
46736
+ }
46737
+ }
46721
46738
  const PatternComponent = getComponentForPattern(content.pattern);
46722
46739
  if (PatternComponent) {
46723
46740
  const childrenConfig = content.props.children;
46724
46741
  const hasChildren = PATTERNS_WITH_CHILDREN.has(content.pattern) || Array.isArray(childrenConfig) && childrenConfig.length > 0;
46725
46742
  const myPath = patternPath ?? "root";
46726
- const renderedChildren = hasChildren ? renderPatternChildren(childrenConfig, onDismiss, content.id, myPath) : void 0;
46743
+ const renderedChildren = hasChildren ? renderPatternChildren(childrenConfig, onDismiss, content.id, myPath, content.sourceTrait) : void 0;
46727
46744
  const { children: _childrenConfig, ...restProps } = content.props;
46728
46745
  const renderedProps = renderPatternProps(restProps, onDismiss);
46729
46746
  const finalProps = renderedProps;
@@ -52204,20 +52221,39 @@ function SchemaRunner({ schema, serverUrl, mockData, pageName, onNavigate, onLoc
52204
52221
  if (!orbitals) return [];
52205
52222
  return orbitals.filter((o) => typeof o.name === "string").map((o) => o.name);
52206
52223
  }, [schema]);
52207
- const inner = /* @__PURE__ */ jsx(VerificationProvider, { enabled: true, children: /* @__PURE__ */ jsx(SlotsProvider, { children: /* @__PURE__ */ jsxs(EntitySchemaProvider, { entities: Array.from(allEntities.values()), children: [
52208
- /* @__PURE__ */ jsx(
52209
- TraitInitializer,
52210
- {
52211
- traits: allPageTraits,
52212
- orbitalNames: serverUrl ? orbitalNames : void 0,
52213
- onNavigate,
52214
- onLocalFallback,
52215
- persistence
52216
- }
52217
- ),
52218
- /* @__PURE__ */ jsx(SlotBridge, {}),
52219
- /* @__PURE__ */ jsx(Box, { className: "h-full p-4", children: /* @__PURE__ */ jsx(UISlotRenderer, { includeHud: true, hudMode: "inline", includeFloating: true }) })
52220
- ] }) }) });
52224
+ const inner = /* @__PURE__ */ jsx(VerificationProvider, { enabled: true, children: /* @__PURE__ */ jsx(SlotsProvider, { children: /* @__PURE__ */ jsxs(
52225
+ EntitySchemaProvider,
52226
+ {
52227
+ entities: Array.from(allEntities.values()),
52228
+ traitLinkedEntities: (() => {
52229
+ const map = /* @__PURE__ */ new Map();
52230
+ if (ir) {
52231
+ for (const page of ir.pages.values()) {
52232
+ for (const binding of page.traits) {
52233
+ if (binding.linkedEntity) {
52234
+ map.set(binding.trait.name, binding.linkedEntity);
52235
+ }
52236
+ }
52237
+ }
52238
+ }
52239
+ return map;
52240
+ })(),
52241
+ children: [
52242
+ /* @__PURE__ */ jsx(
52243
+ TraitInitializer,
52244
+ {
52245
+ traits: allPageTraits,
52246
+ orbitalNames: serverUrl ? orbitalNames : void 0,
52247
+ onNavigate,
52248
+ onLocalFallback,
52249
+ persistence
52250
+ }
52251
+ ),
52252
+ /* @__PURE__ */ jsx(SlotBridge, {}),
52253
+ /* @__PURE__ */ jsx(Box, { className: "h-full p-4", children: /* @__PURE__ */ jsx(UISlotRenderer, { includeHud: true, hudMode: "inline", includeFloating: true }) })
52254
+ ]
52255
+ }
52256
+ ) }) });
52221
52257
  if (serverUrl) {
52222
52258
  return /* @__PURE__ */ jsx(ServerBridgeProvider, { schema, serverUrl, children: inner });
52223
52259
  }
@@ -37531,7 +37531,7 @@ function getToastPosition(position) {
37531
37531
  return "top-4 right-4";
37532
37532
  }
37533
37533
  }
37534
- function renderPatternChildren(children, onDismiss, parentId = "root", parentPath = "root") {
37534
+ function renderPatternChildren(children, onDismiss, parentId = "root", parentPath = "root", sourceTrait) {
37535
37535
  if (!children || !Array.isArray(children) || children.length === 0) {
37536
37536
  return null;
37537
37537
  }
@@ -37558,7 +37558,11 @@ function renderPatternChildren(children, onDismiss, parentId = "root", parentPat
37558
37558
  pattern: child.type,
37559
37559
  props: resolvedProps,
37560
37560
  priority: 0,
37561
- nodeId: child._id
37561
+ nodeId: child._id,
37562
+ // Inherit sourceTrait from the parent slot so nested patterns
37563
+ // (e.g. form-section inside a stack) can resolve entityDef via
37564
+ // the trait's linkedEntity for form-field enrichment.
37565
+ ...sourceTrait !== void 0 && { sourceTrait }
37562
37566
  };
37563
37567
  return /* @__PURE__ */ jsxRuntime.jsx(
37564
37568
  SlotContentRenderer,
@@ -37609,13 +37613,21 @@ function SlotContentRenderer({
37609
37613
  }
37610
37614
  }
37611
37615
  const schemaCtx = useEntitySchemaOptional();
37612
- const entityDef = typeof entityProp === "string" && entityProp.length > 0 && schemaCtx ? schemaCtx.entities.get(entityProp) : void 0;
37616
+ let entityDef;
37617
+ if (typeof entityProp === "string" && entityProp.length > 0 && schemaCtx) {
37618
+ entityDef = schemaCtx.entities.get(entityProp);
37619
+ } else if (schemaCtx && content.sourceTrait !== void 0) {
37620
+ const linkedEntity = schemaCtx.traitLinkedEntities.get(content.sourceTrait);
37621
+ if (linkedEntity !== void 0) {
37622
+ entityDef = schemaCtx.entities.get(linkedEntity);
37623
+ }
37624
+ }
37613
37625
  const PatternComponent = getComponentForPattern(content.pattern);
37614
37626
  if (PatternComponent) {
37615
37627
  const childrenConfig = content.props.children;
37616
37628
  const hasChildren = PATTERNS_WITH_CHILDREN.has(content.pattern) || Array.isArray(childrenConfig) && childrenConfig.length > 0;
37617
37629
  const myPath = patternPath ?? "root";
37618
- const renderedChildren = hasChildren ? renderPatternChildren(childrenConfig, onDismiss, content.id, myPath) : void 0;
37630
+ const renderedChildren = hasChildren ? renderPatternChildren(childrenConfig, onDismiss, content.id, myPath, content.sourceTrait) : void 0;
37619
37631
  const { children: _childrenConfig, ...restProps } = content.props;
37620
37632
  const renderedProps = renderPatternProps(restProps, onDismiss);
37621
37633
  const finalProps = renderedProps;
@@ -37486,7 +37486,7 @@ function getToastPosition(position) {
37486
37486
  return "top-4 right-4";
37487
37487
  }
37488
37488
  }
37489
- function renderPatternChildren(children, onDismiss, parentId = "root", parentPath = "root") {
37489
+ function renderPatternChildren(children, onDismiss, parentId = "root", parentPath = "root", sourceTrait) {
37490
37490
  if (!children || !Array.isArray(children) || children.length === 0) {
37491
37491
  return null;
37492
37492
  }
@@ -37513,7 +37513,11 @@ function renderPatternChildren(children, onDismiss, parentId = "root", parentPat
37513
37513
  pattern: child.type,
37514
37514
  props: resolvedProps,
37515
37515
  priority: 0,
37516
- nodeId: child._id
37516
+ nodeId: child._id,
37517
+ // Inherit sourceTrait from the parent slot so nested patterns
37518
+ // (e.g. form-section inside a stack) can resolve entityDef via
37519
+ // the trait's linkedEntity for form-field enrichment.
37520
+ ...sourceTrait !== void 0 && { sourceTrait }
37517
37521
  };
37518
37522
  return /* @__PURE__ */ jsx(
37519
37523
  SlotContentRenderer,
@@ -37564,13 +37568,21 @@ function SlotContentRenderer({
37564
37568
  }
37565
37569
  }
37566
37570
  const schemaCtx = useEntitySchemaOptional();
37567
- const entityDef = typeof entityProp === "string" && entityProp.length > 0 && schemaCtx ? schemaCtx.entities.get(entityProp) : void 0;
37571
+ let entityDef;
37572
+ if (typeof entityProp === "string" && entityProp.length > 0 && schemaCtx) {
37573
+ entityDef = schemaCtx.entities.get(entityProp);
37574
+ } else if (schemaCtx && content.sourceTrait !== void 0) {
37575
+ const linkedEntity = schemaCtx.traitLinkedEntities.get(content.sourceTrait);
37576
+ if (linkedEntity !== void 0) {
37577
+ entityDef = schemaCtx.entities.get(linkedEntity);
37578
+ }
37579
+ }
37568
37580
  const PatternComponent = getComponentForPattern(content.pattern);
37569
37581
  if (PatternComponent) {
37570
37582
  const childrenConfig = content.props.children;
37571
37583
  const hasChildren = PATTERNS_WITH_CHILDREN.has(content.pattern) || Array.isArray(childrenConfig) && childrenConfig.length > 0;
37572
37584
  const myPath = patternPath ?? "root";
37573
- const renderedChildren = hasChildren ? renderPatternChildren(childrenConfig, onDismiss, content.id, myPath) : void 0;
37585
+ const renderedChildren = hasChildren ? renderPatternChildren(childrenConfig, onDismiss, content.id, myPath, content.sourceTrait) : void 0;
37574
37586
  const { children: _childrenConfig, ...restProps } = content.props;
37575
37587
  const renderedProps = renderPatternProps(restProps, onDismiss);
37576
37588
  const finalProps = renderedProps;
@@ -38040,7 +38040,7 @@ function getToastPosition(position) {
38040
38040
  return "top-4 right-4";
38041
38041
  }
38042
38042
  }
38043
- function renderPatternChildren(children, onDismiss, parentId = "root", parentPath = "root") {
38043
+ function renderPatternChildren(children, onDismiss, parentId = "root", parentPath = "root", sourceTrait) {
38044
38044
  if (!children || !Array.isArray(children) || children.length === 0) {
38045
38045
  return null;
38046
38046
  }
@@ -38067,7 +38067,11 @@ function renderPatternChildren(children, onDismiss, parentId = "root", parentPat
38067
38067
  pattern: child.type,
38068
38068
  props: resolvedProps,
38069
38069
  priority: 0,
38070
- nodeId: child._id
38070
+ nodeId: child._id,
38071
+ // Inherit sourceTrait from the parent slot so nested patterns
38072
+ // (e.g. form-section inside a stack) can resolve entityDef via
38073
+ // the trait's linkedEntity for form-field enrichment.
38074
+ ...sourceTrait !== void 0 && { sourceTrait }
38071
38075
  };
38072
38076
  return /* @__PURE__ */ jsxRuntime.jsx(
38073
38077
  SlotContentRenderer,
@@ -38118,13 +38122,21 @@ function SlotContentRenderer({
38118
38122
  }
38119
38123
  }
38120
38124
  const schemaCtx = useEntitySchemaOptional();
38121
- const entityDef = typeof entityProp === "string" && entityProp.length > 0 && schemaCtx ? schemaCtx.entities.get(entityProp) : void 0;
38125
+ let entityDef;
38126
+ if (typeof entityProp === "string" && entityProp.length > 0 && schemaCtx) {
38127
+ entityDef = schemaCtx.entities.get(entityProp);
38128
+ } else if (schemaCtx && content.sourceTrait !== void 0) {
38129
+ const linkedEntity = schemaCtx.traitLinkedEntities.get(content.sourceTrait);
38130
+ if (linkedEntity !== void 0) {
38131
+ entityDef = schemaCtx.entities.get(linkedEntity);
38132
+ }
38133
+ }
38122
38134
  const PatternComponent = getComponentForPattern(content.pattern);
38123
38135
  if (PatternComponent) {
38124
38136
  const childrenConfig = content.props.children;
38125
38137
  const hasChildren = PATTERNS_WITH_CHILDREN.has(content.pattern) || Array.isArray(childrenConfig) && childrenConfig.length > 0;
38126
38138
  const myPath = patternPath ?? "root";
38127
- const renderedChildren = hasChildren ? renderPatternChildren(childrenConfig, onDismiss, content.id, myPath) : void 0;
38139
+ const renderedChildren = hasChildren ? renderPatternChildren(childrenConfig, onDismiss, content.id, myPath, content.sourceTrait) : void 0;
38128
38140
  const { children: _childrenConfig, ...restProps } = content.props;
38129
38141
  const renderedProps = renderPatternProps(restProps, onDismiss);
38130
38142
  const finalProps = renderedProps;
@@ -37995,7 +37995,7 @@ function getToastPosition(position) {
37995
37995
  return "top-4 right-4";
37996
37996
  }
37997
37997
  }
37998
- function renderPatternChildren(children, onDismiss, parentId = "root", parentPath = "root") {
37998
+ function renderPatternChildren(children, onDismiss, parentId = "root", parentPath = "root", sourceTrait) {
37999
37999
  if (!children || !Array.isArray(children) || children.length === 0) {
38000
38000
  return null;
38001
38001
  }
@@ -38022,7 +38022,11 @@ function renderPatternChildren(children, onDismiss, parentId = "root", parentPat
38022
38022
  pattern: child.type,
38023
38023
  props: resolvedProps,
38024
38024
  priority: 0,
38025
- nodeId: child._id
38025
+ nodeId: child._id,
38026
+ // Inherit sourceTrait from the parent slot so nested patterns
38027
+ // (e.g. form-section inside a stack) can resolve entityDef via
38028
+ // the trait's linkedEntity for form-field enrichment.
38029
+ ...sourceTrait !== void 0 && { sourceTrait }
38026
38030
  };
38027
38031
  return /* @__PURE__ */ jsx(
38028
38032
  SlotContentRenderer,
@@ -38073,13 +38077,21 @@ function SlotContentRenderer({
38073
38077
  }
38074
38078
  }
38075
38079
  const schemaCtx = useEntitySchemaOptional();
38076
- const entityDef = typeof entityProp === "string" && entityProp.length > 0 && schemaCtx ? schemaCtx.entities.get(entityProp) : void 0;
38080
+ let entityDef;
38081
+ if (typeof entityProp === "string" && entityProp.length > 0 && schemaCtx) {
38082
+ entityDef = schemaCtx.entities.get(entityProp);
38083
+ } else if (schemaCtx && content.sourceTrait !== void 0) {
38084
+ const linkedEntity = schemaCtx.traitLinkedEntities.get(content.sourceTrait);
38085
+ if (linkedEntity !== void 0) {
38086
+ entityDef = schemaCtx.entities.get(linkedEntity);
38087
+ }
38088
+ }
38077
38089
  const PatternComponent = getComponentForPattern(content.pattern);
38078
38090
  if (PatternComponent) {
38079
38091
  const childrenConfig = content.props.children;
38080
38092
  const hasChildren = PATTERNS_WITH_CHILDREN.has(content.pattern) || Array.isArray(childrenConfig) && childrenConfig.length > 0;
38081
38093
  const myPath = patternPath ?? "root";
38082
- const renderedChildren = hasChildren ? renderPatternChildren(childrenConfig, onDismiss, content.id, myPath) : void 0;
38094
+ const renderedChildren = hasChildren ? renderPatternChildren(childrenConfig, onDismiss, content.id, myPath, content.sourceTrait) : void 0;
38083
38095
  const { children: _childrenConfig, ...restProps } = content.props;
38084
38096
  const renderedProps = renderPatternProps(restProps, onDismiss);
38085
38097
  const finalProps = renderedProps;
@@ -15,10 +15,31 @@ import type { ResolvedEntity } from '@almadar/core';
15
15
  export interface EntitySchemaContextValue {
16
16
  /** Entity definitions (schema metadata only) */
17
17
  entities: Map<string, ResolvedEntity>;
18
+ /**
19
+ * Per-trait linkedEntity name. `ResolvedTrait` itself doesn't carry
20
+ * linkedEntity (it lives on `ResolvedTraitBinding` at the page-binding
21
+ * level), so OrbPreview pre-projects every page's trait bindings into
22
+ * a flat `traitName → entityName` map for the slot renderer.
23
+ *
24
+ * Used by SlotContentRenderer to resolve `entityDef` via
25
+ * `traitLinkedEntities.get(sourceTrait) → entities.get(...)` when the
26
+ * rendered pattern's `entity:` prop is a resolved value (V2 path)
27
+ * rather than a string entity-name. Without this lookup, form-section
28
+ * can't enrich its fields with entity field metadata (values enum,
29
+ * etc.) and an enum field renders as a plain text input. Closes VR3.
30
+ */
31
+ traitLinkedEntities: ReadonlyMap<string, string>;
18
32
  }
19
33
  export interface EntitySchemaProviderProps {
20
34
  /** Entity definitions from resolved schema */
21
35
  entities: ResolvedEntity[];
36
+ /**
37
+ * Per-trait linkedEntity name, projected from every page's
38
+ * ResolvedTraitBinding. Optional for back-compat; when omitted,
39
+ * SlotContentRenderer's enrichment path can only follow the
40
+ * legacy V1 string-entity-name lookup.
41
+ */
42
+ traitLinkedEntities?: ReadonlyMap<string, string>;
22
43
  /** Children */
23
44
  children: React.ReactNode;
24
45
  }
@@ -29,7 +50,7 @@ export interface EntitySchemaProviderProps {
29
50
  * Actual entity rows arrive via `@payload.data` on the rendering trait's
30
51
  * success transition — they do NOT live in this context.
31
52
  */
32
- export declare function EntitySchemaProvider({ entities, children, }: EntitySchemaProviderProps): React.ReactElement;
53
+ export declare function EntitySchemaProvider({ entities, traitLinkedEntities, children, }: EntitySchemaProviderProps): React.ReactElement;
33
54
  /**
34
55
  * Access entity schema definitions.
35
56
  * Use this for field metadata (form building, filter enrichment).
@@ -784,6 +784,7 @@ var init_usePullToRefresh = __esm({
784
784
  });
785
785
  function EntitySchemaProvider({
786
786
  entities,
787
+ traitLinkedEntities,
787
788
  children
788
789
  }) {
789
790
  const entitiesMap = React115.useMemo(() => {
@@ -793,11 +794,15 @@ function EntitySchemaProvider({
793
794
  }
794
795
  return map;
795
796
  }, [entities]);
797
+ const linkedMap = React115.useMemo(() => {
798
+ return traitLinkedEntities ?? /* @__PURE__ */ new Map();
799
+ }, [traitLinkedEntities]);
796
800
  const contextValue = React115.useMemo(
797
801
  () => ({
798
- entities: entitiesMap
802
+ entities: entitiesMap,
803
+ traitLinkedEntities: linkedMap
799
804
  }),
800
- [entitiesMap]
805
+ [entitiesMap, linkedMap]
801
806
  );
802
807
  return /* @__PURE__ */ jsxRuntime.jsx(EntitySchemaContext.Provider, { value: contextValue, children });
803
808
  }
@@ -37626,7 +37631,7 @@ function getToastPosition(position) {
37626
37631
  return "top-4 right-4";
37627
37632
  }
37628
37633
  }
37629
- function renderPatternChildren(children, onDismiss, parentId = "root", parentPath = "root") {
37634
+ function renderPatternChildren(children, onDismiss, parentId = "root", parentPath = "root", sourceTrait) {
37630
37635
  if (!children || !Array.isArray(children) || children.length === 0) {
37631
37636
  return null;
37632
37637
  }
@@ -37653,7 +37658,11 @@ function renderPatternChildren(children, onDismiss, parentId = "root", parentPat
37653
37658
  pattern: child.type,
37654
37659
  props: resolvedProps,
37655
37660
  priority: 0,
37656
- nodeId: child._id
37661
+ nodeId: child._id,
37662
+ // Inherit sourceTrait from the parent slot so nested patterns
37663
+ // (e.g. form-section inside a stack) can resolve entityDef via
37664
+ // the trait's linkedEntity for form-field enrichment.
37665
+ ...sourceTrait !== void 0 && { sourceTrait }
37657
37666
  };
37658
37667
  return /* @__PURE__ */ jsxRuntime.jsx(
37659
37668
  SlotContentRenderer,
@@ -37704,13 +37713,21 @@ function SlotContentRenderer({
37704
37713
  }
37705
37714
  }
37706
37715
  const schemaCtx = useEntitySchemaOptional();
37707
- const entityDef = typeof entityProp === "string" && entityProp.length > 0 && schemaCtx ? schemaCtx.entities.get(entityProp) : void 0;
37716
+ let entityDef;
37717
+ if (typeof entityProp === "string" && entityProp.length > 0 && schemaCtx) {
37718
+ entityDef = schemaCtx.entities.get(entityProp);
37719
+ } else if (schemaCtx && content.sourceTrait !== void 0) {
37720
+ const linkedEntity = schemaCtx.traitLinkedEntities.get(content.sourceTrait);
37721
+ if (linkedEntity !== void 0) {
37722
+ entityDef = schemaCtx.entities.get(linkedEntity);
37723
+ }
37724
+ }
37708
37725
  const PatternComponent = getComponentForPattern(content.pattern);
37709
37726
  if (PatternComponent) {
37710
37727
  const childrenConfig = content.props.children;
37711
37728
  const hasChildren = PATTERNS_WITH_CHILDREN.has(content.pattern) || Array.isArray(childrenConfig) && childrenConfig.length > 0;
37712
37729
  const myPath = patternPath ?? "root";
37713
- const renderedChildren = hasChildren ? renderPatternChildren(childrenConfig, onDismiss, content.id, myPath) : void 0;
37730
+ const renderedChildren = hasChildren ? renderPatternChildren(childrenConfig, onDismiss, content.id, myPath, content.sourceTrait) : void 0;
37714
37731
  const { children: _childrenConfig, ...restProps } = content.props;
37715
37732
  const renderedProps = renderPatternProps(restProps, onDismiss);
37716
37733
  const finalProps = renderedProps;
@@ -39090,20 +39107,39 @@ function SchemaRunner({ schema, serverUrl, mockData, pageName, onNavigate, onLoc
39090
39107
  if (!orbitals) return [];
39091
39108
  return orbitals.filter((o) => typeof o.name === "string").map((o) => o.name);
39092
39109
  }, [schema]);
39093
- const inner = /* @__PURE__ */ jsxRuntime.jsx(providers.VerificationProvider, { enabled: true, children: /* @__PURE__ */ jsxRuntime.jsx(SlotsProvider, { children: /* @__PURE__ */ jsxRuntime.jsxs(EntitySchemaProvider, { entities: Array.from(allEntities.values()), children: [
39094
- /* @__PURE__ */ jsxRuntime.jsx(
39095
- TraitInitializer,
39096
- {
39097
- traits: allPageTraits,
39098
- orbitalNames: serverUrl ? orbitalNames : void 0,
39099
- onNavigate,
39100
- onLocalFallback,
39101
- persistence
39102
- }
39103
- ),
39104
- /* @__PURE__ */ jsxRuntime.jsx(SlotBridge, {}),
39105
- /* @__PURE__ */ jsxRuntime.jsx(Box, { className: "h-full p-4", children: /* @__PURE__ */ jsxRuntime.jsx(UISlotRenderer, { includeHud: true, hudMode: "inline", includeFloating: true }) })
39106
- ] }) }) });
39110
+ const inner = /* @__PURE__ */ jsxRuntime.jsx(providers.VerificationProvider, { enabled: true, children: /* @__PURE__ */ jsxRuntime.jsx(SlotsProvider, { children: /* @__PURE__ */ jsxRuntime.jsxs(
39111
+ EntitySchemaProvider,
39112
+ {
39113
+ entities: Array.from(allEntities.values()),
39114
+ traitLinkedEntities: (() => {
39115
+ const map = /* @__PURE__ */ new Map();
39116
+ if (ir) {
39117
+ for (const page of ir.pages.values()) {
39118
+ for (const binding of page.traits) {
39119
+ if (binding.linkedEntity) {
39120
+ map.set(binding.trait.name, binding.linkedEntity);
39121
+ }
39122
+ }
39123
+ }
39124
+ }
39125
+ return map;
39126
+ })(),
39127
+ children: [
39128
+ /* @__PURE__ */ jsxRuntime.jsx(
39129
+ TraitInitializer,
39130
+ {
39131
+ traits: allPageTraits,
39132
+ orbitalNames: serverUrl ? orbitalNames : void 0,
39133
+ onNavigate,
39134
+ onLocalFallback,
39135
+ persistence
39136
+ }
39137
+ ),
39138
+ /* @__PURE__ */ jsxRuntime.jsx(SlotBridge, {}),
39139
+ /* @__PURE__ */ jsxRuntime.jsx(Box, { className: "h-full p-4", children: /* @__PURE__ */ jsxRuntime.jsx(UISlotRenderer, { includeHud: true, hudMode: "inline", includeFloating: true }) })
39140
+ ]
39141
+ }
39142
+ ) }) });
39107
39143
  if (serverUrl) {
39108
39144
  return /* @__PURE__ */ jsxRuntime.jsx(ServerBridgeProvider, { schema, serverUrl, children: inner });
39109
39145
  }
@@ -739,6 +739,7 @@ var init_usePullToRefresh = __esm({
739
739
  });
740
740
  function EntitySchemaProvider({
741
741
  entities,
742
+ traitLinkedEntities,
742
743
  children
743
744
  }) {
744
745
  const entitiesMap = useMemo(() => {
@@ -748,11 +749,15 @@ function EntitySchemaProvider({
748
749
  }
749
750
  return map;
750
751
  }, [entities]);
752
+ const linkedMap = useMemo(() => {
753
+ return traitLinkedEntities ?? /* @__PURE__ */ new Map();
754
+ }, [traitLinkedEntities]);
751
755
  const contextValue = useMemo(
752
756
  () => ({
753
- entities: entitiesMap
757
+ entities: entitiesMap,
758
+ traitLinkedEntities: linkedMap
754
759
  }),
755
- [entitiesMap]
760
+ [entitiesMap, linkedMap]
756
761
  );
757
762
  return /* @__PURE__ */ jsx(EntitySchemaContext.Provider, { value: contextValue, children });
758
763
  }
@@ -37581,7 +37586,7 @@ function getToastPosition(position) {
37581
37586
  return "top-4 right-4";
37582
37587
  }
37583
37588
  }
37584
- function renderPatternChildren(children, onDismiss, parentId = "root", parentPath = "root") {
37589
+ function renderPatternChildren(children, onDismiss, parentId = "root", parentPath = "root", sourceTrait) {
37585
37590
  if (!children || !Array.isArray(children) || children.length === 0) {
37586
37591
  return null;
37587
37592
  }
@@ -37608,7 +37613,11 @@ function renderPatternChildren(children, onDismiss, parentId = "root", parentPat
37608
37613
  pattern: child.type,
37609
37614
  props: resolvedProps,
37610
37615
  priority: 0,
37611
- nodeId: child._id
37616
+ nodeId: child._id,
37617
+ // Inherit sourceTrait from the parent slot so nested patterns
37618
+ // (e.g. form-section inside a stack) can resolve entityDef via
37619
+ // the trait's linkedEntity for form-field enrichment.
37620
+ ...sourceTrait !== void 0 && { sourceTrait }
37612
37621
  };
37613
37622
  return /* @__PURE__ */ jsx(
37614
37623
  SlotContentRenderer,
@@ -37659,13 +37668,21 @@ function SlotContentRenderer({
37659
37668
  }
37660
37669
  }
37661
37670
  const schemaCtx = useEntitySchemaOptional();
37662
- const entityDef = typeof entityProp === "string" && entityProp.length > 0 && schemaCtx ? schemaCtx.entities.get(entityProp) : void 0;
37671
+ let entityDef;
37672
+ if (typeof entityProp === "string" && entityProp.length > 0 && schemaCtx) {
37673
+ entityDef = schemaCtx.entities.get(entityProp);
37674
+ } else if (schemaCtx && content.sourceTrait !== void 0) {
37675
+ const linkedEntity = schemaCtx.traitLinkedEntities.get(content.sourceTrait);
37676
+ if (linkedEntity !== void 0) {
37677
+ entityDef = schemaCtx.entities.get(linkedEntity);
37678
+ }
37679
+ }
37663
37680
  const PatternComponent = getComponentForPattern(content.pattern);
37664
37681
  if (PatternComponent) {
37665
37682
  const childrenConfig = content.props.children;
37666
37683
  const hasChildren = PATTERNS_WITH_CHILDREN.has(content.pattern) || Array.isArray(childrenConfig) && childrenConfig.length > 0;
37667
37684
  const myPath = patternPath ?? "root";
37668
- const renderedChildren = hasChildren ? renderPatternChildren(childrenConfig, onDismiss, content.id, myPath) : void 0;
37685
+ const renderedChildren = hasChildren ? renderPatternChildren(childrenConfig, onDismiss, content.id, myPath, content.sourceTrait) : void 0;
37669
37686
  const { children: _childrenConfig, ...restProps } = content.props;
37670
37687
  const renderedProps = renderPatternProps(restProps, onDismiss);
37671
37688
  const finalProps = renderedProps;
@@ -39045,20 +39062,39 @@ function SchemaRunner({ schema, serverUrl, mockData, pageName, onNavigate, onLoc
39045
39062
  if (!orbitals) return [];
39046
39063
  return orbitals.filter((o) => typeof o.name === "string").map((o) => o.name);
39047
39064
  }, [schema]);
39048
- const inner = /* @__PURE__ */ jsx(VerificationProvider, { enabled: true, children: /* @__PURE__ */ jsx(SlotsProvider, { children: /* @__PURE__ */ jsxs(EntitySchemaProvider, { entities: Array.from(allEntities.values()), children: [
39049
- /* @__PURE__ */ jsx(
39050
- TraitInitializer,
39051
- {
39052
- traits: allPageTraits,
39053
- orbitalNames: serverUrl ? orbitalNames : void 0,
39054
- onNavigate,
39055
- onLocalFallback,
39056
- persistence
39057
- }
39058
- ),
39059
- /* @__PURE__ */ jsx(SlotBridge, {}),
39060
- /* @__PURE__ */ jsx(Box, { className: "h-full p-4", children: /* @__PURE__ */ jsx(UISlotRenderer, { includeHud: true, hudMode: "inline", includeFloating: true }) })
39061
- ] }) }) });
39065
+ const inner = /* @__PURE__ */ jsx(VerificationProvider, { enabled: true, children: /* @__PURE__ */ jsx(SlotsProvider, { children: /* @__PURE__ */ jsxs(
39066
+ EntitySchemaProvider,
39067
+ {
39068
+ entities: Array.from(allEntities.values()),
39069
+ traitLinkedEntities: (() => {
39070
+ const map = /* @__PURE__ */ new Map();
39071
+ if (ir) {
39072
+ for (const page of ir.pages.values()) {
39073
+ for (const binding of page.traits) {
39074
+ if (binding.linkedEntity) {
39075
+ map.set(binding.trait.name, binding.linkedEntity);
39076
+ }
39077
+ }
39078
+ }
39079
+ }
39080
+ return map;
39081
+ })(),
39082
+ children: [
39083
+ /* @__PURE__ */ jsx(
39084
+ TraitInitializer,
39085
+ {
39086
+ traits: allPageTraits,
39087
+ orbitalNames: serverUrl ? orbitalNames : void 0,
39088
+ onNavigate,
39089
+ onLocalFallback,
39090
+ persistence
39091
+ }
39092
+ ),
39093
+ /* @__PURE__ */ jsx(SlotBridge, {}),
39094
+ /* @__PURE__ */ jsx(Box, { className: "h-full p-4", children: /* @__PURE__ */ jsx(UISlotRenderer, { includeHud: true, hudMode: "inline", includeFloating: true }) })
39095
+ ]
39096
+ }
39097
+ ) }) });
39062
39098
  if (serverUrl) {
39063
39099
  return /* @__PURE__ */ jsx(ServerBridgeProvider, { schema, serverUrl, children: inner });
39064
39100
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@almadar/ui",
3
- "version": "4.6.1",
3
+ "version": "4.6.3",
4
4
  "description": "React UI components, hooks, and providers for Almadar",
5
5
  "type": "module",
6
6
  "main": "./dist/components/index.js",