@plasmicpkgs/plasmic-rich-components 1.0.91 → 1.0.93
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
|
@@ -1051,8 +1051,15 @@ function omitUndefined(x) {
|
|
|
1051
1051
|
return v !== undefined;
|
|
1052
1052
|
}));
|
|
1053
1053
|
}
|
|
1054
|
+
function filterNavMenuItemsByConditions(navMenuItems) {
|
|
1055
|
+
return navMenuItems
|
|
1056
|
+
.filter(function (item) { return item.condition === undefined || item.condition; })
|
|
1057
|
+
.map(function (item) { return (__assign(__assign({}, item), { routes: item.routes
|
|
1058
|
+
? filterNavMenuItemsByConditions(item.routes)
|
|
1059
|
+
: undefined })); });
|
|
1060
|
+
}
|
|
1054
1061
|
// width: 100% needed because parent is display: flex, which is needed for the min-height behavior.
|
|
1055
|
-
var baseStyles = "\n.ant-pro-layout-bg-list {\n display: none;\n}\n.ant-pro-layout {\n display: flex;\n width: 100%;\n}\n";
|
|
1062
|
+
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";
|
|
1056
1063
|
function RichLayout(_a) {
|
|
1057
1064
|
var _b, _c, _d;
|
|
1058
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"]);
|
|
@@ -1095,6 +1102,27 @@ function RichLayout(_a) {
|
|
|
1095
1102
|
if (!isClient) {
|
|
1096
1103
|
return null;
|
|
1097
1104
|
}
|
|
1105
|
+
var layoutColorOverrides = isNavBgLight
|
|
1106
|
+
? undefined
|
|
1107
|
+
: {
|
|
1108
|
+
colorBgCollapsedButton: navBgColor,
|
|
1109
|
+
colorTextCollapsedButtonHover: "rgba(255,255,255,0.85)",
|
|
1110
|
+
colorTextCollapsedButton: "rgba(255,255,255,0.65)",
|
|
1111
|
+
colorMenuBackground: navBgColor,
|
|
1112
|
+
colorBgMenuItemCollapsedHover: "rgba(0,0,0,0.06)",
|
|
1113
|
+
colorBgMenuItemCollapsedSelected: "rgba(0,0,0,0.15)",
|
|
1114
|
+
colorBgMenuItemCollapsedElevated: "rgba(0,0,0,0.85)",
|
|
1115
|
+
colorMenuItemDivider: "rgba(255,255,255,0.15)",
|
|
1116
|
+
colorBgMenuItemHover: "rgba(0,0,0,0.06)",
|
|
1117
|
+
colorBgMenuItemSelected: "rgba(0,0,0,0.15)",
|
|
1118
|
+
colorTextMenuSelected: "#fff",
|
|
1119
|
+
colorTextMenuItemHover: "rgba(255,255,255,0.75)",
|
|
1120
|
+
colorTextMenu: "rgba(255,255,255,0.75)",
|
|
1121
|
+
colorTextMenuSecondary: "rgba(255,255,255,0.65)",
|
|
1122
|
+
colorTextMenuTitle: "rgba(255,255,255,0.95)",
|
|
1123
|
+
colorTextMenuActive: "rgba(255,255,255,0.95)",
|
|
1124
|
+
colorTextSubMenuSelected: "#fff",
|
|
1125
|
+
};
|
|
1098
1126
|
return (React__default.default.createElement("div", { className: className, style: { display: "flex" } },
|
|
1099
1127
|
React__default.default.createElement("style", null, baseStyles),
|
|
1100
1128
|
React__default.default.createElement(proComponents.ProLayout, __assign({}, layoutProps, {
|
|
@@ -1114,36 +1142,14 @@ function RichLayout(_a) {
|
|
|
1114
1142
|
// ProConfigProvider does first read/inherit the theme/tokens from the surrounding ConfigProvider.
|
|
1115
1143
|
headerRender: function (_props, defaultDom) { return (React__default.default.createElement(antd.ConfigProvider, { theme: { token: omitUndefined({ colorTextBase: navTextColor }) } },
|
|
1116
1144
|
React__default.default.createElement(proComponents.ProConfigProvider, { dark: !isNavBgLight }, defaultDom))); }, token: {
|
|
1117
|
-
header: omitUndefined({
|
|
1118
|
-
colorBgHeader: navBgColor,
|
|
1119
|
-
}),
|
|
1145
|
+
header: omitUndefined(__assign({ colorBgHeader: navBgColor }, layoutColorOverrides)),
|
|
1120
1146
|
// Ideally, we'd do something similar to headerRender above, and just specify general dark mode to specify
|
|
1121
1147
|
// whether all components/text should be light.
|
|
1122
1148
|
// But for some reason it doesn't work, causing the bg color to be ignored (just the default dark Menu color),
|
|
1123
1149
|
// *and* the text is just dark as well.
|
|
1124
1150
|
// Haven't yet been able to unravel the pro components code to figure out the proper way to do this, so just
|
|
1125
1151
|
// bluntly specifying tokens here, as recommended in some GitHub issue.
|
|
1126
|
-
sider:
|
|
1127
|
-
? undefined
|
|
1128
|
-
: {
|
|
1129
|
-
colorBgCollapsedButton: navBgColor,
|
|
1130
|
-
colorTextCollapsedButtonHover: "rgba(255,255,255,0.85)",
|
|
1131
|
-
colorTextCollapsedButton: "rgba(255,255,255,0.65)",
|
|
1132
|
-
colorMenuBackground: navBgColor,
|
|
1133
|
-
colorBgMenuItemCollapsedHover: "rgba(0,0,0,0.06)",
|
|
1134
|
-
colorBgMenuItemCollapsedSelected: "rgba(0,0,0,0.15)",
|
|
1135
|
-
colorBgMenuItemCollapsedElevated: "rgba(0,0,0,0.85)",
|
|
1136
|
-
colorMenuItemDivider: "rgba(255,255,255,0.15)",
|
|
1137
|
-
colorBgMenuItemHover: "rgba(0,0,0,0.06)",
|
|
1138
|
-
colorBgMenuItemSelected: "rgba(0,0,0,0.15)",
|
|
1139
|
-
colorTextMenuSelected: "#fff",
|
|
1140
|
-
colorTextMenuItemHover: "rgba(255,255,255,0.75)",
|
|
1141
|
-
colorTextMenu: "rgba(255,255,255,0.75)",
|
|
1142
|
-
colorTextMenuSecondary: "rgba(255,255,255,0.65)",
|
|
1143
|
-
colorTextMenuTitle: "rgba(255,255,255,0.95)",
|
|
1144
|
-
colorTextMenuActive: "rgba(255,255,255,0.95)",
|
|
1145
|
-
colorTextSubMenuSelected: "#fff",
|
|
1146
|
-
},
|
|
1152
|
+
sider: layoutColorOverrides,
|
|
1147
1153
|
},
|
|
1148
1154
|
// Tweak defaults. ProLayout is janky and has terrible docs!
|
|
1149
1155
|
layout: (_b = layoutProps.layout) !== null && _b !== void 0 ? _b : "top", fixedHeader: (_c = layoutProps.fixedHeader) !== null && _c !== void 0 ? _c : false, fixSiderbar:
|
|
@@ -1154,7 +1160,9 @@ function RichLayout(_a) {
|
|
|
1154
1160
|
// 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.
|
|
1155
1161
|
splitMenus: layoutProps.layout === "mix", route: {
|
|
1156
1162
|
path: rootUrl,
|
|
1157
|
-
routes: navMenuItems
|
|
1163
|
+
routes: navMenuItems
|
|
1164
|
+
? filterNavMenuItemsByConditions(navMenuItems)
|
|
1165
|
+
: undefined,
|
|
1158
1166
|
}, location: {
|
|
1159
1167
|
pathname: pathname,
|
|
1160
1168
|
}, menu: {
|
|
@@ -1191,20 +1199,25 @@ function RichLayout(_a) {
|
|
|
1191
1199
|
} }), children)));
|
|
1192
1200
|
}
|
|
1193
1201
|
|
|
1194
|
-
function generateNavMenuType(remainingDepth, displayName, defaultValue) {
|
|
1202
|
+
function generateNavMenuType(isNested, remainingDepth, displayName, defaultValue) {
|
|
1195
1203
|
return {
|
|
1196
1204
|
displayName: displayName ? displayName : "Nested items",
|
|
1197
1205
|
type: "array",
|
|
1198
1206
|
defaultValue: defaultValue,
|
|
1207
|
+
advanced: isNested,
|
|
1199
1208
|
itemType: {
|
|
1200
1209
|
type: "object",
|
|
1201
1210
|
nameFunc: function (item) {
|
|
1202
1211
|
return item.name || (!displayName ? "Unnamed nested item" : "Unnamed item");
|
|
1203
1212
|
},
|
|
1204
|
-
fields: __assign({ path: "href", name: "string"
|
|
1213
|
+
fields: __assign({ path: "href", name: "string", condition: {
|
|
1214
|
+
advanced: true,
|
|
1215
|
+
displayName: "Show only if",
|
|
1216
|
+
type: "exprEditor",
|
|
1217
|
+
} }, (remainingDepth === 0
|
|
1205
1218
|
? {}
|
|
1206
1219
|
: {
|
|
1207
|
-
routes: generateNavMenuType(remainingDepth - 1),
|
|
1220
|
+
routes: generateNavMenuType(true, remainingDepth - 1),
|
|
1208
1221
|
})),
|
|
1209
1222
|
},
|
|
1210
1223
|
};
|
|
@@ -1231,7 +1244,7 @@ var richLayoutMeta = {
|
|
|
1231
1244
|
type: "imageUrl",
|
|
1232
1245
|
defaultValue: "https://www.plasmic.app/favicon.ico",
|
|
1233
1246
|
},
|
|
1234
|
-
navMenuItems: generateNavMenuType(2, "Nav menu items", [
|
|
1247
|
+
navMenuItems: generateNavMenuType(false, 2, "Nav menu items", [
|
|
1235
1248
|
{
|
|
1236
1249
|
path: "/",
|
|
1237
1250
|
name: "Link 1",
|