@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.
@@ -17401,25 +17401,15 @@ function DataGrid({
17401
17401
  }
17402
17402
  const hasRenderProp = typeof children === "function";
17403
17403
  useEffect(() => {
17404
- const renderItemTypeOf = typeof schemaRenderItem;
17405
- const childrenTypeOf = typeof children;
17406
- if (data.length > 0 && !hasRenderProp) {
17407
- const firstRow = data[0];
17408
- const sampleKeys = firstRow ? Object.keys(firstRow).slice(0, 6) : [];
17404
+ if (data.length > 0 && !hasRenderProp && (!fields || fields.length === 0)) {
17409
17405
  const renderItemRaw = schemaRenderItem;
17410
17406
  const isFnLambda = Array.isArray(renderItemRaw) && renderItemRaw.length >= 3 && (renderItemRaw[0] === "fn" || renderItemRaw[0] === "lambda");
17411
17407
  dataGridLog.warn("renderItem-unresolved", {
17412
17408
  rowCount: data.length,
17413
- fieldsCount: fields?.length ?? 0,
17414
- renderItemTypeOf,
17415
- renderItemIsArray: Array.isArray(renderItemRaw),
17416
- renderItemIsFnLambda: isFnLambda,
17417
- renderItemHead: Array.isArray(renderItemRaw) ? String(renderItemRaw[0]) : void 0,
17418
- childrenTypeOf,
17419
- sampleRowKeys: sampleKeys
17409
+ renderItemIsFnLambda: isFnLambda
17420
17410
  });
17421
17411
  }
17422
- }, [data, hasRenderProp, schemaRenderItem, children, fields]);
17412
+ }, [data, hasRenderProp, schemaRenderItem, fields]);
17423
17413
  const allIds = data.map((item, i) => item.id || String(i));
17424
17414
  const allSelected = allIds.length > 0 && allIds.every((id) => selectedIds.has(id));
17425
17415
  const someSelected = selectedIds.size > 0;
