@plasmicpkgs/plasmic-rich-components 1.0.94 → 1.0.95

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/common.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import React from "react";
1
2
  export declare function useIsClient(): boolean;
3
+ export declare const useIsomorphicLayoutEffect: typeof React.useLayoutEffect;
2
4
  export declare function capitalize(text: string): string;
3
5
  export declare function isLight(color: string): boolean;
package/dist/index.js CHANGED
@@ -8,6 +8,7 @@ var antd = require('antd');
8
8
  var tinycolor = require('@ctrl/tinycolor');
9
9
  var icons = require('@ant-design/icons');
10
10
  var proComponents = require('@ant-design/pro-components');
11
+ var host = require('@plasmicapp/host');
11
12
  var csvWriterBrowser = require('csv-writer-browser');
12
13
  var fastStringify = require('fast-stringify');
13
14
  var classNames = require('classnames');
@@ -1031,12 +1032,16 @@ function registerRichDetails(loader) {
1031
1032
  }
1032
1033
 
1033
1034
  function useIsClient() {
1034
- var _a = React.useState(false), loaded = _a[0], setLoaded = _a[1];
1035
- React.useEffect(function () {
1035
+ var _a = React__default.default.useState(false), loaded = _a[0], setLoaded = _a[1];
1036
+ useIsomorphicLayoutEffect(function () {
1036
1037
  setLoaded(true);
1037
1038
  });
1038
1039
  return loaded;
1039
1040
  }
1041
+ var isBrowser = typeof window !== "undefined";
1042
+ var useIsomorphicLayoutEffect = isBrowser
1043
+ ? React__default.default.useLayoutEffect
1044
+ : React__default.default.useEffect;
1040
1045
  function capitalize(text) {
1041
1046
  return text.slice(0, 1).toUpperCase() + text.slice(1);
1042
1047
  }
@@ -1045,6 +1050,10 @@ function isLight(color) {
1045
1050
  return r * 0.299 + g * 0.587 + b * 0.114 > 186;
1046
1051
  }
1047
1052
 
1053
+ var AnchorLink = React__default.default.forwardRef(function AnchorLink(props, ref) {
1054
+ return React__default.default.createElement("a", __assign({}, props, { ref: ref }));
1055
+ });
1056
+
1048
1057
  function omitUndefined(x) {
1049
1058
  return Object.fromEntries(Object.entries(x).filter(function (_a) {
1050
1059
  _a[0]; var v = _a[1];
@@ -1061,15 +1070,17 @@ function filterNavMenuItemsByConditions(navMenuItems) {
1061
1070
  // width: 100% needed because parent is display: flex, which is needed for the min-height behavior.
1062
1071
  var baseStyles = "\n.ant-pro-layout-bg-list {\n display: none;\n}\n.ant-pro-layout {\n display: flex;\n width: 100%;\n}\n.ant-pro-layout .ant-pro-layout-content {\n padding: 0;\n}\n";
1063
1072
  function RichLayout(_a) {
1064
- var _b, _c, _d;
1065
- var children = _a.children, navMenuItems = _a.navMenuItems, _e = _a.rootUrl, rootUrl = _e === void 0 ? "/" : _e, actionsChildren = _a.actionsChildren, footerChildren = _a.footerChildren, avatarLabel = _a.avatarLabel, avatarImage = _a.avatarImage, showAvatarMenu = _a.showAvatarMenu, className = _a.className, simpleNavTheme = _a.simpleNavTheme, layoutProps = __rest(_a, ["children", "navMenuItems", "rootUrl", "actionsChildren", "footerChildren", "avatarLabel", "avatarImage", "showAvatarMenu", "className", "simpleNavTheme"]);
1073
+ var _b, _c, _d, _e;
1074
+ var children = _a.children, navMenuItems = _a.navMenuItems, _f = _a.rootUrl, rootUrl = _f === void 0 ? "/" : _f, actionsChildren = _a.actionsChildren, footerChildren = _a.footerChildren, avatarLabel = _a.avatarLabel, avatarImage = _a.avatarImage, showAvatarMenu = _a.showAvatarMenu, className = _a.className, simpleNavTheme = _a.simpleNavTheme, logo = _a.logo, logoElement = _a.logoElement, layoutProps = __rest(_a, ["children", "navMenuItems", "rootUrl", "actionsChildren", "footerChildren", "avatarLabel", "avatarImage", "showAvatarMenu", "className", "simpleNavTheme", "logo", "logoElement"]);
1066
1075
  var isClient = useIsClient();
1067
- var _f = React.useState(undefined), pathname = _f[0], setPathname = _f[1];
1076
+ var _g = React.useState(undefined), pathname = _g[0], setPathname = _g[1];
1068
1077
  React.useEffect(function () {
1069
1078
  if (typeof location !== "undefined") {
1070
1079
  setPathname(location.pathname);
1071
1080
  }
1072
1081
  }, []);
1082
+ // The usePlasmicLink function may be undefined, if host is not up to date
1083
+ var Link = (_b = host.usePlasmicLink === null || host.usePlasmicLink === void 0 ? void 0 : host.usePlasmicLink()) !== null && _b !== void 0 ? _b : AnchorLink;
1073
1084
  var token = antd.theme.useToken().token;
1074
1085
  var origTextColor = token.colorTextBase;
1075
1086
  function getNavBgColor() {
@@ -1125,7 +1136,7 @@ function RichLayout(_a) {
1125
1136
  };
1126
1137
  return (React__default.default.createElement("div", { className: className, style: { display: "flex" } },
1127
1138
  React__default.default.createElement("style", null, baseStyles),
1128
- React__default.default.createElement(proComponents.ProLayout, __assign({}, layoutProps, {
1139
+ React__default.default.createElement(proComponents.ProLayout, __assign({}, layoutProps, { logo: logo !== null && logo !== void 0 ? logo : logoElement,
1129
1140
  // Theme just the header. If you simply pass in navTheme=realDark, it affects all main content as well.
1130
1141
  //
1131
1142
  // What we're doing is telling Ant to use the dark mode algorithm. However, dark mode algorithm doesn't change
@@ -1152,11 +1163,11 @@ function RichLayout(_a) {
1152
1163
  sider: layoutColorOverrides,
1153
1164
  },
1154
1165
  // Tweak defaults. ProLayout is janky and has terrible docs!
1155
- layout: (_b = layoutProps.layout) !== null && _b !== void 0 ? _b : "top", fixedHeader: (_c = layoutProps.fixedHeader) !== null && _c !== void 0 ? _c : false, fixSiderbar:
1166
+ layout: (_c = layoutProps.layout) !== null && _c !== void 0 ? _c : "top", fixedHeader: (_d = layoutProps.fixedHeader) !== null && _d !== void 0 ? _d : false, fixSiderbar:
1156
1167
  // Doesn't stretch full height if you set this to false and you're in mix mode.
1157
1168
  layoutProps.layout === "mix"
1158
1169
  ? undefined
1159
- : (_d = layoutProps.fixSiderbar) !== null && _d !== void 0 ? _d : false,
1170
+ : (_e = layoutProps.fixSiderbar) !== null && _e !== void 0 ? _e : false,
1160
1171
  // This is always needed if you want layout mix to have effect and look any different from layout side - not clear why this should ever be false.
1161
1172
  splitMenus: layoutProps.layout === "mix", route: {
1162
1173
  path: rootUrl,
@@ -1192,8 +1203,8 @@ function RichLayout(_a) {
1192
1203
  if (props === null || props === void 0 ? void 0 : props.collapsed)
1193
1204
  return undefined;
1194
1205
  return footerChildren;
1195
- }, onMenuHeaderClick: function (e) { return console.log(e); }, menuItemRender: function (item, dom) { return React__default.default.createElement("a", { href: item.path }, dom); }, headerTitleRender: function (logo, title, _) {
1196
- return (React__default.default.createElement("a", { href: rootUrl },
1206
+ }, onMenuHeaderClick: function (e) { return console.log(e); }, menuItemRender: function (item, dom) { return React__default.default.createElement(Link, { href: item.path }, dom); }, headerTitleRender: function (logo, title, _) {
1207
+ return (React__default.default.createElement(Link, { href: rootUrl },
1197
1208
  logo,
1198
1209
  title));
1199
1210
  } }), children)));
@@ -1242,7 +1253,16 @@ var richLayoutMeta = {
1242
1253
  logo: {
1243
1254
  displayName: "Logo",
1244
1255
  type: "imageUrl",
1245
- defaultValue: "https://www.plasmic.app/favicon.ico",
1256
+ hidden: function (ps) { return !ps.logo; },
1257
+ },
1258
+ logoElement: {
1259
+ type: "slot",
1260
+ displayName: "Logo",
1261
+ defaultValue: {
1262
+ type: "img",
1263
+ src: "https://static1.plasmic.app/fake-logo.svg",
1264
+ },
1265
+ hidden: function (ps) { return !!ps.logo; },
1246
1266
  },
1247
1267
  navMenuItems: generateNavMenuType(false, 2, "Nav menu items", [
1248
1268
  {