@contentful/field-editor-slug 3.5.4-canary.26 → 3.5.4-canary.30
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/SlugEditor.js +5 -5
- package/dist/cjs/SlugEditor.test.js +23 -23
- package/dist/cjs/SlugEditorField.js +11 -11
- package/dist/cjs/index.js +4 -4
- package/dist/cjs/services/makeSlug.js +3 -3
- package/dist/cjs/styles.js +7 -7
- package/dist/esm/SlugEditor.js +5 -5
- package/dist/esm/SlugEditor.test.js +23 -23
- package/dist/esm/SlugEditorField.js +8 -8
- package/package.json +4 -4
package/dist/cjs/SlugEditor.js
CHANGED
|
@@ -64,9 +64,9 @@ function FieldConnectorCallback({ Component, value, disabled, setValue, errors,
|
|
|
64
64
|
}, [
|
|
65
65
|
setValue
|
|
66
66
|
]);
|
|
67
|
-
return
|
|
67
|
+
return _react.createElement("div", {
|
|
68
68
|
"data-test-id": "slug-editor"
|
|
69
|
-
},
|
|
69
|
+
}, _react.createElement(Component, {
|
|
70
70
|
locale: locale,
|
|
71
71
|
createdAt: createdAt,
|
|
72
72
|
performUniqueCheck: performUniqueCheck,
|
|
@@ -114,20 +114,20 @@ function SlugEditor({ isInitiallyDisabled, autoGenerationStrategy = 'field', bas
|
|
|
114
114
|
entrySys.id,
|
|
115
115
|
cma.entry
|
|
116
116
|
]);
|
|
117
|
-
return
|
|
117
|
+
return _react.createElement(_TrackingFieldConnector.TrackingFieldConnector, {
|
|
118
118
|
sdk: baseSdk,
|
|
119
119
|
field: field,
|
|
120
120
|
defaultLocale: locales.default,
|
|
121
121
|
isOptionalLocaleWithFallback: isOptionalLocaleWithFallback,
|
|
122
122
|
trackingFieldId: trackingFieldId
|
|
123
|
-
}, ({ titleValue, isPublished, isSame })
|
|
123
|
+
}, ({ titleValue, isPublished, isSame })=>_react.createElement(_fieldeditorshared.FieldConnector, {
|
|
124
124
|
field: field,
|
|
125
125
|
isInitiallyDisabled: isInitiallyDisabled,
|
|
126
126
|
debounce: 0
|
|
127
127
|
}, ({ value, errors, disabled, setValue, externalReset })=>{
|
|
128
128
|
const shouldTrackTitle = autoGenerationStrategy !== 'document' && isPublished === false && isSame === false;
|
|
129
129
|
const Component = shouldTrackTitle ? _SlugEditorField.SlugEditorField : _SlugEditorField.SlugEditorFieldStatic;
|
|
130
|
-
return
|
|
130
|
+
return _react.createElement(FieldConnectorCallback, {
|
|
131
131
|
Component: Component,
|
|
132
132
|
titleValue: titleValue,
|
|
133
133
|
value: value,
|
|
@@ -78,7 +78,7 @@ function createMocks(initialValues = {}) {
|
|
|
78
78
|
}), initialValues.titleField || '');
|
|
79
79
|
const [descriptionField] = (0, _fieldeditortestutils.createFakeFieldAPI)((field)=>({
|
|
80
80
|
...field,
|
|
81
|
-
id:
|
|
81
|
+
id: "description-id",
|
|
82
82
|
setValue: _vitest.vi.fn().mockImplementation(field.setValue),
|
|
83
83
|
getValue: _vitest.vi.fn().mockImplementation(field.getValue),
|
|
84
84
|
onValueChanged: _vitest.vi.fn().mockImplementation(field.onValueChanged)
|
|
@@ -107,7 +107,7 @@ function createMocks(initialValues = {}) {
|
|
|
107
107
|
fields: {
|
|
108
108
|
'title-id': titleField,
|
|
109
109
|
'entry-id': field,
|
|
110
|
-
|
|
110
|
+
"description-id": descriptionField
|
|
111
111
|
}
|
|
112
112
|
},
|
|
113
113
|
contentType: {
|
|
@@ -129,7 +129,7 @@ function createMocks(initialValues = {}) {
|
|
|
129
129
|
sdk.entry.getSys.mockReturnValue({
|
|
130
130
|
publishedVersion: 2
|
|
131
131
|
});
|
|
132
|
-
(0, _react1.render)(
|
|
132
|
+
(0, _react1.render)(_react.createElement(_SlugEditor.SlugEditor, {
|
|
133
133
|
field: field,
|
|
134
134
|
baseSdk: sdk,
|
|
135
135
|
isInitiallyDisabled: false
|
|
@@ -145,7 +145,7 @@ function createMocks(initialValues = {}) {
|
|
|
145
145
|
(0, _vitest.it)('when title and slug are the same field', async ()=>{
|
|
146
146
|
const { field, titleField, sdk } = createMocks();
|
|
147
147
|
sdk.contentType.displayField = 'entry-id';
|
|
148
|
-
(0, _react1.render)(
|
|
148
|
+
(0, _react1.render)(_react.createElement(_SlugEditor.SlugEditor, {
|
|
149
149
|
field: field,
|
|
150
150
|
baseSdk: sdk,
|
|
151
151
|
isInitiallyDisabled: false
|
|
@@ -160,7 +160,7 @@ function createMocks(initialValues = {}) {
|
|
|
160
160
|
titleField: 'Hello world!',
|
|
161
161
|
field: 'something-different'
|
|
162
162
|
});
|
|
163
|
-
(0, _react1.render)(
|
|
163
|
+
(0, _react1.render)(_react.createElement(_SlugEditor.SlugEditor, {
|
|
164
164
|
field: field,
|
|
165
165
|
baseSdk: sdk,
|
|
166
166
|
isInitiallyDisabled: false
|
|
@@ -189,7 +189,7 @@ function createMocks(initialValues = {}) {
|
|
|
189
189
|
sdk.cma.entry.getMany.mockResolvedValue({
|
|
190
190
|
total: 0
|
|
191
191
|
});
|
|
192
|
-
const { queryByTestId, queryByText } = (0, _react1.render)(
|
|
192
|
+
const { queryByTestId, queryByText } = (0, _react1.render)(_react.createElement(_SlugEditor.SlugEditor, {
|
|
193
193
|
field: field,
|
|
194
194
|
baseSdk: sdk,
|
|
195
195
|
isInitiallyDisabled: false
|
|
@@ -228,7 +228,7 @@ function createMocks(initialValues = {}) {
|
|
|
228
228
|
sdk.cma.entry.getMany.mockResolvedValue({
|
|
229
229
|
total: 2
|
|
230
230
|
});
|
|
231
|
-
const { queryByTestId, queryByText, getByTestId } = (0, _react1.render)(
|
|
231
|
+
const { queryByTestId, queryByText, getByTestId } = (0, _react1.render)(_react.createElement(_SlugEditor.SlugEditor, {
|
|
232
232
|
field: field,
|
|
233
233
|
baseSdk: sdk,
|
|
234
234
|
isInitiallyDisabled: false
|
|
@@ -293,7 +293,7 @@ function createMocks(initialValues = {}) {
|
|
|
293
293
|
sdk.cma.entry.getMany.mockResolvedValue({
|
|
294
294
|
total: 2
|
|
295
295
|
});
|
|
296
|
-
const { queryByText, getByTestId } = (0, _react1.render)(
|
|
296
|
+
const { queryByText, getByTestId } = (0, _react1.render)(_react.createElement(_SlugEditor.SlugEditor, {
|
|
297
297
|
field: field,
|
|
298
298
|
baseSdk: sdk,
|
|
299
299
|
isInitiallyDisabled: false
|
|
@@ -307,7 +307,7 @@ function createMocks(initialValues = {}) {
|
|
|
307
307
|
(0, _vitest.it)('hides duplicate warning when publish sets hasError', async ()=>{
|
|
308
308
|
const performUniqueCheck = _vitest.vi.fn().mockResolvedValue(false);
|
|
309
309
|
const setValue = _vitest.vi.fn();
|
|
310
|
-
const { queryByTestId } = (0, _react1.render)(
|
|
310
|
+
const { queryByTestId } = (0, _react1.render)(_react.createElement(_SlugEditorField.SlugEditorFieldStatic, {
|
|
311
311
|
hasError: true,
|
|
312
312
|
isUniqueValidationEnabled: false,
|
|
313
313
|
isOptionalLocaleWithFallback: false,
|
|
@@ -331,7 +331,7 @@ function createMocks(initialValues = {}) {
|
|
|
331
331
|
field: '',
|
|
332
332
|
titleField: ''
|
|
333
333
|
});
|
|
334
|
-
(0, _react1.render)(
|
|
334
|
+
(0, _react1.render)(_react.createElement(_SlugEditor.SlugEditor, {
|
|
335
335
|
field: field,
|
|
336
336
|
baseSdk: sdk,
|
|
337
337
|
isInitiallyDisabled: true
|
|
@@ -349,7 +349,7 @@ function createMocks(initialValues = {}) {
|
|
|
349
349
|
field: '',
|
|
350
350
|
titleField: ''
|
|
351
351
|
});
|
|
352
|
-
(0, _react1.render)(
|
|
352
|
+
(0, _react1.render)(_react.createElement(_SlugEditor.SlugEditor, {
|
|
353
353
|
field: field,
|
|
354
354
|
baseSdk: sdk,
|
|
355
355
|
isInitiallyDisabled: false
|
|
@@ -377,7 +377,7 @@ function createMocks(initialValues = {}) {
|
|
|
377
377
|
field: '',
|
|
378
378
|
titleField: 'This is initial title value'
|
|
379
379
|
});
|
|
380
|
-
(0, _react1.render)(
|
|
380
|
+
(0, _react1.render)(_react.createElement(_SlugEditor.SlugEditor, {
|
|
381
381
|
field: field,
|
|
382
382
|
baseSdk: sdk,
|
|
383
383
|
isInitiallyDisabled: false
|
|
@@ -399,7 +399,7 @@ function createMocks(initialValues = {}) {
|
|
|
399
399
|
field: '',
|
|
400
400
|
titleField: ''
|
|
401
401
|
});
|
|
402
|
-
const { getByTestId } = (0, _react1.render)(
|
|
402
|
+
const { getByTestId } = (0, _react1.render)(_react.createElement(_SlugEditor.SlugEditor, {
|
|
403
403
|
field: field,
|
|
404
404
|
baseSdk: sdk,
|
|
405
405
|
isInitiallyDisabled: false
|
|
@@ -437,7 +437,7 @@ function createMocks(initialValues = {}) {
|
|
|
437
437
|
field: '',
|
|
438
438
|
titleField: ''
|
|
439
439
|
});
|
|
440
|
-
const { getByTestId } = (0, _react1.render)(
|
|
440
|
+
const { getByTestId } = (0, _react1.render)(_react.createElement(_SlugEditor.SlugEditor, {
|
|
441
441
|
field: field,
|
|
442
442
|
baseSdk: sdk,
|
|
443
443
|
isInitiallyDisabled: false
|
|
@@ -487,7 +487,7 @@ function createMocks(initialValues = {}) {
|
|
|
487
487
|
'de-DE': undefined,
|
|
488
488
|
'ru-RU': undefined
|
|
489
489
|
};
|
|
490
|
-
(0, _react1.render)(
|
|
490
|
+
(0, _react1.render)(_react.createElement(_SlugEditor.SlugEditor, {
|
|
491
491
|
field: field,
|
|
492
492
|
baseSdk: sdk,
|
|
493
493
|
isInitiallyDisabled: false
|
|
@@ -515,7 +515,7 @@ function createMocks(initialValues = {}) {
|
|
|
515
515
|
'de-DE': undefined,
|
|
516
516
|
'ru-RU': 'de-DE'
|
|
517
517
|
};
|
|
518
|
-
(0, _react1.render)(
|
|
518
|
+
(0, _react1.render)(_react.createElement(_SlugEditor.SlugEditor, {
|
|
519
519
|
field: field,
|
|
520
520
|
baseSdk: sdk,
|
|
521
521
|
isInitiallyDisabled: false
|
|
@@ -542,7 +542,7 @@ function createMocks(initialValues = {}) {
|
|
|
542
542
|
}
|
|
543
543
|
}
|
|
544
544
|
];
|
|
545
|
-
(0, _react1.render)(
|
|
545
|
+
(0, _react1.render)(_react.createElement(_SlugEditor.SlugEditor, {
|
|
546
546
|
field: field,
|
|
547
547
|
baseSdk: sdk,
|
|
548
548
|
isInitiallyDisabled: false
|
|
@@ -569,7 +569,7 @@ function createMocks(initialValues = {}) {
|
|
|
569
569
|
}
|
|
570
570
|
}
|
|
571
571
|
];
|
|
572
|
-
(0, _react1.render)(
|
|
572
|
+
(0, _react1.render)(_react.createElement(_SlugEditor.SlugEditor, {
|
|
573
573
|
field: field,
|
|
574
574
|
baseSdk: sdk,
|
|
575
575
|
isInitiallyDisabled: false
|
|
@@ -586,15 +586,15 @@ function createMocks(initialValues = {}) {
|
|
|
586
586
|
const { field, titleField, descriptionField, sdk } = createMocks({
|
|
587
587
|
field: '',
|
|
588
588
|
titleField: 'This is initial title value',
|
|
589
|
-
descriptionField:
|
|
589
|
+
descriptionField: "This is initial description value"
|
|
590
590
|
});
|
|
591
|
-
(0, _react1.render)(
|
|
591
|
+
(0, _react1.render)(_react.createElement(_SlugEditor.SlugEditor, {
|
|
592
592
|
field: field,
|
|
593
593
|
baseSdk: sdk,
|
|
594
594
|
isInitiallyDisabled: false,
|
|
595
595
|
parameters: {
|
|
596
596
|
instance: {
|
|
597
|
-
trackingFieldId:
|
|
597
|
+
trackingFieldId: "description-id"
|
|
598
598
|
}
|
|
599
599
|
}
|
|
600
600
|
}));
|
|
@@ -602,9 +602,9 @@ function createMocks(initialValues = {}) {
|
|
|
602
602
|
(0, _vitest.expect)(titleField.onValueChanged).not.toHaveBeenCalled();
|
|
603
603
|
(0, _vitest.expect)(descriptionField.onValueChanged).toHaveBeenCalledWith('en-US', _vitest.expect.any(Function));
|
|
604
604
|
(0, _vitest.expect)(field.setValue).toHaveBeenCalledTimes(1);
|
|
605
|
-
(0, _vitest.expect)(field.setValue).toHaveBeenLastCalledWith(
|
|
605
|
+
(0, _vitest.expect)(field.setValue).toHaveBeenLastCalledWith("this-is-initial-description-value");
|
|
606
606
|
});
|
|
607
|
-
await sdk.entry.fields[
|
|
607
|
+
await sdk.entry.fields["description-id"].setValue('Hello world!');
|
|
608
608
|
await (0, _react1.waitFor)(()=>{
|
|
609
609
|
(0, _vitest.expect)(field.setValue).toHaveBeenCalledTimes(2);
|
|
610
610
|
(0, _vitest.expect)(field.setValue).toHaveBeenLastCalledWith('hello-world');
|
|
@@ -5,14 +5,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
function _export(target, all) {
|
|
6
6
|
for(var name in all)Object.defineProperty(target, name, {
|
|
7
7
|
enumerable: true,
|
|
8
|
-
get: all
|
|
8
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
SlugEditorField
|
|
12
|
+
get SlugEditorField () {
|
|
13
13
|
return SlugEditorField;
|
|
14
14
|
},
|
|
15
|
-
SlugEditorFieldStatic
|
|
15
|
+
get SlugEditorFieldStatic () {
|
|
16
16
|
return SlugEditorFieldStatic;
|
|
17
17
|
}
|
|
18
18
|
});
|
|
@@ -108,11 +108,11 @@ function SlugEditorFieldStatic(props) {
|
|
|
108
108
|
const hasDuplicate = status === 'duplicate';
|
|
109
109
|
const shouldShowDuplicateAsError = hasDuplicate && isUniqueValidationEnabled && !hasError;
|
|
110
110
|
const shouldShowDuplicateAsWarning = hasDuplicate && !shouldShowDuplicateAsError && !hasError;
|
|
111
|
-
return
|
|
111
|
+
return _react.createElement("div", {
|
|
112
112
|
className: _styles.inputContainer
|
|
113
|
-
},
|
|
113
|
+
}, _react.createElement(_f36icons.LinkSimpleIcon, {
|
|
114
114
|
className: _styles.icon
|
|
115
|
-
}),
|
|
115
|
+
}), _react.createElement(_f36components.TextInput, {
|
|
116
116
|
className: _styles.input,
|
|
117
117
|
isInvalid: hasError || shouldShowDuplicateAsError,
|
|
118
118
|
isDisabled: isDisabled,
|
|
@@ -129,17 +129,17 @@ function SlugEditorFieldStatic(props) {
|
|
|
129
129
|
onBlur();
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
|
-
}), status === 'checking' &&
|
|
132
|
+
}), status === 'checking' && _react.createElement("div", {
|
|
133
133
|
className: _styles.spinnerContainer
|
|
134
|
-
},
|
|
134
|
+
}, _react.createElement(_f36components.Spinner, {
|
|
135
135
|
testId: "slug-editor-spinner"
|
|
136
|
-
})), shouldShowDuplicateAsError &&
|
|
136
|
+
})), shouldShowDuplicateAsError && _react.createElement(_f36components.ValidationMessage, {
|
|
137
137
|
testId: "slug-editor-duplicate-error",
|
|
138
138
|
className: _styles.uniqueValidationError
|
|
139
139
|
}, _core.i18n._({
|
|
140
140
|
id: "FieldEditors.Slug.SlugEditorField.DuplicateSlugError",
|
|
141
141
|
message: "This slug has already been published in another entry"
|
|
142
|
-
})), shouldShowDuplicateAsWarning &&
|
|
142
|
+
})), shouldShowDuplicateAsWarning && _react.createElement(_f36note.Note, {
|
|
143
143
|
variant: "warning",
|
|
144
144
|
testId: "slug-editor-duplicate-warning",
|
|
145
145
|
className: _styles.uniqueValidationError
|
|
@@ -189,7 +189,7 @@ function SlugEditorField(props) {
|
|
|
189
189
|
areEqual
|
|
190
190
|
]);
|
|
191
191
|
useSlugUpdater(props, check, generateSlug);
|
|
192
|
-
return
|
|
192
|
+
return _react.createElement(SlugEditorFieldStatic, {
|
|
193
193
|
...props,
|
|
194
194
|
onChange: ()=>{
|
|
195
195
|
setCheck(false);
|
package/dist/cjs/index.js
CHANGED
|
@@ -5,17 +5,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
function _export(target, all) {
|
|
6
6
|
for(var name in all)Object.defineProperty(target, name, {
|
|
7
7
|
enumerable: true,
|
|
8
|
-
get: all
|
|
8
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
SlugEditor
|
|
12
|
+
get SlugEditor () {
|
|
13
13
|
return _SlugEditor.SlugEditor;
|
|
14
14
|
},
|
|
15
|
-
makeSlug
|
|
15
|
+
get makeSlug () {
|
|
16
16
|
return _makeSlug.makeSlug;
|
|
17
17
|
},
|
|
18
|
-
slugify
|
|
18
|
+
get slugify () {
|
|
19
19
|
return _slugify.slugify;
|
|
20
20
|
}
|
|
21
21
|
});
|
|
@@ -5,14 +5,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
function _export(target, all) {
|
|
6
6
|
for(var name in all)Object.defineProperty(target, name, {
|
|
7
7
|
enumerable: true,
|
|
8
|
-
get: all
|
|
8
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
formatUtcDate
|
|
12
|
+
get formatUtcDate () {
|
|
13
13
|
return formatUtcDate;
|
|
14
14
|
},
|
|
15
|
-
makeSlug
|
|
15
|
+
get makeSlug () {
|
|
16
16
|
return makeSlug;
|
|
17
17
|
}
|
|
18
18
|
});
|
package/dist/cjs/styles.js
CHANGED
|
@@ -5,26 +5,26 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
function _export(target, all) {
|
|
6
6
|
for(var name in all)Object.defineProperty(target, name, {
|
|
7
7
|
enumerable: true,
|
|
8
|
-
get: all
|
|
8
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
icon
|
|
12
|
+
get icon () {
|
|
13
13
|
return icon;
|
|
14
14
|
},
|
|
15
|
-
input
|
|
15
|
+
get input () {
|
|
16
16
|
return input;
|
|
17
17
|
},
|
|
18
|
-
inputContainer
|
|
18
|
+
get inputContainer () {
|
|
19
19
|
return inputContainer;
|
|
20
20
|
},
|
|
21
|
-
spinnerContainer
|
|
21
|
+
get spinnerContainer () {
|
|
22
22
|
return spinnerContainer;
|
|
23
23
|
},
|
|
24
|
-
uniqueValidationError
|
|
24
|
+
get uniqueValidationError () {
|
|
25
25
|
return uniqueValidationError;
|
|
26
26
|
},
|
|
27
|
-
validationRow
|
|
27
|
+
get validationRow () {
|
|
28
28
|
return validationRow;
|
|
29
29
|
}
|
|
30
30
|
});
|
package/dist/esm/SlugEditor.js
CHANGED
|
@@ -13,9 +13,9 @@ function FieldConnectorCallback({ Component, value, disabled, setValue, errors,
|
|
|
13
13
|
}, [
|
|
14
14
|
setValue
|
|
15
15
|
]);
|
|
16
|
-
return
|
|
16
|
+
return React.createElement("div", {
|
|
17
17
|
"data-test-id": "slug-editor"
|
|
18
|
-
},
|
|
18
|
+
}, React.createElement(Component, {
|
|
19
19
|
locale: locale,
|
|
20
20
|
createdAt: createdAt,
|
|
21
21
|
performUniqueCheck: performUniqueCheck,
|
|
@@ -63,20 +63,20 @@ export function SlugEditor({ isInitiallyDisabled, autoGenerationStrategy = 'fiel
|
|
|
63
63
|
entrySys.id,
|
|
64
64
|
cma.entry
|
|
65
65
|
]);
|
|
66
|
-
return
|
|
66
|
+
return React.createElement(TrackingFieldConnector, {
|
|
67
67
|
sdk: baseSdk,
|
|
68
68
|
field: field,
|
|
69
69
|
defaultLocale: locales.default,
|
|
70
70
|
isOptionalLocaleWithFallback: isOptionalLocaleWithFallback,
|
|
71
71
|
trackingFieldId: trackingFieldId
|
|
72
|
-
}, ({ titleValue, isPublished, isSame })
|
|
72
|
+
}, ({ titleValue, isPublished, isSame })=>React.createElement(FieldConnector, {
|
|
73
73
|
field: field,
|
|
74
74
|
isInitiallyDisabled: isInitiallyDisabled,
|
|
75
75
|
debounce: 0
|
|
76
76
|
}, ({ value, errors, disabled, setValue, externalReset })=>{
|
|
77
77
|
const shouldTrackTitle = autoGenerationStrategy !== 'document' && isPublished === false && isSame === false;
|
|
78
78
|
const Component = shouldTrackTitle ? SlugEditorField : SlugEditorFieldStatic;
|
|
79
|
-
return
|
|
79
|
+
return React.createElement(FieldConnectorCallback, {
|
|
80
80
|
Component: Component,
|
|
81
81
|
titleValue: titleValue,
|
|
82
82
|
value: value,
|
|
@@ -33,7 +33,7 @@ function createMocks(initialValues = {}) {
|
|
|
33
33
|
}), initialValues.titleField || '');
|
|
34
34
|
const [descriptionField] = createFakeFieldAPI((field)=>({
|
|
35
35
|
...field,
|
|
36
|
-
id:
|
|
36
|
+
id: "description-id",
|
|
37
37
|
setValue: vi.fn().mockImplementation(field.setValue),
|
|
38
38
|
getValue: vi.fn().mockImplementation(field.getValue),
|
|
39
39
|
onValueChanged: vi.fn().mockImplementation(field.onValueChanged)
|
|
@@ -62,7 +62,7 @@ function createMocks(initialValues = {}) {
|
|
|
62
62
|
fields: {
|
|
63
63
|
'title-id': titleField,
|
|
64
64
|
'entry-id': field,
|
|
65
|
-
|
|
65
|
+
"description-id": descriptionField
|
|
66
66
|
}
|
|
67
67
|
},
|
|
68
68
|
contentType: {
|
|
@@ -84,7 +84,7 @@ describe('SlugEditor', ()=>{
|
|
|
84
84
|
sdk.entry.getSys.mockReturnValue({
|
|
85
85
|
publishedVersion: 2
|
|
86
86
|
});
|
|
87
|
-
render(
|
|
87
|
+
render(React.createElement(SlugEditor, {
|
|
88
88
|
field: field,
|
|
89
89
|
baseSdk: sdk,
|
|
90
90
|
isInitiallyDisabled: false
|
|
@@ -100,7 +100,7 @@ describe('SlugEditor', ()=>{
|
|
|
100
100
|
it('when title and slug are the same field', async ()=>{
|
|
101
101
|
const { field, titleField, sdk } = createMocks();
|
|
102
102
|
sdk.contentType.displayField = 'entry-id';
|
|
103
|
-
render(
|
|
103
|
+
render(React.createElement(SlugEditor, {
|
|
104
104
|
field: field,
|
|
105
105
|
baseSdk: sdk,
|
|
106
106
|
isInitiallyDisabled: false
|
|
@@ -115,7 +115,7 @@ describe('SlugEditor', ()=>{
|
|
|
115
115
|
titleField: 'Hello world!',
|
|
116
116
|
field: 'something-different'
|
|
117
117
|
});
|
|
118
|
-
render(
|
|
118
|
+
render(React.createElement(SlugEditor, {
|
|
119
119
|
field: field,
|
|
120
120
|
baseSdk: sdk,
|
|
121
121
|
isInitiallyDisabled: false
|
|
@@ -144,7 +144,7 @@ describe('SlugEditor', ()=>{
|
|
|
144
144
|
sdk.cma.entry.getMany.mockResolvedValue({
|
|
145
145
|
total: 0
|
|
146
146
|
});
|
|
147
|
-
const { queryByTestId, queryByText } = render(
|
|
147
|
+
const { queryByTestId, queryByText } = render(React.createElement(SlugEditor, {
|
|
148
148
|
field: field,
|
|
149
149
|
baseSdk: sdk,
|
|
150
150
|
isInitiallyDisabled: false
|
|
@@ -183,7 +183,7 @@ describe('SlugEditor', ()=>{
|
|
|
183
183
|
sdk.cma.entry.getMany.mockResolvedValue({
|
|
184
184
|
total: 2
|
|
185
185
|
});
|
|
186
|
-
const { queryByTestId, queryByText, getByTestId } = render(
|
|
186
|
+
const { queryByTestId, queryByText, getByTestId } = render(React.createElement(SlugEditor, {
|
|
187
187
|
field: field,
|
|
188
188
|
baseSdk: sdk,
|
|
189
189
|
isInitiallyDisabled: false
|
|
@@ -248,7 +248,7 @@ describe('SlugEditor', ()=>{
|
|
|
248
248
|
sdk.cma.entry.getMany.mockResolvedValue({
|
|
249
249
|
total: 2
|
|
250
250
|
});
|
|
251
|
-
const { queryByText, getByTestId } = render(
|
|
251
|
+
const { queryByText, getByTestId } = render(React.createElement(SlugEditor, {
|
|
252
252
|
field: field,
|
|
253
253
|
baseSdk: sdk,
|
|
254
254
|
isInitiallyDisabled: false
|
|
@@ -262,7 +262,7 @@ describe('SlugEditor', ()=>{
|
|
|
262
262
|
it('hides duplicate warning when publish sets hasError', async ()=>{
|
|
263
263
|
const performUniqueCheck = vi.fn().mockResolvedValue(false);
|
|
264
264
|
const setValue = vi.fn();
|
|
265
|
-
const { queryByTestId } = render(
|
|
265
|
+
const { queryByTestId } = render(React.createElement(SlugEditorFieldStatic, {
|
|
266
266
|
hasError: true,
|
|
267
267
|
isUniqueValidationEnabled: false,
|
|
268
268
|
isOptionalLocaleWithFallback: false,
|
|
@@ -286,7 +286,7 @@ describe('SlugEditor', ()=>{
|
|
|
286
286
|
field: '',
|
|
287
287
|
titleField: ''
|
|
288
288
|
});
|
|
289
|
-
render(
|
|
289
|
+
render(React.createElement(SlugEditor, {
|
|
290
290
|
field: field,
|
|
291
291
|
baseSdk: sdk,
|
|
292
292
|
isInitiallyDisabled: true
|
|
@@ -304,7 +304,7 @@ describe('SlugEditor', ()=>{
|
|
|
304
304
|
field: '',
|
|
305
305
|
titleField: ''
|
|
306
306
|
});
|
|
307
|
-
render(
|
|
307
|
+
render(React.createElement(SlugEditor, {
|
|
308
308
|
field: field,
|
|
309
309
|
baseSdk: sdk,
|
|
310
310
|
isInitiallyDisabled: false
|
|
@@ -332,7 +332,7 @@ describe('SlugEditor', ()=>{
|
|
|
332
332
|
field: '',
|
|
333
333
|
titleField: 'This is initial title value'
|
|
334
334
|
});
|
|
335
|
-
render(
|
|
335
|
+
render(React.createElement(SlugEditor, {
|
|
336
336
|
field: field,
|
|
337
337
|
baseSdk: sdk,
|
|
338
338
|
isInitiallyDisabled: false
|
|
@@ -354,7 +354,7 @@ describe('SlugEditor', ()=>{
|
|
|
354
354
|
field: '',
|
|
355
355
|
titleField: ''
|
|
356
356
|
});
|
|
357
|
-
const { getByTestId } = render(
|
|
357
|
+
const { getByTestId } = render(React.createElement(SlugEditor, {
|
|
358
358
|
field: field,
|
|
359
359
|
baseSdk: sdk,
|
|
360
360
|
isInitiallyDisabled: false
|
|
@@ -392,7 +392,7 @@ describe('SlugEditor', ()=>{
|
|
|
392
392
|
field: '',
|
|
393
393
|
titleField: ''
|
|
394
394
|
});
|
|
395
|
-
const { getByTestId } = render(
|
|
395
|
+
const { getByTestId } = render(React.createElement(SlugEditor, {
|
|
396
396
|
field: field,
|
|
397
397
|
baseSdk: sdk,
|
|
398
398
|
isInitiallyDisabled: false
|
|
@@ -442,7 +442,7 @@ describe('SlugEditor', ()=>{
|
|
|
442
442
|
'de-DE': undefined,
|
|
443
443
|
'ru-RU': undefined
|
|
444
444
|
};
|
|
445
|
-
render(
|
|
445
|
+
render(React.createElement(SlugEditor, {
|
|
446
446
|
field: field,
|
|
447
447
|
baseSdk: sdk,
|
|
448
448
|
isInitiallyDisabled: false
|
|
@@ -470,7 +470,7 @@ describe('SlugEditor', ()=>{
|
|
|
470
470
|
'de-DE': undefined,
|
|
471
471
|
'ru-RU': 'de-DE'
|
|
472
472
|
};
|
|
473
|
-
render(
|
|
473
|
+
render(React.createElement(SlugEditor, {
|
|
474
474
|
field: field,
|
|
475
475
|
baseSdk: sdk,
|
|
476
476
|
isInitiallyDisabled: false
|
|
@@ -497,7 +497,7 @@ describe('SlugEditor', ()=>{
|
|
|
497
497
|
}
|
|
498
498
|
}
|
|
499
499
|
];
|
|
500
|
-
render(
|
|
500
|
+
render(React.createElement(SlugEditor, {
|
|
501
501
|
field: field,
|
|
502
502
|
baseSdk: sdk,
|
|
503
503
|
isInitiallyDisabled: false
|
|
@@ -524,7 +524,7 @@ describe('SlugEditor', ()=>{
|
|
|
524
524
|
}
|
|
525
525
|
}
|
|
526
526
|
];
|
|
527
|
-
render(
|
|
527
|
+
render(React.createElement(SlugEditor, {
|
|
528
528
|
field: field,
|
|
529
529
|
baseSdk: sdk,
|
|
530
530
|
isInitiallyDisabled: false
|
|
@@ -541,15 +541,15 @@ describe('SlugEditor', ()=>{
|
|
|
541
541
|
const { field, titleField, descriptionField, sdk } = createMocks({
|
|
542
542
|
field: '',
|
|
543
543
|
titleField: 'This is initial title value',
|
|
544
|
-
descriptionField:
|
|
544
|
+
descriptionField: "This is initial description value"
|
|
545
545
|
});
|
|
546
|
-
render(
|
|
546
|
+
render(React.createElement(SlugEditor, {
|
|
547
547
|
field: field,
|
|
548
548
|
baseSdk: sdk,
|
|
549
549
|
isInitiallyDisabled: false,
|
|
550
550
|
parameters: {
|
|
551
551
|
instance: {
|
|
552
|
-
trackingFieldId:
|
|
552
|
+
trackingFieldId: "description-id"
|
|
553
553
|
}
|
|
554
554
|
}
|
|
555
555
|
}));
|
|
@@ -557,9 +557,9 @@ describe('SlugEditor', ()=>{
|
|
|
557
557
|
expect(titleField.onValueChanged).not.toHaveBeenCalled();
|
|
558
558
|
expect(descriptionField.onValueChanged).toHaveBeenCalledWith('en-US', expect.any(Function));
|
|
559
559
|
expect(field.setValue).toHaveBeenCalledTimes(1);
|
|
560
|
-
expect(field.setValue).toHaveBeenLastCalledWith(
|
|
560
|
+
expect(field.setValue).toHaveBeenLastCalledWith("this-is-initial-description-value");
|
|
561
561
|
});
|
|
562
|
-
await sdk.entry.fields[
|
|
562
|
+
await sdk.entry.fields["description-id"].setValue('Hello world!');
|
|
563
563
|
await waitFor(()=>{
|
|
564
564
|
expect(field.setValue).toHaveBeenCalledTimes(2);
|
|
565
565
|
expect(field.setValue).toHaveBeenLastCalledWith('hello-world');
|
|
@@ -49,11 +49,11 @@ export function SlugEditorFieldStatic(props) {
|
|
|
49
49
|
const hasDuplicate = status === 'duplicate';
|
|
50
50
|
const shouldShowDuplicateAsError = hasDuplicate && isUniqueValidationEnabled && !hasError;
|
|
51
51
|
const shouldShowDuplicateAsWarning = hasDuplicate && !shouldShowDuplicateAsError && !hasError;
|
|
52
|
-
return
|
|
52
|
+
return React.createElement("div", {
|
|
53
53
|
className: styles.inputContainer
|
|
54
|
-
},
|
|
54
|
+
}, React.createElement(LinkSimpleIcon, {
|
|
55
55
|
className: styles.icon
|
|
56
|
-
}),
|
|
56
|
+
}), React.createElement(TextInput, {
|
|
57
57
|
className: styles.input,
|
|
58
58
|
isInvalid: hasError || shouldShowDuplicateAsError,
|
|
59
59
|
isDisabled: isDisabled,
|
|
@@ -70,17 +70,17 @@ export function SlugEditorFieldStatic(props) {
|
|
|
70
70
|
onBlur();
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
|
-
}), status === 'checking' &&
|
|
73
|
+
}), status === 'checking' && React.createElement("div", {
|
|
74
74
|
className: styles.spinnerContainer
|
|
75
|
-
},
|
|
75
|
+
}, React.createElement(Spinner, {
|
|
76
76
|
testId: "slug-editor-spinner"
|
|
77
|
-
})), shouldShowDuplicateAsError &&
|
|
77
|
+
})), shouldShowDuplicateAsError && React.createElement(ValidationMessage, {
|
|
78
78
|
testId: "slug-editor-duplicate-error",
|
|
79
79
|
className: styles.uniqueValidationError
|
|
80
80
|
}, $_i18n._({
|
|
81
81
|
id: "FieldEditors.Slug.SlugEditorField.DuplicateSlugError",
|
|
82
82
|
message: "This slug has already been published in another entry"
|
|
83
|
-
})), shouldShowDuplicateAsWarning &&
|
|
83
|
+
})), shouldShowDuplicateAsWarning && React.createElement(Note, {
|
|
84
84
|
variant: "warning",
|
|
85
85
|
testId: "slug-editor-duplicate-warning",
|
|
86
86
|
className: styles.uniqueValidationError
|
|
@@ -130,7 +130,7 @@ export function SlugEditorField(props) {
|
|
|
130
130
|
areEqual
|
|
131
131
|
]);
|
|
132
132
|
useSlugUpdater(props, check, generateSlug);
|
|
133
|
-
return
|
|
133
|
+
return React.createElement(SlugEditorFieldStatic, {
|
|
134
134
|
...props,
|
|
135
135
|
onChange: ()=>{
|
|
136
136
|
setCheck(false);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/field-editor-slug",
|
|
3
|
-
"version": "3.5.4-canary.
|
|
3
|
+
"version": "3.5.4-canary.30+0e4621f9",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"@contentful/f36-icons": "^6.7.1",
|
|
43
43
|
"@contentful/f36-note": "^6.7.0",
|
|
44
44
|
"@contentful/f36-tokens": "^6.1.2",
|
|
45
|
-
"@contentful/field-editor-shared": "^4.6.3-canary.
|
|
45
|
+
"@contentful/field-editor-shared": "^4.6.3-canary.30+0e4621f9",
|
|
46
46
|
"@emotion/css": "^11.13.5",
|
|
47
47
|
"@types/speakingurl": "^13.0.6",
|
|
48
48
|
"speakingurl": "^14.0.1",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@contentful/app-sdk": "^4.45.0",
|
|
53
53
|
"@contentful/field-editor-test-utils": "^3.2.1",
|
|
54
|
-
"@lingui/core": "5.
|
|
54
|
+
"@lingui/core": "5.9.5"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
57
|
"@contentful/app-sdk": "^4.45.0",
|
|
@@ -68,5 +68,5 @@
|
|
|
68
68
|
"prettier --write"
|
|
69
69
|
]
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "0e4621f97b3a6b65da12df50fa740c00bcd17b1f"
|
|
72
72
|
}
|