@plasmicpkgs/plasmic-rich-components 1.0.78 → 1.0.80
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,10 @@
|
|
|
1
1
|
import registerComponent from '@plasmicapp/host/registerComponent';
|
|
2
2
|
import '@plasmicapp/host/registerGlobalContext';
|
|
3
3
|
import { ProDescriptions, ProLayout, ProConfigProvider, ProTable, TableDropdown } from '@ant-design/pro-components';
|
|
4
|
-
import React, { useState, useEffect,
|
|
5
|
-
import { Checkbox, Switch, Empty, theme, Dropdown, Button } from 'antd';
|
|
4
|
+
import React, { useState, useEffect, useRef } from 'react';
|
|
5
|
+
import { Checkbox, Switch, Empty, theme, ConfigProvider, Dropdown, Button } from 'antd';
|
|
6
|
+
import { tinycolor } from '@ctrl/tinycolor';
|
|
6
7
|
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
8
|
import { createObjectCsvStringifier } from 'csv-writer-browser';
|
|
10
9
|
import fastStringify from 'fast-stringify';
|
|
11
10
|
|
|
@@ -201,10 +200,11 @@ function buildFieldsPropType(opts) {
|
|
|
201
200
|
displayName: displayName,
|
|
202
201
|
control: control,
|
|
203
202
|
argNames: ["currentItem", "currentValue"],
|
|
204
|
-
argValues: function (_props, ctx) {
|
|
205
|
-
var
|
|
206
|
-
var
|
|
207
|
-
var
|
|
203
|
+
argValues: function (_props, ctx, _a) {
|
|
204
|
+
var _b;
|
|
205
|
+
var item = _a.item;
|
|
206
|
+
var row = (_b = ctx === null || ctx === void 0 ? void 0 : ctx.data) === null || _b === void 0 ? void 0 : _b[0];
|
|
207
|
+
var cell = item.fieldId ? row === null || row === void 0 ? void 0 : row[item.fieldId] : undefined;
|
|
208
208
|
return [row, cell];
|
|
209
209
|
},
|
|
210
210
|
});
|
|
@@ -251,7 +251,7 @@ function buildFieldsPropType(opts) {
|
|
|
251
251
|
type: "string",
|
|
252
252
|
displayName: "Title",
|
|
253
253
|
defaultValueHint: getDefaultValueHint("title"),
|
|
254
|
-
}, expr: rowDataType("Customize data"), isHidden: {
|
|
254
|
+
}, expr: rowDataType("Customize cell data"), isHidden: {
|
|
255
255
|
type: "boolean",
|
|
256
256
|
displayName: "Is hidden",
|
|
257
257
|
defaultValueHint: getDefaultValueHint("isHidden"),
|
|
@@ -865,7 +865,10 @@ function useColumnDefinitions$1(data, props) {
|
|
|
865
865
|
return defaultRender(_);
|
|
866
866
|
},
|
|
867
867
|
render: function (value, record, rowIndex) {
|
|
868
|
-
|
|
868
|
+
var cellValue = cconfig.fieldId
|
|
869
|
+
? record[cconfig.fieldId]
|
|
870
|
+
: undefined;
|
|
871
|
+
return renderValue(cellValue, record, cconfig);
|
|
869
872
|
},
|
|
870
873
|
};
|
|
871
874
|
return columnDefinition;
|
|
@@ -942,9 +945,16 @@ function useIsClient() {
|
|
|
942
945
|
function capitalize(text) {
|
|
943
946
|
return text.slice(0, 1).toUpperCase() + text.slice(1);
|
|
944
947
|
}
|
|
948
|
+
function isLight(color) {
|
|
949
|
+
var _a = tinycolor(color).toRgb(), r = _a.r, g = _a.g, b = _a.b;
|
|
950
|
+
return r * 0.299 + g * 0.587 + b * 0.114 > 186;
|
|
951
|
+
}
|
|
945
952
|
|
|
946
|
-
function
|
|
947
|
-
return
|
|
953
|
+
function omitUndefined(x) {
|
|
954
|
+
return Object.fromEntries(Object.entries(x).filter(function (_a) {
|
|
955
|
+
_a[0]; var v = _a[1];
|
|
956
|
+
return v !== undefined;
|
|
957
|
+
}));
|
|
948
958
|
}
|
|
949
959
|
function RichLayout(_a) {
|
|
950
960
|
var _b, _c, _d;
|
|
@@ -956,19 +966,35 @@ function RichLayout(_a) {
|
|
|
956
966
|
setPathname(location.pathname);
|
|
957
967
|
}
|
|
958
968
|
}, []);
|
|
959
|
-
var _g = useContext(ConfigContext); _g.locale; var th = _g.theme; __rest(_g, ["locale", "theme"]);
|
|
960
969
|
var token = theme.useToken().token;
|
|
961
|
-
var
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
970
|
+
var origTextColor = token.colorTextBase;
|
|
971
|
+
function getNavBgColor() {
|
|
972
|
+
var _a, _b;
|
|
973
|
+
var scheme = (_a = simpleNavTheme === null || simpleNavTheme === void 0 ? void 0 : simpleNavTheme.scheme) !== null && _a !== void 0 ? _a : "default";
|
|
974
|
+
switch (scheme) {
|
|
975
|
+
case "primary":
|
|
976
|
+
return token.colorPrimary;
|
|
977
|
+
case "dark":
|
|
978
|
+
// Ant default dark blue Menu color.
|
|
979
|
+
return "#011528";
|
|
980
|
+
case "custom":
|
|
981
|
+
return (_b = simpleNavTheme === null || simpleNavTheme === void 0 ? void 0 : simpleNavTheme.customBgColor) !== null && _b !== void 0 ? _b : token.colorBgBase;
|
|
982
|
+
case "light":
|
|
983
|
+
// Just use this sorta ugly gray if using 'light' scheme in 'dark' mode.
|
|
984
|
+
// Otherwise using light scheme in light mode.
|
|
985
|
+
return "#fff";
|
|
986
|
+
case "default":
|
|
987
|
+
return token.colorBgBase || "#fff";
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
var navBgColor = getNavBgColor();
|
|
991
|
+
// Dynamically determine whether we need to change the text to black/white or not, based on background color.
|
|
992
|
+
// We don't want light-on-light or dark-on-dark, so if both isNavBgLight and isOrigTextLight are the same, then need to change.
|
|
993
|
+
// If no need to change, we leave text color as is.
|
|
994
|
+
var isNavBgLight = isLight(navBgColor);
|
|
995
|
+
var isOrigTextLight = isLight(origTextColor);
|
|
996
|
+
// Ant will interpret "" as defaulting to "#fff" for dark mode and "#000" in light mode.
|
|
997
|
+
var navTextColor = isNavBgLight !== isOrigTextLight ? undefined : "";
|
|
972
998
|
if (!isClient) {
|
|
973
999
|
return null;
|
|
974
1000
|
}
|
|
@@ -976,23 +1002,37 @@ function RichLayout(_a) {
|
|
|
976
1002
|
React.createElement("style", null, ".ant-pro-layout-bg-list {\n display: none;\n }"),
|
|
977
1003
|
React.createElement(ProLayout, __assign({}, layoutProps, {
|
|
978
1004
|
// Theme just the header. If you simply pass in navTheme=realDark, it affects all main content as well.
|
|
979
|
-
|
|
1005
|
+
//
|
|
1006
|
+
// What we're doing is telling Ant to use the dark mode algorithm. However, dark mode algorithm doesn't change
|
|
1007
|
+
// the seed tokens for colorTextBase and colorBgBase - it only fills in #fff and #000 for these if they are
|
|
1008
|
+
// unset (""). So that's why further up we may be setting the text color to "".
|
|
1009
|
+
//
|
|
1010
|
+
// I think it doesn't matter too much what is the colorBgBase, since we are setting (Pro-specific) `tokens`
|
|
1011
|
+
// further down for actually setting the fill of the nav sections. What matters is the text color - if we're
|
|
1012
|
+
// showing a dark background, then we want the text to be white.
|
|
1013
|
+
//
|
|
1014
|
+
// We could specify darkAlgorithm to ConfigProvider, but IIRC Pro might be setting some of its own tokens
|
|
1015
|
+
// based on whether dark is being specified to the ProConfigProvider. So that's why we need that.
|
|
1016
|
+
//
|
|
1017
|
+
// ProConfigProvider does first read/inherit the theme/tokens from the surrounding ConfigProvider.
|
|
1018
|
+
headerRender: function (_props, defaultDom) { return (React.createElement(ConfigProvider, { theme: { token: omitUndefined({ colorTextBase: navTextColor }) } },
|
|
1019
|
+
React.createElement(ProConfigProvider, { dark: !isNavBgLight }, defaultDom))); }, token: {
|
|
980
1020
|
header: omitUndefined({
|
|
981
|
-
colorBgHeader:
|
|
1021
|
+
colorBgHeader: navBgColor,
|
|
982
1022
|
}),
|
|
983
1023
|
// Ideally, we'd do something similar to headerRender above, and just specify general dark mode to specify
|
|
984
1024
|
// whether all components/text should be light.
|
|
985
1025
|
// But for some reason it doesn't work, causing the bg color to be ignored (just the default dark Menu color),
|
|
986
1026
|
// *and* the text is just dark as well.
|
|
987
|
-
// Haven't
|
|
988
|
-
// bluntly specifying tokens here.
|
|
989
|
-
sider:
|
|
1027
|
+
// Haven't yet been able to unravel the pro components code to figure out the proper way to do this, so just
|
|
1028
|
+
// bluntly specifying tokens here, as recommended in some GitHub issue.
|
|
1029
|
+
sider: isNavBgLight
|
|
990
1030
|
? undefined
|
|
991
1031
|
: {
|
|
992
|
-
colorBgCollapsedButton:
|
|
993
|
-
colorTextCollapsedButtonHover: "rgba(
|
|
994
|
-
colorTextCollapsedButton: "rgba(
|
|
995
|
-
colorMenuBackground:
|
|
1032
|
+
colorBgCollapsedButton: navBgColor,
|
|
1033
|
+
colorTextCollapsedButtonHover: "rgba(255,255,255,0.85)",
|
|
1034
|
+
colorTextCollapsedButton: "rgba(255,255,255,0.65)",
|
|
1035
|
+
colorMenuBackground: navBgColor,
|
|
996
1036
|
colorBgMenuItemCollapsedHover: "rgba(0,0,0,0.06)",
|
|
997
1037
|
colorBgMenuItemCollapsedSelected: "rgba(0,0,0,0.15)",
|
|
998
1038
|
colorBgMenuItemCollapsedElevated: "rgba(0,0,0,0.85)",
|
|
@@ -1024,7 +1064,7 @@ function RichLayout(_a) {
|
|
|
1024
1064
|
// collapsedShowGroupTitle: true,
|
|
1025
1065
|
defaultOpenAll: true,
|
|
1026
1066
|
// hideMenuWhenCollapsed: true,
|
|
1027
|
-
}, avatarProps: showAvatarMenu
|
|
1067
|
+
}, avatarProps: showAvatarMenu
|
|
1028
1068
|
? {
|
|
1029
1069
|
src: avatarImage,
|
|
1030
1070
|
size: "small",
|
|
@@ -1064,7 +1104,7 @@ function generateNavMenuType(remainingDepth, displayName, defaultValue) {
|
|
|
1064
1104
|
nameFunc: function (item) {
|
|
1065
1105
|
return item.name || (!displayName ? "Unnamed nested item" : "Unnamed item");
|
|
1066
1106
|
},
|
|
1067
|
-
fields: __assign({ path: "
|
|
1107
|
+
fields: __assign({ path: "href", name: "string" }, (remainingDepth === 0
|
|
1068
1108
|
? {}
|
|
1069
1109
|
: {
|
|
1070
1110
|
routes: generateNavMenuType(remainingDepth - 1),
|
|
@@ -1074,7 +1114,7 @@ function generateNavMenuType(remainingDepth, displayName, defaultValue) {
|
|
|
1074
1114
|
}
|
|
1075
1115
|
var richLayoutMeta = {
|
|
1076
1116
|
name: "hostless-rich-layout",
|
|
1077
|
-
displayName: "Rich
|
|
1117
|
+
displayName: "Rich App Layout",
|
|
1078
1118
|
props: {
|
|
1079
1119
|
children: {
|
|
1080
1120
|
type: "slot",
|
|
@@ -1115,16 +1155,21 @@ var richLayoutMeta = {
|
|
|
1115
1155
|
},
|
|
1116
1156
|
simpleNavTheme: {
|
|
1117
1157
|
displayName: "Theme",
|
|
1118
|
-
advanced: true,
|
|
1119
1158
|
type: "object",
|
|
1120
1159
|
fields: {
|
|
1121
1160
|
scheme: {
|
|
1122
1161
|
type: "choice",
|
|
1123
|
-
options: ["
|
|
1162
|
+
options: ["default", "primary", "light", "dark", "custom"].map(function (v) { return ({
|
|
1124
1163
|
label: capitalize(v),
|
|
1125
1164
|
value: v,
|
|
1126
1165
|
}); }),
|
|
1127
|
-
|
|
1166
|
+
defaultValueHint: "default",
|
|
1167
|
+
},
|
|
1168
|
+
customBgColor: {
|
|
1169
|
+
type: "color",
|
|
1170
|
+
displayName: "Custom color",
|
|
1171
|
+
hidden: function (props) { var _a; return !(((_a = props.simpleNavTheme) === null || _a === void 0 ? void 0 : _a.scheme) === "custom"); },
|
|
1172
|
+
defaultValue: "#D73B58",
|
|
1128
1173
|
},
|
|
1129
1174
|
},
|
|
1130
1175
|
},
|
|
@@ -1194,6 +1239,7 @@ var richLayoutMeta = {
|
|
|
1194
1239
|
defaultStyles: {
|
|
1195
1240
|
width: "full-bleed",
|
|
1196
1241
|
height: "stretch",
|
|
1242
|
+
minHeight: "100vh",
|
|
1197
1243
|
},
|
|
1198
1244
|
importName: "RichLayout",
|
|
1199
1245
|
importPath: "@plasmicpkgs/plasmic-rich-components",
|
|
@@ -1352,7 +1398,10 @@ function useColumnDefinitions(data, props) {
|
|
|
1352
1398
|
return defaultRender(_);
|
|
1353
1399
|
},
|
|
1354
1400
|
render: function (value, record, rowIndex) {
|
|
1355
|
-
|
|
1401
|
+
var cellValue = cconfig.fieldId
|
|
1402
|
+
? record[cconfig.fieldId]
|
|
1403
|
+
: undefined;
|
|
1404
|
+
return renderValue(cellValue, record, cconfig);
|
|
1356
1405
|
},
|
|
1357
1406
|
};
|
|
1358
1407
|
return columnDefinition;
|