@contentful/field-editor-shared 1.4.2 → 1.4.5
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/CharCounter.js +3 -1
- package/dist/cjs/CharValidation.js +4 -2
- package/dist/cjs/FieldConnector.js +4 -2
- package/dist/cjs/FieldConnector.test.js +3 -1
- package/dist/cjs/ModalDialogLauncher.js +8 -6
- package/dist/cjs/PredefinedValuesError.js +3 -1
- package/dist/cjs/index.js +32 -30
- package/dist/cjs/typesEntity.js +5 -5
- package/dist/cjs/utils/entityHelpers.js +24 -25
- package/dist/cjs/utils/shortenStorageUnit.js +4 -4
- package/dist/esm/CharValidation.js +1 -1
- package/dist/esm/FieldConnector.js +1 -1
- package/dist/esm/ModalDialogLauncher.js +2 -2
- package/dist/esm/utils/entityHelpers.js +8 -9
- package/dist/esm/utils/shortenStorageUnit.js +1 -1
- package/dist/types/CharCounter.d.ts +2 -2
- package/dist/types/CharValidation.d.ts +2 -2
- package/dist/types/PredefinedValuesError.d.ts +2 -2
- package/package.json +6 -3
package/dist/cjs/CharCounter.js
CHANGED
|
@@ -37,7 +37,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
37
37
|
if (cache && cache.has(obj)) {
|
|
38
38
|
return cache.get(obj);
|
|
39
39
|
}
|
|
40
|
-
var newObj = {
|
|
40
|
+
var newObj = {
|
|
41
|
+
__proto__: null
|
|
42
|
+
};
|
|
41
43
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
42
44
|
for(var key in obj){
|
|
43
45
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -30,7 +30,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
30
30
|
if (cache && cache.has(obj)) {
|
|
31
31
|
return cache.get(obj);
|
|
32
32
|
}
|
|
33
|
-
var newObj = {
|
|
33
|
+
var newObj = {
|
|
34
|
+
__proto__: null
|
|
35
|
+
};
|
|
34
36
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
35
37
|
for(var key in obj){
|
|
36
38
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -49,7 +51,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
49
51
|
return newObj;
|
|
50
52
|
}
|
|
51
53
|
function CharValidation(props) {
|
|
52
|
-
const { constraints
|
|
54
|
+
const { constraints } = props;
|
|
53
55
|
if (constraints.type === 'max') {
|
|
54
56
|
return _react.createElement("span", null, "Maximum ", constraints.max, " characters");
|
|
55
57
|
} else if (constraints.type === 'min') {
|
|
@@ -50,7 +50,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
50
50
|
if (cache && cache.has(obj)) {
|
|
51
51
|
return cache.get(obj);
|
|
52
52
|
}
|
|
53
|
-
var newObj = {
|
|
53
|
+
var newObj = {
|
|
54
|
+
__proto__: null
|
|
55
|
+
};
|
|
54
56
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
55
57
|
for(var key in obj){
|
|
56
58
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -71,7 +73,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
71
73
|
var _React_Component;
|
|
72
74
|
class FieldConnector extends (_React_Component = _react.Component) {
|
|
73
75
|
componentDidMount() {
|
|
74
|
-
const { field
|
|
76
|
+
const { field } = this.props;
|
|
75
77
|
this.unsubscribeErrors = field.onSchemaErrorsChanged((errors)=>{
|
|
76
78
|
this.setState({
|
|
77
79
|
errors: errors || []
|
|
@@ -33,7 +33,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
33
33
|
if (cache && cache.has(obj)) {
|
|
34
34
|
return cache.get(obj);
|
|
35
35
|
}
|
|
36
|
-
var newObj = {
|
|
36
|
+
var newObj = {
|
|
37
|
+
__proto__: null
|
|
38
|
+
};
|
|
37
39
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
38
40
|
for(var key in obj){
|
|
39
41
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -9,14 +9,14 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
+
default: function() {
|
|
13
|
+
return _default;
|
|
14
|
+
},
|
|
12
15
|
open: function() {
|
|
13
16
|
return open;
|
|
14
17
|
},
|
|
15
18
|
openDialog: function() {
|
|
16
19
|
return openDialog;
|
|
17
|
-
},
|
|
18
|
-
default: function() {
|
|
19
|
-
return _default;
|
|
20
20
|
}
|
|
21
21
|
});
|
|
22
22
|
const _react = _interop_require_wildcard(require("react"));
|
|
@@ -49,7 +49,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
49
49
|
if (cache && cache.has(obj)) {
|
|
50
50
|
return cache.get(obj);
|
|
51
51
|
}
|
|
52
|
-
var newObj = {
|
|
52
|
+
var newObj = {
|
|
53
|
+
__proto__: null
|
|
54
|
+
};
|
|
53
55
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
54
56
|
for(var key in obj){
|
|
55
57
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -82,7 +84,7 @@ function open(componentRenderer) {
|
|
|
82
84
|
onClose,
|
|
83
85
|
isShown: true
|
|
84
86
|
};
|
|
85
|
-
function render({ onClose
|
|
87
|
+
function render({ onClose, isShown }) {
|
|
86
88
|
_reactdom.default.render(componentRenderer({
|
|
87
89
|
onClose,
|
|
88
90
|
isShown
|
|
@@ -103,7 +105,7 @@ function open(componentRenderer) {
|
|
|
103
105
|
function openDialog(options, Component) {
|
|
104
106
|
const key = Date.now();
|
|
105
107
|
const size = (0, _isNumber.default)(options.width) ? `${options.width}px` : options.width;
|
|
106
|
-
return open(({ isShown
|
|
108
|
+
return open(({ isShown, onClose })=>{
|
|
107
109
|
const onCloseHandler = ()=>onClose();
|
|
108
110
|
return _react.createElement(_f36components.Modal, {
|
|
109
111
|
key: key,
|
|
@@ -31,7 +31,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
31
31
|
if (cache && cache.has(obj)) {
|
|
32
32
|
return cache.get(obj);
|
|
33
33
|
}
|
|
34
|
-
var newObj = {
|
|
34
|
+
var newObj = {
|
|
35
|
+
__proto__: null
|
|
36
|
+
};
|
|
35
37
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
36
38
|
for(var key in obj){
|
|
37
39
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
package/dist/cjs/index.js
CHANGED
|
@@ -15,15 +15,30 @@ _export(exports, {
|
|
|
15
15
|
AppConfigAPI: function() {
|
|
16
16
|
return _appsdk.AppConfigAPI;
|
|
17
17
|
},
|
|
18
|
+
Asset: function() {
|
|
19
|
+
return _typesEntity.Asset;
|
|
20
|
+
},
|
|
18
21
|
BaseAppSDK: function() {
|
|
19
22
|
return _appsdk.BaseAppSDK;
|
|
20
23
|
},
|
|
24
|
+
CharCounter: function() {
|
|
25
|
+
return _CharCounter.CharCounter;
|
|
26
|
+
},
|
|
27
|
+
CharValidation: function() {
|
|
28
|
+
return _CharValidation.CharValidation;
|
|
29
|
+
},
|
|
30
|
+
ConstraintsUtils: function() {
|
|
31
|
+
return _constraints;
|
|
32
|
+
},
|
|
21
33
|
ContentType: function() {
|
|
22
34
|
return _appsdk.ContentType;
|
|
23
35
|
},
|
|
24
36
|
DialogsAPI: function() {
|
|
25
37
|
return _appsdk.DialogsAPI;
|
|
26
38
|
},
|
|
39
|
+
Entry: function() {
|
|
40
|
+
return _typesEntity.Entry;
|
|
41
|
+
},
|
|
27
42
|
EntryAPI: function() {
|
|
28
43
|
return _appsdk.EntryAPI;
|
|
29
44
|
},
|
|
@@ -36,6 +51,12 @@ _export(exports, {
|
|
|
36
51
|
FieldAppSDK: function() {
|
|
37
52
|
return _appsdk.FieldAppSDK;
|
|
38
53
|
},
|
|
54
|
+
FieldConnector: function() {
|
|
55
|
+
return _FieldConnector.FieldConnector;
|
|
56
|
+
},
|
|
57
|
+
File: function() {
|
|
58
|
+
return _typesEntity.File;
|
|
59
|
+
},
|
|
39
60
|
IdsAPI: function() {
|
|
40
61
|
return _appsdk.IdsAPI;
|
|
41
62
|
},
|
|
@@ -45,6 +66,9 @@ _export(exports, {
|
|
|
45
66
|
LocationAPI: function() {
|
|
46
67
|
return _appsdk.LocationAPI;
|
|
47
68
|
},
|
|
69
|
+
ModalDialogLauncher: function() {
|
|
70
|
+
return _ModalDialogLauncher;
|
|
71
|
+
},
|
|
48
72
|
NavigatorAPI: function() {
|
|
49
73
|
return _appsdk.NavigatorAPI;
|
|
50
74
|
},
|
|
@@ -57,32 +81,17 @@ _export(exports, {
|
|
|
57
81
|
ParametersAPI: function() {
|
|
58
82
|
return _appsdk.ParametersAPI;
|
|
59
83
|
},
|
|
84
|
+
PredefinedValuesError: function() {
|
|
85
|
+
return _PredefinedValuesError.PredefinedValuesError;
|
|
86
|
+
},
|
|
60
87
|
SpaceAPI: function() {
|
|
61
88
|
return _appsdk.SpaceAPI;
|
|
62
89
|
},
|
|
63
90
|
WindowAPI: function() {
|
|
64
91
|
return _appsdk.WindowAPI;
|
|
65
92
|
},
|
|
66
|
-
|
|
67
|
-
return
|
|
68
|
-
},
|
|
69
|
-
CharValidation: function() {
|
|
70
|
-
return _CharValidation.CharValidation;
|
|
71
|
-
},
|
|
72
|
-
FieldConnector: function() {
|
|
73
|
-
return _FieldConnector.FieldConnector;
|
|
74
|
-
},
|
|
75
|
-
PredefinedValuesError: function() {
|
|
76
|
-
return _PredefinedValuesError.PredefinedValuesError;
|
|
77
|
-
},
|
|
78
|
-
Asset: function() {
|
|
79
|
-
return _typesEntity.Asset;
|
|
80
|
-
},
|
|
81
|
-
Entry: function() {
|
|
82
|
-
return _typesEntity.Entry;
|
|
83
|
-
},
|
|
84
|
-
File: function() {
|
|
85
|
-
return _typesEntity.File;
|
|
93
|
+
entityHelpers: function() {
|
|
94
|
+
return _entityHelpers;
|
|
86
95
|
},
|
|
87
96
|
isValidImage: function() {
|
|
88
97
|
return _isValidImage.isValidImage;
|
|
@@ -92,15 +101,6 @@ _export(exports, {
|
|
|
92
101
|
},
|
|
93
102
|
toLocaleString: function() {
|
|
94
103
|
return _shortenStorageUnit.toLocaleString;
|
|
95
|
-
},
|
|
96
|
-
ModalDialogLauncher: function() {
|
|
97
|
-
return _ModalDialogLauncher;
|
|
98
|
-
},
|
|
99
|
-
entityHelpers: function() {
|
|
100
|
-
return _entityHelpers;
|
|
101
|
-
},
|
|
102
|
-
ConstraintsUtils: function() {
|
|
103
|
-
return _constraints;
|
|
104
104
|
}
|
|
105
105
|
});
|
|
106
106
|
const _appsdk = require("@contentful/app-sdk");
|
|
@@ -135,7 +135,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
135
135
|
if (cache && cache.has(obj)) {
|
|
136
136
|
return cache.get(obj);
|
|
137
137
|
}
|
|
138
|
-
var newObj = {
|
|
138
|
+
var newObj = {
|
|
139
|
+
__proto__: null
|
|
140
|
+
};
|
|
139
141
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
140
142
|
for(var key in obj){
|
|
141
143
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
package/dist/cjs/typesEntity.js
CHANGED
|
@@ -9,6 +9,9 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
+
Asset: function() {
|
|
13
|
+
return _appsdk.Asset;
|
|
14
|
+
},
|
|
12
15
|
BaseAppSDK: function() {
|
|
13
16
|
return _appsdk.BaseAppSDK;
|
|
14
17
|
},
|
|
@@ -18,14 +21,11 @@ _export(exports, {
|
|
|
18
21
|
ContentTypeField: function() {
|
|
19
22
|
return _appsdk.ContentTypeField;
|
|
20
23
|
},
|
|
21
|
-
Link: function() {
|
|
22
|
-
return _appsdk.Link;
|
|
23
|
-
},
|
|
24
24
|
Entry: function() {
|
|
25
25
|
return _appsdk.Entry;
|
|
26
26
|
},
|
|
27
|
-
|
|
28
|
-
return _appsdk.
|
|
27
|
+
Link: function() {
|
|
28
|
+
return _appsdk.Link;
|
|
29
29
|
}
|
|
30
30
|
});
|
|
31
31
|
const _appsdk = require("@contentful/app-sdk");
|
|
@@ -9,44 +9,43 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
getFieldValue: function() {
|
|
13
|
-
return getFieldValue;
|
|
14
|
-
},
|
|
15
12
|
getAssetTitle: function() {
|
|
16
13
|
return getAssetTitle;
|
|
17
14
|
},
|
|
18
|
-
isAssetField: function() {
|
|
19
|
-
return isAssetField;
|
|
20
|
-
},
|
|
21
|
-
isDisplayField: function() {
|
|
22
|
-
return isDisplayField;
|
|
23
|
-
},
|
|
24
|
-
isDescriptionField: function() {
|
|
25
|
-
return isDescriptionField;
|
|
26
|
-
},
|
|
27
15
|
getEntityDescription: function() {
|
|
28
16
|
return getEntityDescription;
|
|
29
17
|
},
|
|
30
|
-
|
|
31
|
-
return
|
|
18
|
+
getEntryImage: function() {
|
|
19
|
+
return getEntryImage;
|
|
32
20
|
},
|
|
33
21
|
getEntryStatus: function() {
|
|
34
22
|
return getEntryStatus;
|
|
35
23
|
},
|
|
36
|
-
|
|
37
|
-
return
|
|
24
|
+
getEntryTitle: function() {
|
|
25
|
+
return getEntryTitle;
|
|
26
|
+
},
|
|
27
|
+
getFieldValue: function() {
|
|
28
|
+
return getFieldValue;
|
|
29
|
+
},
|
|
30
|
+
isAssetField: function() {
|
|
31
|
+
return isAssetField;
|
|
32
|
+
},
|
|
33
|
+
isDescriptionField: function() {
|
|
34
|
+
return isDescriptionField;
|
|
35
|
+
},
|
|
36
|
+
isDisplayField: function() {
|
|
37
|
+
return isDisplayField;
|
|
38
38
|
}
|
|
39
39
|
});
|
|
40
40
|
const _get = _interop_require_default(require("lodash/get"));
|
|
41
41
|
const _isObject = _interop_require_default(require("lodash/isObject"));
|
|
42
|
-
const _isString = _interop_require_default(require("lodash/isString"));
|
|
43
42
|
function _interop_require_default(obj) {
|
|
44
43
|
return obj && obj.__esModule ? obj : {
|
|
45
44
|
default: obj
|
|
46
45
|
};
|
|
47
46
|
}
|
|
48
47
|
function titleOrDefault(title, defaultTitle) {
|
|
49
|
-
if (!(
|
|
48
|
+
if (!(title != null && typeof title.valueOf() === 'string')) {
|
|
50
49
|
return defaultTitle;
|
|
51
50
|
}
|
|
52
51
|
if (title) {
|
|
@@ -58,7 +57,7 @@ function titleOrDefault(title, defaultTitle) {
|
|
|
58
57
|
}
|
|
59
58
|
return defaultTitle;
|
|
60
59
|
}
|
|
61
|
-
function getFieldValue({ entity
|
|
60
|
+
function getFieldValue({ entity, fieldId, localeCode, defaultLocaleCode }) {
|
|
62
61
|
const values = (0, _get.default)(entity, [
|
|
63
62
|
'fields',
|
|
64
63
|
fieldId
|
|
@@ -69,7 +68,7 @@ function getFieldValue({ entity , fieldId , localeCode , defaultLocaleCode }) {
|
|
|
69
68
|
const firstLocaleCode = Object.keys(values)[0];
|
|
70
69
|
return values[localeCode] || values[defaultLocaleCode] || values[firstLocaleCode];
|
|
71
70
|
}
|
|
72
|
-
function getAssetTitle({ asset
|
|
71
|
+
function getAssetTitle({ asset, localeCode, defaultLocaleCode, defaultTitle }) {
|
|
73
72
|
const title = getFieldValue({
|
|
74
73
|
entity: {
|
|
75
74
|
fields: {
|
|
@@ -83,10 +82,10 @@ function getAssetTitle({ asset , localeCode , defaultLocaleCode , defaultTitle
|
|
|
83
82
|
return titleOrDefault(title, defaultTitle);
|
|
84
83
|
}
|
|
85
84
|
const isAssetField = (field)=>field.type === 'Link' && field.linkType === 'Asset';
|
|
86
|
-
function isDisplayField({ field
|
|
85
|
+
function isDisplayField({ field, contentType }) {
|
|
87
86
|
return field.id === contentType.displayField;
|
|
88
87
|
}
|
|
89
|
-
function isDescriptionField({ field
|
|
88
|
+
function isDescriptionField({ field, contentType }) {
|
|
90
89
|
const isTextField = (field)=>[
|
|
91
90
|
'Symbol',
|
|
92
91
|
'Text'
|
|
@@ -97,7 +96,7 @@ function isDescriptionField({ field , contentType }) {
|
|
|
97
96
|
contentType
|
|
98
97
|
}) && !isMaybeSlugField(field);
|
|
99
98
|
}
|
|
100
|
-
function getEntityDescription({ entity
|
|
99
|
+
function getEntityDescription({ entity, contentType, localeCode, defaultLocaleCode }) {
|
|
101
100
|
if (!contentType) {
|
|
102
101
|
return '';
|
|
103
102
|
}
|
|
@@ -115,7 +114,7 @@ function getEntityDescription({ entity , contentType , localeCode , defaultLocal
|
|
|
115
114
|
defaultLocaleCode
|
|
116
115
|
}) || '';
|
|
117
116
|
}
|
|
118
|
-
function getEntryTitle({ entry
|
|
117
|
+
function getEntryTitle({ entry, contentType, localeCode, defaultLocaleCode, defaultTitle }) {
|
|
119
118
|
let title;
|
|
120
119
|
if (!contentType) {
|
|
121
120
|
return defaultTitle;
|
|
@@ -179,7 +178,7 @@ function getEntryStatus(sys) {
|
|
|
179
178
|
return 'draft';
|
|
180
179
|
}
|
|
181
180
|
}
|
|
182
|
-
const getEntryImage = async ({ entry
|
|
181
|
+
const getEntryImage = async ({ entry, contentType, localeCode }, getAsset)=>{
|
|
183
182
|
if (!contentType) {
|
|
184
183
|
return null;
|
|
185
184
|
}
|
|
@@ -9,11 +9,11 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
toLocaleString: function() {
|
|
13
|
-
return toLocaleString;
|
|
14
|
-
},
|
|
15
12
|
shortenStorageUnit: function() {
|
|
16
13
|
return shortenStorageUnit;
|
|
14
|
+
},
|
|
15
|
+
toLocaleString: function() {
|
|
16
|
+
return toLocaleString;
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
19
|
function toLocaleString(number) {
|
|
@@ -50,6 +50,6 @@ function shortenStorageUnit(value, uom) {
|
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
52
|
};
|
|
53
|
-
const { number
|
|
53
|
+
const { number, unit } = reduce(value, uom);
|
|
54
54
|
return `${formatFloat(number, false)} ${unit}`;
|
|
55
55
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
export function CharValidation(props) {
|
|
3
|
-
const { constraints
|
|
3
|
+
const { constraints } = props;
|
|
4
4
|
if (constraints.type === 'max') {
|
|
5
5
|
return React.createElement("span", null, "Maximum ", constraints.max, " characters");
|
|
6
6
|
} else if (constraints.type === 'min') {
|
|
@@ -17,7 +17,7 @@ import isEqual from 'lodash/isEqual';
|
|
|
17
17
|
var _React_Component;
|
|
18
18
|
export class FieldConnector extends (_React_Component = React.Component) {
|
|
19
19
|
componentDidMount() {
|
|
20
|
-
const { field
|
|
20
|
+
const { field } = this.props;
|
|
21
21
|
this.unsubscribeErrors = field.onSchemaErrorsChanged((errors)=>{
|
|
22
22
|
this.setState({
|
|
23
23
|
errors: errors || []
|
|
@@ -17,7 +17,7 @@ export function open(componentRenderer) {
|
|
|
17
17
|
onClose,
|
|
18
18
|
isShown: true
|
|
19
19
|
};
|
|
20
|
-
function render({ onClose
|
|
20
|
+
function render({ onClose, isShown }) {
|
|
21
21
|
ReactDOM.render(componentRenderer({
|
|
22
22
|
onClose,
|
|
23
23
|
isShown
|
|
@@ -38,7 +38,7 @@ export function open(componentRenderer) {
|
|
|
38
38
|
export function openDialog(options, Component) {
|
|
39
39
|
const key = Date.now();
|
|
40
40
|
const size = isNumber(options.width) ? `${options.width}px` : options.width;
|
|
41
|
-
return open(({ isShown
|
|
41
|
+
return open(({ isShown, onClose })=>{
|
|
42
42
|
const onCloseHandler = ()=>onClose();
|
|
43
43
|
return React.createElement(Modal, {
|
|
44
44
|
key: key,
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import get from 'lodash/get';
|
|
2
2
|
import isObject from 'lodash/isObject';
|
|
3
|
-
import isString from 'lodash/isString';
|
|
4
3
|
function titleOrDefault(title, defaultTitle) {
|
|
5
|
-
if (!
|
|
4
|
+
if (!(title != null && typeof title.valueOf() === 'string')) {
|
|
6
5
|
return defaultTitle;
|
|
7
6
|
}
|
|
8
7
|
if (title) {
|
|
@@ -14,7 +13,7 @@ function titleOrDefault(title, defaultTitle) {
|
|
|
14
13
|
}
|
|
15
14
|
return defaultTitle;
|
|
16
15
|
}
|
|
17
|
-
export function getFieldValue({ entity
|
|
16
|
+
export function getFieldValue({ entity, fieldId, localeCode, defaultLocaleCode }) {
|
|
18
17
|
const values = get(entity, [
|
|
19
18
|
'fields',
|
|
20
19
|
fieldId
|
|
@@ -25,7 +24,7 @@ export function getFieldValue({ entity , fieldId , localeCode , defaultLocaleCod
|
|
|
25
24
|
const firstLocaleCode = Object.keys(values)[0];
|
|
26
25
|
return values[localeCode] || values[defaultLocaleCode] || values[firstLocaleCode];
|
|
27
26
|
}
|
|
28
|
-
export function getAssetTitle({ asset
|
|
27
|
+
export function getAssetTitle({ asset, localeCode, defaultLocaleCode, defaultTitle }) {
|
|
29
28
|
const title = getFieldValue({
|
|
30
29
|
entity: {
|
|
31
30
|
fields: {
|
|
@@ -39,10 +38,10 @@ export function getAssetTitle({ asset , localeCode , defaultLocaleCode , default
|
|
|
39
38
|
return titleOrDefault(title, defaultTitle);
|
|
40
39
|
}
|
|
41
40
|
export const isAssetField = (field)=>field.type === 'Link' && field.linkType === 'Asset';
|
|
42
|
-
export function isDisplayField({ field
|
|
41
|
+
export function isDisplayField({ field, contentType }) {
|
|
43
42
|
return field.id === contentType.displayField;
|
|
44
43
|
}
|
|
45
|
-
export function isDescriptionField({ field
|
|
44
|
+
export function isDescriptionField({ field, contentType }) {
|
|
46
45
|
const isTextField = (field)=>[
|
|
47
46
|
'Symbol',
|
|
48
47
|
'Text'
|
|
@@ -53,7 +52,7 @@ export function isDescriptionField({ field , contentType }) {
|
|
|
53
52
|
contentType
|
|
54
53
|
}) && !isMaybeSlugField(field);
|
|
55
54
|
}
|
|
56
|
-
export function getEntityDescription({ entity
|
|
55
|
+
export function getEntityDescription({ entity, contentType, localeCode, defaultLocaleCode }) {
|
|
57
56
|
if (!contentType) {
|
|
58
57
|
return '';
|
|
59
58
|
}
|
|
@@ -71,7 +70,7 @@ export function getEntityDescription({ entity , contentType , localeCode , defau
|
|
|
71
70
|
defaultLocaleCode
|
|
72
71
|
}) || '';
|
|
73
72
|
}
|
|
74
|
-
export function getEntryTitle({ entry
|
|
73
|
+
export function getEntryTitle({ entry, contentType, localeCode, defaultLocaleCode, defaultTitle }) {
|
|
75
74
|
let title;
|
|
76
75
|
if (!contentType) {
|
|
77
76
|
return defaultTitle;
|
|
@@ -135,7 +134,7 @@ export function getEntryStatus(sys) {
|
|
|
135
134
|
return 'draft';
|
|
136
135
|
}
|
|
137
136
|
}
|
|
138
|
-
export const getEntryImage = async ({ entry
|
|
137
|
+
export const getEntryImage = async ({ entry, contentType, localeCode }, getAsset)=>{
|
|
139
138
|
if (!contentType) {
|
|
140
139
|
return null;
|
|
141
140
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
interface CharCounterProps {
|
|
3
3
|
value?: string;
|
|
4
4
|
checkConstraint: (n: number) => boolean;
|
|
5
5
|
}
|
|
6
|
-
export declare function CharCounter(props: CharCounterProps):
|
|
6
|
+
export declare function CharCounter(props: CharCounterProps): JSX.Element;
|
|
7
7
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import { ValidationType } from './types';
|
|
3
3
|
interface CharValidationProps {
|
|
4
4
|
constraints: ValidationType;
|
|
5
5
|
}
|
|
6
|
-
export declare function CharValidation(props: CharValidationProps):
|
|
6
|
+
export declare function CharValidation(props: CharValidationProps): JSX.Element;
|
|
7
7
|
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function PredefinedValuesError():
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare function PredefinedValuesError(): JSX.Element;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/field-editor-shared",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.5",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@contentful/app-sdk": "^4.17.1",
|
|
39
|
-
"@contentful/field-editor-test-utils": "^1.4.
|
|
39
|
+
"@contentful/field-editor-test-utils": "^1.4.6"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@contentful/f36-note": "^4.2.8",
|
|
@@ -48,5 +48,8 @@
|
|
|
48
48
|
"@contentful/app-sdk": "^4.17.1",
|
|
49
49
|
"react": ">=16.8.0"
|
|
50
50
|
},
|
|
51
|
-
"
|
|
51
|
+
"publishConfig": {
|
|
52
|
+
"registry": "https://npm.pkg.github.com/"
|
|
53
|
+
},
|
|
54
|
+
"gitHead": "142d2039f023bf4ced956aae1dd08b27c35fdbaa"
|
|
52
55
|
}
|