@contentful/field-editor-reference 5.30.2 → 5.30.3

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.
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "ExternalEntryCard", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return ExternalEntryCard;
9
+ }
10
+ });
11
+ const _react = _interop_require_wildcard(require("react"));
12
+ const _ExternalResourceCard = require("../ExternalResourceCard/ExternalResourceCard");
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
+ function ExternalEntryCard(props) {
55
+ const openEntryDetail = ()=>{
56
+ window.open(props.info.resource.fields.externalUrl, '_blank', 'noopener,noreferrer');
57
+ };
58
+ return _react.createElement(_ExternalResourceCard.ExternalResourceCard, {
59
+ ...props,
60
+ onEdit: openEntryDetail
61
+ });
62
+ }
@@ -13,8 +13,8 @@ const _reactintersectionobserver = require("react-intersection-observer");
13
13
  const _f36components = require("@contentful/f36-components");
14
14
  const _EntityStore = require("../../common/EntityStore");
15
15
  const _components = require("../../components");
16
- const _ExternalResourceCard = require("../ExternalResourceCard/ExternalResourceCard");
17
16
  const _ContentfulEntryCard = require("./ContentfulEntryCard");
17
+ const _ExternalEntryCard = require("./ExternalEntryCard");
18
18
  function _getRequireWildcardCache(nodeInterop) {
19
19
  if (typeof WeakMap !== "function") return null;
20
20
  var cacheBabelInterop = new WeakMap();
@@ -87,7 +87,7 @@ function ExistingResourceCard(props) {
87
87
  ...props
88
88
  });
89
89
  }
90
- return _react.createElement(_ExternalResourceCard.ExternalResourceCard, {
90
+ return _react.createElement(_ExternalEntryCard.ExternalEntryCard, {
91
91
  info: info,
92
92
  ...props
93
93
  });
@@ -98,14 +98,9 @@ function ExternalResourceCardDescription({ subtitle, description }) {
98
98
  }, truncatedDescription));
99
99
  }
100
100
  ExternalResourceCardDescription.displayName = 'ExternalResourceCardDescription';
