@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.
@@ -1,14 +1,15 @@
1
1
  import registerComponent from '@plasmicapp/host/registerComponent';
2
2
  import '@plasmicapp/host/registerGlobalContext';
3
- import { groupBy } from 'lodash';
4
- import { ProDescriptions, ProLayout, ProConfigProvider, ProTable } from '@ant-design/pro-components';
3
+ import 'lodash/get';
5
4
  import React, { useState, useEffect, useRef } from 'react';
6
- import { Checkbox, Switch, Empty, theme, ConfigProvider, Dropdown, Button, Input, List, Card, Tag } from 'antd';
5
+ import { Checkbox, Switch, Empty, Descriptions, theme, ConfigProvider, Dropdown, Button, Input, List, Card, Tag } from 'antd';
7
6
  import { tinycolor } from '@ctrl/tinycolor';
8
7
  import { LogoutOutlined, PlusOutlined, EllipsisOutlined } from '@ant-design/icons';
8
+ import { ProLayout, ProConfigProvider, ProTable } from '@ant-design/pro-components';
9
9
  import { createObjectCsvStringifier } from 'csv-writer-browser';
10
10
  import fastStringify from 'fast-stringify';
11
11
  import classNames from 'classnames';
12
+ import groupBy from 'lodash/groupBy';
12
13
 
13
14
  /*! *****************************************************************************
14
15
  Copyright (c) Microsoft Corporation.
@@ -266,7 +267,7 @@ function getFieldSubprops(opts) {
266
267
  type: "boolean",
267
268
  displayName: "Is hidden",
268
269
  defaultValueHint: getDefaultValueHint("isHidden"),
269
- } }, (opts.noDataType
270
+ } }, (!opts.noDataType
270
271
  ? {
271
272
  dataType: {
272
273
  type: "choice",
@@ -918,14 +919,15 @@ function RichDetails(props) {
918
919
  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;
919
920
  var data = normalizeData(rawData);
920
921
  var columnDefinitions = useColumnDefinitions$1(data, props).columnDefinitions;
921
- if (!data) {
922
- return React.createElement(Empty, { className: className });
922
+ if (!data || !((_a = data.data) === null || _a === void 0 ? void 0 : _a[0])) {
923
+ return React.createElement(Empty, { className: className, image: Empty.PRESENTED_IMAGE_SIMPLE });
923
924
  }
924
- return (React.createElement(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: {
925
+ var row = data.data[0];
926
+ return (React.createElement(Descriptions, { className: className, size: size, bordered: bordered, layout: layout, column: {
925
927
  xs: 1,
926
928
  sm: 1,
927
929
  md: column,
928
- } }));
930
+ } }, columnDefinitions.map(function (col) { return (React.createElement(Descriptions.Item, { label: col.title, key: col.key, span: col.span }, col.render(row))); })));
929
931
  }
930
932
  function useColumnDefinitions$1(data, props) {
931
933
  var fields = props.fields, setControlContextData = props.setControlContextData;
@@ -949,21 +951,8 @@ function useColumnDefinitions$1(data, props) {
949
951
  dataIndex: cconfig.fieldId,
950
952
  title: cconfig.title,
951
953
  key: cconfig.key,
952
- valueType: deriveValueType(cconfig),
953
954
  span: cconfig.span,
954
- // To come later
955
- copyable: false,
956
- ellipsis: false,
957
- tip: undefined,
958
- formItemProps: {
959
- rules: [],
960
- },
961
- valueEnum: undefined,
962
- renderFormItem: function (_, _a) {
963
- var defaultRender = _a.defaultRender;
964
- return defaultRender(_);
965
- },
966
- render: function (value, record, rowIndex) {
955
+ render: function (record) {
967
956
  return renderValue(record, cconfig);
968
957
  },
969
958
  };
@@ -1935,6 +1924,8 @@ function RichList(props) {
1935
1924
  var data = normalizeData(rawData);
1936
1925
  var _f = useRoleDefinitions(data, props), normalized = _f.normalized, roleConfigs = _f.finalRoles;
1937
1926
  useRef();
1927
+ // Simply ignore the linkTo if it's not a function.
1928
+ var linkTo = typeof props.linkTo === "function" ? props.linkTo : undefined;
1938
1929
  var _g = useSortedFilteredData(data, normalized), finalData = _g.finalData, search = _g.search, setSearch = _g.setSearch; _g.setSortState;
1939
1930
  var actuallyBordered = type === "list" ? bordered : false;
1940
1931
  return (React.createElement("div", { className: className },
@@ -1963,10 +1954,9 @@ function RichList(props) {
1963
1954
  : "plasmic-list-item-card-cover" })); });
1964
1955
  var content = (React.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) }));
1965
1956
  function makeLinkWrapper() {
1966
- var _a;
1967
1957
  if ((actions !== null && actions !== void 0 ? actions : []).length > 0)
1968
1958
  return undefined;
1969
- var href = maybeRenderString(record, (_a = roleConfigs.linkTo) === null || _a === void 0 ? void 0 : _a[0]);
1959
+ var href = linkTo === null || linkTo === void 0 ? void 0 : linkTo(record);
1970
1960
  if (!href && !onRowClick)
1971
1961
  return undefined;
1972
1962
  var _linkWrapper = function (x) { return (React.createElement("a", { href: href, onClick: function (event) {
@@ -2023,7 +2013,6 @@ var defaultColumnConfig = function () {
2023
2013
  });
2024
2014
  };
2025
2015
  var roles = [
2026
- "linkTo",
2027
2016
  "content",
2028
2017
  "title",
2029
2018
  "subtitle",
@@ -2065,7 +2054,7 @@ function useRoleDefinitions(data, props) {
2065
2054
  }
2066
2055
  }
2067
2056
  // This is only being computed to get the default role choices.
2068
- 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 && {
2057
+ 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 && {
2069
2058
  key: field.id,
2070
2059
  fieldId: field.id,
2071
2060
  title: field.label || field.id,
@@ -2195,7 +2184,7 @@ var richListMeta = {
2195
2184
  }, footer: {
2196
2185
  type: "slot",
2197
2186
  hidePlaceholder: true,
2198
- }, title: roleProp({ role: "title" }), content: roleProp({ role: "content" }), image: roleProp({ role: "image", singular: true }), linkTo: roleProp({ role: "linkTo", singular: true }), subtitle: roleProp({
2187
+ }, title: roleProp({ role: "title" }), content: roleProp({ role: "content" }), image: roleProp({ role: "image", singular: true }), subtitle: roleProp({
2199
2188
  role: "subtitle",
2200
2189
  displayName: "Subtitle",
2201
2190
  advanced: true,
@@ -2203,7 +2192,14 @@ var richListMeta = {
2203
2192
  // Haven't styled these yet!
2204
2193
  // beforeTitle: roleProp({ role: "beforeTitle", advanced: true }),
2205
2194
  // afterTitle: roleProp({ role: "afterTitle", advanced: true }),
2206
- onRowClick: onRowClickProp(), rowActions: rowActionsProp(), bordered: {
2195
+ linkTo: {
2196
+ type: "function",
2197
+ control: {
2198
+ type: "href",
2199
+ },
2200
+ argNames: ["currentItem"],
2201
+ 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]]; },
2202
+ }, onRowClick: onRowClickProp(), rowActions: rowActionsProp(), bordered: {
2207
2203
  type: "boolean",
2208
2204
  defaultValue: true,
2209
2205
  hidden: function (ps) { var _a; return ((_a = ps.type) !== null && _a !== void 0 ? _a : "list") !== "list"; },