@plasmicpkgs/plasmic-cms 0.0.284 → 0.0.285

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.
@@ -1,1881 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
-
7
- var registerComponent = _interopDefault(require('@plasmicapp/host/registerComponent'));
8
- var registerGlobalContext = _interopDefault(require('@plasmicapp/host/registerGlobalContext'));
9
- var host = require('@plasmicapp/host');
10
- var query = require('@plasmicapp/query');
11
- var dayjs = _interopDefault(require('dayjs'));
12
- var React = _interopDefault(require('react'));
13
-
14
- function asyncGeneratorStep(n, t, e, r, o, a, c) {
15
- try {
16
- var i = n[a](c),
17
- u = i.value;
18
- } catch (n) {
19
- return void e(n);
20
- }
21
- i.done ? t(u) : Promise.resolve(u).then(r, o);
22
- }
23
- function _asyncToGenerator(n) {
24
- return function () {
25
- var t = this,
26
- e = arguments;
27
- return new Promise(function (r, o) {
28
- var a = n.apply(t, e);
29
- function _next(n) {
30
- asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
31
- }
32
- function _throw(n) {
33
- asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
34
- }
35
- _next(void 0);
36
- });
37
- };
38
- }
39
- function _construct(t, e, r) {
40
- if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments);
41
- var o = [null];
42
- o.push.apply(o, e);
43
- var p = new (t.bind.apply(t, o))();
44
- return r && _setPrototypeOf(p, r.prototype), p;
45
- }
46
- function _extends() {
47
- return _extends = Object.assign ? Object.assign.bind() : function (n) {
48
- for (var e = 1; e < arguments.length; e++) {
49
- var t = arguments[e];
50
- for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
51
- }
52
- return n;
53
- }, _extends.apply(null, arguments);
54
- }
55
- function _getPrototypeOf(t) {
56
- return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
57
- return t.__proto__ || Object.getPrototypeOf(t);
58
- }, _getPrototypeOf(t);
59
- }
60
- function _inheritsLoose(t, o) {
61
- t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o);
62
- }
63
- function _isNativeFunction(t) {
64
- try {
65
- return -1 !== Function.toString.call(t).indexOf("[native code]");
66
- } catch (n) {
67
- return "function" == typeof t;
68
- }
69
- }
70
- function _isNativeReflectConstruct() {
71
- try {
72
- var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
73
- } catch (t) {}
74
- return (_isNativeReflectConstruct = function () {
75
- return !!t;
76
- })();
77
- }
78
- function _objectWithoutPropertiesLoose(r, e) {
79
- if (null == r) return {};
80
- var t = {};
81
- for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
82
- if (-1 !== e.indexOf(n)) continue;
83
- t[n] = r[n];
84
- }
85
- return t;
86
- }
87
- function _regeneratorRuntime() {
88
- _regeneratorRuntime = function () {
89
- return e;
90
- };
91
- var t,
92
- e = {},
93
- r = Object.prototype,
94
- n = r.hasOwnProperty,
95
- o = Object.defineProperty || function (t, e, r) {
96
- t[e] = r.value;
97
- },
98
- i = "function" == typeof Symbol ? Symbol : {},
99
- a = i.iterator || "@@iterator",
100
- c = i.asyncIterator || "@@asyncIterator",
101
- u = i.toStringTag || "@@toStringTag";
102
- function define(t, e, r) {
103
- return Object.defineProperty(t, e, {
104
- value: r,
105
- enumerable: !0,
106
- configurable: !0,
107
- writable: !0
108
- }), t[e];
109
- }
110
- try {
111
- define({}, "");
112
- } catch (t) {
113
- define = function (t, e, r) {
114
- return t[e] = r;
115
- };
116
- }
117
- function wrap(t, e, r, n) {
118
- var i = e && e.prototype instanceof Generator ? e : Generator,
119
- a = Object.create(i.prototype),
120
- c = new Context(n || []);
121
- return o(a, "_invoke", {
122
- value: makeInvokeMethod(t, r, c)
123
- }), a;
124
- }
125
- function tryCatch(t, e, r) {
126
- try {
127
- return {
128
- type: "normal",
129
- arg: t.call(e, r)
130
- };
131
- } catch (t) {
132
- return {
133
- type: "throw",
134
- arg: t
135
- };
136
- }
137
- }
138
- e.wrap = wrap;
139
- var h = "suspendedStart",
140
- l = "suspendedYield",
141
- f = "executing",
142
- s = "completed",
143
- y = {};
144
- function Generator() {}
145
- function GeneratorFunction() {}
146
- function GeneratorFunctionPrototype() {}
147
- var p = {};
148
- define(p, a, function () {
149
- return this;
150
- });
151
- var d = Object.getPrototypeOf,
152
- v = d && d(d(values([])));
153
- v && v !== r && n.call(v, a) && (p = v);
154
- var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
155
- function defineIteratorMethods(t) {
156
- ["next", "throw", "return"].forEach(function (e) {
157
- define(t, e, function (t) {
158
- return this._invoke(e, t);
159
- });
160
- });
161
- }
162
- function AsyncIterator(t, e) {
163
- function invoke(r, o, i, a) {
164
- var c = tryCatch(t[r], t, o);
165
- if ("throw" !== c.type) {
166
- var u = c.arg,
167
- h = u.value;
168
- return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
169
- invoke("next", t, i, a);
170
- }, function (t) {
171
- invoke("throw", t, i, a);
172
- }) : e.resolve(h).then(function (t) {
173
- u.value = t, i(u);
174
- }, function (t) {
175
- return invoke("throw", t, i, a);
176
- });
177
- }
178
- a(c.arg);
179
- }
180
- var r;
181
- o(this, "_invoke", {
182
- value: function (t, n) {
183
- function callInvokeWithMethodAndArg() {
184
- return new e(function (e, r) {
185
- invoke(t, n, e, r);
186
- });
187
- }
188
- return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
189
- }
190
- });
191
- }
192
- function makeInvokeMethod(e, r, n) {
193
- var o = h;
194
- return function (i, a) {
195
- if (o === f) throw Error("Generator is already running");
196
- if (o === s) {
197
- if ("throw" === i) throw a;
198
- return {
199
- value: t,
200
- done: !0
201
- };
202
- }
203
- for (n.method = i, n.arg = a;;) {
204
- var c = n.delegate;
205
- if (c) {
206
- var u = maybeInvokeDelegate(c, n);
207
- if (u) {
208
- if (u === y) continue;
209
- return u;
210
- }
211
- }
212
- if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
213
- if (o === h) throw o = s, n.arg;
214
- n.dispatchException(n.arg);
215
- } else "return" === n.method && n.abrupt("return", n.arg);
216
- o = f;
217
- var p = tryCatch(e, r, n);
218
- if ("normal" === p.type) {
219
- if (o = n.done ? s : l, p.arg === y) continue;
220
- return {
221
- value: p.arg,
222
- done: n.done
223
- };
224
- }
225
- "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
226
- }
227
- };
228
- }
229
- function maybeInvokeDelegate(e, r) {
230
- var n = r.method,
231
- o = e.iterator[n];
232
- if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y;
233
- var i = tryCatch(o, e.iterator, r.arg);
234
- if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
235
- var a = i.arg;
236
- return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y);
237
- }
238
- function pushTryEntry(t) {
239
- var e = {
240
- tryLoc: t[0]
241
- };
242
- 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
243
- }
244
- function resetTryEntry(t) {
245
- var e = t.completion || {};
246
- e.type = "normal", delete e.arg, t.completion = e;
247
- }
248
- function Context(t) {
249
- this.tryEntries = [{
250
- tryLoc: "root"
251
- }], t.forEach(pushTryEntry, this), this.reset(!0);
252
- }
253
- function values(e) {
254
- if (e || "" === e) {
255
- var r = e[a];
256
- if (r) return r.call(e);
257
- if ("function" == typeof e.next) return e;
258
- if (!isNaN(e.length)) {
259
- var o = -1,
260
- i = function next() {
261
- for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
262
- return next.value = t, next.done = !0, next;
263
- };
264
- return i.next = i;
265
- }
266
- }
267
- throw new TypeError(typeof e + " is not iterable");
268
- }
269
- return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
270
- value: GeneratorFunctionPrototype,
271
- configurable: !0
272
- }), o(GeneratorFunctionPrototype, "constructor", {
273
- value: GeneratorFunction,
274
- configurable: !0
275
- }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
276
- var e = "function" == typeof t && t.constructor;
277
- return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
278
- }, e.mark = function (t) {
279
- return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
280
- }, e.awrap = function (t) {
281
- return {
282
- __await: t
283
- };
284
- }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
285
- return this;
286
- }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
287
- void 0 === i && (i = Promise);
288
- var a = new AsyncIterator(wrap(t, r, n, o), i);
289
- return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
290
- return t.done ? t.value : a.next();
291
- });
292
- }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
293
- return this;
294
- }), define(g, "toString", function () {
295
- return "[object Generator]";
296
- }), e.keys = function (t) {
297
- var e = Object(t),
298
- r = [];
299
- for (var n in e) r.push(n);
300
- return r.reverse(), function next() {
301
- for (; r.length;) {
302
- var t = r.pop();
303
- if (t in e) return next.value = t, next.done = !1, next;
304
- }
305
- return next.done = !0, next;
306
- };
307
- }, e.values = values, Context.prototype = {
308
- constructor: Context,
309
- reset: function (e) {
310
- if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
311
- },
312
- stop: function () {
313
- this.done = !0;
314
- var t = this.tryEntries[0].completion;
315
- if ("throw" === t.type) throw t.arg;
316
- return this.rval;
317
- },
318
- dispatchException: function (e) {
319
- if (this.done) throw e;
320
- var r = this;
321
- function handle(n, o) {
322
- return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
323
- }
324
- for (var o = this.tryEntries.length - 1; o >= 0; --o) {
325
- var i = this.tryEntries[o],
326
- a = i.completion;
327
- if ("root" === i.tryLoc) return handle("end");
328
- if (i.tryLoc <= this.prev) {
329
- var c = n.call(i, "catchLoc"),
330
- u = n.call(i, "finallyLoc");
331
- if (c && u) {
332
- if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
333
- if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
334
- } else if (c) {
335
- if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
336
- } else {
337
- if (!u) throw Error("try statement without catch or finally");
338
- if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
339
- }
340
- }
341
- }
342
- },
343
- abrupt: function (t, e) {
344
- for (var r = this.tryEntries.length - 1; r >= 0; --r) {
345
- var o = this.tryEntries[r];
346
- if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
347
- var i = o;
348
- break;
349
- }
350
- }
351
- i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
352
- var a = i ? i.completion : {};
353
- return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
354
- },
355
- complete: function (t, e) {
356
- if ("throw" === t.type) throw t.arg;
357
- return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y;
358
- },
359
- finish: function (t) {
360
- for (var e = this.tryEntries.length - 1; e >= 0; --e) {
361
- var r = this.tryEntries[e];
362
- if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
363
- }
364
- },
365
- catch: function (t) {
366
- for (var e = this.tryEntries.length - 1; e >= 0; --e) {
367
- var r = this.tryEntries[e];
368
- if (r.tryLoc === t) {
369
- var n = r.completion;
370
- if ("throw" === n.type) {
371
- var o = n.arg;
372
- resetTryEntry(r);
373
- }
374
- return o;
375
- }
376
- }
377
- throw Error("illegal catch attempt");
378
- },
379
- delegateYield: function (e, r, n) {
380
- return this.delegate = {
381
- iterator: values(e),
382
- resultName: r,
383
- nextLoc: n
384
- }, "next" === this.method && (this.arg = t), y;
385
- }
386
- }, e;
387
- }
388
- function _setPrototypeOf(t, e) {
389
- return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
390
- return t.__proto__ = e, t;
391
- }, _setPrototypeOf(t, e);
392
- }
393
- function _wrapNativeSuper(t) {
394
- var r = "function" == typeof Map ? new Map() : void 0;
395
- return _wrapNativeSuper = function (t) {
396
- if (null === t || !_isNativeFunction(t)) return t;
397
- if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function");
398
- if (void 0 !== r) {
399
- if (r.has(t)) return r.get(t);
400
- r.set(t, Wrapper);
401
- }
402
- function Wrapper() {
403
- return _construct(t, arguments, _getPrototypeOf(this).constructor);
404
- }
405
- return Wrapper.prototype = Object.create(t.prototype, {
406
- constructor: {
407
- value: Wrapper,
408
- enumerable: !1,
409
- writable: !0,
410
- configurable: !0
411
- }
412
- }), _setPrototypeOf(Wrapper, t);
413
- }, _wrapNativeSuper(t);
414
- }
415
-
416
- function queryParamsToApi(params) {
417
- return {
418
- where: params.where,
419
- limit: params.limit,
420
- offset: params.offset,
421
- order: params.orderBy ? [{
422
- field: params.orderBy,
423
- dir: params.desc ? "desc" : "asc"
424
- }] : undefined,
425
- fields: params.fields
426
- };
427
- }
428
- var HttpError = /*#__PURE__*/function (_Error) {
429
- _inheritsLoose(HttpError, _Error);
430
- function HttpError(status, message) {
431
- var _this;
432
- _this = _Error.call(this, message) || this;
433
- _this.status = status;
434
- return _this;
435
- }
436
- return HttpError;
437
- }(/*#__PURE__*/_wrapNativeSuper(Error));
438
- var API = /*#__PURE__*/function () {
439
- function API(config) {
440
- this.config = config;
441
- }
442
- var _proto = API.prototype;
443
- _proto.get = /*#__PURE__*/function () {
444
- var _get = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(endpoint, params) {
445
- var url, fixedParams, response, message, _json$error, json;
446
- return _regeneratorRuntime().wrap(function _callee$(_context) {
447
- while (1) switch (_context.prev = _context.next) {
448
- case 0:
449
- if (params === void 0) {
450
- params = {};
451
- }
452
- url = new URL(this.config.host + "/api/v1/cms/databases/" + this.config.databaseId + endpoint);
453
- fixedParams = Object.keys(params).reduce(function (newObj, key) {
454
- var value = params[key];
455
- if (value != null) {
456
- newObj[key] = value;
457
- }
458
- return newObj;
459
- }, {});
460
- url.search = new URLSearchParams(fixedParams).toString();
461
- _context.next = 6;
462
- return fetch(url.toString(), {
463
- method: "GET",
464
- headers: {
465
- accept: "*/*",
466
- "x-plasmic-api-cms-tokens": this.config.databaseId + ":" + this.config.databaseToken
467
- },
468
- mode: "cors"
469
- });
470
- case 6:
471
- response = _context.sent;
472
- if (!(response.status !== 200)) {
473
- _context.next = 13;
474
- break;
475
- }
476
- _context.next = 10;
477
- return response.text();
478
- case 10:
479
- message = _context.sent;
480
- try {
481
- json = JSON.parse(message);
482
- if ((_json$error = json.error) != null && _json$error.message) {
483
- message = json.error.message;
484
- }
485
- } catch (_unused) {
486
- // ignored
487
- }
488
- throw new HttpError(response.status, message);
489
- case 13:
490
- _context.next = 15;
491
- return response.json();
492
- case 15:
493
- return _context.abrupt("return", _context.sent);
494
- case 16:
495
- case "end":
496
- return _context.stop();
497
- }
498
- }, _callee, this);
499
- }));
500
- function get(_x, _x2) {
501
- return _get.apply(this, arguments);
502
- }
503
- return get;
504
- }();
505
- _proto.fetchTables = /*#__PURE__*/function () {
506
- var _fetchTables = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
507
- var response;
508
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
509
- while (1) switch (_context2.prev = _context2.next) {
510
- case 0:
511
- _context2.prev = 0;
512
- _context2.next = 3;
513
- return this.get("");
514
- case 3:
515
- response = _context2.sent;
516
- return _context2.abrupt("return", response.tables);
517
- case 7:
518
- _context2.prev = 7;
519
- _context2.t0 = _context2["catch"](0);
520
- console.error(_context2.t0);
521
- throw _context2.t0;
522
- case 11:
523
- case "end":
524
- return _context2.stop();
525
- }
526
- }, _callee2, this, [[0, 7]]);
527
- }));
528
- function fetchTables() {
529
- return _fetchTables.apply(this, arguments);
530
- }
531
- return fetchTables;
532
- }();
533
- _proto.useDraftForTable = function useDraftForTable(table) {
534
- if (Array.isArray(this.config.useDraft)) {
535
- return this.config.useDraft.includes(table);
536
- } else {
537
- return this.config.useDraft;
538
- }
539
- };
540
- _proto.query = /*#__PURE__*/function () {
541
- var _query = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(table, params) {
542
- var response;
543
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
544
- while (1) switch (_context3.prev = _context3.next) {
545
- case 0:
546
- if (params === void 0) {
547
- params = {};
548
- }
549
- _context3.prev = 1;
550
- _context3.next = 4;
551
- return this.get("/tables/" + table + "/query", {
552
- q: JSON.stringify(queryParamsToApi(params)),
553
- draft: Number(this.useDraftForTable(table) || params.useDraft),
554
- locale: this.config.locale
555
- });
556
- case 4:
557
- response = _context3.sent;
558
- return _context3.abrupt("return", response.rows);
559
- case 8:
560
- _context3.prev = 8;
561
- _context3.t0 = _context3["catch"](1);
562
- console.error(_context3.t0);
563
- throw _context3.t0;
564
- case 12:
565
- case "end":
566
- return _context3.stop();
567
- }
568
- }, _callee3, this, [[1, 8]]);
569
- }));
570
- function query(_x3, _x4) {
571
- return _query.apply(this, arguments);
572
- }
573
- return query;
574
- }();
575
- _proto.count = /*#__PURE__*/function () {
576
- var _count = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(table, params) {
577
- var response;
578
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
579
- while (1) switch (_context4.prev = _context4.next) {
580
- case 0:
581
- if (params === void 0) {
582
- params = {};
583
- }
584
- _context4.prev = 1;
585
- _context4.next = 4;
586
- return this.get("/tables/" + table + "/count", {
587
- q: JSON.stringify(queryParamsToApi(params)),
588
- draft: Number(this.useDraftForTable(table) || params.useDraft)
589
- });
590
- case 4:
591
- response = _context4.sent;
592
- return _context4.abrupt("return", response.count);
593
- case 8:
594
- _context4.prev = 8;
595
- _context4.t0 = _context4["catch"](1);
596
- console.error(_context4.t0);
597
- throw _context4.t0;
598
- case 12:
599
- case "end":
600
- return _context4.stop();
601
- }
602
- }, _callee4, this, [[1, 8]]);
603
- }));
604
- function count(_x5, _x6) {
605
- return _count.apply(this, arguments);
606
- }
607
- return count;
608
- }();
609
- return API;
610
- }();
611
- function mkApi(config) {
612
- if (!config) {
613
- throw new Error("Component must be wrapped in 'CMS Data Provider'.");
614
- }
615
- return new API(config);
616
- }
617
-
618
- var _excluded = ["databaseToken"];
619
- var contextPrefix = "plasmicCms";
620
- var databaseContextKey = contextPrefix + "Database";
621
- var tablesContextKey = contextPrefix + "Tables";
622
- var tableSchemaContextKey = contextPrefix + "TableSchema";
623
- var collectionResultSuffix = "Collection";
624
- var mkQueryContextKey = function mkQueryContextKey(table) {
625
- return "" + contextPrefix + capitalizeFirst(table) + collectionResultSuffix;
626
- };
627
- var itemContextSuffix = "Item";
628
- var countContextSuffix = "Count";
629
- var modeContextSuffix = "Mode";
630
- var mkRowContextKey = function mkRowContextKey(table) {
631
- return "" + contextPrefix + capitalizeFirst(table) + itemContextSuffix;
632
- };
633
- var mkCountContextKey = function mkCountContextKey(table) {
634
- return "" + contextPrefix + capitalizeFirst(table) + countContextSuffix;
635
- };
636
- var mkModeContextKey = function mkModeContextKey(table) {
637
- return "" + contextPrefix + capitalizeFirst(table) + modeContextSuffix;
638
- };
639
- function capitalizeFirst(str) {
640
- var _str$;
641
- return ((_str$ = str[0]) == null ? void 0 : _str$.toUpperCase()) + str.slice(1);
642
- }
643
- function useDatabase() {
644
- return host.useSelector(databaseContextKey);
645
- }
646
- function makeDatabaseCacheKey(config) {
647
- if (!config) {
648
- return null;
649
- }
650
- var rest = _objectWithoutPropertiesLoose(config, _excluded);
651
- return JSON.stringify(rest);
652
- }
653
- function DatabaseProvider(_ref) {
654
- var config = _ref.config,
655
- children = _ref.children;
656
- return React.createElement(host.DataProvider, {
657
- name: databaseContextKey,
658
- data: config,
659
- hidden: true
660
- }, children);
661
- }
662
- function useTables() {
663
- return host.useSelector(tablesContextKey);
664
- }
665
- function TablesProvider(_ref2) {
666
- var children = _ref2.children,
667
- tables = _ref2.tables;
668
- return React.createElement(host.DataProvider, {
669
- name: tablesContextKey,
670
- data: tables,
671
- hidden: true
672
- }, children);
673
- }
674
- function TableSchemaProvider(_ref3) {
675
- var children = _ref3.children,
676
- table = _ref3.table;
677
- var tables = useTables();
678
- var schema;
679
- if (tables && (tables == null ? void 0 : tables.length) > 0) {
680
- if (!table) {
681
- var _tables$;
682
- schema = (_tables$ = tables[0]) == null ? void 0 : _tables$.schema;
683
- } else {
684
- var _tables$find;
685
- schema = tables == null || (_tables$find = tables.find(function (t) {
686
- return (t == null ? void 0 : t.identifier) === table;
687
- })) == null ? void 0 : _tables$find.schema;
688
- }
689
- }
690
- return React.createElement(host.DataProvider, {
691
- name: tableSchemaContextKey,
692
- data: schema
693
- }, children);
694
- }
695
- function getClosestMatchingKeysBy(env, pred) {
696
- return [].concat(Object.keys(env).reverse()).filter(function (key) {
697
- return pred(key);
698
- });
699
- }
700
- function QueryResultProvider(_ref4) {
701
- var children = _ref4.children,
702
- table = _ref4.table,
703
- rows = _ref4.rows,
704
- hidden = _ref4.hidden;
705
- return React.createElement(host.DataProvider, {
706
- name: table ? mkModeContextKey(table) : undefined,
707
- data: "rows",
708
- hidden: true
709
- }, React.createElement(host.DataProvider, {
710
- name: table ? mkQueryContextKey(table) : undefined,
711
- data: rows,
712
- hidden: hidden
713
- }, children));
714
- }
715
- function useTablesWithDataLoaded(mode) {
716
- var env = host.useDataEnv();
717
- var tables = useTables();
718
- if (!env) {
719
- return undefined;
720
- }
721
- if (!tables) {
722
- return undefined;
723
- }
724
- var matchingKeys = getClosestMatchingKeysBy(env, function (key) {
725
- if (mode === "rows") {
726
- return key.endsWith(itemContextSuffix);
727
- } else if (mode === "count") {
728
- return key.endsWith(countContextSuffix);
729
- } else {
730
- return key.endsWith(itemContextSuffix) || key.endsWith(countContextSuffix);
731
- }
732
- });
733
- return tables.filter(function (table) {
734
- return matchingKeys.some(function (key) {
735
- if (mode === "rows") {
736
- return mkRowContextKey(table.identifier) === key;
737
- } else if (mode === "count") {
738
- return mkCountContextKey(table.identifier) === key;
739
- } else {
740
- return mkRowContextKey(table.identifier) === key || mkCountContextKey(table.identifier) === key;
741
- }
742
- });
743
- });
744
- }
745
- function deriveTableId(tables, table) {
746
- if (!table && tables && tables.length > 0) {
747
- table = tables[0].identifier;
748
- }
749
- return table;
750
- }
751
- function useRow(tables, table) {
752
- var env = host.useDataEnv();
753
- if (!env) {
754
- return undefined;
755
- }
756
- table = deriveTableId(tables, table);
757
- if (table) {
758
- return {
759
- table: table,
760
- row: env[mkRowContextKey(table)]
761
- };
762
- }
763
- return undefined;
764
- }
765
- function useCount(tables, table) {
766
- var env = host.useDataEnv();
767
- if (!env) {
768
- return undefined;
769
- }
770
- table = deriveTableId(tables, table);
771
- if (table) {
772
- return {
773
- table: table,
774
- count: env[mkCountContextKey(table)]
775
- };
776
- }
777
- return undefined;
778
- }
779
- function RowProvider(_ref5) {
780
- var children = _ref5.children,
781
- table = _ref5.table,
782
- row = _ref5.row;
783
- return React.createElement(host.DataProvider, {
784
- name: mkRowContextKey(table),
785
- data: row
786
- }, children);
787
- }
788
- function CountProvider(_ref6) {
789
- var children = _ref6.children,
790
- table = _ref6.table,
791
- count = _ref6.count;
792
- return React.createElement(host.DataProvider, {
793
- name: table ? mkModeContextKey(table) : undefined,
794
- data: "count",
795
- hidden: true
796
- }, React.createElement(host.DataProvider, {
797
- name: table ? mkCountContextKey(table) : undefined,
798
- data: count
799
- }, children));
800
- }
801
-
802
- function mkTableOptions(tables) {
803
- if (!tables) {
804
- return [];
805
- }
806
- return tables.map(function (table) {
807
- return {
808
- value: table.identifier,
809
- label: table.name
810
- };
811
- });
812
- }
813
- function mkFieldOptions(tables, tableIdentifier, types) {
814
- if (!tables) {
815
- return [];
816
- }
817
- var table = tables.find(function (t) {
818
- return t.identifier === tableIdentifier;
819
- });
820
- if (!table) {
821
- return [];
822
- }
823
- var fields = table.schema.fields;
824
- if (types) {
825
- fields = fields.filter(function (f) {
826
- return types.includes(f.type);
827
- });
828
- }
829
- var options = fields.map(function (f) {
830
- return {
831
- value: f.identifier,
832
- label: f.name || f.identifier
833
- };
834
- });
835
- if (!options.some(function (option) {
836
- return option.value === "_id";
837
- })) {
838
- options.push({
839
- label: "System-assigned ID",
840
- value: "_id"
841
- });
842
- }
843
- return options;
844
- }
845
-
846
- var _excluded$1 = ["className", "table", "field", "dateFormat", "setControlContextData", "usePlasmicTheme", "themeResetClassName"],
847
- _excluded2 = ["className", "table", "setControlContextData"],
848
- _excluded3 = ["table", "field", "valueProp", "children", "setControlContextData"];
849
- var modulePath = "@plasmicpkgs/plasmic-cms";
850
- var componentPrefix = "hostless-plasmic-cms";
851
- function renderMaybeData(maybeData, renderFn, loaderProps, inEditor, loadingMessage, forceLoadingState) {
852
- if ("error" in maybeData) {
853
- var error = maybeData.error;
854
- if (!inEditor) {
855
- return React.createElement(React.Fragment, null, loadingMessage != null ? loadingMessage : React.createElement("div", null, "Loading..."));
856
- }
857
- if (error && error instanceof HttpError && error.status === 404) {
858
- if (loaderProps.hideIfNotFound) {
859
- return null;
860
- } else {
861
- return React.createElement("div", null, "Error: Data not found");
862
- }
863
- } else {
864
- return React.createElement("div", null, "Error: ", error == null ? void 0 : error.message);
865
- }
866
- }
867
- if (!("data" in maybeData) || forceLoadingState) {
868
- return React.createElement(React.Fragment, null, loadingMessage != null ? loadingMessage : React.createElement("div", null, "Loading..."));
869
- }
870
- return renderFn(maybeData.data);
871
- }
872
- var defaultHost = "https://data.plasmic.app";
873
- var cmsCredentialsProviderMeta = {
874
- name: componentPrefix + "-credentials-provider",
875
- displayName: "CMS Credentials Provider",
876
- description: "\nFind (or create) your CMS in the [dashboard](https://studio.plasmic.app), and go to its Settings view for the ID and token.\n\n[See tutorial video](https://docs.plasmic.app/learn/plasmic-cms/).",
877
- importName: "CmsCredentialsProvider",
878
- importPath: modulePath,
879
- providesData: true,
880
- props: {
881
- host: {
882
- type: "string",
883
- displayName: "Studio URL",
884
- description: "The default host for use in production is " + defaultHost + ".",
885
- defaultValue: defaultHost,
886
- defaultValueHint: defaultHost,
887
- advanced: true
888
- },
889
- databaseId: {
890
- type: "string",
891
- displayName: "CMS ID",
892
- description: "The ID of the CMS (database) to use. (Can get on the CMS settings page)"
893
- },
894
- databaseToken: {
895
- type: "string",
896
- displayName: "CMS Public Token",
897
- description: "The Public Token of the CMS (database) you are using. (Can get on the CMS settings page)"
898
- },
899
- locale: {
900
- type: "string",
901
- displayName: "Locale",
902
- description: "The locale to use for localized values, leave empty for the default locale."
903
- }
904
- }
905
- };
906
- function CmsCredentialsProvider(_ref) {
907
- var children = _ref.children,
908
- databaseId = _ref.databaseId,
909
- databaseToken = _ref.databaseToken,
910
- host = _ref.host,
911
- locale = _ref.locale,
912
- useDraft = _ref.useDraft;
913
- var config = {
914
- databaseId: databaseId,
915
- databaseToken: databaseToken,
916
- locale: locale,
917
- host: host || defaultHost,
918
- useDraft: useDraft != null ? useDraft : false
919
- };
920
- return React.createElement(DatabaseProvider, {
921
- config: config
922
- }, React.createElement(TablesFetcher, null, children));
923
- }
924
- function TablesFetcher(_ref2) {
925
- var children = _ref2.children;
926
- var databaseConfig = useDatabase();
927
- var cacheKey = JSON.stringify({
928
- component: "TablesFetcher",
929
- databaseConfig: makeDatabaseCacheKey(databaseConfig)
930
- });
931
- var maybeData = query.usePlasmicQueryData(cacheKey, /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
932
- return _regeneratorRuntime().wrap(function _callee$(_context) {
933
- while (1) switch (_context.prev = _context.next) {
934
- case 0:
935
- if (isDatabaseConfigured(databaseConfig)) {
936
- _context.next = 2;
937
- break;
938
- }
939
- return _context.abrupt("return", []);
940
- case 2:
941
- _context.next = 4;
942
- return mkApi(databaseConfig).fetchTables();
943
- case 4:
944
- return _context.abrupt("return", _context.sent);
945
- case 5:
946
- case "end":
947
- return _context.stop();
948
- }
949
- }, _callee);
950
- })));
951
- var inEditor = !!host.usePlasmicCanvasContext();
952
- return React.createElement(TablesProvider, {
953
- tables: maybeData.data
954
- }, inEditor && maybeData.error ? React.createElement("div", null, "CMS Error: ", maybeData.error.message) : children);
955
- }
956
- function isDatabaseConfigured(config) {
957
- return (config == null ? void 0 : config.databaseId) && (config == null ? void 0 : config.databaseToken);
958
- }
959
- var cmsQueryRepeaterMeta = {
960
- name: componentPrefix + "-query-repeater",
961
- displayName: "CMS Data Fetcher",
962
- description: "Fetches CMS data. Repeats `children` slot content for each row fetched. [See tutorial video](https://docs.plasmic.app/learn/plasmic-cms/).",
963
- importName: "CmsQueryRepeater",
964
- importPath: modulePath,
965
- providesData: true,
966
- defaultStyles: {
967
- display: "flex",
968
- width: "stretch",
969
- maxWidth: "100%",
970
- flexDirection: "column"
971
- },
972
- props: {
973
- children: {
974
- type: "slot",
975
- isRepeated: true,
976
- defaultValue: {
977
- type: "vbox",
978
- children: [{
979
- type: "component",
980
- name: componentPrefix + "-row-field"
981
- }]
982
- }
983
- },
984
- table: {
985
- type: "choice",
986
- displayName: "Model",
987
- description: "CMS model (table) to query.",
988
- options: function options(_, ctx) {
989
- return mkTableOptions(ctx == null ? void 0 : ctx.tables);
990
- },
991
- defaultValueHint: function defaultValueHint(_, ctx) {
992
- return ctx == null ? void 0 : ctx.table;
993
- }
994
- },
995
- useDraft: {
996
- type: "boolean",
997
- displayName: "Use drafts?",
998
- description: "If set, also query unpublished content.",
999
- defaultValue: false,
1000
- hidden: function hidden() {
1001
- return true;
1002
- }
1003
- },
1004
- mode: {
1005
- type: "choice",
1006
- options: [{
1007
- label: "Rows",
1008
- value: "rows"
1009
- }, {
1010
- label: "Count",
1011
- value: "count"
1012
- }],
1013
- defaultValueHint: "rows"
1014
- },
1015
- where: {
1016
- type: "object",
1017
- displayName: "Filter",
1018
- description: "Filter clause, as a JSON in Mongo query format. Should not be used together with Filter field and Filter value",
1019
- advanced: true
1020
- },
1021
- filterField: {
1022
- type: "choice",
1023
- displayName: "Filter field",
1024
- description: "Field (from model schema) to filter by",
1025
- options: function options(_ref4, ctx) {
1026
- var _ctx$table;
1027
- var table = _ref4.table;
1028
- return mkFieldOptions(ctx == null ? void 0 : ctx.tables, (_ctx$table = ctx == null ? void 0 : ctx.table) != null ? _ctx$table : table, ["number" /* NUMBER */, "boolean" /* BOOLEAN */, "text" /* TEXT */, "long-text" /* LONG_TEXT */, "ref" /* REF */]);
1029
- }
1030
- },
1031
- filterValue: {
1032
- type: "string",
1033
- displayName: "Filter value",
1034
- description: "Value to filter by, should be of filter field type"
1035
- },
1036
- orderBy: {
1037
- type: "choice",
1038
- displayName: "Order by",
1039
- description: "Field to order by.",
1040
- options: function options(_, ctx) {
1041
- return mkFieldOptions(ctx == null ? void 0 : ctx.tables, ctx == null ? void 0 : ctx.table, ["number" /* NUMBER */, "boolean" /* BOOLEAN */, "date-time" /* DATE_TIME */, "long-text" /* LONG_TEXT */, "text" /* TEXT */]);
1042
- },
1043
- hidden: function hidden(ps) {
1044
- return ps.mode === "count";
1045
- }
1046
- },
1047
- desc: {
1048
- type: "boolean",
1049
- displayName: "Sort descending?",
1050
- description: 'Sort descending by "Order by" field.',
1051
- defaultValue: false,
1052
- hidden: function hidden(ps) {
1053
- return ps.mode === "count";
1054
- }
1055
- },
1056
- limit: {
1057
- type: "number",
1058
- displayName: "Limit",
1059
- description: "Maximum number of entries to fetch (0 for unlimited).",
1060
- defaultValue: 0,
1061
- min: 0,
1062
- hidden: function hidden(ps) {
1063
- return ps.mode === "count";
1064
- }
1065
- },
1066
- offset: {
1067
- type: "number",
1068
- displayName: "Offset",
1069
- description: "Skips this number of rows in the result set; used in combination with limit to build pagination",
1070
- min: 0,
1071
- hidden: function hidden(ps) {
1072
- return ps.mode === "count";
1073
- }
1074
- },
1075
- fields: {
1076
- type: "choice",
1077
- multiSelect: true,
1078
- displayName: "Fields",
1079
- description: "Fields from the CMS model to include with each row; by default, all fields are included",
1080
- options: function options(_ref5, ctx) {
1081
- var _ctx$table2;
1082
- var table = _ref5.table;
1083
- return mkFieldOptions(ctx == null ? void 0 : ctx.tables, (_ctx$table2 = ctx == null ? void 0 : ctx.table) != null ? _ctx$table2 : table);
1084
- },
1085
- hidden: function hidden(ps) {
1086
- return ps.mode === "count";
1087
- }
1088
- },
1089
- emptyMessage: {
1090
- type: "slot",
1091
- defaultValue: {
1092
- type: "text",
1093
- value: "No matching published entries found."
1094
- }
1095
- },
1096
- forceEmptyState: {
1097
- type: "boolean",
1098
- displayName: "Force empty state",
1099
- description: "If set, will render as if no matching entries were found.",
1100
- defaultValue: false
1101
- },
1102
- loadingMessage: {
1103
- type: "slot",
1104
- defaultValue: {
1105
- type: "text",
1106
- value: "Loading..."
1107
- }
1108
- },
1109
- forceLoadingState: {
1110
- type: "boolean",
1111
- displayName: "Force loading state",
1112
- description: "If set, will render as if it is waiting for the query to run.",
1113
- defaultValue: false
1114
- },
1115
- noLayout: {
1116
- type: "boolean",
1117
- displayName: "No layout",
1118
- description: "When set, CMS Data Loader 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.",
1119
- defaultValue: false
1120
- },
1121
- noAutoRepeat: {
1122
- type: "boolean",
1123
- displayName: "No auto-repeat",
1124
- description: "Do not automatically repeat children for every entry.",
1125
- defaultValue: false,
1126
- hidden: function hidden(ps) {
1127
- return ps.mode === "count";
1128
- }
1129
- }
1130
- }
1131
- };
1132
- function CmsQueryRepeater(_ref6) {
1133
- var table = _ref6.table,
1134
- children = _ref6.children,
1135
- setControlContextData = _ref6.setControlContextData,
1136
- mode = _ref6.mode,
1137
- where = _ref6.where,
1138
- useDraft = _ref6.useDraft,
1139
- orderBy = _ref6.orderBy,
1140
- desc = _ref6.desc,
1141
- limit = _ref6.limit,
1142
- offset = _ref6.offset,
1143
- emptyMessage = _ref6.emptyMessage,
1144
- forceEmptyState = _ref6.forceEmptyState,
1145
- loadingMessage = _ref6.loadingMessage,
1146
- forceLoadingState = _ref6.forceLoadingState,
1147
- noLayout = _ref6.noLayout,
1148
- noAutoRepeat = _ref6.noAutoRepeat,
1149
- className = _ref6.className,
1150
- filterField = _ref6.filterField,
1151
- filterValue = _ref6.filterValue,
1152
- fields = _ref6.fields;
1153
- var databaseConfig = useDatabase();
1154
- var tables = useTables();
1155
- if (filterField && filterValue) {
1156
- var _where;
1157
- where = (_where = {}, _where[filterField] = filterValue, _where);
1158
- }
1159
- var params = {
1160
- where: where,
1161
- useDraft: useDraft,
1162
- orderBy: orderBy,
1163
- desc: desc,
1164
- limit: limit,
1165
- offset: offset,
1166
- fields: fields
1167
- };
1168
- if (!table && tables && tables.length > 0) {
1169
- table = tables[0].identifier;
1170
- }
1171
- var cacheKey = JSON.stringify({
1172
- component: "CmsQueryLoader",
1173
- mode: mode,
1174
- table: table,
1175
- databaseConfig: makeDatabaseCacheKey(databaseConfig),
1176
- params: params
1177
- });
1178
- if (tables) {
1179
- // TODO: Only include table if __plasmic_cms_row_{table} exists.
1180
- setControlContextData == null || setControlContextData({
1181
- tables: tables,
1182
- table: table
1183
- });
1184
- }
1185
- var maybeData = query.usePlasmicQueryData(cacheKey, /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
1186
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
1187
- while (1) switch (_context2.prev = _context2.next) {
1188
- case 0:
1189
- if (isDatabaseConfigured(databaseConfig)) {
1190
- _context2.next = 2;
1191
- break;
1192
- }
1193
- throw new Error("You must specify a CMS ID and API key");
1194
- case 2:
1195
- if (table) {
1196
- _context2.next = 6;
1197
- break;
1198
- }
1199
- throw new Error("You must select a model to query");
1200
- case 6:
1201
- if (!(tables && !tables.find(function (t) {
1202
- return t.identifier === table;
1203
- }))) {
1204
- _context2.next = 10;
1205
- break;
1206
- }
1207
- throw new Error("There is no model called \"" + table + "\"");
1208
- case 10:
1209
- if (!(mode === "count")) {
1210
- _context2.next = 14;
1211
- break;
1212
- }
1213
- return _context2.abrupt("return", mkApi(databaseConfig).count(table, params));
1214
- case 14:
1215
- return _context2.abrupt("return", mkApi(databaseConfig).query(table, params));
1216
- case 15:
1217
- case "end":
1218
- return _context2.stop();
1219
- }
1220
- }, _callee2);
1221
- })));
1222
- var inEditor = !!host.usePlasmicCanvasContext();
1223
- if (mode === "count") {
1224
- var node = renderMaybeData(maybeData, function () {
1225
- return children;
1226
- }, {
1227
- hideIfNotFound: false
1228
- }, inEditor, loadingMessage, forceLoadingState);
1229
- return React.createElement(TableSchemaProvider, {
1230
- table: table
1231
- }, React.createElement(CountProvider, {
1232
- table: table,
1233
- count: typeof (maybeData == null ? void 0 : maybeData.data) === "number" ? maybeData.data : undefined
1234
- }, node));
1235
- } else {
1236
- var _node = renderMaybeData(maybeData, function (rows) {
1237
- if (rows.length === 0 || forceEmptyState) {
1238
- return emptyMessage;
1239
- }
1240
- return noAutoRepeat ? children : rows.map(function (row, index) {
1241
- return React.createElement(RowProvider, {
1242
- key: index,
1243
- table: table,
1244
- row: row
1245
- }, host.repeatedElement(index, children));
1246
- });
1247
- }, {
1248
- hideIfNotFound: false
1249
- }, inEditor, loadingMessage, forceLoadingState);
1250
- return React.createElement(TableSchemaProvider, {
1251
- table: table
1252
- }, React.createElement(QueryResultProvider, {
1253
- rows: Array.isArray(maybeData == null ? void 0 : maybeData.data) ? maybeData.data : undefined,
1254
- table: table
1255
- }, noLayout ? React.createElement(React.Fragment, null, " ", _node, " ") : React.createElement("div", {
1256
- className: className
1257
- }, " ", _node, " ")));
1258
- }
1259
- }
1260
- var cmsRowFieldMeta = {
1261
- name: componentPrefix + "-row-field",
1262
- displayName: "CMS Entry Field",
1263
- importName: "CmsRowField",
1264
- importPath: modulePath,
1265
- props: {
1266
- table: {
1267
- type: "choice",
1268
- displayName: "Model",
1269
- hidden: function hidden(props, ctx) {
1270
- var _ctx$tables$length, _ctx$tables;
1271
- return ((_ctx$tables$length = ctx == null || (_ctx$tables = ctx.tables) == null ? void 0 : _ctx$tables.length) != null ? _ctx$tables$length : 0) <= 1 && !props.table;
1272
- },
1273
- helpText: "Pick model from a CMS Data Fetcher",
1274
- description: "Usually not used! Only with multiple CMS Data Loaders, use this to choose which to show. Otherwise, go select the CMS Data Loader if you want to load different data.",
1275
- options: function options(_, ctx) {
1276
- return mkTableOptions(ctx == null ? void 0 : ctx.tables);
1277
- },
1278
- defaultValueHint: function defaultValueHint(_, ctx) {
1279
- return ctx == null ? void 0 : ctx.table;
1280
- }
1281
- },
1282
- field: {
1283
- type: "choice",
1284
- displayName: "Field",
1285
- description: "Field (from model schema) to use.",
1286
- options: function options(_ref8, ctx) {
1287
- var _ctx$table3;
1288
- var table = _ref8.table;
1289
- return mkFieldOptions(ctx == null ? void 0 : ctx.tables, (_ctx$table3 = ctx == null ? void 0 : ctx.table) != null ? _ctx$table3 : table, ["number" /* NUMBER */, "boolean" /* BOOLEAN */, "text" /* TEXT */, "long-text" /* LONG_TEXT */, "date-time" /* DATE_TIME */, "rich-text" /* RICH_TEXT */, "image" /* IMAGE */, "file" /* FILE */, "enum" /* ENUM */]);
1290
- },
1291
- defaultValueHint: function defaultValueHint(_, ctx) {
1292
- var _ctx$fieldMeta, _ctx$fieldMeta2;
1293
- return (ctx == null || (_ctx$fieldMeta = ctx.fieldMeta) == null ? void 0 : _ctx$fieldMeta.name) || (ctx == null || (_ctx$fieldMeta2 = ctx.fieldMeta) == null ? void 0 : _ctx$fieldMeta2.identifier);
1294
- }
1295
- },
1296
- dateFormat: {
1297
- type: "choice",
1298
- displayName: "Date Format",
1299
- hidden: function hidden(_ref9, ctx) {
1300
- var field = _ref9.field;
1301
- if (!ctx) {
1302
- return true;
1303
- }
1304
- var tableIdentifier = ctx.table,
1305
- tables = ctx.tables;
1306
- var table = tables == null ? void 0 : tables.find(function (t) {
1307
- return t.identifier === tableIdentifier;
1308
- });
1309
- if (!table) {
1310
- return true;
1311
- }
1312
- var fieldMeta = table.schema.fields.find(function (f) {
1313
- return f.identifier === field;
1314
- });
1315
- if (!fieldMeta) {
1316
- return true;
1317
- }
1318
- return fieldMeta.type !== "date-time" /* DATE_TIME */;
1319
- },
1320
- options: [{
1321
- label: "July 26, 2014",
1322
- value: "MMMM D, YYYY"
1323
- }, {
1324
- label: "July 26, 2014 10:02 PM",
1325
- value: "MMMM D, YYYY h:mm A"
1326
- }, {
1327
- label: "Jul 26, 2014",
1328
- value: "MMM D, YYYY"
1329
- }, {
1330
- label: "Jul 26, 2014 10:02 PM",
1331
- value: "MMM D, YYYY h:mm A"
1332
- }, {
1333
- label: "Saturday, July 26, 2014",
1334
- value: "dddd, MMMM D, YYYY"
1335
- }, {
1336
- label: "7/26/2014",
1337
- value: "M/D/YYYY"
1338
- }, {
1339
- label: "7/26/2014 10:02 PM",
1340
- value: "M/D/YYYY h:mm A"
1341
- }, {
1342
- label: "26/7/2014",
1343
- value: "D/M/YYYY"
1344
- }, {
1345
- label: "26/7/2014 10:02 PM",
1346
- value: "D/M/YYYY h:mm A"
1347
- }, {
1348
- label: "7/26/14",
1349
- value: "M/D/YY"
1350
- }, {
1351
- label: "7/26/14 10:02 PM",
1352
- value: "M/D/YY h:mm A"
1353
- }, {
1354
- label: "26/7/14",
1355
- value: "D/M/YY"
1356
- }, {
1357
- label: "26/7/14 10:02 PM",
1358
- value: "D/M/YY h:mm A"
1359
- }]
1360
- },
1361
- usePlasmicTheme: {
1362
- type: "boolean",
1363
- displayName: "Use Plasmic tag styles?",
1364
- description: "For HTML content, use tag styles defined in Plasmic",
1365
- advanced: true
1366
- },
1367
- themeResetClassName: {
1368
- type: "themeResetClass",
1369
- targetAllTags: true
1370
- }
1371
- },
1372
- defaultStyles: {
1373
- objectFit: "cover"
1374
- }
1375
- };
1376
- function CmsRowField(_ref10) {
1377
- var _res$row$data;
1378
- var className = _ref10.className,
1379
- table = _ref10.table,
1380
- field = _ref10.field,
1381
- dateFormat = _ref10.dateFormat,
1382
- setControlContextData = _ref10.setControlContextData,
1383
- usePlasmicTheme = _ref10.usePlasmicTheme,
1384
- themeResetClassName = _ref10.themeResetClassName,
1385
- rest = _objectWithoutPropertiesLoose(_ref10, _excluded$1);
1386
- var tables = useTablesWithDataLoaded("rows");
1387
- var res = useRow(tables, table);
1388
- var unknown = React.createElement("div", Object.assign({
1389
- className: className
1390
- }, rest), "Field ", table != null ? table : "Unknown Model", ".", field != null ? field : "Unknown Field");
1391
- var fieldMeta = res ? deriveInferredTableField({
1392
- table: res.table,
1393
- tables: tables,
1394
- field: field,
1395
- typeFilters: ["text" /* TEXT */, "long-text" /* LONG_TEXT */, "rich-text" /* RICH_TEXT */]
1396
- }) : undefined;
1397
- if (tables) {
1398
- // TODO: Only include table if __plasmic_cms_row_{table} exists.
1399
- setControlContextData == null || setControlContextData(_extends({
1400
- tables: tables
1401
- }, res && res.row ? {
1402
- table: res.table,
1403
- row: res.row,
1404
- fieldMeta: fieldMeta
1405
- } : {}));
1406
- }
1407
- if (!res) {
1408
- return unknown;
1409
- }
1410
- if (!res.row) {
1411
- return React.createElement("div", {
1412
- className: className
1413
- }, "Error: No CMS Entry found");
1414
- }
1415
- if (!fieldMeta) {
1416
- return unknown;
1417
- }
1418
- var data = (_res$row$data = res.row.data) == null ? void 0 : _res$row$data[fieldMeta.identifier];
1419
- if (!data) {
1420
- return null;
1421
- }
1422
- if (fieldMeta.type === "date-time" /* DATE_TIME */ && dateFormat) {
1423
- data = dayjs(data).format(dateFormat);
1424
- }
1425
- return data ? renderValue(data, fieldMeta.type, _extends({
1426
- className: (usePlasmicTheme ? themeResetClassName : "") + " " + className
1427
- }, rest)) : null;
1428
- }
1429
- var cmsCountFieldMeta = {
1430
- name: componentPrefix + "-count",
1431
- displayName: "CMS Entries Count",
1432
- importName: "CmsCount",
1433
- importPath: modulePath,
1434
- props: {
1435
- table: {
1436
- type: "choice",
1437
- displayName: "Model",
1438
- hidden: function hidden(props, ctx) {
1439
- var _ctx$tables$length2, _ctx$tables2;
1440
- return ((_ctx$tables$length2 = ctx == null || (_ctx$tables2 = ctx.tables) == null ? void 0 : _ctx$tables2.length) != null ? _ctx$tables$length2 : 0) <= 1 && !props.table;
1441
- },
1442
- helpText: "Pick model from a CMS Data Fetcher",
1443
- description: "Usually not used! Only with multiple CMS Data Loaders, use this to choose which to show. Otherwise, go select the CMS Data Loader if you want to load different data.",
1444
- options: function options(_, ctx) {
1445
- return mkTableOptions(ctx == null ? void 0 : ctx.tables);
1446
- },
1447
- defaultValueHint: function defaultValueHint(_, ctx) {
1448
- return ctx == null ? void 0 : ctx.table;
1449
- }
1450
- }
1451
- }
1452
- };
1453
- function CmsCount(_ref11) {
1454
- var className = _ref11.className,
1455
- table = _ref11.table,
1456
- rest = _objectWithoutPropertiesLoose(_ref11, _excluded2);
1457
- var tables = useTablesWithDataLoaded("count");
1458
- var res = useCount(tables, table);
1459
- var unknown = React.createElement("div", Object.assign({
1460
- className: className
1461
- }, rest), "Count: ", table != null ? table : "Unknown Model");
1462
- if (!res) {
1463
- return unknown;
1464
- }
1465
- if (res.count == null) {
1466
- return null;
1467
- } else {
1468
- return React.createElement("div", Object.assign({
1469
- className: className
1470
- }, rest), new Intl.NumberFormat().format(res.count));
1471
- }
1472
- }
1473
- var DEFAULT_TYPE_FILTERS = ["text" /* TEXT */];
1474
- function deriveInferredTableField(opts) {
1475
- var _tables$find;
1476
- var table = opts.table,
1477
- tables = opts.tables,
1478
- field = opts.field,
1479
- typeFilters = opts.typeFilters;
1480
- if (!table) return undefined;
1481
- var schema = tables == null || (_tables$find = tables.find(function (t) {
1482
- return t.identifier === table;
1483
- })) == null ? void 0 : _tables$find.schema;
1484
- var fieldMeta = field ? schema == null ? void 0 : schema.fields.find(function (f) {
1485
- return f.identifier === field;
1486
- }) : schema == null ? void 0 : schema.fields.find(function (f) {
1487
- return (typeFilters != null ? typeFilters : DEFAULT_TYPE_FILTERS).includes(f.type);
1488
- });
1489
- return fieldMeta;
1490
- }
1491
- function assertNever(_) {
1492
- throw new Error("unexpected branch taken");
1493
- }
1494
- function renderValue(value, type, props) {
1495
- switch (type) {
1496
- case "number" /* NUMBER */:
1497
- case "boolean" /* BOOLEAN */:
1498
- case "text" /* TEXT */:
1499
- case "long-text" /* LONG_TEXT */:
1500
- case "date-time" /* DATE_TIME */:
1501
- case "enum" /* ENUM */:
1502
- case "ref" /* REF */:
1503
- return React.createElement("div", Object.assign({}, props), value);
1504
- case "rich-text" /* RICH_TEXT */:
1505
- return React.createElement("div", Object.assign({
1506
- dangerouslySetInnerHTML: {
1507
- __html: value
1508
- },
1509
- style: {
1510
- whiteSpace: "normal"
1511
- }
1512
- }, props));
1513
- case "image" /* IMAGE */:
1514
- if (value && typeof value === "object" && value.url && value.imageMeta) {
1515
- return React.createElement("img", Object.assign({
1516
- src: value.url,
1517
- width: value.imageMeta.width,
1518
- height: value.imageMeta.height
1519
- }, props));
1520
- }
1521
- return null;
1522
- case "file" /* FILE */:
1523
- if (value && typeof value === "object" && value.url && value.name) {
1524
- return React.createElement("a", Object.assign({
1525
- href: value.url,
1526
- target: "_blank"
1527
- }, props), value.name);
1528
- }
1529
- return null;
1530
- default:
1531
- assertNever();
1532
- }
1533
- }
1534
- var cmsRowLinkMeta = {
1535
- name: componentPrefix + "-row-link",
1536
- displayName: "CMS Entry Link",
1537
- importName: "CmsRowLink",
1538
- importPath: modulePath,
1539
- props: {
1540
- children: {
1541
- type: "slot",
1542
- defaultValue: {
1543
- type: "text",
1544
- tag: "a",
1545
- value: "Link"
1546
- }
1547
- },
1548
- table: {
1549
- type: "choice",
1550
- displayName: "Model",
1551
- hidden: function hidden(props, ctx) {
1552
- var _ctx$tables$length3, _ctx$tables3;
1553
- return ((_ctx$tables$length3 = ctx == null || (_ctx$tables3 = ctx.tables) == null ? void 0 : _ctx$tables3.length) != null ? _ctx$tables$length3 : 0) <= 1 && !props.table;
1554
- },
1555
- helpText: "Pick model from a CMS Data Fetcher",
1556
- description: "Usually not used! Only with multiple CMS Data Loaders, use this to choose which to show. Otherwise, go select the CMS Data Loader if you want to load different data.",
1557
- options: function options(_, ctx) {
1558
- return mkTableOptions(ctx == null ? void 0 : ctx.tables);
1559
- },
1560
- defaultValueHint: function defaultValueHint(_, ctx) {
1561
- return ctx == null ? void 0 : ctx.table;
1562
- }
1563
- },
1564
- field: {
1565
- type: "choice",
1566
- displayName: "Field",
1567
- description: "Field (from model schema) to use.",
1568
- options: function options(_ref12, ctx) {
1569
- var _ctx$table4;
1570
- var table = _ref12.table;
1571
- return mkFieldOptions(ctx == null ? void 0 : ctx.tables, (_ctx$table4 = ctx == null ? void 0 : ctx.table) != null ? _ctx$table4 : table);
1572
- },
1573
- defaultValueHint: function defaultValueHint(_, ctx) {
1574
- var _ctx$fieldMeta3, _ctx$fieldMeta4;
1575
- return (ctx == null || (_ctx$fieldMeta3 = ctx.fieldMeta) == null ? void 0 : _ctx$fieldMeta3.name) || (ctx == null || (_ctx$fieldMeta4 = ctx.fieldMeta) == null ? void 0 : _ctx$fieldMeta4.identifier);
1576
- }
1577
- },
1578
- hrefProp: {
1579
- type: "string",
1580
- displayName: '"href" prop',
1581
- description: "Prop to inject into children",
1582
- defaultValue: "href"
1583
- },
1584
- prefix: {
1585
- type: "string",
1586
- displayName: "Optional prefix",
1587
- description: "Prefix to prepend to prop value.",
1588
- hidden: function hidden(_, ctx) {
1589
- var _ctx$fieldMeta5;
1590
- return (ctx == null || (_ctx$fieldMeta5 = ctx.fieldMeta) == null ? void 0 : _ctx$fieldMeta5.type) === "file";
1591
- }
1592
- },
1593
- suffix: {
1594
- type: "string",
1595
- displayName: "Optional suffix",
1596
- description: "Suffix to append to prop value.",
1597
- hidden: function hidden(_, ctx) {
1598
- var _ctx$fieldMeta6;
1599
- return (ctx == null || (_ctx$fieldMeta6 = ctx.fieldMeta) == null ? void 0 : _ctx$fieldMeta6.type) === "file";
1600
- }
1601
- }
1602
- }
1603
- };
1604
- function CmsRowLink(_ref13) {
1605
- var _res$row$data2;
1606
- var table = _ref13.table,
1607
- field = _ref13.field,
1608
- hrefProp = _ref13.hrefProp,
1609
- children = _ref13.children,
1610
- setControlContextData = _ref13.setControlContextData,
1611
- prefix = _ref13.prefix,
1612
- suffix = _ref13.suffix;
1613
- var tables = useTablesWithDataLoaded("rows");
1614
- var res = useRow(tables, table);
1615
- if (!res || !res.row) {
1616
- return React.createElement(React.Fragment, null, children);
1617
- }
1618
- var fieldMeta = deriveInferredTableField({
1619
- table: res.table,
1620
- tables: tables,
1621
- field: field,
1622
- typeFilters: ["file" /* FILE */, "text" /* TEXT */]
1623
- });
1624
- if (tables) {
1625
- // TODO: Only include table if __plasmic_cms_row_{table} exists.
1626
- setControlContextData == null || setControlContextData({
1627
- tables: tables,
1628
- table: res.table,
1629
- row: res.row,
1630
- fieldMeta: fieldMeta
1631
- });
1632
- }
1633
- if (!fieldMeta) {
1634
- return React.createElement(React.Fragment, null, children);
1635
- }
1636
- if (!children) {
1637
- return null;
1638
- }
1639
- var value = ((_res$row$data2 = res.row.data) == null ? void 0 : _res$row$data2[fieldMeta.identifier]) || "";
1640
- var childrenWithProps = React.Children.map(children, function (child) {
1641
- if (React.isValidElement(child)) {
1642
- var _React$cloneElement;
1643
- return React.cloneElement(child, (_React$cloneElement = {}, _React$cloneElement[hrefProp] = fieldMeta.type === "file" /* FILE */ ? value.url : prefix || suffix ? "" + (prefix || "") + value + (suffix || "") : value, _React$cloneElement));
1644
- }
1645
- return child;
1646
- });
1647
- return React.createElement(React.Fragment, null, childrenWithProps != null ? childrenWithProps : null);
1648
- }
1649
- var cmsRowImageMeta = {
1650
- name: componentPrefix + "-row-image",
1651
- displayName: "CMS Entry Image",
1652
- importName: "CmsRowImage",
1653
- importPath: modulePath,
1654
- props: {
1655
- children: {
1656
- type: "slot",
1657
- defaultValue: {
1658
- type: "img",
1659
- src: "https://studio.plasmic.app/static/img/placeholder-full.png"
1660
- }
1661
- },
1662
- table: {
1663
- type: "choice",
1664
- displayName: "Model",
1665
- hidden: function hidden(props, ctx) {
1666
- var _ctx$tables$length4, _ctx$tables4;
1667
- return ((_ctx$tables$length4 = ctx == null || (_ctx$tables4 = ctx.tables) == null ? void 0 : _ctx$tables4.length) != null ? _ctx$tables$length4 : 0) <= 1 && !props.table;
1668
- },
1669
- helpText: "Pick model from a CMS Data Fetcher",
1670
- description: "Usually not used! Only with multiple CMS Data Loaders, use this to choose which to show. Otherwise, go select the CMS Data Loader if you want to load different data.",
1671
- options: function options(_, ctx) {
1672
- return mkTableOptions(ctx == null ? void 0 : ctx.tables);
1673
- },
1674
- defaultValueHint: function defaultValueHint(_, ctx) {
1675
- return ctx == null ? void 0 : ctx.table;
1676
- }
1677
- },
1678
- field: {
1679
- type: "choice",
1680
- displayName: "Field",
1681
- description: "Field (from model schema) to use.",
1682
- options: function options(_ref14, ctx) {
1683
- var _ctx$table5;
1684
- var table = _ref14.table;
1685
- return mkFieldOptions(ctx == null ? void 0 : ctx.tables, (_ctx$table5 = ctx == null ? void 0 : ctx.table) != null ? _ctx$table5 : table, ["image" /* IMAGE */]);
1686
- },
1687
- defaultValueHint: function defaultValueHint(_, ctx) {
1688
- var _ctx$fieldMeta7, _ctx$fieldMeta8;
1689
- return (ctx == null || (_ctx$fieldMeta7 = ctx.fieldMeta) == null ? void 0 : _ctx$fieldMeta7.name) || (ctx == null || (_ctx$fieldMeta8 = ctx.fieldMeta) == null ? void 0 : _ctx$fieldMeta8.identifier);
1690
- }
1691
- },
1692
- srcProp: {
1693
- type: "string",
1694
- displayName: 'Image "src" prop',
1695
- description: "Prop to inject into children",
1696
- defaultValue: "src"
1697
- }
1698
- }
1699
- };
1700
- function CmsRowImage(_ref15) {
1701
- var _res$row$data3;
1702
- var table = _ref15.table,
1703
- field = _ref15.field,
1704
- srcProp = _ref15.srcProp,
1705
- children = _ref15.children,
1706
- setControlContextData = _ref15.setControlContextData;
1707
- var tables = useTablesWithDataLoaded("rows");
1708
- var res = useRow(tables, table);
1709
- if (!res || !res.row) {
1710
- return React.createElement(React.Fragment, null, children);
1711
- }
1712
- var fieldMeta = deriveInferredTableField({
1713
- table: res.table,
1714
- tables: tables,
1715
- field: field,
1716
- typeFilters: ["image" /* IMAGE */]
1717
- });
1718
- if (tables) {
1719
- // TODO: Only include table if __plasmic_cms_row_{table} exists.
1720
- setControlContextData == null || setControlContextData({
1721
- tables: tables,
1722
- table: res.table,
1723
- row: res.row,
1724
- fieldMeta: fieldMeta
1725
- });
1726
- }
1727
- if (!fieldMeta) {
1728
- return React.createElement(React.Fragment, null, children);
1729
- }
1730
- var value = ((_res$row$data3 = res.row.data) == null ? void 0 : _res$row$data3[fieldMeta.identifier]) || "";
1731
- var childrenWithProps = React.Children.map(children, function (child) {
1732
- if (React.isValidElement(child) && value) {
1733
- var _React$cloneElement3;
1734
- if (typeof value === "object" && value.url && value.imageMeta) {
1735
- var _React$cloneElement2;
1736
- return React.cloneElement(child, (_React$cloneElement2 = {}, _React$cloneElement2[srcProp] = {
1737
- src: value.url,
1738
- fullHeight: value.imageMeta.height,
1739
- fullWidth: value.imageMeta.width
1740
- }, _React$cloneElement2));
1741
- }
1742
- return React.cloneElement(child, (_React$cloneElement3 = {}, _React$cloneElement3[srcProp] = value, _React$cloneElement3));
1743
- }
1744
- return child;
1745
- });
1746
- return React.createElement(React.Fragment, null, childrenWithProps);
1747
- }
1748
- var cmsRowFieldValueMeta = {
1749
- name: componentPrefix + "-row-value",
1750
- displayName: "CMS Entry Value",
1751
- importName: "CmsRowFieldValue",
1752
- importPath: modulePath,
1753
- props: {
1754
- children: {
1755
- type: "slot"
1756
- },
1757
- table: {
1758
- type: "choice",
1759
- displayName: "Model",
1760
- hidden: function hidden(props, ctx) {
1761
- var _ctx$tables$length5, _ctx$tables5;
1762
- return ((_ctx$tables$length5 = ctx == null || (_ctx$tables5 = ctx.tables) == null ? void 0 : _ctx$tables5.length) != null ? _ctx$tables$length5 : 0) <= 1 && !props.table;
1763
- },
1764
- helpText: "Pick model from a CMS Data Fetcher",
1765
- description: "Usually not used! Only with multiple CMS Data Loaders, use this to choose which to show. Otherwise, go select the CMS Data Loader if you want to load different data.",
1766
- options: function options(_, ctx) {
1767
- return mkTableOptions(ctx == null ? void 0 : ctx.tables);
1768
- },
1769
- defaultValueHint: function defaultValueHint(_, ctx) {
1770
- return ctx == null ? void 0 : ctx.table;
1771
- }
1772
- },
1773
- field: {
1774
- type: "choice",
1775
- displayName: "Field",
1776
- description: "Field (from model schema) to use.",
1777
- options: function options(_ref16, ctx) {
1778
- var _ctx$table6;
1779
- var table = _ref16.table;
1780
- return mkFieldOptions(ctx == null ? void 0 : ctx.tables, (_ctx$table6 = ctx == null ? void 0 : ctx.table) != null ? _ctx$table6 : table);
1781
- },
1782
- defaultValueHint: function defaultValueHint(_, ctx) {
1783
- var _ctx$fieldMeta9, _ctx$fieldMeta10;
1784
- return (ctx == null || (_ctx$fieldMeta9 = ctx.fieldMeta) == null ? void 0 : _ctx$fieldMeta9.name) || (ctx == null || (_ctx$fieldMeta10 = ctx.fieldMeta) == null ? void 0 : _ctx$fieldMeta10.identifier);
1785
- }
1786
- },
1787
- valueProp: {
1788
- type: "string",
1789
- displayName: "Value prop",
1790
- description: "Prop to inject into children as",
1791
- defaultValue: "children"
1792
- }
1793
- }
1794
- };
1795
- function CmsRowFieldValue(_ref17) {
1796
- var _res$row$data4;
1797
- var table = _ref17.table,
1798
- field = _ref17.field,
1799
- valueProp = _ref17.valueProp,
1800
- children = _ref17.children,
1801
- setControlContextData = _ref17.setControlContextData,
1802
- rest = _objectWithoutPropertiesLoose(_ref17, _excluded3);
1803
- var tables = useTablesWithDataLoaded("rows");
1804
- var res = useRow(tables, table);
1805
- if (!res || !res.row) {
1806
- return React.createElement(React.Fragment, null, children);
1807
- }
1808
- var fieldMeta = deriveInferredTableField({
1809
- table: res.table,
1810
- tables: tables,
1811
- field: field,
1812
- typeFilters: ["text" /* TEXT */]
1813
- });
1814
- if (tables) {
1815
- // TODO: Only include table if __plasmic_cms_row_{table} exists.
1816
- setControlContextData == null || setControlContextData({
1817
- tables: tables,
1818
- table: res.table,
1819
- row: res.row,
1820
- fieldMeta: fieldMeta
1821
- });
1822
- }
1823
- if (!fieldMeta) {
1824
- return React.createElement(React.Fragment, null, children);
1825
- }
1826
- var value = ((_res$row$data4 = res.row.data) == null ? void 0 : _res$row$data4[fieldMeta.identifier]) || "";
1827
- var childrenWithProps = React.Children.map(children, function (child) {
1828
- if (React.isValidElement(child)) {
1829
- var _extends2;
1830
- return React.cloneElement(child, _extends({}, rest, (_extends2 = {}, _extends2[valueProp] = value, _extends2)));
1831
- }
1832
- return child;
1833
- });
1834
- return React.createElement(React.Fragment, null, childrenWithProps);
1835
- }
1836
-
1837
- function registerAll(loader) {
1838
- //const registerContext = loader?.registerContext ?? hostRegisterContext;
1839
- //registerContext(CmsDataProvider, cmsDataProviderMeta);
1840
- var _registerComponent = function _registerComponent(Component, defaultMeta) {
1841
- if (loader) {
1842
- loader.registerComponent(Component, defaultMeta);
1843
- } else {
1844
- registerComponent(Component, defaultMeta);
1845
- }
1846
- };
1847
- var _registerGlobalContext = function _registerGlobalContext(Component, defaultMeta) {
1848
- if (loader) {
1849
- loader.registerGlobalContext(Component, defaultMeta);
1850
- } else {
1851
- registerGlobalContext(Component, defaultMeta);
1852
- }
1853
- };
1854
- _registerGlobalContext(CmsCredentialsProvider, cmsCredentialsProviderMeta);
1855
- _registerComponent(CmsQueryRepeater, cmsQueryRepeaterMeta);
1856
- _registerComponent(CmsRowField, cmsRowFieldMeta);
1857
- _registerComponent(CmsRowLink, cmsRowLinkMeta);
1858
- _registerComponent(CmsRowImage, cmsRowImageMeta);
1859
- _registerComponent(CmsRowFieldValue, cmsRowFieldValueMeta);
1860
- _registerComponent(CmsCount, cmsCountFieldMeta);
1861
- }
1862
-
1863
- exports.API = API;
1864
- exports.CmsCount = CmsCount;
1865
- exports.CmsCredentialsProvider = CmsCredentialsProvider;
1866
- exports.CmsQueryRepeater = CmsQueryRepeater;
1867
- exports.CmsRowField = CmsRowField;
1868
- exports.CmsRowFieldValue = CmsRowFieldValue;
1869
- exports.CmsRowImage = CmsRowImage;
1870
- exports.CmsRowLink = CmsRowLink;
1871
- exports.HttpError = HttpError;
1872
- exports.cmsCountFieldMeta = cmsCountFieldMeta;
1873
- exports.cmsCredentialsProviderMeta = cmsCredentialsProviderMeta;
1874
- exports.cmsQueryRepeaterMeta = cmsQueryRepeaterMeta;
1875
- exports.cmsRowFieldMeta = cmsRowFieldMeta;
1876
- exports.cmsRowFieldValueMeta = cmsRowFieldValueMeta;
1877
- exports.cmsRowImageMeta = cmsRowImageMeta;
1878
- exports.cmsRowLinkMeta = cmsRowLinkMeta;
1879
- exports.mkApi = mkApi;
1880
- exports.registerAll = registerAll;
1881
- //# sourceMappingURL=plasmic-cms.cjs.development.js.map