101
- function ExternalResourceCard({ info, isClickable, onRemove, onMoveTop, onMoveBottom, hasCardEditActions, hasCardMoveActions, hasCardRemoveActions, renderDragHandle, onClick, isSelected }) {
101
+ function ExternalResourceCard({ info, isClickable, onEdit, onRemove, onMoveTop, onMoveBottom, hasCardEditActions, hasCardMoveActions, hasCardRemoveActions, renderDragHandle, onClick, isSelected }) {
102
102
  const { resource: entity, resourceType } = info;
103
103
  const badge = ExternalEntityBadge(entity.fields.badge);
104
- const onEdit = ()=>{
105
- if (entity.fields.externalUrl) {
106
- window.open(entity.fields.externalUrl, '_blank', 'noopener,noreferrer');
107
- }
108
- };
109
104
  return _react.createElement(_f36components.EntryCard, {
110
105
  as: entity.fields.externalUrl ? 'a' : 'article',
111
106
  href: entity.fields.externalUrl,
@@ -152,7 +147,7 @@ function ExternalResourceCard({ info, isClickable, onRemove, onMoveTop, onMoveBo
152
147
  onClick: isClickable ? (e)=>{
153
148
  e.preventDefault();
154
149
  if (onClick) return onClick(e);
155
- onEdit();
150
+ onEdit && onEdit();
156
151
  } : undefined
157
152
  }, _react.createElement(ExternalResourceCardDescription, {
158
153
  subtitle: entity.fields.subtitle,
@@ -0,0 +1,11 @@
1
+ import * as React from 'react';
2
+ import { ExternalResourceCard } from '../ExternalResourceCard/ExternalResourceCard';
3
+ export function ExternalEntryCard(props) {
4
+ const openEntryDetail = ()=>{
5
+ window.open(props.info.resource.fields.externalUrl, '_blank', 'noopener,noreferrer');
6
+ };
7
+ return React.createElement(ExternalResourceCard, {
8
+ ...props,
9
+ onEdit: openEntryDetail
10
+ });
11
+ }
@@ -3,8 +3,8 @@ import { useInView } from 'react-intersection-observer';
3
3
  import { EntryCard } from '@contentful/f36-components';
4
4
  import { isContentfulResourceInfo, useResource } from '../../common/EntityStore';
5
5
  import { ResourceEntityErrorCard } from '../../components';
6
- import { ExternalResourceCard } from '../ExternalResourceCard/ExternalResourceCard';
7
6
  import { ContentfulEntryCard } from './ContentfulEntryCard';
7
+ import { ExternalEntryCard } from './ExternalEntryCard';
8
8
  function ResourceCardSkeleton() {
9
9
  return React.createElement(EntryCard, {
10
10
  size: "small",
@@ -36,7 +36,7 @@ function ExistingResourceCard(props) {
36
36
  ...props
37
37
  });
38
38
  }
39
- return React.createElement(ExternalResourceCard, {
39
+ return React.createElement(ExternalEntryCard, {
40
40
  info: info,
41
41
  ...props
42
42
  });
@@ -42,14 +42,9 @@ function ExternalResourceCardDescription({ subtitle, description }) {
42
42
  }, truncatedDescription));
43
43
  }
44
44
  ExternalResourceCardDescription.displayName = 'ExternalResourceCardDescription';
45
- export function ExternalResourceCard({ info, isClickable, onRemove, onMoveTop, onMoveBottom, hasCardEditActions, hasCardMoveActions, hasCardRemoveActions, renderDragHandle, onClick, isSelected }) {
45
+ export function ExternalResourceCard({ info, isClickable, onEdit, onRemove, onMoveTop, onMoveBottom, hasCardEditActions, hasCardMoveActions, hasCardRemoveActions, renderDragHandle, onClick, isSelected }) {
46
46
  const { resource: entity, resourceType } = info;
47
47
  const badge = ExternalEntityBadge(entity.fields.badge);
48
- const onEdit = ()=>{
49
- if (entity.fields.externalUrl) {
50
- window.open(entity.fields.externalUrl, '_blank', 'noopener,noreferrer');
51
- }
52
- };
53
48
  return React.createElement(EntryCard, {
54
49
  as: entity.fields.externalUrl ? 'a' : 'article',
55
50
  href: entity.fields.externalUrl,
@@ -96,7 +91,7 @@ export function ExternalResourceCard({ info, isClickable, onRemove, onMoveTop, o
96
91
  onClick: isClickable ? (e)=>{
97
92
  e.preventDefault();
98
93
  if (onClick) return onClick(e);
99
- onEdit();
94
+ onEdit && onEdit();
100
95
  } : undefined
101
96
  }, React.createElement(ExternalResourceCardDescription, {
102
97
  subtitle: entity.fields.subtitle,
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import { type ExternalResourceCardProps } from '../ExternalResourceCard/ExternalResourceCard';
3
+ type ExternalEntryCardProps = ExternalResourceCardProps;
4
+ export declare function ExternalEntryCard(props: ExternalEntryCardProps): JSX.Element;
5
+ export {};
@@ -6,6 +6,7 @@ export interface ExternalResourceCardProps {
6
6
  isDisabled: boolean;
7
7
  isSelected?: boolean;
8
8
  onRemove?: () => void;
9
+ onEdit?: () => void;
9
10
  onClick?: (e: React.MouseEvent<HTMLElement>) => void;
10
11
  renderDragHandle?: RenderDragFn;
11
12
  isClickable?: boolean;
@@ -15,7 +16,7 @@ export interface ExternalResourceCardProps {
15
16
  hasCardMoveActions?: boolean;
16
17
  hasCardRemoveActions?: boolean;
17
18
  }
18
- export declare function ExternalResourceCard({ info, isClickable, onRemove, onMoveTop, onMoveBottom, hasCardEditActions, hasCardMoveActions, hasCardRemoveActions, renderDragHandle, onClick, isSelected, }: ExternalResourceCardProps): JSX.Element;
19
+ export declare function ExternalResourceCard({ info, isClickable, onEdit, onRemove, onMoveTop, onMoveBottom, hasCardEditActions, hasCardMoveActions, hasCardRemoveActions, renderDragHandle, onClick, isSelected, }: ExternalResourceCardProps): JSX.Element;
19
20
  export declare namespace ExternalResourceCard {
20
21
  var defaultProps: {
21
22
  isClickable: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/field-editor-reference",
3
- "version": "5.30.2",
3
+ "version": "5.30.3",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "types": "dist/types/index.d.ts",
@@ -65,5 +65,5 @@
65
65
  "publishConfig": {
66
66
  "registry": "https://npm.pkg.github.com/"
67
67
  },
68
- "gitHead": "d6378c31a4dfd237fce1f7290cffaef23162f7e2"
68
+ "gitHead": "759fde7b73a0ae4380021335304b3f387ceedce5"
69
69
  }