@almadar/ui 4.22.0 → 4.22.2

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.
@@ -10268,6 +10268,25 @@ var init_renderer = __esm({
10268
10268
  init_init();
10269
10269
  }
10270
10270
  });
10271
+
10272
+ // runtime/wrapCallbackForEvent.ts
10273
+ function wrapCallbackForEvent(qualifiedEvent, callbackArgs, emit) {
10274
+ const argNames = (callbackArgs ?? []).map((a) => a.name);
10275
+ if (argNames.length === 0) {
10276
+ return () => emit(qualifiedEvent);
10277
+ }
10278
+ return (...args) => {
10279
+ const payload = {};
10280
+ for (let i = 0; i < argNames.length; i += 1) {
10281
+ payload[argNames[i]] = args[i];
10282
+ }
10283
+ emit(qualifiedEvent, payload);
10284
+ };
10285
+ }
10286
+ var init_wrapCallbackForEvent = __esm({
10287
+ "runtime/wrapCallbackForEvent.ts"() {
10288
+ }
10289
+ });
10271
10290
  var variantBorderClasses, variantIconColors, iconMap3, Alert;
10272
10291
  var init_Alert = __esm({
10273
10292
  "components/molecules/Alert.tsx"() {
@@ -21941,6 +21960,7 @@ function formatValue(value, format) {
21941
21960
  function DataGrid({
21942
21961
  entity,
21943
21962
  fields,
21963
+ columns,
21944
21964
  itemActions,
21945
21965
  cols,
21946
21966
  gap = "md",
@@ -21962,6 +21982,7 @@ function DataGrid({
21962
21982
  const { t } = useTranslate();
21963
21983
  const [selectedIds, setSelectedIds] = React127.useState(/* @__PURE__ */ new Set());
21964
21984
  const [visibleCount, setVisibleCount] = React127.useState(pageSize || Infinity);
21985
+ const fieldDefs = fields ?? columns ?? [];
21965
21986
  const allData = Array.isArray(entity) ? entity : entity ? [entity] : [];
21966
21987
  const data = pageSize > 0 ? allData.slice(0, visibleCount) : allData;
21967
21988
  const hasMoreLocal = pageSize > 0 && visibleCount < allData.length;
@@ -21989,9 +22010,9 @@ function DataGrid({
21989
22010
  return next;
21990
22011
  });
21991
22012
  }, [data, selectionEvent, eventBus]);
21992
- const titleField = fields.find((f3) => f3.variant === "h3" || f3.variant === "h4") ?? fields[0];
21993
- const badgeFields = fields.filter((f3) => f3.variant === "badge" && f3 !== titleField);
21994
- const bodyFields = fields.filter((f3) => f3 !== titleField && !badgeFields.includes(f3));
22013
+ const titleField = fieldDefs.find((f3) => f3.variant === "h3" || f3.variant === "h4") ?? fieldDefs[0];
22014
+ const badgeFields = fieldDefs.filter((f3) => f3.variant === "badge" && f3 !== titleField);
22015
+ const bodyFields = fieldDefs.filter((f3) => f3 !== titleField && !badgeFields.includes(f3));
21995
22016
  const primaryActions = itemActions?.filter((a) => a.variant !== "danger") ?? [];
21996
22017
  const dangerActions = itemActions?.filter((a) => a.variant === "danger") ?? [];
21997
22018
  const handleActionClick = (action, itemData) => (e) => {
@@ -22004,7 +22025,7 @@ function DataGrid({
22004
22025
  };
22005
22026
  const hasRenderProp = typeof children === "function";
22006
22027
  React127.useEffect(() => {
22007
- if (data.length > 0 && !hasRenderProp && (!fields || fields.length === 0)) {
22028
+ if (data.length > 0 && !hasRenderProp && fieldDefs.length === 0) {
22008
22029
  const renderItemRaw = schemaRenderItem;
22009
22030
  const isFnLambda = Array.isArray(renderItemRaw) && renderItemRaw.length >= 3 && (renderItemRaw[0] === "fn" || renderItemRaw[0] === "lambda");
22010
22031
  dataGridLog.warn("renderItem-unresolved", {
@@ -22012,7 +22033,7 @@ function DataGrid({
22012
22033
  renderItemIsFnLambda: isFnLambda
22013
22034
  });
22014
22035
  }
22015
- }, [data, hasRenderProp, schemaRenderItem, fields]);
22036
+ }, [data, hasRenderProp, schemaRenderItem, fieldDefs]);
22016
22037
  const gridTemplateColumns = cols ? void 0 : `repeat(auto-fit, minmax(min(${minCardWidth}px, 100%), 1fr))`;
22017
22038
  const colsClass = cols ? {
22018
22039
  1: "grid-cols-1",
@@ -22317,6 +22338,7 @@ function groupData(items, field) {
22317
22338
  function DataList({
22318
22339
  entity,
22319
22340
  fields,
22341
+ columns,
22320
22342
  itemActions,
22321
22343
  gap = "none",
22322
22344
  variant = "default",
@@ -22346,6 +22368,7 @@ function DataList({
22346
22368
  const eventBus = useEventBus();
22347
22369
  const { t } = useTranslate();
22348
22370
  const [visibleCount, setVisibleCount] = React127__namespace.default.useState(pageSize || Infinity);
22371
+ const fieldDefs = fields ?? columns ?? [];
22349
22372
  const allData = Array.isArray(entity) ? entity : entity ? [entity] : [];
22350
22373
  const data = pageSize > 0 ? allData.slice(0, visibleCount) : allData;
22351
22374
  const hasMoreLocal = pageSize > 0 && visibleCount < allData.length;
@@ -22360,7 +22383,7 @@ function DataList({
22360
22383
  const isFnLambda = Array.isArray(renderItemRaw) && renderItemRaw.length >= 3 && (renderItemRaw[0] === "fn" || renderItemRaw[0] === "lambda");
22361
22384
  dataListLog.warn("renderItem-unresolved", {
22362
22385
  rowCount: data.length,
22363
- fieldsCount: fields?.length ?? 0,
22386
+ fieldsCount: fieldDefs.length,
22364
22387
  renderItemTypeOf,
22365
22388
  renderItemIsArray: Array.isArray(renderItemRaw),
22366
22389
  renderItemIsFnLambda: isFnLambda,
@@ -22369,11 +22392,11 @@ function DataList({
22369
22392
  sampleRowKeys: sampleKeys
22370
22393
  });
22371
22394
  }
22372
- }, [data, hasRenderProp, schemaRenderItem, children, fields]);
22373
- const titleField = fields.find((f3) => f3.variant === "h3" || f3.variant === "h4") ?? fields[0];
22374
- const badgeFields = fields.filter((f3) => f3.variant === "badge" && f3 !== titleField);
22375
- const progressFields = fields.filter((f3) => f3.variant === "progress");
22376
- const bodyFields = fields.filter(
22395
+ }, [data, hasRenderProp, schemaRenderItem, children, fieldDefs]);
22396
+ const titleField = fieldDefs.find((f3) => f3.variant === "h3" || f3.variant === "h4") ?? fieldDefs[0];
22397
+ const badgeFields = fieldDefs.filter((f3) => f3.variant === "badge" && f3 !== titleField);
22398
+ const progressFields = fieldDefs.filter((f3) => f3.variant === "progress");
22399
+ const bodyFields = fieldDefs.filter(
22377
22400
  (f3) => f3 !== titleField && !badgeFields.includes(f3) && !progressFields.includes(f3)
22378
22401
  );
22379
22402
  const handleActionClick = (action, itemData) => (e) => {
@@ -22405,7 +22428,7 @@ function DataList({
22405
22428
  if (isMessage) {
22406
22429
  const items2 = data.map((item) => item);
22407
22430
  const groups2 = groupBy ? groupData(items2, groupBy) : [{ label: "", items: items2 }];
22408
- const contentField = titleField?.name ?? fields[0]?.name ?? "";
22431
+ const contentField = titleField?.name ?? fieldDefs[0]?.name ?? "";
22409
22432
  return /* @__PURE__ */ jsxRuntime.jsx(VStack, { gap: "sm", className: cn("py-2", className), children: groups2.map((group, gi) => /* @__PURE__ */ jsxRuntime.jsxs(React127__namespace.default.Fragment, { children: [
22410
22433
  group.label && /* @__PURE__ */ jsxRuntime.jsx(Divider, { label: group.label, className: "my-2" }),
22411
22434
  group.items.map((itemData, index) => {
@@ -22413,7 +22436,7 @@ function DataList({
22413
22436
  const sender = senderField ? String(getNestedValue(itemData, senderField) ?? "") : "";
22414
22437
  const isSent = Boolean(currentUser && sender === currentUser);
22415
22438
  const content = getNestedValue(itemData, contentField);
22416
- const timestampField = fields.find((f3) => f3.format === "date");
22439
+ const timestampField = fieldDefs.find((f3) => f3.format === "date");
22417
22440
  const timestamp = timestampField ? getNestedValue(itemData, timestampField.name) : null;
22418
22441
  return /* @__PURE__ */ jsxRuntime.jsx(
22419
22442
  Box,
@@ -47066,6 +47089,7 @@ function SlotContentRenderer({
47066
47089
  );
47067
47090
  }
47068
47091
  }
47092
+ const eventBus = useEventBus();
47069
47093
  const schemaCtx = useEntitySchemaOptional();
47070
47094
  let entityDef;
47071
47095
  if (typeof entityProp === "string" && entityProp.length > 0 && schemaCtx) {
@@ -47087,6 +47111,20 @@ function SlotContentRenderer({
47087
47111
  const { children: _childrenConfig, ...restPropsNoChildren } = content.props;
47088
47112
  const restProps = childrenIsRenderFn ? { ...restPropsNoChildren, children: incomingChildren } : restPropsNoChildren;
47089
47113
  const renderedProps = renderPatternProps(restProps, onDismiss);
47114
+ const patternDef = patterns.getPatternDefinition(content.pattern);
47115
+ const propsSchema = patternDef?.propsSchema;
47116
+ if (propsSchema) {
47117
+ for (const [propKey, propValue] of Object.entries(renderedProps)) {
47118
+ if (typeof propValue !== "string") continue;
47119
+ const propDef = propsSchema[propKey];
47120
+ if (!propDef || propDef.kind !== "callback") continue;
47121
+ renderedProps[propKey] = wrapCallbackForEvent(
47122
+ `UI:${propValue}`,
47123
+ propDef.callbackArgs,
47124
+ (eventKey, payload) => eventBus.emit(eventKey, payload)
47125
+ );
47126
+ }
47127
+ }
47090
47128
  const finalProps = renderedProps;
47091
47129
  const resolvedItems = Array.isArray(
47092
47130
  finalProps.entity
@@ -47213,6 +47251,7 @@ var init_UISlotRenderer = __esm({
47213
47251
  init_logger();
47214
47252
  init_Skeleton();
47215
47253
  init_renderer();
47254
+ init_wrapCallbackForEvent();
47216
47255
  init_TraitFrame();
47217
47256
  init_component_registry_generated();
47218
47257
  scopeWrapLog = createLogger("almadar:ui:scope-wrap");
package/dist/avl/index.js CHANGED
@@ -5,7 +5,7 @@ import React127__default, { createContext, useContext, useRef, useState, useCall
5
5
  import * as LucideIcons from 'lucide-react';
6
6
  import { Loader2, ChevronDown, X, Check, Copy, AlertTriangle, Info, AlertCircle, CheckCircle, List, Printer, ChevronRight, ChevronLeft, Code, FileText, WrapText, Trash2, Settings, Menu as Menu$1, Search, Bell, LogOut, ZoomOut, ZoomIn, Download, FileQuestion, Inbox, XCircle, Filter, Plus, Pause, Play, RotateCcw, Package, Calendar, Pencil, Eye, MoreHorizontal, Image as Image$1, Upload, Minus, ArrowLeft, HelpCircle, ChevronUp, Eraser, Star, TrendingUp, TrendingDown, ArrowUp, ArrowDown, MoreVertical, Sun, Moon, Circle, Clock, CheckCircle2, ArrowRight, FileWarning, SkipForward, Bug, Send, Wrench, User, Tag, DollarSign, Zap, Sword, Move, Heart, Shield } from 'lucide-react';
7
7
  import { evaluate, createMinimalContext } from '@almadar/evaluator';
8
- import { getComponentForPattern as getComponentForPattern$1, getPatternDefinition, isEntityAwarePattern } from '@almadar/patterns';
8
+ import { getPatternDefinition, getComponentForPattern as getComponentForPattern$1, isEntityAwarePattern } from '@almadar/patterns';
9
9
  import { createPortal } from 'react-dom';
10
10
  import { Link, Outlet, useLocation } from 'react-router-dom';
11
11
  import ReactMarkdown from 'react-markdown';
@@ -10222,6 +10222,25 @@ var init_renderer = __esm({
10222
10222
  init_init();
10223
10223
  }
10224
10224
  });
10225
+
10226
+ // runtime/wrapCallbackForEvent.ts
10227
+ function wrapCallbackForEvent(qualifiedEvent, callbackArgs, emit) {
10228
+ const argNames = (callbackArgs ?? []).map((a) => a.name);
10229
+ if (argNames.length === 0) {
10230
+ return () => emit(qualifiedEvent);
10231
+ }
10232
+ return (...args) => {
10233
+ const payload = {};
10234
+ for (let i = 0; i < argNames.length; i += 1) {
10235
+ payload[argNames[i]] = args[i];
10236
+ }
10237
+ emit(qualifiedEvent, payload);
10238
+ };
10239
+ }
10240
+ var init_wrapCallbackForEvent = __esm({
10241
+ "runtime/wrapCallbackForEvent.ts"() {
10242
+ }
10243
+ });
10225
10244
  var variantBorderClasses, variantIconColors, iconMap3, Alert;
10226
10245
  var init_Alert = __esm({
10227
10246
  "components/molecules/Alert.tsx"() {
@@ -21895,6 +21914,7 @@ function formatValue(value, format) {
21895
21914
  function DataGrid({
21896
21915
  entity,
21897
21916
  fields,
21917
+ columns,
21898
21918
  itemActions,
21899
21919
  cols,
21900
21920
  gap = "md",
@@ -21916,6 +21936,7 @@ function DataGrid({
21916
21936
  const { t } = useTranslate();
21917
21937
  const [selectedIds, setSelectedIds] = useState(/* @__PURE__ */ new Set());
21918
21938
  const [visibleCount, setVisibleCount] = useState(pageSize || Infinity);
21939
+ const fieldDefs = fields ?? columns ?? [];
21919
21940
  const allData = Array.isArray(entity) ? entity : entity ? [entity] : [];
21920
21941
  const data = pageSize > 0 ? allData.slice(0, visibleCount) : allData;
21921
21942
  const hasMoreLocal = pageSize > 0 && visibleCount < allData.length;
@@ -21943,9 +21964,9 @@ function DataGrid({
21943
21964
  return next;
21944
21965
  });
21945
21966
  }, [data, selectionEvent, eventBus]);
21946
- const titleField = fields.find((f3) => f3.variant === "h3" || f3.variant === "h4") ?? fields[0];
21947
- const badgeFields = fields.filter((f3) => f3.variant === "badge" && f3 !== titleField);
21948
- const bodyFields = fields.filter((f3) => f3 !== titleField && !badgeFields.includes(f3));
21967
+ const titleField = fieldDefs.find((f3) => f3.variant === "h3" || f3.variant === "h4") ?? fieldDefs[0];
21968
+ const badgeFields = fieldDefs.filter((f3) => f3.variant === "badge" && f3 !== titleField);
21969
+ const bodyFields = fieldDefs.filter((f3) => f3 !== titleField && !badgeFields.includes(f3));
21949
21970
  const primaryActions = itemActions?.filter((a) => a.variant !== "danger") ?? [];
21950
21971
  const dangerActions = itemActions?.filter((a) => a.variant === "danger") ?? [];
21951
21972
  const handleActionClick = (action, itemData) => (e) => {
@@ -21958,7 +21979,7 @@ function DataGrid({
21958
21979
  };
21959
21980
  const hasRenderProp = typeof children === "function";
21960
21981
  useEffect(() => {
21961
- if (data.length > 0 && !hasRenderProp && (!fields || fields.length === 0)) {
21982
+ if (data.length > 0 && !hasRenderProp && fieldDefs.length === 0) {
21962
21983
  const renderItemRaw = schemaRenderItem;
21963
21984
  const isFnLambda = Array.isArray(renderItemRaw) && renderItemRaw.length >= 3 && (renderItemRaw[0] === "fn" || renderItemRaw[0] === "lambda");
21964
21985
  dataGridLog.warn("renderItem-unresolved", {
@@ -21966,7 +21987,7 @@ function DataGrid({
21966
21987
  renderItemIsFnLambda: isFnLambda
21967
21988
  });
21968
21989
  }
21969
- }, [data, hasRenderProp, schemaRenderItem, fields]);
21990
+ }, [data, hasRenderProp, schemaRenderItem, fieldDefs]);
21970
21991
  const gridTemplateColumns = cols ? void 0 : `repeat(auto-fit, minmax(min(${minCardWidth}px, 100%), 1fr))`;
21971
21992
  const colsClass = cols ? {
21972
21993
  1: "grid-cols-1",
@@ -22271,6 +22292,7 @@ function groupData(items, field) {
22271
22292
  function DataList({
22272
22293
  entity,
22273
22294
  fields,
22295
+ columns,
22274
22296
  itemActions,
22275
22297
  gap = "none",
22276
22298
  variant = "default",
@@ -22300,6 +22322,7 @@ function DataList({
22300
22322
  const eventBus = useEventBus();
22301
22323
  const { t } = useTranslate();
22302
22324
  const [visibleCount, setVisibleCount] = React127__default.useState(pageSize || Infinity);
22325
+ const fieldDefs = fields ?? columns ?? [];
22303
22326
  const allData = Array.isArray(entity) ? entity : entity ? [entity] : [];
22304
22327
  const data = pageSize > 0 ? allData.slice(0, visibleCount) : allData;
22305
22328
  const hasMoreLocal = pageSize > 0 && visibleCount < allData.length;
@@ -22314,7 +22337,7 @@ function DataList({
22314
22337
  const isFnLambda = Array.isArray(renderItemRaw) && renderItemRaw.length >= 3 && (renderItemRaw[0] === "fn" || renderItemRaw[0] === "lambda");
22315
22338
  dataListLog.warn("renderItem-unresolved", {
22316
22339
  rowCount: data.length,
22317
- fieldsCount: fields?.length ?? 0,
22340
+ fieldsCount: fieldDefs.length,
22318
22341
  renderItemTypeOf,
22319
22342
  renderItemIsArray: Array.isArray(renderItemRaw),
22320
22343
  renderItemIsFnLambda: isFnLambda,
@@ -22323,11 +22346,11 @@ function DataList({
22323
22346
  sampleRowKeys: sampleKeys
22324
22347
  });
22325
22348
  }
22326
- }, [data, hasRenderProp, schemaRenderItem, children, fields]);
22327
- const titleField = fields.find((f3) => f3.variant === "h3" || f3.variant === "h4") ?? fields[0];
22328
- const badgeFields = fields.filter((f3) => f3.variant === "badge" && f3 !== titleField);
22329
- const progressFields = fields.filter((f3) => f3.variant === "progress");
22330
- const bodyFields = fields.filter(
22349
+ }, [data, hasRenderProp, schemaRenderItem, children, fieldDefs]);
22350
+ const titleField = fieldDefs.find((f3) => f3.variant === "h3" || f3.variant === "h4") ?? fieldDefs[0];
22351
+ const badgeFields = fieldDefs.filter((f3) => f3.variant === "badge" && f3 !== titleField);
22352
+ const progressFields = fieldDefs.filter((f3) => f3.variant === "progress");
22353
+ const bodyFields = fieldDefs.filter(
22331
22354
  (f3) => f3 !== titleField && !badgeFields.includes(f3) && !progressFields.includes(f3)
22332
22355
  );
22333
22356
  const handleActionClick = (action, itemData) => (e) => {
@@ -22359,7 +22382,7 @@ function DataList({
22359
22382
  if (isMessage) {
22360
22383
  const items2 = data.map((item) => item);
22361
22384
  const groups2 = groupBy ? groupData(items2, groupBy) : [{ label: "", items: items2 }];
22362
- const contentField = titleField?.name ?? fields[0]?.name ?? "";
22385
+ const contentField = titleField?.name ?? fieldDefs[0]?.name ?? "";
22363
22386
  return /* @__PURE__ */ jsx(VStack, { gap: "sm", className: cn("py-2", className), children: groups2.map((group, gi) => /* @__PURE__ */ jsxs(React127__default.Fragment, { children: [
22364
22387
  group.label && /* @__PURE__ */ jsx(Divider, { label: group.label, className: "my-2" }),
22365
22388
  group.items.map((itemData, index) => {
@@ -22367,7 +22390,7 @@ function DataList({
22367
22390
  const sender = senderField ? String(getNestedValue(itemData, senderField) ?? "") : "";
22368
22391
  const isSent = Boolean(currentUser && sender === currentUser);
22369
22392
  const content = getNestedValue(itemData, contentField);
22370
- const timestampField = fields.find((f3) => f3.format === "date");
22393
+ const timestampField = fieldDefs.find((f3) => f3.format === "date");
22371
22394
  const timestamp = timestampField ? getNestedValue(itemData, timestampField.name) : null;
22372
22395
  return /* @__PURE__ */ jsx(
22373
22396
  Box,
@@ -47020,6 +47043,7 @@ function SlotContentRenderer({
47020
47043
  );
47021
47044
  }
47022
47045
  }
47046
+ const eventBus = useEventBus();
47023
47047
  const schemaCtx = useEntitySchemaOptional();
47024
47048
  let entityDef;
47025
47049
  if (typeof entityProp === "string" && entityProp.length > 0 && schemaCtx) {
@@ -47041,6 +47065,20 @@ function SlotContentRenderer({
47041
47065
  const { children: _childrenConfig, ...restPropsNoChildren } = content.props;
47042
47066
  const restProps = childrenIsRenderFn ? { ...restPropsNoChildren, children: incomingChildren } : restPropsNoChildren;
47043
47067
  const renderedProps = renderPatternProps(restProps, onDismiss);
47068
+ const patternDef = getPatternDefinition(content.pattern);
47069
+ const propsSchema = patternDef?.propsSchema;
47070
+ if (propsSchema) {
47071
+ for (const [propKey, propValue] of Object.entries(renderedProps)) {
47072
+ if (typeof propValue !== "string") continue;
47073
+ const propDef = propsSchema[propKey];
47074
+ if (!propDef || propDef.kind !== "callback") continue;
47075
+ renderedProps[propKey] = wrapCallbackForEvent(
47076
+ `UI:${propValue}`,
47077
+ propDef.callbackArgs,
47078
+ (eventKey, payload) => eventBus.emit(eventKey, payload)
47079
+ );
47080
+ }
47081
+ }
47044
47082
  const finalProps = renderedProps;
47045
47083
  const resolvedItems = Array.isArray(
47046
47084
  finalProps.entity
@@ -47167,6 +47205,7 @@ var init_UISlotRenderer = __esm({
47167
47205
  init_logger();
47168
47206
  init_Skeleton();
47169
47207
  init_renderer();
47208
+ init_wrapCallbackForEvent();
47170
47209
  init_TraitFrame();
47171
47210
  init_component_registry_generated();
47172
47211
  scopeWrapLog = createLogger("almadar:ui:scope-wrap");
@@ -5425,6 +5425,25 @@ var init_renderer = __esm({
5425
5425
  init_init();
5426
5426
  }
5427
5427
  });
5428
+
5429
+ // runtime/wrapCallbackForEvent.ts
5430
+ function wrapCallbackForEvent(qualifiedEvent, callbackArgs, emit) {
5431
+ const argNames = (callbackArgs ?? []).map((a) => a.name);
5432
+ if (argNames.length === 0) {
5433
+ return () => emit(qualifiedEvent);
5434
+ }
5435
+ return (...args) => {
5436
+ const payload = {};
5437
+ for (let i = 0; i < argNames.length; i += 1) {
5438
+ payload[argNames[i]] = args[i];
5439
+ }
5440
+ emit(qualifiedEvent, payload);
5441
+ };
5442
+ }
5443
+ var init_wrapCallbackForEvent = __esm({
5444
+ "runtime/wrapCallbackForEvent.ts"() {
5445
+ }
5446
+ });
5428
5447
  var variantBorderClasses, variantIconColors, iconMap3; exports.Alert = void 0;
5429
5448
  var init_Alert = __esm({
5430
5449
  "components/molecules/Alert.tsx"() {
@@ -17369,6 +17388,7 @@ function formatValue(value, format) {
17369
17388
  function DataGrid({
17370
17389
  entity,
17371
17390
  fields,
17391
+ columns,
17372
17392
  itemActions,
17373
17393
  cols,
17374
17394
  gap = "md",
@@ -17390,6 +17410,7 @@ function DataGrid({
17390
17410
  const { t } = useTranslate();
17391
17411
  const [selectedIds, setSelectedIds] = React110.useState(/* @__PURE__ */ new Set());
17392
17412
  const [visibleCount, setVisibleCount] = React110.useState(pageSize || Infinity);
17413
+ const fieldDefs = fields ?? columns ?? [];
17393
17414
  const allData = Array.isArray(entity) ? entity : entity ? [entity] : [];
17394
17415
  const data = pageSize > 0 ? allData.slice(0, visibleCount) : allData;
17395
17416
  const hasMoreLocal = pageSize > 0 && visibleCount < allData.length;
@@ -17417,9 +17438,9 @@ function DataGrid({
17417
17438
  return next;
17418
17439
  });
17419
17440
  }, [data, selectionEvent, eventBus]);
17420
- const titleField = fields.find((f3) => f3.variant === "h3" || f3.variant === "h4") ?? fields[0];
17421
- const badgeFields = fields.filter((f3) => f3.variant === "badge" && f3 !== titleField);
17422
- const bodyFields = fields.filter((f3) => f3 !== titleField && !badgeFields.includes(f3));
17441
+ const titleField = fieldDefs.find((f3) => f3.variant === "h3" || f3.variant === "h4") ?? fieldDefs[0];
17442
+ const badgeFields = fieldDefs.filter((f3) => f3.variant === "badge" && f3 !== titleField);
17443
+ const bodyFields = fieldDefs.filter((f3) => f3 !== titleField && !badgeFields.includes(f3));
17423
17444
  const primaryActions = itemActions?.filter((a) => a.variant !== "danger") ?? [];
17424
17445
  const dangerActions = itemActions?.filter((a) => a.variant === "danger") ?? [];
17425
17446
  const handleActionClick = (action, itemData) => (e) => {
@@ -17432,7 +17453,7 @@ function DataGrid({
17432
17453
  };
17433
17454
  const hasRenderProp = typeof children === "function";
17434
17455
  React110.useEffect(() => {
17435
- if (data.length > 0 && !hasRenderProp && (!fields || fields.length === 0)) {
17456
+ if (data.length > 0 && !hasRenderProp && fieldDefs.length === 0) {
17436
17457
  const renderItemRaw = schemaRenderItem;
17437
17458
  const isFnLambda = Array.isArray(renderItemRaw) && renderItemRaw.length >= 3 && (renderItemRaw[0] === "fn" || renderItemRaw[0] === "lambda");
17438
17459
  dataGridLog.warn("renderItem-unresolved", {
@@ -17440,7 +17461,7 @@ function DataGrid({
17440
17461
  renderItemIsFnLambda: isFnLambda
17441
17462
  });
17442
17463
  }
17443
- }, [data, hasRenderProp, schemaRenderItem, fields]);
17464
+ }, [data, hasRenderProp, schemaRenderItem, fieldDefs]);
17444
17465
  const gridTemplateColumns = cols ? void 0 : `repeat(auto-fit, minmax(min(${minCardWidth}px, 100%), 1fr))`;
17445
17466
  const colsClass = cols ? {
17446
17467
  1: "grid-cols-1",
@@ -17745,6 +17766,7 @@ function groupData(items, field) {
17745
17766
  function DataList({
17746
17767
  entity,
17747
17768
  fields,
17769
+ columns,
17748
17770
  itemActions,
17749
17771
  gap = "none",
17750
17772
  variant = "default",
@@ -17774,6 +17796,7 @@ function DataList({
17774
17796
  const eventBus = useEventBus();
17775
17797
  const { t } = useTranslate();
17776
17798
  const [visibleCount, setVisibleCount] = React110__namespace.default.useState(pageSize || Infinity);
17799
+ const fieldDefs = fields ?? columns ?? [];
17777
17800
  const allData = Array.isArray(entity) ? entity : entity ? [entity] : [];
17778
17801
  const data = pageSize > 0 ? allData.slice(0, visibleCount) : allData;
17779
17802
  const hasMoreLocal = pageSize > 0 && visibleCount < allData.length;
@@ -17788,7 +17811,7 @@ function DataList({
17788
17811
  const isFnLambda = Array.isArray(renderItemRaw) && renderItemRaw.length >= 3 && (renderItemRaw[0] === "fn" || renderItemRaw[0] === "lambda");
17789
17812
  dataListLog.warn("renderItem-unresolved", {
17790
17813
  rowCount: data.length,
17791
- fieldsCount: fields?.length ?? 0,
17814
+ fieldsCount: fieldDefs.length,
17792
17815
  renderItemTypeOf,
17793
17816
  renderItemIsArray: Array.isArray(renderItemRaw),
17794
17817
  renderItemIsFnLambda: isFnLambda,
@@ -17797,11 +17820,11 @@ function DataList({
17797
17820
  sampleRowKeys: sampleKeys
17798
17821
  });
17799
17822
  }
17800
- }, [data, hasRenderProp, schemaRenderItem, children, fields]);
17801
- const titleField = fields.find((f3) => f3.variant === "h3" || f3.variant === "h4") ?? fields[0];
17802
- const badgeFields = fields.filter((f3) => f3.variant === "badge" && f3 !== titleField);
17803
- const progressFields = fields.filter((f3) => f3.variant === "progress");
17804
- const bodyFields = fields.filter(
17823
+ }, [data, hasRenderProp, schemaRenderItem, children, fieldDefs]);
17824
+ const titleField = fieldDefs.find((f3) => f3.variant === "h3" || f3.variant === "h4") ?? fieldDefs[0];
17825
+ const badgeFields = fieldDefs.filter((f3) => f3.variant === "badge" && f3 !== titleField);
17826
+ const progressFields = fieldDefs.filter((f3) => f3.variant === "progress");
17827
+ const bodyFields = fieldDefs.filter(
17805
17828
  (f3) => f3 !== titleField && !badgeFields.includes(f3) && !progressFields.includes(f3)
17806
17829
  );
17807
17830
  const handleActionClick = (action, itemData) => (e) => {
@@ -17833,7 +17856,7 @@ function DataList({
17833
17856
  if (isMessage) {
17834
17857
  const items2 = data.map((item) => item);
17835
17858
  const groups2 = groupBy ? groupData(items2, groupBy) : [{ label: "", items: items2 }];
17836
- const contentField = titleField?.name ?? fields[0]?.name ?? "";
17859
+ const contentField = titleField?.name ?? fieldDefs[0]?.name ?? "";
17837
17860
  return /* @__PURE__ */ jsxRuntime.jsx(exports.VStack, { gap: "sm", className: cn("py-2", className), children: groups2.map((group, gi) => /* @__PURE__ */ jsxRuntime.jsxs(React110__namespace.default.Fragment, { children: [
17838
17861
  group.label && /* @__PURE__ */ jsxRuntime.jsx(exports.Divider, { label: group.label, className: "my-2" }),
17839
17862
  group.items.map((itemData, index) => {
@@ -17841,7 +17864,7 @@ function DataList({
17841
17864
  const sender = senderField ? String(getNestedValue(itemData, senderField) ?? "") : "";
17842
17865
  const isSent = Boolean(currentUser && sender === currentUser);
17843
17866
  const content = getNestedValue(itemData, contentField);
17844
- const timestampField = fields.find((f3) => f3.format === "date");
17867
+ const timestampField = fieldDefs.find((f3) => f3.format === "date");
17845
17868
  const timestamp = timestampField ? getNestedValue(itemData, timestampField.name) : null;
17846
17869
  return /* @__PURE__ */ jsxRuntime.jsx(
17847
17870
  exports.Box,
@@ -37812,6 +37835,7 @@ function SlotContentRenderer({
37812
37835
  );
37813
37836
  }
37814
37837
  }
37838
+ const eventBus = useEventBus();
37815
37839
  const schemaCtx = useEntitySchemaOptional();
37816
37840
  let entityDef;
37817
37841
  if (typeof entityProp === "string" && entityProp.length > 0 && schemaCtx) {
@@ -37833,6 +37857,20 @@ function SlotContentRenderer({
37833
37857
  const { children: _childrenConfig, ...restPropsNoChildren } = content.props;
37834
37858
  const restProps = childrenIsRenderFn ? { ...restPropsNoChildren, children: incomingChildren } : restPropsNoChildren;
37835
37859
  const renderedProps = renderPatternProps(restProps, onDismiss);
37860
+ const patternDef = patterns.getPatternDefinition(content.pattern);
37861
+ const propsSchema = patternDef?.propsSchema;
37862
+ if (propsSchema) {
37863
+ for (const [propKey, propValue] of Object.entries(renderedProps)) {
37864
+ if (typeof propValue !== "string") continue;
37865
+ const propDef = propsSchema[propKey];
37866
+ if (!propDef || propDef.kind !== "callback") continue;
37867
+ renderedProps[propKey] = wrapCallbackForEvent(
37868
+ `UI:${propValue}`,
37869
+ propDef.callbackArgs,
37870
+ (eventKey, payload) => eventBus.emit(eventKey, payload)
37871
+ );
37872
+ }
37873
+ }
37836
37874
  const finalProps = renderedProps;
37837
37875
  const resolvedItems = Array.isArray(
37838
37876
  finalProps.entity
@@ -37957,6 +37995,7 @@ var init_UISlotRenderer = __esm({
37957
37995
  init_logger();
37958
37996
  init_Skeleton();
37959
37997
  init_renderer();
37998
+ init_wrapCallbackForEvent();
37960
37999
  init_TraitFrame();
37961
38000
  init_component_registry_generated();
37962
38001
  scopeWrapLog = createLogger("almadar:ui:scope-wrap");