@almadar/ui 4.15.2 → 4.15.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.
@@ -22005,25 +22005,15 @@ function DataGrid({
22005
22005
  }
22006
22006
  const hasRenderProp = typeof children === "function";
22007
22007
  React127.useEffect(() => {
22008
- const renderItemTypeOf = typeof schemaRenderItem;
22009
- const childrenTypeOf = typeof children;
22010
- if (data.length > 0 && !hasRenderProp) {
22011
- const firstRow = data[0];
22012
- const sampleKeys = firstRow ? Object.keys(firstRow).slice(0, 6) : [];
22008
+ if (data.length > 0 && !hasRenderProp && (!fields || fields.length === 0)) {
22013
22009
  const renderItemRaw = schemaRenderItem;
22014
22010
  const isFnLambda = Array.isArray(renderItemRaw) && renderItemRaw.length >= 3 && (renderItemRaw[0] === "fn" || renderItemRaw[0] === "lambda");
22015
22011
  dataGridLog.warn("renderItem-unresolved", {
22016
22012
  rowCount: data.length,
22017
- fieldsCount: fields?.length ?? 0,
22018
- renderItemTypeOf,
22019
- renderItemIsArray: Array.isArray(renderItemRaw),
22020
- renderItemIsFnLambda: isFnLambda,
22021
- renderItemHead: Array.isArray(renderItemRaw) ? String(renderItemRaw[0]) : void 0,
22022
- childrenTypeOf,
22023
- sampleRowKeys: sampleKeys
22013
+ renderItemIsFnLambda: isFnLambda
22024
22014
  });
22025
22015
  }
22026
- }, [data, hasRenderProp, schemaRenderItem, children, fields]);
22016
+ }, [data, hasRenderProp, schemaRenderItem, fields]);
22027
22017
  const allIds = data.map((item, i) => item.id || String(i));
22028
22018
  const allSelected = allIds.length > 0 && allIds.every((id) => selectedIds.has(id));
22029
22019
  const someSelected = selectedIds.size > 0;
