@plasmicpkgs/plasmic-contentful 0.0.50 → 0.0.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/contentful.d.ts +8 -6
- package/dist/plasmic-contentful.cjs.development.js +286 -322
- package/dist/plasmic-contentful.cjs.development.js.map +1 -1
- package/dist/plasmic-contentful.cjs.production.min.js +1 -1
- package/dist/plasmic-contentful.cjs.production.min.js.map +1 -1
- package/dist/plasmic-contentful.esm.js +286 -322
- package/dist/plasmic-contentful.esm.js.map +1 -1
- package/dist/utils.d.ts +5 -0
- package/package.json +9 -9
|
@@ -4,7 +4,6 @@ import { documentToHtmlString } from '@contentful/rich-text-html-renderer';
|
|
|
4
4
|
import { DataProvider, repeatedElement, useSelector } from '@plasmicapp/host';
|
|
5
5
|
import { usePlasmicQueryData } from '@plasmicapp/query';
|
|
6
6
|
import { pascalCase } from 'change-case';
|
|
7
|
-
import { createClient } from 'contentful';
|
|
8
7
|
import get from 'dlv';
|
|
9
8
|
import React, { useContext } from 'react';
|
|
10
9
|
|
|
@@ -16,29 +15,24 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
|
16
15
|
reject(error);
|
|
17
16
|
return;
|
|
18
17
|
}
|
|
19
|
-
|
|
20
18
|
if (info.done) {
|
|
21
19
|
resolve(value);
|
|
22
20
|
} else {
|
|
23
21
|
Promise.resolve(value).then(_next, _throw);
|
|
24
22
|
}
|
|
25
23
|
}
|
|
26
|
-
|
|
27
24
|
function _asyncToGenerator(fn) {
|
|
28
25
|
return function () {
|
|
29
26
|
var self = this,
|
|
30
|
-
|
|
27
|
+
args = arguments;
|
|
31
28
|
return new Promise(function (resolve, reject) {
|
|
32
29
|
var gen = fn.apply(self, args);
|
|
33
|
-
|
|
34
30
|
function _next(value) {
|
|
35
31
|
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
36
32
|
}
|
|
37
|
-
|
|
38
33
|
function _throw(err) {
|
|
39
34
|
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
40
35
|
}
|
|
41
|
-
|
|
42
36
|
_next(undefined);
|
|
43
37
|
});
|
|
44
38
|
};
|
|
@@ -55,17 +49,16 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
55
49
|
* This source code is licensed under the MIT license found in the
|
|
56
50
|
* LICENSE file in the root directory of this source tree.
|
|
57
51
|
*/
|
|
52
|
+
|
|
58
53
|
var runtime = function (exports) {
|
|
59
54
|
|
|
60
55
|
var Op = Object.prototype;
|
|
61
56
|
var hasOwn = Op.hasOwnProperty;
|
|
62
57
|
var undefined$1; // More compressible than void 0.
|
|
63
|
-
|
|
64
58
|
var $Symbol = typeof Symbol === "function" ? Symbol : {};
|
|
65
59
|
var iteratorSymbol = $Symbol.iterator || "@@iterator";
|
|
66
60
|
var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
|
|
67
61
|
var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
68
|
-
|
|
69
62
|
function define(obj, key, value) {
|
|
70
63
|
Object.defineProperty(obj, key, {
|
|
71
64
|
value: value,
|
|
@@ -75,7 +68,6 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
75
68
|
});
|
|
76
69
|
return obj[key];
|
|
77
70
|
}
|
|
78
|
-
|
|
79
71
|
try {
|
|
80
72
|
// IE 8 has a broken Object.defineProperty that only works on DOM objects.
|
|
81
73
|
define({}, "");
|
|
@@ -84,19 +76,20 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
84
76
|
return obj[key] = value;
|
|
85
77
|
};
|
|
86
78
|
}
|
|
87
|
-
|
|
88
79
|
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
89
80
|
// If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
|
|
90
81
|
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
|
|
91
82
|
var generator = Object.create(protoGenerator.prototype);
|
|
92
|
-
var context = new Context(tryLocsList || []);
|
|
93
|
-
// .throw, and .return methods.
|
|
83
|
+
var context = new Context(tryLocsList || []);
|
|
94
84
|
|
|
85
|
+
// The ._invoke method unifies the implementations of the .next,
|
|
86
|
+
// .throw, and .return methods.
|
|
95
87
|
generator._invoke = makeInvokeMethod(innerFn, self, context);
|
|
96
88
|
return generator;
|
|
97
89
|
}
|
|
90
|
+
exports.wrap = wrap;
|
|
98
91
|
|
|
99
|
-
|
|
92
|
+
// Try/catch helper to minimize deoptimizations. Returns a completion
|
|
100
93
|
// record like context.tryEntries[i].completion. This interface could
|
|
101
94
|
// have been (and was previously) designed to take a closure to be
|
|
102
95
|
// invoked without arguments, but in all the cases we care about we
|
|
@@ -106,7 +99,6 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
106
99
|
// in every case, so we don't have to touch the arguments object. The
|
|
107
100
|
// only additional allocation required is the completion record, which
|
|
108
101
|
// has a stable shape and so hopefully should be cheap to allocate.
|
|
109
|
-
|
|
110
102
|
function tryCatch(fn, obj, arg) {
|
|
111
103
|
try {
|
|
112
104
|
return {
|
|
@@ -120,46 +112,44 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
120
112
|
};
|
|
121
113
|
}
|
|
122
114
|
}
|
|
123
|
-
|
|
124
115
|
var GenStateSuspendedStart = "suspendedStart";
|
|
125
116
|
var GenStateSuspendedYield = "suspendedYield";
|
|
126
117
|
var GenStateExecuting = "executing";
|
|
127
|
-
var GenStateCompleted = "completed";
|
|
118
|
+
var GenStateCompleted = "completed";
|
|
119
|
+
|
|
120
|
+
// Returning this object from the innerFn has the same effect as
|
|
128
121
|
// breaking out of the dispatch switch statement.
|
|
122
|
+
var ContinueSentinel = {};
|
|
129
123
|
|
|
130
|
-
|
|
124
|
+
// Dummy constructor functions that we use as the .constructor and
|
|
131
125
|
// .constructor.prototype properties for functions that return Generator
|
|
132
126
|
// objects. For full spec compliance, you may wish to configure your
|
|
133
127
|
// minifier not to mangle the names of these two functions.
|
|
134
|
-
|
|
135
128
|
function Generator() {}
|
|
136
|
-
|
|
137
129
|
function GeneratorFunction() {}
|
|
130
|
+
function GeneratorFunctionPrototype() {}
|
|
138
131
|
|
|
139
|
-
|
|
132
|
+
// This is a polyfill for %IteratorPrototype% for environments that
|
|
140
133
|
// don't natively support it.
|
|
141
|
-
|
|
142
|
-
|
|
143
134
|
var IteratorPrototype = {};
|
|
144
135
|
define(IteratorPrototype, iteratorSymbol, function () {
|
|
145
136
|
return this;
|
|
146
137
|
});
|
|
147
138
|
var getProto = Object.getPrototypeOf;
|
|
148
139
|
var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
149
|
-
|
|
150
140
|
if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
|
|
151
141
|
// This environment has a native %IteratorPrototype%; use it instead
|
|
152
142
|
// of the polyfill.
|
|
153
143
|
IteratorPrototype = NativeIteratorPrototype;
|
|
154
144
|
}
|
|
155
|
-
|
|
156
145
|
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
|
157
146
|
GeneratorFunction.prototype = GeneratorFunctionPrototype;
|
|
158
147
|
define(Gp, "constructor", GeneratorFunctionPrototype);
|
|
159
148
|
define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
|
|
160
|
-
GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction");
|
|
161
|
-
// Iterator interface in terms of a single ._invoke method.
|
|
149
|
+
GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction");
|
|
162
150
|
|
|
151
|
+
// Helper for defining the .next, .throw, and .return methods of the
|
|
152
|
+
// Iterator interface in terms of a single ._invoke method.
|
|
163
153
|
function defineIteratorMethods(prototype) {
|
|
164
154
|
["next", "throw", "return"].forEach(function (method) {
|
|
165
155
|
define(prototype, method, function (arg) {
|
|
@@ -167,14 +157,13 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
167
157
|
});
|
|
168
158
|
});
|
|
169
159
|
}
|
|
170
|
-
|
|
171
160
|
exports.isGeneratorFunction = function (genFun) {
|
|
172
161
|
var ctor = typeof genFun === "function" && genFun.constructor;
|
|
173
|
-
return ctor ? ctor === GeneratorFunction ||
|
|
162
|
+
return ctor ? ctor === GeneratorFunction ||
|
|
163
|
+
// For the native GeneratorFunction constructor, the best we can
|
|
174
164
|
// do is to check its .name property.
|
|
175
165
|
(ctor.displayName || ctor.name) === "GeneratorFunction" : false;
|
|
176
166
|
};
|
|
177
|
-
|
|
178
167
|
exports.mark = function (genFun) {
|
|
179
168
|
if (Object.setPrototypeOf) {
|
|
180
169
|
Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
|
|
@@ -182,31 +171,27 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
182
171
|
genFun.__proto__ = GeneratorFunctionPrototype;
|
|
183
172
|
define(genFun, toStringTagSymbol, "GeneratorFunction");
|
|
184
173
|
}
|
|
185
|
-
|
|
186
174
|
genFun.prototype = Object.create(Gp);
|
|
187
175
|
return genFun;
|
|
188
|
-
};
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
// Within the body of any async function, `await x` is transformed to
|
|
189
179
|
// `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
|
|
190
180
|
// `hasOwn.call(value, "__await")` to determine if the yielded value is
|
|
191
181
|
// meant to be awaited.
|
|
192
|
-
|
|
193
|
-
|
|
194
182
|
exports.awrap = function (arg) {
|
|
195
183
|
return {
|
|
196
184
|
__await: arg
|
|
197
185
|
};
|
|
198
186
|
};
|
|
199
|
-
|
|
200
187
|
function AsyncIterator(generator, PromiseImpl) {
|
|
201
188
|
function invoke(method, arg, resolve, reject) {
|
|
202
189
|
var record = tryCatch(generator[method], generator, arg);
|
|
203
|
-
|
|
204
190
|
if (record.type === "throw") {
|
|
205
191
|
reject(record.arg);
|
|
206
192
|
} else {
|
|
207
193
|
var result = record.arg;
|
|
208
194
|
var value = result.value;
|
|
209
|
-
|
|
210
195
|
if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
|
|
211
196
|
return PromiseImpl.resolve(value.__await).then(function (value) {
|
|
212
197
|
invoke("next", value, resolve, reject);
|
|
@@ -214,7 +199,6 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
214
199
|
invoke("throw", err, resolve, reject);
|
|
215
200
|
});
|
|
216
201
|
}
|
|
217
|
-
|
|
218
202
|
return PromiseImpl.resolve(value).then(function (unwrapped) {
|
|
219
203
|
// When a yielded Promise is resolved, its final value becomes
|
|
220
204
|
// the .value of the Promise<{value,done}> result for the
|
|
@@ -228,17 +212,15 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
228
212
|
});
|
|
229
213
|
}
|
|
230
214
|
}
|
|
231
|
-
|
|
232
215
|
var previousPromise;
|
|
233
|
-
|
|
234
216
|
function enqueue(method, arg) {
|
|
235
217
|
function callInvokeWithMethodAndArg() {
|
|
236
218
|
return new PromiseImpl(function (resolve, reject) {
|
|
237
219
|
invoke(method, arg, resolve, reject);
|
|
238
220
|
});
|
|
239
221
|
}
|
|
240
|
-
|
|
241
|
-
|
|
222
|
+
return previousPromise =
|
|
223
|
+
// If enqueue has been called before, then we want to wait until
|
|
242
224
|
// all previous Promises have been resolved before calling invoke,
|
|
243
225
|
// so that results are always delivered in the correct order. If
|
|
244
226
|
// enqueue has not been called before, then it is important to
|
|
@@ -250,24 +232,25 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
250
232
|
// execute code before the first await. Since we implement simple
|
|
251
233
|
// async functions in terms of async generators, it is especially
|
|
252
234
|
// important to get this right, even though it requires care.
|
|
253
|
-
previousPromise ? previousPromise.then(callInvokeWithMethodAndArg,
|
|
235
|
+
previousPromise ? previousPromise.then(callInvokeWithMethodAndArg,
|
|
236
|
+
// Avoid propagating failures to Promises returned by later
|
|
254
237
|
// invocations of the iterator.
|
|
255
238
|
callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
256
|
-
}
|
|
257
|
-
// .throw, and .return (see defineIteratorMethods).
|
|
258
|
-
|
|
239
|
+
}
|
|
259
240
|
|
|
241
|
+
// Define the unified helper method that is used to implement .next,
|
|
242
|
+
// .throw, and .return (see defineIteratorMethods).
|
|
260
243
|
this._invoke = enqueue;
|
|
261
244
|
}
|
|
262
|
-
|
|
263
245
|
defineIteratorMethods(AsyncIterator.prototype);
|
|
264
246
|
define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
|
|
265
247
|
return this;
|
|
266
248
|
});
|
|
267
|
-
exports.AsyncIterator = AsyncIterator;
|
|
249
|
+
exports.AsyncIterator = AsyncIterator;
|
|
250
|
+
|
|
251
|
+
// Note that simple async functions are implemented on top of
|
|
268
252
|
// AsyncIterator objects; they just return a Promise for the value of
|
|
269
253
|
// the final result produced by the iterator.
|
|
270
|
-
|
|
271
254
|
exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
272
255
|
if (PromiseImpl === void 0) PromiseImpl = Promise;
|
|
273
256
|
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
|
@@ -276,39 +259,32 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
276
259
|
return result.done ? result.value : iter.next();
|
|
277
260
|
});
|
|
278
261
|
};
|
|
279
|
-
|
|
280
262
|
function makeInvokeMethod(innerFn, self, context) {
|
|
281
263
|
var state = GenStateSuspendedStart;
|
|
282
264
|
return function invoke(method, arg) {
|
|
283
265
|
if (state === GenStateExecuting) {
|
|
284
266
|
throw new Error("Generator is already running");
|
|
285
267
|
}
|
|
286
|
-
|
|
287
268
|
if (state === GenStateCompleted) {
|
|
288
269
|
if (method === "throw") {
|
|
289
270
|
throw arg;
|
|
290
|
-
}
|
|
291
|
-
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
|
|
292
|
-
|
|
271
|
+
}
|
|
293
272
|
|
|
273
|
+
// Be forgiving, per 25.3.3.3.3 of the spec:
|
|
274
|
+
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
|
|
294
275
|
return doneResult();
|
|
295
276
|
}
|
|
296
|
-
|
|
297
277
|
context.method = method;
|
|
298
278
|
context.arg = arg;
|
|
299
|
-
|
|
300
279
|
while (true) {
|
|
301
280
|
var delegate = context.delegate;
|
|
302
|
-
|
|
303
281
|
if (delegate) {
|
|
304
282
|
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
305
|
-
|
|
306
283
|
if (delegateResult) {
|
|
307
284
|
if (delegateResult === ContinueSentinel) continue;
|
|
308
285
|
return delegateResult;
|
|
309
286
|
}
|
|
310
287
|
}
|
|
311
|
-
|
|
312
288
|
if (context.method === "next") {
|
|
313
289
|
// Setting context._sent for legacy support of Babel's
|
|
314
290
|
// function.sent implementation.
|
|
@@ -318,51 +294,44 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
318
294
|
state = GenStateCompleted;
|
|
319
295
|
throw context.arg;
|
|
320
296
|
}
|
|
321
|
-
|
|
322
297
|
context.dispatchException(context.arg);
|
|
323
298
|
} else if (context.method === "return") {
|
|
324
299
|
context.abrupt("return", context.arg);
|
|
325
300
|
}
|
|
326
|
-
|
|
327
301
|
state = GenStateExecuting;
|
|
328
302
|
var record = tryCatch(innerFn, self, context);
|
|
329
|
-
|
|
330
303
|
if (record.type === "normal") {
|
|
331
304
|
// If an exception is thrown from innerFn, we leave state ===
|
|
332
305
|
// GenStateExecuting and loop back for another invocation.
|
|
333
306
|
state = context.done ? GenStateCompleted : GenStateSuspendedYield;
|
|
334
|
-
|
|
335
307
|
if (record.arg === ContinueSentinel) {
|
|
336
308
|
continue;
|
|
337
309
|
}
|
|
338
|
-
|
|
339
310
|
return {
|
|
340
311
|
value: record.arg,
|
|
341
312
|
done: context.done
|
|
342
313
|
};
|
|
343
314
|
} else if (record.type === "throw") {
|
|
344
|
-
state = GenStateCompleted;
|
|
315
|
+
state = GenStateCompleted;
|
|
316
|
+
// Dispatch the exception by looping back around to the
|
|
345
317
|
// context.dispatchException(context.arg) call above.
|
|
346
|
-
|
|
347
318
|
context.method = "throw";
|
|
348
319
|
context.arg = record.arg;
|
|
349
320
|
}
|
|
350
321
|
}
|
|
351
322
|
};
|
|
352
|
-
}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// Call delegate.iterator[context.method](context.arg) and handle the
|
|
353
326
|
// result, either by returning a { value, done } result from the
|
|
354
327
|
// delegate iterator, or by modifying context.method and context.arg,
|
|
355
328
|
// setting context.delegate to null, and returning the ContinueSentinel.
|
|
356
|
-
|
|
357
|
-
|
|
358
329
|
function maybeInvokeDelegate(delegate, context) {
|
|
359
330
|
var method = delegate.iterator[context.method];
|
|
360
|
-
|
|
361
331
|
if (method === undefined$1) {
|
|
362
332
|
// A .throw or .return when the delegate iterator has no .throw
|
|
363
333
|
// method always terminates the yield* loop.
|
|
364
334
|
context.delegate = null;
|
|
365
|
-
|
|
366
335
|
if (context.method === "throw") {
|
|
367
336
|
// Note: ["return"] must be used for ES3 parsing compatibility.
|
|
368
337
|
if (delegate.iterator["return"]) {
|
|
@@ -371,51 +340,45 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
371
340
|
context.method = "return";
|
|
372
341
|
context.arg = undefined$1;
|
|
373
342
|
maybeInvokeDelegate(delegate, context);
|
|
374
|
-
|
|
375
343
|
if (context.method === "throw") {
|
|
376
344
|
// If maybeInvokeDelegate(context) changed context.method from
|
|
377
345
|
// "return" to "throw", let that override the TypeError below.
|
|
378
346
|
return ContinueSentinel;
|
|
379
347
|
}
|
|
380
348
|
}
|
|
381
|
-
|
|
382
349
|
context.method = "throw";
|
|
383
350
|
context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
|
384
351
|
}
|
|
385
|
-
|
|
386
352
|
return ContinueSentinel;
|
|
387
353
|
}
|
|
388
|
-
|
|
389
354
|
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
390
|
-
|
|
391
355
|
if (record.type === "throw") {
|
|
392
356
|
context.method = "throw";
|
|
393
357
|
context.arg = record.arg;
|
|
394
358
|
context.delegate = null;
|
|
395
359
|
return ContinueSentinel;
|
|
396
360
|
}
|
|
397
|
-
|
|
398
361
|
var info = record.arg;
|
|
399
|
-
|
|
400
362
|
if (!info) {
|
|
401
363
|
context.method = "throw";
|
|
402
364
|
context.arg = new TypeError("iterator result is not an object");
|
|
403
365
|
context.delegate = null;
|
|
404
366
|
return ContinueSentinel;
|
|
405
367
|
}
|
|
406
|
-
|
|
407
368
|
if (info.done) {
|
|
408
369
|
// Assign the result of the finished delegate to the temporary
|
|
409
370
|
// variable specified by delegate.resultName (see delegateYield).
|
|
410
|
-
context[delegate.resultName] = info.value;
|
|
371
|
+
context[delegate.resultName] = info.value;
|
|
372
|
+
|
|
373
|
+
// Resume execution at the desired location (see delegateYield).
|
|
374
|
+
context.next = delegate.nextLoc;
|
|
411
375
|
|
|
412
|
-
|
|
376
|
+
// If context.method was "throw" but the delegate handled the
|
|
413
377
|
// exception, let the outer generator proceed normally. If
|
|
414
378
|
// context.method was "next", forget context.arg since it has been
|
|
415
379
|
// "consumed" by the delegate iterator. If context.method was
|
|
416
380
|
// "return", allow the original .return call to continue in the
|
|
417
381
|
// outer generator.
|
|
418
|
-
|
|
419
382
|
if (context.method !== "return") {
|
|
420
383
|
context.method = "next";
|
|
421
384
|
context.arg = undefined$1;
|
|
@@ -423,54 +386,49 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
423
386
|
} else {
|
|
424
387
|
// Re-yield the result returned by the delegate method.
|
|
425
388
|
return info;
|
|
426
|
-
}
|
|
427
|
-
// the outer generator.
|
|
428
|
-
|
|
389
|
+
}
|
|
429
390
|
|
|
391
|
+
// The delegate iterator is finished, so forget it and continue with
|
|
392
|
+
// the outer generator.
|
|
430
393
|
context.delegate = null;
|
|
431
394
|
return ContinueSentinel;
|
|
432
|
-
}
|
|
433
|
-
// unified ._invoke helper method.
|
|
434
|
-
|
|
395
|
+
}
|
|
435
396
|
|
|
397
|
+
// Define Generator.prototype.{next,throw,return} in terms of the
|
|
398
|
+
// unified ._invoke helper method.
|
|
436
399
|
defineIteratorMethods(Gp);
|
|
437
|
-
define(Gp, toStringTagSymbol, "Generator");
|
|
400
|
+
define(Gp, toStringTagSymbol, "Generator");
|
|
401
|
+
|
|
402
|
+
// A Generator should always return itself as the iterator object when the
|
|
438
403
|
// @@iterator function is called on it. Some browsers' implementations of the
|
|
439
404
|
// iterator prototype chain incorrectly implement this, causing the Generator
|
|
440
405
|
// object to not be returned from this call. This ensures that doesn't happen.
|
|
441
406
|
// See https://github.com/facebook/regenerator/issues/274 for more details.
|
|
442
|
-
|
|
443
407
|
define(Gp, iteratorSymbol, function () {
|
|
444
408
|
return this;
|
|
445
409
|
});
|
|
446
410
|
define(Gp, "toString", function () {
|
|
447
411
|
return "[object Generator]";
|
|
448
412
|
});
|
|
449
|
-
|
|
450
413
|
function pushTryEntry(locs) {
|
|
451
414
|
var entry = {
|
|
452
415
|
tryLoc: locs[0]
|
|
453
416
|
};
|
|
454
|
-
|
|
455
417
|
if (1 in locs) {
|
|
456
418
|
entry.catchLoc = locs[1];
|
|
457
419
|
}
|
|
458
|
-
|
|
459
420
|
if (2 in locs) {
|
|
460
421
|
entry.finallyLoc = locs[2];
|
|
461
422
|
entry.afterLoc = locs[3];
|
|
462
423
|
}
|
|
463
|
-
|
|
464
424
|
this.tryEntries.push(entry);
|
|
465
425
|
}
|
|
466
|
-
|
|
467
426
|
function resetTryEntry(entry) {
|
|
468
427
|
var record = entry.completion || {};
|
|
469
428
|
record.type = "normal";
|
|
470
429
|
delete record.arg;
|
|
471
430
|
entry.completion = record;
|
|
472
431
|
}
|
|
473
|
-
|
|
474
432
|
function Context(tryLocsList) {
|
|
475
433
|
// The root entry object (effectively a try statement without a catch
|
|
476
434
|
// or a finally block) gives us a place to store values thrown from
|
|
@@ -481,97 +439,84 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
481
439
|
tryLocsList.forEach(pushTryEntry, this);
|
|
482
440
|
this.reset(true);
|
|
483
441
|
}
|
|
484
|
-
|
|
485
442
|
exports.keys = function (object) {
|
|
486
443
|
var keys = [];
|
|
487
|
-
|
|
488
444
|
for (var key in object) {
|
|
489
445
|
keys.push(key);
|
|
490
446
|
}
|
|
447
|
+
keys.reverse();
|
|
491
448
|
|
|
492
|
-
|
|
449
|
+
// Rather than returning an object with a next method, we keep
|
|
493
450
|
// things simple and return the next function itself.
|
|
494
|
-
|
|
495
451
|
return function next() {
|
|
496
452
|
while (keys.length) {
|
|
497
453
|
var key = keys.pop();
|
|
498
|
-
|
|
499
454
|
if (key in object) {
|
|
500
455
|
next.value = key;
|
|
501
456
|
next.done = false;
|
|
502
457
|
return next;
|
|
503
458
|
}
|
|
504
|
-
}
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
// To avoid creating an additional object, we just hang the .value
|
|
505
462
|
// and .done properties off the next function object itself. This
|
|
506
463
|
// also ensures that the minifier will not anonymize the function.
|
|
507
|
-
|
|
508
|
-
|
|
509
464
|
next.done = true;
|
|
510
465
|
return next;
|
|
511
466
|
};
|
|
512
467
|
};
|
|
513
|
-
|
|
514
468
|
function values(iterable) {
|
|
515
469
|
if (iterable) {
|
|
516
470
|
var iteratorMethod = iterable[iteratorSymbol];
|
|
517
|
-
|
|
518
471
|
if (iteratorMethod) {
|
|
519
472
|
return iteratorMethod.call(iterable);
|
|
520
473
|
}
|
|
521
|
-
|
|
522
474
|
if (typeof iterable.next === "function") {
|
|
523
475
|
return iterable;
|
|
524
476
|
}
|
|
525
|
-
|
|
526
477
|
if (!isNaN(iterable.length)) {
|
|
527
478
|
var i = -1,
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
479
|
+
next = function next() {
|
|
480
|
+
while (++i < iterable.length) {
|
|
481
|
+
if (hasOwn.call(iterable, i)) {
|
|
482
|
+
next.value = iterable[i];
|
|
483
|
+
next.done = false;
|
|
484
|
+
return next;
|
|
485
|
+
}
|
|
534
486
|
}
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
return next;
|
|
540
|
-
};
|
|
541
|
-
|
|
487
|
+
next.value = undefined$1;
|
|
488
|
+
next.done = true;
|
|
489
|
+
return next;
|
|
490
|
+
};
|
|
542
491
|
return next.next = next;
|
|
543
492
|
}
|
|
544
|
-
}
|
|
545
|
-
|
|
493
|
+
}
|
|
546
494
|
|
|
495
|
+
// Return an iterator with no values.
|
|
547
496
|
return {
|
|
548
497
|
next: doneResult
|
|
549
498
|
};
|
|
550
499
|
}
|
|
551
|
-
|
|
552
500
|
exports.values = values;
|
|
553
|
-
|
|
554
501
|
function doneResult() {
|
|
555
502
|
return {
|
|
556
503
|
value: undefined$1,
|
|
557
504
|
done: true
|
|
558
505
|
};
|
|
559
506
|
}
|
|
560
|
-
|
|
561
507
|
Context.prototype = {
|
|
562
508
|
constructor: Context,
|
|
563
509
|
reset: function reset(skipTempReset) {
|
|
564
510
|
this.prev = 0;
|
|
565
|
-
this.next = 0;
|
|
511
|
+
this.next = 0;
|
|
512
|
+
// Resetting context._sent for legacy support of Babel's
|
|
566
513
|
// function.sent implementation.
|
|
567
|
-
|
|
568
514
|
this.sent = this._sent = undefined$1;
|
|
569
515
|
this.done = false;
|
|
570
516
|
this.delegate = null;
|
|
571
517
|
this.method = "next";
|
|
572
518
|
this.arg = undefined$1;
|
|
573
519
|
this.tryEntries.forEach(resetTryEntry);
|
|
574
|
-
|
|
575
520
|
if (!skipTempReset) {
|
|
576
521
|
for (var name in this) {
|
|
577
522
|
// Not sure about the optimal order of these conditions:
|
|
@@ -585,50 +530,40 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
585
530
|
this.done = true;
|
|
586
531
|
var rootEntry = this.tryEntries[0];
|
|
587
532
|
var rootRecord = rootEntry.completion;
|
|
588
|
-
|
|
589
533
|
if (rootRecord.type === "throw") {
|
|
590
534
|
throw rootRecord.arg;
|
|
591
535
|
}
|
|
592
|
-
|
|
593
536
|
return this.rval;
|
|
594
537
|
},
|
|
595
538
|
dispatchException: function dispatchException(exception) {
|
|
596
539
|
if (this.done) {
|
|
597
540
|
throw exception;
|
|
598
541
|
}
|
|
599
|
-
|
|
600
542
|
var context = this;
|
|
601
|
-
|
|
602
543
|
function handle(loc, caught) {
|
|
603
544
|
record.type = "throw";
|
|
604
545
|
record.arg = exception;
|
|
605
546
|
context.next = loc;
|
|
606
|
-
|
|
607
547
|
if (caught) {
|
|
608
548
|
// If the dispatched exception was caught by a catch block,
|
|
609
549
|
// then let that catch block handle the exception normally.
|
|
610
550
|
context.method = "next";
|
|
611
551
|
context.arg = undefined$1;
|
|
612
552
|
}
|
|
613
|
-
|
|
614
553
|
return !!caught;
|
|
615
554
|
}
|
|
616
|
-
|
|
617
555
|
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
618
556
|
var entry = this.tryEntries[i];
|
|
619
557
|
var record = entry.completion;
|
|
620
|
-
|
|
621
558
|
if (entry.tryLoc === "root") {
|
|
622
559
|
// Exception thrown outside of any try block that could handle
|
|
623
560
|
// it, so set the completion value of the entire function to
|
|
624
561
|
// throw the exception.
|
|
625
562
|
return handle("end");
|
|
626
563
|
}
|
|
627
|
-
|
|
628
564
|
if (entry.tryLoc <= this.prev) {
|
|
629
565
|
var hasCatch = hasOwn.call(entry, "catchLoc");
|
|
630
566
|
var hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
631
|
-
|
|
632
567
|
if (hasCatch && hasFinally) {
|
|
633
568
|
if (this.prev < entry.catchLoc) {
|
|
634
569
|
return handle(entry.catchLoc, true);
|
|
@@ -652,36 +587,30 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
652
587
|
abrupt: function abrupt(type, arg) {
|
|
653
588
|
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
654
589
|
var entry = this.tryEntries[i];
|
|
655
|
-
|
|
656
590
|
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
|
657
591
|
var finallyEntry = entry;
|
|
658
592
|
break;
|
|
659
593
|
}
|
|
660
594
|
}
|
|
661
|
-
|
|
662
595
|
if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
|
|
663
596
|
// Ignore the finally entry if control is not jumping to a
|
|
664
597
|
// location outside the try/catch block.
|
|
665
598
|
finallyEntry = null;
|
|
666
599
|
}
|
|
667
|
-
|
|
668
600
|
var record = finallyEntry ? finallyEntry.completion : {};
|
|
669
601
|
record.type = type;
|
|
670
602
|
record.arg = arg;
|
|
671
|
-
|
|
672
603
|
if (finallyEntry) {
|
|
673
604
|
this.method = "next";
|
|
674
605
|
this.next = finallyEntry.finallyLoc;
|
|
675
606
|
return ContinueSentinel;
|
|
676
607
|
}
|
|
677
|
-
|
|
678
608
|
return this.complete(record);
|
|
679
609
|
},
|
|
680
610
|
complete: function complete(record, afterLoc) {
|
|
681
611
|
if (record.type === "throw") {
|
|
682
612
|
throw record.arg;
|
|
683
613
|
}
|
|
684
|
-
|
|
685
614
|
if (record.type === "break" || record.type === "continue") {
|
|
686
615
|
this.next = record.arg;
|
|
687
616
|
} else if (record.type === "return") {
|
|
@@ -691,13 +620,11 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
691
620
|
} else if (record.type === "normal" && afterLoc) {
|
|
692
621
|
this.next = afterLoc;
|
|
693
622
|
}
|
|
694
|
-
|
|
695
623
|
return ContinueSentinel;
|
|
696
624
|
},
|
|
697
625
|
finish: function finish(finallyLoc) {
|
|
698
626
|
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
699
627
|
var entry = this.tryEntries[i];
|
|
700
|
-
|
|
701
628
|
if (entry.finallyLoc === finallyLoc) {
|
|
702
629
|
this.complete(entry.completion, entry.afterLoc);
|
|
703
630
|
resetTryEntry(entry);
|
|
@@ -708,21 +635,18 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
708
635
|
"catch": function _catch(tryLoc) {
|
|
709
636
|
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
710
637
|
var entry = this.tryEntries[i];
|
|
711
|
-
|
|
712
638
|
if (entry.tryLoc === tryLoc) {
|
|
713
639
|
var record = entry.completion;
|
|
714
|
-
|
|
715
640
|
if (record.type === "throw") {
|
|
716
641
|
var thrown = record.arg;
|
|
717
642
|
resetTryEntry(entry);
|
|
718
643
|
}
|
|
719
|
-
|
|
720
644
|
return thrown;
|
|
721
645
|
}
|
|
722
|
-
}
|
|
723
|
-
// argument that corresponds to a known catch block.
|
|
724
|
-
|
|
646
|
+
}
|
|
725
647
|
|
|
648
|
+
// The context.catch method must only be called with a location
|
|
649
|
+
// argument that corresponds to a known catch block.
|
|
726
650
|
throw new Error("illegal catch attempt");
|
|
727
651
|
},
|
|
728
652
|
delegateYield: function delegateYield(iterable, resultName, nextLoc) {
|
|
@@ -731,27 +655,26 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
731
655
|
resultName: resultName,
|
|
732
656
|
nextLoc: nextLoc
|
|
733
657
|
};
|
|
734
|
-
|
|
735
658
|
if (this.method === "next") {
|
|
736
659
|
// Deliberately forget the last sent value so that we don't
|
|
737
660
|
// accidentally pass it on to the delegate.
|
|
738
661
|
this.arg = undefined$1;
|
|
739
662
|
}
|
|
740
|
-
|
|
741
663
|
return ContinueSentinel;
|
|
742
664
|
}
|
|
743
|
-
};
|
|
665
|
+
};
|
|
666
|
+
|
|
667
|
+
// Regardless of whether this script is executing as a CommonJS module
|
|
744
668
|
// or not, return the runtime object so that we can declare the variable
|
|
745
669
|
// regeneratorRuntime in the outer scope, which allows this module to be
|
|
746
670
|
// injected easily by `bin/regenerator --include-runtime script.js`.
|
|
747
|
-
|
|
748
671
|
return exports;
|
|
749
|
-
}(
|
|
672
|
+
}(
|
|
673
|
+
// If this script is executing as a CommonJS module, use module.exports
|
|
750
674
|
// as the regeneratorRuntime namespace. Otherwise create a new empty
|
|
751
675
|
// object. Either way, the resulting object will be used to initialize
|
|
752
676
|
// the regeneratorRuntime variable at the top of this file.
|
|
753
677
|
module.exports );
|
|
754
|
-
|
|
755
678
|
try {
|
|
756
679
|
regeneratorRuntime = runtime;
|
|
757
680
|
} catch (accidentalStrictMode) {
|
|
@@ -773,6 +696,23 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
773
696
|
}
|
|
774
697
|
});
|
|
775
698
|
|
|
699
|
+
var searchParameters = [{
|
|
700
|
+
value: "[lt]",
|
|
701
|
+
label: 'Less than'
|
|
702
|
+
}, {
|
|
703
|
+
value: "[lte]",
|
|
704
|
+
label: 'Less than or equal'
|
|
705
|
+
}, {
|
|
706
|
+
value: "[gt]",
|
|
707
|
+
label: 'Greater than'
|
|
708
|
+
}, {
|
|
709
|
+
value: "[gte]",
|
|
710
|
+
label: 'Greater than or equal '
|
|
711
|
+
}];
|
|
712
|
+
var uniq = function uniq(xs) {
|
|
713
|
+
return Array.from(new Set(xs));
|
|
714
|
+
};
|
|
715
|
+
|
|
776
716
|
function ensure(x) {
|
|
777
717
|
if (x === null || x === undefined) {
|
|
778
718
|
debugger;
|
|
@@ -782,11 +722,9 @@ function ensure(x) {
|
|
|
782
722
|
}
|
|
783
723
|
}
|
|
784
724
|
var modulePath = "@plasmicpkgs/plasmic-contentful";
|
|
785
|
-
|
|
786
725
|
var makeDataProviderName = function makeDataProviderName(contentType) {
|
|
787
726
|
return "currentContentful" + pascalCase(contentType) + "Item";
|
|
788
727
|
};
|
|
789
|
-
|
|
790
728
|
var CredentialsContext = /*#__PURE__*/React.createContext(undefined);
|
|
791
729
|
var ContentfulCredentialsProviderMeta = {
|
|
792
730
|
name: "Contentful CredentialsProvider",
|
|
@@ -816,9 +754,9 @@ var ContentfulCredentialsProviderMeta = {
|
|
|
816
754
|
};
|
|
817
755
|
function ContentfulCredentialsProvider(_ref) {
|
|
818
756
|
var accessToken = _ref.accessToken,
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
757
|
+
space = _ref.space,
|
|
758
|
+
environment = _ref.environment,
|
|
759
|
+
children = _ref.children;
|
|
822
760
|
return React.createElement(CredentialsContext.Provider, {
|
|
823
761
|
value: {
|
|
824
762
|
space: space,
|
|
@@ -860,10 +798,8 @@ var ContentfulFetcherMeta = {
|
|
|
860
798
|
type: "choice",
|
|
861
799
|
options: function options(props, ctx) {
|
|
862
800
|
var _ctx$types$map, _ctx$types;
|
|
863
|
-
|
|
864
801
|
return (_ctx$types$map = ctx == null ? void 0 : (_ctx$types = ctx.types) == null ? void 0 : _ctx$types.map(function (type) {
|
|
865
802
|
var _type$sys;
|
|
866
|
-
|
|
867
803
|
return {
|
|
868
804
|
label: type == null ? void 0 : type.name,
|
|
869
805
|
value: type == null ? void 0 : (_type$sys = type.sys) == null ? void 0 : _type$sys.id
|
|
@@ -873,34 +809,48 @@ var ContentfulFetcherMeta = {
|
|
|
873
809
|
displayName: "Content type",
|
|
874
810
|
description: "Content type to be queried."
|
|
875
811
|
},
|
|
876
|
-
|
|
812
|
+
filterField: {
|
|
877
813
|
type: "choice",
|
|
814
|
+
displayName: "Filter field",
|
|
815
|
+
description: "Field (from Collection) to filter by",
|
|
878
816
|
options: function options(props, ctx) {
|
|
879
|
-
var _ctx$
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
817
|
+
var _ctx$fields;
|
|
818
|
+
return (_ctx$fields = ctx == null ? void 0 : ctx.fields) != null ? _ctx$fields : [];
|
|
819
|
+
},
|
|
820
|
+
hidden: function hidden(props, ctx) {
|
|
821
|
+
return !props.contentType;
|
|
822
|
+
}
|
|
823
|
+
},
|
|
824
|
+
searchParameter: {
|
|
825
|
+
type: "choice",
|
|
826
|
+
displayName: "Search Parameter",
|
|
827
|
+
description: "Search Parameter to filter by.Read more (https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/search-parameters/)",
|
|
828
|
+
options: function options(props, ctx) {
|
|
829
|
+
var _ctx$queryOptions;
|
|
830
|
+
return (_ctx$queryOptions = ctx == null ? void 0 : ctx.queryOptions) != null ? _ctx$queryOptions : [];
|
|
889
831
|
},
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
832
|
+
hidden: function hidden(props, ctx) {
|
|
833
|
+
return !props.filterField;
|
|
834
|
+
}
|
|
835
|
+
},
|
|
836
|
+
filterValue: {
|
|
837
|
+
type: "string",
|
|
838
|
+
displayName: "Filter value",
|
|
839
|
+
description: "Value to filter by, should be of filter field type",
|
|
840
|
+
hidden: function hidden(props, ctx) {
|
|
841
|
+
return !props.searchParameter;
|
|
842
|
+
}
|
|
893
843
|
},
|
|
894
844
|
limit: {
|
|
895
845
|
type: "number",
|
|
896
846
|
displayName: "Limit",
|
|
897
|
-
description: "Limit the number of entries that are returned."
|
|
898
|
-
defaultValue: 1000
|
|
847
|
+
description: "Limit the number of entries that are returned."
|
|
899
848
|
},
|
|
900
|
-
|
|
901
|
-
type: "
|
|
902
|
-
displayName: "
|
|
903
|
-
description: "
|
|
849
|
+
noAutoRepeat: {
|
|
850
|
+
type: "boolean",
|
|
851
|
+
displayName: "No auto-repeat",
|
|
852
|
+
description: "Do not automatically repeat children for every entry.",
|
|
853
|
+
defaultValue: false
|
|
904
854
|
},
|
|
905
855
|
noLayout: {
|
|
906
856
|
type: "boolean",
|
|
@@ -911,144 +861,149 @@ var ContentfulFetcherMeta = {
|
|
|
911
861
|
}
|
|
912
862
|
};
|
|
913
863
|
function ContentfulFetcher(_ref2) {
|
|
914
|
-
var
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
864
|
+
var _contentTypes$items, _operators, _contentTypes$items2;
|
|
865
|
+
var filterField = _ref2.filterField,
|
|
866
|
+
filterValue = _ref2.filterValue,
|
|
867
|
+
searchParameter = _ref2.searchParameter,
|
|
868
|
+
noAutoRepeat = _ref2.noAutoRepeat,
|
|
869
|
+
contentType = _ref2.contentType,
|
|
870
|
+
children = _ref2.children,
|
|
871
|
+
className = _ref2.className,
|
|
872
|
+
limit = _ref2.limit,
|
|
873
|
+
noLayout = _ref2.noLayout,
|
|
874
|
+
setControlContextData = _ref2.setControlContextData;
|
|
922
875
|
var creds = ensure(useContext(CredentialsContext));
|
|
923
876
|
var cacheKey = JSON.stringify({
|
|
877
|
+
limit: limit,
|
|
878
|
+
filterField: filterField,
|
|
879
|
+
filterValue: filterValue,
|
|
880
|
+
searchParameter: searchParameter,
|
|
924
881
|
creds: creds
|
|
925
882
|
});
|
|
926
|
-
var
|
|
927
|
-
space: creds.space,
|
|
928
|
-
accessToken: creds.accessToken
|
|
929
|
-
});
|
|
930
|
-
|
|
883
|
+
var baseUrl = "https://cdn.contentful.com";
|
|
931
884
|
var _usePlasmicQueryData = usePlasmicQueryData(cacheKey + "/contentTypes", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
return _context.stop();
|
|
947
|
-
}
|
|
948
|
-
}
|
|
949
|
-
}, _callee);
|
|
950
|
-
}))),
|
|
951
|
-
contentTypes = _usePlasmicQueryData.data,
|
|
952
|
-
contentTypesError = _usePlasmicQueryData.error;
|
|
953
|
-
|
|
954
|
-
var _usePlasmicQueryData2 = usePlasmicQueryData(contentType ? cacheKey + "/" + contentType + "/entriesData/" + limit + "/" + order : null, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
|
|
955
|
-
var response;
|
|
956
|
-
return runtime_1.wrap(function _callee2$(_context2) {
|
|
957
|
-
while (1) {
|
|
958
|
-
switch (_context2.prev = _context2.next) {
|
|
959
|
-
case 0:
|
|
960
|
-
_context2.next = 2;
|
|
961
|
-
return client.getEntries({
|
|
962
|
-
content_type: "" + (contentType == null ? void 0 : contentType.toString()),
|
|
963
|
-
limit: limit,
|
|
964
|
-
order: order
|
|
965
|
-
});
|
|
966
|
-
|
|
967
|
-
case 2:
|
|
968
|
-
response = _context2.sent;
|
|
969
|
-
return _context2.abrupt("return", response);
|
|
970
|
-
|
|
971
|
-
case 4:
|
|
972
|
-
case "end":
|
|
973
|
-
return _context2.stop();
|
|
974
|
-
}
|
|
975
|
-
}
|
|
976
|
-
}, _callee2);
|
|
977
|
-
}))),
|
|
978
|
-
entriesData = _usePlasmicQueryData2.data,
|
|
979
|
-
entriesDataError = _usePlasmicQueryData2.error;
|
|
980
|
-
|
|
981
|
-
var _usePlasmicQueryData3 = usePlasmicQueryData(entryID ? cacheKey + "/entry/" + entryID : null, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3() {
|
|
982
|
-
var response;
|
|
983
|
-
return runtime_1.wrap(function _callee3$(_context3) {
|
|
984
|
-
while (1) {
|
|
985
|
-
switch (_context3.prev = _context3.next) {
|
|
986
|
-
case 0:
|
|
987
|
-
_context3.next = 2;
|
|
988
|
-
return client.getEntry("" + entryID);
|
|
989
|
-
|
|
990
|
-
case 2:
|
|
991
|
-
response = _context3.sent;
|
|
992
|
-
return _context3.abrupt("return", response);
|
|
993
|
-
|
|
994
|
-
case 4:
|
|
995
|
-
case "end":
|
|
996
|
-
return _context3.stop();
|
|
885
|
+
var resp;
|
|
886
|
+
return runtime_1.wrap(function _callee$(_context) {
|
|
887
|
+
while (1) {
|
|
888
|
+
switch (_context.prev = _context.next) {
|
|
889
|
+
case 0:
|
|
890
|
+
_context.next = 2;
|
|
891
|
+
return fetch(baseUrl + "/spaces/" + creds.space + "/environments/" + creds.environment + "/content_types?access_token=" + creds.accessToken);
|
|
892
|
+
case 2:
|
|
893
|
+
resp = _context.sent;
|
|
894
|
+
return _context.abrupt("return", resp.json());
|
|
895
|
+
case 4:
|
|
896
|
+
case "end":
|
|
897
|
+
return _context.stop();
|
|
898
|
+
}
|
|
997
899
|
}
|
|
998
|
-
}
|
|
999
|
-
},
|
|
1000
|
-
|
|
1001
|
-
entryData = _usePlasmicQueryData3.data,
|
|
1002
|
-
entryDataError = _usePlasmicQueryData3.error;
|
|
1003
|
-
|
|
900
|
+
}, _callee);
|
|
901
|
+
}))),
|
|
902
|
+
contentTypes = _usePlasmicQueryData.data;
|
|
1004
903
|
setControlContextData == null ? void 0 : setControlContextData({
|
|
1005
|
-
types: contentTypes == null ? void 0 : contentTypes.items
|
|
1006
|
-
entries: entriesData == null ? void 0 : entriesData.items
|
|
904
|
+
types: (_contentTypes$items = contentTypes == null ? void 0 : contentTypes.items) != null ? _contentTypes$items : []
|
|
1007
905
|
});
|
|
1008
|
-
|
|
906
|
+
var _usePlasmicQueryData2 = usePlasmicQueryData(contentType ? cacheKey + "/" + contentType + "/entriesData" : null, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
|
|
907
|
+
var url, query, resp;
|
|
908
|
+
return runtime_1.wrap(function _callee2$(_context2) {
|
|
909
|
+
while (1) {
|
|
910
|
+
switch (_context2.prev = _context2.next) {
|
|
911
|
+
case 0:
|
|
912
|
+
url = "/spaces/" + creds.space + "/environments/" + creds.environment + "/entries?access_token=" + creds.accessToken + "&content_type=" + contentType;
|
|
913
|
+
if (limit) {
|
|
914
|
+
query = url + "&limit=" + limit;
|
|
915
|
+
} else {
|
|
916
|
+
query = url;
|
|
917
|
+
}
|
|
918
|
+
_context2.next = 4;
|
|
919
|
+
return fetch("" + baseUrl + query);
|
|
920
|
+
case 4:
|
|
921
|
+
resp = _context2.sent;
|
|
922
|
+
return _context2.abrupt("return", resp.json());
|
|
923
|
+
case 6:
|
|
924
|
+
case "end":
|
|
925
|
+
return _context2.stop();
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
}, _callee2);
|
|
929
|
+
}))),
|
|
930
|
+
entriesData = _usePlasmicQueryData2.data;
|
|
931
|
+
var _usePlasmicQueryData3 = usePlasmicQueryData(contentType && filterField && filterValue ? cacheKey + "/" + contentType + "/filteredData" : null, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3() {
|
|
932
|
+
var queryPath, resp;
|
|
933
|
+
return runtime_1.wrap(function _callee3$(_context3) {
|
|
934
|
+
while (1) {
|
|
935
|
+
switch (_context3.prev = _context3.next) {
|
|
936
|
+
case 0:
|
|
937
|
+
queryPath = "/spaces/" + creds.space + "/environments/" + creds.environment + "/entries?access_token=" + creds.accessToken + "&content_type=" + contentType + "&fields." + filterField + searchParameter + "=" + filterValue;
|
|
938
|
+
_context3.next = 3;
|
|
939
|
+
return fetch("" + baseUrl + queryPath);
|
|
940
|
+
case 3:
|
|
941
|
+
resp = _context3.sent;
|
|
942
|
+
return _context3.abrupt("return", resp.json());
|
|
943
|
+
case 5:
|
|
944
|
+
case "end":
|
|
945
|
+
return _context3.stop();
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
}, _callee3);
|
|
949
|
+
}))),
|
|
950
|
+
filteredData = _usePlasmicQueryData3.data;
|
|
1009
951
|
if (!creds.space || !creds.accessToken) {
|
|
1010
952
|
return React.createElement("div", null, "Please specify a valid API Credentials: Space, Access Token and Environment");
|
|
1011
953
|
}
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
}
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
954
|
+
if (!contentTypes) {
|
|
955
|
+
return React.createElement("div", null, "Please configure the ContentStack credentials");
|
|
956
|
+
}
|
|
957
|
+
if (!entriesData) {
|
|
958
|
+
return React.createElement("div", null, "Please select a content type");
|
|
959
|
+
}
|
|
960
|
+
var filterFields = entriesData == null ? void 0 : entriesData.items.flatMap(function (item) {
|
|
961
|
+
var fields = Object.keys(item.fields).filter(function (field) {
|
|
962
|
+
var value = get(item, field);
|
|
963
|
+
return typeof value !== "object" && field !== "photos";
|
|
964
|
+
});
|
|
965
|
+
return fields;
|
|
966
|
+
});
|
|
967
|
+
var operators;
|
|
968
|
+
var matchedFields = Object.values(entriesData.items).map(function (item) {
|
|
969
|
+
var fields = Object.entries(item.fields).find(function (el) {
|
|
970
|
+
return el[0] === filterField;
|
|
971
|
+
});
|
|
972
|
+
return fields;
|
|
973
|
+
});
|
|
974
|
+
Object.values(matchedFields).map(function (model) {
|
|
975
|
+
return Array.isArray(model) ? model : [model];
|
|
976
|
+
}).map(function (item) {
|
|
977
|
+
if (typeof item[1] === "number" && typeof item[1] !== "object") {
|
|
978
|
+
operators = searchParameters;
|
|
979
|
+
} else if (typeof item[1] !== "number" && typeof item[1] !== "object" && typeof item[1] === "string") {
|
|
980
|
+
operators = [{
|
|
981
|
+
value: "[match]",
|
|
982
|
+
label: "Full text search"
|
|
983
|
+
}];
|
|
1026
984
|
}
|
|
985
|
+
});
|
|
986
|
+
setControlContextData == null ? void 0 : setControlContextData({
|
|
987
|
+
queryOptions: (_operators = operators) != null ? _operators : [],
|
|
988
|
+
types: (_contentTypes$items2 = contentTypes == null ? void 0 : contentTypes.items) != null ? _contentTypes$items2 : [],
|
|
989
|
+
fields: uniq(filterFields != null ? filterFields : [])
|
|
990
|
+
});
|
|
991
|
+
if (filterField && !searchParameter) {
|
|
992
|
+
return React.createElement("div", null, "Please specify a Search Parameter");
|
|
993
|
+
}
|
|
994
|
+
if (searchParameter && !filterValue) {
|
|
995
|
+
return React.createElement("div", null, "Please specify a Filter value");
|
|
1027
996
|
}
|
|
1028
|
-
|
|
1029
997
|
var renderedData;
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
name: "contentfulItem",
|
|
1034
|
-
data: entryData,
|
|
1035
|
-
hidden: true
|
|
1036
|
-
}, React.createElement(DataProvider, {
|
|
1037
|
-
name: makeDataProviderName(contentType),
|
|
1038
|
-
data: entryData
|
|
1039
|
-
}, children));
|
|
1040
|
-
} else if (contentType) {
|
|
1041
|
-
var _entriesData$items, _entriesData$items2;
|
|
1042
|
-
|
|
1043
|
-
if ((entriesData == null ? void 0 : (_entriesData$items = entriesData.items) == null ? void 0 : _entriesData$items.length) === 0) {
|
|
998
|
+
if (filteredData) {
|
|
999
|
+
var _filteredData$items, _filteredData$items2;
|
|
1000
|
+
if ((filteredData == null ? void 0 : (_filteredData$items = filteredData.items) == null ? void 0 : _filteredData$items.length) === 0) {
|
|
1044
1001
|
return React.createElement("div", {
|
|
1045
1002
|
className: className
|
|
1046
|
-
},
|
|
1003
|
+
}, "No published entry found");
|
|
1047
1004
|
}
|
|
1048
|
-
|
|
1049
|
-
renderedData = entriesData == null ? void 0 : (_entriesData$items2 = entriesData.items) == null ? void 0 : _entriesData$items2.map(function (item, index) {
|
|
1005
|
+
renderedData = noAutoRepeat ? children : filteredData == null ? void 0 : (_filteredData$items2 = filteredData.items) == null ? void 0 : _filteredData$items2.map(function (item, index) {
|
|
1050
1006
|
var _item$sys;
|
|
1051
|
-
|
|
1052
1007
|
return React.createElement(DataProvider, {
|
|
1053
1008
|
key: item == null ? void 0 : (_item$sys = item.sys) == null ? void 0 : _item$sys.id,
|
|
1054
1009
|
name: "contentfulItem",
|
|
@@ -1060,12 +1015,31 @@ function ContentfulFetcher(_ref2) {
|
|
|
1060
1015
|
}, repeatedElement(index, children)));
|
|
1061
1016
|
});
|
|
1062
1017
|
} else {
|
|
1063
|
-
|
|
1018
|
+
var _entriesData$items, _entriesData$items2;
|
|
1019
|
+
if ((entriesData == null ? void 0 : (_entriesData$items = entriesData.items) == null ? void 0 : _entriesData$items.length) === 0) {
|
|
1020
|
+
return React.createElement("div", {
|
|
1021
|
+
className: className
|
|
1022
|
+
}, contentType, " is empty");
|
|
1023
|
+
}
|
|
1024
|
+
renderedData = noAutoRepeat ? children : entriesData == null ? void 0 : (_entriesData$items2 = entriesData.items) == null ? void 0 : _entriesData$items2.map(function (item, index) {
|
|
1025
|
+
var _item$sys2;
|
|
1026
|
+
return React.createElement(DataProvider, {
|
|
1027
|
+
key: item == null ? void 0 : (_item$sys2 = item.sys) == null ? void 0 : _item$sys2.id,
|
|
1028
|
+
name: "contentfulItem",
|
|
1029
|
+
data: item,
|
|
1030
|
+
hidden: true
|
|
1031
|
+
}, React.createElement(DataProvider, {
|
|
1032
|
+
name: makeDataProviderName(contentType),
|
|
1033
|
+
data: item
|
|
1034
|
+
}, repeatedElement(index, children)));
|
|
1035
|
+
});
|
|
1064
1036
|
}
|
|
1065
|
-
|
|
1066
|
-
|
|
1037
|
+
return React.createElement(DataProvider, {
|
|
1038
|
+
name: "contentfulItems",
|
|
1039
|
+
data: entriesData == null ? void 0 : entriesData.items
|
|
1040
|
+
}, noLayout ? React.createElement(React.Fragment, null, " ", renderedData, " ") : React.createElement("div", {
|
|
1067
1041
|
className: className
|
|
1068
|
-
}, " ", renderedData, " ");
|
|
1042
|
+
}, " ", renderedData, " "));
|
|
1069
1043
|
}
|
|
1070
1044
|
var ContentfulFieldMeta = {
|
|
1071
1045
|
name: "ContentfulField",
|
|
@@ -1077,7 +1051,6 @@ var ContentfulFieldMeta = {
|
|
|
1077
1051
|
type: "dataSelector",
|
|
1078
1052
|
data: function data(props, ctx) {
|
|
1079
1053
|
var _ctx$data;
|
|
1080
|
-
|
|
1081
1054
|
return (_ctx$data = ctx == null ? void 0 : ctx.data) != null ? _ctx$data : {};
|
|
1082
1055
|
},
|
|
1083
1056
|
displayName: "Field",
|
|
@@ -1087,26 +1060,20 @@ var ContentfulFieldMeta = {
|
|
|
1087
1060
|
};
|
|
1088
1061
|
function ContentfulField(_ref6) {
|
|
1089
1062
|
var _useSelector;
|
|
1090
|
-
|
|
1091
1063
|
var className = _ref6.className,
|
|
1092
|
-
|
|
1093
|
-
|
|
1064
|
+
objectPath = _ref6.objectPath,
|
|
1065
|
+
setControlContextData = _ref6.setControlContextData;
|
|
1094
1066
|
var item = (_useSelector = useSelector("contentfulItem")) == null ? void 0 : _useSelector.fields;
|
|
1095
|
-
|
|
1096
1067
|
if (!item) {
|
|
1097
1068
|
return React.createElement("div", null, "ContentfulField must be used within a ContentfulFetcher ");
|
|
1098
1069
|
}
|
|
1099
|
-
|
|
1100
1070
|
setControlContextData == null ? void 0 : setControlContextData({
|
|
1101
1071
|
data: item
|
|
1102
1072
|
});
|
|
1103
|
-
|
|
1104
1073
|
if (!objectPath) {
|
|
1105
1074
|
return React.createElement("div", null, "Please specify a valid path or select a field.");
|
|
1106
1075
|
}
|
|
1107
|
-
|
|
1108
1076
|
var data = get(item, objectPath);
|
|
1109
|
-
|
|
1110
1077
|
if (typeof data === "object" && "nodeType" in data && data.nodeType === "document") {
|
|
1111
1078
|
return React.createElement("div", {
|
|
1112
1079
|
className: className,
|
|
@@ -1140,15 +1107,12 @@ function registerAll(loader) {
|
|
|
1140
1107
|
registerComponent(Component, defaultMeta);
|
|
1141
1108
|
}
|
|
1142
1109
|
};
|
|
1143
|
-
|
|
1144
1110
|
if (loader) {
|
|
1145
1111
|
loader.registerGlobalContext(ContentfulCredentialsProvider, ContentfulCredentialsProviderMeta);
|
|
1146
1112
|
} else {
|
|
1147
1113
|
registerGlobalContext(ContentfulCredentialsProvider, ContentfulCredentialsProviderMeta);
|
|
1148
1114
|
}
|
|
1149
|
-
|
|
1150
1115
|
_registerComponent(ContentfulFetcher, ContentfulFetcherMeta);
|
|
1151
|
-
|
|
1152
1116
|
_registerComponent(ContentfulField, ContentfulFieldMeta);
|
|
1153
1117
|
}
|
|
1154
1118
|
|