@plasmicpkgs/plasmic-rich-components 1.0.77 → 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.
@@ -1,9 +1,11 @@
1
1
  import registerComponent from '@plasmicapp/host/registerComponent';
2
2
  import '@plasmicapp/host/registerGlobalContext';
3
- import { ProDescriptions, ProLayout, ProTable, TableDropdown } from '@ant-design/pro-components';
4
- import React, { useState, useEffect, useRef } from 'react';
5
- import { Checkbox, Switch, Empty, Dropdown, Button } from 'antd';
3
+ import { ProDescriptions, ProLayout, ProConfigProvider, ProTable, TableDropdown } from '@ant-design/pro-components';
4
+ import React, { useState, useEffect, useContext, useRef } from 'react';
5
+ import { Checkbox, Switch, Empty, theme, Dropdown, Button } from 'antd';
6
6
  import { LogoutOutlined, PlusOutlined, EllipsisOutlined } from '@ant-design/icons';
7
+ import { omitUndefined } from '@ant-design/pro-utils/lib';
8
+ import { ConfigContext } from 'antd/es/config-provider';
7
9
  import { createObjectCsvStringifier } from 'csv-writer-browser';
8
10
  import fastStringify from 'fast-stringify';
9
11
 
@@ -941,9 +943,12 @@ function capitalize(text) {
941
943
  return text.slice(0, 1).toUpperCase() + text.slice(1);
942
944
  }
943
945
 
