@contentful/field-editor-reference 5.23.0 → 5.24.0
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/cjs/resources/Cards/ResourceCard.spec.js +1 -1
- package/dist/cjs/resources/ExternalResourceCard/ExternalResourceCard.js +42 -3
- package/dist/esm/resources/Cards/ResourceCard.spec.js +1 -1
- package/dist/esm/resources/ExternalResourceCard/ExternalResourceCard.js +38 -4
- package/package.json +2 -2
|
@@ -224,6 +224,6 @@ describe('ResourceCard', ()=>{
|
|
|
224
224
|
});
|
|
225
225
|
await (0, _react1.waitFor)(()=>expect(getByTestId('cf-ui-entry-card')).toBeDefined());
|
|
226
226
|
expect(getByText(_resourcejson.default.fields.title)).toBeDefined();
|
|
227
|
-
expect(getByText(_resourcetypejson.default.name)).toBeDefined();
|
|
227
|
+
expect(getByText(`${_resourcetypejson.default.sys.resourceProvider.sys.id} ${_resourcetypejson.default.name}`)).toBeDefined();
|
|
228
228
|
});
|
|
229
229
|
});
|
|
@@ -10,6 +10,14 @@ Object.defineProperty(exports, "ExternalResourceCard", {
|
|
|
10
10
|
});
|
|
11
11
|
const _react = _interop_require_wildcard(require("react"));
|
|
12
12
|
const _f36components = require("@contentful/f36-components");
|
|
13
|
+
const _f36tokens = _interop_require_default(require("@contentful/f36-tokens"));
|
|
14
|
+
const _emotion = require("emotion");
|
|
15
|
+
const _truncate = _interop_require_default(require("truncate"));
|
|
16
|
+
function _interop_require_default(obj) {
|
|
17
|
+
return obj && obj.__esModule ? obj : {
|
|
18
|
+
default: obj
|
|
19
|
+
};
|
|
20
|
+
}
|
|
13
21
|
function _getRequireWildcardCache(nodeInterop) {
|
|
14
22
|
if (typeof WeakMap !== "function") return null;
|
|
15
23
|
var cacheBabelInterop = new WeakMap();
|
|
@@ -56,11 +64,40 @@ const defaultProps = {
|
|
|
56
64
|
hasCardMoveActions: true,
|
|
57
65
|
hasCardRemoveActions: true
|
|
58
66
|
};
|
|
67
|
+
const styles = {
|
|
68
|
+
subtitle: (0, _emotion.css)({
|
|
69
|
+
color: _f36tokens.default.gray600
|
|
70
|
+
}),
|
|
71
|
+
description: (0, _emotion.css)({
|
|
72
|
+
color: _f36tokens.default.gray900
|
|
73
|
+
})
|
|
74
|
+
};
|
|
59
75
|
function ExternalEntityBadge(badge) {
|
|
60
76
|
return badge ? _react.createElement(_f36components.Badge, {
|
|
61
77
|
variant: badge.variant
|
|
62
78
|
}, badge.label) : null;
|
|
63
79
|
}
|
|
80
|
+
function ExternalResourceCardDescription({ subtitle, description }) {
|
|
81
|
+
if (!subtitle) {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
if (!description) {
|
|
85
|
+
return _react.createElement(_f36components.Paragraph, {
|
|
86
|
+
className: styles.description,
|
|
87
|
+
marginBottom: "none",
|
|
88
|
+
isWordBreak: true
|
|
89
|
+
}, subtitle);
|
|
90
|
+
}
|
|
91
|
+
const truncatedDescription = (0, _truncate.default)(description, 95, {});
|
|
92
|
+
return _react.createElement(_react.Fragment, null, _react.createElement(_f36components.Caption, {
|
|
93
|
+
className: styles.subtitle
|
|
94
|
+
}, subtitle), _react.createElement(_f36components.Paragraph, {
|
|
95
|
+
className: styles.description,
|
|
96
|
+
marginBottom: "none",
|
|
97
|
+
isWordBreak: true
|
|
98
|
+
}, truncatedDescription));
|
|
99
|
+
}
|
|
100
|
+
ExternalResourceCardDescription.displayName = 'ExternalResourceCardDescription';
|
|
64
101
|
function ExternalResourceCard({ info, isClickable, onEdit, onRemove, onMoveTop, onMoveBottom, hasCardEditActions, hasCardMoveActions, hasCardRemoveActions, renderDragHandle, onClick }) {
|
|
65
102
|
const { resource: entity, resourceType } = info;
|
|
66
103
|
const badge = ExternalEntityBadge(entity.fields.badge);
|
|
@@ -68,8 +105,7 @@ function ExternalResourceCard({ info, isClickable, onEdit, onRemove, onMoveTop,
|
|
|
68
105
|
as: entity.fields.externalUrl ? 'a' : 'article',
|
|
69
106
|
href: entity.fields.externalUrl,
|
|
70
107
|
title: entity.fields.title,
|
|
71
|
-
|
|
72
|
-
contentType: resourceType.name,
|
|
108
|
+
contentType: `${resourceType.sys.resourceProvider.sys.id} ${resourceType.name}`,
|
|
73
109
|
size: 'auto',
|
|
74
110
|
thumbnailElement: entity.fields.image?.url ? _react.createElement("img", {
|
|
75
111
|
alt: entity.fields.image.altText,
|
|
@@ -112,6 +148,9 @@ function ExternalResourceCard({ info, isClickable, onEdit, onRemove, onMoveTop,
|
|
|
112
148
|
if (onClick) return onClick(e);
|
|
113
149
|
onEdit && onEdit();
|
|
114
150
|
} : undefined
|
|
115
|
-
}
|
|
151
|
+
}, _react.createElement(ExternalResourceCardDescription, {
|
|
152
|
+
subtitle: entity.fields.subtitle,
|
|
153
|
+
description: entity.fields.description
|
|
154
|
+
}));
|
|
116
155
|
}
|
|
117
156
|
ExternalResourceCard.defaultProps = defaultProps;
|
|
@@ -174,6 +174,6 @@ describe('ResourceCard', ()=>{
|
|
|
174
174
|
});
|
|
175
175
|
await waitFor(()=>expect(getByTestId('cf-ui-entry-card')).toBeDefined());
|
|
176
176
|
expect(getByText(resource.fields.title)).toBeDefined();
|
|
177
|
-
expect(getByText(resourceType.name)).toBeDefined();
|
|
177
|
+
expect(getByText(`${resourceType.sys.resourceProvider.sys.id} ${resourceType.name}`)).toBeDefined();
|
|
178
178
|
});
|
|
179
179
|
});
|
|
@@ -1,15 +1,47 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { Badge, EntryCard, MenuItem, MenuDivider } from '@contentful/f36-components';
|
|
2
|
+
import { Badge, EntryCard, MenuItem, MenuDivider, Paragraph, Caption } from '@contentful/f36-components';
|
|
3
|
+
import tokens from '@contentful/f36-tokens';
|
|
4
|
+
import { css } from 'emotion';
|
|
5
|
+
import truncate from 'truncate';
|
|
3
6
|
const defaultProps = {
|
|
4
7
|
isClickable: true,
|
|
5
8
|
hasCardMoveActions: true,
|
|
6
9
|
hasCardRemoveActions: true
|
|
7
10
|
};
|
|
11
|
+
const styles = {
|
|
12
|
+
subtitle: css({
|
|
13
|
+
color: tokens.gray600
|
|
14
|
+
}),
|
|
15
|
+
description: css({
|
|
16
|
+
color: tokens.gray900
|
|
17
|
+
})
|
|
18
|
+
};
|
|
8
19
|
function ExternalEntityBadge(badge) {
|
|
9
20
|
return badge ? React.createElement(Badge, {
|
|
10
21
|
variant: badge.variant
|
|
11
22
|
}, badge.label) : null;
|
|
12
23
|
}
|
|
24
|
+
function ExternalResourceCardDescription({ subtitle, description }) {
|
|
25
|
+
if (!subtitle) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
if (!description) {
|
|
29
|
+
return React.createElement(Paragraph, {
|
|
30
|
+
className: styles.description,
|
|
31
|
+
marginBottom: "none",
|
|
32
|
+
isWordBreak: true
|
|
33
|
+
}, subtitle);
|
|
34
|
+
}
|
|
35
|
+
const truncatedDescription = truncate(description, 95, {});
|
|
36
|
+
return React.createElement(React.Fragment, null, React.createElement(Caption, {
|
|
37
|
+
className: styles.subtitle
|
|
38
|
+
}, subtitle), React.createElement(Paragraph, {
|
|
39
|
+
className: styles.description,
|
|
40
|
+
marginBottom: "none",
|
|
41
|
+
isWordBreak: true
|
|
42
|
+
}, truncatedDescription));
|
|
43
|
+
}
|
|
44
|
+
ExternalResourceCardDescription.displayName = 'ExternalResourceCardDescription';
|
|
13
45
|
export function ExternalResourceCard({ info, isClickable, onEdit, onRemove, onMoveTop, onMoveBottom, hasCardEditActions, hasCardMoveActions, hasCardRemoveActions, renderDragHandle, onClick }) {
|
|
14
46
|
const { resource: entity, resourceType } = info;
|
|
15
47
|
const badge = ExternalEntityBadge(entity.fields.badge);
|
|
@@ -17,8 +49,7 @@ export function ExternalResourceCard({ info, isClickable, onEdit, onRemove, onMo
|
|
|
17
49
|
as: entity.fields.externalUrl ? 'a' : 'article',
|
|
18
50
|
href: entity.fields.externalUrl,
|
|
19
51
|
title: entity.fields.title,
|
|
20
|
-
|
|
21
|
-
contentType: resourceType.name,
|
|
52
|
+
contentType: `${resourceType.sys.resourceProvider.sys.id} ${resourceType.name}`,
|
|
22
53
|
size: 'auto',
|
|
23
54
|
thumbnailElement: entity.fields.image?.url ? React.createElement("img", {
|
|
24
55
|
alt: entity.fields.image.altText,
|
|
@@ -61,6 +92,9 @@ export function ExternalResourceCard({ info, isClickable, onEdit, onRemove, onMo
|
|
|
61
92
|
if (onClick) return onClick(e);
|
|
62
93
|
onEdit && onEdit();
|
|
63
94
|
} : undefined
|
|
64
|
-
}
|
|
95
|
+
}, React.createElement(ExternalResourceCardDescription, {
|
|
96
|
+
subtitle: entity.fields.subtitle,
|
|
97
|
+
description: entity.fields.description
|
|
98
|
+
}));
|
|
65
99
|
}
|
|
66
100
|
ExternalResourceCard.defaultProps = defaultProps;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/field-editor-reference",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.24.0",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"publishConfig": {
|
|
68
68
|
"registry": "https://npm.pkg.github.com/"
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "49604b4ca3f3eefb173d40e365352686e65eeaef"
|
|
71
71
|
}
|