@contentful/field-editor-reference 5.21.6 → 5.22.2
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/index.js +3 -0
- package/dist/cjs/resources/ExternalResourceCard/ExternalResourceCard.js +125 -0
- package/dist/cjs/resources/index.js +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/resources/ExternalResourceCard/ExternalResourceCard.js +74 -0
- package/dist/esm/resources/index.js +1 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/resources/ExternalResourceCard/ExternalResourceCard.d.ts +54 -0
- package/dist/types/resources/index.d.ts +1 -0
- package/package.json +5 -5
package/dist/cjs/index.js
CHANGED
|
@@ -27,6 +27,9 @@ _export(exports, {
|
|
|
27
27
|
EntityProvider: function() {
|
|
28
28
|
return _EntityStore.EntityProvider;
|
|
29
29
|
},
|
|
30
|
+
ExternalResourceCard: function() {
|
|
31
|
+
return _resources.ExternalResourceCard;
|
|
32
|
+
},
|
|
30
33
|
MissingEntityCard: function() {
|
|
31
34
|
return _components.MissingEntityCard;
|
|
32
35
|
},
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "ExternalResourceCard", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return ExternalResourceCard;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _react = _interop_require_wildcard(require("react"));
|
|
12
|
+
const _f36components = require("@contentful/f36-components");
|
|
13
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
14
|
+
if (typeof WeakMap !== "function") return null;
|
|
15
|
+
var cacheBabelInterop = new WeakMap();
|
|
16
|
+
var cacheNodeInterop = new WeakMap();
|
|
17
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
18
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
19
|
+
})(nodeInterop);
|
|
20
|
+
}
|
|
21
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
22
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
23
|
+
return obj;
|
|
24
|
+
}
|
|
25
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
26
|
+
return {
|
|
27
|
+
default: obj
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
31
|
+
if (cache && cache.has(obj)) {
|
|
32
|
+
return cache.get(obj);
|
|
33
|
+
}
|
|
34
|
+
var newObj = {
|
|
35
|
+
__proto__: null
|
|
36
|
+
};
|
|
37
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
38
|
+
for(var key in obj){
|
|
39
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
40
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
41
|
+
if (desc && (desc.get || desc.set)) {
|
|
42
|
+
Object.defineProperty(newObj, key, desc);
|
|
43
|
+
} else {
|
|
44
|
+
newObj[key] = obj[key];
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
newObj.default = obj;
|
|
49
|
+
if (cache) {
|
|
50
|
+
cache.set(obj, newObj);
|
|
51
|
+
}
|
|
52
|
+
return newObj;
|
|
53
|
+
}
|
|
54
|
+
const defaultProps = {
|
|
55
|
+
isClickable: true,
|
|
56
|
+
hasCardEditActions: true,
|
|
57
|
+
hasCardMoveActions: true,
|
|
58
|
+
hasCardRemoveActions: true
|
|
59
|
+
};
|
|
60
|
+
const statusMap = {
|
|
61
|
+
active: 'positive',
|
|
62
|
+
draft: 'warning',
|
|
63
|
+
archived: 'negative',
|
|
64
|
+
suspended: 'negative'
|
|
65
|
+
};
|
|
66
|
+
function ExternalEntityBadge(entityStatus) {
|
|
67
|
+
const variant = statusMap[entityStatus];
|
|
68
|
+
return _react.createElement(_f36components.Badge, {
|
|
69
|
+
variant: variant
|
|
70
|
+
}, entityStatus);
|
|
71
|
+
}
|
|
72
|
+
function ExternalResourceCard({ entity, resourceType, size, isClickable, onEdit, onRemove, onMoveTop, onMoveBottom, hasCardEditActions, hasCardMoveActions, hasCardRemoveActions, renderDragHandle, onClick }) {
|
|
73
|
+
const status = entity.fields.additionalData.status;
|
|
74
|
+
const badge = status ? ExternalEntityBadge(status) : null;
|
|
75
|
+
return _react.createElement(_f36components.EntryCard, {
|
|
76
|
+
as: entity.fields.externalUrl ? 'a' : 'article',
|
|
77
|
+
href: entity.fields.externalUrl,
|
|
78
|
+
title: entity.fields.title,
|
|
79
|
+
description: entity.fields.description,
|
|
80
|
+
contentType: resourceType,
|
|
81
|
+
size: size,
|
|
82
|
+
thumbnailElement: entity.fields.image && entity.fields.image.url ? _react.createElement("img", {
|
|
83
|
+
alt: entity.fields.image.description,
|
|
84
|
+
src: entity.fields.image.url
|
|
85
|
+
}) : undefined,
|
|
86
|
+
dragHandleRender: renderDragHandle,
|
|
87
|
+
withDragHandle: !!renderDragHandle,
|
|
88
|
+
badge: badge,
|
|
89
|
+
actions: onEdit || onRemove ? [
|
|
90
|
+
hasCardEditActions && onEdit ? _react.createElement(_f36components.MenuItem, {
|
|
91
|
+
key: "edit",
|
|
92
|
+
testId: "edit",
|
|
93
|
+
onClick: ()=>{
|
|
94
|
+
onEdit && onEdit();
|
|
95
|
+
}
|
|
96
|
+
}, "Edit") : null,
|
|
97
|
+
hasCardRemoveActions && onRemove ? _react.createElement(_f36components.MenuItem, {
|
|
98
|
+
key: "delete",
|
|
99
|
+
testId: "delete",
|
|
100
|
+
onClick: ()=>{
|
|
101
|
+
onRemove && onRemove();
|
|
102
|
+
}
|
|
103
|
+
}, "Remove") : null,
|
|
104
|
+
hasCardMoveActions && (onMoveTop || onMoveBottom) ? _react.createElement(_f36components.MenuDivider, {
|
|
105
|
+
key: "divider"
|
|
106
|
+
}) : null,
|
|
107
|
+
hasCardMoveActions && onMoveTop ? _react.createElement(_f36components.MenuItem, {
|
|
108
|
+
key: "move-top",
|
|
109
|
+
onClick: ()=>onMoveTop && onMoveTop(),
|
|
110
|
+
testId: "move-top"
|
|
111
|
+
}, "Move to top") : null,
|
|
112
|
+
hasCardMoveActions && onMoveBottom ? _react.createElement(_f36components.MenuItem, {
|
|
113
|
+
key: "move-bottom",
|
|
114
|
+
onClick: ()=>onMoveBottom && onMoveBottom(),
|
|
115
|
+
testId: "move-bottom"
|
|
116
|
+
}, "Move to bottom") : null
|
|
117
|
+
].filter((item)=>item) : [],
|
|
118
|
+
onClick: isClickable ? (e)=>{
|
|
119
|
+
e.preventDefault();
|
|
120
|
+
if (onClick) return onClick(e);
|
|
121
|
+
onEdit && onEdit();
|
|
122
|
+
} : undefined
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
ExternalResourceCard.defaultProps = defaultProps;
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
_export_star(require("./MultipleResourceReferenceEditor"), exports);
|
|
6
6
|
_export_star(require("./SingleResourceReferenceEditor"), exports);
|
|
7
|
+
_export_star(require("./ExternalResourceCard/ExternalResourceCard"), exports);
|
|
7
8
|
function _export_star(from, to) {
|
|
8
9
|
Object.keys(from).forEach(function(k) {
|
|
9
10
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
package/dist/esm/index.js
CHANGED
|
@@ -4,5 +4,5 @@ export { SingleMediaEditor, MultipleMediaEditor, WrappedAssetCard } from './asse
|
|
|
4
4
|
export { SortableLinkList } from './common/SortableLinkList';
|
|
5
5
|
export { EntityProvider, useEntityLoader, useEntity, useResource } from './common/EntityStore';
|
|
6
6
|
export { SharedQueryClientProvider as EntityCacheProvider } from './common/queryClient';
|
|
7
|
-
export { SingleResourceReferenceEditor, MultipleResourceReferenceEditor } from './resources';
|
|
7
|
+
export { SingleResourceReferenceEditor, MultipleResourceReferenceEditor, ExternalResourceCard } from './resources';
|
|
8
8
|
export * from './types';
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Badge, EntryCard, MenuItem, MenuDivider } from '@contentful/f36-components';
|
|
3
|
+
const defaultProps = {
|
|
4
|
+
isClickable: true,
|
|
5
|
+
hasCardEditActions: true,
|
|
6
|
+
hasCardMoveActions: true,
|
|
7
|
+
hasCardRemoveActions: true
|
|
8
|
+
};
|
|
9
|
+
const statusMap = {
|
|
10
|
+
active: 'positive',
|
|
11
|
+
draft: 'warning',
|
|
12
|
+
archived: 'negative',
|
|
13
|
+
suspended: 'negative'
|
|
14
|
+
};
|
|
15
|
+
function ExternalEntityBadge(entityStatus) {
|
|
16
|
+
const variant = statusMap[entityStatus];
|
|
17
|
+
return React.createElement(Badge, {
|
|
18
|
+
variant: variant
|
|
19
|
+
}, entityStatus);
|
|
20
|
+
}
|
|
21
|
+
export function ExternalResourceCard({ entity, resourceType, size, isClickable, onEdit, onRemove, onMoveTop, onMoveBottom, hasCardEditActions, hasCardMoveActions, hasCardRemoveActions, renderDragHandle, onClick }) {
|
|
22
|
+
const status = entity.fields.additionalData.status;
|
|
23
|
+
const badge = status ? ExternalEntityBadge(status) : null;
|
|
24
|
+
return React.createElement(EntryCard, {
|
|
25
|
+
as: entity.fields.externalUrl ? 'a' : 'article',
|
|
26
|
+
href: entity.fields.externalUrl,
|
|
27
|
+
title: entity.fields.title,
|
|
28
|
+
description: entity.fields.description,
|
|
29
|
+
contentType: resourceType,
|
|
30
|
+
size: size,
|
|
31
|
+
thumbnailElement: entity.fields.image && entity.fields.image.url ? React.createElement("img", {
|
|
32
|
+
alt: entity.fields.image.description,
|
|
33
|
+
src: entity.fields.image.url
|
|
34
|
+
}) : undefined,
|
|
35
|
+
dragHandleRender: renderDragHandle,
|
|
36
|
+
withDragHandle: !!renderDragHandle,
|
|
37
|
+
badge: badge,
|
|
38
|
+
actions: onEdit || onRemove ? [
|
|
39
|
+
hasCardEditActions && onEdit ? React.createElement(MenuItem, {
|
|
40
|
+
key: "edit",
|
|
41
|
+
testId: "edit",
|
|
42
|
+
onClick: ()=>{
|
|
43
|
+
onEdit && onEdit();
|
|
44
|
+
}
|
|
45
|
+
}, "Edit") : null,
|
|
46
|
+
hasCardRemoveActions && onRemove ? React.createElement(MenuItem, {
|
|
47
|
+
key: "delete",
|
|
48
|
+
testId: "delete",
|
|
49
|
+
onClick: ()=>{
|
|
50
|
+
onRemove && onRemove();
|
|
51
|
+
}
|
|
52
|
+
}, "Remove") : null,
|
|
53
|
+
hasCardMoveActions && (onMoveTop || onMoveBottom) ? React.createElement(MenuDivider, {
|
|
54
|
+
key: "divider"
|
|
55
|
+
}) : null,
|
|
56
|
+
hasCardMoveActions && onMoveTop ? React.createElement(MenuItem, {
|
|
57
|
+
key: "move-top",
|
|
58
|
+
onClick: ()=>onMoveTop && onMoveTop(),
|
|
59
|
+
testId: "move-top"
|
|
60
|
+
}, "Move to top") : null,
|
|
61
|
+
hasCardMoveActions && onMoveBottom ? React.createElement(MenuItem, {
|
|
62
|
+
key: "move-bottom",
|
|
63
|
+
onClick: ()=>onMoveBottom && onMoveBottom(),
|
|
64
|
+
testId: "move-bottom"
|
|
65
|
+
}, "Move to bottom") : null
|
|
66
|
+
].filter((item)=>item) : [],
|
|
67
|
+
onClick: isClickable ? (e)=>{
|
|
68
|
+
e.preventDefault();
|
|
69
|
+
if (onClick) return onClick(e);
|
|
70
|
+
onEdit && onEdit();
|
|
71
|
+
} : undefined
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
ExternalResourceCard.defaultProps = defaultProps;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -7,5 +7,5 @@ export { SortableLinkList } from './common/SortableLinkList';
|
|
|
7
7
|
export { EntityProvider, useEntityLoader, useEntity, useResource } from './common/EntityStore';
|
|
8
8
|
export { SharedQueryClientProvider as EntityCacheProvider } from './common/queryClient';
|
|
9
9
|
export type { ResourceInfo } from './common/EntityStore';
|
|
10
|
-
export { SingleResourceReferenceEditor, MultipleResourceReferenceEditor } from './resources';
|
|
10
|
+
export { SingleResourceReferenceEditor, MultipleResourceReferenceEditor, ExternalResourceCard, } from './resources';
|
|
11
11
|
export * from './types';
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { RenderDragFn } from '../../types';
|
|
3
|
+
type SysExternalResource<T extends string> = {
|
|
4
|
+
sys: {
|
|
5
|
+
type: 'Link';
|
|
6
|
+
linkType: T;
|
|
7
|
+
id: string;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
interface ExternalResource {
|
|
11
|
+
sys: {
|
|
12
|
+
type: string;
|
|
13
|
+
id: string;
|
|
14
|
+
resourceProvider: SysExternalResource<'ResourceProvider'>;
|
|
15
|
+
resourceType: SysExternalResource<'ResourceType'>;
|
|
16
|
+
};
|
|
17
|
+
fields: {
|
|
18
|
+
title: string;
|
|
19
|
+
description?: string;
|
|
20
|
+
externalUrl?: string;
|
|
21
|
+
image?: {
|
|
22
|
+
url?: string;
|
|
23
|
+
description?: string;
|
|
24
|
+
};
|
|
25
|
+
additionalData: any;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export interface ExternalResourceCardProps {
|
|
29
|
+
entity: ExternalResource;
|
|
30
|
+
resourceType: string;
|
|
31
|
+
isDisabled: boolean;
|
|
32
|
+
size: 'small' | 'default' | 'auto';
|
|
33
|
+
isSelected?: boolean;
|
|
34
|
+
onRemove?: () => void;
|
|
35
|
+
onEdit?: () => void;
|
|
36
|
+
onClick?: (e: React.MouseEvent<HTMLElement>) => void;
|
|
37
|
+
renderDragHandle?: RenderDragFn;
|
|
38
|
+
isClickable?: boolean;
|
|
39
|
+
onMoveTop?: () => void;
|
|
40
|
+
onMoveBottom?: () => void;
|
|
41
|
+
hasCardEditActions: boolean;
|
|
42
|
+
hasCardMoveActions?: boolean;
|
|
43
|
+
hasCardRemoveActions?: boolean;
|
|
44
|
+
}
|
|
45
|
+
export declare function ExternalResourceCard({ entity, resourceType, size, isClickable, onEdit, onRemove, onMoveTop, onMoveBottom, hasCardEditActions, hasCardMoveActions, hasCardRemoveActions, renderDragHandle, onClick, }: ExternalResourceCardProps): JSX.Element;
|
|
46
|
+
export declare namespace ExternalResourceCard {
|
|
47
|
+
var defaultProps: {
|
|
48
|
+
isClickable: boolean;
|
|
49
|
+
hasCardEditActions: boolean;
|
|
50
|
+
hasCardMoveActions: boolean;
|
|
51
|
+
hasCardRemoveActions: boolean;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/field-editor-reference",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.22.2",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
"tsc": "tsc -p ./ --noEmit"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@contentful/f36-components": "^4.0
|
|
39
|
-
"@contentful/f36-icons": "^4.
|
|
40
|
-
"@contentful/f36-tokens": "^4.0.
|
|
38
|
+
"@contentful/f36-components": "^4.60.0",
|
|
39
|
+
"@contentful/f36-icons": "^4.27.0",
|
|
40
|
+
"@contentful/f36-tokens": "^4.0.4",
|
|
41
41
|
"@contentful/field-editor-shared": "^1.4.5",
|
|
42
42
|
"@contentful/mimetype": "^2.2.29",
|
|
43
43
|
"@dnd-kit/core": "^6.0.8",
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"publishConfig": {
|
|
68
68
|
"registry": "https://npm.pkg.github.com/"
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "e9e822565077a5de09c4daa930c5d8aef50910af"
|
|
71
71
|
}
|