@plasmicpkgs/plasmic-rich-components 1.0.78 → 1.0.79

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,11 +1,9 @@
1
1
  import registerComponent from '@plasmicapp/host/registerComponent';
2
2
  import '@plasmicapp/host/registerGlobalContext';
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';
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';
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';
9
7
  import { createObjectCsvStringifier } from 'csv-writer-browser';
10
8
  import fastStringify from 'fast-stringify';
11
9
 
@@ -201,10 +199,11 @@ function buildFieldsPropType(opts) {
201
199
  displayName: displayName,
202
200
  control: control,
203
201
  argNames: ["currentItem", "currentValue"],
204
- argValues: function (_props, ctx) {
205
- var _a;
206
- var row = (_a = ctx === null || ctx === void 0 ? void 0 : ctx.data) === null || _a === void 0 ? void 0 : _a[0];
207
- var cell = _props.fieldId ? row === null || row === void 0 ? void 0 : row[_props.fieldId] : undefined;
202
+ argValues: function (_props, ctx, _a) {
203
+ var _b;
204
+ var item = _a.item;
205
+ var row = (_b = ctx === null || ctx === void 0 ? void 0 : ctx.data) === null || _b === void 0 ? void 0 : _b[0];
206
+ var cell = item.fieldId ? row === null || row === void 0 ? void 0 : row[item.fieldId] : undefined;
208
207
  return [row, cell];
209
208
  },
210
209
  });
@@ -251,7 +250,7 @@ function buildFieldsPropType(opts) {
251
250
  type: "string",
252
251
  displayName: "Title",
253
252
  defaultValueHint: getDefaultValueHint("title"),
254
- }, expr: rowDataType("Customize data"), isHidden: {
253
+ }, expr: rowDataType("Customize cell data"), isHidden: {
255
254
  type: "boolean",
256
255
  displayName: "Is hidden",
257
256
  defaultValueHint: getDefaultValueHint("isHidden"),
@@ -865,7 +864,10 @@ function useColumnDefinitions$1(data, props) {
865
864
  return defaultRender(_);
866
865
  },
867
866
  render: function (value, record, rowIndex) {
868
- return renderValue(value, record, cconfig);
867
+ var cellValue = cconfig.fieldId
868
+ ? record[cconfig.fieldId]
869
+ : undefined;
870
+ return renderValue(cellValue, record, cconfig);
869
871
  },
870
872
  };
871
873
  return columnDefinition;
@@ -943,12 +945,9 @@ function capitalize(text) {
943
945
  return text.slice(0, 1).toUpperCase() + text.slice(1);
944
946
  }
945
947
 
946
- function ensureArray(xs) {
947
- return Array.isArray(xs) ? xs : [xs];
948
- }
949
948
  function RichLayout(_a) {
950
949
  var _b, _c, _d;
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"]);
950
+ 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"]);
952
951
  var isClient = useIsClient();
953
952
  var _f = useState(undefined), pathname = _f[0], setPathname = _f[1];
954
953
  useEffect(function () {
@@ -956,58 +955,12 @@ function RichLayout(_a) {
956
955
  setPathname(location.pathname);
957
956
  }
958
957
  }, []);
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;
972
958
  if (!isClient) {
973
959
  return null;
974
960
  }
975
961
  return (React.createElement("div", { className: className },
976
962
  React.createElement("style", null, ".ant-pro-layout-bg-list {\n display: none;\n }"),
977
963
  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
- },
1011
964
  // Tweak defaults. ProLayout is janky and has terrible docs!
1012
965
  layout: (_b = layoutProps.layout) !== null && _b !== void 0 ? _b : "top", fixedHeader: (_c = layoutProps.fixedHeader) !== null && _c !== void 0 ? _c : false, fixSiderbar:
1013
966
  // Doesn't stretch full height if you set this to false and you're in mix mode.
@@ -1024,7 +977,7 @@ function RichLayout(_a) {
1024
977
  // collapsedShowGroupTitle: true,
1025
978
  defaultOpenAll: true,
1026
979
  // hideMenuWhenCollapsed: true,
1027
- }, avatarProps: showAvatarMenu && 0 / 1
980
+ }, avatarProps: showAvatarMenu && false
1028
981
  ? {
1029
982
  src: avatarImage,
1030
983
  size: "small",
@@ -1064,7 +1017,7 @@ function generateNavMenuType(remainingDepth, displayName, defaultValue) {
1064
1017
  nameFunc: function (item) {
1065
1018
  return item.name || (!displayName ? "Unnamed nested item" : "Unnamed item");
1066
1019
  },
1067
- fields: __assign({ path: "string", name: "string" }, (remainingDepth === 0
1020
+ fields: __assign({ path: "href", name: "string" }, (remainingDepth === 0
1068
1021
  ? {}
1069
1022
  : {
1070
1023
  routes: generateNavMenuType(remainingDepth - 1),
@@ -1113,21 +1066,6 @@ var richLayoutMeta = {
1113
1066
  }); }),
1114
1067
  defaultValueHint: "top",
1115
1068
  },
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
- },
1131
1069
  // Advanced, show later
1132
1070
  /*
1133
1071
  siderMenuType: {
@@ -1145,6 +1083,18 @@ var richLayoutMeta = {
1145
1083
  options: ["Fluid", "Fixed"],
1146
1084
  defaultValueHint: "Fluid",
1147
1085
  },
1086
+ navTheme: {
1087
+ displayName: "Theme",
1088
+ type: "choice",
1089
+ options: [
1090
+ { value: "realDark", label: "Dark" },
1091
+ { value: "light", label: "Light" },
1092
+ ],
1093
+ },
1094
+ colorPrimary: {
1095
+ displayName: "Primary color",
1096
+ type: "color",
1097
+ },
1148
1098
  */
1149
1099
  fixedHeader: {
1150
1100
  displayName: "Sticky header",
@@ -1352,7 +1302,10 @@ function useColumnDefinitions(data, props) {
1352
1302
  return defaultRender(_);
1353
1303
  },
1354
1304
  render: function (value, record, rowIndex) {
1355
- return renderValue(value, record, cconfig);
1305
+ var cellValue = cconfig.fieldId
1306
+ ? record[cconfig.fieldId]
1307
+ : undefined;
1308
+ return renderValue(cellValue, record, cconfig);
1356
1309
  },
1357
1310
  };
1358
1311
  return columnDefinition;