@wipco/sdui 0.46.0 → 0.47.0
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/index.js +30 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2423,10 +2423,20 @@ function revertUnsettledStamps(fetched, runnable, epochs, settled) {
|
|
|
2423
2423
|
function isArgsFrame(frame) {
|
|
2424
2424
|
return "callSiteScope" in frame;
|
|
2425
2425
|
}
|
|
2426
|
+
function isEventFrame(frame) {
|
|
2427
|
+
return "event" in frame;
|
|
2428
|
+
}
|
|
2429
|
+
function nearestEventFrame(scope) {
|
|
2430
|
+
for (let i = scope.length - 1; i >= 0; i -= 1) {
|
|
2431
|
+
const frame = scope[i];
|
|
2432
|
+
if (isEventFrame(frame)) return frame;
|
|
2433
|
+
}
|
|
2434
|
+
return void 0;
|
|
2435
|
+
}
|
|
2426
2436
|
function nearestItemFrame(scope) {
|
|
2427
2437
|
for (let i = scope.length - 1; i >= 0; i--) {
|
|
2428
2438
|
const frame = scope[i];
|
|
2429
|
-
if (!isArgsFrame(frame)) return frame;
|
|
2439
|
+
if (!isArgsFrame(frame) && !isEventFrame(frame)) return frame;
|
|
2430
2440
|
}
|
|
2431
2441
|
return void 0;
|
|
2432
2442
|
}
|
|
@@ -2449,6 +2459,17 @@ function isItemRef(v) {
|
|
|
2449
2459
|
function isIndexRef(v) {
|
|
2450
2460
|
return isPlainObject5(v) && "$index" in v;
|
|
2451
2461
|
}
|
|
2462
|
+
function isEventRef(v) {
|
|
2463
|
+
return isPlainObject5(v) && "$event" in v;
|
|
2464
|
+
}
|
|
2465
|
+
function readEventPath(source, path) {
|
|
2466
|
+
let current = source;
|
|
2467
|
+
for (const segment of path.split(".")) {
|
|
2468
|
+
if (!isPlainObject5(current) || !Object.hasOwn(current, segment)) return null;
|
|
2469
|
+
current = current[segment];
|
|
2470
|
+
}
|
|
2471
|
+
return current ?? null;
|
|
2472
|
+
}
|
|
2452
2473
|
function isCalcRef(v) {
|
|
2453
2474
|
return isPlainObject5(v) && isPlainObject5(v.$calc);
|
|
2454
2475
|
}
|
|
@@ -2645,11 +2666,7 @@ function SduiNodeRenderer({
|
|
|
2645
2666
|
}
|
|
2646
2667
|
if (name.startsWith("on") && (isAction(raw) || isArgRef(raw) || isActionEntryList(raw))) {
|
|
2647
2668
|
props[name] = (arg) => expandActionEntries(raw, scope).forEach(
|
|
2648
|
-
(entry) => dispatch(
|
|
2649
|
-
resolveValue(entry.action, entry.scope),
|
|
2650
|
-
arg,
|
|
2651
|
-
entry.scope
|
|
2652
|
-
)
|
|
2669
|
+
(entry) => dispatch(entry.action, arg, entry.scope)
|
|
2653
2670
|
);
|
|
2654
2671
|
} else if (name === "rowClick" && (isAction(raw) || isActionList(raw))) {
|
|
2655
2672
|
props[name] = raw;
|
|
@@ -2917,6 +2934,11 @@ function SduiRenderer({
|
|
|
2917
2934
|
if (isIndexRef(value)) {
|
|
2918
2935
|
return nearestItemFrame(scope)?.index ?? null;
|
|
2919
2936
|
}
|
|
2937
|
+
if (isEventRef(value)) {
|
|
2938
|
+
const frame = nearestEventFrame(scope);
|
|
2939
|
+
if (!frame) return null;
|
|
2940
|
+
return value.$event === true ? frame.event : readEventPath(frame.event, String(value.$event));
|
|
2941
|
+
}
|
|
2920
2942
|
if (isArgRef(value)) {
|
|
2921
2943
|
const frame = nearestArgsFrame(scope);
|
|
2922
2944
|
if (frame?.args && Object.hasOwn(frame.args, value.$arg)) {
|
|
@@ -3032,9 +3054,10 @@ function SduiRenderer({
|
|
|
3032
3054
|
}
|
|
3033
3055
|
return;
|
|
3034
3056
|
}
|
|
3057
|
+
const eventScope = arg === void 0 ? scope : [...scope, { event: eventValue(arg) }];
|
|
3035
3058
|
const action = resolveValue(
|
|
3036
3059
|
rawAction,
|
|
3037
|
-
|
|
3060
|
+
eventScope
|
|
3038
3061
|
);
|
|
3039
3062
|
switch (action.action) {
|
|
3040
3063
|
case "navigate":
|