@prismicio/vue 2.0.11 → 2.1.0-alpha.0
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/LICENSE +202 -0
- package/README.md +81 -149
- package/components/common.js +275 -41
- package/components/index.js +269 -39
- package/components/umd.js +278 -43
- package/dist/prismic-vue.common.js +278 -48
- package/dist/prismic-vue.esm.js +270 -42
- package/dist/prismic-vue.js +282 -52
- package/dist/prismic-vue.min.js +1 -1
- package/package.json +51 -47
- package/src/components/Link.js +87 -51
- package/src/components/RichText.js +40 -41
- package/src/components/SliceZone.js +144 -0
- package/src/components/Text.js +37 -0
- package/src/components/index.js +26 -22
- package/src/components-bundler.js +10 -5
- package/src/index.js +46 -39
package/dist/prismic-vue.js
CHANGED
|
@@ -1,35 +1,26 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['
|
|
4
|
-
(global.PrismicVue = factory(global.
|
|
5
|
-
}(this, (function (PrismicDOM
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@prismicio/client'), require('prismic-dom')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['@prismicio/client', 'prismic-dom'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.PrismicVue = factory(global.prismicJS, global.prismicDOM));
|
|
5
|
+
})(this, (function (prismicJS, PrismicDOM) { 'use strict';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
prismicJS = prismicJS && prismicJS.hasOwnProperty('default') ? prismicJS['default'] : prismicJS;
|
|
7
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
Object.defineProperty(obj, key, {
|
|
13
|
-
value: value,
|
|
14
|
-
enumerable: true,
|
|
15
|
-
configurable: true,
|
|
16
|
-
writable: true
|
|
17
|
-
});
|
|
18
|
-
} else {
|
|
19
|
-
obj[key] = value;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return obj;
|
|
23
|
-
}
|
|
9
|
+
var prismicJS__default = /*#__PURE__*/_interopDefaultLegacy(prismicJS);
|
|
10
|
+
var PrismicDOM__default = /*#__PURE__*/_interopDefaultLegacy(PrismicDOM);
|
|
24
11
|
|
|
25
12
|
function ownKeys(object, enumerableOnly) {
|
|
26
13
|
var keys = Object.keys(object);
|
|
27
14
|
|
|
28
15
|
if (Object.getOwnPropertySymbols) {
|
|
29
16
|
var symbols = Object.getOwnPropertySymbols(object);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
17
|
+
|
|
18
|
+
if (enumerableOnly) {
|
|
19
|
+
symbols = symbols.filter(function (sym) {
|
|
20
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
33
24
|
keys.push.apply(keys, symbols);
|
|
34
25
|
}
|
|
35
26
|
|
|
@@ -56,6 +47,21 @@
|
|
|
56
47
|
return target;
|
|
57
48
|
}
|
|
58
49
|
|
|
50
|
+
function _defineProperty(obj, key, value) {
|
|
51
|
+
if (key in obj) {
|
|
52
|
+
Object.defineProperty(obj, key, {
|
|
53
|
+
value: value,
|
|
54
|
+
enumerable: true,
|
|
55
|
+
configurable: true,
|
|
56
|
+
writable: true
|
|
57
|
+
});
|
|
58
|
+
} else {
|
|
59
|
+
obj[key] = value;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return obj;
|
|
63
|
+
}
|
|
64
|
+
|
|
59
65
|
function _slicedToArray(arr, i) {
|
|
60
66
|
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
61
67
|
}
|
|
@@ -65,14 +71,17 @@
|
|
|
65
71
|
}
|
|
66
72
|
|
|
67
73
|
function _iterableToArrayLimit(arr, i) {
|
|
68
|
-
|
|
74
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
75
|
+
|
|
76
|
+
if (_i == null) return;
|
|
69
77
|
var _arr = [];
|
|
70
78
|
var _n = true;
|
|
71
79
|
var _d = false;
|
|
72
|
-
|
|
80
|
+
|
|
81
|
+
var _s, _e;
|
|
73
82
|
|
|
74
83
|
try {
|
|
75
|
-
for (
|
|
84
|
+
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
76
85
|
_arr.push(_s.value);
|
|
77
86
|
|
|
78
87
|
if (i && _arr.length === i) break;
|
|
@@ -184,11 +193,24 @@
|
|
|
184
193
|
}
|
|
185
194
|
};
|
|
186
195
|
|
|
196
|
+
var isInternalURL = function isInternalURL(url) {
|
|
197
|
+
/**
|
|
198
|
+
* @see Regex101 expression: {@link https://regex101.com/r/1y7iod/1}
|
|
199
|
+
*/
|
|
200
|
+
var isInternal = /^\/(?!\/)/.test(url);
|
|
201
|
+
/**
|
|
202
|
+
* @see Regex101 expression: {@link https://regex101.com/r/RnUseS/1}
|
|
203
|
+
*/
|
|
204
|
+
|
|
205
|
+
var isSpecialLink = !isInternal && !/^https?:\/\//i.test(url);
|
|
206
|
+
return isInternal && !isSpecialLink;
|
|
207
|
+
};
|
|
208
|
+
|
|
187
209
|
var Link = (function (_ref) {
|
|
188
210
|
var _ref$component = _ref.component,
|
|
189
|
-
component = _ref$component === void 0 ?
|
|
211
|
+
component = _ref$component === void 0 ? "a" : _ref$component;
|
|
190
212
|
return {
|
|
191
|
-
name:
|
|
213
|
+
name: "PrismicLink",
|
|
192
214
|
functional: true,
|
|
193
215
|
props: {
|
|
194
216
|
field: {
|
|
@@ -198,6 +220,21 @@
|
|
|
198
220
|
linkResolver: {
|
|
199
221
|
type: Function,
|
|
200
222
|
required: false
|
|
223
|
+
},
|
|
224
|
+
target: {
|
|
225
|
+
type: String,
|
|
226
|
+
"default": undefined,
|
|
227
|
+
required: false
|
|
228
|
+
},
|
|
229
|
+
rel: {
|
|
230
|
+
type: String,
|
|
231
|
+
"default": undefined,
|
|
232
|
+
required: false
|
|
233
|
+
},
|
|
234
|
+
blankTargetRelAttribute: {
|
|
235
|
+
type: String,
|
|
236
|
+
"default": "noopener",
|
|
237
|
+
required: false
|
|
201
238
|
}
|
|
202
239
|
},
|
|
203
240
|
render: function render(h, _ref2) {
|
|
@@ -212,11 +249,11 @@
|
|
|
212
249
|
return null;
|
|
213
250
|
}
|
|
214
251
|
|
|
215
|
-
var url = parent.$prismic ? parent.$prismic.asLink(field, linkResolver) : PrismicDOM__default.Link.url(field, linkResolver || function () {
|
|
252
|
+
var url = parent.$prismic ? parent.$prismic.asLink(field, linkResolver) : PrismicDOM__default["default"].Link.url(field, linkResolver || function () {
|
|
216
253
|
return null;
|
|
217
254
|
});
|
|
218
255
|
|
|
219
|
-
if (url
|
|
256
|
+
if (isInternalURL(url) && !props.target) {
|
|
220
257
|
data.props = data.props || {};
|
|
221
258
|
data.props.to = url;
|
|
222
259
|
return h(component, data, children);
|
|
@@ -224,23 +261,33 @@
|
|
|
224
261
|
|
|
225
262
|
data.attrs = _objectSpread2(_objectSpread2({}, data.attrs), {}, {
|
|
226
263
|
href: url
|
|
227
|
-
}, field.target && {
|
|
228
|
-
target: field.target,
|
|
229
|
-
rel: 'noopener'
|
|
230
264
|
});
|
|
231
|
-
|
|
265
|
+
|
|
266
|
+
if (typeof props.target !== "undefined" || field.target) {
|
|
267
|
+
data.attrs.target = typeof props.target !== "undefined" ? props.target : field.target;
|
|
268
|
+
|
|
269
|
+
if (data.attrs.target === "_blank") {
|
|
270
|
+
data.attrs.rel = typeof props.rel !== "undefined" ? props.rel : props.blankTargetRelAttribute;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
return h("a", data, children);
|
|
232
275
|
}
|
|
233
276
|
};
|
|
234
277
|
});
|
|
235
278
|
|
|
236
279
|
var RichText = {
|
|
237
|
-
name:
|
|
280
|
+
name: "PrismicRichText",
|
|
238
281
|
functional: true,
|
|
239
282
|
props: {
|
|
240
283
|
field: {
|
|
241
284
|
type: Array,
|
|
242
285
|
required: true
|
|
243
286
|
},
|
|
287
|
+
linkResolver: {
|
|
288
|
+
type: Function,
|
|
289
|
+
required: false
|
|
290
|
+
},
|
|
244
291
|
htmlSerializer: {
|
|
245
292
|
type: Function,
|
|
246
293
|
required: false
|
|
@@ -248,15 +295,15 @@
|
|
|
248
295
|
wrapper: {
|
|
249
296
|
type: String,
|
|
250
297
|
required: false,
|
|
251
|
-
"default":
|
|
298
|
+
"default": "div"
|
|
252
299
|
}
|
|
253
300
|
},
|
|
254
301
|
render: function render(h, _ref) {
|
|
255
302
|
var props = _ref.props,
|
|
256
303
|
data = _ref.data,
|
|
257
|
-
children = _ref.children,
|
|
258
304
|
parent = _ref.parent;
|
|
259
305
|
var field = props.field,
|
|
306
|
+
linkResolver = props.linkResolver,
|
|
260
307
|
htmlSerializer = props.htmlSerializer,
|
|
261
308
|
wrapper = props.wrapper;
|
|
262
309
|
|
|
@@ -264,7 +311,7 @@
|
|
|
264
311
|
return null;
|
|
265
312
|
}
|
|
266
313
|
|
|
267
|
-
var innerHTML = PrismicDOM.RichText.asHtml(field, parent.$prismic.linkResolver, htmlSerializer || parent.$prismic.htmlSerializer);
|
|
314
|
+
var innerHTML = PrismicDOM.RichText.asHtml(field, linkResolver || parent.$prismic.linkResolver, htmlSerializer || parent.$prismic.htmlSerializer);
|
|
268
315
|
return h(wrapper, _objectSpread2(_objectSpread2({}, data), {}, {
|
|
269
316
|
domProps: {
|
|
270
317
|
innerHTML: innerHTML
|
|
@@ -273,17 +320,199 @@
|
|
|
273
320
|
}
|
|
274
321
|
};
|
|
275
322
|
|
|
323
|
+
var Text = {
|
|
324
|
+
name: "PrismicText",
|
|
325
|
+
functional: true,
|
|
326
|
+
props: {
|
|
327
|
+
field: {
|
|
328
|
+
type: Array,
|
|
329
|
+
required: true
|
|
330
|
+
},
|
|
331
|
+
separator: {
|
|
332
|
+
type: String,
|
|
333
|
+
"default": undefined,
|
|
334
|
+
required: false
|
|
335
|
+
},
|
|
336
|
+
wrapper: {
|
|
337
|
+
type: String,
|
|
338
|
+
required: false,
|
|
339
|
+
"default": "div"
|
|
340
|
+
}
|
|
341
|
+
},
|
|
342
|
+
render: function render(h, _ref) {
|
|
343
|
+
var props = _ref.props,
|
|
344
|
+
data = _ref.data;
|
|
345
|
+
_ref.children;
|
|
346
|
+
_ref.parent;
|
|
347
|
+
var field = props.field,
|
|
348
|
+
separator = props.separator,
|
|
349
|
+
wrapper = props.wrapper;
|
|
350
|
+
|
|
351
|
+
if (!field) {
|
|
352
|
+
return null;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
var innerHTML = PrismicDOM.RichText.asText(field, separator);
|
|
356
|
+
return h(wrapper, _objectSpread2(_objectSpread2({}, data), {}, {
|
|
357
|
+
domProps: {
|
|
358
|
+
innerHTML: innerHTML
|
|
359
|
+
}
|
|
360
|
+
}));
|
|
361
|
+
}
|
|
362
|
+
};
|
|
363
|
+
|
|
364
|
+
// We need to polyfill process if it doesn't exist, such as in the browser.
|
|
365
|
+
if (typeof process === "undefined") {
|
|
366
|
+
globalThis.process = {
|
|
367
|
+
env: {}
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* `true` if in the production environment, `false` otherwise.
|
|
372
|
+
*
|
|
373
|
+
* This boolean can be used to perform actions only in development environments,
|
|
374
|
+
* such as logging.
|
|
375
|
+
*/
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
var __PRODUCTION__ = process.env.NODE_ENV === "production";
|
|
379
|
+
|
|
380
|
+
var getSliceComponentProps = function getSliceComponentProps(propsHint) {
|
|
381
|
+
return {
|
|
382
|
+
slice: {
|
|
383
|
+
type: Object,
|
|
384
|
+
required: true
|
|
385
|
+
},
|
|
386
|
+
index: {
|
|
387
|
+
type: Number,
|
|
388
|
+
required: true
|
|
389
|
+
},
|
|
390
|
+
slices: {
|
|
391
|
+
type: Array,
|
|
392
|
+
required: true
|
|
393
|
+
},
|
|
394
|
+
context: {
|
|
395
|
+
type: null,
|
|
396
|
+
required: true
|
|
397
|
+
}
|
|
398
|
+
};
|
|
399
|
+
};
|
|
400
|
+
var TODOSliceComponent = __PRODUCTION__ ? function () {
|
|
401
|
+
return null;
|
|
402
|
+
} : {
|
|
403
|
+
name: "TODOSliceCOmponent",
|
|
404
|
+
functional: true,
|
|
405
|
+
props: getSliceComponentProps(),
|
|
406
|
+
renfer: function renfer(h, _ref) {
|
|
407
|
+
var props = _ref.props,
|
|
408
|
+
data = _ref.data;
|
|
409
|
+
console.warn("[SliceZone] Could not find a component for Slice type \"".concat(props.slice.slice_type, "\""), props.slice);
|
|
410
|
+
return function () {
|
|
411
|
+
return h("section", _objectSpread2(_objectSpread2({}, data), {}, {
|
|
412
|
+
"data-slice-zone-todo-component": "",
|
|
413
|
+
"data-slice-type": props.slice.slice_type
|
|
414
|
+
}), ["Could not find a component for Slice type \"".concat(props.slice.slice_type, "\"")]);
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
}; // Just mimiced to prevent confusion but doesn't provide any value with version 2 of this kit
|
|
418
|
+
var SliceZone = {
|
|
419
|
+
name: "SliceZone",
|
|
420
|
+
functional: true,
|
|
421
|
+
props: {
|
|
422
|
+
slices: {
|
|
423
|
+
type: Array,
|
|
424
|
+
required: true
|
|
425
|
+
},
|
|
426
|
+
components: {
|
|
427
|
+
type: Object,
|
|
428
|
+
"default": undefined,
|
|
429
|
+
required: false
|
|
430
|
+
},
|
|
431
|
+
resolver: {
|
|
432
|
+
type: Function,
|
|
433
|
+
"default": undefined,
|
|
434
|
+
required: false
|
|
435
|
+
},
|
|
436
|
+
context: {
|
|
437
|
+
type: null,
|
|
438
|
+
"default": undefined,
|
|
439
|
+
required: false
|
|
440
|
+
},
|
|
441
|
+
defaultComponent: {
|
|
442
|
+
type: Object,
|
|
443
|
+
"default": undefined,
|
|
444
|
+
required: false
|
|
445
|
+
},
|
|
446
|
+
wrapper: {
|
|
447
|
+
type: [String, Object, Function],
|
|
448
|
+
"default": "div",
|
|
449
|
+
required: false
|
|
450
|
+
}
|
|
451
|
+
},
|
|
452
|
+
render: function render(h, _ref2) {
|
|
453
|
+
var props = _ref2.props,
|
|
454
|
+
data = _ref2.data;
|
|
455
|
+
|
|
456
|
+
// Prevent fatal if user didn't check for field, throws `Invalid prop` warn
|
|
457
|
+
if (!props.slices) {
|
|
458
|
+
return function () {
|
|
459
|
+
return null;
|
|
460
|
+
};
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
var renderedSlices = computed(function () {
|
|
464
|
+
return props.slices.map(function (slice, index) {
|
|
465
|
+
var component = props.components && slice.slice_type in props.components ? props.components[slice.slice_type] : props.defaultComponent || TODOSliceComponent; // TODO: Remove `resolver` in v3 in favor of `components`.
|
|
466
|
+
|
|
467
|
+
if (props.resolver) {
|
|
468
|
+
var resolvedComponent = props.resolver({
|
|
469
|
+
slice: slice,
|
|
470
|
+
sliceName: slice.slice_type,
|
|
471
|
+
i: index
|
|
472
|
+
});
|
|
473
|
+
|
|
474
|
+
if (resolvedComponent) {
|
|
475
|
+
component = resolvedComponent;
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
var p = {
|
|
480
|
+
key: "".concat(slice.slice_type, "-").concat(index),
|
|
481
|
+
slice: slice,
|
|
482
|
+
index: index,
|
|
483
|
+
context: props.context,
|
|
484
|
+
slices: props.slices
|
|
485
|
+
};
|
|
486
|
+
return h(component, p);
|
|
487
|
+
});
|
|
488
|
+
});
|
|
489
|
+
var parent = props.wrapper;
|
|
490
|
+
|
|
491
|
+
if (typeof parent === "string") {
|
|
492
|
+
return h(parent, data, renderedSlices.value);
|
|
493
|
+
} else {
|
|
494
|
+
return h(parent, data, {
|
|
495
|
+
"default": function _default() {
|
|
496
|
+
return renderedSlices.value;
|
|
497
|
+
}
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
};
|
|
502
|
+
|
|
276
503
|
var NuxtLink = Link({
|
|
277
|
-
component:
|
|
504
|
+
component: "nuxt-link"
|
|
278
505
|
});
|
|
279
506
|
var VueRouterLink = Link({
|
|
280
|
-
component:
|
|
507
|
+
component: "router-link"
|
|
281
508
|
});
|
|
282
509
|
var exp = {
|
|
283
510
|
common: {
|
|
284
511
|
Embed: Embed,
|
|
285
512
|
Image: Image,
|
|
286
|
-
RichText: RichText
|
|
513
|
+
RichText: RichText,
|
|
514
|
+
Text: Text,
|
|
515
|
+
SliceZone: SliceZone
|
|
287
516
|
},
|
|
288
517
|
nuxt: {
|
|
289
518
|
Link: NuxtLink
|
|
@@ -295,24 +524,24 @@
|
|
|
295
524
|
|
|
296
525
|
function asHtml(richText, linkResolver, htmlSerializer) {
|
|
297
526
|
if (richText) {
|
|
298
|
-
return PrismicDOM__default.RichText.asHtml(richText, linkResolver, htmlSerializer);
|
|
527
|
+
return PrismicDOM__default["default"].RichText.asHtml(richText, linkResolver, htmlSerializer);
|
|
299
528
|
}
|
|
300
529
|
}
|
|
301
530
|
function asText(richText, joinString) {
|
|
302
531
|
if (richText) {
|
|
303
|
-
return PrismicDOM__default.RichText.asText(richText, joinString);
|
|
532
|
+
return PrismicDOM__default["default"].RichText.asText(richText, joinString);
|
|
304
533
|
}
|
|
305
534
|
|
|
306
535
|
return '';
|
|
307
536
|
}
|
|
308
537
|
function asLink(link, linkResolver) {
|
|
309
538
|
if (link) {
|
|
310
|
-
return PrismicDOM__default.Link.url(link, linkResolver);
|
|
539
|
+
return PrismicDOM__default["default"].Link.url(link, linkResolver);
|
|
311
540
|
}
|
|
312
541
|
}
|
|
313
542
|
function asDate(date) {
|
|
314
543
|
if (date) {
|
|
315
|
-
return PrismicDOM__default.Date(date);
|
|
544
|
+
return PrismicDOM__default["default"].Date(date);
|
|
316
545
|
}
|
|
317
546
|
}
|
|
318
547
|
|
|
@@ -321,6 +550,7 @@
|
|
|
321
550
|
return asHtml(richText, linkResolver || options.linkResolver, htmlSerializer || options.htmlSerializer);
|
|
322
551
|
};
|
|
323
552
|
|
|
553
|
+
Vue.prototype.$prismic.asHTML = Vue.prototype.$prismic.asHtml;
|
|
324
554
|
Vue.prototype.$prismic.asText = asText;
|
|
325
555
|
Vue.prototype.$prismic.richTextAsPlain = asText;
|
|
326
556
|
Vue.prototype.$prismic.asDate = asDate;
|
|
@@ -333,12 +563,12 @@
|
|
|
333
563
|
var PrismicVue = {
|
|
334
564
|
install: function install(Vue, options) {
|
|
335
565
|
var _options$linkType = options.linkType,
|
|
336
|
-
linkType = _options$linkType === void 0 ?
|
|
337
|
-
Vue.prototype.$prismic =
|
|
566
|
+
linkType = _options$linkType === void 0 ? "vueRouter" : _options$linkType;
|
|
567
|
+
Vue.prototype.$prismic = prismicJS__default["default"];
|
|
338
568
|
Vue.prototype.$prismic.endpoint = options.endpoint;
|
|
339
569
|
Vue.prototype.$prismic.linkResolver = options.linkResolver;
|
|
340
570
|
Vue.prototype.$prismic.htmlSerializer = options.htmlSerializer;
|
|
341
|
-
Vue.prototype.$prismic.client =
|
|
571
|
+
Vue.prototype.$prismic.client = prismicJS__default["default"].client(options.endpoint, options.apiOptions);
|
|
342
572
|
attachMethods(Vue, options);
|
|
343
573
|
|
|
344
574
|
var components = _objectSpread2(_objectSpread2({}, exp.common), exp[linkType]);
|
|
@@ -349,9 +579,9 @@
|
|
|
349
579
|
|
|
350
580
|
|
|
351
581
|
Object.entries(components).forEach(function (_ref) {
|
|
352
|
-
var _ref2 = _slicedToArray(_ref, 2)
|
|
353
|
-
|
|
354
|
-
c = _ref2[1];
|
|
582
|
+
var _ref2 = _slicedToArray(_ref, 2);
|
|
583
|
+
_ref2[0];
|
|
584
|
+
var c = _ref2[1];
|
|
355
585
|
|
|
356
586
|
Vue.component(c.name, c);
|
|
357
587
|
});
|
|
@@ -360,4 +590,4 @@
|
|
|
360
590
|
|
|
361
591
|
return PrismicVue;
|
|
362
592
|
|
|
363
|
-
}))
|
|
593
|
+
}));
|
package/dist/prismic-vue.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?module.exports=factory(require("prismic-dom"),require("@prismicio/client")):typeof define==="function"&&define.amd?define(["prismic-dom","@prismicio/client"],factory):global.PrismicVue=factory(global.prismicDOM,global.prismicJS)})(this,function(PrismicDOM,prismicJS){"use strict";var PrismicDOM__default="default"in PrismicDOM?PrismicDOM["default"]:PrismicDOM;prismicJS=prismicJS&&prismicJS.hasOwnProperty("default")?prismicJS["default"]:prismicJS;function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);if(enumerableOnly)symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable});keys.push.apply(keys,symbols)}return keys}function _objectSpread2(target){for(var i=1;i<arguments.length;i++){var source=arguments[i]!=null?arguments[i]:{};if(i%2){ownKeys(Object(source),true).forEach(function(key){_defineProperty(target,key,source[key])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(target,Object.getOwnPropertyDescriptors(source))}else{ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key))})}}return target}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest()}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr}function _iterableToArrayLimit(arr,i){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(arr)))return;var _arr=[];var _n=true;var _d=false;var _e=undefined;try{for(var _i=arr[Symbol.iterator](),_s;!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break}}catch(err){_d=true;_e=err}finally{try{if(!_n&&_i["return"]!=null)_i["return"]()}finally{if(_d)throw _e}}return _arr}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var Embed={name:"PrismicEmbed",functional:true,props:{field:{type:Object,required:true},wrapper:{type:String,required:false,default:"div"}},render:function render(h,_ref){var props=_ref.props,data=_ref.data;var field=props.field,wrapper=props.wrapper;if(!field||!field.html){return null}var embedUrl=field.embed_url,type=field.type,providerName=field.provider_name;var attrs=_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({},data.attrs),embedUrl&&{"data-oembed":embedUrl}),type&&{"data-oembed-type":type}),providerName&&{"data-oembed-provider":providerName});return h(wrapper,_objectSpread2(_objectSpread2({},Object.assign(data,{attrs:attrs})),{},{domProps:{innerHTML:field.html}}))}};var Image={name:"PrismicImage",functional:true,props:{field:{type:Object,required:true}},render:function render(h,_ref){var props=_ref.props,data=_ref.data;var _props$field=props.field,url=_props$field.url,alt=_props$field.alt,copyright=_props$field.copyright;return h("img",Object.assign(data,{attrs:_objectSpread2(_objectSpread2({},data.attrs),{},{src:url,alt:alt,copyright:copyright})}))}};var Link=function(_ref){var _ref$component=_ref.component,component=_ref$component===void 0?"a":_ref$component;return{name:"PrismicLink",functional:true,props:{field:{type:Object,required:true},linkResolver:{type:Function,required:false}},render:function render(h,_ref2){var props=_ref2.props,data=_ref2.data,children=_ref2.children,parent=_ref2.parent;var field=props.field,linkResolver=props.linkResolver;if(!field){return null}var url=parent.$prismic?parent.$prismic.asLink(field,linkResolver):PrismicDOM__default.Link.url(field,linkResolver||function(){return null});if(url.indexOf("/")===0){data.props=data.props||{};data.props.to=url;return h(component,data,children)}data.attrs=_objectSpread2(_objectSpread2({},data.attrs),{},{href:url},field.target&&{target:field.target,rel:"noopener"});return h("a",data,children)}}};var RichText={name:"PrismicRichText",functional:true,props:{field:{type:Array,required:true},htmlSerializer:{type:Function,required:false},wrapper:{type:String,required:false,default:"div"}},render:function render(h,_ref){var props=_ref.props,data=_ref.data,children=_ref.children,parent=_ref.parent;var field=props.field,htmlSerializer=props.htmlSerializer,wrapper=props.wrapper;if(!field){return null}var innerHTML=PrismicDOM.RichText.asHtml(field,parent.$prismic.linkResolver,htmlSerializer||parent.$prismic.htmlSerializer);return h(wrapper,_objectSpread2(_objectSpread2({},data),{},{domProps:{innerHTML:innerHTML}}))}};var NuxtLink=Link({component:"nuxt-link"});var VueRouterLink=Link({component:"router-link"});var exp={common:{Embed:Embed,Image:Image,RichText:RichText},nuxt:{Link:NuxtLink},vueRouter:{Link:VueRouterLink}};function asHtml(richText,linkResolver,htmlSerializer){if(richText){return PrismicDOM__default.RichText.asHtml(richText,linkResolver,htmlSerializer)}}function asText(richText,joinString){if(richText){return PrismicDOM__default.RichText.asText(richText,joinString)}return""}function asLink(link,linkResolver){if(link){return PrismicDOM__default.Link.url(link,linkResolver)}}function asDate(date){if(date){return PrismicDOM__default.Date(date)}}function attachMethods(Vue,options){Vue.prototype.$prismic.asHtml=function(richText,linkResolver,htmlSerializer){return asHtml(richText,linkResolver||options.linkResolver,htmlSerializer||options.htmlSerializer)};Vue.prototype.$prismic.asText=asText;Vue.prototype.$prismic.richTextAsPlain=asText;Vue.prototype.$prismic.asDate=asDate;Vue.prototype.$prismic.asLink=function(link,linkResolver){return asLink(link,linkResolver||options.linkResolver)}}var PrismicVue={install:function install(Vue,options){var _options$linkType=options.linkType,linkType=_options$linkType===void 0?"vueRouter":_options$linkType;Vue.prototype.$prismic=prismicJS;Vue.prototype.$prismic.endpoint=options.endpoint;Vue.prototype.$prismic.linkResolver=options.linkResolver;Vue.prototype.$prismic.htmlSerializer=options.htmlSerializer;Vue.prototype.$prismic.client=prismicJS.client(options.endpoint,options.apiOptions);attachMethods(Vue,options);var components=_objectSpread2(_objectSpread2({},exp.common),exp[linkType]);Object.entries(components).forEach(function(_ref){var _ref2=_slicedToArray(_ref,2),_=_ref2[0],c=_ref2[1];Vue.component(c.name,c)})}};return PrismicVue});
|
|
1
|
+
(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?module.exports=factory(require("@prismicio/client"),require("prismic-dom")):typeof define==="function"&&define.amd?define(["@prismicio/client","prismic-dom"],factory):(global=typeof globalThis!=="undefined"?globalThis:global||self,global.PrismicVue=factory(global.prismicJS,global.prismicDOM))})(this,function(prismicJS,PrismicDOM){"use strict";function _interopDefaultLegacy(e){return e&&typeof e==="object"&&"default"in e?e:{default:e}}var prismicJS__default=_interopDefaultLegacy(prismicJS);var PrismicDOM__default=_interopDefaultLegacy(PrismicDOM);function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);if(enumerableOnly){symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable})}keys.push.apply(keys,symbols)}return keys}function _objectSpread2(target){for(var i=1;i<arguments.length;i++){var source=arguments[i]!=null?arguments[i]:{};if(i%2){ownKeys(Object(source),true).forEach(function(key){_defineProperty(target,key,source[key])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(target,Object.getOwnPropertyDescriptors(source))}else{ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key))})}}return target}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest()}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr}function _iterableToArrayLimit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break}}catch(err){_d=true;_e=err}finally{try{if(!_n&&_i["return"]!=null)_i["return"]()}finally{if(_d)throw _e}}return _arr}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var Embed={name:"PrismicEmbed",functional:true,props:{field:{type:Object,required:true},wrapper:{type:String,required:false,default:"div"}},render:function render(h,_ref){var props=_ref.props,data=_ref.data;var field=props.field,wrapper=props.wrapper;if(!field||!field.html){return null}var embedUrl=field.embed_url,type=field.type,providerName=field.provider_name;var attrs=_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({},data.attrs),embedUrl&&{"data-oembed":embedUrl}),type&&{"data-oembed-type":type}),providerName&&{"data-oembed-provider":providerName});return h(wrapper,_objectSpread2(_objectSpread2({},Object.assign(data,{attrs:attrs})),{},{domProps:{innerHTML:field.html}}))}};var Image={name:"PrismicImage",functional:true,props:{field:{type:Object,required:true}},render:function render(h,_ref){var props=_ref.props,data=_ref.data;var _props$field=props.field,url=_props$field.url,alt=_props$field.alt,copyright=_props$field.copyright;return h("img",Object.assign(data,{attrs:_objectSpread2(_objectSpread2({},data.attrs),{},{src:url,alt:alt,copyright:copyright})}))}};var isInternalURL=function isInternalURL(url){var isInternal=/^\/(?!\/)/.test(url);var isSpecialLink=!isInternal&&!/^https?:\/\//i.test(url);return isInternal&&!isSpecialLink};var Link=function(_ref){var _ref$component=_ref.component,component=_ref$component===void 0?"a":_ref$component;return{name:"PrismicLink",functional:true,props:{field:{type:Object,required:true},linkResolver:{type:Function,required:false},target:{type:String,default:undefined,required:false},rel:{type:String,default:undefined,required:false},blankTargetRelAttribute:{type:String,default:"noopener",required:false}},render:function render(h,_ref2){var props=_ref2.props,data=_ref2.data,children=_ref2.children,parent=_ref2.parent;var field=props.field,linkResolver=props.linkResolver;if(!field){return null}var url=parent.$prismic?parent.$prismic.asLink(field,linkResolver):PrismicDOM__default["default"].Link.url(field,linkResolver||function(){return null});if(isInternalURL(url)&&!props.target){data.props=data.props||{};data.props.to=url;return h(component,data,children)}data.attrs=_objectSpread2(_objectSpread2({},data.attrs),{},{href:url});if(typeof props.target!=="undefined"||field.target){data.attrs.target=typeof props.target!=="undefined"?props.target:field.target;if(data.attrs.target==="_blank"){data.attrs.rel=typeof props.rel!=="undefined"?props.rel:props.blankTargetRelAttribute}}return h("a",data,children)}}};var RichText={name:"PrismicRichText",functional:true,props:{field:{type:Array,required:true},linkResolver:{type:Function,required:false},htmlSerializer:{type:Function,required:false},wrapper:{type:String,required:false,default:"div"}},render:function render(h,_ref){var props=_ref.props,data=_ref.data,parent=_ref.parent;var field=props.field,linkResolver=props.linkResolver,htmlSerializer=props.htmlSerializer,wrapper=props.wrapper;if(!field){return null}var innerHTML=PrismicDOM.RichText.asHtml(field,linkResolver||parent.$prismic.linkResolver,htmlSerializer||parent.$prismic.htmlSerializer);return h(wrapper,_objectSpread2(_objectSpread2({},data),{},{domProps:{innerHTML:innerHTML}}))}};var Text={name:"PrismicText",functional:true,props:{field:{type:Array,required:true},separator:{type:String,default:undefined,required:false},wrapper:{type:String,required:false,default:"div"}},render:function render(h,_ref){var props=_ref.props,data=_ref.data;_ref.children;_ref.parent;var field=props.field,separator=props.separator,wrapper=props.wrapper;if(!field){return null}var innerHTML=PrismicDOM.RichText.asText(field,separator);return h(wrapper,_objectSpread2(_objectSpread2({},data),{},{domProps:{innerHTML:innerHTML}}))}};if(typeof process==="undefined"){globalThis.process={env:{}}}var __PRODUCTION__=process.env.NODE_ENV==="production";var getSliceComponentProps=function getSliceComponentProps(propsHint){return{slice:{type:Object,required:true},index:{type:Number,required:true},slices:{type:Array,required:true},context:{type:null,required:true}}};var TODOSliceComponent=__PRODUCTION__?function(){return null}:{name:"TODOSliceCOmponent",functional:true,props:getSliceComponentProps(),renfer:function renfer(h,_ref){var props=_ref.props,data=_ref.data;console.warn('[SliceZone] Could not find a component for Slice type "'.concat(props.slice.slice_type,'"'),props.slice);return function(){return h("section",_objectSpread2(_objectSpread2({},data),{},{"data-slice-zone-todo-component":"","data-slice-type":props.slice.slice_type}),['Could not find a component for Slice type "'.concat(props.slice.slice_type,'"')])}}};var SliceZone={name:"SliceZone",functional:true,props:{slices:{type:Array,required:true},components:{type:Object,default:undefined,required:false},resolver:{type:Function,default:undefined,required:false},context:{type:null,default:undefined,required:false},defaultComponent:{type:Object,default:undefined,required:false},wrapper:{type:[String,Object,Function],default:"div",required:false}},render:function render(h,_ref2){var props=_ref2.props,data=_ref2.data;if(!props.slices){return function(){return null}}var renderedSlices=computed(function(){return props.slices.map(function(slice,index){var component=props.components&&slice.slice_type in props.components?props.components[slice.slice_type]:props.defaultComponent||TODOSliceComponent;if(props.resolver){var resolvedComponent=props.resolver({slice:slice,sliceName:slice.slice_type,i:index});if(resolvedComponent){component=resolvedComponent}}var p={key:"".concat(slice.slice_type,"-").concat(index),slice:slice,index:index,context:props.context,slices:props.slices};return h(component,p)})});var parent=props.wrapper;if(typeof parent==="string"){return h(parent,data,renderedSlices.value)}else{return h(parent,data,{default:function _default(){return renderedSlices.value}})}}};var NuxtLink=Link({component:"nuxt-link"});var VueRouterLink=Link({component:"router-link"});var exp={common:{Embed:Embed,Image:Image,RichText:RichText,Text:Text,SliceZone:SliceZone},nuxt:{Link:NuxtLink},vueRouter:{Link:VueRouterLink}};function asHtml(richText,linkResolver,htmlSerializer){if(richText){return PrismicDOM__default["default"].RichText.asHtml(richText,linkResolver,htmlSerializer)}}function asText(richText,joinString){if(richText){return PrismicDOM__default["default"].RichText.asText(richText,joinString)}return""}function asLink(link,linkResolver){if(link){return PrismicDOM__default["default"].Link.url(link,linkResolver)}}function asDate(date){if(date){return PrismicDOM__default["default"].Date(date)}}function attachMethods(Vue,options){Vue.prototype.$prismic.asHtml=function(richText,linkResolver,htmlSerializer){return asHtml(richText,linkResolver||options.linkResolver,htmlSerializer||options.htmlSerializer)};Vue.prototype.$prismic.asHTML=Vue.prototype.$prismic.asHtml;Vue.prototype.$prismic.asText=asText;Vue.prototype.$prismic.richTextAsPlain=asText;Vue.prototype.$prismic.asDate=asDate;Vue.prototype.$prismic.asLink=function(link,linkResolver){return asLink(link,linkResolver||options.linkResolver)}}var PrismicVue={install:function install(Vue,options){var _options$linkType=options.linkType,linkType=_options$linkType===void 0?"vueRouter":_options$linkType;Vue.prototype.$prismic=prismicJS__default["default"];Vue.prototype.$prismic.endpoint=options.endpoint;Vue.prototype.$prismic.linkResolver=options.linkResolver;Vue.prototype.$prismic.htmlSerializer=options.htmlSerializer;Vue.prototype.$prismic.client=prismicJS__default["default"].client(options.endpoint,options.apiOptions);attachMethods(Vue,options);var components=_objectSpread2(_objectSpread2({},exp.common),exp[linkType]);Object.entries(components).forEach(function(_ref){var _ref2=_slicedToArray(_ref,2);_ref2[0];var c=_ref2[1];Vue.component(c.name,c)})}};return PrismicVue});
|
package/package.json
CHANGED
|
@@ -1,49 +1,53 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
2
|
+
"name": "@prismicio/vue",
|
|
3
|
+
"version": "2.1.0-alpha.0",
|
|
4
|
+
"description": "Vue.js plugin to facilitate integration of content managed with Prismic",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"repository": "github:prismicio/prismic-vue",
|
|
7
|
+
"author": "Prismic",
|
|
8
|
+
"components": "dist/components.esm.js",
|
|
9
|
+
"main": "dist/prismic-vue.common.js",
|
|
10
|
+
"module": "dist/prismic-vue.esm.js",
|
|
11
|
+
"unpkg": "dist/prismic-vue.min.js",
|
|
12
|
+
"jsdelivr": "dist/prismic-vue.min.js",
|
|
13
|
+
"files": [
|
|
14
|
+
"components",
|
|
15
|
+
"dist",
|
|
16
|
+
"src"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "rollup -c --environment BUILD:production && uglifyjs dist/prismic-vue.js -o dist/prismic-vue.min.js",
|
|
20
|
+
"release": "npm run build && npm publish",
|
|
21
|
+
"beauty": "rollup -c",
|
|
22
|
+
"dev": "rollup -c --watch --environment BUILD:development",
|
|
23
|
+
"visualize": "rollup -c --config-visualize"
|
|
24
|
+
},
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"vue": "^2.6.0",
|
|
27
|
+
"@prismicio/client": "^4.0.0 || ^5.0.0",
|
|
28
|
+
"prismic-dom": "^2.2.0"
|
|
29
|
+
},
|
|
30
|
+
"engines": {
|
|
31
|
+
"node": ">= 6.0.0"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@babel/core": "^7.16.0",
|
|
35
|
+
"@babel/preset-env": "^7.16.4",
|
|
36
|
+
"@prismicio/client": "^5.1.0",
|
|
37
|
+
"postcss": "^8.3.11",
|
|
38
|
+
"prismic-dom": "^2.2.6",
|
|
39
|
+
"rollup": "^2.60.1",
|
|
40
|
+
"rollup-plugin-auto-named-exports": "^1.0.0-beta.3",
|
|
41
|
+
"rollup-plugin-babel": "^4.4.0",
|
|
42
|
+
"rollup-plugin-commonjs": "^10.1.0",
|
|
43
|
+
"rollup-plugin-node-resolve": "^5.2.0",
|
|
44
|
+
"rollup-plugin-visualizer": "^5.5.2",
|
|
45
|
+
"rollup-plugin-vue": "^6.0.0",
|
|
46
|
+
"uglify-js": "^3.14.3",
|
|
47
|
+
"vue-template-compiler": "^2.6.14"
|
|
48
|
+
},
|
|
49
|
+
"vetur": {
|
|
50
|
+
"tags": "vetur/tags.json",
|
|
51
|
+
"attributes": "vetur/attributes.json"
|
|
52
|
+
}
|
|
49
53
|
}
|