@plasmicpkgs/plasmic-rich-components 1.0.76 → 1.0.78

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 CHANGED
@@ -6,6 +6,8 @@ var proComponents = require('@ant-design/pro-components');
6
6
  var React = require('react');
7
7
  var antd = require('antd');
8
8
  var icons = require('@ant-design/icons');
9
+ var lib = require('@ant-design/pro-utils/lib');
10
+ var configProvider = require('antd/es/config-provider');
9
11
  var csvWriterBrowser = require('csv-writer-browser');
10
12
  var fastStringify = require('fast-stringify');
11
13
 
@@ -949,9 +951,12 @@ function capitalize(text) {
949
951
  return text.slice(0, 1).toUpperCase() + text.slice(1);
950
952
  }
951
953
 
954
+ function ensureArray(xs) {
955
+ return Array.isArray(xs) ? xs : [xs];
956
+ }
952
957
  function RichLayout(_a) {
953
958
  var _b, _c, _d;
954
- 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, layoutProps = __rest(_a, ["children", "navMenuItems", "rootUrl", "actionsChildren", "footerChildren", "avatarLabel", "avatarImage", "showAvatarMenu", "className"]);
959
+ 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"]);
955
960
  var isClient = useIsClient();
956
961
  var _f = React.useState(undefined), pathname = _f[0], setPathname = _f[1];
957
962
  React.useEffect(function () {
@@ -959,12 +964,58 @@ function RichLayout(_a) {
959
964
  setPathname(location.pathname);
960
965
  }
961
966
  }, []);
967
+ var _g = React.useContext(configProvider.ConfigContext); _g.locale; var th = _g.theme; __rest(_g, ["locale", "theme"]);
968
+ var token = antd.theme.useToken().token;
969
+ var inDarkMode = ensureArray(th === null || th === void 0 ? void 0 : th.algorithm).includes(antd.theme.darkAlgorithm);
970
+ var bgColor = (simpleNavTheme === null || simpleNavTheme === void 0 ? void 0 : simpleNavTheme.scheme) === "accent"
971
+ ? token.colorPrimary
972
+ : (simpleNavTheme === null || simpleNavTheme === void 0 ? void 0 : simpleNavTheme.scheme) === "dark"
973
+ ? // This is the default dark Menu color in Ant.
974
+ "#011528"
975
+ : inDarkMode
976
+ ? // Just use this sorta ugly gray if using 'light' scheme in 'dark' mode....
977
+ "rgba(0,0,0,0.6)"
978
+ : // Using 'light' scheme in 'light' mode
979
+ undefined;
962
980
  if (!isClient) {
963
981
  return null;
964
982
  }
965
983
  return (React__default.default.createElement("div", { className: className },
966
984
  React__default.default.createElement("style", null, ".ant-pro-layout-bg-list {\n display: none;\n }"),
967
985
  React__default.default.createElement(proComponents.ProLayout, __assign({}, layoutProps, {
986
+ // Theme just the header. If you simply pass in navTheme=realDark, it affects all main content as well.
987
+ headerRender: function (props, defaultDom) { return (React__default.default.createElement(proComponents.ProConfigProvider, { dark: (simpleNavTheme === null || simpleNavTheme === void 0 ? void 0 : simpleNavTheme.scheme) !== "light" }, defaultDom)); }, token: {
988
+ header: lib.omitUndefined({
989
+ colorBgHeader: bgColor,
990
+ }),
991
+ // Ideally, we'd do something similar to headerRender above, and just specify general dark mode to specify
992
+ // whether all components/text should be light.
993
+ // But for some reason it doesn't work, causing the bg color to be ignored (just the default dark Menu color),
994
+ // *and* the text is just dark as well.
995
+ // Haven't bothered debugging the pro components code to figure out the proper way to do this, so just
996
+ // bluntly specifying tokens here.
997
+ sider: !inDarkMode && (simpleNavTheme === null || simpleNavTheme === void 0 ? void 0 : simpleNavTheme.scheme) === "light"
998
+ ? undefined
999
+ : {
1000
+ colorBgCollapsedButton: "#fff",
1001
+ colorTextCollapsedButtonHover: "rgba(0,0,0,0.65)",
1002
+ colorTextCollapsedButton: "rgba(0,0,0,0.45)",
1003
+ colorMenuBackground: bgColor,
1004
+ colorBgMenuItemCollapsedHover: "rgba(0,0,0,0.06)",
1005
+ colorBgMenuItemCollapsedSelected: "rgba(0,0,0,0.15)",
1006
+ colorBgMenuItemCollapsedElevated: "rgba(0,0,0,0.85)",
1007
+ colorMenuItemDivider: "rgba(255,255,255,0.15)",
1008
+ colorBgMenuItemHover: "rgba(0,0,0,0.06)",
1009
+ colorBgMenuItemSelected: "rgba(0,0,0,0.15)",
1010
+ colorTextMenuSelected: "#fff",
1011
+ colorTextMenuItemHover: "rgba(255,255,255,0.75)",
1012
+ colorTextMenu: "rgba(255,255,255,0.75)",
1013
+ colorTextMenuSecondary: "rgba(255,255,255,0.65)",
1014
+ colorTextMenuTitle: "rgba(255,255,255,0.95)",
1015
+ colorTextMenuActive: "rgba(255,255,255,0.95)",
1016
+ colorTextSubMenuSelected: "#fff",
1017
+ },
1018
+ },
968
1019
  // Tweak defaults. ProLayout is janky and has terrible docs!
969
1020
  layout: (_b = layoutProps.layout) !== null && _b !== void 0 ? _b : "top", fixedHeader: (_c = layoutProps.fixedHeader) !== null && _c !== void 0 ? _c : false, fixSiderbar:
970
1021
  // Doesn't stretch full height if you set this to false and you're in mix mode.
@@ -981,7 +1032,7 @@ function RichLayout(_a) {
981
1032
  // collapsedShowGroupTitle: true,
982
1033
  defaultOpenAll: true,
983
1034
  // hideMenuWhenCollapsed: true,
984
- }, avatarProps: showAvatarMenu && false
1035
+ }, avatarProps: showAvatarMenu && 0 / 1
985
1036
  ? {
986
1037
  src: avatarImage,
987
1038
  size: "small",
@@ -1070,6 +1121,21 @@ var richLayoutMeta = {
1070
1121
  }); }),
1071
1122
  defaultValueHint: "top",
1072
1123
  },
1124
+ simpleNavTheme: {
1125
+ displayName: "Theme",
1126
+ advanced: true,
1127
+ type: "object",
1128
+ fields: {
1129
+ scheme: {
1130
+ type: "choice",
1131
+ options: ["light", "accent", "dark"].map(function (v) { return ({
1132
+ label: capitalize(v),
1133
+ value: v,
1134
+ }); }),
1135
+ defaultValue: "accent",
1136
+ },
1137
+ },
1138
+ },
1073
1139
  // Advanced, show later
1074
1140
  /*
1075
1141
  siderMenuType: {
@@ -1087,18 +1153,6 @@ var richLayoutMeta = {
1087
1153
  options: ["Fluid", "Fixed"],
1088
1154
  defaultValueHint: "Fluid",
1089
1155
  },
1090
- navTheme: {
1091
- displayName: "Theme",
1092
- type: "choice",
1093
- options: [
1094
- { value: "realDark", label: "Dark" },
1095
- { value: "light", label: "Light" },
1096
- ],
1097
- },
1098
- colorPrimary: {
1099
- displayName: "Primary color",
1100
- type: "color",
1101
- },
1102
1156
  */
1103
1157
  fixedHeader: {
1104
1158
  displayName: "Sticky header",