@contentful/field-editor-shared 1.1.7 → 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.
@@ -10,913 +10,86 @@ var throttle = _interopDefault(require('lodash/throttle'));
10
10
  var f36Note = require('@contentful/f36-note');
11
11
  var tokens = _interopDefault(require('@contentful/f36-tokens'));
12
12
  var emotion = require('emotion');
13
- var isNumber = _interopDefault(require('lodash/isNumber'));
14
13
  var ReactDOM = _interopDefault(require('react-dom'));
15
14
  var f36Components = require('@contentful/f36-components');
15
+ var isNumber = _interopDefault(require('lodash/isNumber'));
16
16
  var get = _interopDefault(require('lodash/get'));
17
17
  var isObject = _interopDefault(require('lodash/isObject'));
18
18
  var isString = _interopDefault(require('lodash/isString'));
19
19
 
20
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
21
- try {
22
- var info = gen[key](arg);
23
- var value = info.value;
24
- } catch (error) {
25
- reject(error);
26
- return;
27
- }
28
-
29
- if (info.done) {
30
- resolve(value);
31
- } else {
32
- Promise.resolve(value).then(_next, _throw);
33
- }
34
- }
35
-
36
- function _asyncToGenerator(fn) {
37
- return function () {
38
- var self = this,
39
- args = arguments;
40
- return new Promise(function (resolve, reject) {
41
- var gen = fn.apply(self, args);
42
-
43
- function _next(value) {
44
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
45
- }
46
-
47
- function _throw(err) {
48
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
49
- }
50
-
51
- _next(undefined);
52
- });
53
- };
54
- }
55
-
56
- function _extends() {
57
- _extends = Object.assign || function (target) {
58
- for (var i = 1; i < arguments.length; i++) {
59
- var source = arguments[i];
60
-
61
- for (var key in source) {
62
- if (Object.prototype.hasOwnProperty.call(source, key)) {
63
- target[key] = source[key];
64
- }
65
- }
66
- }
67
-
68
- return target;
69
- };
70
-
71
- return _extends.apply(this, arguments);
72
- }
73
-
74
- function _inheritsLoose(subClass, superClass) {
75
- subClass.prototype = Object.create(superClass.prototype);
76
- subClass.prototype.constructor = subClass;
77
-
78
- _setPrototypeOf(subClass, superClass);
79
- }
80
-
81
- function _setPrototypeOf(o, p) {
82
- _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
83
- o.__proto__ = p;
84
- return o;
85
- };
86
-
87
- return _setPrototypeOf(o, p);
88
- }
89
-
90
- function createCommonjsModule(fn, module) {
91
- return module = { exports: {} }, fn(module, module.exports), module.exports;
92
- }
93
-
94
- var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
95
- /**
96
- * Copyright (c) 2014-present, Facebook, Inc.
97
- *
98
- * This source code is licensed under the MIT license found in the
99
- * LICENSE file in the root directory of this source tree.
100
- */
101
- var runtime = function (exports) {
102
-
103
- var Op = Object.prototype;
104
- var hasOwn = Op.hasOwnProperty;
105
- var undefined$1; // More compressible than void 0.
106
-
107
- var $Symbol = typeof Symbol === "function" ? Symbol : {};
108
- var iteratorSymbol = $Symbol.iterator || "@@iterator";
109
- var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
110
- var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
111
-
112
- function define(obj, key, value) {
113
- Object.defineProperty(obj, key, {
114
- value: value,
115
- enumerable: true,
116
- configurable: true,
117
- writable: true
118
- });
119
- return obj[key];
120
- }
121
-
122
- try {
123
- // IE 8 has a broken Object.defineProperty that only works on DOM objects.
124
- define({}, "");
125
- } catch (err) {
126
- define = function define(obj, key, value) {
127
- return obj[key] = value;
128
- };
129
- }
130
-
131
- function wrap(innerFn, outerFn, self, tryLocsList) {
132
- // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
133
- var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
134
- var generator = Object.create(protoGenerator.prototype);
135
- var context = new Context(tryLocsList || []); // The ._invoke method unifies the implementations of the .next,
136
- // .throw, and .return methods.
137
-
138
- generator._invoke = makeInvokeMethod(innerFn, self, context);
139
- return generator;
140
- }
141
-
142
- exports.wrap = wrap; // Try/catch helper to minimize deoptimizations. Returns a completion
143
- // record like context.tryEntries[i].completion. This interface could
144
- // have been (and was previously) designed to take a closure to be
145
- // invoked without arguments, but in all the cases we care about we
146
- // already have an existing method we want to call, so there's no need
147
- // to create a new function object. We can even get away with assuming
148
- // the method takes exactly one argument, since that happens to be true
149
- // in every case, so we don't have to touch the arguments object. The
150
- // only additional allocation required is the completion record, which
151
- // has a stable shape and so hopefully should be cheap to allocate.
152
-
153
- function tryCatch(fn, obj, arg) {
154
- try {
155
- return {
156
- type: "normal",
157
- arg: fn.call(obj, arg)
158
- };
159
- } catch (err) {
160
- return {
161
- type: "throw",
162
- arg: err
163
- };
164
- }
165
- }
166
-
167
- var GenStateSuspendedStart = "suspendedStart";
168
- var GenStateSuspendedYield = "suspendedYield";
169
- var GenStateExecuting = "executing";
170
- var GenStateCompleted = "completed"; // Returning this object from the innerFn has the same effect as
171
- // breaking out of the dispatch switch statement.
172
-
173
- var ContinueSentinel = {}; // Dummy constructor functions that we use as the .constructor and
174
- // .constructor.prototype properties for functions that return Generator
175
- // objects. For full spec compliance, you may wish to configure your
176
- // minifier not to mangle the names of these two functions.
177
-
178
- function Generator() {}
179
-
180
- function GeneratorFunction() {}
181
-
182
- function GeneratorFunctionPrototype() {} // This is a polyfill for %IteratorPrototype% for environments that
183
- // don't natively support it.
184
-
185
-
186
- var IteratorPrototype = {};
187
- define(IteratorPrototype, iteratorSymbol, function () {
188
- return this;
189
- });
190
- var getProto = Object.getPrototypeOf;
191
- var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
192
-
193
- if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
194
- // This environment has a native %IteratorPrototype%; use it instead
195
- // of the polyfill.
196
- IteratorPrototype = NativeIteratorPrototype;
197
- }
198
-
199
- var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
200
- GeneratorFunction.prototype = GeneratorFunctionPrototype;
201
- define(Gp, "constructor", GeneratorFunctionPrototype);
202
- define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
203
- GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"); // Helper for defining the .next, .throw, and .return methods of the
204
- // Iterator interface in terms of a single ._invoke method.
205
-
206
- function defineIteratorMethods(prototype) {
207
- ["next", "throw", "return"].forEach(function (method) {
208
- define(prototype, method, function (arg) {
209
- return this._invoke(method, arg);
20
+ class FieldConnector extends React.Component {
21
+ constructor(props) {
22
+ super(props);
23
+ this.unsubscribeErrors = null;
24
+ this.unsubscribeDisabled = null;
25
+ this.unsubscribeValue = null;
26
+
27
+ this.setValue = async value => {
28
+ if (this.props.isEmptyValue(value ?? null)) {
29
+ this.setState({
30
+ value: undefined
210
31
  });
211
- });
212
- }
213
-
214
- exports.isGeneratorFunction = function (genFun) {
215
- var ctor = typeof genFun === "function" && genFun.constructor;
216
- return ctor ? ctor === GeneratorFunction || // For the native GeneratorFunction constructor, the best we can
217
- // do is to check its .name property.
218
- (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
219
- };
220
-
221
- exports.mark = function (genFun) {
222
- if (Object.setPrototypeOf) {
223
- Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
224
32
  } else {
225
- genFun.__proto__ = GeneratorFunctionPrototype;
226
- define(genFun, toStringTagSymbol, "GeneratorFunction");
227
- }
228
-
229
- genFun.prototype = Object.create(Gp);
230
- return genFun;
231
- }; // Within the body of any async function, `await x` is transformed to
232
- // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
233
- // `hasOwn.call(value, "__await")` to determine if the yielded value is
234
- // meant to be awaited.
235
-
236
-
237
- exports.awrap = function (arg) {
238
- return {
239
- __await: arg
240
- };
241
- };
242
-
243
- function AsyncIterator(generator, PromiseImpl) {
244
- function invoke(method, arg, resolve, reject) {
245
- var record = tryCatch(generator[method], generator, arg);
246
-
247
- if (record.type === "throw") {
248
- reject(record.arg);
249
- } else {
250
- var result = record.arg;
251
- var value = result.value;
252
-
253
- if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
254
- return PromiseImpl.resolve(value.__await).then(function (value) {
255
- invoke("next", value, resolve, reject);
256
- }, function (err) {
257
- invoke("throw", err, resolve, reject);
258
- });
259
- }
260
-
261
- return PromiseImpl.resolve(value).then(function (unwrapped) {
262
- // When a yielded Promise is resolved, its final value becomes
263
- // the .value of the Promise<{value,done}> result for the
264
- // current iteration.
265
- result.value = unwrapped;
266
- resolve(result);
267
- }, function (error) {
268
- // If a rejected Promise was yielded, throw the rejection back
269
- // into the async generator function so it can be handled there.
270
- return invoke("throw", error, resolve, reject);
271
- });
272
- }
273
- }
274
-
275
- var previousPromise;
276
-
277
- function enqueue(method, arg) {
278
- function callInvokeWithMethodAndArg() {
279
- return new PromiseImpl(function (resolve, reject) {
280
- invoke(method, arg, resolve, reject);
281
- });
282
- }
283
-
284
- return previousPromise = // If enqueue has been called before, then we want to wait until
285
- // all previous Promises have been resolved before calling invoke,
286
- // so that results are always delivered in the correct order. If
287
- // enqueue has not been called before, then it is important to
288
- // call invoke immediately, without waiting on a callback to fire,
289
- // so that the async generator function has the opportunity to do
290
- // any necessary setup in a predictable way. This predictability
291
- // is why the Promise constructor synchronously invokes its
292
- // executor callback, and why async functions synchronously
293
- // execute code before the first await. Since we implement simple
294
- // async functions in terms of async generators, it is especially
295
- // important to get this right, even though it requires care.
296
- previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, // Avoid propagating failures to Promises returned by later
297
- // invocations of the iterator.
298
- callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
299
- } // Define the unified helper method that is used to implement .next,
300
- // .throw, and .return (see defineIteratorMethods).
301
-
302
-
303
- this._invoke = enqueue;
304
- }
305
-
306
- defineIteratorMethods(AsyncIterator.prototype);
307
- define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
308
- return this;
309
- });
310
- exports.AsyncIterator = AsyncIterator; // Note that simple async functions are implemented on top of
311
- // AsyncIterator objects; they just return a Promise for the value of
312
- // the final result produced by the iterator.
313
-
314
- exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
315
- if (PromiseImpl === void 0) PromiseImpl = Promise;
316
- var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
317
- return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator.
318
- : iter.next().then(function (result) {
319
- return result.done ? result.value : iter.next();
320
- });
321
- };
322
-
323
- function makeInvokeMethod(innerFn, self, context) {
324
- var state = GenStateSuspendedStart;
325
- return function invoke(method, arg) {
326
- if (state === GenStateExecuting) {
327
- throw new Error("Generator is already running");
328
- }
329
-
330
- if (state === GenStateCompleted) {
331
- if (method === "throw") {
332
- throw arg;
333
- } // Be forgiving, per 25.3.3.3.3 of the spec:
334
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
335
-
336
-
337
- return doneResult();
338
- }
339
-
340
- context.method = method;
341
- context.arg = arg;
342
-
343
- while (true) {
344
- var delegate = context.delegate;
345
-
346
- if (delegate) {
347
- var delegateResult = maybeInvokeDelegate(delegate, context);
348
-
349
- if (delegateResult) {
350
- if (delegateResult === ContinueSentinel) continue;
351
- return delegateResult;
352
- }
353
- }
354
-
355
- if (context.method === "next") {
356
- // Setting context._sent for legacy support of Babel's
357
- // function.sent implementation.
358
- context.sent = context._sent = context.arg;
359
- } else if (context.method === "throw") {
360
- if (state === GenStateSuspendedStart) {
361
- state = GenStateCompleted;
362
- throw context.arg;
363
- }
364
-
365
- context.dispatchException(context.arg);
366
- } else if (context.method === "return") {
367
- context.abrupt("return", context.arg);
368
- }
369
-
370
- state = GenStateExecuting;
371
- var record = tryCatch(innerFn, self, context);
372
-
373
- if (record.type === "normal") {
374
- // If an exception is thrown from innerFn, we leave state ===
375
- // GenStateExecuting and loop back for another invocation.
376
- state = context.done ? GenStateCompleted : GenStateSuspendedYield;
377
-
378
- if (record.arg === ContinueSentinel) {
379
- continue;
380
- }
381
-
382
- return {
383
- value: record.arg,
384
- done: context.done
385
- };
386
- } else if (record.type === "throw") {
387
- state = GenStateCompleted; // Dispatch the exception by looping back around to the
388
- // context.dispatchException(context.arg) call above.
389
-
390
- context.method = "throw";
391
- context.arg = record.arg;
392
- }
393
- }
394
- };
395
- } // Call delegate.iterator[context.method](context.arg) and handle the
396
- // result, either by returning a { value, done } result from the
397
- // delegate iterator, or by modifying context.method and context.arg,
398
- // setting context.delegate to null, and returning the ContinueSentinel.
399
-
400
-
401
- function maybeInvokeDelegate(delegate, context) {
402
- var method = delegate.iterator[context.method];
403
-
404
- if (method === undefined$1) {
405
- // A .throw or .return when the delegate iterator has no .throw
406
- // method always terminates the yield* loop.
407
- context.delegate = null;
408
-
409
- if (context.method === "throw") {
410
- // Note: ["return"] must be used for ES3 parsing compatibility.
411
- if (delegate.iterator["return"]) {
412
- // If the delegate iterator has a return method, give it a
413
- // chance to clean up.
414
- context.method = "return";
415
- context.arg = undefined$1;
416
- maybeInvokeDelegate(delegate, context);
417
-
418
- if (context.method === "throw") {
419
- // If maybeInvokeDelegate(context) changed context.method from
420
- // "return" to "throw", let that override the TypeError below.
421
- return ContinueSentinel;
422
- }
423
- }
424
-
425
- context.method = "throw";
426
- context.arg = new TypeError("The iterator does not provide a 'throw' method");
427
- }
428
-
429
- return ContinueSentinel;
430
- }
431
-
432
- var record = tryCatch(method, delegate.iterator, context.arg);
433
-
434
- if (record.type === "throw") {
435
- context.method = "throw";
436
- context.arg = record.arg;
437
- context.delegate = null;
438
- return ContinueSentinel;
439
- }
440
-
441
- var info = record.arg;
442
-
443
- if (!info) {
444
- context.method = "throw";
445
- context.arg = new TypeError("iterator result is not an object");
446
- context.delegate = null;
447
- return ContinueSentinel;
448
- }
449
-
450
- if (info.done) {
451
- // Assign the result of the finished delegate to the temporary
452
- // variable specified by delegate.resultName (see delegateYield).
453
- context[delegate.resultName] = info.value; // Resume execution at the desired location (see delegateYield).
454
-
455
- context.next = delegate.nextLoc; // If context.method was "throw" but the delegate handled the
456
- // exception, let the outer generator proceed normally. If
457
- // context.method was "next", forget context.arg since it has been
458
- // "consumed" by the delegate iterator. If context.method was
459
- // "return", allow the original .return call to continue in the
460
- // outer generator.
461
-
462
- if (context.method !== "return") {
463
- context.method = "next";
464
- context.arg = undefined$1;
465
- }
466
- } else {
467
- // Re-yield the result returned by the delegate method.
468
- return info;
469
- } // The delegate iterator is finished, so forget it and continue with
470
- // the outer generator.
471
-
472
-
473
- context.delegate = null;
474
- return ContinueSentinel;
475
- } // Define Generator.prototype.{next,throw,return} in terms of the
476
- // unified ._invoke helper method.
477
-
478
-
479
- defineIteratorMethods(Gp);
480
- define(Gp, toStringTagSymbol, "Generator"); // A Generator should always return itself as the iterator object when the
481
- // @@iterator function is called on it. Some browsers' implementations of the
482
- // iterator prototype chain incorrectly implement this, causing the Generator
483
- // object to not be returned from this call. This ensures that doesn't happen.
484
- // See https://github.com/facebook/regenerator/issues/274 for more details.
485
-
486
- define(Gp, iteratorSymbol, function () {
487
- return this;
488
- });
489
- define(Gp, "toString", function () {
490
- return "[object Generator]";
491
- });
492
-
493
- function pushTryEntry(locs) {
494
- var entry = {
495
- tryLoc: locs[0]
496
- };
497
-
498
- if (1 in locs) {
499
- entry.catchLoc = locs[1];
500
- }
501
-
502
- if (2 in locs) {
503
- entry.finallyLoc = locs[2];
504
- entry.afterLoc = locs[3];
505
- }
506
-
507
- this.tryEntries.push(entry);
508
- }
509
-
510
- function resetTryEntry(entry) {
511
- var record = entry.completion || {};
512
- record.type = "normal";
513
- delete record.arg;
514
- entry.completion = record;
515
- }
516
-
517
- function Context(tryLocsList) {
518
- // The root entry object (effectively a try statement without a catch
519
- // or a finally block) gives us a place to store values thrown from
520
- // locations where there is no enclosing try statement.
521
- this.tryEntries = [{
522
- tryLoc: "root"
523
- }];
524
- tryLocsList.forEach(pushTryEntry, this);
525
- this.reset(true);
526
- }
527
-
528
- exports.keys = function (object) {
529
- var keys = [];
530
-
531
- for (var key in object) {
532
- keys.push(key);
33
+ this.setState({
34
+ value
35
+ });
533
36
  }
534
37
 
535
- keys.reverse(); // Rather than returning an object with a next method, we keep
536
- // things simple and return the next function itself.
537
-
538
- return function next() {
539
- while (keys.length) {
540
- var key = keys.pop();
541
-
542
- if (key in object) {
543
- next.value = key;
544
- next.done = false;
545
- return next;
546
- }
547
- } // To avoid creating an additional object, we just hang the .value
548
- // and .done properties off the next function object itself. This
549
- // also ensures that the minifier will not anonymize the function.
550
-
551
-
552
- next.done = true;
553
- return next;
554
- };
38
+ await this.triggerSetValueCallbacks(value);
555
39
  };
556
40
 
557
- function values(iterable) {
558
- if (iterable) {
559
- var iteratorMethod = iterable[iteratorSymbol];
560
-
561
- if (iteratorMethod) {
562
- return iteratorMethod.call(iterable);
563
- }
564
-
565
- if (typeof iterable.next === "function") {
566
- return iterable;
567
- }
568
-
569
- if (!isNaN(iterable.length)) {
570
- var i = -1,
571
- next = function next() {
572
- while (++i < iterable.length) {
573
- if (hasOwn.call(iterable, i)) {
574
- next.value = iterable[i];
575
- next.done = false;
576
- return next;
577
- }
578
- }
579
-
580
- next.value = undefined$1;
581
- next.done = true;
582
- return next;
583
- };
584
-
585
- return next.next = next;
586
- }
587
- } // Return an iterator with no values.
588
-
589
-
590
- return {
591
- next: doneResult
592
- };
593
- }
594
-
595
- exports.values = values;
596
-
597
- function doneResult() {
598
- return {
599
- value: undefined$1,
600
- done: true
601
- };
602
- }
603
-
604
- Context.prototype = {
605
- constructor: Context,
606
- reset: function reset(skipTempReset) {
607
- this.prev = 0;
608
- this.next = 0; // Resetting context._sent for legacy support of Babel's
609
- // function.sent implementation.
610
-
611
- this.sent = this._sent = undefined$1;
612
- this.done = false;
613
- this.delegate = null;
614
- this.method = "next";
615
- this.arg = undefined$1;
616
- this.tryEntries.forEach(resetTryEntry);
617
-
618
- if (!skipTempReset) {
619
- for (var name in this) {
620
- // Not sure about the optimal order of these conditions:
621
- if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
622
- this[name] = undefined$1;
623
- }
624
- }
625
- }
626
- },
627
- stop: function stop() {
628
- this.done = true;
629
- var rootEntry = this.tryEntries[0];
630
- var rootRecord = rootEntry.completion;
631
-
632
- if (rootRecord.type === "throw") {
633
- throw rootRecord.arg;
634
- }
635
-
636
- return this.rval;
637
- },
638
- dispatchException: function dispatchException(exception) {
639
- if (this.done) {
640
- throw exception;
641
- }
642
-
643
- var context = this;
644
-
645
- function handle(loc, caught) {
646
- record.type = "throw";
647
- record.arg = exception;
648
- context.next = loc;
649
-
650
- if (caught) {
651
- // If the dispatched exception was caught by a catch block,
652
- // then let that catch block handle the exception normally.
653
- context.method = "next";
654
- context.arg = undefined$1;
655
- }
656
-
657
- return !!caught;
658
- }
659
-
660
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
661
- var entry = this.tryEntries[i];
662
- var record = entry.completion;
663
-
664
- if (entry.tryLoc === "root") {
665
- // Exception thrown outside of any try block that could handle
666
- // it, so set the completion value of the entire function to
667
- // throw the exception.
668
- return handle("end");
669
- }
670
-
671
- if (entry.tryLoc <= this.prev) {
672
- var hasCatch = hasOwn.call(entry, "catchLoc");
673
- var hasFinally = hasOwn.call(entry, "finallyLoc");
674
-
675
- if (hasCatch && hasFinally) {
676
- if (this.prev < entry.catchLoc) {
677
- return handle(entry.catchLoc, true);
678
- } else if (this.prev < entry.finallyLoc) {
679
- return handle(entry.finallyLoc);
680
- }
681
- } else if (hasCatch) {
682
- if (this.prev < entry.catchLoc) {
683
- return handle(entry.catchLoc, true);
684
- }
685
- } else if (hasFinally) {
686
- if (this.prev < entry.finallyLoc) {
687
- return handle(entry.finallyLoc);
688
- }
689
- } else {
690
- throw new Error("try statement without catch or finally");
691
- }
692
- }
693
- }
694
- },
695
- abrupt: function abrupt(type, arg) {
696
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
697
- var entry = this.tryEntries[i];
698
-
699
- if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
700
- var finallyEntry = entry;
701
- break;
702
- }
703
- }
704
-
705
- if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
706
- // Ignore the finally entry if control is not jumping to a
707
- // location outside the try/catch block.
708
- finallyEntry = null;
709
- }
710
-
711
- var record = finallyEntry ? finallyEntry.completion : {};
712
- record.type = type;
713
- record.arg = arg;
714
-
715
- if (finallyEntry) {
716
- this.method = "next";
717
- this.next = finallyEntry.finallyLoc;
718
- return ContinueSentinel;
719
- }
720
-
721
- return this.complete(record);
722
- },
723
- complete: function complete(record, afterLoc) {
724
- if (record.type === "throw") {
725
- throw record.arg;
726
- }
727
-
728
- if (record.type === "break" || record.type === "continue") {
729
- this.next = record.arg;
730
- } else if (record.type === "return") {
731
- this.rval = this.arg = record.arg;
732
- this.method = "return";
733
- this.next = "end";
734
- } else if (record.type === "normal" && afterLoc) {
735
- this.next = afterLoc;
736
- }
737
-
738
- return ContinueSentinel;
739
- },
740
- finish: function finish(finallyLoc) {
741
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
742
- var entry = this.tryEntries[i];
743
-
744
- if (entry.finallyLoc === finallyLoc) {
745
- this.complete(entry.completion, entry.afterLoc);
746
- resetTryEntry(entry);
747
- return ContinueSentinel;
748
- }
749
- }
750
- },
751
- "catch": function _catch(tryLoc) {
752
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
753
- var entry = this.tryEntries[i];
754
-
755
- if (entry.tryLoc === tryLoc) {
756
- var record = entry.completion;
757
-
758
- if (record.type === "throw") {
759
- var thrown = record.arg;
760
- resetTryEntry(entry);
761
- }
762
-
763
- return thrown;
764
- }
765
- } // The context.catch method must only be called with a location
766
- // argument that corresponds to a known catch block.
767
-
768
-
769
- throw new Error("illegal catch attempt");
770
- },
771
- delegateYield: function delegateYield(iterable, resultName, nextLoc) {
772
- this.delegate = {
773
- iterator: values(iterable),
774
- resultName: resultName,
775
- nextLoc: nextLoc
776
- };
777
-
778
- if (this.method === "next") {
779
- // Deliberately forget the last sent value so that we don't
780
- // accidentally pass it on to the delegate.
781
- this.arg = undefined$1;
782
- }
783
-
784
- return ContinueSentinel;
785
- }
786
- }; // Regardless of whether this script is executing as a CommonJS module
787
- // or not, return the runtime object so that we can declare the variable
788
- // regeneratorRuntime in the outer scope, which allows this module to be
789
- // injected easily by `bin/regenerator --include-runtime script.js`.
790
-
791
- return exports;
792
- }( // If this script is executing as a CommonJS module, use module.exports
793
- // as the regeneratorRuntime namespace. Otherwise create a new empty
794
- // object. Either way, the resulting object will be used to initialize
795
- // the regeneratorRuntime variable at the top of this file.
796
- module.exports );
797
-
798
- try {
799
- regeneratorRuntime = runtime;
800
- } catch (accidentalStrictMode) {
801
- // This module should not be running in strict mode, so the above
802
- // assignment should always work unless something is misconfigured. Just
803
- // in case runtime.js accidentally runs in strict mode, in modern engines
804
- // we can explicitly access globalThis. In older engines we can escape
805
- // strict mode using a global Function call. This could conceivably fail
806
- // if a Content Security Policy forbids using Function, but in that case
807
- // the proper solution is to fix the accidental strict mode problem. If
808
- // you've misconfigured your bundler to force strict mode and applied a
809
- // CSP to forbid Function, and you're not willing to fix either of those
810
- // problems, please detail your unique predicament in a GitHub issue.
811
- if (typeof globalThis === "object") {
812
- globalThis.regeneratorRuntime = runtime;
813
- } else {
814
- Function("r", "regeneratorRuntime = r")(runtime);
815
- }
816
- }
817
- });
818
-
819
- var FieldConnector = /*#__PURE__*/function (_React$Component) {
820
- _inheritsLoose(FieldConnector, _React$Component);
821
-
822
- function FieldConnector(props) {
823
- var _props$isInitiallyDis;
824
-
825
- var _this;
826
-
827
- _this = _React$Component.call(this, props) || this;
828
- _this.unsubscribeErrors = null;
829
- _this.unsubscribeDisabled = null;
830
- _this.unsubscribeValue = null;
831
-
832
- _this.setValue = /*#__PURE__*/function () {
833
- var _ref = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(value) {
834
- return runtime_1.wrap(function _callee$(_context) {
835
- while (1) {
836
- switch (_context.prev = _context.next) {
837
- case 0:
838
- if (_this.props.isEmptyValue(value != null ? value : null)) {
839
- _this.setState({
840
- value: undefined
841
- });
842
- } else {
843
- _this.setState({
844
- value: value
845
- });
846
- }
847
-
848
- _context.next = 3;
849
- return _this.triggerSetValueCallbacks(value);
850
-
851
- case 3:
852
- case "end":
853
- return _context.stop();
854
- }
855
- }
856
- }, _callee);
857
- }));
858
-
859
- return function (_x) {
860
- return _ref.apply(this, arguments);
861
- };
862
- }();
863
-
864
- _this.triggerSetValueCallbacks = throttle(function (value) {
865
- return new Promise(function (resolve, reject) {
866
- if (_this.props.isEmptyValue(value != null ? value : null)) {
867
- _this.props.field.removeValue().then(resolve)["catch"](reject);
41
+ this.triggerSetValueCallbacks = throttle(value => {
42
+ return new Promise((resolve, reject) => {
43
+ if (this.props.isEmptyValue(value ?? null)) {
44
+ this.props.field.removeValue().then(resolve).catch(reject);
868
45
  } else {
869
- _this.props.field.setValue(value).then(resolve)["catch"](reject);
46
+ this.props.field.setValue(value).then(resolve).catch(reject);
870
47
  }
871
48
  });
872
- }, _this.props.throttle, {
873
- leading: _this.props.throttle === 0
49
+ }, this.props.throttle, {
50
+ leading: this.props.throttle === 0
874
51
  });
875
- var initialValue = props.field.getValue();
876
- _this.state = {
52
+ const initialValue = props.field.getValue();
53
+ this.state = {
877
54
  isLocalValueChange: false,
878
55
  externalReset: 0,
879
56
  value: initialValue,
880
57
  lastRemoteValue: initialValue,
881
- disabled: (_props$isInitiallyDis = props.isInitiallyDisabled) != null ? _props$isInitiallyDis : false,
58
+ disabled: props.isInitiallyDisabled ?? false,
882
59
  errors: []
883
60
  };
884
- return _this;
885
61
  }
886
62
 
887
- var _proto = FieldConnector.prototype;
888
-
889
- _proto.componentDidMount = function componentDidMount() {
890
- var _this2 = this;
891
-
892
- var field = this.props.field;
893
- this.unsubscribeErrors = field.onSchemaErrorsChanged(function (errors) {
894
- _this2.setState({
63
+ componentDidMount() {
64
+ const {
65
+ field
66
+ } = this.props;
67
+ this.unsubscribeErrors = field.onSchemaErrorsChanged(errors => {
68
+ this.setState({
895
69
  errors: errors || []
896
70
  });
897
71
  });
898
- this.unsubscribeDisabled = field.onIsDisabledChanged(function (disabled) {
899
- _this2.setState({
900
- disabled: disabled
72
+ this.unsubscribeDisabled = field.onIsDisabledChanged(disabled => {
73
+ this.setState({
74
+ disabled
901
75
  });
902
76
  });
903
- this.unsubscribeValue = field.onValueChanged(function (value) {
904
- _this2.setState(function (currentState) {
905
- var isLocalValueChange = _this2.props.isEqualValues(value, currentState.value);
906
-
907
- var lastRemoteValue = isLocalValueChange ? currentState.lastRemoteValue : value;
908
- var externalReset = currentState.externalReset + (isLocalValueChange ? 0 : 1);
77
+ this.unsubscribeValue = field.onValueChanged(value => {
78
+ this.setState(currentState => {
79
+ const isLocalValueChange = this.props.isEqualValues(value, currentState.value);
80
+ const lastRemoteValue = isLocalValueChange ? currentState.lastRemoteValue : value;
81
+ const externalReset = currentState.externalReset + (isLocalValueChange ? 0 : 1);
909
82
  return {
910
- value: value,
911
- lastRemoteValue: lastRemoteValue,
912
- isLocalValueChange: isLocalValueChange,
913
- externalReset: externalReset
83
+ value,
84
+ lastRemoteValue,
85
+ isLocalValueChange,
86
+ externalReset
914
87
  };
915
88
  });
916
89
  });
917
- };
90
+ }
918
91
 
919
- _proto.componentWillUnmount = function componentWillUnmount() {
92
+ componentWillUnmount() {
920
93
  if (typeof this.unsubscribeErrors === 'function') {
921
94
  this.unsubscribeErrors();
922
95
  }
@@ -928,27 +101,26 @@ var FieldConnector = /*#__PURE__*/function (_React$Component) {
928
101
  if (typeof this.unsubscribeValue === 'function') {
929
102
  this.unsubscribeValue();
930
103
  }
931
- };
104
+ }
932
105
 
933
- _proto.render = function render() {
934
- return this.props.children(_extends({}, this.state, {
106
+ render() {
107
+ return this.props.children({ ...this.state,
935
108
  setValue: this.setValue,
936
109
  disabled: this.props.isDisabled || this.state.disabled
937
- }));
938
- };
110
+ });
111
+ }
939
112
 
940
- return FieldConnector;
941
- }(React.Component);
113
+ }
942
114
  FieldConnector.defaultProps = {
943
- children: function children() {
115
+ children: () => {
944
116
  return null;
945
117
  },
946
118
  // eslint-disable-next-line -- TODO: describe this disable
947
- isEmptyValue: function isEmptyValue(value) {
119
+ isEmptyValue: value => {
948
120
  return value === null || value === '';
949
121
  },
950
122
  // eslint-disable-next-line -- TODO: describe this disable
951
- isEqualValues: function isEqualValues(value1, value2) {
123
+ isEqualValues: (value1, value2) => {
952
124
  return isEqual(value1, value2);
953
125
  },
954
126
  throttle: 300
@@ -961,29 +133,31 @@ function PredefinedValuesError() {
961
133
  }, "The widget failed to initialize. You can fix the problem by providing predefined values under the validations tab in the field settings.");
962
134
  }
963
135
 
964
- var styles = {
136
+ const styles = {
965
137
  invalid: /*#__PURE__*/emotion.css({
966
138
  color: tokens.red600
967
139
  })
968
140
  };
969
141
  function CharCounter(props) {
970
- var _cx;
971
-
972
- var count = 0;
142
+ let count = 0;
973
143
 
974
144
  if (props.value) {
975
145
  count = props.value.length;
976
146
  }
977
147
 
978
- var valid = count === 0 || props.checkConstraint(count);
148
+ const valid = count === 0 || props.checkConstraint(count);
979
149
  return React.createElement("span", {
980
150
  "data-status-code": valid ? null : 'invalid-size',
981
- className: emotion.cx((_cx = {}, _cx[styles.invalid] = !valid, _cx))
151
+ className: emotion.cx({
152
+ [styles.invalid]: !valid
153
+ })
982
154
  }, count, " characters");
983
155
  }
984
156
 
985
157
  function CharValidation(props) {
986
- var constraints = props.constraints;
158
+ const {
159
+ constraints
160
+ } = props;
987
161
 
988
162
  if (constraints.type === 'max') {
989
163
  return React.createElement("span", null, "Maximum ", constraints.max, " characters");
@@ -994,10 +168,11 @@ function CharValidation(props) {
994
168
  }
995
169
  }
996
170
 
171
+ /* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-use-before-define */
997
172
  function open(componentRenderer) {
998
- var rootDom = null;
173
+ let rootDom = null;
999
174
 
1000
- var getRoot = function getRoot() {
175
+ const getRoot = () => {
1001
176
  if (rootDom === null) {
1002
177
  rootDom = document.createElement('div');
1003
178
  rootDom.setAttribute('id', 'field-editor-modal-root');
@@ -1007,29 +182,30 @@ function open(componentRenderer) {
1007
182
  return rootDom;
1008
183
  };
1009
184
 
1010
- return new Promise(function (resolve) {
1011
- var currentConfig = {
1012
- onClose: onClose,
185
+ return new Promise(resolve => {
186
+ let currentConfig = {
187
+ onClose,
1013
188
  isShown: true
1014
189
  };
1015
190
 
1016
- function render(_ref) {
1017
- var onClose = _ref.onClose,
1018
- isShown = _ref.isShown;
191
+ function render({
192
+ onClose,
193
+ isShown
194
+ }) {
1019
195
  ReactDOM.render(componentRenderer({
1020
- onClose: onClose,
1021
- isShown: isShown
196
+ onClose,
197
+ isShown
1022
198
  }), getRoot());
1023
199
  }
1024
200
 
1025
- function onClose() {
1026
- currentConfig = _extends({}, currentConfig, {
201
+ function onClose(...args) {
202
+ currentConfig = { ...currentConfig,
1027
203
  isShown: false
1028
- });
204
+ };
1029
205
  render(currentConfig); // eslint-disable-next-line -- TODO: describe this disable @typescript-eslint/ban-ts-comment
1030
206
  // @ts-ignore
1031
207
 
1032
- resolve.apply(void 0, arguments);
208
+ resolve(...args);
1033
209
  getRoot().remove();
1034
210
  }
1035
211
 
@@ -1037,15 +213,13 @@ function open(componentRenderer) {
1037
213
  });
1038
214
  }
1039
215
  function openDialog(options, Component) {
1040
- var key = Date.now();
1041
- var size = isNumber(options.width) ? options.width + "px" : options.width;
1042
- return open(function (_ref2) {
1043
- var isShown = _ref2.isShown,
1044
- onClose = _ref2.onClose;
1045
-
1046
- var onCloseHandler = function onCloseHandler() {
1047
- return onClose();
1048
- };
216
+ const key = Date.now();
217
+ const size = isNumber(options.width) ? `${options.width}px` : options.width;
218
+ return open(({
219
+ isShown,
220
+ onClose
221
+ }) => {
222
+ const onCloseHandler = () => onClose();
1049
223
 
1050
224
  return React.createElement(f36Components.Modal, {
1051
225
  key: key,
@@ -1056,23 +230,21 @@ function openDialog(options, Component) {
1056
230
  isShown: isShown,
1057
231
  onClose: onCloseHandler,
1058
232
  size: size || '700px'
1059
- }, function () {
1060
- return React.createElement(React.Fragment, null, options.title && React.createElement(f36Components.ModalHeader, {
1061
- testId: "dialog-title",
1062
- title: options.title,
1063
- onClose: onCloseHandler
1064
- }), React.createElement("div", {
1065
- style: {
1066
- minHeight: options.minHeight || 'auto'
1067
- }
1068
- }, React.createElement(Component, {
1069
- onClose: onClose
1070
- })));
1071
- });
233
+ }, () => React.createElement(React.Fragment, null, options.title && React.createElement(f36Components.ModalHeader, {
234
+ testId: "dialog-title",
235
+ title: options.title,
236
+ onClose: onCloseHandler
237
+ }), React.createElement("div", {
238
+ style: {
239
+ minHeight: options.minHeight || 'auto'
240
+ }
241
+ }, React.createElement(Component, {
242
+ onClose: onClose
243
+ }))));
1072
244
  });
1073
245
  }
1074
246
  var ModalDialogLauncher = {
1075
- openDialog: openDialog
247
+ openDialog
1076
248
  };
1077
249
 
1078
250
  var ModalDialogLauncher$1 = {
@@ -1088,7 +260,7 @@ function titleOrDefault(title, defaultTitle) {
1088
260
  }
1089
261
 
1090
262
  if (title) {
1091
- var trimmedTitle = title.trim();
263
+ const trimmedTitle = title.trim();
1092
264
 
1093
265
  if (trimmedTitle.length === 0) {
1094
266
  return defaultTitle;
@@ -1100,36 +272,41 @@ function titleOrDefault(title, defaultTitle) {
1100
272
  return defaultTitle;
1101
273
  }
1102
274
 
1103
- function getFieldValue(_ref) {
1104
- var entity = _ref.entity,
1105
- fieldId = _ref.fieldId,
1106
- localeCode = _ref.localeCode,
1107
- defaultLocaleCode = _ref.defaultLocaleCode;
1108
- var values = get(entity, ['fields', fieldId]);
275
+ function getFieldValue({
276
+ /**
277
+ * Expects an entity fetched with a flag Skip-Transformation: true
278
+ */
279
+ entity,
280
+ fieldId,
281
+ localeCode,
282
+ defaultLocaleCode
283
+ }) {
284
+ const values = get(entity, ['fields', fieldId]);
1109
285
 
1110
286
  if (!isObject(values)) {
1111
287
  return;
1112
288
  }
1113
289
 
1114
- var firstLocaleCode = Object.keys(values)[0];
290
+ const firstLocaleCode = Object.keys(values)[0];
1115
291
  return values[localeCode] || values[defaultLocaleCode] || values[firstLocaleCode];
1116
292
  }
1117
- function getAssetTitle(_ref2) {
293
+ function getAssetTitle({
294
+ asset,
295
+ localeCode,
296
+ defaultLocaleCode,
297
+ defaultTitle
298
+ }) {
1118
299
  var _asset$fields;
1119
300
 
1120
- var asset = _ref2.asset,
1121
- localeCode = _ref2.localeCode,
1122
- defaultLocaleCode = _ref2.defaultLocaleCode,
1123
- defaultTitle = _ref2.defaultTitle;
1124
- var title = getFieldValue({
301
+ const title = getFieldValue({
1125
302
  entity: {
1126
303
  fields: {
1127
304
  title: (_asset$fields = asset.fields) == null ? void 0 : _asset$fields.title
1128
305
  }
1129
306
  },
1130
307
  fieldId: 'title',
1131
- localeCode: localeCode,
1132
- defaultLocaleCode: defaultLocaleCode
308
+ localeCode,
309
+ defaultLocaleCode
1133
310
  });
1134
311
  return titleOrDefault(title, defaultTitle);
1135
312
  }
@@ -1140,88 +317,80 @@ function getAssetTitle(_ref2) {
1140
317
  * @returns {boolean}
1141
318
  */
1142
319
 
1143
- var isAssetField = function isAssetField(field) {
1144
- return field.type === 'Link' && field.linkType === 'Asset';
1145
- };
320
+ const isAssetField = field => field.type === 'Link' && field.linkType === 'Asset';
1146
321
  /**
1147
322
  * Returns true if field is a Title
1148
323
  */
1149
324
 
1150
- function isDisplayField(_ref3) {
1151
- var field = _ref3.field,
1152
- contentType = _ref3.contentType;
325
+ function isDisplayField({
326
+ field,
327
+ contentType
328
+ }) {
1153
329
  return field.id === contentType.displayField;
1154
330
  }
1155
331
  /**
1156
332
  * Returns true if field is a short Description
1157
333
  */
1158
334
 
1159
- function isDescriptionField(_ref4) {
1160
- var field = _ref4.field,
1161
- contentType = _ref4.contentType;
335
+ function isDescriptionField({
336
+ field,
337
+ contentType
338
+ }) {
339
+ const isTextField = field => ['Symbol', 'Text'].includes(field.type);
1162
340
 
1163
- var isTextField = function isTextField(field) {
1164
- return ['Symbol', 'Text'].includes(field.type);
1165
- };
1166
-
1167
- var isMaybeSlugField = function isMaybeSlugField(field) {
1168
- return /\bslug\b/.test(field.name);
1169
- };
341
+ const isMaybeSlugField = field => /\bslug\b/.test(field.name);
1170
342
 
1171
343
  return isTextField(field) && !isDisplayField({
1172
- field: field,
1173
- contentType: contentType
344
+ field,
345
+ contentType
1174
346
  }) && !isMaybeSlugField(field);
1175
347
  }
1176
- function getEntityDescription(_ref5) {
1177
- var entity = _ref5.entity,
1178
- contentType = _ref5.contentType,
1179
- localeCode = _ref5.localeCode,
1180
- defaultLocaleCode = _ref5.defaultLocaleCode;
1181
-
348
+ function getEntityDescription({
349
+ entity,
350
+ contentType,
351
+ localeCode,
352
+ defaultLocaleCode
353
+ }) {
1182
354
  if (!contentType) {
1183
355
  return '';
1184
356
  }
1185
357
 
1186
- var descriptionField = contentType.fields.find(function (field) {
1187
- return isDescriptionField({
1188
- field: field,
1189
- contentType: contentType
1190
- });
1191
- });
358
+ const descriptionField = contentType.fields.find(field => isDescriptionField({
359
+ field,
360
+ contentType
361
+ }));
1192
362
 
1193
363
  if (!descriptionField) {
1194
364
  return '';
1195
365
  }
1196
366
 
1197
367
  return getFieldValue({
1198
- entity: entity,
368
+ entity,
1199
369
  fieldId: descriptionField.id,
1200
- localeCode: localeCode,
1201
- defaultLocaleCode: defaultLocaleCode
370
+ localeCode,
371
+ defaultLocaleCode
1202
372
  }) || '';
1203
373
  }
1204
- function getEntryTitle(_ref6) {
1205
- var entry = _ref6.entry,
1206
- contentType = _ref6.contentType,
1207
- localeCode = _ref6.localeCode,
1208
- defaultLocaleCode = _ref6.defaultLocaleCode,
1209
- defaultTitle = _ref6.defaultTitle;
1210
- var title;
374
+ function getEntryTitle({
375
+ entry,
376
+ contentType,
377
+ localeCode,
378
+ defaultLocaleCode,
379
+ defaultTitle
380
+ }) {
381
+ let title;
1211
382
 
1212
383
  if (!contentType) {
1213
384
  return defaultTitle;
1214
385
  }
1215
386
 
1216
- var displayField = contentType.displayField;
387
+ const displayField = contentType.displayField;
1217
388
 
1218
389
  if (!displayField) {
1219
390
  return defaultTitle;
1220
391
  }
1221
392
 
1222
- var displayFieldInfo = contentType.fields.find(function (field) {
1223
- return field.id === displayField;
1224
- });
393
+ const displayFieldInfo = contentType.fields.find(field => field.id === displayField);
1225
394
 
1226
395
  if (!displayFieldInfo) {
1227
396
  return defaultTitle;
@@ -1234,8 +403,8 @@ function getEntryTitle(_ref6) {
1234
403
  title = getFieldValue({
1235
404
  entity: entry,
1236
405
  fieldId: displayField,
1237
- localeCode: localeCode,
1238
- defaultLocaleCode: defaultLocaleCode
406
+ localeCode,
407
+ defaultLocaleCode
1239
408
  });
1240
409
 
1241
410
  if (!title) {
@@ -1245,15 +414,15 @@ function getEntryTitle(_ref6) {
1245
414
  title = getFieldValue({
1246
415
  entity: entry,
1247
416
  fieldId: displayFieldInfo.id,
1248
- localeCode: localeCode,
1249
- defaultLocaleCode: defaultLocaleCode
417
+ localeCode,
418
+ defaultLocaleCode
1250
419
  });
1251
420
  }
1252
421
  } else {
1253
422
  title = getFieldValue({
1254
423
  entity: entry,
1255
424
  fieldId: displayField,
1256
- defaultLocaleCode: defaultLocaleCode,
425
+ defaultLocaleCode,
1257
426
  localeCode: ''
1258
427
  });
1259
428
 
@@ -1261,7 +430,7 @@ function getEntryTitle(_ref6) {
1261
430
  title = getFieldValue({
1262
431
  entity: entry,
1263
432
  fieldId: displayFieldInfo.id,
1264
- defaultLocaleCode: defaultLocaleCode,
433
+ defaultLocaleCode,
1265
434
  localeCode: ''
1266
435
  });
1267
436
  }
@@ -1293,70 +462,36 @@ function getEntryStatus(sys) {
1293
462
  * given entities file. The promise may resolve with null.
1294
463
  */
1295
464
 
1296
- var getEntryImage = /*#__PURE__*/function () {
1297
- var _ref8 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(_ref7, getAsset) {
1298
- var entry, contentType, localeCode, assetLink, assetId, asset, file, isImage;
1299
- return runtime_1.wrap(function _callee$(_context) {
1300
- while (1) {
1301
- switch (_context.prev = _context.next) {
1302
- case 0:
1303
- entry = _ref7.entry, contentType = _ref7.contentType, localeCode = _ref7.localeCode;
1304
-
1305
- if (contentType) {
1306
- _context.next = 3;
1307
- break;
1308
- }
1309
-
1310
- return _context.abrupt("return", null);
1311
-
1312
- case 3:
1313
- assetLink = contentType.fields.find(isAssetField);
1314
-
1315
- if (assetLink) {
1316
- _context.next = 6;
1317
- break;
1318
- }
1319
-
1320
- return _context.abrupt("return", null);
1321
-
1322
- case 6:
1323
- assetId = get(entry.fields, [assetLink.id, localeCode, 'sys', 'id']);
1324
-
1325
- if (assetId) {
1326
- _context.next = 9;
1327
- break;
1328
- }
1329
-
1330
- return _context.abrupt("return", null);
1331
-
1332
- case 9:
1333
- _context.prev = 9;
1334
- _context.next = 12;
1335
- return getAsset(assetId);
1336
-
1337
- case 12:
1338
- asset = _context.sent;
1339
- file = get(asset, ['fields', 'file', localeCode]);
1340
- isImage = Boolean(get(file, ['details', 'image'], false));
1341
- return _context.abrupt("return", isImage ? file : null);
1342
-
1343
- case 18:
1344
- _context.prev = 18;
1345
- _context.t0 = _context["catch"](9);
1346
- return _context.abrupt("return", null);
1347
-
1348
- case 21:
1349
- case "end":
1350
- return _context.stop();
1351
- }
1352
- }
1353
- }, _callee, null, [[9, 18]]);
1354
- }));
465
+ const getEntryImage = async ({
466
+ entry,
467
+ contentType,
468
+ localeCode
469
+ }, getAsset) => {
470
+ if (!contentType) {
471
+ return null;
472
+ }
1355
473
 
1356
- return function getEntryImage(_x, _x2) {
1357
- return _ref8.apply(this, arguments);
1358
- };
1359
- }();
474
+ const assetLink = contentType.fields.find(isAssetField);
475
+
476
+ if (!assetLink) {
477
+ return null;
478
+ }
479
+
480
+ const assetId = get(entry.fields, [assetLink.id, localeCode, 'sys', 'id']);
481
+
482
+ if (!assetId) {
483
+ return null;
484
+ }
485
+
486
+ try {
487
+ const asset = await getAsset(assetId);
488
+ const file = get(asset, ['fields', 'file', localeCode]);
489
+ const isImage = Boolean(get(file, ['details', 'image'], false));
490
+ return isImage ? file : null;
491
+ } catch (e) {
492
+ return null;
493
+ }
494
+ };
1360
495
 
1361
496
  var entityHelpers = {
1362
497
  __proto__: null,
@@ -1372,33 +507,27 @@ var entityHelpers = {
1372
507
  };
1373
508
 
1374
509
  /* eslint-disable @typescript-eslint/no-explicit-any */
1375
- function fromFieldValidations(validations, fieldType) {
1376
- if (validations === void 0) {
1377
- validations = [];
1378
- }
1379
-
1380
- var sizeValidation = validations.find(function (v) {
1381
- return 'size' in v;
1382
- });
1383
- var size = sizeValidation && sizeValidation.size || {};
1384
- var min = size.min;
1385
- var max = size.max;
510
+ function fromFieldValidations(validations = [], fieldType) {
511
+ const sizeValidation = validations.find(v => 'size' in v);
512
+ const size = sizeValidation && sizeValidation.size || {};
513
+ const min = size.min;
514
+ const max = size.max;
1386
515
 
1387
516
  if (isNumber(min) && isNumber(max)) {
1388
517
  return {
1389
518
  type: 'min-max',
1390
- min: min,
1391
- max: max
519
+ min,
520
+ max
1392
521
  };
1393
522
  } else if (isNumber(min)) {
1394
523
  return {
1395
524
  type: 'min',
1396
- min: min
525
+ min
1397
526
  };
1398
527
  } else if (isNumber(max)) {
1399
528
  return {
1400
529
  type: 'max',
1401
- max: max
530
+ max
1402
531
  };
1403
532
  } else {
1404
533
  return {
@@ -1429,7 +558,7 @@ var constraints = {
1429
558
  * Checks whether the passed content type matches one of our valid MIME types
1430
559
  */
1431
560
  function isValidImage(file) {
1432
- var validMimeTypes = ['image/avif', 'image/bmp', 'image/x-windows-bmp', 'image/gif', 'image/webp', // This is not a valid MIME type but we supported it in the past.
561
+ const validMimeTypes = ['image/avif', 'image/bmp', 'image/x-windows-bmp', 'image/gif', 'image/webp', // This is not a valid MIME type but we supported it in the past.
1433
562
  'image/jpg', 'image/jpeg', 'image/pjpeg', 'image/x-jps', 'image/png', 'image/svg+xml'];
1434
563
  return validMimeTypes.includes(file.contentType);
1435
564
  }
@@ -1462,42 +591,34 @@ function shortenStorageUnit(value, uom) {
1462
591
  return '0 B';
1463
592
  }
1464
593
 
1465
- var units = ['PB', 'TB', 'GB', 'MB', 'KB', 'B'];
594
+ const units = ['PB', 'TB', 'GB', 'MB', 'KB', 'B'];
1466
595
 
1467
- var getBigger = function getBigger(unit) {
1468
- return units[units.indexOf(unit) - 1];
1469
- };
596
+ const getBigger = unit => units[units.indexOf(unit) - 1];
1470
597
 
1471
- var getSmaller = function getSmaller(unit) {
1472
- return units[units.indexOf(unit) + 1];
1473
- };
598
+ const getSmaller = unit => units[units.indexOf(unit) + 1];
1474
599
 
1475
- var isBiggestUnit = function isBiggestUnit(unit) {
1476
- return units.indexOf(unit) === 0;
1477
- };
600
+ const isBiggestUnit = unit => units.indexOf(unit) === 0;
1478
601
 
1479
- var isSmallestUnit = function isSmallestUnit(unit) {
1480
- return units.indexOf(unit) === units.length - 1;
1481
- };
602
+ const isSmallestUnit = unit => units.indexOf(unit) === units.length - 1;
1482
603
 
1483
- var reduce = function reduce(number, unit) {
604
+ const reduce = (number, unit) => {
1484
605
  if (number < 0.99 && !isSmallestUnit(unit)) {
1485
606
  return reduce(number * 1000, getSmaller(unit));
1486
607
  } else if (number >= 1000 && !isBiggestUnit(unit)) {
1487
608
  return reduce(number / 1000, getBigger(unit));
1488
609
  } else {
1489
610
  return {
1490
- number: number,
1491
- unit: unit
611
+ number,
612
+ unit
1492
613
  };
1493
614
  }
1494
615
  };
1495
616
 
1496
- var _reduce = reduce(value, uom),
1497
- number = _reduce.number,
1498
- unit = _reduce.unit;
1499
-
1500
- return formatFloat(number, false) + " " + unit;
617
+ const {
618
+ number,
619
+ unit
620
+ } = reduce(value, uom);
621
+ return `${formatFloat(number, false)} ${unit}`;
1501
622
  }
1502
623
 
1503
624
  exports.CharCounter = CharCounter;