@plasmicpkgs/plasmic-rich-components 1.0.93 → 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 +2 -0
- package/dist/index.js +31 -11
- package/dist/index.js.map +1 -1
- package/dist/plasmic-rich-components.esm.js +31 -11
- package/dist/plasmic-rich-components.esm.js.map +1 -1
- package/dist/rich-layout/RichLayout.d.ts +2 -1
- package/dist/widgets.d.ts +2 -0
- package/package.json +4 -4
|
@@ -6,6 +6,7 @@ import { Checkbox, Switch, Empty, Descriptions, theme, ConfigProvider, Dropdown,
|
|
|
6
6
|
import { tinycolor } from '@ctrl/tinycolor';
|
|
7
7
|
import { LogoutOutlined, PlusOutlined, EllipsisOutlined } from '@ant-design/icons';
|
|
8
8
|
import { ProLayout, ProConfigProvider, ProTable } from '@ant-design/pro-components';
|
|
9
|
+
import { usePlasmicLink } from '@plasmicapp/host';
|
|
9
10
|
import { createObjectCsvStringifier } from 'csv-writer-browser';
|
|
10
11
|
import fastStringify from 'fast-stringify';
|
|
11
12
|
import classNames from 'classnames';
|
|
@@ -1021,12 +1022,16 @@ function registerRichDetails(loader) {
|
|
|
1021
1022
|
}
|
|
1022
1023
|
|
|
1023
1024
|
function useIsClient() {
|
|
1024
|
-
var _a = useState(false), loaded = _a[0], setLoaded = _a[1];
|
|
1025
|
-
|
|
1025
|
+
var _a = React.useState(false), loaded = _a[0], setLoaded = _a[1];
|
|
1026
|
+
useIsomorphicLayoutEffect(function () {
|
|
1026
1027
|
setLoaded(true);
|
|
1027
1028
|
});
|
|
1028
1029
|
return loaded;
|
|
1029
1030
|
}
|
|
1031
|
+
var isBrowser = typeof window !== "undefined";
|
|
1032
|
+
var useIsomorphicLayoutEffect = isBrowser
|
|
1033
|
+
? React.useLayoutEffect
|
|
1034
|
+
: React.useEffect;
|
|
1030
1035
|
function capitalize(text) {
|
|
1031
1036
|
return text.slice(0, 1).toUpperCase() + text.slice(1);
|
|
1032
1037
|
}
|
|
@@ -1035,6 +1040,10 @@ function isLight(color) {
|
|
|
1035
1040
|
return r * 0.299 + g * 0.587 + b * 0.114 > 186;
|
|
1036
1041
|
}
|
|
1037
1042
|
|
|
1043
|
+
var AnchorLink = React.forwardRef(function AnchorLink(props, ref) {
|
|
1044
|
+
return React.createElement("a", __assign({}, props, { ref: ref }));
|
|
1045
|
+
});
|
|
1046
|
+
|
|
1038
1047
|
function omitUndefined(x) {
|
|
1039
1048
|
return Object.fromEntries(Object.entries(x).filter(function (_a) {
|
|
1040
1049
|
_a[0]; var v = _a[1];
|
|
@@ -1051,15 +1060,17 @@ function filterNavMenuItemsByConditions(navMenuItems) {
|
|
|
1051
1060
|
// width: 100% needed because parent is display: flex, which is needed for the min-height behavior.
|
|
1052
1061
|
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";
|
|
1053
1062
|
function RichLayout(_a) {
|
|
1054
|
-
var _b, _c, _d;
|
|
1055
|
-
var children = _a.children, navMenuItems = _a.navMenuItems,
|
|
1063
|
+
var _b, _c, _d, _e;
|
|
1064
|
+
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"]);
|
|
1056
1065
|
var isClient = useIsClient();
|
|
1057
|
-
var
|
|
1066
|
+
var _g = useState(undefined), pathname = _g[0], setPathname = _g[1];
|
|
1058
1067
|
useEffect(function () {
|
|
1059
1068
|
if (typeof location !== "undefined") {
|
|
1060
1069
|
setPathname(location.pathname);
|
|
1061
1070
|
}
|
|
1062
1071
|
}, []);
|
|
1072
|
+
// The usePlasmicLink function may be undefined, if host is not up to date
|
|
1073
|
+
var Link = (_b = usePlasmicLink === null || usePlasmicLink === void 0 ? void 0 : usePlasmicLink()) !== null && _b !== void 0 ? _b : AnchorLink;
|
|
1063
1074
|
var token = theme.useToken().token;
|
|
1064
1075
|
var origTextColor = token.colorTextBase;
|
|
1065
1076
|
function getNavBgColor() {
|
|
@@ -1115,7 +1126,7 @@ function RichLayout(_a) {
|
|
|
1115
1126
|
};
|
|
1116
1127
|
return (React.createElement("div", { className: className, style: { display: "flex" } },
|
|
1117
1128
|
React.createElement("style", null, baseStyles),
|
|
1118
|
-
React.createElement(ProLayout, __assign({}, layoutProps, {
|
|
1129
|
+
React.createElement(ProLayout, __assign({}, layoutProps, { logo: logo !== null && logo !== void 0 ? logo : logoElement,
|
|
1119
1130
|
// Theme just the header. If you simply pass in navTheme=realDark, it affects all main content as well.
|
|
1120
1131
|
//
|
|
1121
1132
|
// What we're doing is telling Ant to use the dark mode algorithm. However, dark mode algorithm doesn't change
|
|
@@ -1142,11 +1153,11 @@ function RichLayout(_a) {
|
|
|
1142
1153
|
sider: layoutColorOverrides,
|
|
1143
1154
|
},
|
|
1144
1155
|
// Tweak defaults. ProLayout is janky and has terrible docs!
|
|
1145
|
-
layout: (
|
|
1156
|
+
layout: (_c = layoutProps.layout) !== null && _c !== void 0 ? _c : "top", fixedHeader: (_d = layoutProps.fixedHeader) !== null && _d !== void 0 ? _d : false, fixSiderbar:
|
|
1146
1157
|
// Doesn't stretch full height if you set this to false and you're in mix mode.
|
|
1147
1158
|
layoutProps.layout === "mix"
|
|
1148
1159
|
? undefined
|
|
1149
|
-
: (
|
|
1160
|
+
: (_e = layoutProps.fixSiderbar) !== null && _e !== void 0 ? _e : false,
|
|
1150
1161
|
// 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.
|
|
1151
1162
|
splitMenus: layoutProps.layout === "mix", route: {
|
|
1152
1163
|
path: rootUrl,
|
|
@@ -1182,8 +1193,8 @@ function RichLayout(_a) {
|
|
|
1182
1193
|
if (props === null || props === void 0 ? void 0 : props.collapsed)
|
|
1183
1194
|
return undefined;
|
|
1184
1195
|
return footerChildren;
|
|
1185
|
-
}, onMenuHeaderClick: function (e) { return console.log(e); }, menuItemRender: function (item, dom) { return React.createElement(
|
|
1186
|
-
return (React.createElement(
|
|
1196
|
+
}, onMenuHeaderClick: function (e) { return console.log(e); }, menuItemRender: function (item, dom) { return React.createElement(Link, { href: item.path }, dom); }, headerTitleRender: function (logo, title, _) {
|
|
1197
|
+
return (React.createElement(Link, { href: rootUrl },
|
|
1187
1198
|
logo,
|
|
1188
1199
|
title));
|
|
1189
1200
|
} }), children)));
|
|
@@ -1232,7 +1243,16 @@ var richLayoutMeta = {
|
|
|
1232
1243
|
logo: {
|
|
1233
1244
|
displayName: "Logo",
|
|
1234
1245
|
type: "imageUrl",
|
|
1235
|
-
|
|
1246
|
+
hidden: function (ps) { return !ps.logo; },
|
|
1247
|
+
},
|
|
1248
|
+
logoElement: {
|
|
1249
|
+
type: "slot",
|
|
1250
|
+
displayName: "Logo",
|
|
1251
|
+
defaultValue: {
|
|
1252
|
+
type: "img",
|
|
1253
|
+
src: "https://static1.plasmic.app/fake-logo.svg",
|
|
1254
|
+
},
|
|
1255
|
+
hidden: function (ps) { return !!ps.logo; },
|
|
1236
1256
|
},
|
|
1237
1257
|
navMenuItems: generateNavMenuType(false, 2, "Nav menu items", [
|
|
1238
1258
|
{
|