@plasmicpkgs/plasmic-rich-components 1.0.88 → 1.0.90

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
@@ -2,15 +2,16 @@
2
2
 
3
3
  var registerComponent = require('@plasmicapp/host/registerComponent');
4
4
  require('@plasmicapp/host/registerGlobalContext');
5
- var lodash = require('lodash');
6
- var proComponents = require('@ant-design/pro-components');
5
+ require('lodash/get');
7
6
  var React = require('react');
8
7
  var antd = require('antd');
9
8
  var tinycolor = require('@ctrl/tinycolor');
10
9
  var icons = require('@ant-design/icons');
10
+ var proComponents = require('@ant-design/pro-components');
11
11
  var csvWriterBrowser = require('csv-writer-browser');
12
12
  var fastStringify = require('fast-stringify');
13
13
  var classNames = require('classnames');
14
+ var groupBy = require('lodash/groupBy');
14
15
 
15
16
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
16
17
 
@@ -18,6 +19,7 @@ var registerComponent__default = /*#__PURE__*/_interopDefault(registerComponent)
18
19
  var React__default = /*#__PURE__*/_interopDefault(React);
19
20
  var fastStringify__default = /*#__PURE__*/_interopDefault(fastStringify);
20
21
  var classNames__default = /*#__PURE__*/_interopDefault(classNames);
22
+ var groupBy__default = /*#__PURE__*/_interopDefault(groupBy);
21
23
 