946
+ function ensureArray(xs) {
947
+ return Array.isArray(xs) ? xs : [xs];
948
+ }
944
949
  function RichLayout(_a) {
945
950
  var _b, _c, _d;
946
- 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"]);
951
+ 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"]);
947
952
  var isClient = useIsClient();
948
953
  var _f = useState(undefined), pathname = _f[0], setPathname = _f[1];
949
954
  useEffect(function () {
@@ -951,12 +956,58 @@ function RichLayout(_a) {
951
956
  setPathname(location.pathname);
952
957
  }
953
958
  }, []);
959
+ var _g = useContext(ConfigContext); _g.locale; var th = _g.theme; __rest(_g, ["locale", "theme"]);
960
+ var token = theme.useToken().token;
961
+ var inDarkMode = ensureArray(th === null || th === void 0 ? void 0 : th.algorithm).includes(theme.darkAlgorithm);
962
+ var bgColor = (simpleNavTheme === null || simpleNavTheme === void 0 ? void 0 : simpleNavTheme.scheme) === "accent"
963
+ ? token.colorPrimary
964
+ : (simpleNavTheme === null || simpleNavTheme === void 0 ? void 0 : simpleNavTheme.scheme) === "dark"
965
+ ? // This is the default dark Menu color in Ant.
966
+ "#011528"
967
+ : inDarkMode
968
+ ? // Just use this sorta ugly gray if using 'light' scheme in 'dark' mode....
969
+ "rgba(0,0,0,0.6)"
970
+ : // Using 'light' scheme in 'light' mode
971
+ undefined;
954
972
  if (!isClient) {
955
973
  return null;
956
974
  }
957
975
  return (React.createElement("div", { className: className },
958
976
  React.createElement("style", null, ".ant-pro-layout-bg-list {\n display: none;\n }"),
959
977
  React.createElement(ProLayout, __assign({}, layoutProps, {
978
+ // Theme just the header. If you simply pass in navTheme=realDark, it affects all main content as well.
979
+ headerRender: function (props, defaultDom) { return (React.createElement(ProConfigProvider, { dark: (simpleNavTheme === null || simpleNavTheme === void 0 ? void 0 : simpleNavTheme.scheme) !== "light" }, defaultDom)); }, token: {
980
+ header: omitUndefined({
981
+ colorBgHeader: bgColor,
982
+ }),
983
+ // Ideally, we'd do something similar to headerRender above, and just specify general dark mode to specify
984
+ // whether all components/text should be light.
985
+ // But for some reason it doesn't work, causing the bg color to be ignored (just the default dark Menu color),
986
+ // *and* the text is just dark as well.
987
+ // Haven't bothered debugging the pro components code to figure out the proper way to do this, so just
988
+ // bluntly specifying tokens here.
989
+ sider: !inDarkMode && (simpleNavTheme === null || simpleNavTheme === void 0 ? void 0 : simpleNavTheme.scheme) === "light"
990
+ ? undefined
991
+ : {
992
+ colorBgCollapsedButton: "#fff",
993
+ colorTextCollapsedButtonHover: "rgba(0,0,0,0.65)",
994
+ colorTextCollapsedButton: "rgba(0,0,0,0.45)",
995
+ colorMenuBackground: bgColor,
996
+ colorBgMenuItemCollapsedHover: "rgba(0,0,0,0.06)",
997
+ colorBgMenuItemCollapsedSelected: "rgba(0,0,0,0.15)",
998
+ colorBgMenuItemCollapsedElevated: "rgba(0,0,0,0.85)",
999
+ colorMenuItemDivider: "rgba(255,255,255,0.15)",
1000
+ colorBgMenuItemHover: "rgba(0,0,0,0.06)",
1001
+ colorBgMenuItemSelected: "rgba(0,0,0,0.15)",
1002
+ colorTextMenuSelected: "#fff",
1003
+ colorTextMenuItemHover: "rgba(255,255,255,0.75)",
1004
+ colorTextMenu: "rgba(255,255,255,0.75)",
1005
+ colorTextMenuSecondary: "rgba(255,255,255,0.65)",
1006
+ colorTextMenuTitle: "rgba(255,255,255,0.95)",
1007
+ colorTextMenuActive: "rgba(255,255,255,0.95)",
1008
+ colorTextSubMenuSelected: "#fff",
1009
+ },
1010
+ },
960
1011
  // Tweak defaults. ProLayout is janky and has terrible docs!
961
1012
  layout: (_b = layoutProps.layout) !== null && _b !== void 0 ? _b : "top", fixedHeader: (_c = layoutProps.fixedHeader) !== null && _c !== void 0 ? _c : false, fixSiderbar:
962
1013
  // Doesn't stretch full height if you set this to false and you're in mix mode.
@@ -973,7 +1024,7 @@ function RichLayout(_a) {
973
1024
  // collapsedShowGroupTitle: true,
974
1025
  defaultOpenAll: true,
975
1026
  // hideMenuWhenCollapsed: true,
976
- }, avatarProps: showAvatarMenu && false
1027
+ }, avatarProps: showAvatarMenu && 0 / 1
977
1028
  ? {
978
1029
  src: avatarImage,
979
1030
  size: "small",
@@ -1062,6 +1113,21 @@ var richLayoutMeta = {
1062
1113
  }); }),
1063
1114
  defaultValueHint: "top",
1064
1115
  },
1116
+ simpleNavTheme: {
1117
+ displayName: "Theme",
1118
+ advanced: true,
1119
+ type: "object",
1120
+ fields: {
1121
+ scheme: {
1122
+ type: "choice",
1123
+ options: ["light", "accent", "dark"].map(function (v) { return ({
1124
+ label: capitalize(v),
1125
+ value: v,
1126
+ }); }),
1127
+ defaultValue: "accent",
1128
+ },
1129
+ },
1130
+ },
1065
1131
  // Advanced, show later
1066
1132
  /*
1067
1133
  siderMenuType: {
@@ -1079,18 +1145,6 @@ var richLayoutMeta = {
1079
1145
  options: ["Fluid", "Fixed"],
1080
1146
  defaultValueHint: "Fluid",
1081
1147
  },
1082
- navTheme: {
1083
- displayName: "Theme",
1084
- type: "choice",
1085
- options: [
1086
- { value: "realDark", label: "Dark" },
1087
- { value: "light", label: "Light" },
1088
- ],
1089
- },
1090
- colorPrimary: {
1091
- displayName: "Primary color",
1092
- type: "color",
1093
- },
1094
1148
  */
1095
1149
  fixedHeader: {
1096
1150
  displayName: "Sticky header",