@contentful/field-editor-slug 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.
@@ -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)) {
@@ -54,7 +56,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
54
56
  function isSupportedFieldTypes(val) {
55
57
  return val === 'Symbol';
56
58
  }
57
- function FieldConnectorCallback({ Component , value , disabled , setValue , errors , titleValue , isOptionalLocaleWithFallback , locale , createdAt , performUniqueCheck }) {
59
+ function FieldConnectorCallback({ Component, value, disabled, setValue, errors, titleValue, isOptionalLocaleWithFallback, locale, createdAt, performUniqueCheck }) {
58
60
  const safeSetValue = _react.useCallback(async (...args)=>{
59
61
  try {
60
62
  await setValue(...args);
@@ -77,8 +79,8 @@ function FieldConnectorCallback({ Component , value , disabled , setValue , erro
77
79
  }));
78
80
  }
79
81
  function SlugEditor(props) {
80
- const { field , parameters } = props;
81
- const { locales , entry , space } = props.baseSdk;
82
+ const { field, parameters } = props;
83
+ const { locales, entry, space } = props.baseSdk;
82
84
  if (!isSupportedFieldTypes(field.type)) {
83
85
  throw new Error(`"${field.type}" field type is not supported by SlugEditor`);
84
86
  }
@@ -112,11 +114,11 @@ function SlugEditor(props) {
112
114
  defaultLocale: locales.default,
113
115
  isOptionalLocaleWithFallback: isOptionalLocaleWithFallback,
114
116
  trackingFieldId: trackingFieldId
115
- }, ({ titleValue , isPublished , isSame })=>_react.createElement(_fieldeditorshared.FieldConnector, {
117
+ }, ({ titleValue, isPublished, isSame })=>_react.createElement(_fieldeditorshared.FieldConnector, {
116
118
  field: field,
117
119
  isInitiallyDisabled: props.isInitiallyDisabled,
118
120
  debounce: 0
119
- }, ({ value , errors , disabled , setValue , externalReset })=>{
121
+ }, ({ value, errors, disabled, setValue, externalReset })=>{
120
122
  const shouldTrackTitle = isPublished === false && isSame === false;
121
123
  const Component = shouldTrackTitle ? _SlugEditorField.SlugEditorField : _SlugEditorField.SlugEditorFieldStatic;
122
124
  return _react.createElement(FieldConnectorCallback, {
@@ -28,7 +28,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
28
28
  if (cache && cache.has(obj)) {
29
29
  return cache.get(obj);
30
30
  }
31
- var newObj = {};
31
+ var newObj = {
32
+ __proto__: null
33
+ };
32
34
  var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
33
35
  for(var key in obj){
34
36
  if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
@@ -115,7 +117,7 @@ describe('SlugEditor', ()=>{
115
117
  afterEach(_react1.cleanup);
116
118
  describe('should not subscribe to title changes', ()=>{
117
119
  it('when entry is published', async ()=>{
118
- const { field , titleField , sdk } = createMocks();
120
+ const { field, titleField, sdk } = createMocks();
119
121
  sdk.entry.getSys.mockReturnValue({
120
122
  publishedVersion: 2
121
123
  });
@@ -133,7 +135,7 @@ describe('SlugEditor', ()=>{
133
135
  });
134
136
  });
135
137
  it('when title and slug are the same field', async ()=>{
136
- const { field , titleField , sdk } = createMocks();
138
+ const { field, titleField, sdk } = createMocks();
137
139
  sdk.contentType.displayField = 'entry-id';
138
140
  (0, _react1.render)(_react.createElement(_SlugEditor.SlugEditor, {
139
141
  field: field,
@@ -146,7 +148,7 @@ describe('SlugEditor', ()=>{
146
148
  });
147
149
  });
148
150
  it('when a saved slug is different from a title at the render', async ()=>{
149
- const { field , titleField , sdk } = createMocks({
151
+ const { field, titleField, sdk } = createMocks({
150
152
  titleField: 'Hello world!',
151
153
  field: 'something-different'
152
154
  });
@@ -163,7 +165,7 @@ describe('SlugEditor', ()=>{
163
165
  });
164
166
  describe('should check for uniqueness', ()=>{
165
167
  it('if it is published', async ()=>{
166
- const { field , titleField , sdk } = createMocks({
168
+ const { field, titleField, sdk } = createMocks({
167
169
  titleField: 'Slug value',
168
170
  field: 'slug-value'
169
171
  });
@@ -179,7 +181,7 @@ describe('SlugEditor', ()=>{
179
181
  sdk.space.getEntries.mockResolvedValue({
180
182
  total: 0
181
183
  });
182
- const { queryByTestId , queryByText } = (0, _react1.render)(_react.createElement(_SlugEditor.SlugEditor, {
184
+ const { queryByTestId, queryByText } = (0, _react1.render)(_react.createElement(_SlugEditor.SlugEditor, {
183
185
  field: field,
184
186
  baseSdk: sdk,
185
187
  isInitiallyDisabled: false
@@ -199,7 +201,7 @@ describe('SlugEditor', ()=>{
199
201
  });
200
202
  });
201
203
  it('if it is not published', async ()=>{
202
- const { field , titleField , sdk } = createMocks({
204
+ const { field, titleField, sdk } = createMocks({
203
205
  titleField: 'Slug value',
204
206
  field: 'slug-value'
205
207
  });
@@ -215,7 +217,7 @@ describe('SlugEditor', ()=>{
215
217
  sdk.space.getEntries.mockResolvedValue({
216
218
  total: 2
217
219
  });
218
- const { queryByTestId , queryByText , getByTestId } = (0, _react1.render)(_react.createElement(_SlugEditor.SlugEditor, {
220
+ const { queryByTestId, queryByText, getByTestId } = (0, _react1.render)(_react.createElement(_SlugEditor.SlugEditor, {
219
221
  field: field,
220
222
  baseSdk: sdk,
221
223
  isInitiallyDisabled: false
@@ -259,7 +261,7 @@ describe('SlugEditor', ()=>{
259
261
  });
260
262
  describe('should react to title changes', ()=>{
261
263
  it('when field is disabled', async ()=>{
262
- const { field , titleField , sdk } = createMocks({
264
+ const { field, titleField, sdk } = createMocks({
263
265
  field: '',
264
266
  titleField: ''
265
267
  });
@@ -277,7 +279,7 @@ describe('SlugEditor', ()=>{
277
279
  });
278
280
  });
279
281
  it('should generate unique value with date if title is empty', async ()=>{
280
- const { field , titleField , sdk } = createMocks({
282
+ const { field, titleField, sdk } = createMocks({
281
283
  field: '',
282
284
  titleField: ''
283
285
  });
@@ -305,7 +307,7 @@ describe('SlugEditor', ()=>{
305
307
  });
306
308
  });
307
309
  it('should generate value from title if it is not empty', async ()=>{
308
- const { field , titleField , sdk } = createMocks({
310
+ const { field, titleField, sdk } = createMocks({
309
311
  field: '',
310
312
  titleField: 'This is initial title value'
311
313
  });
@@ -327,11 +329,11 @@ describe('SlugEditor', ()=>{
327
329
  });
328
330
  });
329
331
  it('should stop tracking value after user intentionally changes slug value', async ()=>{
330
- const { field , titleField , sdk } = createMocks({
332
+ const { field, titleField, sdk } = createMocks({
331
333
  field: '',
332
334
  titleField: ''
333
335
  });
334
- const { getByTestId } = (0, _react1.render)(_react.createElement(_SlugEditor.SlugEditor, {
336
+ const { getByTestId } = (0, _react1.render)(_react.createElement(_SlugEditor.SlugEditor, {
335
337
  field: field,
336
338
  baseSdk: sdk,
337
339
  isInitiallyDisabled: false
@@ -365,11 +367,11 @@ describe('SlugEditor', ()=>{
365
367
  });
366
368
  });
367
369
  it('should start tracking again after potential slug equals real one', async ()=>{
368
- const { field , sdk } = createMocks({
370
+ const { field, sdk } = createMocks({
369
371
  field: '',
370
372
  titleField: ''
371
373
  });
372
- const { getByTestId } = (0, _react1.render)(_react.createElement(_SlugEditor.SlugEditor, {
374
+ const { getByTestId } = (0, _react1.render)(_react.createElement(_SlugEditor.SlugEditor, {
373
375
  field: field,
374
376
  baseSdk: sdk,
375
377
  isInitiallyDisabled: false
@@ -403,7 +405,7 @@ describe('SlugEditor', ()=>{
403
405
  });
404
406
  describe('for non default locales', ()=>{
405
407
  it('locale is not optional and has no fallback then it should track default locale changes & current locale changes', async ()=>{
406
- const { sdk , field , titleField } = createMocks();
408
+ const { sdk, field, titleField } = createMocks();
407
409
  field.locale = 'ru-RU';
408
410
  field.required = false;
409
411
  sdk.locales.available = [
@@ -431,7 +433,7 @@ describe('SlugEditor', ()=>{
431
433
  });
432
434
  });
433
435
  it('locale is optional and has a fallback then it should track only current locale changes', async ()=>{
434
- const { sdk , field , titleField } = createMocks();
436
+ const { sdk, field, titleField } = createMocks();
435
437
  field.locale = 'ru-RU';
436
438
  field.required = false;
437
439
  sdk.locales.available = [
@@ -460,7 +462,7 @@ describe('SlugEditor', ()=>{
460
462
  });
461
463
  });
462
464
  it('slug suggestion is limited to 75 symbols', async ()=>{
463
- const { field , sdk } = createMocks({
465
+ const { field, sdk } = createMocks({
464
466
  field: '',
465
467
  titleField: ''
466
468
  });
@@ -478,7 +480,7 @@ describe('SlugEditor', ()=>{
478
480
  });
479
481
  });
480
482
  it('slug suggestion does not contain cut-off words', async ()=>{
481
- const { field , sdk } = createMocks({
483
+ const { field, sdk } = createMocks({
482
484
  field: '',
483
485
  titleField: ''
484
486
  });
@@ -496,7 +498,7 @@ describe('SlugEditor', ()=>{
496
498
  });
497
499
  });
498
500
  it('should subscribe for changes in custom field id', async ()=>{
499
- const { field , titleField , descriptionField , sdk } = createMocks({
501
+ const { field, titleField, descriptionField, sdk } = createMocks({
500
502
  field: '',
501
503
  titleField: 'This is initial title value',
502
504
  descriptionField: 'This is initial description value'
@@ -9,11 +9,11 @@ function _export(target, all) {
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- SlugEditorFieldStatic: function() {
13
- return SlugEditorFieldStatic;
14
- },
15
12
  SlugEditorField: function() {
16
13
  return SlugEditorField;
14
+ },
15
+ SlugEditorFieldStatic: function() {
16
+ return SlugEditorFieldStatic;
17
17
  }
18
18
  });
19
19
  const _react = _interop_require_wildcard(require("react"));
@@ -43,7 +43,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
43
43
  if (cache && cache.has(obj)) {
44
44
  return cache.get(obj);
45
45
  }
46
- var newObj = {};
46
+ var newObj = {
47
+ __proto__: null
48
+ };
47
49
  var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
48
50
  for(var key in obj){
49
51
  if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
@@ -62,7 +64,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
62
64
  return newObj;
63
65
  }
64
66
  function useSlugUpdater(props, check) {
65
- const { value , setValue , createdAt , locale , titleValue , isOptionalLocaleWithFallback } = props;
67
+ const { value, setValue, createdAt, locale, titleValue, isOptionalLocaleWithFallback } = props;
66
68
  _react.useEffect(()=>{
67
69
  if (check === false) {
68
70
  return;
@@ -86,7 +88,7 @@ function useSlugUpdater(props, check) {
86
88
  ]);
87
89
  }
88
90
  function useUniqueChecker(props) {
89
- const { performUniqueCheck } = props;
91
+ const { performUniqueCheck } = props;
90
92
  const [status, setStatus] = _react.useState(props.value ? 'checking' : 'unique');
91
93
  const [debouncedValue] = (0, _usedebounce.useDebounce)(props.value, 1000);
92
94
  _react.useEffect(()=>{
@@ -107,7 +109,7 @@ function useUniqueChecker(props) {
107
109
  return status;
108
110
  }
109
111
  function SlugEditorFieldStatic(props) {
110
- const { hasError , isDisabled , value , setValue , onChange , onBlur } = props;
112
+ const { hasError, isDisabled, value, setValue, onChange, onBlur } = props;
111
113
  const status = useUniqueChecker(props);
112
114
  return _react.createElement("div", {
113
115
  className: _styles.inputContainer
@@ -139,7 +141,7 @@ function SlugEditorFieldStatic(props) {
139
141
  }, "This slug has already been published in another entry"));
140
142
  }
141
143
  function SlugEditorField(props) {
142
- const { titleValue , isOptionalLocaleWithFallback , locale , createdAt , value } = props;
144
+ const { titleValue, isOptionalLocaleWithFallback, locale, createdAt, value } = props;
143
145
  const areEqual = _react.useCallback(()=>{
144
146
  const potentialSlug = (0, _makeSlug.makeSlug)(titleValue, {
145
147
  isOptionalLocaleWithFallback: isOptionalLocaleWithFallback,
@@ -43,7 +43,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
43
43
  if (cache && cache.has(obj)) {
44
44
  return cache.get(obj);
45
45
  }
46
- var newObj = {};
46
+ var newObj = {
47
+ __proto__: null
48
+ };
47
49
  var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
48
50
  for(var key in obj){
49
51
  if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
@@ -62,7 +64,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
62
64
  return newObj;
63
65
  }
64
66
  function getTitleField(sdk, trackingFieldId) {
65
- const { entry , contentType } = sdk;
67
+ const { entry, contentType } = sdk;
66
68
  if (trackingFieldId && entry.fields[trackingFieldId]) {
67
69
  return entry.fields[trackingFieldId];
68
70
  }
package/dist/cjs/index.js CHANGED
@@ -12,11 +12,11 @@ _export(exports, {
12
12
  SlugEditor: function() {
13
13
  return _SlugEditor.SlugEditor;
14
14
  },
15
- slugify: function() {
16
- return _slugify.slugify;
17
- },
18
15
  makeSlug: function() {
19
16
  return _makeSlug.makeSlug;
17
+ },
18
+ slugify: function() {
19
+ return _slugify.slugify;
20
20
  }
21
21
  });
22
22
  const _SlugEditor = require("./SlugEditor");
@@ -30,7 +30,7 @@ function formatUtcDate(date) {
30
30
  const seconds = formatTwoDigit(date.getUTCSeconds());
31
31
  return `${year} ${month} ${day} at ${hour} ${minutes} ${seconds}`;
32
32
  }
33
- function untitledSlug({ isOptionalLocaleWithFallback , createdAt }) {
33
+ function untitledSlug({ isOptionalLocaleWithFallback, createdAt }) {
34
34
  if (isOptionalLocaleWithFallback) {
35
35
  return '';
36
36
  }
@@ -9,23 +9,23 @@ function _export(target, all) {
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- validationRow: function() {
13
- return validationRow;
14
- },
15
- inputContainer: function() {
16
- return inputContainer;
12
+ icon: function() {
13
+ return icon;
17
14
  },
18
15
  input: function() {
19
16
  return input;
20
17
  },
21
- icon: function() {
22
- return icon;
18
+ inputContainer: function() {
19
+ return inputContainer;
23
20
  },
24
21
  spinnerContainer: function() {
25
22
  return spinnerContainer;
26
23
  },
27
24
  uniqueValidationError: function() {
28
25
  return uniqueValidationError;
26
+ },
27
+ validationRow: function() {
28
+ return validationRow;
29
29
  }
30
30
  });
31
31
  const _f36tokens = _interop_require_default(require("@contentful/f36-tokens"));
@@ -5,7 +5,7 @@ import { TrackingFieldConnector } from './TrackingFieldConnector';
5
5
  function isSupportedFieldTypes(val) {
6
6
  return val === 'Symbol';
7
7
  }
8
- function FieldConnectorCallback({ Component , value , disabled , setValue , errors , titleValue , isOptionalLocaleWithFallback , locale , createdAt , performUniqueCheck }) {
8
+ function FieldConnectorCallback({ Component, value, disabled, setValue, errors, titleValue, isOptionalLocaleWithFallback, locale, createdAt, performUniqueCheck }) {
9
9
  const safeSetValue = React.useCallback(async (...args)=>{
10
10
  try {
11
11
  await setValue(...args);
@@ -28,8 +28,8 @@ function FieldConnectorCallback({ Component , value , disabled , setValue , erro
28
28
  }));
29
29
  }
30
30
  export function SlugEditor(props) {
31
- const { field , parameters } = props;
32
- const { locales , entry , space } = props.baseSdk;
31
+ const { field, parameters } = props;
32
+ const { locales, entry, space } = props.baseSdk;
33
33
  if (!isSupportedFieldTypes(field.type)) {
34
34
  throw new Error(`"${field.type}" field type is not supported by SlugEditor`);
35
35
  }
@@ -63,11 +63,11 @@ export function SlugEditor(props) {
63
63
  defaultLocale: locales.default,
64
64
  isOptionalLocaleWithFallback: isOptionalLocaleWithFallback,
65
65
  trackingFieldId: trackingFieldId
66
- }, ({ titleValue , isPublished , isSame })=>React.createElement(FieldConnector, {
66
+ }, ({ titleValue, isPublished, isSame })=>React.createElement(FieldConnector, {
67
67
  field: field,
68
68
  isInitiallyDisabled: props.isInitiallyDisabled,
69
69
  debounce: 0
70
- }, ({ value , errors , disabled , setValue , externalReset })=>{
70
+ }, ({ value, errors, disabled, setValue, externalReset })=>{
71
71
  const shouldTrackTitle = isPublished === false && isSame === false;
72
72
  const Component = shouldTrackTitle ? SlugEditorField : SlugEditorFieldStatic;
73
73
  return React.createElement(FieldConnectorCallback, {
@@ -72,7 +72,7 @@ describe('SlugEditor', ()=>{
72
72
  afterEach(cleanup);
73
73
  describe('should not subscribe to title changes', ()=>{
74
74
  it('when entry is published', async ()=>{
75
- const { field , titleField , sdk } = createMocks();
75
+ const { field, titleField, sdk } = createMocks();
76
76
  sdk.entry.getSys.mockReturnValue({
77
77
  publishedVersion: 2
78
78
  });
@@ -90,7 +90,7 @@ describe('SlugEditor', ()=>{
90
90
  });
91
91
  });
92
92
  it('when title and slug are the same field', async ()=>{
93
- const { field , titleField , sdk } = createMocks();
93
+ const { field, titleField, sdk } = createMocks();
94
94
  sdk.contentType.displayField = 'entry-id';
95
95
  render(React.createElement(SlugEditor, {
96
96
  field: field,
@@ -103,7 +103,7 @@ describe('SlugEditor', ()=>{
103
103
  });
104
104
  });
105
105
  it('when a saved slug is different from a title at the render', async ()=>{
106
- const { field , titleField , sdk } = createMocks({
106
+ const { field, titleField, sdk } = createMocks({
107
107
  titleField: 'Hello world!',
108
108
  field: 'something-different'
109
109
  });
@@ -120,7 +120,7 @@ describe('SlugEditor', ()=>{
120
120
  });
121
121
  describe('should check for uniqueness', ()=>{
122
122
  it('if it is published', async ()=>{
123
- const { field , titleField , sdk } = createMocks({
123
+ const { field, titleField, sdk } = createMocks({
124
124
  titleField: 'Slug value',
125
125
  field: 'slug-value'
126
126
  });
@@ -136,7 +136,7 @@ describe('SlugEditor', ()=>{
136
136
  sdk.space.getEntries.mockResolvedValue({
137
137
  total: 0
138
138
  });
139
- const { queryByTestId , queryByText } = render(React.createElement(SlugEditor, {
139
+ const { queryByTestId, queryByText } = render(React.createElement(SlugEditor, {
140
140
  field: field,
141
141
  baseSdk: sdk,
142
142
  isInitiallyDisabled: false
@@ -156,7 +156,7 @@ describe('SlugEditor', ()=>{
156
156
  });
157
157
  });
158
158
  it('if it is not published', async ()=>{
159
- const { field , titleField , sdk } = createMocks({
159
+ const { field, titleField, sdk } = createMocks({
160
160
  titleField: 'Slug value',
161
161
  field: 'slug-value'
162
162
  });
@@ -172,7 +172,7 @@ describe('SlugEditor', ()=>{
172
172
  sdk.space.getEntries.mockResolvedValue({
173
173
  total: 2
174
174
  });
175
- const { queryByTestId , queryByText , getByTestId } = render(React.createElement(SlugEditor, {
175
+ const { queryByTestId, queryByText, getByTestId } = render(React.createElement(SlugEditor, {
176
176
  field: field,
177
177
  baseSdk: sdk,
178
178
  isInitiallyDisabled: false
@@ -216,7 +216,7 @@ describe('SlugEditor', ()=>{
216
216
  });
217
217
  describe('should react to title changes', ()=>{
218
218
  it('when field is disabled', async ()=>{
219
- const { field , titleField , sdk } = createMocks({
219
+ const { field, titleField, sdk } = createMocks({
220
220
  field: '',
221
221
  titleField: ''
222
222
  });
@@ -234,7 +234,7 @@ describe('SlugEditor', ()=>{
234
234
  });
235
235
  });
236
236
  it('should generate unique value with date if title is empty', async ()=>{
237
- const { field , titleField , sdk } = createMocks({
237
+ const { field, titleField, sdk } = createMocks({
238
238
  field: '',
239
239
  titleField: ''
240
240
  });
@@ -262,7 +262,7 @@ describe('SlugEditor', ()=>{
262
262
  });
263
263
  });
264
264
  it('should generate value from title if it is not empty', async ()=>{
265
- const { field , titleField , sdk } = createMocks({
265
+ const { field, titleField, sdk } = createMocks({
266
266
  field: '',
267
267
  titleField: 'This is initial title value'
268
268
  });
@@ -284,11 +284,11 @@ describe('SlugEditor', ()=>{
284
284
  });
285
285
  });
286
286
  it('should stop tracking value after user intentionally changes slug value', async ()=>{
287
- const { field , titleField , sdk } = createMocks({
287
+ const { field, titleField, sdk } = createMocks({
288
288
  field: '',
289
289
  titleField: ''
290
290
  });
291
- const { getByTestId } = render(React.createElement(SlugEditor, {
291
+ const { getByTestId } = render(React.createElement(SlugEditor, {
292
292
  field: field,
293
293
  baseSdk: sdk,
294
294
  isInitiallyDisabled: false
@@ -322,11 +322,11 @@ describe('SlugEditor', ()=>{
322
322
  });
323
323
  });
324
324
  it('should start tracking again after potential slug equals real one', async ()=>{
325
- const { field , sdk } = createMocks({
325
+ const { field, sdk } = createMocks({
326
326
  field: '',
327
327
  titleField: ''
328
328
  });
329
- const { getByTestId } = render(React.createElement(SlugEditor, {
329
+ const { getByTestId } = render(React.createElement(SlugEditor, {
330
330
  field: field,
331
331
  baseSdk: sdk,
332
332
  isInitiallyDisabled: false
@@ -360,7 +360,7 @@ describe('SlugEditor', ()=>{
360
360
  });
361
361
  describe('for non default locales', ()=>{
362
362
  it('locale is not optional and has no fallback then it should track default locale changes & current locale changes', async ()=>{
363
- const { sdk , field , titleField } = createMocks();
363
+ const { sdk, field, titleField } = createMocks();
364
364
  field.locale = 'ru-RU';
365
365
  field.required = false;
366
366
  sdk.locales.available = [
@@ -388,7 +388,7 @@ describe('SlugEditor', ()=>{
388
388
  });
389
389
  });
390
390
  it('locale is optional and has a fallback then it should track only current locale changes', async ()=>{
391
- const { sdk , field , titleField } = createMocks();
391
+ const { sdk, field, titleField } = createMocks();
392
392
  field.locale = 'ru-RU';
393
393
  field.required = false;
394
394
  sdk.locales.available = [
@@ -417,7 +417,7 @@ describe('SlugEditor', ()=>{
417
417
  });
418
418
  });
419
419
  it('slug suggestion is limited to 75 symbols', async ()=>{
420
- const { field , sdk } = createMocks({
420
+ const { field, sdk } = createMocks({
421
421
  field: '',
422
422
  titleField: ''
423
423
  });
@@ -435,7 +435,7 @@ describe('SlugEditor', ()=>{
435
435
  });
436
436
  });
437
437
  it('slug suggestion does not contain cut-off words', async ()=>{
438
- const { field , sdk } = createMocks({
438
+ const { field, sdk } = createMocks({
439
439
  field: '',
440
440
  titleField: ''
441
441
  });
@@ -453,7 +453,7 @@ describe('SlugEditor', ()=>{
453
453
  });
454
454
  });
455
455
  it('should subscribe for changes in custom field id', async ()=>{
456
- const { field , titleField , descriptionField , sdk } = createMocks({
456
+ const { field, titleField, descriptionField, sdk } = createMocks({
457
457
  field: '',
458
458
  titleField: 'This is initial title value',
459
459
  descriptionField: 'This is initial description value'
@@ -5,7 +5,7 @@ import { useDebounce } from 'use-debounce';
5
5
  import { makeSlug } from './services/makeSlug';
6
6
  import * as styles from './styles';
7
7
  function useSlugUpdater(props, check) {
8
- const { value , setValue , createdAt , locale , titleValue , isOptionalLocaleWithFallback } = props;
8
+ const { value, setValue, createdAt, locale, titleValue, isOptionalLocaleWithFallback } = props;
9
9
  React.useEffect(()=>{
10
10
  if (check === false) {
11
11
  return;
@@ -29,7 +29,7 @@ function useSlugUpdater(props, check) {
29
29
  ]);
30
30
  }
31
31
  function useUniqueChecker(props) {
32
- const { performUniqueCheck } = props;
32
+ const { performUniqueCheck } = props;
33
33
  const [status, setStatus] = React.useState(props.value ? 'checking' : 'unique');
34
34
  const [debouncedValue] = useDebounce(props.value, 1000);
35
35
  React.useEffect(()=>{
@@ -50,7 +50,7 @@ function useUniqueChecker(props) {
50
50
  return status;
51
51
  }
52
52
  export function SlugEditorFieldStatic(props) {
53
- const { hasError , isDisabled , value , setValue , onChange , onBlur } = props;
53
+ const { hasError, isDisabled, value, setValue, onChange, onBlur } = props;
54
54
  const status = useUniqueChecker(props);
55
55
  return React.createElement("div", {
56
56
  className: styles.inputContainer
@@ -82,7 +82,7 @@ export function SlugEditorFieldStatic(props) {
82
82
  }, "This slug has already been published in another entry"));
83
83
  }
84
84
  export function SlugEditorField(props) {
85
- const { titleValue , isOptionalLocaleWithFallback , locale , createdAt , value } = props;
85
+ const { titleValue, isOptionalLocaleWithFallback, locale, createdAt, value } = props;
86
86
  const areEqual = React.useCallback(()=>{
87
87
  const potentialSlug = makeSlug(titleValue, {
88
88
  isOptionalLocaleWithFallback: isOptionalLocaleWithFallback,
@@ -13,7 +13,7 @@ function _define_property(obj, key, value) {
13
13
  }
14
14
  import * as React from 'react';
15
15
  function getTitleField(sdk, trackingFieldId) {
16
- const { entry , contentType } = sdk;
16
+ const { entry, contentType } = sdk;
17
17
  if (trackingFieldId && entry.fields[trackingFieldId]) {
18
18
  return entry.fields[trackingFieldId];
19
19
  }
@@ -12,7 +12,7 @@ export function formatUtcDate(date) {
12
12
  const seconds = formatTwoDigit(date.getUTCSeconds());
13
13
  return `${year} ${month} ${day} at ${hour} ${minutes} ${seconds}`;
14
14
  }
15
- function untitledSlug({ isOptionalLocaleWithFallback , createdAt }) {
15
+ function untitledSlug({ isOptionalLocaleWithFallback, createdAt }) {
16
16
  if (isOptionalLocaleWithFallback) {
17
17
  return '';
18
18
  }
@@ -1,4 +1,4 @@
1
- import * as React from 'react';
1
+ /// <reference types="react" />
2
2
  import { FieldAppSDK, FieldAPI } from '@contentful/app-sdk';
3
3
  export interface SlugEditorProps {
4
4
  /**
@@ -16,7 +16,7 @@ export interface SlugEditorProps {
16
16
  };
17
17
  };
18
18
  }
19
- export declare function SlugEditor(props: SlugEditorProps): React.JSX.Element;
19
+ export declare function SlugEditor(props: SlugEditorProps): JSX.Element;
20
20
  export declare namespace SlugEditor {
21
21
  var defaultProps: {
22
22
  isInitiallyDisabled: boolean;
@@ -1,4 +1,4 @@
1
- import * as React from 'react';
1
+ /// <reference types="react" />
2
2
  interface SlugEditorFieldProps {
3
3
  hasError: boolean;
4
4
  isOptionalLocaleWithFallback: boolean;
@@ -13,6 +13,6 @@ interface SlugEditorFieldProps {
13
13
  export declare function SlugEditorFieldStatic(props: SlugEditorFieldProps & {
14
14
  onChange?: Function;
15
15
  onBlur?: Function;
16
- }): React.JSX.Element;
17
- export declare function SlugEditorField(props: SlugEditorFieldProps): React.JSX.Element;
16
+ }): JSX.Element;
17
+ export declare function SlugEditorField(props: SlugEditorFieldProps): JSX.Element;
18
18
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/field-editor-slug",
3
- "version": "1.4.2",
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",
@@ -38,7 +38,7 @@
38
38
  "@contentful/f36-components": "^4.0.27",
39
39
  "@contentful/f36-icons": "^4.1.0",
40
40
  "@contentful/f36-tokens": "^4.0.0",
41
- "@contentful/field-editor-shared": "^1.4.2",
41
+ "@contentful/field-editor-shared": "^1.4.5",
42
42
  "@types/speakingurl": "^13.0.2",
43
43
  "emotion": "^10.0.17",
44
44
  "lodash": "^4.17.15",
@@ -47,11 +47,14 @@
47
47
  },
48
48
  "devDependencies": {
49
49
  "@contentful/app-sdk": "^4.17.1",
50
- "@contentful/field-editor-test-utils": "^1.4.3"
50
+ "@contentful/field-editor-test-utils": "^1.4.6"
51
51
  },
52
52
  "peerDependencies": {
53
53
  "@contentful/app-sdk": "^4.17.1",
54
54
  "react": ">=16.8.0"
55
55
  },
56
- "gitHead": "ef0adb263ad287e6f78888a05727d0f2f4f8968d"
56
+ "publishConfig": {
57
+ "registry": "https://npm.pkg.github.com/"
58
+ },
59
+ "gitHead": "142d2039f023bf4ced956aae1dd08b27c35fdbaa"
57
60
  }