@contentful/field-editor-shared 0.25.0 → 1.0.1

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/CHANGELOG.md CHANGED
@@ -3,187 +3,128 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
- # [0.25.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-shared@0.24.0...@contentful/field-editor-shared@0.25.0) (2021-10-06)
7
-
8
-
9
- ### Features
6
+ ## [1.0.1](https://github.com/contentful/field-editors/compare/@contentful/field-editor-shared@1.0.0...@contentful/field-editor-shared@1.0.1) (2021-11-17)
10
7
 
11
- * [EXT-3161] bump app sdk to v4 ([#881](https://github.com/contentful/field-editors/issues/881)) ([9c4a2af](https://github.com/contentful/field-editors/commit/9c4a2af07da203d59fb5f15c3a5188ecc64b1d44))
8
+ ### Bug Fixes
12
9
 
10
+ - **card-actions:** update forma 36 to fix card actions click issue ([#927](https://github.com/contentful/field-editors/issues/927)) ([3dfdef2](https://github.com/contentful/field-editors/commit/3dfdef2c2b0045f12ea94ddafca89a8e9f25e7d0))
13
11
 
12
+ # [1.0.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-shared@0.26.0...@contentful/field-editor-shared@1.0.0) (2021-11-04)
14
13
 
14
+ **Note:** Version bump only for package @contentful/field-editor-shared
15
15
 
16
+ # [0.26.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-shared@0.25.1...@contentful/field-editor-shared@0.26.0) (2021-11-04)
16
17
 
17
- # [0.24.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-shared@0.23.0...@contentful/field-editor-shared@0.24.0) (2021-09-17)
18
+ ### Features
18
19
 
20
+ - Forma v4 components adoption ([#805](https://github.com/contentful/field-editors/issues/805)) ([526bde6](https://github.com/contentful/field-editors/commit/526bde6e10e0ee3789705ec10fb31489af7ca59e))
19
21
 
20
- ### Features
22
+ ### BREAKING CHANGES
21
23
 
22
- * add shortenStorageUnit util to shared ([#852](https://github.com/contentful/field-editors/issues/852)) ([142472b](https://github.com/contentful/field-editors/commit/142472b57fc1ca2843dd414c5320fdb5b5b11e62))
24
+ - adopts a new Forma v4 beta
23
25
 
26
+ ## [0.25.1](https://github.com/contentful/field-editors/compare/@contentful/field-editor-shared@0.25.0...@contentful/field-editor-shared@0.25.1) (2021-10-14)
24
27
 
28
+ **Note:** Version bump only for package @contentful/field-editor-shared
25
29
 
30
+ # [0.25.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-shared@0.24.0...@contentful/field-editor-shared@0.25.0) (2021-10-06)
26
31
 
32
+ ### Features
27
33
 
28
- # [0.23.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-shared@0.22.1...@contentful/field-editor-shared@0.23.0) (2021-09-16)
34
+ - [EXT-3161] bump app sdk to v4 ([#881](https://github.com/contentful/field-editors/issues/881)) ([9c4a2af](https://github.com/contentful/field-editors/commit/9c4a2af07da203d59fb5f15c3a5188ecc64b1d44))
29
35
 
36
+ # [0.24.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-shared@0.23.0...@contentful/field-editor-shared@0.24.0) (2021-09-17)
30
37
 
31
38
  ### Features
32
39
 
33
- * export shared util to validate images ([#846](https://github.com/contentful/field-editors/issues/846)) ([f26c481](https://github.com/contentful/field-editors/commit/f26c481cc5abf275acb4e4a65b462be487708117))
34
-
40
+ - add shortenStorageUnit util to shared ([#852](https://github.com/contentful/field-editors/issues/852)) ([142472b](https://github.com/contentful/field-editors/commit/142472b57fc1ca2843dd414c5320fdb5b5b11e62))
35
41
 
42
+ # [0.23.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-shared@0.22.1...@contentful/field-editor-shared@0.23.0) (2021-09-16)
36
43
 
44
+ ### Features
37
45
 
46
+ - export shared util to validate images ([#846](https://github.com/contentful/field-editors/issues/846)) ([f26c481](https://github.com/contentful/field-editors/commit/f26c481cc5abf275acb4e4a65b462be487708117))
38
47
 
39
48
  ## [0.22.1](https://github.com/contentful/field-editors/compare/@contentful/field-editor-shared@0.22.0...@contentful/field-editor-shared@0.22.1) (2021-08-19)
40
49
 
41
-
42
50
  ### Bug Fixes
43
51
 
44
- * FieldConnector setValue race conditions ([#803](https://github.com/contentful/field-editors/issues/803)) ([15a5aa6](https://github.com/contentful/field-editors/commit/15a5aa68a6f3f6c7183444c8fd11de1e70208aa7))
45
-
46
-
47
-
48
-
52
+ - FieldConnector setValue race conditions ([#803](https://github.com/contentful/field-editors/issues/803)) ([15a5aa6](https://github.com/contentful/field-editors/commit/15a5aa68a6f3f6c7183444c8fd11de1e70208aa7))
49
53
 
50
54
  # [0.22.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-shared@0.21.0...@contentful/field-editor-shared@0.22.0) (2021-07-23)
51
55
 
52
-
53
56
  ### Features
54
57
 
55
- * 💡 new color tokens ([#778](https://github.com/contentful/field-editors/issues/778)) ([fba548d](https://github.com/contentful/field-editors/commit/fba548de32305016df7f2685634eefb14294828f))
56
-
57
-
58
-
59
-
58
+ - 💡 new color tokens ([#778](https://github.com/contentful/field-editors/issues/778)) ([fba548d](https://github.com/contentful/field-editors/commit/fba548de32305016df7f2685634eefb14294828f))
60
59
 
61
60
  # [0.21.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-shared@0.18.0...@contentful/field-editor-shared@0.21.0) (2021-07-06)
62
61
 
63
-
64
62
  ### Features
65
63
 
66
- * [] bump forma tokens ([#756](https://github.com/contentful/field-editors/issues/756)) ([befc60f](https://github.com/contentful/field-editors/commit/befc60f9f495b0d1e072e9cba969d139da8f674a))
67
-
68
-
69
-
70
-
64
+ - [] bump forma tokens ([#756](https://github.com/contentful/field-editors/issues/756)) ([befc60f](https://github.com/contentful/field-editors/commit/befc60f9f495b0d1e072e9cba969d139da8f674a))
71
65
 
72
66
  # [0.20.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-shared@0.18.0...@contentful/field-editor-shared@0.20.0) (2021-07-06)
73
67
 
74
-
75
68
  ### Features
76
69
 
77
- * [] bump forma tokens ([#756](https://github.com/contentful/field-editors/issues/756)) ([befc60f](https://github.com/contentful/field-editors/commit/befc60f9f495b0d1e072e9cba969d139da8f674a))
78
-
79
-
80
-
81
-
70
+ - [] bump forma tokens ([#756](https://github.com/contentful/field-editors/issues/756)) ([befc60f](https://github.com/contentful/field-editors/commit/befc60f9f495b0d1e072e9cba969d139da8f674a))
82
71
 
83
72
  # [0.19.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-shared@0.18.0...@contentful/field-editor-shared@0.19.0) (2021-06-23)
84
73
 
85
-
86
74
  ### Features
87
75
 
88
- * [] bump forma tokens ([#756](https://github.com/contentful/field-editors/issues/756)) ([befc60f](https://github.com/contentful/field-editors/commit/befc60f9f495b0d1e072e9cba969d139da8f674a))
89
-
90
-
91
-
92
-
76
+ - [] bump forma tokens ([#756](https://github.com/contentful/field-editors/issues/756)) ([befc60f](https://github.com/contentful/field-editors/commit/befc60f9f495b0d1e072e9cba969d139da8f674a))
93
77
 
94
78
  # [0.18.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-shared@0.17.0...@contentful/field-editor-shared@0.18.0) (2021-06-23)
95
79
 
96
-
97
80
  ### Features
98
81
 
99
- * [] bump app sdk ([#755](https://github.com/contentful/field-editors/issues/755)) ([aa0c217](https://github.com/contentful/field-editors/commit/aa0c2179d4edbb1a37453e1e3bdf0ae11991166f))
100
-
101
-
102
-
103
-
82
+ - [] bump app sdk ([#755](https://github.com/contentful/field-editors/issues/755)) ([aa0c217](https://github.com/contentful/field-editors/commit/aa0c2179d4edbb1a37453e1e3bdf0ae11991166f))
104
83
 
105
84
  # [0.17.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-shared@0.16.0...@contentful/field-editor-shared@0.17.0) (2021-06-22)
106
85
 
107
-
108
86
  ### Features
109
87
 
110
- * [EXT-2826] make app-sdk a peer depedency ([#748](https://github.com/contentful/field-editors/issues/748)) ([f1d1d01](https://github.com/contentful/field-editors/commit/f1d1d01d89d59d70ab2c831a513ab2580ea64d7e))
111
-
112
-
113
-
114
-
88
+ - [EXT-2826] make app-sdk a peer depedency ([#748](https://github.com/contentful/field-editors/issues/748)) ([f1d1d01](https://github.com/contentful/field-editors/commit/f1d1d01d89d59d70ab2c831a513ab2580ea64d7e))
115
89
 
116
90
  # [0.16.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-shared@0.15.1...@contentful/field-editor-shared@0.16.0) (2021-02-19)
117
91
 
118
-
119
92
  ### Features
120
93
 
121
- * bump min version of forma-36 ([#606](https://github.com/contentful/field-editors/issues/606)) ([fd57c7a](https://github.com/contentful/field-editors/commit/fd57c7a4312766af38c01507f17706ab22992617))
122
-
123
-
124
-
125
-
94
+ - bump min version of forma-36 ([#606](https://github.com/contentful/field-editors/issues/606)) ([fd57c7a](https://github.com/contentful/field-editors/commit/fd57c7a4312766af38c01507f17706ab22992617))
126
95
 
127
96
  ## [0.15.1](https://github.com/contentful/field-editors/compare/@contentful/field-editor-shared@0.15.0...@contentful/field-editor-shared@0.15.1) (2021-02-09)
128
97
 
129
-
130
98
  ### Bug Fixes
131
99
 
132
- * **tags:** Editor permissions handles entities with metadata ([#584](https://github.com/contentful/field-editors/issues/584)) ([32636da](https://github.com/contentful/field-editors/commit/32636daf05e0ba9abb47eafe9893850db2c6601f))
133
-
134
-
135
-
136
-
100
+ - **tags:** Editor permissions handles entities with metadata ([#584](https://github.com/contentful/field-editors/issues/584)) ([32636da](https://github.com/contentful/field-editors/commit/32636daf05e0ba9abb47eafe9893850db2c6601f))
137
101
 
138
102
  # [0.15.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-shared@0.14.0...@contentful/field-editor-shared@0.15.0) (2021-02-01)
139
103
 
140
-
141
104
  ### Features
142
105
 
143
- * swap ui-extension-sdk to app-sdk ([#576](https://github.com/contentful/field-editors/issues/576)) ([ac88b4b](https://github.com/contentful/field-editors/commit/ac88b4bd4573a72f521246fc8fcc873520ca90d4))
144
-
145
-
146
-
147
-
106
+ - swap ui-extension-sdk to app-sdk ([#576](https://github.com/contentful/field-editors/issues/576)) ([ac88b4b](https://github.com/contentful/field-editors/commit/ac88b4bd4573a72f521246fc8fcc873520ca90d4))
148
107
 
149
108
  # [0.14.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-shared@0.13.3...@contentful/field-editor-shared@0.14.0) (2021-01-20)
150
109
 
151
-
152
110
  ### Features
153
111
 
154
- * update minimal forma-36 versions to use updated design ([#565](https://github.com/contentful/field-editors/issues/565)) ([332c734](https://github.com/contentful/field-editors/commit/332c734bfaf54f0e9773fcbb460d743b1f5459ec))
155
-
156
-
157
-
158
-
112
+ - update minimal forma-36 versions to use updated design ([#565](https://github.com/contentful/field-editors/issues/565)) ([332c734](https://github.com/contentful/field-editors/commit/332c734bfaf54f0e9773fcbb460d743b1f5459ec))
159
113
 
160
114
  ## [0.13.3](https://github.com/contentful/field-editors/compare/@contentful/field-editor-shared@0.13.2...@contentful/field-editor-shared@0.13.3) (2021-01-12)
161
115
 
162
116
  **Note:** Version bump only for package @contentful/field-editor-shared
163
117
 
164
-
165
-
166
-
167
-
168
118
  ## [0.13.2](https://github.com/contentful/field-editors/compare/@contentful/field-editor-shared@0.13.1...@contentful/field-editor-shared@0.13.2) (2020-12-16)
169
119
 
170
120
  **Note:** Version bump only for package @contentful/field-editor-shared
171
121
 
172
-
173
-
174
-
175
-
176
122
  ## [0.13.1](https://github.com/contentful/field-editors/compare/@contentful/field-editor-shared@0.13.0...@contentful/field-editor-shared@0.13.1) (2020-11-06)
177
123
 
178
124
  **Note:** Version bump only for package @contentful/field-editor-shared
179
125
 
180
-
181
-
182
-
183
-
184
126
  # [0.13.0](https://github.com/contentful/field-editors/compare/@contentful/field-editor-shared@0.12.0...@contentful/field-editor-shared@0.13.0) (2020-08-24)
185
127
 
186
-
187
128
  ### Features
188
129
 
189
- * extract field component to default-field-editors package ([#365](https://github.com/contentful/field-editors/issues/365)) ([eb78219](https://github.com/contentful/field-editors/commit/eb78219d52c3dcfb91824f3106f44312aaaf1f8e))
130
+ - extract field component to default-field-editors package ([#365](https://github.com/contentful/field-editors/issues/365)) ([eb78219](https://github.com/contentful/field-editors/commit/eb78219d52c3dcfb91824f3106f44312aaaf1f8e))
@@ -7,11 +7,12 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'defau
7
7
  var React = _interopDefault(require('react'));
8
8
  var isEqual = _interopDefault(require('lodash/isEqual'));
9
9
  var throttle = _interopDefault(require('lodash/throttle'));
10
- var forma36ReactComponents = require('@contentful/forma-36-react-components');
11
- var tokens = _interopDefault(require('@contentful/forma-36-tokens'));
10
+ var f36Note = require('@contentful/f36-note');
11
+ var tokens = _interopDefault(require('@contentful/f36-tokens'));
12
12
  var emotion = require('emotion');
13
13
  var isNumber = _interopDefault(require('lodash/isNumber'));
14
14
  var ReactDOM = _interopDefault(require('react-dom'));
15
+ var f36Components = require('@contentful/f36-components');
15
16
  var get = _interopDefault(require('lodash/get'));
16
17
  var isObject = _interopDefault(require('lodash/isObject'));
17
18
  var isString = _interopDefault(require('lodash/isString'));
@@ -950,8 +951,8 @@ FieldConnector.defaultProps = {
950
951
  };
951
952
 
952
953
  function PredefinedValuesError() {
953
- return React.createElement(forma36ReactComponents.Note, {
954
- noteType: "warning",
954
+ return React.createElement(f36Note.Note, {
955
+ variant: "warning",
955
956
  testId: "predefined-values-warning"
956
957
  }, "The widget failed to initialize. You can fix the problem by providing predefined values under the validations tab in the field settings.");
957
958
  }
@@ -1021,7 +1022,9 @@ function open(componentRenderer) {
1021
1022
  currentConfig = _extends({}, currentConfig, {
1022
1023
  isShown: false
1023
1024
  });
1024
- render(currentConfig);
1025
+ render(currentConfig); // eslint-disable-next-line @typescript-eslint/ban-ts-comment
1026
+ // @ts-ignore
1027
+
1025
1028
  resolve.apply(void 0, arguments);
1026
1029
  getRoot().remove();
1027
1030
  }
@@ -1040,7 +1043,7 @@ function openDialog(options, Component) {
1040
1043
  return onClose();
1041
1044
  };
1042
1045
 
1043
- return React.createElement(forma36ReactComponents.Modal, {
1046
+ return React.createElement(f36Components.Modal, {
1044
1047
  key: key,
1045
1048
  shouldCloseOnOverlayClick: options.shouldCloseOnOverlayClick || false,
1046
1049
  shouldCloseOnEscapePress: options.shouldCloseOnEscapePress || false,
@@ -1050,7 +1053,7 @@ function openDialog(options, Component) {
1050
1053
  onClose: onCloseHandler,
1051
1054
  size: size || '700px'
1052
1055
  }, function () {
1053
- return React.createElement(React.Fragment, null, options.title && React.createElement(forma36ReactComponents.Modal.Header, {
1056
+ return React.createElement(React.Fragment, null, options.title && React.createElement(f36Components.ModalHeader, {
1054
1057
  testId: "dialog-title",
1055
1058
  title: options.title,
1056
1059
  onClose: onCloseHandler
@@ -1120,33 +1123,62 @@ function getAssetTitle(_ref2) {
1120
1123
  });
1121
1124
  return titleOrDefault(title, defaultTitle);
1122
1125
  }
1123
- function getEntityDescription(_ref3) {
1124
- var entity = _ref3.entity,
1125
- contentType = _ref3.contentType,
1126
- localeCode = _ref3.localeCode,
1127
- defaultLocaleCode = _ref3.defaultLocaleCode;
1126
+ /**
1127
+ * Returns true if field is an Asset
1128
+ *
1129
+ * @param field
1130
+ * @returns {boolean}
1131
+ */
1128
1132
 
1129
- if (!contentType) {
1130
- return '';
1131
- }
1133
+ var isAssetField = function isAssetField(field) {
1134
+ return field.type === 'Link' && field.linkType === 'Asset';
1135
+ };
1136
+ /**
1137
+ * Returns true if field is a Title
1138
+ */
1139
+
1140
+ function isDisplayField(_ref3) {
1141
+ var field = _ref3.field,
1142
+ contentType = _ref3.contentType;
1143
+ return field.id === contentType.displayField;
1144
+ }
1145
+ /**
1146
+ * Returns true if field is a short Description
1147
+ */
1148
+
1149
+ function isDescriptionField(_ref4) {
1150
+ var field = _ref4.field,
1151
+ contentType = _ref4.contentType;
1132
1152
 
1133
1153
  var isTextField = function isTextField(field) {
1134
1154
  return ['Symbol', 'Text'].includes(field.type);
1135
1155
  };
1136
1156
 
1137
- var isDisplayField = function isDisplayField(field) {
1138
- return field.id === contentType.displayField;
1139
- };
1140
-
1141
1157
  var isMaybeSlugField = function isMaybeSlugField(field) {
1142
1158
  return /\bslug\b/.test(field.name);
1143
1159
  };
1144
1160
 
1145
- var isDescriptionField = function isDescriptionField(field) {
1146
- return isTextField(field) && !isDisplayField(field) && !isMaybeSlugField(field);
1147
- };
1161
+ return isTextField(field) && !isDisplayField({
1162
+ field: field,
1163
+ contentType: contentType
1164
+ }) && !isMaybeSlugField(field);
1165
+ }
1166
+ function getEntityDescription(_ref5) {
1167
+ var entity = _ref5.entity,
1168
+ contentType = _ref5.contentType,
1169
+ localeCode = _ref5.localeCode,
1170
+ defaultLocaleCode = _ref5.defaultLocaleCode;
1171
+
1172
+ if (!contentType) {
1173
+ return '';
1174
+ }
1148
1175
 
1149
- var descriptionField = contentType.fields.find(isDescriptionField);
1176
+ var descriptionField = contentType.fields.find(function (field) {
1177
+ return isDescriptionField({
1178
+ field: field,
1179
+ contentType: contentType
1180
+ });
1181
+ });
1150
1182
 
1151
1183
  if (!descriptionField) {
1152
1184
  return '';
@@ -1159,12 +1191,12 @@ function getEntityDescription(_ref3) {
1159
1191
  defaultLocaleCode: defaultLocaleCode
1160
1192
  }) || '';
1161
1193
  }
1162
- function getEntryTitle(_ref4) {
1163
- var entry = _ref4.entry,
1164
- contentType = _ref4.contentType,
1165
- localeCode = _ref4.localeCode,
1166
- defaultLocaleCode = _ref4.defaultLocaleCode,
1167
- defaultTitle = _ref4.defaultTitle;
1194
+ function getEntryTitle(_ref6) {
1195
+ var entry = _ref6.entry,
1196
+ contentType = _ref6.contentType,
1197
+ localeCode = _ref6.localeCode,
1198
+ defaultLocaleCode = _ref6.defaultLocaleCode,
1199
+ defaultTitle = _ref6.defaultTitle;
1168
1200
  var title;
1169
1201
 
1170
1202
  if (!contentType) {
@@ -1252,13 +1284,13 @@ function getEntryStatus(sys) {
1252
1284
  */
1253
1285
 
1254
1286
  var getEntryImage = /*#__PURE__*/function () {
1255
- var _ref6 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(_ref5, getAsset) {
1287
+ var _ref8 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(_ref7, getAsset) {
1256
1288
  var entry, contentType, localeCode, assetLink, assetId, asset, file, isImage;
1257
1289
  return runtime_1.wrap(function _callee$(_context) {
1258
1290
  while (1) {
1259
1291
  switch (_context.prev = _context.next) {
1260
1292
  case 0:
1261
- entry = _ref5.entry, contentType = _ref5.contentType, localeCode = _ref5.localeCode;
1293
+ entry = _ref7.entry, contentType = _ref7.contentType, localeCode = _ref7.localeCode;
1262
1294
 
1263
1295
  if (contentType) {
1264
1296
  _context.next = 3;
@@ -1268,9 +1300,7 @@ var getEntryImage = /*#__PURE__*/function () {
1268
1300
  return _context.abrupt("return", null);
1269
1301
 
1270
1302
  case 3:
1271
- assetLink = contentType.fields.find(function (field) {
1272
- return field.type === 'Link' && field.linkType === 'Asset';
1273
- });
1303
+ assetLink = contentType.fields.find(isAssetField);
1274
1304
 
1275
1305
  if (assetLink) {
1276
1306
  _context.next = 6;
@@ -1314,7 +1344,7 @@ var getEntryImage = /*#__PURE__*/function () {
1314
1344
  }));
1315
1345
 
1316
1346
  return function getEntryImage(_x, _x2) {
1317
- return _ref6.apply(this, arguments);
1347
+ return _ref8.apply(this, arguments);
1318
1348
  };
1319
1349
  }();
1320
1350
 
@@ -1322,6 +1352,9 @@ var entityHelpers = {
1322
1352
  __proto__: null,
1323
1353
  getFieldValue: getFieldValue,
1324
1354
  getAssetTitle: getAssetTitle,
1355
+ isAssetField: isAssetField,
1356
+ isDisplayField: isDisplayField,
1357
+ isDescriptionField: isDescriptionField,
1325
1358
  getEntityDescription: getEntityDescription,
1326
1359
  getEntryTitle: getEntryTitle,
1327
1360
  getEntryStatus: getEntryStatus,