@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.
@@ -7,7 +7,7 @@ import * as LucideIcons from 'lucide-react';
7
7
  import { Loader2, X, AlertTriangle, Info, AlertCircle, CheckCircle, ChevronDown, List, Printer, ChevronRight, ChevronLeft, XCircle, Wrench, RotateCcw, Send, Code, FileText, WrapText, Check, Copy, Zap, Sword, Move, Heart, Shield, Trash2, Settings, Menu as Menu$1, Search, Bell, LogOut, ChevronUp, MoreHorizontal, Bug, ZoomOut, ZoomIn, Download, Pause, Play, Package, Calendar, Pencil, Eye, Image as Image$1, Upload, ArrowRight, ArrowLeft, Eraser, SkipForward, TrendingUp, TrendingDown, Minus, ArrowUp, ArrowDown, MoreVertical, Circle, Clock, CheckCircle2, HelpCircle, FileQuestion, Inbox, Plus, User, Filter, Star, FileWarning, Tag, DollarSign, Sun, Moon } from 'lucide-react';
8
8
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
9
9
  import { evaluate, createMinimalContext } from '@almadar/evaluator';
10
- import { getComponentForPattern as getComponentForPattern$1 } from '@almadar/patterns';
10
+ import { getPatternDefinition, getComponentForPattern as getComponentForPattern$1 } from '@almadar/patterns';
11
11
  import { createPortal } from 'react-dom';
12
12
  import { Link, Outlet, useLocation } from 'react-router-dom';
13
13
  import ReactMarkdown from 'react-markdown';
@@ -5380,6 +5380,25 @@ var init_renderer = __esm({
5380
5380
  init_init();
5381
5381
  }
5382
5382
  });
5383
+
5384
+ // runtime/wrapCallbackForEvent.ts
5385
+ function wrapCallbackForEvent(qualifiedEvent, callbackArgs, emit) {
5386
+ const argNames = (callbackArgs ?? []).map((a) => a.name);
5387
+ if (argNames.length === 0) {
5388
+ return () => emit(qualifiedEvent);
5389
+ }
5390
+ return (...args) => {
5391
+ const payload = {};
5392
+ for (let i = 0; i < argNames.length; i += 1) {
5393
+ payload[argNames[i]] = args[i];
5394
+ }
5395
+ emit(qualifiedEvent, payload);
5396
+ };
5397
+ }
5398
+ var init_wrapCallbackForEvent = __esm({
5399
+ "runtime/wrapCallbackForEvent.ts"() {
5400
+ }
5401
+ });
5383
5402
  var variantBorderClasses, variantIconColors, iconMap3, Alert;
