@sapui5/sap.fe.base 1.148.7 → 1.148.8

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.
@@ -822,6 +822,86 @@ export function pathInModel<TargetType extends PrimitiveType>(
822
822
  };
823
823
  }
824
824
 
825
+ /**
826
+ * Transforms a binding path from a navigation property context to its parent context.
827
+ *
828
+ * This is used to transform a binding made for a NavProp context /MainObject/NavProp1/NavProp2
829
+ * into a binding on the previous context /MainObject/NavProp1.
830
+ * @param path The path string to transform
831
+ * @param partnerPath The optional partner navigation property name to check against
832
+ * @returns A binding expression for the upper context, or unresolvableExpression if the path cannot be transformed
833
+ */
834
+ export function getBindingPathExpressionFromPartnerNavigation(path: string, partnerPath?: string): BindingToolkitExpression<unknown> {
835
+ if (path.startsWith("/")) {
836
+ // path is absolute it can be resolved from anywhere
837
+ return pathInModel(path);
838
+ }
839
+
840
+ if (partnerPath && path.startsWith(partnerPath + "/")) {
841
+ // Remove the partner navigation path prefix
842
+ return pathInModel(path.substring(partnerPath.length + 1));
843
+ } else {
844
+ return unresolvableExpression;
845
+ }
846
+ }
847
+
848
+ /**
849
+ * Recursively transforms an expression from a navigation property context to its parent context.
850
+ *
851
+ * This function walks through the expression tree and transforms all PathInModel expressions
852
+ * that reference relative paths (non-absolute, default model) using the partner navigation property.
853
+ * If the resulting expression contains unresolvable parts, the fallback value is returned instead.
854
+ * @template T The type of the binding expression
855
+ * @param expression The initial binding expression to transform
856
+ * @param partnerNavigationPropertyName The partner navigation property name to use for transformation
857
+ * @param fallbackValue The value to return if the expression becomes unresolvable
858
+ * @returns The transformed expression or the fallback value if unresolvable
859
+ */
860
+ export function getBindingExpressionFromUpperContext<T extends PrimitiveType>(
861
+ expression: BindingToolkitExpression<T>,
862
+ partnerNavigationPropertyName: string | undefined,
863
+ fallbackValue: BindingToolkitExpression<T>
864
+ ): BindingToolkitExpression<T> {
865
+ if (expression._type === "Set") {
866
+ const newOperands = expression.operands.map((operand: BindingToolkitExpression<boolean>) =>
867
+ getBindingExpressionFromUpperContext(
868
+ operand,
869
+ partnerNavigationPropertyName,
870
+ fallbackValue as unknown as BindingToolkitExpression<boolean>
871
+ )
872
+ );
873
+
874
+ if (expression.operator === "||") {
875
+ return or(...(newOperands as unknown as BindingToolkitExpression<boolean>[])) as unknown as BindingToolkitExpression<T>;
876
+ } else {
877
+ return and(...(newOperands as unknown as BindingToolkitExpression<boolean>[])) as unknown as BindingToolkitExpression<T>;
878
+ }
879
+ }
880
+ // Transform PathInModel expressions using the partner navigation
881
+ const transformedExpression = transformRecursively<T, "PathInModel">(
882
+ expression,
883
+ "PathInModel",
884
+ (pathExpression: PathInModelExpression<T>) => {
885
+ // Only transform relative paths in the default model (modelName is undefined or empty)
886
+ if (!pathExpression.modelName || pathExpression.modelName === "") {
887
+ return getBindingPathExpressionFromPartnerNavigation(
888
+ pathExpression.path,
889
+ partnerNavigationPropertyName
890
+ ) as BindingToolkitExpression<T>;
891
+ }
892
+ return pathExpression;
893
+ },
894
+ true // includeAllExpression - transform all expression types in the tree
895
+ );
896
+
897
+ // Check if the transformed expression contains unresolvable parts
898
+ if (hasUnresolvableExpression(transformedExpression)) {
899
+ return fallbackValue;
900
+ }
901
+
902
+ return transformedExpression;
903
+ }
904
+
825
905
  type PlainExpressionObject = { [index: string]: BindingToolkitExpression<unknown> };
826
906
 
827
907
  /**
@@ -22,7 +22,7 @@ sap.ui.define(["sap/ui/core/Lib"], function (Library) {
22
22
  controls: [],
23
23
  elements: [],
24
24
  // eslint-disable-next-line no-template-curly-in-string
25
- version: "1.148.7",
25
+ version: "1.148.8",
26
26
  noLibraryCSS: true
27
27
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
28
28
  });