@contentful/field-editor-reference 7.0.1 → 7.0.2-canary.12

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.
@@ -82,7 +82,8 @@ function Editor(props) {
82
82
  const items = _react.useMemo(()=>{
83
83
  return (props.items || []).map((link)=>link || nullableValue);
84
84
  }, [
85
- props.items
85
+ props.items,
86
+ props.items.length
86
87
  ]);
87
88
  const { rearrangeSortIDs } = (0, _useSortIDs.useSortIDs)(items);
88
89
  const onSortStart = (0, _react.useCallback)(()=>{
@@ -140,7 +141,8 @@ function Editor(props) {
140
141
  onSortStart,
141
142
  onSortEnd,
142
143
  onMove,
143
- renderCustomCard: props.renderCustomCard && customCardRenderer
144
+ renderCustomCard: props.renderCustomCard && customCardRenderer,
145
+ items
144
146
  }), /*#__PURE__*/ _react.createElement(_components.LinkEntityActions, {
145
147
  renderCustomActions: props.renderCustomActions,
146
148
  ...linkActionsProps
@@ -63,8 +63,18 @@ function _interop_require_wildcard(obj, nodeInterop) {
63
63
  }
64
64
  return newObj;
65
65
  }
66
+ const nullableValue = {
67
+ sys: {
68
+ type: 'ResourceLink',
69
+ urn: 'null-value'
70
+ }
71
+ };
66
72
  function ResourceEditor(props) {
67
- const { setValue, items } = props;
73
+ const { setValue } = props;
74
+ const items = _react.useMemo(()=>(props.items || []).map((link)=>link || nullableValue), [
75
+ props.items,
76
+ props.items.length
77
+ ]);
68
78
  const onSortStart = ()=>(0, _noop.default)();
69
79
  const onSortEnd = (0, _react.useCallback)(({ oldIndex, newIndex })=>{
70
80
  const newItems = (0, _sortable.arrayMove)(items, oldIndex, newIndex);
@@ -92,6 +102,7 @@ function ResourceEditor(props) {
92
102
  });
93
103
  return /*#__PURE__*/ _react.createElement(_react.Fragment, null, props.children({
94
104
  ...props,
105
+ items,
95
106
  onSortStart,
96
107
  onSortEnd,
97
108
  onMove,
@@ -32,7 +32,8 @@ function Editor(props) {
32
32
  const items = React.useMemo(()=>{
33
33
  return (props.items || []).map((link)=>link || nullableValue);
34
34
  }, [
35
- props.items
35
+ props.items,
36
+ props.items.length
36
37
  ]);
37
38
  const { rearrangeSortIDs } = useSortIDs(items);
38
39
  const onSortStart = useCallback(()=>{
@@ -90,7 +91,8 @@ function Editor(props) {
90
91
  onSortStart,
91
92
  onSortEnd,
92
93
  onMove,
93
- renderCustomCard: props.renderCustomCard && customCardRenderer
94
+ renderCustomCard: props.renderCustomCard && customCardRenderer,
95
+ items
94
96
  }), /*#__PURE__*/ React.createElement(LinkEntityActions, {
95
97
  renderCustomActions: props.renderCustomActions,
96
98
  ...linkActionsProps
@@ -8,8 +8,18 @@ import { SortableLinkList } from '../common/SortableLinkList';
8
8
  import { CombinedLinkEntityActions } from '../components/LinkActions/LinkEntityActions';
9
9
  import { ResourceCard } from './Cards/ResourceCard';
10
10
  import { useResourceLinkActions } from './useResourceLinkActions';
11
+ const nullableValue = {
12
+ sys: {
13
+ type: 'ResourceLink',
14
+ urn: 'null-value'
15
+ }
16
+ };
11
17
  function ResourceEditor(props) {
12
- const { setValue, items } = props;
18
+ const { setValue } = props;
19
+ const items = React.useMemo(()=>(props.items || []).map((link)=>link || nullableValue), [
20
+ props.items,
21
+ props.items.length
22
+ ]);
13
23
  const onSortStart = ()=>noop();
14
24
  const onSortEnd = useCallback(({ oldIndex, newIndex })=>{
15
25
  const newItems = arrayMove(items, oldIndex, newIndex);
@@ -37,6 +47,7 @@ function ResourceEditor(props) {
37
47
  });
38
48
  return /*#__PURE__*/ React.createElement(React.Fragment, null, props.children({
39
49
  ...props,
50
+ items,
40
51
  onSortStart,
41
52
  onSortEnd,
42
53
  onMove,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/field-editor-reference",
3
- "version": "7.0.1",
3
+ "version": "7.0.2-canary.12+a033ba5a",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "types": "dist/types/index.d.ts",
@@ -39,7 +39,7 @@
39
39
  "@contentful/f36-components": "^6.7.1",
40
40
  "@contentful/f36-icons": "^6.7.1",
41
41
  "@contentful/f36-tokens": "^6.1.2",
42
- "@contentful/field-editor-shared": "^3.0.1",
42
+ "@contentful/field-editor-shared": "^3.0.2-canary.12+a033ba5a",
43
43
  "@contentful/mimetype": "^2.2.29",
44
44
  "@dnd-kit/core": "^6.0.8",
45
45
  "@dnd-kit/sortable": "^8.0.0",
@@ -69,5 +69,5 @@
69
69
  "publishConfig": {
70
70
  "registry": "https://npm.pkg.github.com/"
71
71
  },
72
- "gitHead": "79ea20201fece746a4835e16854024616b81e184"
72
+ "gitHead": "a033ba5aa402ff68a0ee2da3dc1ca39c46795eed"
73
73
  }