@contentful/field-editor-shared 2.4.0 → 2.4.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/CharCounter.js +2 -2
- package/dist/cjs/CharValidation.js +1 -1
- package/dist/cjs/FieldConnector.js +7 -14
- package/dist/cjs/FieldConnector.test.js +29 -7
- package/dist/cjs/LocalePublishingEntityStatusBadge/Banner.js +2 -2
- package/dist/cjs/LocalePublishingEntityStatusBadge/LocalePublishingPopover.js +3 -3
- package/dist/cjs/LocalePublishingEntityStatusBadge/LocalePublishingStatus.js +2 -2
- package/dist/cjs/LocalePublishingEntityStatusBadge/LocalePublishingStatusList.js +3 -3
- package/dist/cjs/LocalePublishingEntityStatusBadge/ScheduledBanner.js +6 -6
- package/dist/cjs/ModalDialogLauncher.js +3 -3
- package/dist/cjs/PredefinedValuesError.js +1 -1
- package/dist/cjs/hooks/useLocalePublishStatus.js +1 -1
- package/dist/cjs/hooks/useLocalePublishStatus.spec.js +1 -1
- package/dist/cjs/index.js +3 -3
- package/dist/cjs/utils/constraints.js +1 -1
- package/dist/cjs/utils/entityHelpers.js +2 -2
- package/dist/esm/FieldConnector.js +4 -11
- package/dist/esm/FieldConnector.test.js +27 -5
- package/dist/esm/LocalePublishingEntityStatusBadge/LocalePublishingStatusList.js +1 -1
- package/dist/esm/LocalePublishingEntityStatusBadge/ScheduledBanner.js +4 -4
- package/dist/esm/hooks/useLocalePublishStatus.spec.js +1 -1
- package/package.json +2 -2
package/dist/cjs/CharCounter.js
CHANGED
|
@@ -8,8 +8,8 @@ Object.defineProperty(exports, "CharCounter", {
|
|
|
8
8
|
return CharCounter;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
-
const _react = _interop_require_wildcard(require("react"));
|
|
12
|
-
const _f36tokens = _interop_require_default(require("@contentful/f36-tokens"));
|
|
11
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
12
|
+
const _f36tokens = /*#__PURE__*/ _interop_require_default(require("@contentful/f36-tokens"));
|
|
13
13
|
const _emotion = require("emotion");
|
|
14
14
|
function _interop_require_default(obj) {
|
|
15
15
|
return obj && obj.__esModule ? obj : {
|
|
@@ -8,7 +8,7 @@ Object.defineProperty(exports, "CharValidation", {
|
|
|
8
8
|
return CharValidation;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
-
const _react = _interop_require_wildcard(require("react"));
|
|
11
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
12
12
|
function _getRequireWildcardCache(nodeInterop) {
|
|
13
13
|
if (typeof WeakMap !== "function") return null;
|
|
14
14
|
var cacheBabelInterop = new WeakMap();
|
|
@@ -8,9 +8,9 @@ Object.defineProperty(exports, "FieldConnector", {
|
|
|
8
8
|
return FieldConnector;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
-
const _react = _interop_require_wildcard(require("react"));
|
|
12
|
-
const _fastdeepequal = _interop_require_default(require("fast-deep-equal"));
|
|
13
|
-
const _debounce = _interop_require_default(require("lodash/debounce"));
|
|
11
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
12
|
+
const _fastdeepequal = /*#__PURE__*/ _interop_require_default(require("fast-deep-equal"));
|
|
13
|
+
const _debounce = /*#__PURE__*/ _interop_require_default(require("lodash/debounce"));
|
|
14
14
|
function _define_property(obj, key, value) {
|
|
15
15
|
if (key in obj) {
|
|
16
16
|
Object.defineProperty(obj, key, {
|
|
@@ -117,12 +117,7 @@ class FieldConnector extends (_React_Component = _react.Component) {
|
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
119
|
constructor(props){
|
|
120
|
-
super(props)
|
|
121
|
-
_define_property(this, "unsubscribeErrors", null);
|
|
122
|
-
_define_property(this, "unsubscribeDisabled", null);
|
|
123
|
-
_define_property(this, "unsubscribeValue", null);
|
|
124
|
-
_define_property(this, "getDebounceDuration", ()=>'debounce' in this.props ? this.props.debounce : this.props.throttle);
|
|
125
|
-
_define_property(this, "setValue", async (value)=>{
|
|
120
|
+
super(props), _define_property(this, "unsubscribeErrors", null), _define_property(this, "unsubscribeDisabled", null), _define_property(this, "unsubscribeValue", null), _define_property(this, "getDebounceDuration", ()=>'debounce' in this.props ? this.props.debounce : this.props.throttle), _define_property(this, "setValue", async (value)=>{
|
|
126
121
|
if (this.props.isEmptyValue(value ?? null)) {
|
|
127
122
|
this.setState({
|
|
128
123
|
value: undefined
|
|
@@ -137,8 +132,7 @@ class FieldConnector extends (_React_Component = _react.Component) {
|
|
|
137
132
|
} else {
|
|
138
133
|
await this.debouncedTriggerSetValueCallbacks(value);
|
|
139
134
|
}
|
|
140
|
-
})
|
|
141
|
-
_define_property(this, "triggerSetValueCallbacks", (value)=>{
|
|
135
|
+
}), _define_property(this, "triggerSetValueCallbacks", (value)=>{
|
|
142
136
|
return new Promise((resolve, reject)=>{
|
|
143
137
|
if (this.props.isEmptyValue(value ?? null)) {
|
|
144
138
|
this.props.field.removeValue().then(resolve).catch(reject);
|
|
@@ -146,15 +140,14 @@ class FieldConnector extends (_React_Component = _react.Component) {
|
|
|
146
140
|
this.props.field.setValue(value).then(resolve).catch(reject);
|
|
147
141
|
}
|
|
148
142
|
});
|
|
149
|
-
});
|
|
150
|
-
_define_property(this, "debouncedTriggerSetValueCallbacks", (0, _debounce.default)(this.triggerSetValueCallbacks, this.getDebounceDuration()));
|
|
143
|
+
}), _define_property(this, "debouncedTriggerSetValueCallbacks", (0, _debounce.default)(this.triggerSetValueCallbacks, this.getDebounceDuration()));
|
|
151
144
|
const initialValue = props.field.getValue();
|
|
152
145
|
this.state = {
|
|
153
146
|
isLocalValueChange: false,
|
|
154
147
|
externalReset: 0,
|
|
155
148
|
value: initialValue,
|
|
156
149
|
lastRemoteValue: initialValue,
|
|
157
|
-
disabled: props.isInitiallyDisabled
|
|
150
|
+
disabled: props.isInitiallyDisabled || props.field.getIsDisabled(),
|
|
158
151
|
errors: []
|
|
159
152
|
};
|
|
160
153
|
}
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
const _react = _interop_require_wildcard(require("react"));
|
|
5
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
6
6
|
const _fieldeditortestutils = require("@contentful/field-editor-test-utils");
|
|
7
7
|
const _react1 = require("@testing-library/react");
|
|
8
|
-
const _noop = _interop_require_default(require("lodash/noop"));
|
|
8
|
+
const _noop = /*#__PURE__*/ _interop_require_default(require("lodash/noop"));
|
|
9
9
|
const _FieldConnector = require("./FieldConnector");
|
|
10
10
|
function _interop_require_default(obj) {
|
|
11
11
|
return obj && obj.__esModule ? obj : {
|
|
@@ -53,10 +53,10 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
53
53
|
}
|
|
54
54
|
return newObj;
|
|
55
55
|
}
|
|
56
|
+
function getChild(children) {
|
|
57
|
+
return children.mock.calls[children.mock.calls.length - 1][0];
|
|
58
|
+
}
|
|
56
59
|
it('does not rerender with outdated value after calling setValue', async ()=>{
|
|
57
|
-
function getChild() {
|
|
58
|
-
return props.children.mock.calls[props.children.mock.calls.length - 1][0];
|
|
59
|
-
}
|
|
60
60
|
const onSchemaErrorsChanged = jest.fn();
|
|
61
61
|
const [field] = (0, _fieldeditortestutils.createFakeFieldAPI)((field)=>{
|
|
62
62
|
return {
|
|
@@ -72,14 +72,36 @@ it('does not rerender with outdated value after calling setValue', async ()=>{
|
|
|
72
72
|
debounce: 0
|
|
73
73
|
};
|
|
74
74
|
(0, _react1.render)(_react.createElement(_FieldConnector.FieldConnector, props));
|
|
75
|
-
let child = getChild();
|
|
75
|
+
let child = getChild(props.children);
|
|
76
76
|
expect(child.value).toBe('initial value');
|
|
77
77
|
const initialRenderCount = props.children.mock.calls.length;
|
|
78
78
|
await (0, _react1.act)(async ()=>{
|
|
79
79
|
child.setValue('new value');
|
|
80
80
|
});
|
|
81
81
|
onSchemaErrorsChanged.mock.calls.forEach(([cb])=>cb([]));
|
|
82
|
-
child = getChild();
|
|
82
|
+
child = getChild(props.children);
|
|
83
83
|
expect(child.value).toBe('new value');
|
|
84
84
|
expect(props.children.mock.calls.length).toBeGreaterThan(initialRenderCount);
|
|
85
85
|
});
|
|
86
|
+
it('takes initial disable state from sdk.field', ()=>{
|
|
87
|
+
const [field] = (0, _fieldeditortestutils.createFakeFieldAPI)((field)=>{
|
|
88
|
+
return {
|
|
89
|
+
...field,
|
|
90
|
+
getIsDisabled: jest.fn().mockReturnValue(true)
|
|
91
|
+
};
|
|
92
|
+
}, 'initial value');
|
|
93
|
+
const props = {
|
|
94
|
+
isInitiallyDisabled: false,
|
|
95
|
+
children: jest.fn().mockImplementation(()=>null),
|
|
96
|
+
field,
|
|
97
|
+
debounce: 0
|
|
98
|
+
};
|
|
99
|
+
(0, _react1.render)(_react.createElement(_FieldConnector.FieldConnector, props));
|
|
100
|
+
const child = getChild(props.children);
|
|
101
|
+
expect(child.value).toBe('initial value');
|
|
102
|
+
expect(field.getIsDisabled).toHaveBeenCalled();
|
|
103
|
+
expect(props.children).toHaveBeenCalledTimes(1);
|
|
104
|
+
expect(props.children).toHaveBeenCalledWith(expect.objectContaining({
|
|
105
|
+
disabled: true
|
|
106
|
+
}));
|
|
107
|
+
});
|
|
@@ -8,9 +8,9 @@ Object.defineProperty(exports, "Banner", {
|
|
|
8
8
|
return Banner;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
-
const _react = _interop_require_default(require("react"));
|
|
11
|
+
const _react = /*#__PURE__*/ _interop_require_default(require("react"));
|
|
12
12
|
const _f36components = require("@contentful/f36-components");
|
|
13
|
-
const _f36tokens = _interop_require_default(require("@contentful/f36-tokens"));
|
|
13
|
+
const _f36tokens = /*#__PURE__*/ _interop_require_default(require("@contentful/f36-tokens"));
|
|
14
14
|
const _emotion = require("emotion");
|
|
15
15
|
function _interop_require_default(obj) {
|
|
16
16
|
return obj && obj.__esModule ? obj : {
|
|
@@ -8,11 +8,11 @@ Object.defineProperty(exports, "LocalePublishingPopover", {
|
|
|
8
8
|
return LocalePublishingPopover;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
-
const _react = _interop_require_wildcard(require("react"));
|
|
11
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
12
12
|
const _f36components = require("@contentful/f36-components");
|
|
13
|
-
const _f36tokens = _interop_require_default(require("@contentful/f36-tokens"));
|
|
13
|
+
const _f36tokens = /*#__PURE__*/ _interop_require_default(require("@contentful/f36-tokens"));
|
|
14
14
|
const _emotion = require("emotion");
|
|
15
|
-
const _entityHelpers = _interop_require_wildcard(require("../utils/entityHelpers"));
|
|
15
|
+
const _entityHelpers = /*#__PURE__*/ _interop_require_wildcard(require("../utils/entityHelpers"));
|
|
16
16
|
const _LocalePublishingStatusList = require("./LocalePublishingStatusList");
|
|
17
17
|
const _ScheduledBanner = require("./ScheduledBanner");
|
|
18
18
|
function _interop_require_default(obj) {
|
|
@@ -8,9 +8,9 @@ Object.defineProperty(exports, "LocalePublishingStatus", {
|
|
|
8
8
|
return LocalePublishingStatus;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
-
const _react = _interop_require_default(require("react"));
|
|
11
|
+
const _react = /*#__PURE__*/ _interop_require_default(require("react"));
|
|
12
12
|
const _f36components = require("@contentful/f36-components");
|
|
13
|
-
const _f36tokens = _interop_require_default(require("@contentful/f36-tokens"));
|
|
13
|
+
const _f36tokens = /*#__PURE__*/ _interop_require_default(require("@contentful/f36-tokens"));
|
|
14
14
|
const _emotion = require("emotion");
|
|
15
15
|
function _interop_require_default(obj) {
|
|
16
16
|
return obj && obj.__esModule ? obj : {
|
|
@@ -8,9 +8,9 @@ Object.defineProperty(exports, "LocalePublishingStatusList", {
|
|
|
8
8
|
return LocalePublishingStatusList;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
-
const _react = _interop_require_default(require("react"));
|
|
11
|
+
const _react = /*#__PURE__*/ _interop_require_default(require("react"));
|
|
12
12
|
const _f36components = require("@contentful/f36-components");
|
|
13
|
-
const
|
|
13
|
+
const _sortBy = /*#__PURE__*/ _interop_require_default(require("lodash/sortBy"));
|
|
14
14
|
const _Banner = require("./Banner");
|
|
15
15
|
const _LocalePublishingStatus = require("./LocalePublishingStatus");
|
|
16
16
|
function _interop_require_default(obj) {
|
|
@@ -38,7 +38,7 @@ function groupAndSortLocales(entries, activeLocales) {
|
|
|
38
38
|
nonSelected: []
|
|
39
39
|
});
|
|
40
40
|
return {
|
|
41
|
-
selected: (0,
|
|
41
|
+
selected: (0, _sortBy.default)(selected, 'locale.name'),
|
|
42
42
|
nonSelected: nonSelected.sort((a, b)=>{
|
|
43
43
|
if (a.status === b.status) {
|
|
44
44
|
return a.locale.name.localeCompare(b.locale.name);
|
|
@@ -8,24 +8,24 @@ Object.defineProperty(exports, "ScheduledBanner", {
|
|
|
8
8
|
return ScheduledBanner;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
-
const _react = _interop_require_default(require("react"));
|
|
11
|
+
const _react = /*#__PURE__*/ _interop_require_default(require("react"));
|
|
12
12
|
const _f36components = require("@contentful/f36-components");
|
|
13
|
-
const
|
|
13
|
+
const _orderBy = /*#__PURE__*/ _interop_require_default(require("lodash/orderBy"));
|
|
14
14
|
const _Banner = require("./Banner");
|
|
15
15
|
function _interop_require_default(obj) {
|
|
16
16
|
return obj && obj.__esModule ? obj : {
|
|
17
17
|
default: obj
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
|
-
var ScheduledActionTypes
|
|
21
|
-
(function(ScheduledActionTypes) {
|
|
20
|
+
var ScheduledActionTypes = /*#__PURE__*/ function(ScheduledActionTypes) {
|
|
22
21
|
ScheduledActionTypes["publish"] = "publish";
|
|
23
22
|
ScheduledActionTypes["unpublish"] = "unpublish";
|
|
24
23
|
ScheduledActionTypes["patch+publish"] = "patch+publish";
|
|
25
|
-
|
|
24
|
+
return ScheduledActionTypes;
|
|
25
|
+
}(ScheduledActionTypes || {});
|
|
26
26
|
function ScheduledBanner({ entityId, jobs }) {
|
|
27
27
|
const scheduledJobs = jobs.filter((job)=>job.entity.sys.id === entityId);
|
|
28
|
-
const sortedScheduledJobs = (0,
|
|
28
|
+
const sortedScheduledJobs = (0, _orderBy.default)(scheduledJobs, [
|
|
29
29
|
'scheduledFor.datetime'
|
|
30
30
|
], [
|
|
31
31
|
'asc'
|
|
@@ -19,10 +19,10 @@ _export(exports, {
|
|
|
19
19
|
return openDialog;
|
|
20
20
|
}
|
|
21
21
|
});
|
|
22
|
-
const _react = _interop_require_wildcard(require("react"));
|
|
23
|
-
const _reactdom = _interop_require_default(require("react-dom"));
|
|
22
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
23
|
+
const _reactdom = /*#__PURE__*/ _interop_require_default(require("react-dom"));
|
|
24
24
|
const _f36components = require("@contentful/f36-components");
|
|
25
|
-
const _isNumber = _interop_require_default(require("lodash/isNumber"));
|
|
25
|
+
const _isNumber = /*#__PURE__*/ _interop_require_default(require("lodash/isNumber"));
|
|
26
26
|
function _interop_require_default(obj) {
|
|
27
27
|
return obj && obj.__esModule ? obj : {
|
|
28
28
|
default: obj
|
|
@@ -8,7 +8,7 @@ Object.defineProperty(exports, "PredefinedValuesError", {
|
|
|
8
8
|
return PredefinedValuesError;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
-
const _react = _interop_require_wildcard(require("react"));
|
|
11
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
12
12
|
const _f36note = require("@contentful/f36-note");
|
|
13
13
|
function _getRequireWildcardCache(nodeInterop) {
|
|
14
14
|
if (typeof WeakMap !== "function") return null;
|
|
@@ -9,7 +9,7 @@ Object.defineProperty(exports, "useLocalePublishStatus", {
|
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
const _react = require("react");
|
|
12
|
-
const _entityHelpers = _interop_require_wildcard(require("../utils/entityHelpers"));
|
|
12
|
+
const _entityHelpers = /*#__PURE__*/ _interop_require_wildcard(require("../utils/entityHelpers"));
|
|
13
13
|
function _getRequireWildcardCache(nodeInterop) {
|
|
14
14
|
if (typeof WeakMap !== "function") return null;
|
|
15
15
|
var cacheBabelInterop = new WeakMap();
|
package/dist/cjs/index.js
CHANGED
|
@@ -114,9 +114,9 @@ const _shortenStorageUnit = require("./utils/shortenStorageUnit");
|
|
|
114
114
|
_export_star(require("./hooks/useLocalePublishStatus"), exports);
|
|
115
115
|
_export_star(require("./hooks/useActiveLocales"), exports);
|
|
116
116
|
_export_star(require("./LocalePublishingEntityStatusBadge"), exports);
|
|
117
|
-
const _ModalDialogLauncher = _interop_require_wildcard(require("./ModalDialogLauncher"));
|
|
118
|
-
const _constraints = _interop_require_wildcard(require("./utils/constraints"));
|
|
119
|
-
const _entityHelpers = _interop_require_wildcard(require("./utils/entityHelpers"));
|
|
117
|
+
const _ModalDialogLauncher = /*#__PURE__*/ _interop_require_wildcard(require("./ModalDialogLauncher"));
|
|
118
|
+
const _constraints = /*#__PURE__*/ _interop_require_wildcard(require("./utils/constraints"));
|
|
119
|
+
const _entityHelpers = /*#__PURE__*/ _interop_require_wildcard(require("./utils/entityHelpers"));
|
|
120
120
|
function _export_star(from, to) {
|
|
121
121
|
Object.keys(from).forEach(function(k) {
|
|
122
122
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
@@ -16,7 +16,7 @@ _export(exports, {
|
|
|
16
16
|
return makeChecker;
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
|
-
const _isNumber = _interop_require_default(require("lodash/isNumber"));
|
|
19
|
+
const _isNumber = /*#__PURE__*/ _interop_require_default(require("lodash/isNumber"));
|
|
20
20
|
function _interop_require_default(obj) {
|
|
21
21
|
return obj && obj.__esModule ? obj : {
|
|
22
22
|
default: obj
|
|
@@ -40,8 +40,8 @@ _export(exports, {
|
|
|
40
40
|
return isDisplayField;
|
|
41
41
|
}
|
|
42
42
|
});
|
|
43
|
-
const _get = _interop_require_default(require("lodash/get"));
|
|
44
|
-
const _isObject = _interop_require_default(require("lodash/isObject"));
|
|
43
|
+
const _get = /*#__PURE__*/ _interop_require_default(require("lodash/get"));
|
|
44
|
+
const _isObject = /*#__PURE__*/ _interop_require_default(require("lodash/isObject"));
|
|
45
45
|
function _interop_require_default(obj) {
|
|
46
46
|
return obj && obj.__esModule ? obj : {
|
|
47
47
|
default: obj
|
|
@@ -61,12 +61,7 @@ export class FieldConnector extends (_React_Component = React.Component) {
|
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
63
|
constructor(props){
|
|
64
|
-
super(props)
|
|
65
|
-
_define_property(this, "unsubscribeErrors", null);
|
|
66
|
-
_define_property(this, "unsubscribeDisabled", null);
|
|
67
|
-
_define_property(this, "unsubscribeValue", null);
|
|
68
|
-
_define_property(this, "getDebounceDuration", ()=>'debounce' in this.props ? this.props.debounce : this.props.throttle);
|
|
69
|
-
_define_property(this, "setValue", async (value)=>{
|
|
64
|
+
super(props), _define_property(this, "unsubscribeErrors", null), _define_property(this, "unsubscribeDisabled", null), _define_property(this, "unsubscribeValue", null), _define_property(this, "getDebounceDuration", ()=>'debounce' in this.props ? this.props.debounce : this.props.throttle), _define_property(this, "setValue", async (value)=>{
|
|
70
65
|
if (this.props.isEmptyValue(value ?? null)) {
|
|
71
66
|
this.setState({
|
|
72
67
|
value: undefined
|
|
@@ -81,8 +76,7 @@ export class FieldConnector extends (_React_Component = React.Component) {
|
|
|
81
76
|
} else {
|
|
82
77
|
await this.debouncedTriggerSetValueCallbacks(value);
|
|
83
78
|
}
|
|
84
|
-
})
|
|
85
|
-
_define_property(this, "triggerSetValueCallbacks", (value)=>{
|
|
79
|
+
}), _define_property(this, "triggerSetValueCallbacks", (value)=>{
|
|
86
80
|
return new Promise((resolve, reject)=>{
|
|
87
81
|
if (this.props.isEmptyValue(value ?? null)) {
|
|
88
82
|
this.props.field.removeValue().then(resolve).catch(reject);
|
|
@@ -90,15 +84,14 @@ export class FieldConnector extends (_React_Component = React.Component) {
|
|
|
90
84
|
this.props.field.setValue(value).then(resolve).catch(reject);
|
|
91
85
|
}
|
|
92
86
|
});
|
|
93
|
-
});
|
|
94
|
-
_define_property(this, "debouncedTriggerSetValueCallbacks", debounce(this.triggerSetValueCallbacks, this.getDebounceDuration()));
|
|
87
|
+
}), _define_property(this, "debouncedTriggerSetValueCallbacks", debounce(this.triggerSetValueCallbacks, this.getDebounceDuration()));
|
|
95
88
|
const initialValue = props.field.getValue();
|
|
96
89
|
this.state = {
|
|
97
90
|
isLocalValueChange: false,
|
|
98
91
|
externalReset: 0,
|
|
99
92
|
value: initialValue,
|
|
100
93
|
lastRemoteValue: initialValue,
|
|
101
|
-
disabled: props.isInitiallyDisabled
|
|
94
|
+
disabled: props.isInitiallyDisabled || props.field.getIsDisabled(),
|
|
102
95
|
errors: []
|
|
103
96
|
};
|
|
104
97
|
}
|
|
@@ -3,10 +3,10 @@ import { createFakeFieldAPI } from '@contentful/field-editor-test-utils';
|
|
|
3
3
|
import { act, render } from '@testing-library/react';
|
|
4
4
|
import noop from 'lodash/noop';
|
|
5
5
|
import { FieldConnector } from './FieldConnector';
|
|
6
|
+
function getChild(children) {
|
|
7
|
+
return children.mock.calls[children.mock.calls.length - 1][0];
|
|
8
|
+
}
|
|
6
9
|
it('does not rerender with outdated value after calling setValue', async ()=>{
|
|
7
|
-
function getChild() {
|
|
8
|
-
return props.children.mock.calls[props.children.mock.calls.length - 1][0];
|
|
9
|
-
}
|
|
10
10
|
const onSchemaErrorsChanged = jest.fn();
|
|
11
11
|
const [field] = createFakeFieldAPI((field)=>{
|
|
12
12
|
return {
|
|
@@ -22,14 +22,36 @@ it('does not rerender with outdated value after calling setValue', async ()=>{
|
|
|
22
22
|
debounce: 0
|
|
23
23
|
};
|
|
24
24
|
render(React.createElement(FieldConnector, props));
|
|
25
|
-
let child = getChild();
|
|
25
|
+
let child = getChild(props.children);
|
|
26
26
|
expect(child.value).toBe('initial value');
|
|
27
27
|
const initialRenderCount = props.children.mock.calls.length;
|
|
28
28
|
await act(async ()=>{
|
|
29
29
|
child.setValue('new value');
|
|
30
30
|
});
|
|
31
31
|
onSchemaErrorsChanged.mock.calls.forEach(([cb])=>cb([]));
|
|
32
|
-
child = getChild();
|
|
32
|
+
child = getChild(props.children);
|
|
33
33
|
expect(child.value).toBe('new value');
|
|
34
34
|
expect(props.children.mock.calls.length).toBeGreaterThan(initialRenderCount);
|
|
35
35
|
});
|
|
36
|
+
it('takes initial disable state from sdk.field', ()=>{
|
|
37
|
+
const [field] = createFakeFieldAPI((field)=>{
|
|
38
|
+
return {
|
|
39
|
+
...field,
|
|
40
|
+
getIsDisabled: jest.fn().mockReturnValue(true)
|
|
41
|
+
};
|
|
42
|
+
}, 'initial value');
|
|
43
|
+
const props = {
|
|
44
|
+
isInitiallyDisabled: false,
|
|
45
|
+
children: jest.fn().mockImplementation(()=>null),
|
|
46
|
+
field,
|
|
47
|
+
debounce: 0
|
|
48
|
+
};
|
|
49
|
+
render(React.createElement(FieldConnector, props));
|
|
50
|
+
const child = getChild(props.children);
|
|
51
|
+
expect(child.value).toBe('initial value');
|
|
52
|
+
expect(field.getIsDisabled).toHaveBeenCalled();
|
|
53
|
+
expect(props.children).toHaveBeenCalledTimes(1);
|
|
54
|
+
expect(props.children).toHaveBeenCalledWith(expect.objectContaining({
|
|
55
|
+
disabled: true
|
|
56
|
+
}));
|
|
57
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { MenuSectionTitle } from '@contentful/f36-components';
|
|
3
|
-
import
|
|
3
|
+
import sortBy from 'lodash/sortBy';
|
|
4
4
|
import { Banner } from './Banner';
|
|
5
5
|
import { LocalePublishingStatus } from './LocalePublishingStatus';
|
|
6
6
|
function groupAndSortLocales(entries, activeLocales) {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { formatDateAndTime } from '@contentful/f36-components';
|
|
3
|
-
import
|
|
3
|
+
import orderBy from 'lodash/orderBy';
|
|
4
4
|
import { Banner } from './Banner';
|
|
5
|
-
var ScheduledActionTypes
|
|
6
|
-
(function(ScheduledActionTypes) {
|
|
5
|
+
var ScheduledActionTypes = /*#__PURE__*/ function(ScheduledActionTypes) {
|
|
7
6
|
ScheduledActionTypes["publish"] = "publish";
|
|
8
7
|
ScheduledActionTypes["unpublish"] = "unpublish";
|
|
9
8
|
ScheduledActionTypes["patch+publish"] = "patch+publish";
|
|
10
|
-
|
|
9
|
+
return ScheduledActionTypes;
|
|
10
|
+
}(ScheduledActionTypes || {});
|
|
11
11
|
export function ScheduledBanner({ entityId, jobs }) {
|
|
12
12
|
const scheduledJobs = jobs.filter((job)=>job.entity.sys.id === entityId);
|
|
13
13
|
const sortedScheduledJobs = orderBy(scheduledJobs, [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/field-editor-shared",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.2",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"publishConfig": {
|
|
56
56
|
"registry": "https://npm.pkg.github.com/"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "6bee4a59a3c19a95d2cadde3ef0c78112788626e"
|
|
59
59
|
}
|