@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.
- package/dist/avl/index.cjs +52 -13
- package/dist/avl/index.js +53 -14
- package/dist/components/index.cjs +52 -13
- package/dist/components/index.js +53 -14
- package/dist/components/molecules/DataGrid.d.ts +9 -3
- package/dist/components/molecules/DataList.d.ts +9 -3
- package/dist/providers/index.cjs +52 -13
- package/dist/providers/index.js +53 -14
- package/dist/runtime/index.cjs +56 -13
- package/dist/runtime/index.d.ts +1 -0
- package/dist/runtime/index.js +57 -15
- package/dist/runtime/wrapCallbackForEvent.d.ts +16 -0
- package/package.json +2 -2
package/dist/runtime/index.cjs
CHANGED
|
@@ -6958,6 +6958,25 @@ var init_renderer = __esm({
|
|
|
6958
6958
|
init_init();
|
|
6959
6959
|
}
|
|
6960
6960
|
});
|
|
6961
|
+
|
|
6962
|
+
// runtime/wrapCallbackForEvent.ts
|
|
6963
|
+
function wrapCallbackForEvent(qualifiedEvent, callbackArgs, emit) {
|
|
6964
|
+
const argNames = (callbackArgs ?? []).map((a) => a.name);
|
|
6965
|
+
if (argNames.length === 0) {
|
|
6966
|
+
return () => emit(qualifiedEvent);
|
|
6967
|
+
}
|
|
6968
|
+
return (...args) => {
|
|
6969
|
+
const payload = {};
|
|
6970
|
+
for (let i = 0; i < argNames.length; i += 1) {
|
|
6971
|
+
payload[argNames[i]] = args[i];
|
|
6972
|
+
}
|
|
6973
|
+
emit(qualifiedEvent, payload);
|
|
6974
|
+
};
|
|
6975
|
+
}
|
|
6976
|
+
var init_wrapCallbackForEvent = __esm({
|
|
6977
|
+
"runtime/wrapCallbackForEvent.ts"() {
|
|
6978
|
+
}
|
|
6979
|
+
});
|
|
6961
6980
|
var variantBorderClasses, variantIconColors, iconMap3, Alert;
|
|
6962
6981
|
var init_Alert = __esm({
|
|
6963
6982
|
"components/molecules/Alert.tsx"() {
|
|
@@ -18468,6 +18487,7 @@ function formatValue(value, format) {
|
|
|
18468
18487
|
function DataGrid({
|
|
18469
18488
|
entity,
|
|
18470
18489
|
fields,
|
|
18490
|
+
columns,
|
|
18471
18491
|
itemActions,
|
|
18472
18492
|
cols,
|
|
18473
18493
|
gap = "md",
|
|
@@ -18489,6 +18509,7 @@ function DataGrid({
|
|
|
18489
18509
|
const { t } = useTranslate();
|
|
18490
18510
|
const [selectedIds, setSelectedIds] = React113.useState(/* @__PURE__ */ new Set());
|
|
18491
18511
|
const [visibleCount, setVisibleCount] = React113.useState(pageSize || Infinity);
|
|
18512
|
+
const fieldDefs = fields ?? columns ?? [];
|
|
18492
18513
|
const allData = Array.isArray(entity) ? entity : entity ? [entity] : [];
|
|
18493
18514
|
const data = pageSize > 0 ? allData.slice(0, visibleCount) : allData;
|
|
18494
18515
|
const hasMoreLocal = pageSize > 0 && visibleCount < allData.length;
|
|
@@ -18516,9 +18537,9 @@ function DataGrid({
|
|
|
18516
18537
|
return next;
|
|
18517
18538
|
});
|
|
18518
18539
|
}, [data, selectionEvent, eventBus]);
|
|
18519
|
-
const titleField =
|
|
18520
|
-
const badgeFields =
|
|
18521
|
-
const bodyFields =
|
|
18540
|
+
const titleField = fieldDefs.find((f3) => f3.variant === "h3" || f3.variant === "h4") ?? fieldDefs[0];
|
|
18541
|
+
const badgeFields = fieldDefs.filter((f3) => f3.variant === "badge" && f3 !== titleField);
|
|
18542
|
+
const bodyFields = fieldDefs.filter((f3) => f3 !== titleField && !badgeFields.includes(f3));
|
|
18522
18543
|
const primaryActions = itemActions?.filter((a) => a.variant !== "danger") ?? [];
|
|
18523
18544
|
const dangerActions = itemActions?.filter((a) => a.variant === "danger") ?? [];
|
|
18524
18545
|
const handleActionClick = (action, itemData) => (e) => {
|
|
@@ -18531,7 +18552,7 @@ function DataGrid({
|
|
|
18531
18552
|
};
|
|
18532
18553
|
const hasRenderProp = typeof children === "function";
|
|
18533
18554
|
React113.useEffect(() => {
|
|
18534
|
-
if (data.length > 0 && !hasRenderProp &&
|
|
18555
|
+
if (data.length > 0 && !hasRenderProp && fieldDefs.length === 0) {
|
|
18535
18556
|
const renderItemRaw = schemaRenderItem;
|
|
18536
18557
|
const isFnLambda = Array.isArray(renderItemRaw) && renderItemRaw.length >= 3 && (renderItemRaw[0] === "fn" || renderItemRaw[0] === "lambda");
|
|
18537
18558
|
dataGridLog.warn("renderItem-unresolved", {
|
|
@@ -18539,7 +18560,7 @@ function DataGrid({
|
|
|
18539
18560
|
renderItemIsFnLambda: isFnLambda
|
|
18540
18561
|
});
|
|
18541
18562
|
}
|
|
18542
|
-
}, [data, hasRenderProp, schemaRenderItem,
|
|
18563
|
+
}, [data, hasRenderProp, schemaRenderItem, fieldDefs]);
|
|
18543
18564
|
const gridTemplateColumns = cols ? void 0 : `repeat(auto-fit, minmax(min(${minCardWidth}px, 100%), 1fr))`;
|
|
18544
18565
|
const colsClass = cols ? {
|
|
18545
18566
|
1: "grid-cols-1",
|
|
@@ -18844,6 +18865,7 @@ function groupData(items, field) {
|
|
|
18844
18865
|
function DataList({
|
|
18845
18866
|
entity,
|
|
18846
18867
|
fields,
|
|
18868
|
+
columns,
|
|
18847
18869
|
itemActions,
|
|
18848
18870
|
gap = "none",
|
|
18849
18871
|
variant = "default",
|
|
@@ -18873,6 +18895,7 @@ function DataList({
|
|
|
18873
18895
|
const eventBus = useEventBus();
|
|
18874
18896
|
const { t } = useTranslate();
|
|
18875
18897
|
const [visibleCount, setVisibleCount] = React113__namespace.default.useState(pageSize || Infinity);
|
|
18898
|
+
const fieldDefs = fields ?? columns ?? [];
|
|
18876
18899
|
const allData = Array.isArray(entity) ? entity : entity ? [entity] : [];
|
|
18877
18900
|
const data = pageSize > 0 ? allData.slice(0, visibleCount) : allData;
|
|
18878
18901
|
const hasMoreLocal = pageSize > 0 && visibleCount < allData.length;
|
|
@@ -18887,7 +18910,7 @@ function DataList({
|
|
|
18887
18910
|
const isFnLambda = Array.isArray(renderItemRaw) && renderItemRaw.length >= 3 && (renderItemRaw[0] === "fn" || renderItemRaw[0] === "lambda");
|
|
18888
18911
|
dataListLog.warn("renderItem-unresolved", {
|
|
18889
18912
|
rowCount: data.length,
|
|
18890
|
-
fieldsCount:
|
|
18913
|
+
fieldsCount: fieldDefs.length,
|
|
18891
18914
|
renderItemTypeOf,
|
|
18892
18915
|
renderItemIsArray: Array.isArray(renderItemRaw),
|
|
18893
18916
|
renderItemIsFnLambda: isFnLambda,
|
|
@@ -18896,11 +18919,11 @@ function DataList({
|
|
|
18896
18919
|
sampleRowKeys: sampleKeys
|
|
18897
18920
|
});
|
|
18898
18921
|
}
|
|
18899
|
-
}, [data, hasRenderProp, schemaRenderItem, children,
|
|
18900
|
-
const titleField =
|
|
18901
|
-
const badgeFields =
|
|
18902
|
-
const progressFields =
|
|
18903
|
-
const bodyFields =
|
|
18922
|
+
}, [data, hasRenderProp, schemaRenderItem, children, fieldDefs]);
|
|
18923
|
+
const titleField = fieldDefs.find((f3) => f3.variant === "h3" || f3.variant === "h4") ?? fieldDefs[0];
|
|
18924
|
+
const badgeFields = fieldDefs.filter((f3) => f3.variant === "badge" && f3 !== titleField);
|
|
18925
|
+
const progressFields = fieldDefs.filter((f3) => f3.variant === "progress");
|
|
18926
|
+
const bodyFields = fieldDefs.filter(
|
|
18904
18927
|
(f3) => f3 !== titleField && !badgeFields.includes(f3) && !progressFields.includes(f3)
|
|
18905
18928
|
);
|
|
18906
18929
|
const handleActionClick = (action, itemData) => (e) => {
|
|
@@ -18932,7 +18955,7 @@ function DataList({
|
|
|
18932
18955
|
if (isMessage) {
|
|
18933
18956
|
const items2 = data.map((item) => item);
|
|
18934
18957
|
const groups2 = groupBy ? groupData(items2, groupBy) : [{ label: "", items: items2 }];
|
|
18935
|
-
const contentField = titleField?.name ??
|
|
18958
|
+
const contentField = titleField?.name ?? fieldDefs[0]?.name ?? "";
|
|
18936
18959
|
return /* @__PURE__ */ jsxRuntime.jsx(VStack, { gap: "sm", className: cn("py-2", className), children: groups2.map((group, gi) => /* @__PURE__ */ jsxRuntime.jsxs(React113__namespace.default.Fragment, { children: [
|
|
18937
18960
|
group.label && /* @__PURE__ */ jsxRuntime.jsx(Divider, { label: group.label, className: "my-2" }),
|
|
18938
18961
|
group.items.map((itemData, index) => {
|
|
@@ -18940,7 +18963,7 @@ function DataList({
|
|
|
18940
18963
|
const sender = senderField ? String(getNestedValue(itemData, senderField) ?? "") : "";
|
|
18941
18964
|
const isSent = Boolean(currentUser && sender === currentUser);
|
|
18942
18965
|
const content = getNestedValue(itemData, contentField);
|
|
18943
|
-
const timestampField =
|
|
18966
|
+
const timestampField = fieldDefs.find((f3) => f3.format === "date");
|
|
18944
18967
|
const timestamp = timestampField ? getNestedValue(itemData, timestampField.name) : null;
|
|
18945
18968
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
18946
18969
|
Box,
|
|
@@ -37925,6 +37948,7 @@ function SlotContentRenderer({
|
|
|
37925
37948
|
);
|
|
37926
37949
|
}
|
|
37927
37950
|
}
|
|
37951
|
+
const eventBus = useEventBus();
|
|
37928
37952
|
const schemaCtx = useEntitySchemaOptional();
|
|
37929
37953
|
let entityDef;
|
|
37930
37954
|
if (typeof entityProp === "string" && entityProp.length > 0 && schemaCtx) {
|
|
@@ -37946,6 +37970,20 @@ function SlotContentRenderer({
|
|
|
37946
37970
|
const { children: _childrenConfig, ...restPropsNoChildren } = content.props;
|
|
37947
37971
|
const restProps = childrenIsRenderFn ? { ...restPropsNoChildren, children: incomingChildren } : restPropsNoChildren;
|
|
37948
37972
|
const renderedProps = renderPatternProps(restProps, onDismiss);
|
|
37973
|
+
const patternDef = patterns.getPatternDefinition(content.pattern);
|
|
37974
|
+
const propsSchema = patternDef?.propsSchema;
|
|
37975
|
+
if (propsSchema) {
|
|
37976
|
+
for (const [propKey, propValue] of Object.entries(renderedProps)) {
|
|
37977
|
+
if (typeof propValue !== "string") continue;
|
|
37978
|
+
const propDef = propsSchema[propKey];
|
|
37979
|
+
if (!propDef || propDef.kind !== "callback") continue;
|
|
37980
|
+
renderedProps[propKey] = wrapCallbackForEvent(
|
|
37981
|
+
`UI:${propValue}`,
|
|
37982
|
+
propDef.callbackArgs,
|
|
37983
|
+
(eventKey, payload) => eventBus.emit(eventKey, payload)
|
|
37984
|
+
);
|
|
37985
|
+
}
|
|
37986
|
+
}
|
|
37949
37987
|
const finalProps = renderedProps;
|
|
37950
37988
|
const resolvedItems = Array.isArray(
|
|
37951
37989
|
finalProps.entity
|
|
@@ -38070,6 +38108,7 @@ var init_UISlotRenderer = __esm({
|
|
|
38070
38108
|
init_logger();
|
|
38071
38109
|
init_Skeleton();
|
|
38072
38110
|
init_renderer();
|
|
38111
|
+
init_wrapCallbackForEvent();
|
|
38073
38112
|
init_TraitFrame();
|
|
38074
38113
|
init_component_registry_generated();
|
|
38075
38114
|
scopeWrapLog = createLogger("almadar:ui:scope-wrap");
|
|
@@ -39149,6 +39188,9 @@ function useTrait(traitName) {
|
|
|
39149
39188
|
return context.getTrait(traitName);
|
|
39150
39189
|
}
|
|
39151
39190
|
|
|
39191
|
+
// runtime/index.ts
|
|
39192
|
+
init_wrapCallbackForEvent();
|
|
39193
|
+
|
|
39152
39194
|
// runtime/OrbPreview.tsx
|
|
39153
39195
|
init_Box();
|
|
39154
39196
|
init_Typography();
|
|
@@ -39927,3 +39969,4 @@ exports.useServerBridge = useServerBridge;
|
|
|
39927
39969
|
exports.useTrait = useTrait;
|
|
39928
39970
|
exports.useTraitContext = useTraitContext;
|
|
39929
39971
|
exports.useTraitStateMachine = useTraitStateMachine;
|
|
39972
|
+
exports.wrapCallbackForEvent = wrapCallbackForEvent;
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export { useResolvedSchema, type ResolvedSchemaResult, clearSchemaCache } from '
|
|
|
11
11
|
export { EntitySchemaProvider, useEntitySchema, useEntityDefinition, useEntitySchemaOptional, type EntitySchemaContextValue, type EntitySchemaProviderProps, } from './EntitySchemaContext';
|
|
12
12
|
export { TraitProvider, TraitContext, useTraitContext, useTrait, type TraitContextValue, type TraitInstance, type TraitProviderProps, } from './TraitProvider';
|
|
13
13
|
export type { SlotPatternEntry, SlotSource } from './ui/slot-types';
|
|
14
|
+
export { wrapCallbackForEvent } from './wrapCallbackForEvent';
|
|
14
15
|
export { createClientEffectHandlers, type ClientEventBus, type SlotSetter, type CreateClientEffectHandlersOptions, } from './createClientEffectHandlers';
|
|
15
16
|
export { OrbPreview, type OrbPreviewProps } from './OrbPreview';
|
|
16
17
|
export { BrowserPlayground, type BrowserPlaygroundProps } from './BrowserPlayground';
|
package/dist/runtime/index.js
CHANGED
|
@@ -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, UISlotProvider } 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';
|
|
@@ -6913,6 +6913,25 @@ var init_renderer = __esm({
|
|
|
6913
6913
|
init_init();
|
|
6914
6914
|
}
|
|
6915
6915
|
});
|
|
6916
|
+
|
|
6917
|
+
// runtime/wrapCallbackForEvent.ts
|
|
6918
|
+
function wrapCallbackForEvent(qualifiedEvent, callbackArgs, emit) {
|
|
6919
|
+
const argNames = (callbackArgs ?? []).map((a) => a.name);
|
|
6920
|
+
if (argNames.length === 0) {
|
|
6921
|
+
return () => emit(qualifiedEvent);
|
|
6922
|
+
}
|
|
6923
|
+
return (...args) => {
|
|
6924
|
+
const payload = {};
|
|
6925
|
+
for (let i = 0; i < argNames.length; i += 1) {
|
|
6926
|
+
payload[argNames[i]] = args[i];
|
|
6927
|
+
}
|
|
6928
|
+
emit(qualifiedEvent, payload);
|
|
6929
|
+
};
|
|
6930
|
+
}
|
|
6931
|
+
var init_wrapCallbackForEvent = __esm({
|
|
6932
|
+
"runtime/wrapCallbackForEvent.ts"() {
|
|
6933
|
+
}
|
|
6934
|
+
});
|
|
6916
6935
|
var variantBorderClasses, variantIconColors, iconMap3, Alert;
|
|
6917
6936
|
var init_Alert = __esm({
|
|
6918
6937
|
"components/molecules/Alert.tsx"() {
|
|
@@ -18423,6 +18442,7 @@ function formatValue(value, format) {
|
|
|
18423
18442
|
function DataGrid({
|
|
18424
18443
|
entity,
|
|
18425
18444
|
fields,
|
|
18445
|
+
columns,
|
|
18426
18446
|
itemActions,
|
|
18427
18447
|
cols,
|
|
18428
18448
|
gap = "md",
|
|
@@ -18444,6 +18464,7 @@ function DataGrid({
|
|
|
18444
18464
|
const { t } = useTranslate();
|
|
18445
18465
|
const [selectedIds, setSelectedIds] = useState(/* @__PURE__ */ new Set());
|
|
18446
18466
|
const [visibleCount, setVisibleCount] = useState(pageSize || Infinity);
|
|
18467
|
+
const fieldDefs = fields ?? columns ?? [];
|
|
18447
18468
|
const allData = Array.isArray(entity) ? entity : entity ? [entity] : [];
|
|
18448
18469
|
const data = pageSize > 0 ? allData.slice(0, visibleCount) : allData;
|
|
18449
18470
|
const hasMoreLocal = pageSize > 0 && visibleCount < allData.length;
|
|
@@ -18471,9 +18492,9 @@ function DataGrid({
|
|
|
18471
18492
|
return next;
|
|
18472
18493
|
});
|
|
18473
18494
|
}, [data, selectionEvent, eventBus]);
|
|
18474
|
-
const titleField =
|
|
18475
|
-
const badgeFields =
|
|
18476
|
-
const bodyFields =
|
|
18495
|
+
const titleField = fieldDefs.find((f3) => f3.variant === "h3" || f3.variant === "h4") ?? fieldDefs[0];
|
|
18496
|
+
const badgeFields = fieldDefs.filter((f3) => f3.variant === "badge" && f3 !== titleField);
|
|
18497
|
+
const bodyFields = fieldDefs.filter((f3) => f3 !== titleField && !badgeFields.includes(f3));
|
|
18477
18498
|
const primaryActions = itemActions?.filter((a) => a.variant !== "danger") ?? [];
|
|
18478
18499
|
const dangerActions = itemActions?.filter((a) => a.variant === "danger") ?? [];
|
|
18479
18500
|
const handleActionClick = (action, itemData) => (e) => {
|
|
@@ -18486,7 +18507,7 @@ function DataGrid({
|
|
|
18486
18507
|
};
|
|
18487
18508
|
const hasRenderProp = typeof children === "function";
|
|
18488
18509
|
useEffect(() => {
|
|
18489
|
-
if (data.length > 0 && !hasRenderProp &&
|
|
18510
|
+
if (data.length > 0 && !hasRenderProp && fieldDefs.length === 0) {
|
|
18490
18511
|
const renderItemRaw = schemaRenderItem;
|
|
18491
18512
|
const isFnLambda = Array.isArray(renderItemRaw) && renderItemRaw.length >= 3 && (renderItemRaw[0] === "fn" || renderItemRaw[0] === "lambda");
|
|
18492
18513
|
dataGridLog.warn("renderItem-unresolved", {
|
|
@@ -18494,7 +18515,7 @@ function DataGrid({
|
|
|
18494
18515
|
renderItemIsFnLambda: isFnLambda
|
|
18495
18516
|
});
|
|
18496
18517
|
}
|
|
18497
|
-
}, [data, hasRenderProp, schemaRenderItem,
|
|
18518
|
+
}, [data, hasRenderProp, schemaRenderItem, fieldDefs]);
|
|
18498
18519
|
const gridTemplateColumns = cols ? void 0 : `repeat(auto-fit, minmax(min(${minCardWidth}px, 100%), 1fr))`;
|
|
18499
18520
|
const colsClass = cols ? {
|
|
18500
18521
|
1: "grid-cols-1",
|
|
@@ -18799,6 +18820,7 @@ function groupData(items, field) {
|
|
|
18799
18820
|
function DataList({
|
|
18800
18821
|
entity,
|
|
18801
18822
|
fields,
|
|
18823
|
+
columns,
|
|
18802
18824
|
itemActions,
|
|
18803
18825
|
gap = "none",
|
|
18804
18826
|
variant = "default",
|
|
@@ -18828,6 +18850,7 @@ function DataList({
|
|
|
18828
18850
|
const eventBus = useEventBus();
|
|
18829
18851
|
const { t } = useTranslate();
|
|
18830
18852
|
const [visibleCount, setVisibleCount] = React113__default.useState(pageSize || Infinity);
|
|
18853
|
+
const fieldDefs = fields ?? columns ?? [];
|
|
18831
18854
|
const allData = Array.isArray(entity) ? entity : entity ? [entity] : [];
|
|
18832
18855
|
const data = pageSize > 0 ? allData.slice(0, visibleCount) : allData;
|
|
18833
18856
|
const hasMoreLocal = pageSize > 0 && visibleCount < allData.length;
|
|
@@ -18842,7 +18865,7 @@ function DataList({
|
|
|
18842
18865
|
const isFnLambda = Array.isArray(renderItemRaw) && renderItemRaw.length >= 3 && (renderItemRaw[0] === "fn" || renderItemRaw[0] === "lambda");
|
|
18843
18866
|
dataListLog.warn("renderItem-unresolved", {
|
|
18844
18867
|
rowCount: data.length,
|
|
18845
|
-
fieldsCount:
|
|
18868
|
+
fieldsCount: fieldDefs.length,
|
|
18846
18869
|
renderItemTypeOf,
|
|
18847
18870
|
renderItemIsArray: Array.isArray(renderItemRaw),
|
|
18848
18871
|
renderItemIsFnLambda: isFnLambda,
|
|
@@ -18851,11 +18874,11 @@ function DataList({
|
|
|
18851
18874
|
sampleRowKeys: sampleKeys
|
|
18852
18875
|
});
|
|
18853
18876
|
}
|
|
18854
|
-
}, [data, hasRenderProp, schemaRenderItem, children,
|
|
18855
|
-
const titleField =
|
|
18856
|
-
const badgeFields =
|
|
18857
|
-
const progressFields =
|
|
18858
|
-
const bodyFields =
|
|
18877
|
+
}, [data, hasRenderProp, schemaRenderItem, children, fieldDefs]);
|
|
18878
|
+
const titleField = fieldDefs.find((f3) => f3.variant === "h3" || f3.variant === "h4") ?? fieldDefs[0];
|
|
18879
|
+
const badgeFields = fieldDefs.filter((f3) => f3.variant === "badge" && f3 !== titleField);
|
|
18880
|
+
const progressFields = fieldDefs.filter((f3) => f3.variant === "progress");
|
|
18881
|
+
const bodyFields = fieldDefs.filter(
|
|
18859
18882
|
(f3) => f3 !== titleField && !badgeFields.includes(f3) && !progressFields.includes(f3)
|
|
18860
18883
|
);
|
|
18861
18884
|
const handleActionClick = (action, itemData) => (e) => {
|
|
@@ -18887,7 +18910,7 @@ function DataList({
|
|
|
18887
18910
|
if (isMessage) {
|
|
18888
18911
|
const items2 = data.map((item) => item);
|
|
18889
18912
|
const groups2 = groupBy ? groupData(items2, groupBy) : [{ label: "", items: items2 }];
|
|
18890
|
-
const contentField = titleField?.name ??
|
|
18913
|
+
const contentField = titleField?.name ?? fieldDefs[0]?.name ?? "";
|
|
18891
18914
|
return /* @__PURE__ */ jsx(VStack, { gap: "sm", className: cn("py-2", className), children: groups2.map((group, gi) => /* @__PURE__ */ jsxs(React113__default.Fragment, { children: [
|
|
18892
18915
|
group.label && /* @__PURE__ */ jsx(Divider, { label: group.label, className: "my-2" }),
|
|
18893
18916
|
group.items.map((itemData, index) => {
|
|
@@ -18895,7 +18918,7 @@ function DataList({
|
|
|
18895
18918
|
const sender = senderField ? String(getNestedValue(itemData, senderField) ?? "") : "";
|
|
18896
18919
|
const isSent = Boolean(currentUser && sender === currentUser);
|
|
18897
18920
|
const content = getNestedValue(itemData, contentField);
|
|
18898
|
-
const timestampField =
|
|
18921
|
+
const timestampField = fieldDefs.find((f3) => f3.format === "date");
|
|
18899
18922
|
const timestamp = timestampField ? getNestedValue(itemData, timestampField.name) : null;
|
|
18900
18923
|
return /* @__PURE__ */ jsx(
|
|
18901
18924
|
Box,
|
|
@@ -37880,6 +37903,7 @@ function SlotContentRenderer({
|
|
|
37880
37903
|
);
|
|
37881
37904
|
}
|
|
37882
37905
|
}
|
|
37906
|
+
const eventBus = useEventBus();
|
|
37883
37907
|
const schemaCtx = useEntitySchemaOptional();
|
|
37884
37908
|
let entityDef;
|
|
37885
37909
|
if (typeof entityProp === "string" && entityProp.length > 0 && schemaCtx) {
|
|
@@ -37901,6 +37925,20 @@ function SlotContentRenderer({
|
|
|
37901
37925
|
const { children: _childrenConfig, ...restPropsNoChildren } = content.props;
|
|
37902
37926
|
const restProps = childrenIsRenderFn ? { ...restPropsNoChildren, children: incomingChildren } : restPropsNoChildren;
|
|
37903
37927
|
const renderedProps = renderPatternProps(restProps, onDismiss);
|
|
37928
|
+
const patternDef = getPatternDefinition(content.pattern);
|
|
37929
|
+
const propsSchema = patternDef?.propsSchema;
|
|
37930
|
+
if (propsSchema) {
|
|
37931
|
+
for (const [propKey, propValue] of Object.entries(renderedProps)) {
|
|
37932
|
+
if (typeof propValue !== "string") continue;
|
|
37933
|
+
const propDef = propsSchema[propKey];
|
|
37934
|
+
if (!propDef || propDef.kind !== "callback") continue;
|
|
37935
|
+
renderedProps[propKey] = wrapCallbackForEvent(
|
|
37936
|
+
`UI:${propValue}`,
|
|
37937
|
+
propDef.callbackArgs,
|
|
37938
|
+
(eventKey, payload) => eventBus.emit(eventKey, payload)
|
|
37939
|
+
);
|
|
37940
|
+
}
|
|
37941
|
+
}
|
|
37904
37942
|
const finalProps = renderedProps;
|
|
37905
37943
|
const resolvedItems = Array.isArray(
|
|
37906
37944
|
finalProps.entity
|
|
@@ -38025,6 +38063,7 @@ var init_UISlotRenderer = __esm({
|
|
|
38025
38063
|
init_logger();
|
|
38026
38064
|
init_Skeleton();
|
|
38027
38065
|
init_renderer();
|
|
38066
|
+
init_wrapCallbackForEvent();
|
|
38028
38067
|
init_TraitFrame();
|
|
38029
38068
|
init_component_registry_generated();
|
|
38030
38069
|
scopeWrapLog = createLogger("almadar:ui:scope-wrap");
|
|
@@ -39104,6 +39143,9 @@ function useTrait(traitName) {
|
|
|
39104
39143
|
return context.getTrait(traitName);
|
|
39105
39144
|
}
|
|
39106
39145
|
|
|
39146
|
+
// runtime/index.ts
|
|
39147
|
+
init_wrapCallbackForEvent();
|
|
39148
|
+
|
|
39107
39149
|
// runtime/OrbPreview.tsx
|
|
39108
39150
|
init_Box();
|
|
39109
39151
|
init_Typography();
|
|
@@ -39863,4 +39905,4 @@ function BrowserPlayground({
|
|
|
39863
39905
|
);
|
|
39864
39906
|
}
|
|
39865
39907
|
|
|
39866
|
-
export { BrowserPlayground, EntitySchemaProvider, OrbPreview, ServerBridgeProvider, TraitContext, TraitProvider, adjustSchemaForMockData, buildMockData, clearSchemaCache, createClientEffectHandlers, prepareSchemaForPreview, useEntityDefinition, useEntitySchema, useEntitySchemaOptional, useResolvedSchema, useServerBridge, useTrait, useTraitContext, useTraitStateMachine };
|
|
39908
|
+
export { BrowserPlayground, EntitySchemaProvider, OrbPreview, ServerBridgeProvider, TraitContext, TraitProvider, adjustSchemaForMockData, buildMockData, clearSchemaCache, createClientEffectHandlers, prepareSchemaForPreview, useEntityDefinition, useEntitySchema, useEntitySchemaOptional, useResolvedSchema, useServerBridge, useTrait, useTraitContext, useTraitStateMachine, wrapCallbackForEvent };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { PatternCallbackArg } from '@almadar/patterns';
|
|
2
|
+
import type { EventPayload, EventPayloadValue } from '@almadar/core';
|
|
3
|
+
/**
|
|
4
|
+
* Build the runtime wrapper that turns a string-typed callback prop
|
|
5
|
+
* (e.g. `onTabChange: "TAB_CHANGED"`) into a function the component can
|
|
6
|
+
* invoke. The wrapper consumes the component's positional callback args
|
|
7
|
+
* by name and dispatches an OBJECT payload `{ argName: value, ... }` so
|
|
8
|
+
* the bus carries the trait's declared event payload, not a raw
|
|
9
|
+
* positional spread. Mirrors the codegen wrapper in
|
|
10
|
+
* `orbital-shell-typescript/src/codegen/pattern.rs` (C2 compiled path).
|
|
11
|
+
*
|
|
12
|
+
* Single-sourcing this logic across runtime and codegen (shared shape,
|
|
13
|
+
* not shared code — codegen emits string source) is what keeps the two
|
|
14
|
+
* paths from silently diverging on payload shape.
|
|
15
|
+
*/
|
|
16
|
+
export declare function wrapCallbackForEvent(qualifiedEvent: string, callbackArgs: PatternCallbackArg[] | undefined, emit: (eventKey: string, payload?: EventPayload) => void): (...args: EventPayloadValue[]) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@almadar/ui",
|
|
3
|
-
"version": "4.22.
|
|
3
|
+
"version": "4.22.2",
|
|
4
4
|
"description": "React UI components, hooks, and providers for Almadar",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/components/index.js",
|
|
@@ -120,7 +120,7 @@
|
|
|
120
120
|
"dependencies": {
|
|
121
121
|
"@almadar/core": "^7.10.0",
|
|
122
122
|
"@almadar/evaluator": ">=2.9.2",
|
|
123
|
-
"@almadar/patterns": "
|
|
123
|
+
"@almadar/patterns": "^2.20.1",
|
|
124
124
|
"@almadar/runtime": "^6.0.0",
|
|
125
125
|
"@almadar/std": ">=6.4.1",
|
|
126
126
|
"@almadar/syntax": ">=1.3.1",
|