5384
5403
  var init_Alert = __esm({
5385
5404
  "components/molecules/Alert.tsx"() {
@@ -17324,6 +17343,7 @@ function formatValue(value, format) {
17324
17343
  function DataGrid({
17325
17344
  entity,
17326
17345
  fields,
17346
+ columns,
17327
17347
  itemActions,
17328
17348
  cols,
17329
17349
  gap = "md",
@@ -17345,6 +17365,7 @@ function DataGrid({
17345
17365
  const { t } = useTranslate();
17346
17366
  const [selectedIds, setSelectedIds] = useState(/* @__PURE__ */ new Set());
17347
17367
  const [visibleCount, setVisibleCount] = useState(pageSize || Infinity);
17368
+ const fieldDefs = fields ?? columns ?? [];
17348
17369
  const allData = Array.isArray(entity) ? entity : entity ? [entity] : [];
17349
17370
  const data = pageSize > 0 ? allData.slice(0, visibleCount) : allData;
17350
17371
  const hasMoreLocal = pageSize > 0 && visibleCount < allData.length;
@@ -17372,9 +17393,9 @@ function DataGrid({
17372
17393
  return next;
17373
17394
  });
17374
17395
  }, [data, selectionEvent, eventBus]);
17375
- const titleField = fields.find((f3) => f3.variant === "h3" || f3.variant === "h4") ?? fields[0];
17376
- const badgeFields = fields.filter((f3) => f3.variant === "badge" && f3 !== titleField);
17377
- const bodyFields = fields.filter((f3) => f3 !== titleField && !badgeFields.includes(f3));
17396
+ const titleField = fieldDefs.find((f3) => f3.variant === "h3" || f3.variant === "h4") ?? fieldDefs[0];
17397
+ const badgeFields = fieldDefs.filter((f3) => f3.variant === "badge" && f3 !== titleField);
17398
+ const bodyFields = fieldDefs.filter((f3) => f3 !== titleField && !badgeFields.includes(f3));
17378
17399
  const primaryActions = itemActions?.filter((a) => a.variant !== "danger") ?? [];
17379
17400
  const dangerActions = itemActions?.filter((a) => a.variant === "danger") ?? [];
17380
17401
  const handleActionClick = (action, itemData) => (e) => {
@@ -17387,7 +17408,7 @@ function DataGrid({
17387
17408
  };
17388
17409
  const hasRenderProp = typeof children === "function";
17389
17410
  useEffect(() => {
17390
- if (data.length > 0 && !hasRenderProp && (!fields || fields.length === 0)) {
17411
+ if (data.length > 0 && !hasRenderProp && fieldDefs.length === 0) {
17391
17412
  const renderItemRaw = schemaRenderItem;
17392
17413
  const isFnLambda = Array.isArray(renderItemRaw) && renderItemRaw.length >= 3 && (renderItemRaw[0] === "fn" || renderItemRaw[0] === "lambda");
17393
17414
  dataGridLog.warn("renderItem-unresolved", {
@@ -17395,7 +17416,7 @@ function DataGrid({
17395
17416
  renderItemIsFnLambda: isFnLambda
17396
17417
  });
17397
17418
  }
17398
- }, [data, hasRenderProp, schemaRenderItem, fields]);
17419
+ }, [data, hasRenderProp, schemaRenderItem, fieldDefs]);
17399
17420
  const gridTemplateColumns = cols ? void 0 : `repeat(auto-fit, minmax(min(${minCardWidth}px, 100%), 1fr))`;
17400
17421
  const colsClass = cols ? {
17401
17422
  1: "grid-cols-1",
@@ -17700,6 +17721,7 @@ function groupData(items, field) {
17700
17721
  function DataList({
17701
17722
  entity,
17702
17723
  fields,
17724
+ columns,
17703
17725
  itemActions,
17704
17726
  gap = "none",
17705
17727
  variant = "default",
@@ -17729,6 +17751,7 @@ function DataList({
17729
17751
  const eventBus = useEventBus();
17730
17752
  const { t } = useTranslate();
17731
17753
  const [visibleCount, setVisibleCount] = React110__default.useState(pageSize || Infinity);
17754
+ const fieldDefs = fields ?? columns ?? [];
17732
17755
  const allData = Array.isArray(entity) ? entity : entity ? [entity] : [];
17733
17756
  const data = pageSize > 0 ? allData.slice(0, visibleCount) : allData;
17734
17757
  const hasMoreLocal = pageSize > 0 && visibleCount < allData.length;
@@ -17743,7 +17766,7 @@ function DataList({
17743
17766
  const isFnLambda = Array.isArray(renderItemRaw) && renderItemRaw.length >= 3 && (renderItemRaw[0] === "fn" || renderItemRaw[0] === "lambda");
17744
17767
  dataListLog.warn("renderItem-unresolved", {
17745
17768
  rowCount: data.length,
17746
- fieldsCount: fields?.length ?? 0,
17769
+ fieldsCount: fieldDefs.length,
17747
17770
  renderItemTypeOf,
17748
17771
  renderItemIsArray: Array.isArray(renderItemRaw),
17749
17772
  renderItemIsFnLambda: isFnLambda,
@@ -17752,11 +17775,11 @@ function DataList({
17752
17775
  sampleRowKeys: sampleKeys
17753
17776
  });
17754
17777
  }
17755
- }, [data, hasRenderProp, schemaRenderItem, children, fields]);
17756
- const titleField = fields.find((f3) => f3.variant === "h3" || f3.variant === "h4") ?? fields[0];
17757
- const badgeFields = fields.filter((f3) => f3.variant === "badge" && f3 !== titleField);
17758
- const progressFields = fields.filter((f3) => f3.variant === "progress");
17759
- const bodyFields = fields.filter(
17778
+ }, [data, hasRenderProp, schemaRenderItem, children, fieldDefs]);
17779
+ const titleField = fieldDefs.find((f3) => f3.variant === "h3" || f3.variant === "h4") ?? fieldDefs[0];
17780
+ const badgeFields = fieldDefs.filter((f3) => f3.variant === "badge" && f3 !== titleField);
17781
+ const progressFields = fieldDefs.filter((f3) => f3.variant === "progress");
17782
+ const bodyFields = fieldDefs.filter(
17760
17783
  (f3) => f3 !== titleField && !badgeFields.includes(f3) && !progressFields.includes(f3)
17761
17784
  );
17762
17785
  const handleActionClick = (action, itemData) => (e) => {
@@ -17788,7 +17811,7 @@ function DataList({
17788
17811
  if (isMessage) {
17789
17812
  const items2 = data.map((item) => item);
17790
17813
  const groups2 = groupBy ? groupData(items2, groupBy) : [{ label: "", items: items2 }];
17791
- const contentField = titleField?.name ?? fields[0]?.name ?? "";
17814
+ const contentField = titleField?.name ?? fieldDefs[0]?.name ?? "";
17792
17815
  return /* @__PURE__ */ jsx(VStack, { gap: "sm", className: cn("py-2", className), children: groups2.map((group, gi) => /* @__PURE__ */ jsxs(React110__default.Fragment, { children: [
17793
17816
  group.label && /* @__PURE__ */ jsx(Divider, { label: group.label, className: "my-2" }),
17794
17817
  group.items.map((itemData, index) => {
@@ -17796,7 +17819,7 @@ function DataList({
17796
17819
  const sender = senderField ? String(getNestedValue(itemData, senderField) ?? "") : "";
17797
17820
  const isSent = Boolean(currentUser && sender === currentUser);
17798
17821
  const content = getNestedValue(itemData, contentField);
17799
- const timestampField = fields.find((f3) => f3.format === "date");
17822
+ const timestampField = fieldDefs.find((f3) => f3.format === "date");
17800
17823
  const timestamp = timestampField ? getNestedValue(itemData, timestampField.name) : null;
17801
17824
  return /* @__PURE__ */ jsx(
17802
17825
  Box,
@@ -37767,6 +37790,7 @@ function SlotContentRenderer({
37767
37790
  );
37768
37791
  }
37769
37792
  }
37793
+ const eventBus = useEventBus();
37770
37794
  const schemaCtx = useEntitySchemaOptional();
37771
37795
  let entityDef;
37772
37796
  if (typeof entityProp === "string" && entityProp.length > 0 && schemaCtx) {
@@ -37788,6 +37812,20 @@ function SlotContentRenderer({
37788
37812
  const { children: _childrenConfig, ...restPropsNoChildren } = content.props;
37789
37813
  const restProps = childrenIsRenderFn ? { ...restPropsNoChildren, children: incomingChildren } : restPropsNoChildren;
37790
37814
  const renderedProps = renderPatternProps(restProps, onDismiss);
37815
+ const patternDef = getPatternDefinition(content.pattern);
37816
+ const propsSchema = patternDef?.propsSchema;
37817
+ if (propsSchema) {
37818
+ for (const [propKey, propValue] of Object.entries(renderedProps)) {
37819
+ if (typeof propValue !== "string") continue;
37820
+ const propDef = propsSchema[propKey];
37821
+ if (!propDef || propDef.kind !== "callback") continue;
37822
+ renderedProps[propKey] = wrapCallbackForEvent(
37823
+ `UI:${propValue}`,
37824
+ propDef.callbackArgs,
37825
+ (eventKey, payload) => eventBus.emit(eventKey, payload)
37826
+ );
37827
+ }
37828
+ }
37791
37829
  const finalProps = renderedProps;
37792
37830
  const resolvedItems = Array.isArray(
37793
37831
  finalProps.entity
@@ -37912,6 +37950,7 @@ var init_UISlotRenderer = __esm({
37912
37950
  init_logger();
37913
37951
  init_Skeleton();
37914
37952
  init_renderer();
37953
+ init_wrapCallbackForEvent();
37915
37954
  init_TraitFrame();
37916
37955
  init_component_registry_generated();
37917
37956
  scopeWrapLog = createLogger("almadar:ui:scope-wrap");
@@ -55,8 +55,14 @@ export interface DataGridProps<T extends EntityRow = EntityRow> {
55
55
  * receive cards typed to that exact shape.
56
56
  */
57
57
  entity: T | readonly T[];
58
- /** Field definitions for rendering each card */
59
- fields: readonly DataGridField[];
58
+ /**
59
+ * Field definitions for rendering each card. The pattern contract in
60
+ * `@almadar/patterns` documents `columns` as the wire-format alias the
61
+ * compiler emits — both names resolve to the same shape here. Pass either.
62
+ */
63
+ fields?: readonly DataGridField[];
64
+ /** Alias for `fields` — the compiler emits `columns` for field defs. */
65
+ columns?: readonly DataGridField[];
60
66
  /** Per-item action buttons */
61
67
  itemActions?: readonly DataGridItemAction[];
62
68
  /** Number of columns (uses auto-fit if omitted) */
@@ -96,7 +102,7 @@ export interface DataGridProps<T extends EntityRow = EntityRow> {
96
102
  /** Max items to show before "Show More" button. Defaults to 0 (disabled). */
97
103
  pageSize?: number;
98
104
  }
99
- export declare function DataGrid<T extends EntityRow = EntityRow>({ entity, fields, itemActions, cols, gap, minCardWidth, className, isLoading, error, imageField, selectable, selectionEvent, infiniteScroll, loadMoreEvent, hasMore, children, pageSize, renderItem: schemaRenderItem, }: DataGridProps<T>): import("react/jsx-runtime").JSX.Element;
105
+ export declare function DataGrid<T extends EntityRow = EntityRow>({ entity, fields, columns, itemActions, cols, gap, minCardWidth, className, isLoading, error, imageField, selectable, selectionEvent, infiniteScroll, loadMoreEvent, hasMore, children, pageSize, renderItem: schemaRenderItem, }: DataGridProps<T>): import("react/jsx-runtime").JSX.Element;
100
106
  export declare namespace DataGrid {
101
107
  var displayName: string;
102
108
  }
@@ -45,8 +45,14 @@ export interface DataListProps<T extends EntityRow = EntityRow> {
45
45
  * receive items of that exact shape.
46
46
  */
47
47
  entity: T | readonly T[];
48
- /** Field definitions for rendering each row */
49
- fields: readonly DataListField[];
48
+ /**
49
+ * Field definitions for rendering each row. The pattern contract in
50
+ * `@almadar/patterns` documents `columns` as the wire-format alias the
51
+ * compiler emits — both names resolve to the same shape here. Pass either.
52
+ */
53
+ fields?: readonly DataListField[];
54
+ /** Alias for `fields` — the compiler emits `columns` for field defs. */
55
+ columns?: readonly DataListField[];
50
56
  /** Per-item action buttons */
51
57
  itemActions?: readonly DataListItemAction[];
52
58
  /** Gap between rows */
@@ -110,7 +116,7 @@ export interface DataListProps<T extends EntityRow = EntityRow> {
110
116
  /** Max items to show before "Show More" button. Defaults to 5. Set to 0 to disable. */
111
117
  pageSize?: number;
112
118
  }
113
- export declare function DataList<T extends EntityRow = EntityRow>({ entity, fields, itemActions, gap, variant, groupBy, senderField, currentUser, className, isLoading, error, reorderable: _reorderable, reorderEvent: _reorderEvent, swipeLeftEvent: _swipeLeftEvent, swipeLeftActions: _swipeLeftActions, swipeRightEvent: _swipeRightEvent, swipeRightActions: _swipeRightActions, longPressEvent: _longPressEvent, infiniteScroll, loadMoreEvent, hasMore, children, pageSize, renderItem: schemaRenderItem, }: DataListProps<T>): import("react/jsx-runtime").JSX.Element;
119
+ export declare function DataList<T extends EntityRow = EntityRow>({ entity, fields, columns, itemActions, gap, variant, groupBy, senderField, currentUser, className, isLoading, error, reorderable: _reorderable, reorderEvent: _reorderEvent, swipeLeftEvent: _swipeLeftEvent, swipeLeftActions: _swipeLeftActions, swipeRightEvent: _swipeRightEvent, swipeRightActions: _swipeRightActions, longPressEvent: _longPressEvent, infiniteScroll, loadMoreEvent, hasMore, children, pageSize, renderItem: schemaRenderItem, }: DataListProps<T>): import("react/jsx-runtime").JSX.Element;
114
120
  export declare namespace DataList {
115
121
  var displayName: string;
116
122
  }
@@ -7063,6 +7063,25 @@ var init_renderer = __esm({
7063
7063
  init_init();
7064
7064
  }
7065
7065
  });
7066
+
7067
+ // runtime/wrapCallbackForEvent.ts
7068
+ function wrapCallbackForEvent(qualifiedEvent, callbackArgs, emit) {
7069
+ const argNames = (callbackArgs ?? []).map((a) => a.name);
7070
+ if (argNames.length === 0) {
7071
+ return () => emit(qualifiedEvent);
7072
+ }
7073
+ return (...args) => {
7074
+ const payload = {};
7075
+ for (let i = 0; i < argNames.length; i += 1) {
7076
+ payload[argNames[i]] = args[i];
7077
+ }
7078
+ emit(qualifiedEvent, payload);
7079
+ };
7080
+ }
7081
+ var init_wrapCallbackForEvent = __esm({
7082
+ "runtime/wrapCallbackForEvent.ts"() {
7083
+ }
7084
+ });
7066
7085
  var variantBorderClasses, variantIconColors, iconMap3, Alert;
7067
7086
  var init_Alert = __esm({
7068
7087
  "components/molecules/Alert.tsx"() {
@@ -18692,6 +18711,7 @@ function formatValue(value, format) {
18692
18711
  function DataGrid({
18693
18712
  entity,
18694
18713
  fields,
18714
+ columns,
18695
18715
  itemActions,
18696
18716
  cols,
18697
18717
  gap = "md",
@@ -18713,6 +18733,7 @@ function DataGrid({
18713
18733
  const { t } = useTranslate();
18714
18734
  const [selectedIds, setSelectedIds] = React115.useState(/* @__PURE__ */ new Set());
18715
18735
  const [visibleCount, setVisibleCount] = React115.useState(pageSize || Infinity);
18736
+ const fieldDefs = fields ?? columns ?? [];
18716
18737
  const allData = Array.isArray(entity) ? entity : entity ? [entity] : [];
18717
18738
  const data = pageSize > 0 ? allData.slice(0, visibleCount) : allData;
18718
18739
  const hasMoreLocal = pageSize > 0 && visibleCount < allData.length;
@@ -18740,9 +18761,9 @@ function DataGrid({
18740
18761
  return next;
18741
18762
  });
18742
18763
  }, [data, selectionEvent, eventBus]);
18743
- const titleField = fields.find((f3) => f3.variant === "h3" || f3.variant === "h4") ?? fields[0];
18744
- const badgeFields = fields.filter((f3) => f3.variant === "badge" && f3 !== titleField);
18745
- const bodyFields = fields.filter((f3) => f3 !== titleField && !badgeFields.includes(f3));
18764
+ const titleField = fieldDefs.find((f3) => f3.variant === "h3" || f3.variant === "h4") ?? fieldDefs[0];
18765
+ const badgeFields = fieldDefs.filter((f3) => f3.variant === "badge" && f3 !== titleField);
18766
+ const bodyFields = fieldDefs.filter((f3) => f3 !== titleField && !badgeFields.includes(f3));
18746
18767
  const primaryActions = itemActions?.filter((a) => a.variant !== "danger") ?? [];
18747
18768
  const dangerActions = itemActions?.filter((a) => a.variant === "danger") ?? [];
18748
18769
  const handleActionClick = (action, itemData) => (e) => {
@@ -18755,7 +18776,7 @@ function DataGrid({
18755
18776
  };
18756
18777
  const hasRenderProp = typeof children === "function";
18757
18778
  React115.useEffect(() => {
18758
- if (data.length > 0 && !hasRenderProp && (!fields || fields.length === 0)) {
18779
+ if (data.length > 0 && !hasRenderProp && fieldDefs.length === 0) {
18759
18780
  const renderItemRaw = schemaRenderItem;
18760
18781
  const isFnLambda = Array.isArray(renderItemRaw) && renderItemRaw.length >= 3 && (renderItemRaw[0] === "fn" || renderItemRaw[0] === "lambda");
18761
18782
  dataGridLog.warn("renderItem-unresolved", {
@@ -18763,7 +18784,7 @@ function DataGrid({
18763
18784
  renderItemIsFnLambda: isFnLambda
18764
18785
  });
18765
18786
  }
18766
- }, [data, hasRenderProp, schemaRenderItem, fields]);
18787
+ }, [data, hasRenderProp, schemaRenderItem, fieldDefs]);
18767
18788
  const gridTemplateColumns = cols ? void 0 : `repeat(auto-fit, minmax(min(${minCardWidth}px, 100%), 1fr))`;
18768
18789
  const colsClass = cols ? {
18769
18790
  1: "grid-cols-1",
@@ -19068,6 +19089,7 @@ function groupData(items, field) {
19068
19089
  function DataList({
19069
19090
  entity,
19070
19091
  fields,
19092
+ columns,
19071
19093
  itemActions,
19072
19094
  gap = "none",
19073
19095
  variant = "default",
@@ -19097,6 +19119,7 @@ function DataList({
19097
19119
  const eventBus = useEventBus();
19098
19120
  const { t } = useTranslate();
19099
19121
  const [visibleCount, setVisibleCount] = React115__namespace.default.useState(pageSize || Infinity);
19122
+ const fieldDefs = fields ?? columns ?? [];
19100
19123
  const allData = Array.isArray(entity) ? entity : entity ? [entity] : [];
19101
19124
  const data = pageSize > 0 ? allData.slice(0, visibleCount) : allData;
19102
19125
  const hasMoreLocal = pageSize > 0 && visibleCount < allData.length;
@@ -19111,7 +19134,7 @@ function DataList({
19111
19134
  const isFnLambda = Array.isArray(renderItemRaw) && renderItemRaw.length >= 3 && (renderItemRaw[0] === "fn" || renderItemRaw[0] === "lambda");
19112
19135
  dataListLog.warn("renderItem-unresolved", {
19113
19136
  rowCount: data.length,
19114
- fieldsCount: fields?.length ?? 0,
19137
+ fieldsCount: fieldDefs.length,
19115
19138
  renderItemTypeOf,
19116
19139
  renderItemIsArray: Array.isArray(renderItemRaw),
19117
19140
  renderItemIsFnLambda: isFnLambda,
@@ -19120,11 +19143,11 @@ function DataList({
19120
19143
  sampleRowKeys: sampleKeys
19121
19144
  });
19122
19145
  }
19123
- }, [data, hasRenderProp, schemaRenderItem, children, fields]);
19124
- const titleField = fields.find((f3) => f3.variant === "h3" || f3.variant === "h4") ?? fields[0];
19125
- const badgeFields = fields.filter((f3) => f3.variant === "badge" && f3 !== titleField);
19126
- const progressFields = fields.filter((f3) => f3.variant === "progress");
19127
- const bodyFields = fields.filter(
19146
+ }, [data, hasRenderProp, schemaRenderItem, children, fieldDefs]);
19147
+ const titleField = fieldDefs.find((f3) => f3.variant === "h3" || f3.variant === "h4") ?? fieldDefs[0];
19148
+ const badgeFields = fieldDefs.filter((f3) => f3.variant === "badge" && f3 !== titleField);
19149
+ const progressFields = fieldDefs.filter((f3) => f3.variant === "progress");
19150
+ const bodyFields = fieldDefs.filter(
19128
19151
  (f3) => f3 !== titleField && !badgeFields.includes(f3) && !progressFields.includes(f3)
19129
19152
  );
19130
19153
  const handleActionClick = (action, itemData) => (e) => {
@@ -19156,7 +19179,7 @@ function DataList({
19156
19179
  if (isMessage) {
19157
19180
  const items2 = data.map((item) => item);
19158
19181
  const groups2 = groupBy ? groupData(items2, groupBy) : [{ label: "", items: items2 }];
19159
- const contentField = titleField?.name ?? fields[0]?.name ?? "";
19182
+ const contentField = titleField?.name ?? fieldDefs[0]?.name ?? "";
19160
19183
  return /* @__PURE__ */ jsxRuntime.jsx(VStack, { gap: "sm", className: cn("py-2", className), children: groups2.map((group, gi) => /* @__PURE__ */ jsxRuntime.jsxs(React115__namespace.default.Fragment, { children: [
19161
19184
  group.label && /* @__PURE__ */ jsxRuntime.jsx(Divider, { label: group.label, className: "my-2" }),
19162
19185
  group.items.map((itemData, index) => {
@@ -19164,7 +19187,7 @@ function DataList({
19164
19187
  const sender = senderField ? String(getNestedValue(itemData, senderField) ?? "") : "";
19165
19188
  const isSent = Boolean(currentUser && sender === currentUser);
19166
19189
  const content = getNestedValue(itemData, contentField);
19167
- const timestampField = fields.find((f3) => f3.format === "date");
19190
+ const timestampField = fieldDefs.find((f3) => f3.format === "date");
19168
19191
  const timestamp = timestampField ? getNestedValue(itemData, timestampField.name) : null;
19169
19192
  return /* @__PURE__ */ jsxRuntime.jsx(
19170
19193
  Box,
@@ -38332,6 +38355,7 @@ function SlotContentRenderer({
38332
38355
  );
38333
38356
  }
38334
38357
  }
38358
+ const eventBus = useEventBus();
38335
38359
  const schemaCtx = useEntitySchemaOptional();
38336
38360
  let entityDef;
38337
38361
  if (typeof entityProp === "string" && entityProp.length > 0 && schemaCtx) {
@@ -38353,6 +38377,20 @@ function SlotContentRenderer({
38353
38377
  const { children: _childrenConfig, ...restPropsNoChildren } = content.props;
38354
38378
  const restProps = childrenIsRenderFn ? { ...restPropsNoChildren, children: incomingChildren } : restPropsNoChildren;
38355
38379
  const renderedProps = renderPatternProps(restProps, onDismiss);
38380
+ const patternDef = patterns.getPatternDefinition(content.pattern);
38381
+ const propsSchema = patternDef?.propsSchema;
38382
+ if (propsSchema) {
38383
+ for (const [propKey, propValue] of Object.entries(renderedProps)) {
38384
+ if (typeof propValue !== "string") continue;
38385
+ const propDef = propsSchema[propKey];
38386
+ if (!propDef || propDef.kind !== "callback") continue;
38387
+ renderedProps[propKey] = wrapCallbackForEvent(
38388
+ `UI:${propValue}`,
38389
+ propDef.callbackArgs,
38390
+ (eventKey, payload) => eventBus.emit(eventKey, payload)
38391
+ );
38392
+ }
38393
+ }
38356
38394
  const finalProps = renderedProps;
38357
38395
  const resolvedItems = Array.isArray(
38358
38396
  finalProps.entity
@@ -38477,6 +38515,7 @@ var init_UISlotRenderer = __esm({
38477
38515
  init_logger();
38478
38516
  init_Skeleton();
38479
38517
  init_renderer();
38518
+ init_wrapCallbackForEvent();
38480
38519
  init_TraitFrame();
38481
38520
  init_component_registry_generated();
38482
38521
  scopeWrapLog = createLogger("almadar:ui:scope-wrap");
@@ -8,7 +8,7 @@ import * as LucideIcons from 'lucide-react';
8
8
  import { X, AlertTriangle, Info, AlertCircle, CheckCircle, Loader2, List, Printer, ChevronRight, ChevronLeft, Check, Copy, Code, FileText, WrapText, Trash2, Settings, Menu as Menu$1, Search, Bell, ChevronDown, 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';
9
9
  import { evaluate, createMinimalContext } from '@almadar/evaluator';
10
10
  import { useUISlots } from '@almadar/ui/context';
11
- import { getComponentForPattern as getComponentForPattern$1 } from '@almadar/patterns';
11
+ import { getPatternDefinition, getComponentForPattern as getComponentForPattern$1 } from '@almadar/patterns';
12
12
  import { createPortal } from 'react-dom';
13
13
  import { Link, Outlet, useLocation } from 'react-router-dom';
14
14
  import ReactMarkdown from 'react-markdown';
@@ -7018,6 +7018,25 @@ var init_renderer = __esm({
7018
7018
  init_init();
7019
7019
  }
7020
7020
  });
7021
+
7022
+ // runtime/wrapCallbackForEvent.ts
7023
+ function wrapCallbackForEvent(qualifiedEvent, callbackArgs, emit) {
7024
+ const argNames = (callbackArgs ?? []).map((a) => a.name);
7025
+ if (argNames.length === 0) {
7026
+ return () => emit(qualifiedEvent);
7027
+ }
7028
+ return (...args) => {
7029
+ const payload = {};
7030
+ for (let i = 0; i < argNames.length; i += 1) {
7031
+ payload[argNames[i]] = args[i];
7032
+ }
7033
+ emit(qualifiedEvent, payload);
7034
+ };
7035
+ }
7036
+ var init_wrapCallbackForEvent = __esm({
7037
+ "runtime/wrapCallbackForEvent.ts"() {
7038
+ }
7039
+ });
7021
7040
  var variantBorderClasses, variantIconColors, iconMap3, Alert;
7022
7041
  var init_Alert = __esm({
7023
7042
  "components/molecules/Alert.tsx"() {
@@ -18647,6 +18666,7 @@ function formatValue(value, format) {
18647
18666
  function DataGrid({
18648
18667
  entity,
18649
18668
  fields,
18669
+ columns,
18650
18670
  itemActions,
18651
18671
  cols,
18652
18672
  gap = "md",
@@ -18668,6 +18688,7 @@ function DataGrid({
18668
18688
  const { t } = useTranslate();
18669
18689
  const [selectedIds, setSelectedIds] = useState(/* @__PURE__ */ new Set());
18670
18690
  const [visibleCount, setVisibleCount] = useState(pageSize || Infinity);
18691
+ const fieldDefs = fields ?? columns ?? [];
18671
18692
  const allData = Array.isArray(entity) ? entity : entity ? [entity] : [];
18672
18693
  const data = pageSize > 0 ? allData.slice(0, visibleCount) : allData;
18673
18694
  const hasMoreLocal = pageSize > 0 && visibleCount < allData.length;
@@ -18695,9 +18716,9 @@ function DataGrid({
18695
18716
  return next;
18696
18717
  });
18697
18718
  }, [data, selectionEvent, eventBus]);
18698
- const titleField = fields.find((f3) => f3.variant === "h3" || f3.variant === "h4") ?? fields[0];
18699
- const badgeFields = fields.filter((f3) => f3.variant === "badge" && f3 !== titleField);
18700
- const bodyFields = fields.filter((f3) => f3 !== titleField && !badgeFields.includes(f3));
18719
+ const titleField = fieldDefs.find((f3) => f3.variant === "h3" || f3.variant === "h4") ?? fieldDefs[0];
18720
+ const badgeFields = fieldDefs.filter((f3) => f3.variant === "badge" && f3 !== titleField);
18721
+ const bodyFields = fieldDefs.filter((f3) => f3 !== titleField && !badgeFields.includes(f3));
18701
18722
  const primaryActions = itemActions?.filter((a) => a.variant !== "danger") ?? [];
18702
18723
  const dangerActions = itemActions?.filter((a) => a.variant === "danger") ?? [];
18703
18724
  const handleActionClick = (action, itemData) => (e) => {
@@ -18710,7 +18731,7 @@ function DataGrid({
18710
18731
  };
18711
18732
  const hasRenderProp = typeof children === "function";
18712
18733
  useEffect(() => {
18713
- if (data.length > 0 && !hasRenderProp && (!fields || fields.length === 0)) {
18734
+ if (data.length > 0 && !hasRenderProp && fieldDefs.length === 0) {
18714
18735
  const renderItemRaw = schemaRenderItem;
18715
18736
  const isFnLambda = Array.isArray(renderItemRaw) && renderItemRaw.length >= 3 && (renderItemRaw[0] === "fn" || renderItemRaw[0] === "lambda");
18716
18737
  dataGridLog.warn("renderItem-unresolved", {
@@ -18718,7 +18739,7 @@ function DataGrid({
18718
18739
  renderItemIsFnLambda: isFnLambda
18719
18740
  });
18720
18741
  }
18721
- }, [data, hasRenderProp, schemaRenderItem, fields]);
18742
+ }, [data, hasRenderProp, schemaRenderItem, fieldDefs]);
18722
18743
  const gridTemplateColumns = cols ? void 0 : `repeat(auto-fit, minmax(min(${minCardWidth}px, 100%), 1fr))`;
18723
18744
  const colsClass = cols ? {
18724
18745
  1: "grid-cols-1",
@@ -19023,6 +19044,7 @@ function groupData(items, field) {
19023
19044
  function DataList({
19024
19045
  entity,
19025
19046
  fields,
19047
+ columns,
19026
19048
  itemActions,
19027
19049
  gap = "none",
19028
19050
  variant = "default",
@@ -19052,6 +19074,7 @@ function DataList({
19052
19074
  const eventBus = useEventBus();
19053
19075
  const { t } = useTranslate();
19054
19076
  const [visibleCount, setVisibleCount] = React115__default.useState(pageSize || Infinity);
19077
+ const fieldDefs = fields ?? columns ?? [];
19055
19078
  const allData = Array.isArray(entity) ? entity : entity ? [entity] : [];
19056
19079
  const data = pageSize > 0 ? allData.slice(0, visibleCount) : allData;
19057
19080
  const hasMoreLocal = pageSize > 0 && visibleCount < allData.length;
@@ -19066,7 +19089,7 @@ function DataList({
19066
19089
  const isFnLambda = Array.isArray(renderItemRaw) && renderItemRaw.length >= 3 && (renderItemRaw[0] === "fn" || renderItemRaw[0] === "lambda");
19067
19090
  dataListLog.warn("renderItem-unresolved", {
19068
19091
  rowCount: data.length,
19069
- fieldsCount: fields?.length ?? 0,
19092
+ fieldsCount: fieldDefs.length,
19070
19093
  renderItemTypeOf,
19071
19094
  renderItemIsArray: Array.isArray(renderItemRaw),
19072
19095
  renderItemIsFnLambda: isFnLambda,
@@ -19075,11 +19098,11 @@ function DataList({
19075
19098
  sampleRowKeys: sampleKeys
19076
19099
  });
19077
19100
  }
19078
- }, [data, hasRenderProp, schemaRenderItem, children, fields]);
19079
- const titleField = fields.find((f3) => f3.variant === "h3" || f3.variant === "h4") ?? fields[0];
19080
- const badgeFields = fields.filter((f3) => f3.variant === "badge" && f3 !== titleField);
19081
- const progressFields = fields.filter((f3) => f3.variant === "progress");
19082
- const bodyFields = fields.filter(
19101
+ }, [data, hasRenderProp, schemaRenderItem, children, fieldDefs]);
19102
+ const titleField = fieldDefs.find((f3) => f3.variant === "h3" || f3.variant === "h4") ?? fieldDefs[0];
19103
+ const badgeFields = fieldDefs.filter((f3) => f3.variant === "badge" && f3 !== titleField);
19104
+ const progressFields = fieldDefs.filter((f3) => f3.variant === "progress");
19105
+ const bodyFields = fieldDefs.filter(
19083
19106
  (f3) => f3 !== titleField && !badgeFields.includes(f3) && !progressFields.includes(f3)
19084
19107
  );
19085
19108
  const handleActionClick = (action, itemData) => (e) => {
@@ -19111,7 +19134,7 @@ function DataList({
19111
19134
  if (isMessage) {
19112
19135
  const items2 = data.map((item) => item);
19113
19136
  const groups2 = groupBy ? groupData(items2, groupBy) : [{ label: "", items: items2 }];
19114
- const contentField = titleField?.name ?? fields[0]?.name ?? "";
19137
+ const contentField = titleField?.name ?? fieldDefs[0]?.name ?? "";
19115
19138
  return /* @__PURE__ */ jsx(VStack, { gap: "sm", className: cn("py-2", className), children: groups2.map((group, gi) => /* @__PURE__ */ jsxs(React115__default.Fragment, { children: [
19116
19139
  group.label && /* @__PURE__ */ jsx(Divider, { label: group.label, className: "my-2" }),
19117
19140
  group.items.map((itemData, index) => {
@@ -19119,7 +19142,7 @@ function DataList({
19119
19142
  const sender = senderField ? String(getNestedValue(itemData, senderField) ?? "") : "";
19120
19143
  const isSent = Boolean(currentUser && sender === currentUser);
19121
19144
  const content = getNestedValue(itemData, contentField);
19122
- const timestampField = fields.find((f3) => f3.format === "date");
19145
+ const timestampField = fieldDefs.find((f3) => f3.format === "date");
19123
19146
  const timestamp = timestampField ? getNestedValue(itemData, timestampField.name) : null;
19124
19147
  return /* @__PURE__ */ jsx(
19125
19148
  Box,
@@ -38287,6 +38310,7 @@ function SlotContentRenderer({
38287
38310
  );
38288
38311
  }
38289
38312
  }
38313
+ const eventBus = useEventBus();
38290
38314
  const schemaCtx = useEntitySchemaOptional();
38291
38315
  let entityDef;
38292
38316
  if (typeof entityProp === "string" && entityProp.length > 0 && schemaCtx) {
@@ -38308,6 +38332,20 @@ function SlotContentRenderer({
38308
38332
  const { children: _childrenConfig, ...restPropsNoChildren } = content.props;
38309
38333
  const restProps = childrenIsRenderFn ? { ...restPropsNoChildren, children: incomingChildren } : restPropsNoChildren;
38310
38334
  const renderedProps = renderPatternProps(restProps, onDismiss);
38335
+ const patternDef = getPatternDefinition(content.pattern);
38336
+ const propsSchema = patternDef?.propsSchema;
38337
+ if (propsSchema) {
38338
+ for (const [propKey, propValue] of Object.entries(renderedProps)) {
38339
+ if (typeof propValue !== "string") continue;
38340
+ const propDef = propsSchema[propKey];
38341
+ if (!propDef || propDef.kind !== "callback") continue;
38342
+ renderedProps[propKey] = wrapCallbackForEvent(
38343
+ `UI:${propValue}`,
38344
+ propDef.callbackArgs,
38345
+ (eventKey, payload) => eventBus.emit(eventKey, payload)
38346
+ );
38347
+ }
38348
+ }
38311
38349
  const finalProps = renderedProps;
38312
38350
  const resolvedItems = Array.isArray(
38313
38351
  finalProps.entity
@@ -38432,6 +38470,7 @@ var init_UISlotRenderer = __esm({
38432
38470
  init_logger();
38433
38471
  init_Skeleton();
38434
38472
  init_renderer();
38473
+ init_wrapCallbackForEvent();
38435
38474
  init_TraitFrame();
38436
38475
  init_component_registry_generated();
38437
38476
  scopeWrapLog = createLogger("almadar:ui:scope-wrap");