@prismicio/vue 3.0.0-beta.6 → 3.0.0-beta.9
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.cjs +43 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +93 -19
- package/dist/index.js +43 -28
- package/dist/index.js.map +1 -1
- package/package.json +22 -24
- package/src/components/PrismicImage.ts +4 -3
- package/src/components/PrismicRichText.ts +23 -9
- package/src/components/PrismicText.ts +23 -10
- package/src/components/SliceZone.ts +75 -31
- package/src/components/index.ts +2 -0
- package/src/index.ts +2 -0
- package/vetur/attributes.json +8 -0
- package/vetur/tags.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -59,6 +59,11 @@ const PrismicEmbedImpl = /* @__PURE__ */ vue.defineComponent({
|
|
|
59
59
|
});
|
|
60
60
|
const PrismicEmbed = PrismicEmbedImpl;
|
|
61
61
|
|
|
62
|
+
if (typeof process === "undefined") {
|
|
63
|
+
globalThis.process = { env: {} };
|
|
64
|
+
}
|
|
65
|
+
const __PRODUCTION__ = process.env.NODE_ENV === "production";
|
|
66
|
+
|
|
62
67
|
const prismicKey = Symbol("prismic");
|
|
63
68
|
|
|
64
69
|
const usePrismic = () => {
|
|
@@ -81,8 +86,8 @@ const usePrismicImage = (props) => {
|
|
|
81
86
|
const widths = vue.unref(props.widths);
|
|
82
87
|
const pixelDensities = vue.unref(props.pixelDensities);
|
|
83
88
|
if (widths) {
|
|
84
|
-
if (pixelDensities) {
|
|
85
|
-
console.warn("[PrismicImage] `widths`
|
|
89
|
+
if (!__PRODUCTION__ && pixelDensities) {
|
|
90
|
+
console.warn("[PrismicImage] Only one of `widths` or `pixelDensities` props can be provided. You can resolve this warning by removing either the `widths` or `pixelDensities` prop. `widths` will be used in this case.", props);
|
|
86
91
|
}
|
|
87
92
|
return helpers.asImageWidthSrcSet(field, {
|
|
88
93
|
...imgixParams,
|
|
@@ -307,7 +312,12 @@ const PrismicLink = PrismicLinkImpl;
|
|
|
307
312
|
const defaultWrapper$1 = "div";
|
|
308
313
|
const usePrismicText = (props) => {
|
|
309
314
|
const text = vue.computed(() => {
|
|
310
|
-
|
|
315
|
+
var _a;
|
|
316
|
+
const field = vue.unref(props.field);
|
|
317
|
+
if (!helpers.isFilled.richText(field)) {
|
|
318
|
+
return (_a = vue.unref(props.fallback)) != null ? _a : "";
|
|
319
|
+
}
|
|
320
|
+
return helpers.asText(vue.unref(field), vue.unref(props.separator));
|
|
311
321
|
});
|
|
312
322
|
return {
|
|
313
323
|
text
|
|
@@ -318,7 +328,8 @@ const PrismicTextImpl = /* @__PURE__ */ vue.defineComponent({
|
|
|
318
328
|
props: {
|
|
319
329
|
field: {
|
|
320
330
|
type: Array,
|
|
321
|
-
|
|
331
|
+
default: void 0,
|
|
332
|
+
required: false
|
|
322
333
|
},
|
|
323
334
|
separator: {
|
|
324
335
|
type: String,
|
|
@@ -329,12 +340,14 @@ const PrismicTextImpl = /* @__PURE__ */ vue.defineComponent({
|
|
|
329
340
|
type: [String, Object, Function],
|
|
330
341
|
default: void 0,
|
|
331
342
|
required: false
|
|
343
|
+
},
|
|
344
|
+
fallback: {
|
|
345
|
+
type: String,
|
|
346
|
+
default: void 0,
|
|
347
|
+
required: false
|
|
332
348
|
}
|
|
333
349
|
},
|
|
334
350
|
setup(props) {
|
|
335
|
-
if (!props.field) {
|
|
336
|
-
return () => null;
|
|
337
|
-
}
|
|
338
351
|
const { text } = usePrismicText(props);
|
|
339
352
|
return () => {
|
|
340
353
|
const parent = simplyResolveComponent(props.wrapper || defaultWrapper$1);
|
|
@@ -350,10 +363,14 @@ const defaultWrapper = "div";
|
|
|
350
363
|
const usePrismicRichText = (props) => {
|
|
351
364
|
const { options } = usePrismic();
|
|
352
365
|
const html = vue.computed(() => {
|
|
353
|
-
var _a, _b;
|
|
354
|
-
const
|
|
355
|
-
|
|
356
|
-
|
|
366
|
+
var _a, _b, _c;
|
|
367
|
+
const field = vue.unref(props.field);
|
|
368
|
+
if (!helpers.isFilled.richText(field)) {
|
|
369
|
+
return (_a = vue.unref(props.fallback)) != null ? _a : "";
|
|
370
|
+
}
|
|
371
|
+
const linkResolver = (_b = vue.unref(props.linkResolver)) != null ? _b : options.linkResolver;
|
|
372
|
+
const htmlSerializer = (_c = vue.unref(props.htmlSerializer)) != null ? _c : options.htmlSerializer;
|
|
373
|
+
return helpers.asHTML(vue.unref(field), linkResolver, htmlSerializer);
|
|
357
374
|
});
|
|
358
375
|
return {
|
|
359
376
|
html
|
|
@@ -364,7 +381,8 @@ const PrismicRichTextImpl = /* @__PURE__ */ vue.defineComponent({
|
|
|
364
381
|
props: {
|
|
365
382
|
field: {
|
|
366
383
|
type: Array,
|
|
367
|
-
|
|
384
|
+
default: void 0,
|
|
385
|
+
required: false
|
|
368
386
|
},
|
|
369
387
|
linkResolver: {
|
|
370
388
|
type: Function,
|
|
@@ -380,12 +398,14 @@ const PrismicRichTextImpl = /* @__PURE__ */ vue.defineComponent({
|
|
|
380
398
|
type: [String, Object, Function],
|
|
381
399
|
default: void 0,
|
|
382
400
|
required: false
|
|
401
|
+
},
|
|
402
|
+
fallback: {
|
|
403
|
+
type: String,
|
|
404
|
+
default: void 0,
|
|
405
|
+
required: false
|
|
383
406
|
}
|
|
384
407
|
},
|
|
385
408
|
setup(props) {
|
|
386
|
-
if (!props.field) {
|
|
387
|
-
return () => null;
|
|
388
|
-
}
|
|
389
409
|
const { html } = usePrismicRichText(props);
|
|
390
410
|
const root = vue.ref(null);
|
|
391
411
|
const maybeRouter = vue.inject(vueRouter.routerKey, null);
|
|
@@ -432,11 +452,6 @@ const PrismicRichTextImpl = /* @__PURE__ */ vue.defineComponent({
|
|
|
432
452
|
});
|
|
433
453
|
const PrismicRichText = PrismicRichTextImpl;
|
|
434
454
|
|
|
435
|
-
if (typeof process === "undefined") {
|
|
436
|
-
globalThis.process = { env: {} };
|
|
437
|
-
}
|
|
438
|
-
const __PRODUCTION__ = process.env.NODE_ENV === "production";
|
|
439
|
-
|
|
440
455
|
const getSliceComponentProps = (propsHint) => ({
|
|
441
456
|
slice: {
|
|
442
457
|
type: Object,
|
|
@@ -459,16 +474,15 @@ const TODOSliceComponent = __PRODUCTION__ ? () => null : /* @__PURE__ */ vue.def
|
|
|
459
474
|
name: "TODOSliceComponent",
|
|
460
475
|
props: getSliceComponentProps(),
|
|
461
476
|
setup(props) {
|
|
477
|
+
const type = vue.computed(() => "slice_type" in props.slice ? props.slice.slice_type : props.slice.type);
|
|
462
478
|
vue.watchEffect(() => {
|
|
463
|
-
console.warn(`[SliceZone] Could not find a component for Slice type "${
|
|
479
|
+
console.warn(`[SliceZone] Could not find a component for Slice type "${type.value}"`, props.slice);
|
|
464
480
|
});
|
|
465
481
|
return () => {
|
|
466
482
|
return vue.h("section", {
|
|
467
483
|
"data-slice-zone-todo-component": "",
|
|
468
|
-
"data-slice-type":
|
|
469
|
-
}, [
|
|
470
|
-
`Could not find a component for Slice type "${props.slice.slice_type}"`
|
|
471
|
-
]);
|
|
484
|
+
"data-slice-type": type.value
|
|
485
|
+
}, [`Could not find a component for Slice type "${type.value}"`]);
|
|
472
486
|
};
|
|
473
487
|
}
|
|
474
488
|
});
|
|
@@ -522,11 +536,12 @@ const SliceZoneImpl = /* @__PURE__ */ vue.defineComponent({
|
|
|
522
536
|
const renderedSlices = vue.computed(() => {
|
|
523
537
|
return props.slices.map((slice, index) => {
|
|
524
538
|
var _a;
|
|
525
|
-
|
|
539
|
+
const type = "slice_type" in slice ? slice.slice_type : slice.type;
|
|
540
|
+
let component = props.components && type in props.components ? props.components[type] : props.defaultComponent || ((_a = options.components) == null ? void 0 : _a.sliceZoneDefaultComponent) || TODOSliceComponent;
|
|
526
541
|
if (props.resolver) {
|
|
527
542
|
const resolvedComponent = props.resolver({
|
|
528
543
|
slice,
|
|
529
|
-
sliceName:
|
|
544
|
+
sliceName: type,
|
|
530
545
|
i: index
|
|
531
546
|
});
|
|
532
547
|
if (resolvedComponent) {
|
|
@@ -534,7 +549,7 @@ const SliceZoneImpl = /* @__PURE__ */ vue.defineComponent({
|
|
|
534
549
|
}
|
|
535
550
|
}
|
|
536
551
|
const p = {
|
|
537
|
-
key: `${
|
|
552
|
+
key: `${index}-${JSON.stringify(slice)}`,
|
|
538
553
|
slice,
|
|
539
554
|
index,
|
|
540
555
|
context: props.context,
|