@@ -46990,40 +46980,6 @@ function renderPatternChildren(children, onDismiss, parentId = "root", parentPat
46990
46980
  function isPatternConfig(value) {
46991
46981
  return value !== null && typeof value === "object" && !Array.isArray(value) && "type" in value && typeof value.type === "string";
46992
46982
  }
46993
- function isFnFormLambda(value) {
46994
- return Array.isArray(value) && value.length === 3 && value[0] === "fn" && typeof value[1] === "string" && value[2] !== null && typeof value[2] === "object";
46995
- }
46996
- function resolveLambdaBindings(body, argName, arg) {
46997
- const prefix = `@${argName}.`;
46998
- const lookup = (path) => {
46999
- let cur = arg;
47000
- for (const seg of path.split(".")) {
47001
- if (cur === null || cur === void 0) return void 0;
47002
- if (typeof cur !== "object") return void 0;
47003
- cur = cur[seg];
47004
- }
47005
- return cur;
47006
- };
47007
- if (typeof body === "string") {
47008
- if (body === `@${argName}`) return arg;
47009
- if (body.startsWith(prefix)) {
47010
- const v = lookup(body.slice(prefix.length));
47011
- return v === void 0 || v === null ? "" : v;
47012
- }
47013
- return body;
47014
- }
47015
- if (Array.isArray(body)) {
47016
- return body.map((b) => resolveLambdaBindings(b, argName, arg));
47017
- }
47018
- if (body !== null && typeof body === "object") {
47019
- const out = {};
47020
- for (const [k, v] of Object.entries(body)) {
47021
- out[k] = resolveLambdaBindings(v, argName, arg);
47022
- }
47023
- return out;
47024
- }
47025
- return body;
47026
- }
47027
46983
  function renderPatternProps(props, onDismiss) {
47028
46984
  const rendered = {};
47029
46985
  for (const [key, value] of Object.entries(props)) {
@@ -47039,26 +46995,6 @@ function renderPatternProps(props, onDismiss) {
47039
46995
  priority: 0
47040
46996
  };
47041
46997
  rendered[key] = /* @__PURE__ */ jsxRuntime.jsx(SlotContentRenderer, { content: childContent, onDismiss });
47042
- } else if (isFnFormLambda(value)) {
47043
- const [, argName, body] = value;
47044
- const lambdaBody = body;
47045
- const fn = (item, index) => {
47046
- const resolvedBody = resolveLambdaBindings(lambdaBody, argName, item);
47047
- if (!isPatternConfig(resolvedBody)) {
47048
- return null;
47049
- }
47050
- const childContent = {
47051
- id: `lambda-${key}-${index}`,
47052
- pattern: resolvedBody.type,
47053
- props: Object.fromEntries(
47054
- Object.entries(resolvedBody).filter(([k]) => k !== "type")
47055
- ),
47056
- priority: 0
47057
- };
47058
- return /* @__PURE__ */ jsxRuntime.jsx(SlotContentRenderer, { content: childContent, onDismiss });
47059
- };
47060
- const targetKey = key === "renderItem" ? "children" : key;
47061
- rendered[targetKey] = fn;
47062
46998
  } else {
47063
46999
  rendered[key] = value;
47064
47000
  }
@@ -47102,7 +47038,10 @@ function SlotContentRenderer({
47102
47038
  const hasChildren = PATTERNS_WITH_CHILDREN.has(content.pattern) || Array.isArray(childrenConfig) && childrenConfig.length > 0;
47103
47039
  const myPath = patternPath ?? "root";
47104
47040
  const renderedChildren = hasChildren ? renderPatternChildren(childrenConfig, onDismiss, content.id, myPath, content.sourceTrait) : void 0;
47105
- const { children: _childrenConfig, ...restProps } = content.props;
47041
+ const incomingChildren = content.props.children;
47042
+ const childrenIsRenderFn = typeof incomingChildren === "function";
47043
+ const { children: _childrenConfig, ...restPropsNoChildren } = content.props;
47044
+ const restProps = childrenIsRenderFn ? { ...restPropsNoChildren, children: incomingChildren } : restPropsNoChildren;
47106
47045
  const renderedProps = renderPatternProps(restProps, onDismiss);
47107
47046
  const finalProps = renderedProps;
47108
47047
  const resolvedItems = Array.isArray(
@@ -51640,6 +51579,114 @@ function collectEmbeddedTraits(schema) {
51640
51579
  return out;
51641
51580
  }
51642
51581
 
51582
+ // runtime/fn-form-lambda.ts
51583
+ init_logger();
51584
+ var lambdaLog = createLogger("almadar:ui:fn-form-lambda");
51585
+ function isFnFormLambda(value) {
51586
+ return Array.isArray(value) && value.length === 3 && value[0] === "fn" && typeof value[1] === "string" && value[2] !== null && typeof value[2] === "object";
51587
+ }
51588
+ function resolveLambdaBindings(body, argName, arg) {
51589
+ const prefix = `@${argName}.`;
51590
+ const lookup = (path) => {
51591
+ let cur = arg;
51592
+ for (const seg of path.split(".")) {
51593
+ if (cur === null || cur === void 0) return void 0;
51594
+ if (typeof cur !== "object") return void 0;
51595
+ cur = cur[seg];
51596
+ }
51597
+ return cur;
51598
+ };
51599
+ if (typeof body === "string") {
51600
+ if (body === `@${argName}`) return arg;
51601
+ if (body.startsWith(prefix)) {
51602
+ const v = lookup(body.slice(prefix.length));
51603
+ return v === void 0 || v === null ? "" : v;
51604
+ }
51605
+ return body;
51606
+ }
51607
+ if (Array.isArray(body)) {
51608
+ return body.map((b) => resolveLambdaBindings(b, argName, arg));
51609
+ }
51610
+ if (body !== null && typeof body === "object") {
51611
+ const out = {};
51612
+ for (const [k, v] of Object.entries(body)) {
51613
+ out[k] = resolveLambdaBindings(v, argName, arg);
51614
+ }
51615
+ return out;
51616
+ }
51617
+ return body;
51618
+ }
51619
+ var _slotContentRenderer2 = null;
51620
+ function getSlotContentRenderer2() {
51621
+ if (_slotContentRenderer2) return _slotContentRenderer2;
51622
+ const mod = (init_UISlotRenderer(), __toCommonJS(UISlotRenderer_exports));
51623
+ _slotContentRenderer2 = mod.SlotContentRenderer;
51624
+ return _slotContentRenderer2;
51625
+ }
51626
+ function makeLambdaFn(argName, lambdaBody, callerKey) {
51627
+ return (item, index) => {
51628
+ const resolvedBody = resolveLambdaBindings(lambdaBody, argName, item);
51629
+ if (resolvedBody === null || typeof resolvedBody !== "object" || Array.isArray(resolvedBody)) {
51630
+ return null;
51631
+ }
51632
+ const record = resolvedBody;
51633
+ if (typeof record.type !== "string") {
51634
+ return null;
51635
+ }
51636
+ const SlotContentRenderer2 = getSlotContentRenderer2();
51637
+ const childContent = {
51638
+ id: `lambda-${callerKey}-${index}`,
51639
+ pattern: record.type,
51640
+ props: Object.fromEntries(
51641
+ Object.entries(record).filter(([k]) => k !== "type")
51642
+ ),
51643
+ priority: 0
51644
+ };
51645
+ return React127__namespace.default.createElement(SlotContentRenderer2, { content: childContent });
51646
+ };
51647
+ }
51648
+ function convertNode(node, callerKey) {
51649
+ if (node === null || node === void 0) return node;
51650
+ if (Array.isArray(node)) {
51651
+ if (isFnFormLambda(node)) {
51652
+ const [, argName, body] = node;
51653
+ return makeLambdaFn(argName, body, callerKey);
51654
+ }
51655
+ let anyChanged = false;
51656
+ const mapped = node.map((item, i) => {
51657
+ const next = convertNode(item, `${callerKey}[${i}]`);
51658
+ if (next !== item) anyChanged = true;
51659
+ return next;
51660
+ });
51661
+ return anyChanged ? mapped : node;
51662
+ }
51663
+ if (typeof node === "object") {
51664
+ return convertObjectProps(node);
51665
+ }
51666
+ return node;
51667
+ }
51668
+ function convertObjectProps(props) {
51669
+ let convertedAny = false;
51670
+ const out = {};
51671
+ for (const [key, value] of Object.entries(props)) {
51672
+ if (isFnFormLambda(value)) {
51673
+ convertedAny = true;
51674
+ const [, argName, body] = value;
51675
+ const targetKey = key === "renderItem" ? "children" : key;
51676
+ out[targetKey] = makeLambdaFn(argName, body, key);
51677
+ lambdaLog.debug(`convert key=${key} \u2192 ${targetKey}`);
51678
+ continue;
51679
+ }
51680
+ const next = convertNode(value, key);
51681
+ if (next !== value) convertedAny = true;
51682
+ out[key] = next;
51683
+ }
51684
+ return convertedAny ? out : props;
51685
+ }
51686
+ function convertFnFormLambdasInProps(props) {
51687
+ return convertObjectProps(props);
51688
+ }
51689
+
51643
51690
  // hooks/index.ts
51644
51691
  init_useEventBus();
51645
51692
  init_useUISlots();
@@ -51772,11 +51819,12 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
51772
51819
  const last = patterns[patterns.length - 1];
51773
51820
  const record = last.pattern ?? {};
51774
51821
  const { type: patternType, children: nested, ...inlineProps } = record;
51775
- const props = {
51822
+ const rawProps = {
51776
51823
  ...inlineProps,
51777
51824
  ...last.props,
51778
51825
  ...nested !== void 0 ? { children: nested } : {}
51779
51826
  };
51827
+ const props = convertFnFormLambdasInProps(rawProps);
51780
51828
  const isEmbedded = embedded?.has(traitName) ?? false;
51781
51829
  if (isEmbedded) {
51782
51830
  flushLog.info("embed-route", {
@@ -52069,8 +52117,15 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
52069
52117
  payload: payload || {},
52070
52118
  state: result.previousState
52071
52119
  };
52072
- if (binding.config) {
52073
- sharedBindings.config = binding.config;
52120
+ const sharedDeclared = runtime.collectDeclaredConfigDefaults(
52121
+ binding.trait
52122
+ );
52123
+ const sharedCallSite = binding.config;
52124
+ if (sharedDeclared || sharedCallSite) {
52125
+ sharedBindings.config = {
52126
+ ...sharedDeclared ?? {},
52127
+ ...sharedCallSite ?? {}
52128
+ };
52074
52129
  }
52075
52130
  const serverHandlers = runtime.createServerEffectHandlers({
52076
52131
  persistence,
@@ -52104,8 +52159,15 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
52104
52159
  payload: payload || {},
52105
52160
  state: result.previousState
52106
52161
  };
52107
- if (binding.config) {
52108
- bindingCtx.config = binding.config;
52162
+ const declaredDefaults = runtime.collectDeclaredConfigDefaults(
52163
+ binding.trait
52164
+ );
52165
+ const callSiteConfig = binding.config;
52166
+ if (declaredDefaults || callSiteConfig) {
52167
+ bindingCtx.config = {
52168
+ ...declaredDefaults ?? {},
52169
+ ...callSiteConfig ?? {}
52170
+ };
52109
52171
  }
52110
52172
  const effectContext = {
52111
52173
  traitName: binding.trait.name,
@@ -52611,10 +52673,11 @@ function applyServerEffects(effects, uiSlots, onNavigate, embeddedTraits) {
52611
52673
  const normalizedChildren = Array.isArray(children) ? children.map((c) => normalizeChild(c)) : children;
52612
52674
  const sourceTrait = eff.traitName ?? "server";
52613
52675
  const isEmbedded = embeddedTraits?.has(sourceTrait) ?? false;
52614
- const props = {
52676
+ const rawProps = {
52615
52677
  ...inlineProps,
52616
52678
  ...normalizedChildren !== void 0 ? { children: normalizedChildren } : {}
52617
52679
  };
52680
+ const props = convertFnFormLambdasInProps(rawProps);
52618
52681
  if (isEmbedded) {
52619
52682
  xOrbitalLog2.info("slot:embed-routed", {
52620
52683
  sourceTrait,
package/dist/avl/index.js CHANGED
@@ -43,7 +43,7 @@ import { EffectComposer, Bloom, DepthOfField, Vignette } from '@react-three/post
43
43
  import ELK from 'elkjs/lib/elk.bundled.js';
44
44
  import { MarkerType, Handle, Position, getBezierPath, EdgeLabelRenderer, BaseEdge, ReactFlowProvider, useNodesState, useEdgesState, useReactFlow, ReactFlow, Controls, Background, BackgroundVariant } from '@xyflow/react';
45
45
  import '@tanstack/react-query';
46
- import { InMemoryPersistence, StateMachineManager, createContextFromBindings, interpolateValue, createServerEffectHandlers, EffectExecutor } from '@almadar/runtime';
46
+ import { InMemoryPersistence, StateMachineManager, createContextFromBindings, interpolateValue, collectDeclaredConfigDefaults, createServerEffectHandlers, EffectExecutor } from '@almadar/runtime';
47
47
 
48
48
  var __defProp = Object.defineProperty;
49
49
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -21959,25 +21959,15 @@ function DataGrid({
21959
21959
  }
21960
21960
  const hasRenderProp = typeof children === "function";
21961
21961
  useEffect(() => {
21962
- const renderItemTypeOf = typeof schemaRenderItem;
21963
- const childrenTypeOf = typeof children;
21964
- if (data.length > 0 && !hasRenderProp) {
21965
- const firstRow = data[0];
21966
- const sampleKeys = firstRow ? Object.keys(firstRow).slice(0, 6) : [];
21962
+ if (data.length > 0 && !hasRenderProp && (!fields || fields.length === 0)) {
21967
21963
  const renderItemRaw = schemaRenderItem;
21968
21964
  const isFnLambda = Array.isArray(renderItemRaw) && renderItemRaw.length >= 3 && (renderItemRaw[0] === "fn" || renderItemRaw[0] === "lambda");
21969
21965
  dataGridLog.warn("renderItem-unresolved", {
21970
21966
  rowCount: data.length,
21971
- fieldsCount: fields?.length ?? 0,
21972
- renderItemTypeOf,
21973
- renderItemIsArray: Array.isArray(renderItemRaw),
21974
- renderItemIsFnLambda: isFnLambda,
21975
- renderItemHead: Array.isArray(renderItemRaw) ? String(renderItemRaw[0]) : void 0,
21976
- childrenTypeOf,
21977
- sampleRowKeys: sampleKeys
21967
+ renderItemIsFnLambda: isFnLambda
21978
21968
  });
21979
21969
  }
21980
- }, [data, hasRenderProp, schemaRenderItem, children, fields]);
21970
+ }, [data, hasRenderProp, schemaRenderItem, fields]);
21981
21971
  const allIds = data.map((item, i) => item.id || String(i));
21982
21972
  const allSelected = allIds.length > 0 && allIds.every((id) => selectedIds.has(id));
21983
21973
  const someSelected = selectedIds.size > 0;
@@ -46944,40 +46934,6 @@ function renderPatternChildren(children, onDismiss, parentId = "root", parentPat
46944
46934
  function isPatternConfig(value) {
46945
46935
  return value !== null && typeof value === "object" && !Array.isArray(value) && "type" in value && typeof value.type === "string";
46946
46936
  }
46947
- function isFnFormLambda(value) {
46948
- return Array.isArray(value) && value.length === 3 && value[0] === "fn" && typeof value[1] === "string" && value[2] !== null && typeof value[2] === "object";
46949
- }
46950
- function resolveLambdaBindings(body, argName, arg) {
46951
- const prefix = `@${argName}.`;
46952
- const lookup = (path) => {
46953
- let cur = arg;
46954
- for (const seg of path.split(".")) {
46955
- if (cur === null || cur === void 0) return void 0;
46956
- if (typeof cur !== "object") return void 0;
46957
- cur = cur[seg];
46958
- }
46959
- return cur;
46960
- };
46961
- if (typeof body === "string") {
46962
- if (body === `@${argName}`) return arg;
46963
- if (body.startsWith(prefix)) {
46964
- const v = lookup(body.slice(prefix.length));
46965
- return v === void 0 || v === null ? "" : v;
46966
- }
46967
- return body;
46968
- }
46969
- if (Array.isArray(body)) {
46970
- return body.map((b) => resolveLambdaBindings(b, argName, arg));
46971
- }
46972
- if (body !== null && typeof body === "object") {
46973
- const out = {};
46974
- for (const [k, v] of Object.entries(body)) {
46975
- out[k] = resolveLambdaBindings(v, argName, arg);
46976
- }
46977
- return out;
46978
- }
46979
- return body;
46980
- }
46981
46937
  function renderPatternProps(props, onDismiss) {
46982
46938
  const rendered = {};
46983
46939
  for (const [key, value] of Object.entries(props)) {
@@ -46993,26 +46949,6 @@ function renderPatternProps(props, onDismiss) {
46993
46949
  priority: 0
46994
46950
  };
46995
46951
  rendered[key] = /* @__PURE__ */ jsx(SlotContentRenderer, { content: childContent, onDismiss });
46996
- } else if (isFnFormLambda(value)) {
46997
- const [, argName, body] = value;
46998
- const lambdaBody = body;
46999
- const fn = (item, index) => {
47000
- const resolvedBody = resolveLambdaBindings(lambdaBody, argName, item);
47001
- if (!isPatternConfig(resolvedBody)) {
47002
- return null;
47003
- }
47004
- const childContent = {
47005
- id: `lambda-${key}-${index}`,
47006
- pattern: resolvedBody.type,
47007
- props: Object.fromEntries(
47008
- Object.entries(resolvedBody).filter(([k]) => k !== "type")
47009
- ),
47010
- priority: 0
47011
- };
47012
- return /* @__PURE__ */ jsx(SlotContentRenderer, { content: childContent, onDismiss });
47013
- };
47014
- const targetKey = key === "renderItem" ? "children" : key;
47015
- rendered[targetKey] = fn;
47016
46952
  } else {
47017
46953
  rendered[key] = value;
47018
46954
  }
@@ -47056,7 +46992,10 @@ function SlotContentRenderer({
47056
46992
  const hasChildren = PATTERNS_WITH_CHILDREN.has(content.pattern) || Array.isArray(childrenConfig) && childrenConfig.length > 0;
47057
46993
  const myPath = patternPath ?? "root";
47058
46994
  const renderedChildren = hasChildren ? renderPatternChildren(childrenConfig, onDismiss, content.id, myPath, content.sourceTrait) : void 0;
47059
- const { children: _childrenConfig, ...restProps } = content.props;
46995
+ const incomingChildren = content.props.children;
46996
+ const childrenIsRenderFn = typeof incomingChildren === "function";
46997
+ const { children: _childrenConfig, ...restPropsNoChildren } = content.props;
46998
+ const restProps = childrenIsRenderFn ? { ...restPropsNoChildren, children: incomingChildren } : restPropsNoChildren;
47060
46999
  const renderedProps = renderPatternProps(restProps, onDismiss);
47061
47000
  const finalProps = renderedProps;
47062
47001
  const resolvedItems = Array.isArray(
@@ -51594,6 +51533,114 @@ function collectEmbeddedTraits(schema) {
51594
51533
  return out;
51595
51534
  }
51596
51535
 
51536
+ // runtime/fn-form-lambda.ts
51537
+ init_logger();
51538
+ var lambdaLog = createLogger("almadar:ui:fn-form-lambda");
51539
+ function isFnFormLambda(value) {
51540
+ return Array.isArray(value) && value.length === 3 && value[0] === "fn" && typeof value[1] === "string" && value[2] !== null && typeof value[2] === "object";
51541
+ }
51542
+ function resolveLambdaBindings(body, argName, arg) {
51543
+ const prefix = `@${argName}.`;
51544
+ const lookup = (path) => {
51545
+ let cur = arg;
51546
+ for (const seg of path.split(".")) {
51547
+ if (cur === null || cur === void 0) return void 0;
51548
+ if (typeof cur !== "object") return void 0;
51549
+ cur = cur[seg];
51550
+ }
51551
+ return cur;
51552
+ };
51553
+ if (typeof body === "string") {
51554
+ if (body === `@${argName}`) return arg;
51555
+ if (body.startsWith(prefix)) {
51556
+ const v = lookup(body.slice(prefix.length));
51557
+ return v === void 0 || v === null ? "" : v;
51558
+ }
51559
+ return body;
51560
+ }
51561
+ if (Array.isArray(body)) {
51562
+ return body.map((b) => resolveLambdaBindings(b, argName, arg));
51563
+ }
51564
+ if (body !== null && typeof body === "object") {
51565
+ const out = {};
51566
+ for (const [k, v] of Object.entries(body)) {
51567
+ out[k] = resolveLambdaBindings(v, argName, arg);
51568
+ }
51569
+ return out;
51570
+ }
51571
+ return body;
51572
+ }
51573
+ var _slotContentRenderer2 = null;
51574
+ function getSlotContentRenderer2() {
51575
+ if (_slotContentRenderer2) return _slotContentRenderer2;
51576
+ const mod = (init_UISlotRenderer(), __toCommonJS(UISlotRenderer_exports));
51577
+ _slotContentRenderer2 = mod.SlotContentRenderer;
51578
+ return _slotContentRenderer2;
51579
+ }
51580
+ function makeLambdaFn(argName, lambdaBody, callerKey) {
51581
+ return (item, index) => {
51582
+ const resolvedBody = resolveLambdaBindings(lambdaBody, argName, item);
51583
+ if (resolvedBody === null || typeof resolvedBody !== "object" || Array.isArray(resolvedBody)) {
51584
+ return null;
51585
+ }
51586
+ const record = resolvedBody;
51587
+ if (typeof record.type !== "string") {
51588
+ return null;
51589
+ }
51590
+ const SlotContentRenderer2 = getSlotContentRenderer2();
51591
+ const childContent = {
51592
+ id: `lambda-${callerKey}-${index}`,
51593
+ pattern: record.type,
51594
+ props: Object.fromEntries(
51595
+ Object.entries(record).filter(([k]) => k !== "type")
51596
+ ),
51597
+ priority: 0
51598
+ };
51599
+ return React127__default.createElement(SlotContentRenderer2, { content: childContent });
51600
+ };
51601
+ }
51602
+ function convertNode(node, callerKey) {
51603
+ if (node === null || node === void 0) return node;
51604
+ if (Array.isArray(node)) {
51605
+ if (isFnFormLambda(node)) {
51606
+ const [, argName, body] = node;
51607
+ return makeLambdaFn(argName, body, callerKey);
51608
+ }
51609
+ let anyChanged = false;
51610
+ const mapped = node.map((item, i) => {
51611
+ const next = convertNode(item, `${callerKey}[${i}]`);
51612
+ if (next !== item) anyChanged = true;
51613
+ return next;
51614
+ });
51615
+ return anyChanged ? mapped : node;
51616
+ }
51617
+ if (typeof node === "object") {
51618
+ return convertObjectProps(node);
51619
+ }
51620
+ return node;
51621
+ }
51622
+ function convertObjectProps(props) {
51623
+ let convertedAny = false;
51624
+ const out = {};
51625
+ for (const [key, value] of Object.entries(props)) {
51626
+ if (isFnFormLambda(value)) {
51627
+ convertedAny = true;
51628
+ const [, argName, body] = value;
51629
+ const targetKey = key === "renderItem" ? "children" : key;
51630
+ out[targetKey] = makeLambdaFn(argName, body, key);
51631
+ lambdaLog.debug(`convert key=${key} \u2192 ${targetKey}`);
51632
+ continue;
51633
+ }
51634
+ const next = convertNode(value, key);
51635
+ if (next !== value) convertedAny = true;
51636
+ out[key] = next;
51637
+ }
51638
+ return convertedAny ? out : props;
51639
+ }
51640
+ function convertFnFormLambdasInProps(props) {
51641
+ return convertObjectProps(props);
51642
+ }
51643
+
51597
51644
  // hooks/index.ts
51598
51645
  init_useEventBus();
51599
51646
  init_useUISlots();
@@ -51726,11 +51773,12 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
51726
51773
  const last = patterns[patterns.length - 1];
51727
51774
  const record = last.pattern ?? {};
51728
51775
  const { type: patternType, children: nested, ...inlineProps } = record;
51729
- const props = {
51776
+ const rawProps = {
51730
51777
  ...inlineProps,
51731
51778
  ...last.props,
51732
51779
  ...nested !== void 0 ? { children: nested } : {}
51733
51780
  };
51781
+ const props = convertFnFormLambdasInProps(rawProps);
51734
51782
  const isEmbedded = embedded?.has(traitName) ?? false;
51735
51783
  if (isEmbedded) {
51736
51784
  flushLog.info("embed-route", {
@@ -52023,8 +52071,15 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
52023
52071
  payload: payload || {},
52024
52072
  state: result.previousState
52025
52073
  };
52026
- if (binding.config) {
52027
- sharedBindings.config = binding.config;
52074
+ const sharedDeclared = collectDeclaredConfigDefaults(
52075
+ binding.trait
52076
+ );
52077
+ const sharedCallSite = binding.config;
52078
+ if (sharedDeclared || sharedCallSite) {
52079
+ sharedBindings.config = {
52080
+ ...sharedDeclared ?? {},
52081
+ ...sharedCallSite ?? {}
52082
+ };
52028
52083
  }
52029
52084
  const serverHandlers = createServerEffectHandlers({
52030
52085
  persistence,
@@ -52058,8 +52113,15 @@ function useTraitStateMachine(traitBindings, uiSlots, options) {
52058
52113
  payload: payload || {},
52059
52114
  state: result.previousState
52060
52115
  };
52061
- if (binding.config) {
52062
- bindingCtx.config = binding.config;
52116
+ const declaredDefaults = collectDeclaredConfigDefaults(
52117
+ binding.trait
52118
+ );
52119
+ const callSiteConfig = binding.config;
52120
+ if (declaredDefaults || callSiteConfig) {
52121
+ bindingCtx.config = {
52122
+ ...declaredDefaults ?? {},
52123
+ ...callSiteConfig ?? {}
52124
+ };
52063
52125
  }
52064
52126
  const effectContext = {
52065
52127
  traitName: binding.trait.name,
@@ -52565,10 +52627,11 @@ function applyServerEffects(effects, uiSlots, onNavigate, embeddedTraits) {
52565
52627
  const normalizedChildren = Array.isArray(children) ? children.map((c) => normalizeChild(c)) : children;
52566
52628
  const sourceTrait = eff.traitName ?? "server";
52567
52629
  const isEmbedded = embeddedTraits?.has(sourceTrait) ?? false;
52568
- const props = {
52630
+ const rawProps = {
52569
52631
  ...inlineProps,
52570
52632
  ...normalizedChildren !== void 0 ? { children: normalizedChildren } : {}
52571
52633
  };
52634
+ const props = convertFnFormLambdasInProps(rawProps);
52572
52635
  if (isEmbedded) {
52573
52636
  xOrbitalLog2.info("slot:embed-routed", {
52574
52637
  sourceTrait,
@@ -17446,25 +17446,15 @@ function DataGrid({
17446
17446
  }
17447
17447
  const hasRenderProp = typeof children === "function";
17448
17448
  React110.useEffect(() => {
17449
- const renderItemTypeOf = typeof schemaRenderItem;
17450
- const childrenTypeOf = typeof children;
17451
- if (data.length > 0 && !hasRenderProp) {
17452
- const firstRow = data[0];
17453
- const sampleKeys = firstRow ? Object.keys(firstRow).slice(0, 6) : [];
17449
+ if (data.length > 0 && !hasRenderProp && (!fields || fields.length === 0)) {
17454
17450
  const renderItemRaw = schemaRenderItem;
17455
17451
  const isFnLambda = Array.isArray(renderItemRaw) && renderItemRaw.length >= 3 && (renderItemRaw[0] === "fn" || renderItemRaw[0] === "lambda");
17456
17452
  dataGridLog.warn("renderItem-unresolved", {
17457
17453
  rowCount: data.length,
17458
- fieldsCount: fields?.length ?? 0,
17459
- renderItemTypeOf,
17460
- renderItemIsArray: Array.isArray(renderItemRaw),
17461
- renderItemIsFnLambda: isFnLambda,
17462
- renderItemHead: Array.isArray(renderItemRaw) ? String(renderItemRaw[0]) : void 0,
17463
- childrenTypeOf,
17464
- sampleRowKeys: sampleKeys
17454
+ renderItemIsFnLambda: isFnLambda
17465
17455
  });
17466
17456
  }
17467
- }, [data, hasRenderProp, schemaRenderItem, children, fields]);
17457
+ }, [data, hasRenderProp, schemaRenderItem, fields]);
17468
17458
  const allIds = data.map((item, i) => item.id || String(i));
17469
17459
  const allSelected = allIds.length > 0 && allIds.every((id) => selectedIds.has(id));
17470
17460
  const someSelected = selectedIds.size > 0;
@@ -37749,40 +37739,6 @@ function renderPatternChildren(children, onDismiss, parentId = "root", parentPat
37749
37739
  function isPatternConfig(value) {
37750
37740
  return value !== null && typeof value === "object" && !Array.isArray(value) && "type" in value && typeof value.type === "string";
37751
37741
  }
37752
- function isFnFormLambda(value) {
37753
- return Array.isArray(value) && value.length === 3 && value[0] === "fn" && typeof value[1] === "string" && value[2] !== null && typeof value[2] === "object";
37754
- }
37755
- function resolveLambdaBindings(body, argName, arg) {
37756
- const prefix = `@${argName}.`;
37757
- const lookup = (path) => {
37758
- let cur = arg;
37759
- for (const seg of path.split(".")) {
37760
- if (cur === null || cur === void 0) return void 0;
37761
- if (typeof cur !== "object") return void 0;
37762
- cur = cur[seg];
37763
- }
37764
- return cur;
37765
- };
37766
- if (typeof body === "string") {
37767
- if (body === `@${argName}`) return arg;
37768
- if (body.startsWith(prefix)) {
37769
- const v = lookup(body.slice(prefix.length));
37770
- return v === void 0 || v === null ? "" : v;
37771
- }
37772
- return body;
37773
- }
37774
- if (Array.isArray(body)) {
37775
- return body.map((b) => resolveLambdaBindings(b, argName, arg));
37776
- }
37777
- if (body !== null && typeof body === "object") {
37778
- const out = {};
37779
- for (const [k, v] of Object.entries(body)) {
37780
- out[k] = resolveLambdaBindings(v, argName, arg);
37781
- }
37782
- return out;
37783
- }
37784
- return body;
37785
- }
37786
37742
  function renderPatternProps(props, onDismiss) {
37787
37743
  const rendered = {};
37788
37744
  for (const [key, value] of Object.entries(props)) {
@@ -37798,26 +37754,6 @@ function renderPatternProps(props, onDismiss) {
37798
37754
  priority: 0
37799
37755
  };
37800
37756
  rendered[key] = /* @__PURE__ */ jsxRuntime.jsx(SlotContentRenderer, { content: childContent, onDismiss });
37801
- } else if (isFnFormLambda(value)) {
37802
- const [, argName, body] = value;
37803
- const lambdaBody = body;
37804
- const fn = (item, index) => {
37805
- const resolvedBody = resolveLambdaBindings(lambdaBody, argName, item);
37806
- if (!isPatternConfig(resolvedBody)) {
37807
- return null;
37808
- }
37809
- const childContent = {
37810
- id: `lambda-${key}-${index}`,
37811
- pattern: resolvedBody.type,
37812
- props: Object.fromEntries(
37813
- Object.entries(resolvedBody).filter(([k]) => k !== "type")
37814
- ),
37815
- priority: 0
37816
- };
37817
- return /* @__PURE__ */ jsxRuntime.jsx(SlotContentRenderer, { content: childContent, onDismiss });
37818
- };
37819
- const targetKey = key === "renderItem" ? "children" : key;
37820
- rendered[targetKey] = fn;
37821
37757
  } else {
37822
37758
  rendered[key] = value;
37823
37759
  }
@@ -37861,7 +37797,10 @@ function SlotContentRenderer({
37861
37797
  const hasChildren = PATTERNS_WITH_CHILDREN.has(content.pattern) || Array.isArray(childrenConfig) && childrenConfig.length > 0;
37862
37798
  const myPath = patternPath ?? "root";
37863
37799
  const renderedChildren = hasChildren ? renderPatternChildren(childrenConfig, onDismiss, content.id, myPath, content.sourceTrait) : void 0;
37864
- const { children: _childrenConfig, ...restProps } = content.props;
37800
+ const incomingChildren = content.props.children;
37801
+ const childrenIsRenderFn = typeof incomingChildren === "function";
37802
+ const { children: _childrenConfig, ...restPropsNoChildren } = content.props;
37803
+ const restProps = childrenIsRenderFn ? { ...restPropsNoChildren, children: incomingChildren } : restPropsNoChildren;
37865
37804
  const renderedProps = renderPatternProps(restProps, onDismiss);
37866
37805
  const finalProps = renderedProps;
37867
37806
  const resolvedItems = Array.isArray(