@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.
package/dist/index.cjs.js CHANGED
@@ -1053,6 +1053,8 @@ var PLASMIC_IMAGE_LOADER = {
1053
1053
  },
1054
1054
  };
1055
1055
 
1056
+ // These props are used internally by PlasmicLink to determine how to render the link
1057
+ var INTERNAL_PROPS = ["component", "platform", "legacyBehavior"];
1056
1058
  var PlasmicLink = React.forwardRef(function PlasmicLink(props, ref) {
1057
1059
  var _a;
1058
1060
  // The usePlasmicLinkMaybe function may be undefined, if host is not up-to-date
@@ -1062,8 +1064,9 @@ var PlasmicLink = React.forwardRef(function PlasmicLink(props, ref) {
1062
1064
  return React.createElement(PlasmicLinkInternal, __assign({}, props, { ref: ref }));
1063
1065
  }
1064
1066
  else {
1065
- // Don't pass component/platform props to non-PlasmicLinkInternal
1066
- return React.createElement(Link, __assign({}, omit(props, "component", "platform"), { ref: ref }));
1067
+ // Don't pass internal props (component/platform/legacyBehavior) to non-PlasmicLinkInternal
1068
+ // eslint-disable-next-line react/forbid-elements
1069
+ return React.createElement(Link, __assign({}, omit.apply(void 0, __spreadArray([props], __read(INTERNAL_PROPS), false)), { ref: ref }));
1067
1070
  }
1068
1071
  });
1069
1072
  var PlasmicLinkInternal = React.forwardRef(function PlasmicLinkInternal(props, ref) {
@@ -1083,15 +1086,23 @@ var PlasmicLinkInternal = React.forwardRef(function PlasmicLinkInternal(props, r
1083
1086
  // If this is a fragment identifier link, then we set
1084
1087
  // scroll={false} so that smooth scrolling works
1085
1088
  var isFragment = (_a = props.href) === null || _a === void 0 ? void 0 : _a.startsWith("#");
1086
- return React.createElement(props.component, __assign(__assign({ scroll: !isFragment }, pick.apply(void 0, __spreadArray([props], __read(nextjsProps), false))), { legacyBehavior: true }), React.createElement("a", __assign({}, omit.apply(void 0, __spreadArray([props, "component", "platform"], __read(nextjsProps), false)), { ref: ref })));
1089
+ // Default to legacy behavior (nested <a> tag) unless legacyBehavior
1090
+ // is explicitly set to false. Older codegen may not set this prop at
1091
+ // all, so we treat undefined as legacy for backwards compatibility.
1092
+ // https://github.com/plasmicapp/plasmic-internal/pull/2203#issuecomment-3877931788
1093
+ if (props.legacyBehavior !== false) {
1094
+ return React.createElement(props.component, __assign({ scroll: !isFragment }, pick.apply(void 0, __spreadArray([props], __read(nextjsProps), false))), React.createElement("a", __assign({}, omit.apply(void 0, __spreadArray(__spreadArray([props], __read(INTERNAL_PROPS), false), __read(nextjsProps), false)), { ref: ref })));
1095
+ }
1096
+ // pass props directly to Link (no nested <a>)
1097
+ return React.createElement(props.component, __assign(__assign({ scroll: !isFragment }, omit.apply(void 0, __spreadArray([props], __read(INTERNAL_PROPS), false))), { ref: ref }));
1087
1098
  }
1088
1099
  if (props.platform === "gatsby" && isInternalHref(props.href)) {
1089
- return React.createElement(props.component, __assign(__assign({}, omit(props, "component", "platform", "href")), { to: props.href, ref: ref }));
1100
+ return React.createElement(props.component, __assign(__assign({}, omit.apply(void 0, __spreadArray(__spreadArray([props], __read(INTERNAL_PROPS), false), ["href"], false))), { to: props.href, ref: ref }));
1090
1101
  }
1091
1102
  if (props.platform === "tanstack" && isInternalHref(props.href)) {
1092
- return React.createElement(props.component, __assign(__assign({}, omit(props, "component", "platform", "href")), { to: props.href, ref: ref }));
1103
+ return React.createElement(props.component, __assign(__assign({}, omit.apply(void 0, __spreadArray(__spreadArray([props], __read(INTERNAL_PROPS), false), ["href"], false))), { to: props.href, ref: ref }));
1093
1104
  }
1094
- return React.createElement("a", __assign({}, omit(props, "component", "platform"), { ref: ref }));
1105
+ return React.createElement("a", __assign({}, omit.apply(void 0, __spreadArray([props], __read(INTERNAL_PROPS), false)), { ref: ref }));
1095
1106
  });
1096
1107
  function isInternalHref(href) {
1097
1108
  return /^\/(?!\/)/.test(href);