@@ -37704,40 +37694,6 @@ function renderPatternChildren(children, onDismiss, parentId = "root", parentPat
37704
37694
  function isPatternConfig(value) {
37705
37695
  return value !== null && typeof value === "object" && !Array.isArray(value) && "type" in value && typeof value.type === "string";
37706
37696
  }
37707
- function isFnFormLambda(value) {
37708
- return Array.isArray(value) && value.length === 3 && value[0] === "fn" && typeof value[1] === "string" && value[2] !== null && typeof value[2] === "object";
37709
- }
37710
- function resolveLambdaBindings(body, argName, arg) {
37711
- const prefix = `@${argName}.`;
37712
- const lookup = (path) => {
37713
- let cur = arg;
37714
- for (const seg of path.split(".")) {
37715
- if (cur === null || cur === void 0) return void 0;
37716
- if (typeof cur !== "object") return void 0;
37717
- cur = cur[seg];
37718
- }
37719
- return cur;
37720
- };
37721
- if (typeof body === "string") {
37722
- if (body === `@${argName}`) return arg;
37723
- if (body.startsWith(prefix)) {
37724
- const v = lookup(body.slice(prefix.length));
37725
- return v === void 0 || v === null ? "" : v;
37726
- }
37727
- return body;
37728
- }
37729
- if (Array.isArray(body)) {
37730
- return body.map((b) => resolveLambdaBindings(b, argName, arg));
37731
- }
37732
- if (body !== null && typeof body === "object") {
37733
- const out = {};
37734
- for (const [k, v] of Object.entries(body)) {
37735
- out[k] = resolveLambdaBindings(v, argName, arg);
37736
- }
37737
- return out;
37738
- }
37739
- return body;
37740
- }
37741
37697
  function renderPatternProps(props, onDismiss) {
37742
37698
  const rendered = {};
37743
37699
  for (const [key, value] of Object.entries(props)) {
@@ -37753,26 +37709,6 @@ function renderPatternProps(props, onDismiss) {
37753
37709
  priority: 0
37754
37710
  };
37755
37711
  rendered[key] = /* @__PURE__ */ jsx(SlotContentRenderer, { content: childContent, onDismiss });
37756
- } else if (isFnFormLambda(value)) {
37757
- const [, argName, body] = value;
37758
- const lambdaBody = body;
37759
- const fn = (item, index) => {
37760
- const resolvedBody = resolveLambdaBindings(lambdaBody, argName, item);
37761
- if (!isPatternConfig(resolvedBody)) {
37762
- return null;
37763
- }
37764
- const childContent = {
37765
- id: `lambda-${key}-${index}`,
37766
- pattern: resolvedBody.type,
37767
- props: Object.fromEntries(
37768
- Object.entries(resolvedBody).filter(([k]) => k !== "type")
37769
- ),
37770
- priority: 0
37771
- };
37772
- return /* @__PURE__ */ jsx(SlotContentRenderer, { content: childContent, onDismiss });
37773
- };
37774
- const targetKey = key === "renderItem" ? "children" : key;
37775
- rendered[targetKey] = fn;
37776
37712
  } else {
37777
37713
  rendered[key] = value;
37778
37714
  }
@@ -37816,7 +37752,10 @@ function SlotContentRenderer({
37816
37752
  const hasChildren = PATTERNS_WITH_CHILDREN.has(content.pattern) || Array.isArray(childrenConfig) && childrenConfig.length > 0;
37817
37753
  const myPath = patternPath ?? "root";
37818
37754
  const renderedChildren = hasChildren ? renderPatternChildren(childrenConfig, onDismiss, content.id, myPath, content.sourceTrait) : void 0;
37819
- const { children: _childrenConfig, ...restProps } = content.props;
37755
+ const incomingChildren = content.props.children;
37756
+ const childrenIsRenderFn = typeof incomingChildren === "function";
37757
+ const { children: _childrenConfig, ...restPropsNoChildren } = content.props;
37758
+ const restProps = childrenIsRenderFn ? { ...restPropsNoChildren, children: incomingChildren } : restPropsNoChildren;
37820
37759
  const renderedProps = renderPatternProps(restProps, onDismiss);
37821
37760
  const finalProps = renderedProps;
37822
37761
  const resolvedItems = Array.isArray(
@@ -18769,25 +18769,15 @@ function DataGrid({
18769
18769
  }
18770
18770
  const hasRenderProp = typeof children === "function";
18771
18771
  React115.useEffect(() => {
18772
- const renderItemTypeOf = typeof schemaRenderItem;
18773
- const childrenTypeOf = typeof children;
18774
- if (data.length > 0 && !hasRenderProp) {
18775
- const firstRow = data[0];
18776
- const sampleKeys = firstRow ? Object.keys(firstRow).slice(0, 6) : [];
18772
+ if (data.length > 0 && !hasRenderProp && (!fields || fields.length === 0)) {
18777
18773
  const renderItemRaw = schemaRenderItem;
18778
18774
  const isFnLambda = Array.isArray(renderItemRaw) && renderItemRaw.length >= 3 && (renderItemRaw[0] === "fn" || renderItemRaw[0] === "lambda");
18779
18775
  dataGridLog.warn("renderItem-unresolved", {
18780
18776
  rowCount: data.length,
18781
- fieldsCount: fields?.length ?? 0,
18782
- renderItemTypeOf,
18783
- renderItemIsArray: Array.isArray(renderItemRaw),
18784
- renderItemIsFnLambda: isFnLambda,
18785
- renderItemHead: Array.isArray(renderItemRaw) ? String(renderItemRaw[0]) : void 0,
18786
- childrenTypeOf,
18787
- sampleRowKeys: sampleKeys
18777
+ renderItemIsFnLambda: isFnLambda
18788
18778
  });
18789
18779
  }
18790
- }, [data, hasRenderProp, schemaRenderItem, children, fields]);
18780
+ }, [data, hasRenderProp, schemaRenderItem, fields]);
18791
18781
  const allIds = data.map((item, i) => item.id || String(i));
18792
18782
  const allSelected = allIds.length > 0 && allIds.every((id) => selectedIds.has(id));
18793
18783
  const someSelected = selectedIds.size > 0;
@@ -38269,40 +38259,6 @@ function renderPatternChildren(children, onDismiss, parentId = "root", parentPat
38269
38259
  function isPatternConfig(value) {
38270
38260
  return value !== null && typeof value === "object" && !Array.isArray(value) && "type" in value && typeof value.type === "string";
38271
38261
  }
38272
- function isFnFormLambda(value) {
38273
- return Array.isArray(value) && value.length === 3 && value[0] === "fn" && typeof value[1] === "string" && value[2] !== null && typeof value[2] === "object";
38274
- }
38275
- function resolveLambdaBindings(body, argName, arg) {
38276
- const prefix = `@${argName}.`;
38277
- const lookup = (path) => {
38278
- let cur = arg;
38279
- for (const seg of path.split(".")) {
38280
- if (cur === null || cur === void 0) return void 0;
38281
- if (typeof cur !== "object") return void 0;
38282
- cur = cur[seg];
38283
- }
38284
- return cur;
38285
- };
38286
- if (typeof body === "string") {
38287
- if (body === `@${argName}`) return arg;
38288
- if (body.startsWith(prefix)) {
38289
- const v = lookup(body.slice(prefix.length));
38290
- return v === void 0 || v === null ? "" : v;
38291
- }
38292
- return body;
38293
- }
38294
- if (Array.isArray(body)) {
38295
- return body.map((b) => resolveLambdaBindings(b, argName, arg));
38296
- }
38297
- if (body !== null && typeof body === "object") {
38298
- const out = {};
38299
- for (const [k, v] of Object.entries(body)) {
38300
- out[k] = resolveLambdaBindings(v, argName, arg);
38301
- }
38302
- return out;
38303
- }
38304
- return body;
38305
- }
38306
38262
  function renderPatternProps(props, onDismiss) {
38307
38263
  const rendered = {};
38308
38264
  for (const [key, value] of Object.entries(props)) {
@@ -38318,26 +38274,6 @@ function renderPatternProps(props, onDismiss) {
38318
38274
  priority: 0
38319
38275
  };
38320
38276
  rendered[key] = /* @__PURE__ */ jsxRuntime.jsx(SlotContentRenderer, { content: childContent, onDismiss });
38321
- } else if (isFnFormLambda(value)) {
38322
- const [, argName, body] = value;
38323
- const lambdaBody = body;
38324
- const fn = (item, index) => {
38325
- const resolvedBody = resolveLambdaBindings(lambdaBody, argName, item);
38326
- if (!isPatternConfig(resolvedBody)) {
38327
- return null;
38328
- }
38329
- const childContent = {
38330
- id: `lambda-${key}-${index}`,
38331
- pattern: resolvedBody.type,
38332
- props: Object.fromEntries(
38333
- Object.entries(resolvedBody).filter(([k]) => k !== "type")
38334
- ),
38335
- priority: 0
38336
- };
38337
- return /* @__PURE__ */ jsxRuntime.jsx(SlotContentRenderer, { content: childContent, onDismiss });
38338
- };
38339
- const targetKey = key === "renderItem" ? "children" : key;
38340
- rendered[targetKey] = fn;
38341
38277
  } else {
38342
38278
  rendered[key] = value;
38343
38279
  }
@@ -38381,7 +38317,10 @@ function SlotContentRenderer({
38381
38317
  const hasChildren = PATTERNS_WITH_CHILDREN.has(content.pattern) || Array.isArray(childrenConfig) && childrenConfig.length > 0;
38382
38318
  const myPath = patternPath ?? "root";
38383
38319
  const renderedChildren = hasChildren ? renderPatternChildren(childrenConfig, onDismiss, content.id, myPath, content.sourceTrait) : void 0;
38384
- const { children: _childrenConfig, ...restProps } = content.props;
38320
+ const incomingChildren = content.props.children;
38321
+ const childrenIsRenderFn = typeof incomingChildren === "function";
38322
+ const { children: _childrenConfig, ...restPropsNoChildren } = content.props;
38323
+ const restProps = childrenIsRenderFn ? { ...restPropsNoChildren, children: incomingChildren } : restPropsNoChildren;
38385
38324
  const renderedProps = renderPatternProps(restProps, onDismiss);
38386
38325
  const finalProps = renderedProps;
38387
38326
  const resolvedItems = Array.isArray(
@@ -18724,25 +18724,15 @@ function DataGrid({
18724
18724
  }
18725
18725
  const hasRenderProp = typeof children === "function";
18726
18726
  useEffect(() => {
18727
- const renderItemTypeOf = typeof schemaRenderItem;
18728
- const childrenTypeOf = typeof children;
18729
- if (data.length > 0 && !hasRenderProp) {
18730
- const firstRow = data[0];
18731
- const sampleKeys = firstRow ? Object.keys(firstRow).slice(0, 6) : [];
18727
+ if (data.length > 0 && !hasRenderProp && (!fields || fields.length === 0)) {
18732
18728
  const renderItemRaw = schemaRenderItem;
18733
18729
  const isFnLambda = Array.isArray(renderItemRaw) && renderItemRaw.length >= 3 && (renderItemRaw[0] === "fn" || renderItemRaw[0] === "lambda");
18734
18730
  dataGridLog.warn("renderItem-unresolved", {
18735
18731
  rowCount: data.length,
18736
- fieldsCount: fields?.length ?? 0,
18737
- renderItemTypeOf,
18738
- renderItemIsArray: Array.isArray(renderItemRaw),
18739
- renderItemIsFnLambda: isFnLambda,
18740
- renderItemHead: Array.isArray(renderItemRaw) ? String(renderItemRaw[0]) : void 0,
18741
- childrenTypeOf,
18742
- sampleRowKeys: sampleKeys
18732
+ renderItemIsFnLambda: isFnLambda
18743
18733
  });
18744
18734
  }
18745
- }, [data, hasRenderProp, schemaRenderItem, children, fields]);
18735
+ }, [data, hasRenderProp, schemaRenderItem, fields]);
18746
18736
  const allIds = data.map((item, i) => item.id || String(i));
18747
18737
  const allSelected = allIds.length > 0 && allIds.every((id) => selectedIds.has(id));
18748
18738
  const someSelected = selectedIds.size > 0;
@@ -38224,40 +38214,6 @@ function renderPatternChildren(children, onDismiss, parentId = "root", parentPat
38224
38214
  function isPatternConfig(value) {
38225
38215
  return value !== null && typeof value === "object" && !Array.isArray(value) && "type" in value && typeof value.type === "string";
38226
38216
  }
38227
- function isFnFormLambda(value) {
38228
- return Array.isArray(value) && value.length === 3 && value[0] === "fn" && typeof value[1] === "string" && value[2] !== null && typeof value[2] === "object";
38229
- }
38230
- function resolveLambdaBindings(body, argName, arg) {
38231
- const prefix = `@${argName}.`;
38232
- const lookup = (path) => {
38233
- let cur = arg;
38234
- for (const seg of path.split(".")) {
38235
- if (cur === null || cur === void 0) return void 0;
38236
- if (typeof cur !== "object") return void 0;
38237
- cur = cur[seg];
38238
- }
38239
- return cur;
38240
- };
38241
- if (typeof body === "string") {
38242
- if (body === `@${argName}`) return arg;
38243
- if (body.startsWith(prefix)) {
38244
- const v = lookup(body.slice(prefix.length));
38245
- return v === void 0 || v === null ? "" : v;
38246
- }
38247
- return body;
38248
- }
38249
- if (Array.isArray(body)) {
38250
- return body.map((b) => resolveLambdaBindings(b, argName, arg));
38251
- }
38252
- if (body !== null && typeof body === "object") {
38253
- const out = {};
38254
- for (const [k, v] of Object.entries(body)) {
38255
- out[k] = resolveLambdaBindings(v, argName, arg);
38256
- }
38257
- return out;
38258
- }
38259
- return body;
38260
- }
38261
38217
  function renderPatternProps(props, onDismiss) {
38262
38218
  const rendered = {};
38263
38219
  for (const [key, value] of Object.entries(props)) {
@@ -38273,26 +38229,6 @@ function renderPatternProps(props, onDismiss) {
38273
38229
  priority: 0
38274
38230
  };
38275
38231
  rendered[key] = /* @__PURE__ */ jsx(SlotContentRenderer, { content: childContent, onDismiss });
38276
- } else if (isFnFormLambda(value)) {
38277
- const [, argName, body] = value;
38278
- const lambdaBody = body;
38279
- const fn = (item, index) => {
38280
- const resolvedBody = resolveLambdaBindings(lambdaBody, argName, item);
38281
- if (!isPatternConfig(resolvedBody)) {
38282
- return null;
38283
- }
38284
- const childContent = {
38285
- id: `lambda-${key}-${index}`,
38286
- pattern: resolvedBody.type,
38287
- props: Object.fromEntries(
38288
- Object.entries(resolvedBody).filter(([k]) => k !== "type")
38289
- ),
38290
- priority: 0
38291
- };
38292
- return /* @__PURE__ */ jsx(SlotContentRenderer, { content: childContent, onDismiss });
38293
- };
38294
- const targetKey = key === "renderItem" ? "children" : key;
38295
- rendered[targetKey] = fn;
38296
38232
  } else {
38297
38233
  rendered[key] = value;
38298
38234
  }
@@ -38336,7 +38272,10 @@ function SlotContentRenderer({
38336
38272
  const hasChildren = PATTERNS_WITH_CHILDREN.has(content.pattern) || Array.isArray(childrenConfig) && childrenConfig.length > 0;
38337
38273
  const myPath = patternPath ?? "root";
38338
38274
  const renderedChildren = hasChildren ? renderPatternChildren(childrenConfig, onDismiss, content.id, myPath, content.sourceTrait) : void 0;
38339
- const { children: _childrenConfig, ...restProps } = content.props;
38275
+ const incomingChildren = content.props.children;
38276
+ const childrenIsRenderFn = typeof incomingChildren === "function";
38277
+ const { children: _childrenConfig, ...restPropsNoChildren } = content.props;
38278
+ const restProps = childrenIsRenderFn ? { ...restPropsNoChildren, children: incomingChildren } : restPropsNoChildren;
38340
38279
  const renderedProps = renderPatternProps(restProps, onDismiss);
38341
38280
  const finalProps = renderedProps;
38342
38281
  const resolvedItems = Array.isArray(
@@ -0,0 +1,26 @@
1
+ /**
2
+ * fn-form lambda → React render-prop conversion at the render-ui
3
+ * dispatch site, before the pattern lands in `useUISlots`.
4
+ *
5
+ * `.lolo` authors per-row render functions for DataGrid/DataList/Carousel
6
+ * as `["fn", argName, body]`. By converting them to functions here,
7
+ * SlotContent's props match what consumer components expect (children =
8
+ * real function) without depending on a render-time conversion pass.
9
+ *
10
+ * @packageDocumentation
11
+ */
12
+ import type { EntityRow, RenderItemLambda } from "@almadar/core";
13
+ export declare function isFnFormLambda(value: unknown): value is RenderItemLambda;
14
+ /**
15
+ * Walk a pattern body replacing every `@<argName>.path` string with the
16
+ * value at `path` of `arg`. Mirrors the compiler's inline substitution
17
+ * for `renderItem` lambda bodies.
18
+ */
19
+ export declare function resolveLambdaBindings(body: unknown, argName: string, arg: EntityRow): unknown;
20
+ /**
21
+ * Walk a pattern's props (and recursively their nested children),
22
+ * converting every fn-form lambda value into a React render-prop
23
+ * function. Pure on inputs without lambdas: returns the props object
24
+ * unchanged by reference.
25
+ */
26
+ export declare function convertFnFormLambdasInProps(props: Record<string, unknown>): Record<string, unknown>;