@plasmicpkgs/airtable 0.0.19

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.
@@ -0,0 +1,1149 @@
1
+ import { DataProvider, useSelector, repeatedElement, registerComponent, registerGlobalContext } from '@plasmicapp/host';
2
+ import { usePlasmicQueryData } from '@plasmicapp/query';
3
+ import React from 'react';
4
+
5
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
6
+ try {
7
+ var info = gen[key](arg);
8
+ var value = info.value;
9
+ } catch (error) {
10
+ reject(error);
11
+ return;
12
+ }
13
+
14
+ if (info.done) {
15
+ resolve(value);
16
+ } else {
17
+ Promise.resolve(value).then(_next, _throw);
18
+ }
19
+ }
20
+
21
+ function _asyncToGenerator(fn) {
22
+ return function () {
23
+ var self = this,
24
+ args = arguments;
25
+ return new Promise(function (resolve, reject) {
26
+ var gen = fn.apply(self, args);
27
+
28
+ function _next(value) {
29
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
30
+ }
31
+
32
+ function _throw(err) {
33
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
34
+ }
35
+
36
+ _next(undefined);
37
+ });
38
+ };
39
+ }
40
+
41
+ function _objectWithoutPropertiesLoose(source, excluded) {
42
+ if (source == null) return {};
43
+ var target = {};
44
+ var sourceKeys = Object.keys(source);
45
+ var key, i;
46
+
47
+ for (i = 0; i < sourceKeys.length; i++) {
48
+ key = sourceKeys[i];
49
+ if (excluded.indexOf(key) >= 0) continue;
50
+ target[key] = source[key];
51
+ }
52
+
53
+ return target;
54
+ }
55
+
56
+ function createCommonjsModule(fn, module) {
57
+ return module = { exports: {} }, fn(module, module.exports), module.exports;
58
+ }
59
+
60
+ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
61
+ /**
62
+ * Copyright (c) 2014-present, Facebook, Inc.
63
+ *
64
+ * This source code is licensed under the MIT license found in the
65
+ * LICENSE file in the root directory of this source tree.
66
+ */
67
+ var runtime = function (exports) {
68
+
69
+ var Op = Object.prototype;
70
+ var hasOwn = Op.hasOwnProperty;
71
+ var undefined$1; // More compressible than void 0.
72
+
73
+ var $Symbol = typeof Symbol === "function" ? Symbol : {};
74
+ var iteratorSymbol = $Symbol.iterator || "@@iterator";
75
+ var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
76
+ var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
77
+
78
+ function define(obj, key, value) {
79
+ Object.defineProperty(obj, key, {
80
+ value: value,
81
+ enumerable: true,
82
+ configurable: true,
83
+ writable: true
84
+ });
85
+ return obj[key];
86
+ }
87
+
88
+ try {
89
+ // IE 8 has a broken Object.defineProperty that only works on DOM objects.
90
+ define({}, "");
91
+ } catch (err) {
92
+ define = function define(obj, key, value) {
93
+ return obj[key] = value;
94
+ };
95
+ }
96
+
97
+ function wrap(innerFn, outerFn, self, tryLocsList) {
98
+ // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
99
+ var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
100
+ var generator = Object.create(protoGenerator.prototype);
101
+ var context = new Context(tryLocsList || []); // The ._invoke method unifies the implementations of the .next,
102
+ // .throw, and .return methods.
103
+
104
+ generator._invoke = makeInvokeMethod(innerFn, self, context);
105
+ return generator;
106
+ }
107
+
108
+ exports.wrap = wrap; // Try/catch helper to minimize deoptimizations. Returns a completion
109
+ // record like context.tryEntries[i].completion. This interface could
110
+ // have been (and was previously) designed to take a closure to be
111
+ // invoked without arguments, but in all the cases we care about we
112
+ // already have an existing method we want to call, so there's no need
113
+ // to create a new function object. We can even get away with assuming
114
+ // the method takes exactly one argument, since that happens to be true
115
+ // in every case, so we don't have to touch the arguments object. The
116
+ // only additional allocation required is the completion record, which
117
+ // has a stable shape and so hopefully should be cheap to allocate.
118
+
119
+ function tryCatch(fn, obj, arg) {
120
+ try {
121
+ return {
122
+ type: "normal",
123
+ arg: fn.call(obj, arg)
124
+ };
125
+ } catch (err) {
126
+ return {
127
+ type: "throw",
128
+ arg: err
129
+ };
130
+ }
131
+ }
132
+
133
+ var GenStateSuspendedStart = "suspendedStart";
134
+ var GenStateSuspendedYield = "suspendedYield";
135
+ var GenStateExecuting = "executing";
136
+ var GenStateCompleted = "completed"; // Returning this object from the innerFn has the same effect as
137
+ // breaking out of the dispatch switch statement.
138
+
139
+ var ContinueSentinel = {}; // Dummy constructor functions that we use as the .constructor and
140
+ // .constructor.prototype properties for functions that return Generator
141
+ // objects. For full spec compliance, you may wish to configure your
142
+ // minifier not to mangle the names of these two functions.
143
+
144
+ function Generator() {}
145
+
146
+ function GeneratorFunction() {}
147
+
148
+ function GeneratorFunctionPrototype() {} // This is a polyfill for %IteratorPrototype% for environments that
149
+ // don't natively support it.
150
+
151
+
152
+ var IteratorPrototype = {};
153
+
154
+ IteratorPrototype[iteratorSymbol] = function () {
155
+ return this;
156
+ };
157
+
158
+ var getProto = Object.getPrototypeOf;
159
+ var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
160
+
161
+ if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
162
+ // This environment has a native %IteratorPrototype%; use it instead
163
+ // of the polyfill.
164
+ IteratorPrototype = NativeIteratorPrototype;
165
+ }
166
+
167
+ var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
168
+ GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
169
+ GeneratorFunctionPrototype.constructor = GeneratorFunction;
170
+ GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"); // Helper for defining the .next, .throw, and .return methods of the
171
+ // Iterator interface in terms of a single ._invoke method.
172
+
173
+ function defineIteratorMethods(prototype) {
174
+ ["next", "throw", "return"].forEach(function (method) {
175
+ define(prototype, method, function (arg) {
176
+ return this._invoke(method, arg);
177
+ });
178
+ });
179
+ }
180
+
181
+ exports.isGeneratorFunction = function (genFun) {
182
+ var ctor = typeof genFun === "function" && genFun.constructor;
183
+ return ctor ? ctor === GeneratorFunction || // For the native GeneratorFunction constructor, the best we can
184
+ // do is to check its .name property.
185
+ (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
186
+ };
187
+
188
+ exports.mark = function (genFun) {
189
+ if (Object.setPrototypeOf) {
190
+ Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
191
+ } else {
192
+ genFun.__proto__ = GeneratorFunctionPrototype;
193
+ define(genFun, toStringTagSymbol, "GeneratorFunction");
194
+ }
195
+
196
+ genFun.prototype = Object.create(Gp);
197
+ return genFun;
198
+ }; // Within the body of any async function, `await x` is transformed to
199
+ // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
200
+ // `hasOwn.call(value, "__await")` to determine if the yielded value is
201
+ // meant to be awaited.
202
+
203
+
204
+ exports.awrap = function (arg) {
205
+ return {
206
+ __await: arg
207
+ };
208
+ };
209
+
210
+ function AsyncIterator(generator, PromiseImpl) {
211
+ function invoke(method, arg, resolve, reject) {
212
+ var record = tryCatch(generator[method], generator, arg);
213
+
214
+ if (record.type === "throw") {
215
+ reject(record.arg);
216
+ } else {
217
+ var result = record.arg;
218
+ var value = result.value;
219
+
220
+ if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
221
+ return PromiseImpl.resolve(value.__await).then(function (value) {
222
+ invoke("next", value, resolve, reject);
223
+ }, function (err) {
224
+ invoke("throw", err, resolve, reject);
225
+ });
226
+ }
227
+
228
+ return PromiseImpl.resolve(value).then(function (unwrapped) {
229
+ // When a yielded Promise is resolved, its final value becomes
230
+ // the .value of the Promise<{value,done}> result for the
231
+ // current iteration.
232
+ result.value = unwrapped;
233
+ resolve(result);
234
+ }, function (error) {
235
+ // If a rejected Promise was yielded, throw the rejection back
236
+ // into the async generator function so it can be handled there.
237
+ return invoke("throw", error, resolve, reject);
238
+ });
239
+ }
240
+ }
241
+
242
+ var previousPromise;
243
+
244
+ function enqueue(method, arg) {
245
+ function callInvokeWithMethodAndArg() {
246
+ return new PromiseImpl(function (resolve, reject) {
247
+ invoke(method, arg, resolve, reject);
248
+ });
249
+ }
250
+
251
+ return previousPromise = // If enqueue has been called before, then we want to wait until
252
+ // all previous Promises have been resolved before calling invoke,
253
+ // so that results are always delivered in the correct order. If
254
+ // enqueue has not been called before, then it is important to
255
+ // call invoke immediately, without waiting on a callback to fire,
256
+ // so that the async generator function has the opportunity to do
257
+ // any necessary setup in a predictable way. This predictability
258
+ // is why the Promise constructor synchronously invokes its
259
+ // executor callback, and why async functions synchronously
260
+ // execute code before the first await. Since we implement simple
261
+ // async functions in terms of async generators, it is especially
262
+ // important to get this right, even though it requires care.
263
+ previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, // Avoid propagating failures to Promises returned by later
264
+ // invocations of the iterator.
265
+ callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
266
+ } // Define the unified helper method that is used to implement .next,
267
+ // .throw, and .return (see defineIteratorMethods).
268
+
269
+
270
+ this._invoke = enqueue;
271
+ }
272
+
273
+ defineIteratorMethods(AsyncIterator.prototype);
274
+
275
+ AsyncIterator.prototype[asyncIteratorSymbol] = function () {
276
+ return this;
277
+ };
278
+
279
+ exports.AsyncIterator = AsyncIterator; // Note that simple async functions are implemented on top of
280
+ // AsyncIterator objects; they just return a Promise for the value of
281
+ // the final result produced by the iterator.
282
+
283
+ exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
284
+ if (PromiseImpl === void 0) PromiseImpl = Promise;
285
+ var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
286
+ return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator.
287
+ : iter.next().then(function (result) {
288
+ return result.done ? result.value : iter.next();
289
+ });
290
+ };
291
+
292
+ function makeInvokeMethod(innerFn, self, context) {
293
+ var state = GenStateSuspendedStart;
294
+ return function invoke(method, arg) {
295
+ if (state === GenStateExecuting) {
296
+ throw new Error("Generator is already running");
297
+ }
298
+
299
+ if (state === GenStateCompleted) {
300
+ if (method === "throw") {
301
+ throw arg;
302
+ } // Be forgiving, per 25.3.3.3.3 of the spec:
303
+ // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
304
+
305
+
306
+ return doneResult();
307
+ }
308
+
309
+ context.method = method;
310
+ context.arg = arg;
311
+
312
+ while (true) {
313
+ var delegate = context.delegate;
314
+
315
+ if (delegate) {
316
+ var delegateResult = maybeInvokeDelegate(delegate, context);
317
+
318
+ if (delegateResult) {
319
+ if (delegateResult === ContinueSentinel) continue;
320
+ return delegateResult;
321
+ }
322
+ }
323
+
324
+ if (context.method === "next") {
325
+ // Setting context._sent for legacy support of Babel's
326
+ // function.sent implementation.
327
+ context.sent = context._sent = context.arg;
328
+ } else if (context.method === "throw") {
329
+ if (state === GenStateSuspendedStart) {
330
+ state = GenStateCompleted;
331
+ throw context.arg;
332
+ }
333
+
334
+ context.dispatchException(context.arg);
335
+ } else if (context.method === "return") {
336
+ context.abrupt("return", context.arg);
337
+ }
338
+
339
+ state = GenStateExecuting;
340
+ var record = tryCatch(innerFn, self, context);
341
+
342
+ if (record.type === "normal") {
343
+ // If an exception is thrown from innerFn, we leave state ===
344
+ // GenStateExecuting and loop back for another invocation.
345
+ state = context.done ? GenStateCompleted : GenStateSuspendedYield;
346
+
347
+ if (record.arg === ContinueSentinel) {
348
+ continue;
349
+ }
350
+
351
+ return {
352
+ value: record.arg,
353
+ done: context.done
354
+ };
355
+ } else if (record.type === "throw") {
356
+ state = GenStateCompleted; // Dispatch the exception by looping back around to the
357
+ // context.dispatchException(context.arg) call above.
358
+
359
+ context.method = "throw";
360
+ context.arg = record.arg;
361
+ }
362
+ }
363
+ };
364
+ } // Call delegate.iterator[context.method](context.arg) and handle the
365
+ // result, either by returning a { value, done } result from the
366
+ // delegate iterator, or by modifying context.method and context.arg,
367
+ // setting context.delegate to null, and returning the ContinueSentinel.
368
+
369
+
370
+ function maybeInvokeDelegate(delegate, context) {
371
+ var method = delegate.iterator[context.method];
372
+
373
+ if (method === undefined$1) {
374
+ // A .throw or .return when the delegate iterator has no .throw
375
+ // method always terminates the yield* loop.
376
+ context.delegate = null;
377
+
378
+ if (context.method === "throw") {
379
+ // Note: ["return"] must be used for ES3 parsing compatibility.
380
+ if (delegate.iterator["return"]) {
381
+ // If the delegate iterator has a return method, give it a
382
+ // chance to clean up.
383
+ context.method = "return";
384
+ context.arg = undefined$1;
385
+ maybeInvokeDelegate(delegate, context);
386
+
387
+ if (context.method === "throw") {
388
+ // If maybeInvokeDelegate(context) changed context.method from
389
+ // "return" to "throw", let that override the TypeError below.
390
+ return ContinueSentinel;
391
+ }
392
+ }
393
+
394
+ context.method = "throw";
395
+ context.arg = new TypeError("The iterator does not provide a 'throw' method");
396
+ }
397
+
398
+ return ContinueSentinel;
399
+ }
400
+
401
+ var record = tryCatch(method, delegate.iterator, context.arg);
402
+
403
+ if (record.type === "throw") {
404
+ context.method = "throw";
405
+ context.arg = record.arg;
406
+ context.delegate = null;
407
+ return ContinueSentinel;
408
+ }
409
+
410
+ var info = record.arg;
411
+
412
+ if (!info) {
413
+ context.method = "throw";
414
+ context.arg = new TypeError("iterator result is not an object");
415
+ context.delegate = null;
416
+ return ContinueSentinel;
417
+ }
418
+
419
+ if (info.done) {
420
+ // Assign the result of the finished delegate to the temporary
421
+ // variable specified by delegate.resultName (see delegateYield).
422
+ context[delegate.resultName] = info.value; // Resume execution at the desired location (see delegateYield).
423
+
424
+ context.next = delegate.nextLoc; // If context.method was "throw" but the delegate handled the
425
+ // exception, let the outer generator proceed normally. If
426
+ // context.method was "next", forget context.arg since it has been
427
+ // "consumed" by the delegate iterator. If context.method was
428
+ // "return", allow the original .return call to continue in the
429
+ // outer generator.
430
+
431
+ if (context.method !== "return") {
432
+ context.method = "next";
433
+ context.arg = undefined$1;
434
+ }
435
+ } else {
436
+ // Re-yield the result returned by the delegate method.
437
+ return info;
438
+ } // The delegate iterator is finished, so forget it and continue with
439
+ // the outer generator.
440
+
441
+
442
+ context.delegate = null;
443
+ return ContinueSentinel;
444
+ } // Define Generator.prototype.{next,throw,return} in terms of the
445
+ // unified ._invoke helper method.
446
+
447
+
448
+ defineIteratorMethods(Gp);
449
+ define(Gp, toStringTagSymbol, "Generator"); // A Generator should always return itself as the iterator object when the
450
+ // @@iterator function is called on it. Some browsers' implementations of the
451
+ // iterator prototype chain incorrectly implement this, causing the Generator
452
+ // object to not be returned from this call. This ensures that doesn't happen.
453
+ // See https://github.com/facebook/regenerator/issues/274 for more details.
454
+
455
+ Gp[iteratorSymbol] = function () {
456
+ return this;
457
+ };
458
+
459
+ Gp.toString = function () {
460
+ return "[object Generator]";
461
+ };
462
+
463
+ function pushTryEntry(locs) {
464
+ var entry = {
465
+ tryLoc: locs[0]
466
+ };
467
+
468
+ if (1 in locs) {
469
+ entry.catchLoc = locs[1];
470
+ }
471
+
472
+ if (2 in locs) {
473
+ entry.finallyLoc = locs[2];
474
+ entry.afterLoc = locs[3];
475
+ }
476
+
477
+ this.tryEntries.push(entry);
478
+ }
479
+
480
+ function resetTryEntry(entry) {
481
+ var record = entry.completion || {};
482
+ record.type = "normal";
483
+ delete record.arg;
484
+ entry.completion = record;
485
+ }
486
+
487
+ function Context(tryLocsList) {
488
+ // The root entry object (effectively a try statement without a catch
489
+ // or a finally block) gives us a place to store values thrown from
490
+ // locations where there is no enclosing try statement.
491
+ this.tryEntries = [{
492
+ tryLoc: "root"
493
+ }];
494
+ tryLocsList.forEach(pushTryEntry, this);
495
+ this.reset(true);
496
+ }
497
+
498
+ exports.keys = function (object) {
499
+ var keys = [];
500
+
501
+ for (var key in object) {
502
+ keys.push(key);
503
+ }
504
+
505
+ keys.reverse(); // Rather than returning an object with a next method, we keep
506
+ // things simple and return the next function itself.
507
+
508
+ return function next() {
509
+ while (keys.length) {
510
+ var key = keys.pop();
511
+
512
+ if (key in object) {
513
+ next.value = key;
514
+ next.done = false;
515
+ return next;
516
+ }
517
+ } // To avoid creating an additional object, we just hang the .value
518
+ // and .done properties off the next function object itself. This
519
+ // also ensures that the minifier will not anonymize the function.
520
+
521
+
522
+ next.done = true;
523
+ return next;
524
+ };
525
+ };
526
+
527
+ function values(iterable) {
528
+ if (iterable) {
529
+ var iteratorMethod = iterable[iteratorSymbol];
530
+
531
+ if (iteratorMethod) {
532
+ return iteratorMethod.call(iterable);
533
+ }
534
+
535
+ if (typeof iterable.next === "function") {
536
+ return iterable;
537
+ }
538
+
539
+ if (!isNaN(iterable.length)) {
540
+ var i = -1,
541
+ next = function next() {
542
+ while (++i < iterable.length) {
543
+ if (hasOwn.call(iterable, i)) {
544
+ next.value = iterable[i];
545
+ next.done = false;
546
+ return next;
547
+ }
548
+ }
549
+
550
+ next.value = undefined$1;
551
+ next.done = true;
552
+ return next;
553
+ };
554
+
555
+ return next.next = next;
556
+ }
557
+ } // Return an iterator with no values.
558
+
559
+
560
+ return {
561
+ next: doneResult
562
+ };
563
+ }
564
+
565
+ exports.values = values;
566
+
567
+ function doneResult() {
568
+ return {
569
+ value: undefined$1,
570
+ done: true
571
+ };
572
+ }
573
+
574
+ Context.prototype = {
575
+ constructor: Context,
576
+ reset: function reset(skipTempReset) {
577
+ this.prev = 0;
578
+ this.next = 0; // Resetting context._sent for legacy support of Babel's
579
+ // function.sent implementation.
580
+
581
+ this.sent = this._sent = undefined$1;
582
+ this.done = false;
583
+ this.delegate = null;
584
+ this.method = "next";
585
+ this.arg = undefined$1;
586
+ this.tryEntries.forEach(resetTryEntry);
587
+
588
+ if (!skipTempReset) {
589
+ for (var name in this) {
590
+ // Not sure about the optimal order of these conditions:
591
+ if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
592
+ this[name] = undefined$1;
593
+ }
594
+ }
595
+ }
596
+ },
597
+ stop: function stop() {
598
+ this.done = true;
599
+ var rootEntry = this.tryEntries[0];
600
+ var rootRecord = rootEntry.completion;
601
+
602
+ if (rootRecord.type === "throw") {
603
+ throw rootRecord.arg;
604
+ }
605
+
606
+ return this.rval;
607
+ },
608
+ dispatchException: function dispatchException(exception) {
609
+ if (this.done) {
610
+ throw exception;
611
+ }
612
+
613
+ var context = this;
614
+
615
+ function handle(loc, caught) {
616
+ record.type = "throw";
617
+ record.arg = exception;
618
+ context.next = loc;
619
+
620
+ if (caught) {
621
+ // If the dispatched exception was caught by a catch block,
622
+ // then let that catch block handle the exception normally.
623
+ context.method = "next";
624
+ context.arg = undefined$1;
625
+ }
626
+
627
+ return !!caught;
628
+ }
629
+
630
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
631
+ var entry = this.tryEntries[i];
632
+ var record = entry.completion;
633
+
634
+ if (entry.tryLoc === "root") {
635
+ // Exception thrown outside of any try block that could handle
636
+ // it, so set the completion value of the entire function to
637
+ // throw the exception.
638
+ return handle("end");
639
+ }
640
+
641
+ if (entry.tryLoc <= this.prev) {
642
+ var hasCatch = hasOwn.call(entry, "catchLoc");
643
+ var hasFinally = hasOwn.call(entry, "finallyLoc");
644
+
645
+ if (hasCatch && hasFinally) {
646
+ if (this.prev < entry.catchLoc) {
647
+ return handle(entry.catchLoc, true);
648
+ } else if (this.prev < entry.finallyLoc) {
649
+ return handle(entry.finallyLoc);
650
+ }
651
+ } else if (hasCatch) {
652
+ if (this.prev < entry.catchLoc) {
653
+ return handle(entry.catchLoc, true);
654
+ }
655
+ } else if (hasFinally) {
656
+ if (this.prev < entry.finallyLoc) {
657
+ return handle(entry.finallyLoc);
658
+ }
659
+ } else {
660
+ throw new Error("try statement without catch or finally");
661
+ }
662
+ }
663
+ }
664
+ },
665
+ abrupt: function abrupt(type, arg) {
666
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
667
+ var entry = this.tryEntries[i];
668
+
669
+ if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
670
+ var finallyEntry = entry;
671
+ break;
672
+ }
673
+ }
674
+
675
+ if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
676
+ // Ignore the finally entry if control is not jumping to a
677
+ // location outside the try/catch block.
678
+ finallyEntry = null;
679
+ }
680
+
681
+ var record = finallyEntry ? finallyEntry.completion : {};
682
+ record.type = type;
683
+ record.arg = arg;
684
+
685
+ if (finallyEntry) {
686
+ this.method = "next";
687
+ this.next = finallyEntry.finallyLoc;
688
+ return ContinueSentinel;
689
+ }
690
+
691
+ return this.complete(record);
692
+ },
693
+ complete: function complete(record, afterLoc) {
694
+ if (record.type === "throw") {
695
+ throw record.arg;
696
+ }
697
+
698
+ if (record.type === "break" || record.type === "continue") {
699
+ this.next = record.arg;
700
+ } else if (record.type === "return") {
701
+ this.rval = this.arg = record.arg;
702
+ this.method = "return";
703
+ this.next = "end";
704
+ } else if (record.type === "normal" && afterLoc) {
705
+ this.next = afterLoc;
706
+ }
707
+
708
+ return ContinueSentinel;
709
+ },
710
+ finish: function finish(finallyLoc) {
711
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
712
+ var entry = this.tryEntries[i];
713
+
714
+ if (entry.finallyLoc === finallyLoc) {
715
+ this.complete(entry.completion, entry.afterLoc);
716
+ resetTryEntry(entry);
717
+ return ContinueSentinel;
718
+ }
719
+ }
720
+ },
721
+ "catch": function _catch(tryLoc) {
722
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
723
+ var entry = this.tryEntries[i];
724
+
725
+ if (entry.tryLoc === tryLoc) {
726
+ var record = entry.completion;
727
+
728
+ if (record.type === "throw") {
729
+ var thrown = record.arg;
730
+ resetTryEntry(entry);
731
+ }
732
+
733
+ return thrown;
734
+ }
735
+ } // The context.catch method must only be called with a location
736
+ // argument that corresponds to a known catch block.
737
+
738
+
739
+ throw new Error("illegal catch attempt");
740
+ },
741
+ delegateYield: function delegateYield(iterable, resultName, nextLoc) {
742
+ this.delegate = {
743
+ iterator: values(iterable),
744
+ resultName: resultName,
745
+ nextLoc: nextLoc
746
+ };
747
+
748
+ if (this.method === "next") {
749
+ // Deliberately forget the last sent value so that we don't
750
+ // accidentally pass it on to the delegate.
751
+ this.arg = undefined$1;
752
+ }
753
+
754
+ return ContinueSentinel;
755
+ }
756
+ }; // Regardless of whether this script is executing as a CommonJS module
757
+ // or not, return the runtime object so that we can declare the variable
758
+ // regeneratorRuntime in the outer scope, which allows this module to be
759
+ // injected easily by `bin/regenerator --include-runtime script.js`.
760
+
761
+ return exports;
762
+ }( // If this script is executing as a CommonJS module, use module.exports
763
+ // as the regeneratorRuntime namespace. Otherwise create a new empty
764
+ // object. Either way, the resulting object will be used to initialize
765
+ // the regeneratorRuntime variable at the top of this file.
766
+ module.exports );
767
+
768
+ try {
769
+ regeneratorRuntime = runtime;
770
+ } catch (accidentalStrictMode) {
771
+ // This module should not be running in strict mode, so the above
772
+ // assignment should always work unless something is misconfigured. Just
773
+ // in case runtime.js accidentally runs in strict mode, we can escape
774
+ // strict mode using a global Function call. This could conceivably fail
775
+ // if a Content Security Policy forbids using Function, but in that case
776
+ // the proper solution is to fix the accidental strict mode problem. If
777
+ // you've misconfigured your bundler to force strict mode and applied a
778
+ // CSP to forbid Function, and you're not willing to fix either of those
779
+ // problems, please detail your unique predicament in a GitHub issue.
780
+ Function("r", "regeneratorRuntime = r")(runtime);
781
+ }
782
+ });
783
+
784
+ var _excluded = ["table", "record", "children"],
785
+ _excluded2 = ["table", "children"];
786
+ var defaultHost = "https://studio.plasmic.app";
787
+ var CredentialsContext = /*#__PURE__*/React.createContext(undefined);
788
+ function AirtableRecord(_ref) {
789
+ var _props$base, _props$dataSourceId, _credentialsContext$h;
790
+
791
+ var table = _ref.table,
792
+ record = _ref.record,
793
+ children = _ref.children,
794
+ props = _objectWithoutPropertiesLoose(_ref, _excluded);
795
+
796
+ var credentialsContext = React.useContext(CredentialsContext);
797
+ var base = (_props$base = props.base) != null ? _props$base : credentialsContext == null ? void 0 : credentialsContext.base;
798
+ var dataSourceId = (_props$dataSourceId = props.dataSourceId) != null ? _props$dataSourceId : credentialsContext == null ? void 0 : credentialsContext.dataSourceId;
799
+ var host = (_credentialsContext$h = credentialsContext == null ? void 0 : credentialsContext.host) != null ? _credentialsContext$h : defaultHost;
800
+ var data = usePlasmicQueryData(JSON.stringify(["AirtableRecord", host, base, table, record, dataSourceId]), /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
801
+ var pathname, url;
802
+ return runtime_1.wrap(function _callee$(_context) {
803
+ while (1) {
804
+ switch (_context.prev = _context.next) {
805
+ case 0:
806
+ if (!(!base || !dataSourceId || !table)) {
807
+ _context.next = 2;
808
+ break;
809
+ }
810
+
811
+ throw new Error("AirtableRecord needs base ID, table and Data Source ID");
812
+
813
+ case 2:
814
+ pathname = "/" + base + "/" + table + "/" + record;
815
+ url = host + "/api/v1/server-data-sources/query?pathname=" + encodeURIComponent(pathname) + "&dataSourceId=" + dataSourceId;
816
+ _context.next = 6;
817
+ return fetch(url, {
818
+ method: "GET"
819
+ });
820
+
821
+ case 6:
822
+ _context.next = 8;
823
+ return _context.sent.json();
824
+
825
+ case 8:
826
+ return _context.abrupt("return", _context.sent.fields);
827
+
828
+ case 9:
829
+ case "end":
830
+ return _context.stop();
831
+ }
832
+ }
833
+ }, _callee);
834
+ })));
835
+
836
+ if ("error" in data) {
837
+ var _data$error;
838
+
839
+ return React.createElement("p", null, "Error: ", (_data$error = data.error) == null ? void 0 : _data$error.message);
840
+ }
841
+
842
+ if (!("data" in data)) {
843
+ return React.createElement("p", null, "Loading...");
844
+ }
845
+
846
+ return React.createElement(DataProvider, {
847
+ name: contextKey,
848
+ data: data.data
849
+ }, children);
850
+ }
851
+ var contextKey = "__airtableRecord";
852
+
853
+ function useRecord() {
854
+ return useSelector(contextKey);
855
+ }
856
+
857
+ function AirtableRecordField(_ref3) {
858
+ var className = _ref3.className,
859
+ field = _ref3.field,
860
+ style = _ref3.style,
861
+ setControlContextData = _ref3.setControlContextData;
862
+ var record = useRecord();
863
+ setControlContextData == null ? void 0 : setControlContextData(record);
864
+ return React.createElement("div", {
865
+ className: className,
866
+ style: style
867
+ }, record ? function () {
868
+ var val = record[field || Object.keys(record)[0]];
869
+
870
+ if (val && typeof val === "object") {
871
+ return "Attachment " + val[0].filename;
872
+ }
873
+
874
+ return val;
875
+ }() : "Error: Must provide a record to AirtableRecordField");
876
+ }
877
+ function AirtableCollection(_ref4) {
878
+ var _props$base2, _props$dataSourceId2, _credentialsContext$h2;
879
+
880
+ var table = _ref4.table,
881
+ children = _ref4.children,
882
+ props = _objectWithoutPropertiesLoose(_ref4, _excluded2);
883
+
884
+ var credentialsContext = React.useContext(CredentialsContext);
885
+ var base = (_props$base2 = props.base) != null ? _props$base2 : credentialsContext == null ? void 0 : credentialsContext.base;
886
+ var dataSourceId = (_props$dataSourceId2 = props.dataSourceId) != null ? _props$dataSourceId2 : credentialsContext == null ? void 0 : credentialsContext.dataSourceId;
887
+ var host = (_credentialsContext$h2 = credentialsContext == null ? void 0 : credentialsContext.host) != null ? _credentialsContext$h2 : defaultHost;
888
+ var searchArray = [];
889
+
890
+ if (props.fields) {
891
+ props.fields.forEach(function (f) {
892
+ return searchArray.push(encodeURIComponent("fields[]") + "=" + encodeURIComponent("" + f));
893
+ });
894
+ }
895
+
896
+ ["filterByFormula", "maxRecords", "pageSize", "view"].forEach(function (prop) {
897
+ if (props[prop]) {
898
+ searchArray.push(encodeURIComponent("" + prop) + "=" + encodeURIComponent("" + props[prop]));
899
+ }
900
+ });
901
+
902
+ if (props.sort) {
903
+ props.sort.forEach(function (v, i) {
904
+ searchArray.push(encodeURIComponent("sort[" + i + "][field]") + "=" + encodeURIComponent("" + v.field));
905
+
906
+ if (v.direction) {
907
+ searchArray.push(encodeURIComponent("sort[" + i + "][direction]") + "=" + encodeURIComponent("" + v.direction));
908
+ }
909
+ });
910
+ }
911
+
912
+ var search = searchArray.length === 0 ? "" : "?" + searchArray.join("&");
913
+ var data = usePlasmicQueryData(JSON.stringify(["AirtableCollection", host, base, table, search, dataSourceId]), /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
914
+ var pathname, url;
915
+ return runtime_1.wrap(function _callee2$(_context2) {
916
+ while (1) {
917
+ switch (_context2.prev = _context2.next) {
918
+ case 0:
919
+ if (!(!base || !dataSourceId || !table)) {
920
+ _context2.next = 2;
921
+ break;
922
+ }
923
+
924
+ throw new Error("AirtableRecord needs base ID, table and Data Source ID");
925
+
926
+ case 2:
927
+ pathname = "/" + base + "/" + table + search;
928
+ url = host + "/api/v1/server-data-sources/query?pathname=" + encodeURIComponent(pathname) + "&dataSourceId=" + dataSourceId;
929
+ _context2.next = 6;
930
+ return fetch(url, {
931
+ method: "GET"
932
+ });
933
+
934
+ case 6:
935
+ _context2.next = 8;
936
+ return _context2.sent.json();
937
+
938
+ case 8:
939
+ return _context2.abrupt("return", _context2.sent.records);
940
+
941
+ case 9:
942
+ case "end":
943
+ return _context2.stop();
944
+ }
945
+ }
946
+ }, _callee2);
947
+ })));
948
+
949
+ if ("error" in data) {
950
+ var _data$error2;
951
+
952
+ return React.createElement("p", null, "Error: ", (_data$error2 = data.error) == null ? void 0 : _data$error2.message);
953
+ }
954
+
955
+ if (!("data" in data)) {
956
+ return React.createElement("p", null, "Loading...");
957
+ }
958
+
959
+ return React.createElement(React.Fragment, null, data.data.map(function (record, index) {
960
+ return React.createElement(DataProvider, {
961
+ key: record.id,
962
+ name: contextKey,
963
+ data: record.fields
964
+ }, repeatedElement(index === 0, children));
965
+ }));
966
+ }
967
+ function AirtableCredentialsProvider(_ref6) {
968
+ var base = _ref6.base,
969
+ dataSourceId = _ref6.dataSourceId,
970
+ maybeHost = _ref6.host,
971
+ children = _ref6.children;
972
+ var host = maybeHost || defaultHost;
973
+ return React.createElement(CredentialsContext.Provider, {
974
+ value: {
975
+ base: base,
976
+ dataSourceId: dataSourceId,
977
+ host: host
978
+ }
979
+ }, children);
980
+ }
981
+ var thisModule = "@plasmicpkgs/airtable";
982
+ var airtableRecordMeta = {
983
+ name: "hostless-airtable-record",
984
+ displayName: "Airtable Record",
985
+ importPath: thisModule,
986
+ importName: "AirtableRecord",
987
+ props: {
988
+ children: {
989
+ type: "slot",
990
+ defaultValue: {
991
+ type: "component",
992
+ name: "hostless-airtable-record-field"
993
+ }
994
+ },
995
+ table: {
996
+ type: "string",
997
+ displayName: "Table Name",
998
+ description: "The Airtable table name or ID"
999
+ },
1000
+ record: {
1001
+ type: "string",
1002
+ displayName: "Record",
1003
+ description: "The table record ID"
1004
+ },
1005
+ base: {
1006
+ type: "string",
1007
+ displayName: "Base",
1008
+ defaultValueHint: "Read from Credentials Provider",
1009
+ description: "The Airtable Base (if not provided by the Credentials Provider)"
1010
+ },
1011
+ dataSourceId: {
1012
+ type: "string",
1013
+ displayName: "Data Source ID",
1014
+ defaultValueHint: "Read from Credentials Provider",
1015
+ description: "The Data Source ID with the Airtable secrets"
1016
+ }
1017
+ }
1018
+ };
1019
+ function registerAirtableRecord(loader, customAirtableRecordMeta) {
1020
+ if (loader) {
1021
+ loader.registerComponent(AirtableRecord, customAirtableRecordMeta != null ? customAirtableRecordMeta : airtableRecordMeta);
1022
+ } else {
1023
+ registerComponent(AirtableRecord, customAirtableRecordMeta != null ? customAirtableRecordMeta : airtableRecordMeta);
1024
+ }
1025
+ }
1026
+ var airtableRecordFieldMeta = {
1027
+ name: "hostless-airtable-record-field",
1028
+ displayName: "Airtable Record Field",
1029
+ importPath: thisModule,
1030
+ importName: "AirtableRecordField",
1031
+ props: {
1032
+ field: {
1033
+ type: "choice",
1034
+ displayName: "Field Name",
1035
+ defaultValueHint: "The first field",
1036
+ options: function options(_props, data) {
1037
+ return data ? Object.keys(data) : ["Data unavailable"];
1038
+ }
1039
+ }
1040
+ }
1041
+ };
1042
+ function registerAirtableRecordField(loader, customAirtableRecordFieldMeta) {
1043
+ if (loader) {
1044
+ loader.registerComponent(AirtableRecordField, customAirtableRecordFieldMeta != null ? customAirtableRecordFieldMeta : airtableRecordFieldMeta);
1045
+ } else {
1046
+ registerComponent(AirtableRecordField, customAirtableRecordFieldMeta != null ? customAirtableRecordFieldMeta : airtableRecordFieldMeta);
1047
+ }
1048
+ }
1049
+ var airtableCollectionMeta = {
1050
+ name: "hostless-airtable-collection",
1051
+ displayName: "Airtable Collection",
1052
+ importPath: thisModule,
1053
+ importName: "AirtableCollection",
1054
+ props: {
1055
+ children: {
1056
+ type: "slot",
1057
+ defaultValue: {
1058
+ type: "component",
1059
+ name: "hostless-airtable-record-field"
1060
+ }
1061
+ },
1062
+ table: {
1063
+ type: "string",
1064
+ displayName: "Table Name",
1065
+ description: "The Airtable table name or ID"
1066
+ },
1067
+ fields: {
1068
+ type: "object",
1069
+ displayName: "Fields",
1070
+ description: "List of strings containing the fields to be included"
1071
+ },
1072
+ maxRecords: {
1073
+ type: "number",
1074
+ displayName: "Max Records",
1075
+ description: "The maximum total number of records that will be returned",
1076
+ defaultValueHint: 100,
1077
+ max: 100,
1078
+ min: 1
1079
+ },
1080
+ view: {
1081
+ type: "string",
1082
+ displayName: "View",
1083
+ description: "The name or ID of a view in the table. If set, only records from that view will be returned"
1084
+ },
1085
+ sort: {
1086
+ type: "object",
1087
+ displayName: "Sort",
1088
+ description: 'A list of Airtable sort objects that specifies how the records will be ordered. Each sort object must have a field key specifying the name of the field to sort on, and an optional direction key that is either "asc" or "desc". The default direction is "asc"'
1089
+ },
1090
+ filterByFormula: {
1091
+ type: "string",
1092
+ displayName: "Filter by Formula",
1093
+ description: "An Airtable formula used to filter records"
1094
+ },
1095
+ base: {
1096
+ type: "string",
1097
+ displayName: "Base",
1098
+ defaultValueHint: "Read from Credentials Provider",
1099
+ description: "The Airtable Base (if not provided by the Credentials Provider)"
1100
+ },
1101
+ dataSourceId: {
1102
+ type: "string",
1103
+ displayName: "Data Source ID",
1104
+ defaultValueHint: "Read from Credentials Provider",
1105
+ description: "The Data Source ID with the Airtable secrets"
1106
+ }
1107
+ }
1108
+ };
1109
+ function registerAirtableCollection(loader, customAirtableCollectionMeta) {
1110
+ if (loader) {
1111
+ loader.registerComponent(AirtableCollection, customAirtableCollectionMeta != null ? customAirtableCollectionMeta : airtableCollectionMeta);
1112
+ } else {
1113
+ registerComponent(AirtableCollection, customAirtableCollectionMeta != null ? customAirtableCollectionMeta : airtableCollectionMeta);
1114
+ }
1115
+ }
1116
+ var airtableCredentialsProviderMeta = {
1117
+ name: "hostless-airtable-credentials-provider",
1118
+ displayName: "Airtable Credentials Provider",
1119
+ importPath: thisModule,
1120
+ importName: "AirtableCredentialsProvider",
1121
+ props: {
1122
+ base: {
1123
+ type: "string",
1124
+ displayName: "Base",
1125
+ description: "The Airtable Base"
1126
+ },
1127
+ dataSourceId: {
1128
+ type: "string",
1129
+ displayName: "Data Source ID",
1130
+ description: "The Data Source ID"
1131
+ },
1132
+ host: {
1133
+ type: "string",
1134
+ displayName: "Host",
1135
+ description: "Plasmic Server-Data URL",
1136
+ defaultValueHint: defaultHost
1137
+ }
1138
+ }
1139
+ };
1140
+ function registerAirtableCredentialsProvider(loader, customAirtableCredentialsProviderMeta) {
1141
+ if (loader) {
1142
+ loader.registerGlobalContext(AirtableCredentialsProvider, customAirtableCredentialsProviderMeta != null ? customAirtableCredentialsProviderMeta : airtableCredentialsProviderMeta);
1143
+ } else {
1144
+ registerGlobalContext(AirtableCredentialsProvider, customAirtableCredentialsProviderMeta != null ? customAirtableCredentialsProviderMeta : airtableCredentialsProviderMeta);
1145
+ }
1146
+ }
1147
+
1148
+ export { AirtableCollection, AirtableCredentialsProvider, AirtableRecord, AirtableRecordField, airtableCollectionMeta, airtableCredentialsProviderMeta, airtableRecordFieldMeta, airtableRecordMeta, registerAirtableCollection, registerAirtableCredentialsProvider, registerAirtableRecord, registerAirtableRecordField };
1149
+ //# sourceMappingURL=airtable.esm.js.map