@plasmicpkgs/plasmic-content-stack 0.0.67 → 0.0.69

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