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