@plasmicapp/react-web 0.2.417 → 0.2.419

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.
@@ -1034,6 +1034,8 @@ var PLASMIC_IMAGE_LOADER = {
1034
1034
  },
1035
1035
  };
1036
1036
 
1037
+ // These props are used internally by PlasmicLink to determine how to render the link
1038
+ var INTERNAL_PROPS = ["component", "platform", "legacyBehavior"];
1037
1039
  var PlasmicLink = React__default.forwardRef(function PlasmicLink(props, ref) {
1038
1040
  var _a;
1039
1041
  // The usePlasmicLinkMaybe function may be undefined, if host is not up-to-date
@@ -1043,8 +1045,9 @@ var PlasmicLink = React__default.forwardRef(function PlasmicLink(props, ref) {
1043
1045
  return React__default.createElement(PlasmicLinkInternal, __assign({}, props, { ref: ref }));
1044
1046
  }
1045
1047
  else {
1046
- // Don't pass component/platform props to non-PlasmicLinkInternal
1047
- return React__default.createElement(Link, __assign({}, omit(props, "component", "platform"), { ref: ref }));
1048
+ // Don't pass internal props (component/platform/legacyBehavior) to non-PlasmicLinkInternal
1049
+ // eslint-disable-next-line react/forbid-elements
1050
+ return React__default.createElement(Link, __assign({}, omit.apply(void 0, __spreadArray([props], __read(INTERNAL_PROPS), false)), { ref: ref }));
1048
1051
  }
1049
1052
  });
1050
1053
  var PlasmicLinkInternal = React__default.forwardRef(function PlasmicLinkInternal(props, ref) {
@@ -1064,15 +1067,23 @@ var PlasmicLinkInternal = React__default.forwardRef(function PlasmicLinkInternal
1064
1067
  // If this is a fragment identifier link, then we set
1065
1068
  // scroll={false} so that smooth scrolling works
1066
1069
  var isFragment = (_a = props.href) === null || _a === void 0 ? void 0 : _a.startsWith("#");
1067
- return React__default.createElement(props.component, __assign(__assign({ scroll: !isFragment }, pick.apply(void 0, __spreadArray([props], __read(nextjsProps), false))), { legacyBehavior: true }), React__default.createElement("a", __assign({}, omit.apply(void 0, __spreadArray([props, "component", "platform"], __read(nextjsProps), false)), { ref: ref })));
1070
+ // Default to legacy behavior (nested <a> tag) unless legacyBehavior
1071
+ // is explicitly set to false. Older codegen may not set this prop at
1072
+ // all, so we treat undefined as legacy for backwards compatibility.
1073
+ // https://github.com/plasmicapp/plasmic-internal/pull/2203#issuecomment-3877931788
1074
+ if (props.legacyBehavior !== false) {
1075
+ return React__default.createElement(props.component, __assign({ scroll: !isFragment }, pick.apply(void 0, __spreadArray([props], __read(nextjsProps), false))), React__default.createElement("a", __assign({}, omit.apply(void 0, __spreadArray(__spreadArray([props], __read(INTERNAL_PROPS), false), __read(nextjsProps), false)), { ref: ref })));
1076
+ }
1077
+ // pass props directly to Link (no nested <a>)
1078
+ return React__default.createElement(props.component, __assign(__assign({ scroll: !isFragment }, omit.apply(void 0, __spreadArray([props], __read(INTERNAL_PROPS), false))), { ref: ref }));
1068
1079
  }
1069
1080
  if (props.platform === "gatsby" && isInternalHref(props.href)) {
1070
- return React__default.createElement(props.component, __assign(__assign({}, omit(props, "component", "platform", "href")), { to: props.href, ref: ref }));
1081
+ return React__default.createElement(props.component, __assign(__assign({}, omit.apply(void 0, __spreadArray(__spreadArray([props], __read(INTERNAL_PROPS), false), ["href"], false))), { to: props.href, ref: ref }));
1071
1082
  }
1072
1083
  if (props.platform === "tanstack" && isInternalHref(props.href)) {
1073
- return React__default.createElement(props.component, __assign(__assign({}, omit(props, "component", "platform", "href")), { to: props.href, ref: ref }));
1084
+ return React__default.createElement(props.component, __assign(__assign({}, omit.apply(void 0, __spreadArray(__spreadArray([props], __read(INTERNAL_PROPS), false), ["href"], false))), { to: props.href, ref: ref }));
1074
1085
  }
1075
- return React__default.createElement("a", __assign({}, omit(props, "component", "platform"), { ref: ref }));
1086
+ return React__default.createElement("a", __assign({}, omit.apply(void 0, __spreadArray([props], __read(INTERNAL_PROPS), false)), { ref: ref }));
1076
1087
  });
1077
1088
  function isInternalHref(href) {
1078
1089
  return /^\/(?!\/)/.test(href);