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