@contentful/field-editor-slug 1.1.11 → 1.2.0

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.
@@ -7,916 +7,22 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'defau
7
7
  var React = require('react');
8
8
  var React__default = _interopDefault(React);
9
9
  var fieldEditorShared = require('@contentful/field-editor-shared');
10
+ var f36Components = require('@contentful/f36-components');
11
+ var f36Icons = require('@contentful/f36-icons');
10
12
  var useDebounce = require('use-debounce');
11
13
  var getSlug = _interopDefault(require('speakingurl'));
12
14
  var tokens = _interopDefault(require('@contentful/f36-tokens'));
13
15
  var emotion = require('emotion');
14
- var f36Components = require('@contentful/f36-components');
15
- var f36Icons = require('@contentful/f36-icons');
16
-
17
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
18
- try {
19
- var info = gen[key](arg);
20
- var value = info.value;
21
- } catch (error) {
22
- reject(error);
23
- return;
24
- }
25
-
26
- if (info.done) {
27
- resolve(value);
28
- } else {
29
- Promise.resolve(value).then(_next, _throw);
30
- }
31
- }
32
-
33
- function _asyncToGenerator(fn) {
34
- return function () {
35
- var self = this,
36
- args = arguments;
37
- return new Promise(function (resolve, reject) {
38
- var gen = fn.apply(self, args);
39
-
40
- function _next(value) {
41
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
42
- }
43
-
44
- function _throw(err) {
45
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
46
- }
47
-
48
- _next(undefined);
49
- });
50
- };
51
- }
52
-
53
- function _extends() {
54
- _extends = Object.assign || function (target) {
55
- for (var i = 1; i < arguments.length; i++) {
56
- var source = arguments[i];
57
-
58
- for (var key in source) {
59
- if (Object.prototype.hasOwnProperty.call(source, key)) {
60
- target[key] = source[key];
61
- }
62
- }
63
- }
64
-
65
- return target;
66
- };
67
-
68
- return _extends.apply(this, arguments);
69
- }
70
-
71
- function _inheritsLoose(subClass, superClass) {
72
- subClass.prototype = Object.create(superClass.prototype);
73
- subClass.prototype.constructor = subClass;
74
-
75
- _setPrototypeOf(subClass, superClass);
76
- }
77
-
78
- function _setPrototypeOf(o, p) {
79
- _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
80
- o.__proto__ = p;
81
- return o;
82
- };
83
-
84
- return _setPrototypeOf(o, p);
85
- }
86
-
87
- function createCommonjsModule(fn, module) {
88
- return module = { exports: {} }, fn(module, module.exports), module.exports;
89
- }
90
-
91
- var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
92
- /**
93
- * Copyright (c) 2014-present, Facebook, Inc.
94
- *
95
- * This source code is licensed under the MIT license found in the
96
- * LICENSE file in the root directory of this source tree.
97
- */
98
- var runtime = function (exports) {
99
-
100
- var Op = Object.prototype;
101
- var hasOwn = Op.hasOwnProperty;
102
- var undefined$1; // More compressible than void 0.
103
-
104
- var $Symbol = typeof Symbol === "function" ? Symbol : {};
105
- var iteratorSymbol = $Symbol.iterator || "@@iterator";
106
- var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
107
- var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
108
-
109
- function define(obj, key, value) {
110
- Object.defineProperty(obj, key, {
111
- value: value,
112
- enumerable: true,
113
- configurable: true,
114
- writable: true
115
- });
116
- return obj[key];
117
- }
118
-
119
- try {
120
- // IE 8 has a broken Object.defineProperty that only works on DOM objects.
121
- define({}, "");
122
- } catch (err) {
123
- define = function define(obj, key, value) {
124
- return obj[key] = value;
125
- };
126
- }
127
-
128
- function wrap(innerFn, outerFn, self, tryLocsList) {
129
- // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
130
- var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
131
- var generator = Object.create(protoGenerator.prototype);
132
- var context = new Context(tryLocsList || []); // The ._invoke method unifies the implementations of the .next,
133
- // .throw, and .return methods.
134
-
135
- generator._invoke = makeInvokeMethod(innerFn, self, context);
136
- return generator;
137
- }
138
-
139
- exports.wrap = wrap; // Try/catch helper to minimize deoptimizations. Returns a completion
140
- // record like context.tryEntries[i].completion. This interface could
141
- // have been (and was previously) designed to take a closure to be
142
- // invoked without arguments, but in all the cases we care about we
143
- // already have an existing method we want to call, so there's no need
144
- // to create a new function object. We can even get away with assuming
145
- // the method takes exactly one argument, since that happens to be true
146
- // in every case, so we don't have to touch the arguments object. The
147
- // only additional allocation required is the completion record, which
148
- // has a stable shape and so hopefully should be cheap to allocate.
149
-
150
- function tryCatch(fn, obj, arg) {
151
- try {
152
- return {
153
- type: "normal",
154
- arg: fn.call(obj, arg)
155
- };
156
- } catch (err) {
157
- return {
158
- type: "throw",
159
- arg: err
160
- };
161
- }
162
- }
163
-
164
- var GenStateSuspendedStart = "suspendedStart";
165
- var GenStateSuspendedYield = "suspendedYield";
166
- var GenStateExecuting = "executing";
167
- var GenStateCompleted = "completed"; // Returning this object from the innerFn has the same effect as
168
- // breaking out of the dispatch switch statement.
169
-
170
- var ContinueSentinel = {}; // Dummy constructor functions that we use as the .constructor and
171
- // .constructor.prototype properties for functions that return Generator
172
- // objects. For full spec compliance, you may wish to configure your
173
- // minifier not to mangle the names of these two functions.
174
-
175
- function Generator() {}
176
-
177
- function GeneratorFunction() {}
178
-
179
- function GeneratorFunctionPrototype() {} // This is a polyfill for %IteratorPrototype% for environments that
180
- // don't natively support it.
181
-
182
-
183
- var IteratorPrototype = {};
184
- define(IteratorPrototype, iteratorSymbol, function () {
185
- return this;
186
- });
187
- var getProto = Object.getPrototypeOf;
188
- var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
189
-
190
- if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
191
- // This environment has a native %IteratorPrototype%; use it instead
192
- // of the polyfill.
193
- IteratorPrototype = NativeIteratorPrototype;
194
- }
195
-
196
- var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
197
- GeneratorFunction.prototype = GeneratorFunctionPrototype;
198
- define(Gp, "constructor", GeneratorFunctionPrototype);
199
- define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
200
- GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"); // Helper for defining the .next, .throw, and .return methods of the
201
- // Iterator interface in terms of a single ._invoke method.
202
-
203
- function defineIteratorMethods(prototype) {
204
- ["next", "throw", "return"].forEach(function (method) {
205
- define(prototype, method, function (arg) {
206
- return this._invoke(method, arg);
207
- });
208
- });
209
- }
210
-
211
- exports.isGeneratorFunction = function (genFun) {
212
- var ctor = typeof genFun === "function" && genFun.constructor;
213
- return ctor ? ctor === GeneratorFunction || // For the native GeneratorFunction constructor, the best we can
214
- // do is to check its .name property.
215
- (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
216
- };
217
-
218
- exports.mark = function (genFun) {
219
- if (Object.setPrototypeOf) {
220
- Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
221
- } else {
222
- genFun.__proto__ = GeneratorFunctionPrototype;
223
- define(genFun, toStringTagSymbol, "GeneratorFunction");
224
- }
225
-
226
- genFun.prototype = Object.create(Gp);
227
- return genFun;
228
- }; // Within the body of any async function, `await x` is transformed to
229
- // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
230
- // `hasOwn.call(value, "__await")` to determine if the yielded value is
231
- // meant to be awaited.
232
-
233
-
234
- exports.awrap = function (arg) {
235
- return {
236
- __await: arg
237
- };
238
- };
239
-
240
- function AsyncIterator(generator, PromiseImpl) {
241
- function invoke(method, arg, resolve, reject) {
242
- var record = tryCatch(generator[method], generator, arg);
243
-
244
- if (record.type === "throw") {
245
- reject(record.arg);
246
- } else {
247
- var result = record.arg;
248
- var value = result.value;
249
-
250
- if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
251
- return PromiseImpl.resolve(value.__await).then(function (value) {
252
- invoke("next", value, resolve, reject);
253
- }, function (err) {
254
- invoke("throw", err, resolve, reject);
255
- });
256
- }
257
-
258
- return PromiseImpl.resolve(value).then(function (unwrapped) {
259
- // When a yielded Promise is resolved, its final value becomes
260
- // the .value of the Promise<{value,done}> result for the
261
- // current iteration.
262
- result.value = unwrapped;
263
- resolve(result);
264
- }, function (error) {
265
- // If a rejected Promise was yielded, throw the rejection back
266
- // into the async generator function so it can be handled there.
267
- return invoke("throw", error, resolve, reject);
268
- });
269
- }
270
- }
271
-
272
- var previousPromise;
273
-
274
- function enqueue(method, arg) {
275
- function callInvokeWithMethodAndArg() {
276
- return new PromiseImpl(function (resolve, reject) {
277
- invoke(method, arg, resolve, reject);
278
- });
279
- }
280
-
281
- return previousPromise = // If enqueue has been called before, then we want to wait until
282
- // all previous Promises have been resolved before calling invoke,
283
- // so that results are always delivered in the correct order. If
284
- // enqueue has not been called before, then it is important to
285
- // call invoke immediately, without waiting on a callback to fire,
286
- // so that the async generator function has the opportunity to do
287
- // any necessary setup in a predictable way. This predictability
288
- // is why the Promise constructor synchronously invokes its
289
- // executor callback, and why async functions synchronously
290
- // execute code before the first await. Since we implement simple
291
- // async functions in terms of async generators, it is especially
292
- // important to get this right, even though it requires care.
293
- previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, // Avoid propagating failures to Promises returned by later
294
- // invocations of the iterator.
295
- callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
296
- } // Define the unified helper method that is used to implement .next,
297
- // .throw, and .return (see defineIteratorMethods).
298
-
299
-
300
- this._invoke = enqueue;
301
- }
302
-
303
- defineIteratorMethods(AsyncIterator.prototype);
304
- define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
305
- return this;
306
- });
307
- exports.AsyncIterator = AsyncIterator; // Note that simple async functions are implemented on top of
308
- // AsyncIterator objects; they just return a Promise for the value of
309
- // the final result produced by the iterator.
310
-
311
- exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
312
- if (PromiseImpl === void 0) PromiseImpl = Promise;
313
- var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
314
- return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator.
315
- : iter.next().then(function (result) {
316
- return result.done ? result.value : iter.next();
317
- });
318
- };
319
-
320
- function makeInvokeMethod(innerFn, self, context) {
321
- var state = GenStateSuspendedStart;
322
- return function invoke(method, arg) {
323
- if (state === GenStateExecuting) {
324
- throw new Error("Generator is already running");
325
- }
326
-
327
- if (state === GenStateCompleted) {
328
- if (method === "throw") {
329
- throw arg;
330
- } // Be forgiving, per 25.3.3.3.3 of the spec:
331
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
332
-
333
-
334
- return doneResult();
335
- }
336
-
337
- context.method = method;
338
- context.arg = arg;
339
-
340
- while (true) {
341
- var delegate = context.delegate;
342
-
343
- if (delegate) {
344
- var delegateResult = maybeInvokeDelegate(delegate, context);
345
-
346
- if (delegateResult) {
347
- if (delegateResult === ContinueSentinel) continue;
348
- return delegateResult;
349
- }
350
- }
351
-
352
- if (context.method === "next") {
353
- // Setting context._sent for legacy support of Babel's
354
- // function.sent implementation.
355
- context.sent = context._sent = context.arg;
356
- } else if (context.method === "throw") {
357
- if (state === GenStateSuspendedStart) {
358
- state = GenStateCompleted;
359
- throw context.arg;
360
- }
361
-
362
- context.dispatchException(context.arg);
363
- } else if (context.method === "return") {
364
- context.abrupt("return", context.arg);
365
- }
366
-
367
- state = GenStateExecuting;
368
- var record = tryCatch(innerFn, self, context);
369
-
370
- if (record.type === "normal") {
371
- // If an exception is thrown from innerFn, we leave state ===
372
- // GenStateExecuting and loop back for another invocation.
373
- state = context.done ? GenStateCompleted : GenStateSuspendedYield;
374
-
375
- if (record.arg === ContinueSentinel) {
376
- continue;
377
- }
378
-
379
- return {
380
- value: record.arg,
381
- done: context.done
382
- };
383
- } else if (record.type === "throw") {
384
- state = GenStateCompleted; // Dispatch the exception by looping back around to the
385
- // context.dispatchException(context.arg) call above.
386
-
387
- context.method = "throw";
388
- context.arg = record.arg;
389
- }
390
- }
391
- };
392
- } // Call delegate.iterator[context.method](context.arg) and handle the
393
- // result, either by returning a { value, done } result from the
394
- // delegate iterator, or by modifying context.method and context.arg,
395
- // setting context.delegate to null, and returning the ContinueSentinel.
396
-
397
-
398
- function maybeInvokeDelegate(delegate, context) {
399
- var method = delegate.iterator[context.method];
400
-
401
- if (method === undefined$1) {
402
- // A .throw or .return when the delegate iterator has no .throw
403
- // method always terminates the yield* loop.
404
- context.delegate = null;
405
-
406
- if (context.method === "throw") {
407
- // Note: ["return"] must be used for ES3 parsing compatibility.
408
- if (delegate.iterator["return"]) {
409
- // If the delegate iterator has a return method, give it a
410
- // chance to clean up.
411
- context.method = "return";
412
- context.arg = undefined$1;
413
- maybeInvokeDelegate(delegate, context);
414
-
415
- if (context.method === "throw") {
416
- // If maybeInvokeDelegate(context) changed context.method from
417
- // "return" to "throw", let that override the TypeError below.
418
- return ContinueSentinel;
419
- }
420
- }
421
-
422
- context.method = "throw";
423
- context.arg = new TypeError("The iterator does not provide a 'throw' method");
424
- }
425
-
426
- return ContinueSentinel;
427
- }
428
-
429
- var record = tryCatch(method, delegate.iterator, context.arg);
430
-
431
- if (record.type === "throw") {
432
- context.method = "throw";
433
- context.arg = record.arg;
434
- context.delegate = null;
435
- return ContinueSentinel;
436
- }
437
-
438
- var info = record.arg;
439
-
440
- if (!info) {
441
- context.method = "throw";
442
- context.arg = new TypeError("iterator result is not an object");
443
- context.delegate = null;
444
- return ContinueSentinel;
445
- }
446
-
447
- if (info.done) {
448
- // Assign the result of the finished delegate to the temporary
449
- // variable specified by delegate.resultName (see delegateYield).
450
- context[delegate.resultName] = info.value; // Resume execution at the desired location (see delegateYield).
451
-
452
- context.next = delegate.nextLoc; // If context.method was "throw" but the delegate handled the
453
- // exception, let the outer generator proceed normally. If
454
- // context.method was "next", forget context.arg since it has been
455
- // "consumed" by the delegate iterator. If context.method was
456
- // "return", allow the original .return call to continue in the
457
- // outer generator.
458
-
459
- if (context.method !== "return") {
460
- context.method = "next";
461
- context.arg = undefined$1;
462
- }
463
- } else {
464
- // Re-yield the result returned by the delegate method.
465
- return info;
466
- } // The delegate iterator is finished, so forget it and continue with
467
- // the outer generator.
468
-
469
-
470
- context.delegate = null;
471
- return ContinueSentinel;
472
- } // Define Generator.prototype.{next,throw,return} in terms of the
473
- // unified ._invoke helper method.
474
-
475
-
476
- defineIteratorMethods(Gp);
477
- define(Gp, toStringTagSymbol, "Generator"); // A Generator should always return itself as the iterator object when the
478
- // @@iterator function is called on it. Some browsers' implementations of the
479
- // iterator prototype chain incorrectly implement this, causing the Generator
480
- // object to not be returned from this call. This ensures that doesn't happen.
481
- // See https://github.com/facebook/regenerator/issues/274 for more details.
482
-
483
- define(Gp, iteratorSymbol, function () {
484
- return this;
485
- });
486
- define(Gp, "toString", function () {
487
- return "[object Generator]";
488
- });
489
-
490
- function pushTryEntry(locs) {
491
- var entry = {
492
- tryLoc: locs[0]
493
- };
494
-
495
- if (1 in locs) {
496
- entry.catchLoc = locs[1];
497
- }
498
-
499
- if (2 in locs) {
500
- entry.finallyLoc = locs[2];
501
- entry.afterLoc = locs[3];
502
- }
503
-
504
- this.tryEntries.push(entry);
505
- }
506
-
507
- function resetTryEntry(entry) {
508
- var record = entry.completion || {};
509
- record.type = "normal";
510
- delete record.arg;
511
- entry.completion = record;
512
- }
513
-
514
- function Context(tryLocsList) {
515
- // The root entry object (effectively a try statement without a catch
516
- // or a finally block) gives us a place to store values thrown from
517
- // locations where there is no enclosing try statement.
518
- this.tryEntries = [{
519
- tryLoc: "root"
520
- }];
521
- tryLocsList.forEach(pushTryEntry, this);
522
- this.reset(true);
523
- }
524
-
525
- exports.keys = function (object) {
526
- var keys = [];
527
-
528
- for (var key in object) {
529
- keys.push(key);
530
- }
531
-
532
- keys.reverse(); // Rather than returning an object with a next method, we keep
533
- // things simple and return the next function itself.
534
-
535
- return function next() {
536
- while (keys.length) {
537
- var key = keys.pop();
538
-
539
- if (key in object) {
540
- next.value = key;
541
- next.done = false;
542
- return next;
543
- }
544
- } // To avoid creating an additional object, we just hang the .value
545
- // and .done properties off the next function object itself. This
546
- // also ensures that the minifier will not anonymize the function.
547
-
548
-
549
- next.done = true;
550
- return next;
551
- };
552
- };
553
-
554
- function values(iterable) {
555
- if (iterable) {
556
- var iteratorMethod = iterable[iteratorSymbol];
557
-
558
- if (iteratorMethod) {
559
- return iteratorMethod.call(iterable);
560
- }
561
-
562
- if (typeof iterable.next === "function") {
563
- return iterable;
564
- }
565
-
566
- if (!isNaN(iterable.length)) {
567
- var i = -1,
568
- next = function next() {
569
- while (++i < iterable.length) {
570
- if (hasOwn.call(iterable, i)) {
571
- next.value = iterable[i];
572
- next.done = false;
573
- return next;
574
- }
575
- }
576
-
577
- next.value = undefined$1;
578
- next.done = true;
579
- return next;
580
- };
581
-
582
- return next.next = next;
583
- }
584
- } // Return an iterator with no values.
585
-
586
-
587
- return {
588
- next: doneResult
589
- };
590
- }
591
-
592
- exports.values = values;
593
-
594
- function doneResult() {
595
- return {
596
- value: undefined$1,
597
- done: true
598
- };
599
- }
600
-
601
- Context.prototype = {
602
- constructor: Context,
603
- reset: function reset(skipTempReset) {
604
- this.prev = 0;
605
- this.next = 0; // Resetting context._sent for legacy support of Babel's
606
- // function.sent implementation.
607
-
608
- this.sent = this._sent = undefined$1;
609
- this.done = false;
610
- this.delegate = null;
611
- this.method = "next";
612
- this.arg = undefined$1;
613
- this.tryEntries.forEach(resetTryEntry);
614
-
615
- if (!skipTempReset) {
616
- for (var name in this) {
617
- // Not sure about the optimal order of these conditions:
618
- if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
619
- this[name] = undefined$1;
620
- }
621
- }
622
- }
623
- },
624
- stop: function stop() {
625
- this.done = true;
626
- var rootEntry = this.tryEntries[0];
627
- var rootRecord = rootEntry.completion;
628
-
629
- if (rootRecord.type === "throw") {
630
- throw rootRecord.arg;
631
- }
632
-
633
- return this.rval;
634
- },
635
- dispatchException: function dispatchException(exception) {
636
- if (this.done) {
637
- throw exception;
638
- }
639
-
640
- var context = this;
641
-
642
- function handle(loc, caught) {
643
- record.type = "throw";
644
- record.arg = exception;
645
- context.next = loc;
646
-
647
- if (caught) {
648
- // If the dispatched exception was caught by a catch block,
649
- // then let that catch block handle the exception normally.
650
- context.method = "next";
651
- context.arg = undefined$1;
652
- }
653
-
654
- return !!caught;
655
- }
656
16
 
657
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
658
- var entry = this.tryEntries[i];
659
- var record = entry.completion;
660
-
661
- if (entry.tryLoc === "root") {
662
- // Exception thrown outside of any try block that could handle
663
- // it, so set the completion value of the entire function to
664
- // throw the exception.
665
- return handle("end");
666
- }
667
-
668
- if (entry.tryLoc <= this.prev) {
669
- var hasCatch = hasOwn.call(entry, "catchLoc");
670
- var hasFinally = hasOwn.call(entry, "finallyLoc");
671
-
672
- if (hasCatch && hasFinally) {
673
- if (this.prev < entry.catchLoc) {
674
- return handle(entry.catchLoc, true);
675
- } else if (this.prev < entry.finallyLoc) {
676
- return handle(entry.finallyLoc);
677
- }
678
- } else if (hasCatch) {
679
- if (this.prev < entry.catchLoc) {
680
- return handle(entry.catchLoc, true);
681
- }
682
- } else if (hasFinally) {
683
- if (this.prev < entry.finallyLoc) {
684
- return handle(entry.finallyLoc);
685
- }
686
- } else {
687
- throw new Error("try statement without catch or finally");
688
- }
689
- }
690
- }
691
- },
692
- abrupt: function abrupt(type, arg) {
693
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
694
- var entry = this.tryEntries[i];
695
-
696
- if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
697
- var finallyEntry = entry;
698
- break;
699
- }
700
- }
701
-
702
- if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
703
- // Ignore the finally entry if control is not jumping to a
704
- // location outside the try/catch block.
705
- finallyEntry = null;
706
- }
707
-
708
- var record = finallyEntry ? finallyEntry.completion : {};
709
- record.type = type;
710
- record.arg = arg;
711
-
712
- if (finallyEntry) {
713
- this.method = "next";
714
- this.next = finallyEntry.finallyLoc;
715
- return ContinueSentinel;
716
- }
717
-
718
- return this.complete(record);
719
- },
720
- complete: function complete(record, afterLoc) {
721
- if (record.type === "throw") {
722
- throw record.arg;
723
- }
724
-
725
- if (record.type === "break" || record.type === "continue") {
726
- this.next = record.arg;
727
- } else if (record.type === "return") {
728
- this.rval = this.arg = record.arg;
729
- this.method = "return";
730
- this.next = "end";
731
- } else if (record.type === "normal" && afterLoc) {
732
- this.next = afterLoc;
733
- }
734
-
735
- return ContinueSentinel;
736
- },
737
- finish: function finish(finallyLoc) {
738
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
739
- var entry = this.tryEntries[i];
740
-
741
- if (entry.finallyLoc === finallyLoc) {
742
- this.complete(entry.completion, entry.afterLoc);
743
- resetTryEntry(entry);
744
- return ContinueSentinel;
745
- }
746
- }
747
- },
748
- "catch": function _catch(tryLoc) {
749
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
750
- var entry = this.tryEntries[i];
751
-
752
- if (entry.tryLoc === tryLoc) {
753
- var record = entry.completion;
754
-
755
- if (record.type === "throw") {
756
- var thrown = record.arg;
757
- resetTryEntry(entry);
758
- }
759
-
760
- return thrown;
761
- }
762
- } // The context.catch method must only be called with a location
763
- // argument that corresponds to a known catch block.
764
-
765
-
766
- throw new Error("illegal catch attempt");
767
- },
768
- delegateYield: function delegateYield(iterable, resultName, nextLoc) {
769
- this.delegate = {
770
- iterator: values(iterable),
771
- resultName: resultName,
772
- nextLoc: nextLoc
773
- };
774
-
775
- if (this.method === "next") {
776
- // Deliberately forget the last sent value so that we don't
777
- // accidentally pass it on to the delegate.
778
- this.arg = undefined$1;
779
- }
780
-
781
- return ContinueSentinel;
782
- }
783
- }; // Regardless of whether this script is executing as a CommonJS module
784
- // or not, return the runtime object so that we can declare the variable
785
- // regeneratorRuntime in the outer scope, which allows this module to be
786
- // injected easily by `bin/regenerator --include-runtime script.js`.
787
-
788
- return exports;
789
- }( // If this script is executing as a CommonJS module, use module.exports
790
- // as the regeneratorRuntime namespace. Otherwise create a new empty
791
- // object. Either way, the resulting object will be used to initialize
792
- // the regeneratorRuntime variable at the top of this file.
793
- module.exports );
794
-
795
- try {
796
- regeneratorRuntime = runtime;
797
- } catch (accidentalStrictMode) {
798
- // This module should not be running in strict mode, so the above
799
- // assignment should always work unless something is misconfigured. Just
800
- // in case runtime.js accidentally runs in strict mode, in modern engines
801
- // we can explicitly access globalThis. In older engines we can escape
802
- // strict mode using a global Function call. This could conceivably fail
803
- // if a Content Security Policy forbids using Function, but in that case
804
- // the proper solution is to fix the accidental strict mode problem. If
805
- // you've misconfigured your bundler to force strict mode and applied a
806
- // CSP to forbid Function, and you're not willing to fix either of those
807
- // problems, please detail your unique predicament in a GitHub issue.
808
- if (typeof globalThis === "object") {
809
- globalThis.regeneratorRuntime = runtime;
810
- } else {
811
- Function("r", "regeneratorRuntime = r")(runtime);
812
- }
813
- }
814
- });
815
-
816
- function getTitleField(sdk, trackingFieldId) {
817
- var entry = sdk.entry,
818
- contentType = sdk.contentType;
819
-
820
- if (trackingFieldId && entry.fields[trackingFieldId]) {
821
- return entry.fields[trackingFieldId];
822
- }
823
-
824
- return entry.fields[contentType.displayField];
825
- }
826
-
827
- var TrackingFieldConnector = /*#__PURE__*/function (_React$Component) {
828
- _inheritsLoose(TrackingFieldConnector, _React$Component);
829
-
830
- function TrackingFieldConnector(props) {
831
- var _this;
832
-
833
- _this = _React$Component.call(this, props) || this;
834
- _this.unsubscribeValue = null;
835
- _this.unsubscribeLocalizedValue = null;
836
- _this.unsubscribeSysChanges = null;
837
- var titleField = getTitleField(props.sdk, props.trackingFieldId);
838
- var entrySys = props.sdk.entry.getSys();
839
- var isSame = titleField ? props.field.id === titleField.id : false;
840
- _this.state = {
841
- titleValue: titleField ? titleField.getValue() : '',
842
- isPublished: Boolean(entrySys.publishedVersion),
843
- isSame: isSame
844
- };
845
- return _this;
846
- }
847
-
848
- var _proto = TrackingFieldConnector.prototype;
849
-
850
- _proto.componentDidMount = function componentDidMount() {
851
- var _this2 = this;
852
-
853
- this.unsubscribeSysChanges = this.props.sdk.entry.onSysChanged(function (sys) {
854
- _this2.setState({
855
- isPublished: Boolean(sys.publishedVersion)
856
- });
857
- });
858
- var titleField = getTitleField(this.props.sdk, this.props.trackingFieldId); // the content type's display field might not exist
859
-
860
- if (!titleField) {
861
- return;
862
- }
863
-
864
- if (!this.state.isSame) {
865
- this.unsubscribeLocalizedValue = titleField.onValueChanged(this.props.field.locale, function (value) {
866
- _this2.setState({
867
- titleValue: value
868
- });
869
- });
870
- }
871
-
872
- if (this.props.field.locale !== this.props.defaultLocale) {
873
- if (!this.props.isOptionalLocaleWithFallback) {
874
- this.unsubscribeValue = titleField.onValueChanged(this.props.defaultLocale, function (value) {
875
- if (!titleField.getValue(_this2.props.field.locale)) {
876
- _this2.setState({
877
- titleValue: value
878
- });
879
- }
880
- });
881
- }
882
- }
883
- };
884
-
885
- _proto.componentWillUnmount = function componentWillUnmount() {
886
- if (typeof this.unsubscribeValue === 'function') {
887
- this.unsubscribeValue();
888
- }
889
-
890
- if (typeof this.unsubscribeLocalizedValue === 'function') {
891
- this.unsubscribeLocalizedValue();
892
- }
893
-
894
- if (typeof this.unsubscribeSysChanges === 'function') {
895
- this.unsubscribeSysChanges();
896
- }
897
- };
898
-
899
- _proto.render = function render() {
900
- return this.props.children(_extends({}, this.state));
901
- };
902
-
903
- return TrackingFieldConnector;
904
- }(React__default.Component);
905
- TrackingFieldConnector.defaultProps = {
906
- children: function children() {
907
- return null;
908
- }
909
- };
910
-
911
- var CF_GENERATED_SLUG_MAX_LENGTH = 75;
912
- var languages = ['ar', 'az', 'cs', 'de', 'dv', 'en', 'es', 'fa', 'fi', 'fr', 'ge', 'gr', 'hu', 'it', 'lt', 'lv', 'my', 'mk', 'nl', 'pl', 'pt', 'ro', 'ru', 'sk', 'sr', 'tr', 'uk', 'vn'];
17
+ const CF_GENERATED_SLUG_MAX_LENGTH = 75;
18
+ const languages = ['ar', 'az', 'cs', 'de', 'dv', 'en', 'es', 'fa', 'fi', 'fr', 'ge', 'gr', 'hu', 'it', 'lt', 'lv', 'my', 'mk', 'nl', 'pl', 'pt', 'ro', 'ru', 'sk', 'sr', 'tr', 'uk', 'vn'];
913
19
  /**
914
20
  * Extracts the first two lowercased characters from the locale,
915
21
  * and returns the supported language prefix.
916
22
  */