22
24
  /*! *****************************************************************************
23
25
  Copyright (c) Microsoft Corporation.
@@ -275,7 +277,7 @@ function getFieldSubprops(opts) {
275
277
  type: "boolean",
276
278
  displayName: "Is hidden",
277
279
  defaultValueHint: getDefaultValueHint("isHidden"),
278
- } }, (opts.noDataType
280
+ } }, (!opts.noDataType
279
281
  ? {
280
282
  dataType: {
281
283
  type: "choice",
@@ -927,14 +929,15 @@ function RichDetails(props) {
927
929
  var className = props.className, rawData = props.data, size = props.size, bordered = props.bordered, layout = props.layout, _b = props.column, column = _b === void 0 ? 2 : _b;
928
930
  var data = normalizeData(rawData);
929
931
  var columnDefinitions = useColumnDefinitions$1(data, props).columnDefinitions;
930
- if (!data) {
931
- return React__default.default.createElement(antd.Empty, { className: className });
932
+ if (!data || !((_a = data.data) === null || _a === void 0 ? void 0 : _a[0])) {
933
+ return React__default.default.createElement(antd.Empty, { className: className, image: antd.Empty.PRESENTED_IMAGE_SIMPLE });
932
934
  }
933
- return (React__default.default.createElement(proComponents.ProDescriptions, { className: className, dataSource: (_a = data === null || data === void 0 ? void 0 : data.data) === null || _a === void 0 ? void 0 : _a[0], columns: columnDefinitions, size: size, bordered: bordered, layout: layout, column: {
935
+ var row = data.data[0];
936
+ return (React__default.default.createElement(antd.Descriptions, { className: className, size: size, bordered: bordered, layout: layout, column: {
934
937
  xs: 1,
935
938
  sm: 1,
936
939
  md: column,
937
- } }));
940
+ } }, columnDefinitions.map(function (col) { return (React__default.default.createElement(antd.Descriptions.Item, { label: col.title, key: col.key, span: col.span }, col.render(row))); })));
938
941
  }
939
942
  function useColumnDefinitions$1(data, props) {
940
943
  var fields = props.fields, setControlContextData = props.setControlContextData;
@@ -958,21 +961,8 @@ function useColumnDefinitions$1(data, props) {
958
961
  dataIndex: cconfig.fieldId,
959
962
  title: cconfig.title,
960
963
  key: cconfig.key,
961
- valueType: deriveValueType(cconfig),
962
964
  span: cconfig.span,
963
- // To come later
964
- copyable: false,
965
- ellipsis: false,
966
- tip: undefined,
967
- formItemProps: {
968
- rules: [],
969
- },
970
- valueEnum: undefined,
971
- renderFormItem: function (_, _a) {
972
- var defaultRender = _a.defaultRender;
973
- return defaultRender(_);
974
- },
975
- render: function (value, record, rowIndex) {
965
+ render: function (record) {
976
966
  return renderValue(record, cconfig);
977
967
  },
978
968
  };
@@ -1944,6 +1934,8 @@ function RichList(props) {
1944
1934
  var data = normalizeData(rawData);
1945
1935
  var _f = useRoleDefinitions(data, props), normalized = _f.normalized, roleConfigs = _f.finalRoles;
1946
1936
  React.useRef();
1937
+ // Simply ignore the linkTo if it's not a function.
1938
+ var linkTo = typeof props.linkTo === "function" ? props.linkTo : undefined;
1947
1939
  var _g = useSortedFilteredData(data, normalized), finalData = _g.finalData, search = _g.search, setSearch = _g.setSearch; _g.setSortState;
1948
1940
  var actuallyBordered = type === "list" ? bordered : false;
1949
1941
  return (React__default.default.createElement("div", { className: className },
@@ -1972,10 +1964,9 @@ function RichList(props) {
1972
1964
  : "plasmic-list-item-card-cover" })); });
1973
1965
  var content = (React__default.default.createElement(ListItemContent, { bordered: actuallyBordered, image: type === "list" ? image : undefined, title: multiRenderValue(record, roleConfigs.title), subtitle: multiRenderValue(record, roleConfigs.subtitle), beforeTitle: multiRenderValue(record, roleConfigs.beforeTitle), afterTitle: multiRenderValue(record, roleConfigs.afterTitle), content: multiRenderValue(record, roleConfigs.content) }));
1974
1966
  function makeLinkWrapper() {
1975
- var _a;
1976
1967
  if ((actions !== null && actions !== void 0 ? actions : []).length > 0)
1977
1968
  return undefined;
1978
- var href = maybeRenderString(record, (_a = roleConfigs.linkTo) === null || _a === void 0 ? void 0 : _a[0]);
1969
+ var href = linkTo === null || linkTo === void 0 ? void 0 : linkTo(record);
1979
1970
  if (!href && !onRowClick)
1980
1971
  return undefined;
1981
1972
  var _linkWrapper = function (x) { return (React__default.default.createElement("a", { href: href, onClick: function (event) {
@@ -2032,7 +2023,6 @@ var defaultColumnConfig = function () {
2032
2023
  });
2033
2024
  };
2034
2025
  var roles = [
2035
- "linkTo",
2036
2026
  "content",
2037
2027
  "title",
2038
2028
  "subtitle",
@@ -2074,7 +2064,7 @@ function useRoleDefinitions(data, props) {
2074
2064
  }
2075
2065
  }
2076
2066
  // This is only being computed to get the default role choices.
2077
- var _e = deriveFieldConfigs(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], tagFieldConfigs("image"), true), tagFieldConfigs("content"), true), tagFieldConfigs("title"), true), tagFieldConfigs("beforeTitle"), true), tagFieldConfigs("afterTitle"), true), tagFieldConfigs("subtitle"), true), tagFieldConfigs("linkTo"), true), schema, function (field) { return (__assign(__assign({}, defaultColumnConfig()), (field && {
2067
+ var _e = deriveFieldConfigs(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], tagFieldConfigs("image"), true), tagFieldConfigs("content"), true), tagFieldConfigs("title"), true), tagFieldConfigs("beforeTitle"), true), tagFieldConfigs("afterTitle"), true), tagFieldConfigs("subtitle"), true), schema, function (field) { return (__assign(__assign({}, defaultColumnConfig()), (field && {
2078
2068
  key: field.id,
2079
2069
  fieldId: field.id,
2080
2070
  title: field.label || field.id,
@@ -2132,7 +2122,7 @@ function useRoleDefinitions(data, props) {
2132
2122
  contentField.role = "content";
2133
2123
  }
2134
2124
  }
2135
- var roleConfigs = ensure(lodash.groupBy(mergedFields, function (f) { return f.role; }));
2125
+ var roleConfigs = ensure(groupBy__default.default(mergedFields, function (f) { return f.role; }));
2136
2126
  var finalRoles = {};
2137
2127
  for (var _i = 0, roles_1 = roles; _i < roles_1.length; _i++) {
2138
2128
  var role = roles_1[_i];
@@ -2204,7 +2194,7 @@ var richListMeta = {
2204
2194
  }, footer: {
2205
2195
  type: "slot",
2206
2196
  hidePlaceholder: true,
2207
- }, title: roleProp({ role: "title" }), content: roleProp({ role: "content" }), image: roleProp({ role: "image", singular: true }), linkTo: roleProp({ role: "linkTo", singular: true }), subtitle: roleProp({
2197
+ }, title: roleProp({ role: "title" }), content: roleProp({ role: "content" }), image: roleProp({ role: "image", singular: true }), subtitle: roleProp({
2208
2198
  role: "subtitle",
2209
2199
  displayName: "Subtitle",
2210
2200
  advanced: true,
@@ -2212,7 +2202,14 @@ var richListMeta = {
2212
2202
  // Haven't styled these yet!
2213
2203
  // beforeTitle: roleProp({ role: "beforeTitle", advanced: true }),
2214
2204
  // afterTitle: roleProp({ role: "afterTitle", advanced: true }),
2215
- onRowClick: onRowClickProp(), rowActions: rowActionsProp(), bordered: {
2205
+ linkTo: {
2206
+ type: "function",
2207
+ control: {
2208
+ type: "href",
2209
+ },
2210
+ argNames: ["currentItem"],
2211
+ argValues: function (_props, ctx) { var _a; return [(_a = ctx === null || ctx === void 0 ? void 0 : ctx.data) === null || _a === void 0 ? void 0 : _a[0]]; },
2212
+ }, onRowClick: onRowClickProp(), rowActions: rowActionsProp(), bordered: {
2216
2213
  type: "boolean",
2217
2214
  defaultValue: true,
2218
2215
  hidden: function (ps) { var _a; return ((_a = ps.type) !== null && _a !== void 0 ? _a : "list") !== "list"; },