@plasmicpkgs/plasmic-sanity-io 1.0.154 → 1.0.156
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +52 -0
- package/dist/index.d.ts +52 -7
- package/dist/index.js +531 -5
- package/dist/index.mjs +496 -0
- package/package.json +12 -13
- package/dist/plasmic-sanity-io.cjs.development.js +0 -900
- package/dist/plasmic-sanity-io.cjs.development.js.map +0 -1
- package/dist/plasmic-sanity-io.cjs.production.min.js +0 -2
- package/dist/plasmic-sanity-io.cjs.production.min.js.map +0 -1
- package/dist/plasmic-sanity-io.esm.js +0 -886
- package/dist/plasmic-sanity-io.esm.js.map +0 -1
- package/dist/sanity.d.ts +0 -43
- package/dist/utils.d.ts +0 -4
|
@@ -1,900 +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 client = require('@sanity/client');
|
|
12
|
-
var imageUrlBuilder = _interopDefault(require('@sanity/image-url'));
|
|
13
|
-
var changeCase = require('change-case');
|
|
14
|
-
var get = _interopDefault(require('dlv'));
|
|
15
|
-
var React = require('react');
|
|
16
|
-
var React__default = _interopDefault(React);
|
|
17
|
-
|
|
18
|
-
function _regeneratorRuntime() {
|
|
19
|
-
_regeneratorRuntime = function () {
|
|
20
|
-
return e;
|
|
21
|
-
};
|
|
22
|
-
var t,
|
|
23
|
-
e = {},
|
|
24
|
-
r = Object.prototype,
|
|
25
|
-
n = r.hasOwnProperty,
|
|
26
|
-
o = Object.defineProperty || function (t, e, r) {
|
|
27
|
-
t[e] = r.value;
|
|
28
|
-
},
|
|
29
|
-
i = "function" == typeof Symbol ? Symbol : {},
|
|
30
|
-
a = i.iterator || "@@iterator",
|
|
31
|
-
c = i.asyncIterator || "@@asyncIterator",
|
|
32
|
-
u = i.toStringTag || "@@toStringTag";
|
|
33
|
-
function define(t, e, r) {
|
|
34
|
-
return Object.defineProperty(t, e, {
|
|
35
|
-
value: r,
|
|
36
|
-
enumerable: !0,
|
|
37
|
-
configurable: !0,
|
|
38
|
-
writable: !0
|
|
39
|
-
}), t[e];
|
|
40
|
-
}
|
|
41
|
-
try {
|
|
42
|
-
define({}, "");
|
|
43
|
-
} catch (t) {
|
|
44
|
-
define = function (t, e, r) {
|
|
45
|
-
return t[e] = r;
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
function wrap(t, e, r, n) {
|
|
49
|
-
var i = e && e.prototype instanceof Generator ? e : Generator,
|
|
50
|
-
a = Object.create(i.prototype),
|
|
51
|
-
c = new Context(n || []);
|
|
52
|
-
return o(a, "_invoke", {
|
|
53
|
-
value: makeInvokeMethod(t, r, c)
|
|
54
|
-
}), a;
|
|
55
|
-
}
|
|
56
|
-
function tryCatch(t, e, r) {
|
|
57
|
-
try {
|
|
58
|
-
return {
|
|
59
|
-
type: "normal",
|
|
60
|
-
arg: t.call(e, r)
|
|
61
|
-
};
|
|
62
|
-
} catch (t) {
|
|
63
|
-
return {
|
|
64
|
-
type: "throw",
|
|
65
|
-
arg: t
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
e.wrap = wrap;
|
|
70
|
-
var h = "suspendedStart",
|
|
71
|
-
l = "suspendedYield",
|
|
72
|
-
f = "executing",
|
|
73
|
-
s = "completed",
|
|
74
|
-
y = {};
|
|
75
|
-
function Generator() {}
|
|
76
|
-
function GeneratorFunction() {}
|
|
77
|
-
function GeneratorFunctionPrototype() {}
|
|
78
|
-
var p = {};
|
|
79
|
-
define(p, a, function () {
|
|
80
|
-
return this;
|
|
81
|
-
});
|
|
82
|
-
var d = Object.getPrototypeOf,
|
|
83
|
-
v = d && d(d(values([])));
|
|
84
|
-
v && v !== r && n.call(v, a) && (p = v);
|
|
85
|
-
var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
|
|
86
|
-
function defineIteratorMethods(t) {
|
|
87
|
-
["next", "throw", "return"].forEach(function (e) {
|
|
88
|
-
define(t, e, function (t) {
|
|
89
|
-
return this._invoke(e, t);
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
function AsyncIterator(t, e) {
|
|
94
|
-
function invoke(r, o, i, a) {
|
|
95
|
-
var c = tryCatch(t[r], t, o);
|
|
96
|
-
if ("throw" !== c.type) {
|
|
97
|
-
var u = c.arg,
|
|
98
|
-
h = u.value;
|
|
99
|
-
return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
|
|
100
|
-
invoke("next", t, i, a);
|
|
101
|
-
}, function (t) {
|
|
102
|
-
invoke("throw", t, i, a);
|
|
103
|
-
}) : e.resolve(h).then(function (t) {
|
|
104
|
-
u.value = t, i(u);
|
|
105
|
-
}, function (t) {
|
|
106
|
-
return invoke("throw", t, i, a);
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
a(c.arg);
|
|
110
|
-
}
|
|
111
|
-
var r;
|
|
112
|
-
o(this, "_invoke", {
|
|
113
|
-
value: function (t, n) {
|
|
114
|
-
function callInvokeWithMethodAndArg() {
|
|
115
|
-
return new e(function (e, r) {
|
|
116
|
-
invoke(t, n, e, r);
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
function makeInvokeMethod(e, r, n) {
|
|
124
|
-
var o = h;
|
|
125
|
-
return function (i, a) {
|
|
126
|
-
if (o === f) throw new Error("Generator is already running");
|
|
127
|
-
if (o === s) {
|
|
128
|
-
if ("throw" === i) throw a;
|
|
129
|
-
return {
|
|
130
|
-
value: t,
|
|
131
|
-
done: !0
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
for (n.method = i, n.arg = a;;) {
|
|
135
|
-
var c = n.delegate;
|
|
136
|
-
if (c) {
|
|
137
|
-
var u = maybeInvokeDelegate(c, n);
|
|
138
|
-
if (u) {
|
|
139
|
-
if (u === y) continue;
|
|
140
|
-
return u;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
|
|
144
|
-
if (o === h) throw o = s, n.arg;
|
|
145
|
-
n.dispatchException(n.arg);
|
|
146
|
-
} else "return" === n.method && n.abrupt("return", n.arg);
|
|
147
|
-
o = f;
|
|
148
|
-
var p = tryCatch(e, r, n);
|
|
149
|
-
if ("normal" === p.type) {
|
|
150
|
-
if (o = n.done ? s : l, p.arg === y) continue;
|
|
151
|
-
return {
|
|
152
|
-
value: p.arg,
|
|
153
|
-
done: n.done
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
"throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
function maybeInvokeDelegate(e, r) {
|
|
161
|
-
var n = r.method,
|
|
162
|
-
o = e.iterator[n];
|
|
163
|
-
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;
|
|
164
|
-
var i = tryCatch(o, e.iterator, r.arg);
|
|
165
|
-
if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
|
|
166
|
-
var a = i.arg;
|
|
167
|
-
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);
|
|
168
|
-
}
|
|
169
|
-
function pushTryEntry(t) {
|
|
170
|
-
var e = {
|
|
171
|
-
tryLoc: t[0]
|
|
172
|
-
};
|
|
173
|
-
1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
|
|
174
|
-
}
|
|
175
|
-
function resetTryEntry(t) {
|
|
176
|
-
var e = t.completion || {};
|
|
177
|
-
e.type = "normal", delete e.arg, t.completion = e;
|
|
178
|
-
}
|
|
179
|
-
function Context(t) {
|
|
180
|
-
this.tryEntries = [{
|
|
181
|
-
tryLoc: "root"
|
|
182
|
-
}], t.forEach(pushTryEntry, this), this.reset(!0);
|
|
183
|
-
}
|
|
184
|
-
function values(e) {
|
|
185
|
-
if (e || "" === e) {
|
|
186
|
-
var r = e[a];
|
|
187
|
-
if (r) return r.call(e);
|
|
188
|
-
if ("function" == typeof e.next) return e;
|
|
189
|
-
if (!isNaN(e.length)) {
|
|
190
|
-
var o = -1,
|
|
191
|
-
i = function next() {
|
|
192
|
-
for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
|
|
193
|
-
return next.value = t, next.done = !0, next;
|
|
194
|
-
};
|
|
195
|
-
return i.next = i;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
throw new TypeError(typeof e + " is not iterable");
|
|
199
|
-
}
|
|
200
|
-
return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
|
|
201
|
-
value: GeneratorFunctionPrototype,
|
|
202
|
-
configurable: !0
|
|
203
|
-
}), o(GeneratorFunctionPrototype, "constructor", {
|
|
204
|
-
value: GeneratorFunction,
|
|
205
|
-
configurable: !0
|
|
206
|
-
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
|
|
207
|
-
var e = "function" == typeof t && t.constructor;
|
|
208
|
-
return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
|
|
209
|
-
}, e.mark = function (t) {
|
|
210
|
-
return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
|
|
211
|
-
}, e.awrap = function (t) {
|
|
212
|
-
return {
|
|
213
|
-
__await: t
|
|
214
|
-
};
|
|
215
|
-
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
|
|
216
|
-
return this;
|
|
217
|
-
}), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
|
|
218
|
-
void 0 === i && (i = Promise);
|
|
219
|
-
var a = new AsyncIterator(wrap(t, r, n, o), i);
|
|
220
|
-
return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
|
|
221
|
-
return t.done ? t.value : a.next();
|
|
222
|
-
});
|
|
223
|
-
}, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
|
|
224
|
-
return this;
|
|
225
|
-
}), define(g, "toString", function () {
|
|
226
|
-
return "[object Generator]";
|
|
227
|
-
}), e.keys = function (t) {
|
|
228
|
-
var e = Object(t),
|
|
229
|
-
r = [];
|
|
230
|
-
for (var n in e) r.push(n);
|
|
231
|
-
return r.reverse(), function next() {
|
|
232
|
-
for (; r.length;) {
|
|
233
|
-
var t = r.pop();
|
|
234
|
-
if (t in e) return next.value = t, next.done = !1, next;
|
|
235
|
-
}
|
|
236
|
-
return next.done = !0, next;
|
|
237
|
-
};
|
|
238
|
-
}, e.values = values, Context.prototype = {
|
|
239
|
-
constructor: Context,
|
|
240
|
-
reset: function (e) {
|
|
241
|
-
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);
|
|
242
|
-
},
|
|
243
|
-
stop: function () {
|
|
244
|
-
this.done = !0;
|
|
245
|
-
var t = this.tryEntries[0].completion;
|
|
246
|
-
if ("throw" === t.type) throw t.arg;
|
|
247
|
-
return this.rval;
|
|
248
|
-
},
|
|
249
|
-
dispatchException: function (e) {
|
|
250
|
-
if (this.done) throw e;
|
|
251
|
-
var r = this;
|
|
252
|
-
function handle(n, o) {
|
|
253
|
-
return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
|
|
254
|
-
}
|
|
255
|
-
for (var o = this.tryEntries.length - 1; o >= 0; --o) {
|
|
256
|
-
var i = this.tryEntries[o],
|
|
257
|
-
a = i.completion;
|
|
258
|
-
if ("root" === i.tryLoc) return handle("end");
|
|
259
|
-
if (i.tryLoc <= this.prev) {
|
|
260
|
-
var c = n.call(i, "catchLoc"),
|
|
261
|
-
u = n.call(i, "finallyLoc");
|
|
262
|
-
if (c && u) {
|
|
263
|
-
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
264
|
-
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
265
|
-
} else if (c) {
|
|
266
|
-
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
267
|
-
} else {
|
|
268
|
-
if (!u) throw new Error("try statement without catch or finally");
|
|
269
|
-
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
},
|
|
274
|
-
abrupt: function (t, e) {
|
|
275
|
-
for (var r = this.tryEntries.length - 1; r >= 0; --r) {
|
|
276
|
-
var o = this.tryEntries[r];
|
|
277
|
-
if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
|
|
278
|
-
var i = o;
|
|
279
|
-
break;
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
|
|
283
|
-
var a = i ? i.completion : {};
|
|
284
|
-
return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
|
|
285
|
-
},
|
|
286
|
-
complete: function (t, e) {
|
|
287
|
-
if ("throw" === t.type) throw t.arg;
|
|
288
|
-
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;
|
|
289
|
-
},
|
|
290
|
-
finish: function (t) {
|
|
291
|
-
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
292
|
-
var r = this.tryEntries[e];
|
|
293
|
-
if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
|
|
294
|
-
}
|
|
295
|
-
},
|
|
296
|
-
catch: function (t) {
|
|
297
|
-
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
298
|
-
var r = this.tryEntries[e];
|
|
299
|
-
if (r.tryLoc === t) {
|
|
300
|
-
var n = r.completion;
|
|
301
|
-
if ("throw" === n.type) {
|
|
302
|
-
var o = n.arg;
|
|
303
|
-
resetTryEntry(r);
|
|
304
|
-
}
|
|
305
|
-
return o;
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
throw new Error("illegal catch attempt");
|
|
309
|
-
},
|
|
310
|
-
delegateYield: function (e, r, n) {
|
|
311
|
-
return this.delegate = {
|
|
312
|
-
iterator: values(e),
|
|
313
|
-
resultName: r,
|
|
314
|
-
nextLoc: n
|
|
315
|
-
}, "next" === this.method && (this.arg = t), y;
|
|
316
|
-
}
|
|
317
|
-
}, e;
|
|
318
|
-
}
|
|
319
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
320
|
-
try {
|
|
321
|
-
var info = gen[key](arg);
|
|
322
|
-
var value = info.value;
|
|
323
|
-
} catch (error) {
|
|
324
|
-
reject(error);
|
|
325
|
-
return;
|
|
326
|
-
}
|
|
327
|
-
if (info.done) {
|
|
328
|
-
resolve(value);
|
|
329
|
-
} else {
|
|
330
|
-
Promise.resolve(value).then(_next, _throw);
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
function _asyncToGenerator(fn) {
|
|
334
|
-
return function () {
|
|
335
|
-
var self = this,
|
|
336
|
-
args = arguments;
|
|
337
|
-
return new Promise(function (resolve, reject) {
|
|
338
|
-
var gen = fn.apply(self, args);
|
|
339
|
-
function _next(value) {
|
|
340
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
341
|
-
}
|
|
342
|
-
function _throw(err) {
|
|
343
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
344
|
-
}
|
|
345
|
-
_next(undefined);
|
|
346
|
-
});
|
|
347
|
-
};
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
var filterParameters = [{
|
|
351
|
-
value: '==',
|
|
352
|
-
label: 'Is'
|
|
353
|
-
}, {
|
|
354
|
-
value: '!=',
|
|
355
|
-
label: 'Is not'
|
|
356
|
-
}, {
|
|
357
|
-
value: '>',
|
|
358
|
-
label: 'Greater than'
|
|
359
|
-
}, {
|
|
360
|
-
value: '<',
|
|
361
|
-
label: 'Less than'
|
|
362
|
-
}, {
|
|
363
|
-
value: '<=',
|
|
364
|
-
label: 'Less than or equal'
|
|
365
|
-
}, {
|
|
366
|
-
value: '>=',
|
|
367
|
-
label: 'Greater than or equal '
|
|
368
|
-
}];
|
|
369
|
-
|
|
370
|
-
function ensure(x) {
|
|
371
|
-
if (x === null || x === undefined) {
|
|
372
|
-
throw new Error("Value must not be undefined or null");
|
|
373
|
-
} else {
|
|
374
|
-
return x;
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
var modulePath = "@plasmicpkgs/plasmic-sanity-io";
|
|
378
|
-
var makeDataProviderName = function makeDataProviderName(docType) {
|
|
379
|
-
return "currentSanity" + changeCase.pascalCase(docType) + "Item";
|
|
380
|
-
};
|
|
381
|
-
function makeSanityClient(creds) {
|
|
382
|
-
var sanity = client.createClient({
|
|
383
|
-
projectId: creds.projectId,
|
|
384
|
-
dataset: creds.dataset,
|
|
385
|
-
apiVersion: creds.apiVersion ? creds.apiVersion : "v1",
|
|
386
|
-
token: creds.token,
|
|
387
|
-
useCdn: creds.useCdn
|
|
388
|
-
});
|
|
389
|
-
return sanity;
|
|
390
|
-
}
|
|
391
|
-
var CredentialsContext = /*#__PURE__*/React__default.createContext(undefined);
|
|
392
|
-
var sanityCredentialsProviderMeta = {
|
|
393
|
-
name: "SanityCredentialsProvider",
|
|
394
|
-
displayName: "Sanity Credentials Provider",
|
|
395
|
-
description: "Get your project ID, dataset, and token [here](https://www.sanity.io/manage).\n\nAdd 'https://host.plasmicdev.com' (or your app host origin) as an authorized host in the CORS origins section of your Sanity project.\n\n[See tutorial video](https://www.youtube.com/watch?v=dLeu7I4RsYg).",
|
|
396
|
-
importName: "SanityCredentialsProvider",
|
|
397
|
-
importPath: modulePath,
|
|
398
|
-
props: {
|
|
399
|
-
projectId: {
|
|
400
|
-
type: "string",
|
|
401
|
-
displayName: "Project ID",
|
|
402
|
-
defaultValueHint: "b2gfz67v",
|
|
403
|
-
defaultValue: "b2gfz67v",
|
|
404
|
-
description: "The ID of the project to use."
|
|
405
|
-
},
|
|
406
|
-
dataset: {
|
|
407
|
-
type: "string",
|
|
408
|
-
displayName: "Dataset",
|
|
409
|
-
defaultValueHint: "production",
|
|
410
|
-
defaultValue: "production",
|
|
411
|
-
description: "The dataset to use."
|
|
412
|
-
},
|
|
413
|
-
apiVersion: {
|
|
414
|
-
type: "string",
|
|
415
|
-
displayName: "API Version",
|
|
416
|
-
defaultValueHint: "v1",
|
|
417
|
-
description: "The API version to use (if not set, 'v1' will be used) - see https://www.sanity.io/docs/js-client#specifying-api-version."
|
|
418
|
-
},
|
|
419
|
-
token: {
|
|
420
|
-
type: "string",
|
|
421
|
-
displayName: "Token",
|
|
422
|
-
description: "The token to use (or leave blank for unauthenticated usage) - you can create tokens in the API section of your project (i.e. https://www.sanity.io/manage/personal/project/PROJECT_ID/api#tokens)."
|
|
423
|
-
},
|
|
424
|
-
useCdn: {
|
|
425
|
-
type: "boolean",
|
|
426
|
-
displayName: "Use CDN?",
|
|
427
|
-
defaultValueHint: false,
|
|
428
|
-
description: "Whether you want to use CDN ('false' if you want to ensure fresh data)."
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
};
|
|
432
|
-
function SanityCredentialsProvider(_ref) {
|
|
433
|
-
var projectId = _ref.projectId,
|
|
434
|
-
dataset = _ref.dataset,
|
|
435
|
-
apiVersion = _ref.apiVersion,
|
|
436
|
-
token = _ref.token,
|
|
437
|
-
useCdn = _ref.useCdn,
|
|
438
|
-
children = _ref.children;
|
|
439
|
-
return React__default.createElement(CredentialsContext.Provider, {
|
|
440
|
-
value: {
|
|
441
|
-
projectId: projectId,
|
|
442
|
-
dataset: dataset,
|
|
443
|
-
apiVersion: apiVersion,
|
|
444
|
-
token: token,
|
|
445
|
-
useCdn: useCdn
|
|
446
|
-
}
|
|
447
|
-
}, children);
|
|
448
|
-
}
|
|
449
|
-
var sanityFetcherMeta = {
|
|
450
|
-
name: "SanityFetcher",
|
|
451
|
-
displayName: "Sanity Fetcher",
|
|
452
|
-
importName: "SanityFetcher",
|
|
453
|
-
importPath: modulePath,
|
|
454
|
-
providesData: true,
|
|
455
|
-
description: "Fetches Sanity data of a given collection, and repeats `children` slot content for each row fetched.\n\n[See tutorial video](https://www.youtube.com/watch?v=1SLoVY3hkQ4) and [GROQ cheat sheet](https://www.sanity.io/docs/query-cheat-sheet).",
|
|
456
|
-
defaultStyles: {
|
|
457
|
-
display: "grid",
|
|
458
|
-
gridTemplateColumns: "1fr 1fr 1fr 1fr",
|
|
459
|
-
gridRowGap: "8px",
|
|
460
|
-
gridColumnGap: "8px",
|
|
461
|
-
padding: "8px",
|
|
462
|
-
maxWidth: "100%"
|
|
463
|
-
},
|
|
464
|
-
props: {
|
|
465
|
-
children: {
|
|
466
|
-
type: "slot",
|
|
467
|
-
defaultValue: {
|
|
468
|
-
type: "vbox",
|
|
469
|
-
styles: {
|
|
470
|
-
padding: "8px"
|
|
471
|
-
},
|
|
472
|
-
children: {
|
|
473
|
-
type: "component",
|
|
474
|
-
name: "SanityField"
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
},
|
|
478
|
-
groq: {
|
|
479
|
-
type: "string",
|
|
480
|
-
displayName: "GROQ",
|
|
481
|
-
description: "Query in GROQ.",
|
|
482
|
-
defaultValueHint: "*[_type == 'movie']",
|
|
483
|
-
// Hide this if there's no groq, AND there's docType, so we're in
|
|
484
|
-
// "docType" mode
|
|
485
|
-
hidden: function hidden(props) {
|
|
486
|
-
return !props.groq && !!props.docType;
|
|
487
|
-
}
|
|
488
|
-
},
|
|
489
|
-
docType: {
|
|
490
|
-
type: "choice",
|
|
491
|
-
options: function options(props, ctx) {
|
|
492
|
-
var _ctx$docTypes;
|
|
493
|
-
return (_ctx$docTypes = ctx == null ? void 0 : ctx.docTypes) != null ? _ctx$docTypes : [];
|
|
494
|
-
},
|
|
495
|
-
displayName: "Document type",
|
|
496
|
-
description: "Document type to be queried (*[_type == DOC_TYPE] shortcut).",
|
|
497
|
-
// Hide this if groq is specified, as groq always takes precedence
|
|
498
|
-
hidden: function hidden(props) {
|
|
499
|
-
return !!props.groq;
|
|
500
|
-
}
|
|
501
|
-
},
|
|
502
|
-
filterField: {
|
|
503
|
-
type: "choice",
|
|
504
|
-
displayName: "Filter field",
|
|
505
|
-
description: "Field (from Collection) to filter by",
|
|
506
|
-
options: function options(props, ctx) {
|
|
507
|
-
var _ctx$sanityFields;
|
|
508
|
-
return (_ctx$sanityFields = ctx == null ? void 0 : ctx.sanityFields) != null ? _ctx$sanityFields : [];
|
|
509
|
-
},
|
|
510
|
-
// Hide this if there's groq (so we're just using groq), or if there's
|
|
511
|
-
// no docType selected yet
|
|
512
|
-
hidden: function hidden(props, ctx) {
|
|
513
|
-
return !!props.groq || !props.docType;
|
|
514
|
-
}
|
|
515
|
-
},
|
|
516
|
-
filterParameter: {
|
|
517
|
-
type: "choice",
|
|
518
|
-
displayName: "Filter Operation",
|
|
519
|
-
description: "Filter Option to filter by. Read more (https://www.sanity.io/docs/groq-operators#3b7211e976f6)",
|
|
520
|
-
options: function options(props, ctx) {
|
|
521
|
-
var _ctx$queryOptions;
|
|
522
|
-
return (_ctx$queryOptions = ctx == null ? void 0 : ctx.queryOptions) != null ? _ctx$queryOptions : [];
|
|
523
|
-
},
|
|
524
|
-
// Hide if in groq mode, or if no filter field is selected yet
|
|
525
|
-
hidden: function hidden(props, ctx) {
|
|
526
|
-
return !!props.groq || !props.filterField;
|
|
527
|
-
}
|
|
528
|
-
},
|
|
529
|
-
filterValue: {
|
|
530
|
-
type: "string",
|
|
531
|
-
displayName: "Filter value",
|
|
532
|
-
description: "Value to filter by, should be of filter field type",
|
|
533
|
-
// Hide if in groq mode, or if no filter field is selected yet
|
|
534
|
-
hidden: function hidden(props, ctx) {
|
|
535
|
-
return !!props.groq || !props.filterField;
|
|
536
|
-
}
|
|
537
|
-
},
|
|
538
|
-
limit: {
|
|
539
|
-
type: "string",
|
|
540
|
-
displayName: "Limit",
|
|
541
|
-
description: "Limit",
|
|
542
|
-
// Hide if in groq mode
|
|
543
|
-
hidden: function hidden(props) {
|
|
544
|
-
return !!props.groq || !props.docType;
|
|
545
|
-
}
|
|
546
|
-
},
|
|
547
|
-
noAutoRepeat: {
|
|
548
|
-
type: "boolean",
|
|
549
|
-
displayName: "No auto-repeat",
|
|
550
|
-
description: "Do not automatically repeat children for every category.",
|
|
551
|
-
defaultValue: false
|
|
552
|
-
},
|
|
553
|
-
noLayout: {
|
|
554
|
-
type: "boolean",
|
|
555
|
-
displayName: "No layout",
|
|
556
|
-
description: "When set, Sanity Fetcher 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.",
|
|
557
|
-
defaultValue: false
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
};
|
|
561
|
-
function SanityFetcher(_ref2) {
|
|
562
|
-
var _allDataTypes$data;
|
|
563
|
-
var groq = _ref2.groq,
|
|
564
|
-
docType = _ref2.docType,
|
|
565
|
-
filterField = _ref2.filterField,
|
|
566
|
-
filterValue = _ref2.filterValue,
|
|
567
|
-
filterParameter = _ref2.filterParameter,
|
|
568
|
-
limit = _ref2.limit,
|
|
569
|
-
noAutoRepeat = _ref2.noAutoRepeat,
|
|
570
|
-
children = _ref2.children,
|
|
571
|
-
className = _ref2.className,
|
|
572
|
-
noLayout = _ref2.noLayout,
|
|
573
|
-
setControlContextData = _ref2.setControlContextData;
|
|
574
|
-
var projectIdRegex = new RegExp(/^[-a-z0-9]+$/i);
|
|
575
|
-
var datasetRegex = new RegExp(/^(~[a-z0-9]{1}[-\w]{0,63}|[a-z0-9]{1}[-\w]{0,63})$/);
|
|
576
|
-
var dateRegex = new RegExp(/^\d{4}-\d{2}-\d{2}$/);
|
|
577
|
-
var creds = ensure(React.useContext(CredentialsContext));
|
|
578
|
-
if (!creds.projectId || !projectIdRegex.test(creds.projectId)) {
|
|
579
|
-
return React__default.createElement("div", {
|
|
580
|
-
className: className
|
|
581
|
-
}, "Please specify a valid projectId, it can only contain only a-z, 0-9 and dashes.");
|
|
582
|
-
} else if (!creds.dataset || !datasetRegex.test(creds.dataset)) {
|
|
583
|
-
return React__default.createElement("div", {
|
|
584
|
-
className: className
|
|
585
|
-
}, "Please specify a valid dataset, they can only contain lowercase characters, numbers, underscores and dashes, and start with tilde, and be maximum 64 characters.");
|
|
586
|
-
} else if (creds.apiVersion) {
|
|
587
|
-
if (creds.apiVersion !== "v1" && creds.apiVersion !== "1" && creds.apiVersion !== "X") {
|
|
588
|
-
var date = new Date(creds.apiVersion);
|
|
589
|
-
if (!(dateRegex.test(creds.apiVersion) && date instanceof Date && date.getTime() > 0)) {
|
|
590
|
-
return React__default.createElement("div", {
|
|
591
|
-
className: className
|
|
592
|
-
}, "Please specify a valid API version, expected `v1`, `1` or date in format `YYYY-MM-DD`.");
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
}
|
|
596
|
-
var filterUniqueDocTypes = function filterUniqueDocTypes(records) {
|
|
597
|
-
return records.map(function (record) {
|
|
598
|
-
return record._type;
|
|
599
|
-
}).reduce(function (acc, type) {
|
|
600
|
-
if (!acc.includes(type)) {
|
|
601
|
-
acc.push(type);
|
|
602
|
-
}
|
|
603
|
-
return acc;
|
|
604
|
-
}, []);
|
|
605
|
-
};
|
|
606
|
-
var allDataTypes = query.usePlasmicQueryData(JSON.stringify(creds) + "/SANITY_DOCTYPES", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
607
|
-
var sanity, resp;
|
|
608
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
609
|
-
while (1) switch (_context.prev = _context.next) {
|
|
610
|
-
case 0:
|
|
611
|
-
sanity = makeSanityClient(creds);
|
|
612
|
-
_context.next = 3;
|
|
613
|
-
return sanity.fetch("*{_type}").then(filterUniqueDocTypes);
|
|
614
|
-
case 3:
|
|
615
|
-
resp = _context.sent;
|
|
616
|
-
return _context.abrupt("return", resp);
|
|
617
|
-
case 5:
|
|
618
|
-
case "end":
|
|
619
|
-
return _context.stop();
|
|
620
|
-
}
|
|
621
|
-
}, _callee);
|
|
622
|
-
})));
|
|
623
|
-
var docTypes = (_allDataTypes$data = allDataTypes.data) != null ? _allDataTypes$data : false;
|
|
624
|
-
var hasFilter = !!docType && !!filterField && !!filterParameter && !!filterValue;
|
|
625
|
-
var generateUnfilteredGroq = function generateUnfilteredGroq() {
|
|
626
|
-
if (groq) {
|
|
627
|
-
console.log("ORIG GROQ", groq);
|
|
628
|
-
return groq;
|
|
629
|
-
} else if (docType) {
|
|
630
|
-
var query = "*[_type=='" + docType + "']";
|
|
631
|
-
if (hasFilter) {
|
|
632
|
-
// Ask for only a small sample, so we know how to generate the filter
|
|
633
|
-
query += "[0...10]";
|
|
634
|
-
} else if (limit) {
|
|
635
|
-
query += "[0..." + limit + "]";
|
|
636
|
-
}
|
|
637
|
-
console.log("UNFILTERED GROQ", query);
|
|
638
|
-
return query;
|
|
639
|
-
} else {
|
|
640
|
-
return null;
|
|
641
|
-
}
|
|
642
|
-
};
|
|
643
|
-
var unfilteredQuery = generateUnfilteredGroq();
|
|
644
|
-
var sanity = makeSanityClient(creds);
|
|
645
|
-
var _usePlasmicQueryData = query.usePlasmicQueryData(unfilteredQuery ? JSON.stringify({
|
|
646
|
-
fullQuery: unfilteredQuery,
|
|
647
|
-
creds: creds
|
|
648
|
-
}) : null, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
649
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
650
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
651
|
-
case 0:
|
|
652
|
-
return _context2.abrupt("return", sanity.fetch(unfilteredQuery));
|
|
653
|
-
case 1:
|
|
654
|
-
case "end":
|
|
655
|
-
return _context2.stop();
|
|
656
|
-
}
|
|
657
|
-
}, _callee2);
|
|
658
|
-
}))),
|
|
659
|
-
unfilteredData = _usePlasmicQueryData.data;
|
|
660
|
-
var generateFilteredQuery = function generateFilteredQuery() {
|
|
661
|
-
if (!hasFilter || !unfilteredData) {
|
|
662
|
-
return null;
|
|
663
|
-
}
|
|
664
|
-
var fieldValues = Object.values(unfilteredData).flatMap(function (model) {
|
|
665
|
-
return Array.isArray(model) ? model : [model];
|
|
666
|
-
}).map(function (item) {
|
|
667
|
-
var field = Object.entries(item).find(function (el) {
|
|
668
|
-
return el[0] === filterField;
|
|
669
|
-
});
|
|
670
|
-
return field == null ? void 0 : field[1];
|
|
671
|
-
});
|
|
672
|
-
var query = "*[_type=='" + docType + "'";
|
|
673
|
-
if (fieldValues.some(function (v) {
|
|
674
|
-
return typeof v === "string";
|
|
675
|
-
})) {
|
|
676
|
-
query = query + " && " + filterField + " " + filterParameter + " \"" + filterValue + "\"";
|
|
677
|
-
} else {
|
|
678
|
-
query = query + " && " + filterField + " " + filterParameter + " " + filterValue;
|
|
679
|
-
}
|
|
680
|
-
if (limit) {
|
|
681
|
-
query = query + "][0..." + limit + "]";
|
|
682
|
-
} else {
|
|
683
|
-
query = query + "]";
|
|
684
|
-
}
|
|
685
|
-
console.log("FILTERED GROQ", query);
|
|
686
|
-
return query;
|
|
687
|
-
};
|
|
688
|
-
var filteredQuery = generateFilteredQuery();
|
|
689
|
-
var _usePlasmicQueryData2 = query.usePlasmicQueryData(filteredQuery ? JSON.stringify({
|
|
690
|
-
filteredQuery: filteredQuery,
|
|
691
|
-
creds: creds
|
|
692
|
-
}) : null, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
693
|
-
var resp;
|
|
694
|
-
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
695
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
696
|
-
case 0:
|
|
697
|
-
_context3.next = 2;
|
|
698
|
-
return sanity.fetch(filteredQuery);
|
|
699
|
-
case 2:
|
|
700
|
-
resp = _context3.sent;
|
|
701
|
-
return _context3.abrupt("return", resp);
|
|
702
|
-
case 4:
|
|
703
|
-
case "end":
|
|
704
|
-
return _context3.stop();
|
|
705
|
-
}
|
|
706
|
-
}, _callee3);
|
|
707
|
-
}))),
|
|
708
|
-
filteredData = _usePlasmicQueryData2.data;
|
|
709
|
-
if (!docTypes) {
|
|
710
|
-
return React__default.createElement("div", {
|
|
711
|
-
className: className
|
|
712
|
-
}, "Please configure the Sanity provider with a valid projectId, dataset, and token (if necessary). Don't forget to add 'https://host.plasmicdev.com' as an authorized host on the CORS origins section of your project.");
|
|
713
|
-
}
|
|
714
|
-
setControlContextData == null || setControlContextData({
|
|
715
|
-
docTypes: docTypes
|
|
716
|
-
});
|
|
717
|
-
if (!groq && !docType) {
|
|
718
|
-
return React__default.createElement("div", {
|
|
719
|
-
className: className
|
|
720
|
-
}, "Please specify a valid GROQ query or select a Document type.");
|
|
721
|
-
}
|
|
722
|
-
if (!unfilteredData) {
|
|
723
|
-
return React__default.createElement("div", {
|
|
724
|
-
className: className
|
|
725
|
-
}, "Loading...");
|
|
726
|
-
}
|
|
727
|
-
var sanityFields = unfilteredData.map(function (item) {
|
|
728
|
-
var fields = Object.keys(item).filter(function (field) {
|
|
729
|
-
var value = get(item, field);
|
|
730
|
-
return typeof value !== "object" && value._type !== "image" && typeof value === "number" || typeof value === "string" && !value.match(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/);
|
|
731
|
-
});
|
|
732
|
-
return fields;
|
|
733
|
-
});
|
|
734
|
-
var operators;
|
|
735
|
-
var matchedFields = Object.values(unfilteredData).flatMap(function (model) {
|
|
736
|
-
return Array.isArray(model) ? model : [model];
|
|
737
|
-
}).map(function (item) {
|
|
738
|
-
var fields = Object.entries(item).find(function (el) {
|
|
739
|
-
return el[0] === filterField;
|
|
740
|
-
});
|
|
741
|
-
return fields;
|
|
742
|
-
});
|
|
743
|
-
Object.values(matchedFields).map(function (model) {
|
|
744
|
-
return Array.isArray(model) ? model : [model];
|
|
745
|
-
}).map(function (item) {
|
|
746
|
-
if (typeof item[1] === "number" && typeof item[1] !== "object") {
|
|
747
|
-
operators = filterParameters;
|
|
748
|
-
} else if (typeof item[1] !== "number" && typeof item[1] !== "object" && typeof item[1] === "string") {
|
|
749
|
-
operators = [{
|
|
750
|
-
value: "==",
|
|
751
|
-
label: "Equals"
|
|
752
|
-
}, {
|
|
753
|
-
value: "!=",
|
|
754
|
-
label: "Not equals"
|
|
755
|
-
}];
|
|
756
|
-
}
|
|
757
|
-
});
|
|
758
|
-
setControlContextData == null || setControlContextData({
|
|
759
|
-
queryOptions: operators,
|
|
760
|
-
docTypes: docTypes,
|
|
761
|
-
sanityFields: sanityFields[0]
|
|
762
|
-
});
|
|
763
|
-
if (hasFilter) {
|
|
764
|
-
if (!filterParameter) {
|
|
765
|
-
return React__default.createElement("div", {
|
|
766
|
-
className: className
|
|
767
|
-
}, "Please specify a filter operation");
|
|
768
|
-
}
|
|
769
|
-
if (!filterValue) {
|
|
770
|
-
return React__default.createElement("div", {
|
|
771
|
-
className: className
|
|
772
|
-
}, "Please specify a filter value");
|
|
773
|
-
}
|
|
774
|
-
}
|
|
775
|
-
if (hasFilter && !filteredData) {
|
|
776
|
-
return React__default.createElement("div", {
|
|
777
|
-
className: className
|
|
778
|
-
}, "Loading...");
|
|
779
|
-
}
|
|
780
|
-
var resultData = hasFilter ? filteredData : unfilteredData;
|
|
781
|
-
var imageBuilder = imageUrlBuilder(sanity);
|
|
782
|
-
var repElements = noAutoRepeat ? children : resultData.map(function (item, index) {
|
|
783
|
-
Object.keys(item).forEach(function (field) {
|
|
784
|
-
if (item[field]._type === "image") {
|
|
785
|
-
item[field].imgUrl = imageBuilder.image(item[field]).ignoreImageParams().toString();
|
|
786
|
-
}
|
|
787
|
-
});
|
|
788
|
-
return docType ? React__default.createElement(host.DataProvider, {
|
|
789
|
-
key: item._id,
|
|
790
|
-
name: "sanityItem",
|
|
791
|
-
data: item,
|
|
792
|
-
hidden: true
|
|
793
|
-
}, React__default.createElement(host.DataProvider, {
|
|
794
|
-
name: makeDataProviderName(docType),
|
|
795
|
-
data: item
|
|
796
|
-
}, host.repeatedElement(index, children))) : React__default.createElement(host.DataProvider, {
|
|
797
|
-
key: item._id,
|
|
798
|
-
name: "sanityItem",
|
|
799
|
-
data: item
|
|
800
|
-
}, host.repeatedElement(index, children));
|
|
801
|
-
});
|
|
802
|
-
return React__default.createElement(host.DataProvider, {
|
|
803
|
-
name: "sanityItems",
|
|
804
|
-
data: resultData
|
|
805
|
-
}, noLayout ? React__default.createElement(React__default.Fragment, null, " ", repElements, " ") : React__default.createElement("div", {
|
|
806
|
-
className: className
|
|
807
|
-
}, " ", repElements, " "));
|
|
808
|
-
}
|
|
809
|
-
var sanityFieldMeta = {
|
|
810
|
-
name: "SanityField",
|
|
811
|
-
displayName: "Sanity Field",
|
|
812
|
-
importName: "SanityField",
|
|
813
|
-
importPath: modulePath,
|
|
814
|
-
props: {
|
|
815
|
-
path: {
|
|
816
|
-
type: "string",
|
|
817
|
-
displayName: "Path",
|
|
818
|
-
description: "Field path - see https://www.sanity.io/docs/ids.",
|
|
819
|
-
defaultValueHint: "castMembers.0._key"
|
|
820
|
-
},
|
|
821
|
-
field: {
|
|
822
|
-
type: "choice",
|
|
823
|
-
options: function options(props, ctx) {
|
|
824
|
-
var _ctx$fields;
|
|
825
|
-
return (_ctx$fields = ctx == null ? void 0 : ctx.fields) != null ? _ctx$fields : [];
|
|
826
|
-
},
|
|
827
|
-
displayName: "Field",
|
|
828
|
-
description: "Field to be displayed."
|
|
829
|
-
}
|
|
830
|
-
}
|
|
831
|
-
};
|
|
832
|
-
function SanityField(_ref6) {
|
|
833
|
-
var className = _ref6.className,
|
|
834
|
-
path = _ref6.path,
|
|
835
|
-
field = _ref6.field,
|
|
836
|
-
setControlContextData = _ref6.setControlContextData;
|
|
837
|
-
var item = host.useSelector("sanityItem");
|
|
838
|
-
if (!item) {
|
|
839
|
-
return React__default.createElement("div", null, "SanityField must be used within a SanityFetcher");
|
|
840
|
-
}
|
|
841
|
-
// Getting only fields that aren't objects
|
|
842
|
-
var displayableFields = Object.keys(item).filter(function (field) {
|
|
843
|
-
var value = get(item, field);
|
|
844
|
-
return typeof value !== "object" || value._type === "image";
|
|
845
|
-
});
|
|
846
|
-
setControlContextData == null || setControlContextData({
|
|
847
|
-
fields: displayableFields,
|
|
848
|
-
isImage: false
|
|
849
|
-
});
|
|
850
|
-
if (!path && !field) {
|
|
851
|
-
return React__default.createElement("div", null, "Please specify a valid path or select a field.");
|
|
852
|
-
}
|
|
853
|
-
if (!path) {
|
|
854
|
-
path = field;
|
|
855
|
-
}
|
|
856
|
-
var data = get(item, path);
|
|
857
|
-
setControlContextData == null || setControlContextData({
|
|
858
|
-
fields: displayableFields,
|
|
859
|
-
isImage: (data == null ? void 0 : data._type) == "image"
|
|
860
|
-
});
|
|
861
|
-
if (!data) {
|
|
862
|
-
return React__default.createElement("div", null, "Please specify a valid path.");
|
|
863
|
-
} else if ((data == null ? void 0 : data._type) === "image") {
|
|
864
|
-
return React__default.createElement("img", {
|
|
865
|
-
className: className,
|
|
866
|
-
src: data.imgUrl
|
|
867
|
-
});
|
|
868
|
-
} else {
|
|
869
|
-
return React__default.createElement("div", {
|
|
870
|
-
className: className
|
|
871
|
-
}, data);
|
|
872
|
-
}
|
|
873
|
-
}
|
|
874
|
-
|
|
875
|
-
function registerAll(loader) {
|
|
876
|
-
var _registerComponent = function _registerComponent(Component, defaultMeta) {
|
|
877
|
-
if (loader) {
|
|
878
|
-
loader.registerComponent(Component, defaultMeta);
|
|
879
|
-
} else {
|
|
880
|
-
registerComponent(Component, defaultMeta);
|
|
881
|
-
}
|
|
882
|
-
};
|
|
883
|
-
if (loader) {
|
|
884
|
-
loader.registerGlobalContext(SanityCredentialsProvider, sanityCredentialsProviderMeta);
|
|
885
|
-
} else {
|
|
886
|
-
registerGlobalContext(SanityCredentialsProvider, sanityCredentialsProviderMeta);
|
|
887
|
-
}
|
|
888
|
-
_registerComponent(SanityFetcher, sanityFetcherMeta);
|
|
889
|
-
_registerComponent(SanityField, sanityFieldMeta);
|
|
890
|
-
}
|
|
891
|
-
|
|
892
|
-
exports.SanityCredentialsProvider = SanityCredentialsProvider;
|
|
893
|
-
exports.SanityFetcher = SanityFetcher;
|
|
894
|
-
exports.SanityField = SanityField;
|
|
895
|
-
exports.ensure = ensure;
|
|
896
|
-
exports.registerAll = registerAll;
|
|
897
|
-
exports.sanityCredentialsProviderMeta = sanityCredentialsProviderMeta;
|
|
898
|
-
exports.sanityFetcherMeta = sanityFetcherMeta;
|
|
899
|
-
exports.sanityFieldMeta = sanityFieldMeta;
|
|
900
|
-
//# sourceMappingURL=plasmic-sanity-io.cjs.development.js.map
|