917
23
 
918
24
  function supportedLanguage(locale) {
919
- var prefix = locale.slice(0, 2).toLowerCase();
25
+ const prefix = locale.slice(0, 2).toLowerCase();
920
26
  return languages[languages.indexOf(prefix)];
921
27
  }
922
28
  /**
@@ -932,11 +38,7 @@ function supportedLanguage(locale) {
932
38
  */
933
39
 
934
40
 
935
- function slugify(text, locale) {
936
- if (locale === void 0) {
937
- locale = 'en';
938
- }
939
-
41
+ function slugify(text, locale = 'en') {
940
42
  return getSlug(text, {
941
43
  separator: '-',
942
44
  lang: supportedLanguage(locale) || 'en',
@@ -951,29 +53,29 @@ function slugify(text, locale) {
951
53
  }
952
54
 
953
55
  function formatTwoDigit(num) {
954
- var asString = String(num);
955
- return asString.length === 1 ? "0" + asString : asString;
56
+ const asString = String(num);
57
+ return asString.length === 1 ? `0${asString}` : asString;
956
58
  }
957
59
 
958
60
  function formatUtcDate(date) {
959
- var year = date.getFullYear();
960
- var month = formatTwoDigit(date.getUTCMonth() + 1);
961
- var day = formatTwoDigit(date.getUTCDate());
962
- var hour = formatTwoDigit(date.getUTCHours());
963
- var minutes = formatTwoDigit(date.getUTCMinutes());
964
- var seconds = formatTwoDigit(date.getUTCSeconds());
965
- return year + " " + month + " " + day + " at " + hour + " " + minutes + " " + seconds;
61
+ const year = date.getFullYear();
62
+ const month = formatTwoDigit(date.getUTCMonth() + 1);
63
+ const day = formatTwoDigit(date.getUTCDate());
64
+ const hour = formatTwoDigit(date.getUTCHours());
65
+ const minutes = formatTwoDigit(date.getUTCMinutes());
66
+ const seconds = formatTwoDigit(date.getUTCSeconds());
67
+ return `${year} ${month} ${day} at ${hour} ${minutes} ${seconds}`;
966
68
  }
967
69
 
968
- function untitledSlug(_ref) {
969
- var isOptionalLocaleWithFallback = _ref.isOptionalLocaleWithFallback,
970
- createdAt = _ref.createdAt;
971
-
70
+ function untitledSlug({
71
+ isOptionalLocaleWithFallback,
72
+ createdAt
73
+ }) {
972
74
  if (isOptionalLocaleWithFallback) {
973
75
  return ''; // Will result in `undefined` slug.
974
76
  }
975
77
 
976
- var createdAtFormatted = formatUtcDate(new Date(createdAt));
78
+ const createdAtFormatted = formatUtcDate(new Date(createdAt));
977
79
  return slugify('Untitled entry ' + createdAtFormatted, 'en-US');
978
80
  }
979
81
 
@@ -981,13 +83,13 @@ function makeSlug(title, options) {
981
83
  return title ? slugify(title, options.locale) : untitledSlug(options);
982
84
  }
983
85
 
984
- var inputContainer = /*#__PURE__*/emotion.css({
86
+ const inputContainer = /*#__PURE__*/emotion.css({
985
87
  position: 'relative'
986
88
  });
987
- var input = /*#__PURE__*/emotion.css({
89
+ const input = /*#__PURE__*/emotion.css({
988
90
  paddingLeft: '40px'
989
91
  });
990
- var icon = /*#__PURE__*/emotion.css({
92
+ const icon = /*#__PURE__*/emotion.css({
991
93
  position: 'absolute',
992
94
  left: '10px',
993
95
  top: '8px',
@@ -996,32 +98,34 @@ var icon = /*#__PURE__*/emotion.css({
996
98
  height: '25px',
997
99
  fill: tokens.gray500
998
100
  });
999
- var spinnerContainer = /*#__PURE__*/emotion.css({
101
+ const spinnerContainer = /*#__PURE__*/emotion.css({
1000
102
  position: 'absolute',
1001
103
  zIndex: 2,
1002
104
  right: '8px',
1003
105
  top: '8px'
1004
106
  });
1005
- var uniqueValidationError = /*#__PURE__*/emotion.css({
107
+ const uniqueValidationError = /*#__PURE__*/emotion.css({
1006
108
  marginTop: tokens.spacingS
1007
109
  });
1008
110
 
1009
111
  function useSlugUpdater(props, check) {
1010
- var value = props.value,
1011
- setValue = props.setValue,
1012
- createdAt = props.createdAt,
1013
- locale = props.locale,
1014
- titleValue = props.titleValue,
1015
- isOptionalLocaleWithFallback = props.isOptionalLocaleWithFallback;
1016
- React__default.useEffect(function () {
112
+ const {
113
+ value,
114
+ setValue,
115
+ createdAt,
116
+ locale,
117
+ titleValue,
118
+ isOptionalLocaleWithFallback
119
+ } = props;
120
+ React__default.useEffect(() => {
1017
121
  if (check === false) {
1018
122
  return;
1019
123
  }
1020
124
 
1021
- var newSlug = makeSlug(titleValue, {
1022
- isOptionalLocaleWithFallback: isOptionalLocaleWithFallback,
1023
- locale: locale,
1024
- createdAt: createdAt
125
+ const newSlug = makeSlug(titleValue, {
126
+ isOptionalLocaleWithFallback,
127
+ locale,
128
+ createdAt
1025
129
  });
1026
130
 
1027
131
  if (newSlug !== value) {
@@ -1031,31 +135,27 @@ function useSlugUpdater(props, check) {
1031
135
  }
1032
136
 
1033
137
  function useUniqueChecker(props) {
1034
- var performUniqueCheck = props.performUniqueCheck;
1035
-
1036
- var _React$useState = React__default.useState(props.value ? 'checking' : 'unique'),
1037
- status = _React$useState[0],
1038
- setStatus = _React$useState[1];
1039
-
1040
- var _useDebounce = useDebounce.useDebounce(props.value, 1000),
1041
- debouncedValue = _useDebounce[0];
138
+ const {
139
+ performUniqueCheck
140
+ } = props;
141
+ const [status, setStatus] = React__default.useState(props.value ? 'checking' : 'unique');
142
+ const [debouncedValue] = useDebounce.useDebounce(props.value, 1000);
1042
143
  /**
1043
144
  * Check the uniqueness of the slug in the current space.
1044
145
  * The slug is unique if there is no published entry other than the
1045
146
  * current one, with the same slug.
1046
147
  */
1047
148
 
1048
-
1049
- React__default.useEffect(function () {
149
+ React__default.useEffect(() => {
1050
150
  if (!debouncedValue) {
1051
151
  setStatus('unique');
1052
152
  return;
1053
153
  }
1054
154
 
1055
155
  setStatus('checking');
1056
- performUniqueCheck(debouncedValue).then(function (unique) {
156
+ performUniqueCheck(debouncedValue).then(unique => {
1057
157
  setStatus(unique ? 'unique' : 'duplicate');
1058
- })["catch"](function () {
158
+ }).catch(() => {
1059
159
  setStatus('checking');
1060
160
  });
1061
161
  }, [debouncedValue, performUniqueCheck]);
@@ -1063,13 +163,15 @@ function useUniqueChecker(props) {
1063
163
  }
1064
164
 
1065
165
  function SlugEditorFieldStatic(props) {
1066
- var hasError = props.hasError,
1067
- isDisabled = props.isDisabled,
1068
- value = props.value,
1069
- setValue = props.setValue,
1070
- _onChange = props.onChange,
1071
- _onBlur = props.onBlur;
1072
- var status = useUniqueChecker(props);
166
+ const {
167
+ hasError,
168
+ isDisabled,
169
+ value,
170
+ setValue,
171
+ onChange,
172
+ onBlur
173
+ } = props;
174
+ const status = useUniqueChecker(props);
1073
175
  return React__default.createElement("div", {
1074
176
  className: inputContainer
1075
177
  }, React__default.createElement(f36Icons.LinkIcon, {
@@ -1079,16 +181,16 @@ function SlugEditorFieldStatic(props) {
1079
181
  isInvalid: hasError || status === 'duplicate',
1080
182
  isDisabled: isDisabled,
1081
183
  value: value || '',
1082
- onChange: function onChange(e) {
184
+ onChange: e => {
1083
185
  setValue(e.target.value);
1084
186
 
1085
- if (_onChange) {
1086
- _onChange();
187
+ if (onChange) {
188
+ onChange();
1087
189
  }
1088
190
  },
1089
- onBlur: function onBlur() {
1090
- if (_onBlur) {
1091
- _onBlur();
191
+ onBlur: () => {
192
+ if (onBlur) {
193
+ onBlur();
1092
194
  }
1093
195
  }
1094
196
  }), status === 'checking' && React__default.createElement("div", {
@@ -1101,21 +203,22 @@ function SlugEditorFieldStatic(props) {
1101
203
  }, "This slug has already been published in another entry"));
1102
204
  }
1103
205
  function SlugEditorField(props) {
1104
- var titleValue = props.titleValue,
1105
- isOptionalLocaleWithFallback = props.isOptionalLocaleWithFallback,
1106
- locale = props.locale,
1107
- createdAt = props.createdAt,
1108
- value = props.value;
1109
- var areEqual = React__default.useCallback(function () {
1110
- var potentialSlug = makeSlug(titleValue, {
206
+ const {
207
+ titleValue,
208
+ isOptionalLocaleWithFallback,
209
+ locale,
210
+ createdAt,
211
+ value
212
+ } = props;
213
+ const areEqual = React__default.useCallback(() => {
214
+ const potentialSlug = makeSlug(titleValue, {
1111
215
  isOptionalLocaleWithFallback: isOptionalLocaleWithFallback,
1112
216
  locale: locale,
1113
217
  createdAt: createdAt
1114
218
  });
1115
219
  return value === potentialSlug;
1116
220
  }, [titleValue, isOptionalLocaleWithFallback, locale, createdAt, value]);
1117
-
1118
- var _React$useState2 = React__default.useState(function () {
221
+ const [check, setCheck] = React__default.useState(() => {
1119
222
  if (props.value) {
1120
223
  if (!props.titleValue) {
1121
224
  return false;
@@ -1125,70 +228,137 @@ function SlugEditorField(props) {
1125
228
  }
1126
229
 
1127
230
  return true;
1128
- }),
1129
- check = _React$useState2[0],
1130
- setCheck = _React$useState2[1];
1131
-
1132
- React__default.useEffect(function () {
231
+ });
232
+ React__default.useEffect(() => {
1133
233
  if (areEqual()) {
1134
234
  setCheck(true);
1135
235
  }
1136
236
  }, [props.titleValue, areEqual]);
1137
237
  useSlugUpdater(props, check);
1138
- return React__default.createElement(SlugEditorFieldStatic, _extends({}, props, {
1139
- onChange: function onChange() {
238
+ return React__default.createElement(SlugEditorFieldStatic, { ...props,
239
+ onChange: () => {
1140
240
  setCheck(false);
1141
241
  },
1142
- onBlur: function onBlur() {
242
+ onBlur: () => {
1143
243
  if (areEqual()) {
1144
244
  setCheck(true);
1145
245
  }
1146
246
  }
1147
- }));
247
+ });
1148
248
  }
1149
249
 
1150
- function isSupportedFieldTypes(val) {
1151
- return val === 'Symbol';
250
+ function getTitleField(sdk, trackingFieldId) {
251
+ const {
252
+ entry,
253
+ contentType
254
+ } = sdk;
255
+
256
+ if (trackingFieldId && entry.fields[trackingFieldId]) {
257
+ return entry.fields[trackingFieldId];
258
+ }
259
+
260
+ return entry.fields[contentType.displayField];
1152
261
  }
1153
262
 
1154
- function FieldConnectorCallback(_ref) {
1155
- var Component = _ref.Component,
1156
- value = _ref.value,
1157
- disabled = _ref.disabled,
1158
- setValue = _ref.setValue,
1159
- errors = _ref.errors,
1160
- titleValue = _ref.titleValue,
1161
- isOptionalLocaleWithFallback = _ref.isOptionalLocaleWithFallback,
1162
- locale = _ref.locale,
1163
- createdAt = _ref.createdAt,
1164
- performUniqueCheck = _ref.performUniqueCheck;
1165
- // it is needed to silent permission errors
1166
- // this happens when setValue is called on a field which is disabled for permission reasons
1167
- var safeSetValue = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
1168
- var _args = arguments;
1169
- return runtime_1.wrap(function _callee$(_context) {
1170
- while (1) {
1171
- switch (_context.prev = _context.next) {
1172
- case 0:
1173
- _context.prev = 0;
1174
- _context.next = 3;
1175
- return setValue.apply(void 0, _args);
263
+ class TrackingFieldConnector extends React__default.Component {
264
+ constructor(props) {
265
+ super(props);
266
+ this.unsubscribeValue = null;
267
+ this.unsubscribeLocalizedValue = null;
268
+ this.unsubscribeSysChanges = null;
269
+ const titleField = getTitleField(props.sdk, props.trackingFieldId);
270
+ const entrySys = props.sdk.entry.getSys();
271
+ const isSame = titleField ? props.field.id === titleField.id : false;
272
+ this.state = {
273
+ titleValue: titleField ? titleField.getValue() : '',
274
+ isPublished: Boolean(entrySys.publishedVersion),
275
+ isSame
276
+ };
277
+ }
278
+
279
+ componentDidMount() {
280
+ this.unsubscribeSysChanges = this.props.sdk.entry.onSysChanged(sys => {
281
+ this.setState({
282
+ isPublished: Boolean(sys.publishedVersion)
283
+ });
284
+ });
285
+ const titleField = getTitleField(this.props.sdk, this.props.trackingFieldId); // the content type's display field might not exist
1176
286
 
1177
- case 3:
1178
- _context.next = 7;
1179
- break;
287
+ if (!titleField) {
288
+ return;
289
+ }
1180
290
 
1181
- case 5:
1182
- _context.prev = 5;
1183
- _context.t0 = _context["catch"](0);
291
+ if (!this.state.isSame) {
292
+ this.unsubscribeLocalizedValue = titleField.onValueChanged(this.props.field.locale, value => {
293
+ this.setState({
294
+ titleValue: value
295
+ });
296
+ });
297
+ }
1184
298
 
1185
- case 7:
1186
- case "end":
1187
- return _context.stop();
1188
- }
299
+ if (this.props.field.locale !== this.props.defaultLocale) {
300
+ if (!this.props.isOptionalLocaleWithFallback) {
301
+ this.unsubscribeValue = titleField.onValueChanged(this.props.defaultLocale, value => {
302
+ if (!titleField.getValue(this.props.field.locale)) {
303
+ this.setState({
304
+ titleValue: value
305
+ });
306
+ }
307
+ });
1189
308
  }
1190
- }, _callee, null, [[0, 5]]);
1191
- })), [setValue]);
309
+ }
310
+ }
311
+
312
+ componentWillUnmount() {
313
+ if (typeof this.unsubscribeValue === 'function') {
314
+ this.unsubscribeValue();
315
+ }
316
+
317
+ if (typeof this.unsubscribeLocalizedValue === 'function') {
318
+ this.unsubscribeLocalizedValue();
319
+ }
320
+
321
+ if (typeof this.unsubscribeSysChanges === 'function') {
322
+ this.unsubscribeSysChanges();
323
+ }
324
+ }
325
+
326
+ render() {
327
+ return this.props.children({ ...this.state
328
+ });
329
+ }
330
+
331
+ }
332
+ TrackingFieldConnector.defaultProps = {
333
+ children: () => {
334
+ return null;
335
+ }
336
+ };
337
+
338
+ function isSupportedFieldTypes(val) {
339
+ return val === 'Symbol';
340
+ }
341
+
342
+ function FieldConnectorCallback({
343
+ Component,
344
+ value,
345
+ disabled,
346
+ setValue,
347
+ errors,
348
+ titleValue,
349
+ isOptionalLocaleWithFallback,
350
+ locale,
351
+ createdAt,
352
+ performUniqueCheck
353
+ }) {
354
+ // it is needed to silent permission errors
355
+ // this happens when setValue is called on a field which is disabled for permission reasons
356
+ const safeSetValue = React.useCallback(async (...args) => {
357
+ try {
358
+ await setValue(...args);
359
+ } catch (e) {// do nothing
360
+ }
361
+ }, [setValue]);
1192
362
  return React.createElement("div", {
1193
363
  "data-test-id": "slug-editor"
1194
364
  }, React.createElement(Component, {
@@ -1205,76 +375,83 @@ function FieldConnectorCallback(_ref) {
1205
375
  }
1206
376
 
1207
377
  function SlugEditor(props) {
1208
- var _parameters$instance$, _parameters$instance, _entrySys$contentType3, _entrySys$contentType4;
1209
-
1210
- var field = props.field,
1211
- parameters = props.parameters;
1212
- var _props$baseSdk = props.baseSdk,
1213
- locales = _props$baseSdk.locales,
1214
- entry = _props$baseSdk.entry,
1215
- space = _props$baseSdk.space;
378
+ var _parameters$instance, _entrySys$contentType3, _entrySys$contentType4;
379
+
380
+ const {
381
+ field,
382
+ parameters
383
+ } = props;
384
+ const {
385
+ locales,
386
+ entry,
387
+ space
388
+ } = props.baseSdk;
1216
389
 
1217
390
  if (!isSupportedFieldTypes(field.type)) {
1218
- throw new Error("\"" + field.type + "\" field type is not supported by SlugEditor");
391
+ throw new Error(`"${field.type}" field type is not supported by SlugEditor`);
1219
392
  }
1220
393
 
1221
- var trackingFieldId = (_parameters$instance$ = parameters == null ? void 0 : (_parameters$instance = parameters.instance) == null ? void 0 : _parameters$instance.trackingFieldId) != null ? _parameters$instance$ : undefined;
1222
- var entrySys = entry.getSys();
1223
- var isLocaleOptional = locales.optional[field.locale];
1224
- var localeFallbackCode = locales.fallbacks[field.locale]; // If the field or the locale are not required (there's a locale setting that
394
+ const trackingFieldId = (parameters == null ? void 0 : (_parameters$instance = parameters.instance) == null ? void 0 : _parameters$instance.trackingFieldId) ?? undefined;
395
+ const entrySys = entry.getSys();
396
+ const isLocaleOptional = locales.optional[field.locale];
397
+ const localeFallbackCode = locales.fallbacks[field.locale]; // If the field or the locale are not required (there's a locale setting that
1225
398
  // allows publishing even if the field is required) and if the locale has a
1226
399
  // fallback than there's no need for a slug unless the user manually enters
1227
400
  // one or the title field is also localized with a custom value.
1228
401
 
1229
- var isOptionalFieldLocale = Boolean(!field.required || isLocaleOptional);
1230
- var isOptionalLocaleWithFallback = Boolean(isOptionalFieldLocale && localeFallbackCode && locales.available.includes(localeFallbackCode));
1231
- var performUniqueCheck = React.useCallback(function (value) {
1232
- var _entrySys$contentType, _entrySys$contentType2, _searchQuery;
1233
-
1234
- var searchQuery = (_searchQuery = {
1235
- content_type: entrySys == null ? void 0 : (_entrySys$contentType = entrySys.contentType) == null ? void 0 : (_entrySys$contentType2 = _entrySys$contentType.sys) == null ? void 0 : _entrySys$contentType2.id
1236
- }, _searchQuery["fields." + field.id + "." + field.locale] = value, _searchQuery['sys.id[ne]'] = entrySys.id, _searchQuery['sys.publishedAt[exists]'] = true, _searchQuery.limit = 0, _searchQuery);
1237
- return space.getEntries(searchQuery).then(function (res) {
402
+ const isOptionalFieldLocale = Boolean(!field.required || isLocaleOptional);
403
+ const isOptionalLocaleWithFallback = Boolean(isOptionalFieldLocale && localeFallbackCode && locales.available.includes(localeFallbackCode));
404
+ const performUniqueCheck = React.useCallback(value => {
405
+ var _entrySys$contentType, _entrySys$contentType2;
406
+
407
+ const searchQuery = {
408
+ content_type: entrySys == null ? void 0 : (_entrySys$contentType = entrySys.contentType) == null ? void 0 : (_entrySys$contentType2 = _entrySys$contentType.sys) == null ? void 0 : _entrySys$contentType2.id,
409
+ [`fields.${field.id}.${field.locale}`]: value,
410
+ 'sys.id[ne]': entrySys.id,
411
+ 'sys.publishedAt[exists]': true,
412
+ limit: 0
413
+ };
414
+ return space.getEntries(searchQuery).then(res => {
1238
415
  return res.total === 0;
1239
416
  });
1240
417
  }, [entrySys == null ? void 0 : (_entrySys$contentType3 = entrySys.contentType) == null ? void 0 : (_entrySys$contentType4 = _entrySys$contentType3.sys) == null ? void 0 : _entrySys$contentType4.id, field.id, field.locale, entrySys.id, space]);
1241
418
  return React.createElement(TrackingFieldConnector, {
1242
419
  sdk: props.baseSdk,
1243
420
  field: field,
1244
- defaultLocale: locales["default"],
421
+ defaultLocale: locales.default,
1245
422
  isOptionalLocaleWithFallback: isOptionalLocaleWithFallback,
1246
423
  trackingFieldId: trackingFieldId
1247
- }, function (_ref3) {
1248
- var titleValue = _ref3.titleValue,
1249
- isPublished = _ref3.isPublished,
1250
- isSame = _ref3.isSame;
1251
- return React.createElement(fieldEditorShared.FieldConnector, {
1252
- field: field,
1253
- isInitiallyDisabled: props.isInitiallyDisabled,
1254
- throttle: 0
1255
- }, function (_ref4) {
1256
- var value = _ref4.value,
1257
- errors = _ref4.errors,
1258
- disabled = _ref4.disabled,
1259
- setValue = _ref4.setValue,
1260
- externalReset = _ref4.externalReset;
1261
- var shouldTrackTitle = isPublished === false && isSame === false;
1262
- var Component = shouldTrackTitle ? SlugEditorField : SlugEditorFieldStatic;
1263
- return React.createElement(FieldConnectorCallback, {
1264
- Component: Component,
1265
- titleValue: titleValue,
1266
- value: value,
1267
- errors: errors,
1268
- disabled: disabled,
1269
- setValue: setValue,
1270
- isOptionalLocaleWithFallback: isOptionalLocaleWithFallback,
1271
- createdAt: entrySys.createdAt,
1272
- locale: field.locale,
1273
- performUniqueCheck: performUniqueCheck,
1274
- key: "slug-editor-" + externalReset
1275
- });
424
+ }, ({
425
+ titleValue,
426
+ isPublished,
427
+ isSame
428
+ }) => React.createElement(fieldEditorShared.FieldConnector, {
429
+ field: field,
430
+ isInitiallyDisabled: props.isInitiallyDisabled,
431
+ throttle: 0
432
+ }, ({
433
+ value,
434
+ errors,
435
+ disabled,
436
+ setValue,
437
+ externalReset
438
+ }) => {
439
+ const shouldTrackTitle = isPublished === false && isSame === false;
440
+ const Component = shouldTrackTitle ? SlugEditorField : SlugEditorFieldStatic;
441
+ return React.createElement(FieldConnectorCallback, {
442
+ Component: Component,
443
+ titleValue: titleValue,
444
+ value: value,
445
+ errors: errors,
446
+ disabled: disabled,
447
+ setValue: setValue,
448
+ isOptionalLocaleWithFallback: isOptionalLocaleWithFallback,
449
+ createdAt: entrySys.createdAt,
450
+ locale: field.locale,
451
+ performUniqueCheck: performUniqueCheck,
452
+ key: `slug-editor-${externalReset}`
1276
453
  });
1277
- });
454
+ }));
1278
455
  }
1279
456
  SlugEditor.defaultProps = {
1280
457
  isInitiallyDisabled: true