@prismicio/vue 3.0.0-beta.5 → 3.0.0-beta.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismicio/vue",
3
- "version": "3.0.0-beta.5",
3
+ "version": "3.0.0-beta.8",
4
4
  "description": "Vue plugin, components, and composables to fetch and present Prismic content",
5
5
  "keywords": [
6
6
  "typescript",
@@ -45,52 +45,50 @@
45
45
  "release:dry": "standard-version --dry-run",
46
46
  "size": "size-limit",
47
47
  "test": "npm run lint && npm run unit && npm run build && npm run size",
48
- "unit": "nyc --reporter=lcovonly --reporter=text --exclude-after-remap=false ava"
48
+ "unit": "vitest run --coverage",
49
+ "unit:watch": "vitest watch"
49
50
  },
50
51
  "dependencies": {
51
- "@prismicio/client": "^6.3.0",
52
- "@prismicio/helpers": "^2.2.0",
53
- "@prismicio/types": "^0.1.26",
52
+ "@prismicio/client": "^6.5.1",
53
+ "@prismicio/helpers": "^2.3.1",
54
+ "@prismicio/types": "^0.1.28",
54
55
  "isomorphic-unfetch": "^3.1.0",
55
- "vue-router": "^4.0.13"
56
+ "vue-router": "^4.0.15"
56
57
  },
57
58
  "devDependencies": {
58
- "@prismicio/mock": "^0.0.8",
59
+ "@prismicio/mock": "^0.0.10",
59
60
  "@size-limit/preset-small-lib": "^7.0.8",
60
- "@types/escape-html": "^1.0.1",
61
- "@types/jsdom-global": "3.0.2",
62
- "@types/sinon": "10.0.11",
63
- "@typescript-eslint/eslint-plugin": "^5.13.0",
64
- "@typescript-eslint/parser": "^5.13.0",
65
- "@vitejs/plugin-vue": "^2.2.4",
66
- "@vue/compiler-sfc": "^3.2.31",
61
+ "@types/escape-html": "^1.0.2",
62
+ "@types/jsdom-global": "^3.0.2",
63
+ "@typescript-eslint/eslint-plugin": "^5.27.1",
64
+ "@typescript-eslint/parser": "^5.27.1",
65
+ "@vitejs/plugin-vue": "^2.3.3",
66
+ "@vue/compiler-sfc": "^3.2.37",
67
67
  "@vue/eslint-config-typescript": "^10.0.0",
68
- "@vue/test-utils": "2.0.0-rc.17",
69
- "ava": "^3.15.0",
70
- "eslint": "^8.10.0",
71
- "eslint-config-prettier": "^8.4.0",
68
+ "@vue/test-utils": "^2.0.0",
69
+ "c8": "^7.11.3",
70
+ "eslint": "^8.17.0",
71
+ "eslint-config-prettier": "^8.5.0",
72
72
  "eslint-plugin-prettier": "^4.0.0",
73
- "eslint-plugin-tsdoc": "^0.2.14",
74
- "eslint-plugin-vue": "^8.5.0",
73
+ "eslint-plugin-tsdoc": "^0.2.16",
74
+ "eslint-plugin-vue": "^9.1.0",
75
75
  "jsdom": "^19.0.0",
76
76
  "jsdom-global": "^3.0.2",
77
- "nyc": "^15.1.0",
78
- "prettier": "^2.5.1",
79
- "prettier-plugin-jsdoc": "^0.3.30",
80
- "sinon": "^13.0.1",
77
+ "prettier": "^2.6.2",
78
+ "prettier-plugin-jsdoc": "^0.3.38",
81
79
  "siroc": "^0.16.0",
82
80
  "size-limit": "^7.0.8",
83
- "standard-version": "^9.3.2",
84
- "ts-eager": "^2.0.2",
85
- "typescript": "^4.6.2",
86
- "vite": "^2.8.6",
87
- "vue": "^3.2.31"
81
+ "standard-version": "^9.5.0",
82
+ "typescript": "^4.7.3",
83
+ "vite": "^2.9.10",
84
+ "vitest": "^0.14.1",
85
+ "vue": "^3.2.37"
88
86
  },
89
87
  "peerDependencies": {
90
88
  "vue": "^3.0.0"
91
89
  },
92
90
  "engines": {
93
- "node": ">=12.7.0"
91
+ "node": ">=14.15.0"
94
92
  },
95
93
  "publishConfig": {
96
94
  "access": "public"
@@ -19,9 +19,10 @@ import {
19
19
  isFilled,
20
20
  } from "@prismicio/helpers";
21
21
 
22
+ import { simplyResolveComponent } from "../lib/simplyResolveComponent";
23
+ import { __PRODUCTION__ } from "../lib/__PRODUCTION__";
22
24
  import { usePrismic } from "../usePrismic";
23
25
  import { VueUseOptions } from "../types";
24
- import { simplyResolveComponent } from "../lib/simplyResolveComponent";
25
26
 
26
27
  /**
27
28
  * The default component rendered for images.
@@ -59,8 +60,8 @@ export type PrismicImageProps = {
59
60
  * Adds an additional `srcset` attribute to the image following given widths.
60
61
  *
61
62
  * @remarks
62
- * A special value of `"auto"` is accepted to automatically use image widths
63
- * coming from the API.
63
+ * A special value of `"thumbnails"` is accepted to automatically use image
64
+ * widths coming from the API.
64
65
  * @remarks
65
66
  * A special value of `"defaults"` is accepted to automatically use image
66
67
  * widths coming from the plugin configuration.
@@ -70,7 +71,7 @@ export type PrismicImageProps = {
70
71
  */
71
72
  widths?:
72
73
  | NonNullable<Parameters<typeof asImageWidthSrcSet>[1]>["widths"]
73
- | "auto"
74
+ | "thumbnails"
74
75
  | "defaults";
75
76
 
76
77
  /**
@@ -149,30 +150,20 @@ export const usePrismicImage = (
149
150
  const pixelDensities = unref(props.pixelDensities);
150
151
 
151
152
  if (widths) {
152
- if (pixelDensities) {
153
+ if (!__PRODUCTION__ && pixelDensities) {
153
154
  console.warn(
154
- "[PrismicImage] `widths` and `pixelDensities` props should not be use alongside each others, only `widths` will be applied",
155
+ "[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.",
155
156
  props,
156
157
  );
157
158
  }
158
159
 
159
- if (widths === "auto") {
160
- return asImageWidthSrcSet(field, imgixParams);
161
- } else {
162
- // Remove potential thumbnails when using manual widths
163
- const { url, dimensions, alt, copyright } = field;
164
-
165
- return asImageWidthSrcSet(
166
- { url, dimensions, alt, copyright },
167
- {
168
- ...imgixParams,
169
- widths:
170
- widths === "defaults"
171
- ? options.components?.imageWidthSrcSetDefaults
172
- : widths,
173
- },
174
- );
175
- }
160
+ return asImageWidthSrcSet(field, {
161
+ ...imgixParams,
162
+ widths:
163
+ widths === "defaults"
164
+ ? options.components?.imageWidthSrcSetDefaults
165
+ : widths,
166
+ });
176
167
  } else if (pixelDensities) {
177
168
  return asImagePixelDensitySrcSet(field, {
178
169
  ...imgixParams,
@@ -235,7 +226,7 @@ export const PrismicImageImpl = /*#__PURE__*/ defineComponent({
235
226
  widths: {
236
227
  type: [String, Object] as PropType<
237
228
  | NonNullable<Parameters<typeof asImageWidthSrcSet>[1]>["widths"]
238
- | "auto"
229
+ | "thumbnails"
239
230
  | "defaults"
240
231
  >,
241
232
  default: undefined,
@@ -22,6 +22,7 @@ import {
22
22
  asHTML,
23
23
  HTMLFunctionSerializer,
24
24
  HTMLMapSerializer,
25
+ isFilled,
25
26
  LinkResolverFunction,
26
27
  } from "@prismicio/helpers";
27
28
  import { RichTextField } from "@prismicio/types";
@@ -43,7 +44,7 @@ export type PrismicRichTextProps = {
43
44
  /**
44
45
  * The Prismic rich text or title field to render.
45
46
  */
46
- field: RichTextField;
47
+ field: RichTextField | null | undefined;
47
48
 
48
49
  /**
49
50
  * A link resolver function used to resolve link when not using the route
@@ -70,6 +71,12 @@ export type PrismicRichTextProps = {
70
71
  * @defaultValue `"div"`
71
72
  */
72
73
  wrapper?: string | ConcreteComponent;
74
+
75
+ /**
76
+ * The HTML value to be rendered when the field is empty. If a fallback is not
77
+ * given, `""` (nothing) will be rendered.
78
+ */
79
+ fallback?: string;
73
80
  };
74
81
 
75
82
  /**
@@ -102,11 +109,17 @@ export const usePrismicRichText = (
102
109
  const { options } = usePrismic();
103
110
 
104
111
  const html = computed(() => {
112
+ const field = unref(props.field);
113
+
114
+ if (!isFilled.richText(field)) {
115
+ return unref(props.fallback) ?? "";
116
+ }
117
+
105
118
  const linkResolver = unref(props.linkResolver) ?? options.linkResolver;
106
119
  const htmlSerializer =
107
120
  unref(props.htmlSerializer) ?? options.htmlSerializer;
108
121
 
109
- return asHTML(unref(props.field), linkResolver, htmlSerializer);
122
+ return asHTML(unref(field), linkResolver, htmlSerializer);
110
123
  });
111
124
 
112
125
  return {
@@ -123,8 +136,9 @@ export const PrismicRichTextImpl = /*#__PURE__*/ defineComponent({
123
136
  name: "PrismicRichText",
124
137
  props: {
125
138
  field: {
126
- type: Array as unknown as PropType<RichTextField>,
127
- required: true,
139
+ type: Array as unknown as PropType<RichTextField | null | undefined>,
140
+ default: undefined,
141
+ required: false,
128
142
  },
129
143
  linkResolver: {
130
144
  type: Function as PropType<LinkResolverFunction>,
@@ -143,19 +157,19 @@ export const PrismicRichTextImpl = /*#__PURE__*/ defineComponent({
143
157
  default: undefined,
144
158
  required: false,
145
159
  },
160
+ fallback: {
161
+ type: String as PropType<string>,
162
+ default: undefined,
163
+ required: false,
164
+ },
146
165
  },
147
166
  setup(props) {
148
- // Prevent fatal if user didn't check for field, throws `Invalid prop` warn
149
- if (!props.field) {
150
- return () => null;
151
- }
152
-
153
167
  const { html } = usePrismicRichText(props);
154
168
 
155
169
  const root = ref<HTMLElement | Comment | Component | null>(null);
156
170
 
157
171
  const maybeRouter = inject(routerKey, null);
158
- if (maybeRouter) {
172
+ if (maybeRouter && html.value) {
159
173
  type InternalLink = {
160
174
  element: HTMLAnchorElement;
161
175
  listener: EventListener;
@@ -12,7 +12,7 @@ import {
12
12
  VNodeProps,
13
13
  } from "vue";
14
14
 
15
- import { asText } from "@prismicio/helpers";
15
+ import { asText, isFilled } from "@prismicio/helpers";
16
16
  import { RichTextField } from "@prismicio/types";
17
17
 
18
18
  import { VueUseOptions } from "../types";
@@ -29,7 +29,7 @@ export type PrismicTextProps = {
29
29
  /**
30
30
  * The Prismic rich text or title field to render.
31
31
  */
32
- field: RichTextField;
32
+ field: RichTextField | null | undefined;
33
33
 
34
34
  /**
35
35
  * Separator used to join each element.
@@ -44,6 +44,12 @@ export type PrismicTextProps = {
44
44
  * @defaultValue `"div"`
45
45
  */
46
46
  wrapper?: string | ConcreteComponent;
47
+
48
+ /**
49
+ * The string value to be rendered when the field is empty. If a fallback is
50
+ * not given, `""` (nothing) will be rendered.
51
+ */
52
+ fallback?: string;
47
53
  };
48
54
 
49
55
  /**
@@ -74,7 +80,13 @@ export const usePrismicText = (
74
80
  props: UsePrismicTextOptions,
75
81
  ): UsePrismicTextReturnType => {
76
82
  const text = computed(() => {
77
- return asText(unref(props.field), unref(props.separator));
83
+ const field = unref(props.field);
84
+
85
+ if (!isFilled.richText(field)) {
86
+ return unref(props.fallback) ?? "";
87
+ }
88
+
89
+ return asText(unref(field), unref(props.separator));
78
90
  });
79
91
 
80
92
  return {
@@ -91,8 +103,9 @@ export const PrismicTextImpl = /*#__PURE__*/ defineComponent({
91
103
  name: "PrismicText",
92
104
  props: {
93
105
  field: {
94
- type: Array as unknown as PropType<RichTextField>,
95
- required: true,
106
+ type: Array as unknown as PropType<RichTextField | null | undefined>,
107
+ default: undefined,
108
+ required: false,
96
109
  },
97
110
  separator: {
98
111
  type: String as PropType<string>,
@@ -104,13 +117,13 @@ export const PrismicTextImpl = /*#__PURE__*/ defineComponent({
104
117
  default: undefined,
105
118
  required: false,
106
119
  },
120
+ fallback: {
121
+ type: String as PropType<string>,
122
+ default: undefined,
123
+ required: false,
124
+ },
107
125
  },
108
126
  setup(props) {
109
- // Prevent fatal if user didn't check for field, throws `Invalid prop` warn
110
- if (!props.field) {
111
- return () => null;
112
- }
113
-
114
127
  const { text } = usePrismicText(props);
115
128
 
116
129
  return () => {
@@ -19,6 +19,40 @@ import { simplyResolveComponent } from "../lib/simplyResolveComponent";
19
19
  import { __PRODUCTION__ } from "../lib/__PRODUCTION__";
20
20
  import { usePrismic } from "../usePrismic";
21
21
 
22
+ /**
23
+ * Returns the type of a `SliceLike` type.
24
+ *
25
+ * @typeParam TSlice - The Slice from which the type will be extracted.
26
+ */
27
+ type ExtractSliceType<TSlice extends SliceLike> = TSlice extends SliceLikeRestV2
28
+ ? TSlice["slice_type"]
29
+ : TSlice extends SliceLikeGraphQL
30
+ ? TSlice["type"]
31
+ : never;
32
+
33
+ /**
34
+ * The minimum required properties to represent a Prismic Slice from the Prismic
35
+ * Rest API V2 for the `<SliceZone>` component.
36
+ *
37
+ * If using Prismic's Rest API V2, use the `Slice` export from
38
+ * `@prismicio/types` for a full interface.
39
+ *
40
+ * @typeParam TSliceType - Type name of the Slice.
41
+ */
42
+ export type SliceLikeRestV2<TSliceType extends string = string> = {
43
+ slice_type: Slice<TSliceType>["slice_type"];
44
+ };
45
+
46
+ /**
47
+ * The minimum required properties to represent a Prismic Slice from the Prismic
48
+ * GraphQL API for the `<SliceZone>` component.
49
+ *
50
+ * @typeParam TSliceType - Type name of the Slice.
51
+ */
52
+ export type SliceLikeGraphQL<TSliceType extends string = string> = {
53
+ type: Slice<TSliceType>["slice_type"];
54
+ };
55
+
22
56
  /**
23
57
  * The minimum required properties to represent a Prismic Slice for the
24
58
  * `<SliceZone />` component.
@@ -28,10 +62,9 @@ import { usePrismic } from "../usePrismic";
28
62
  *
29
63
  * @typeParam TSliceType - Type name of the Slice
30
64
  */
31
- export type SliceLike<TSliceType extends string = string> = Pick<
32
- Slice<TSliceType>,
33
- "slice_type"
34
- >;
65
+ export type SliceLike<TSliceType extends string = string> =
66
+ | SliceLikeRestV2<TSliceType>
67
+ | SliceLikeGraphQL<TSliceType>;
35
68
 
36
69
  /**
37
70
  * A looser version of the `SliceZone` type from `@prismicio/types` using `SliceLike`.
@@ -41,7 +74,8 @@ export type SliceLike<TSliceType extends string = string> = Pick<
41
74
  *
42
75
  * @typeParam TSlice - The type(s) of slices in the Slice Zone
43
76
  */
44
- export type SliceZoneLike<TSlice extends SliceLike> = readonly TSlice[];
77
+ export type SliceZoneLike<TSlice extends SliceLike = SliceLike> =
78
+ readonly TSlice[];
45
79
 
46
80
  /**
47
81
  * Vue props for a component rendering content from a Prismic Slice using the
@@ -52,7 +86,8 @@ export type SliceZoneLike<TSlice extends SliceLike> = readonly TSlice[];
52
86
  * available to all Slice components
53
87
  */
54
88
  export type SliceComponentProps<
55
- TSlice extends SliceLike = SliceLike,
89
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
90
+ TSlice extends SliceLike = any,
56
91
  TContext = unknown,
57
92
  > = {
58
93
  /**
@@ -89,7 +124,8 @@ export type SliceComponentProps<
89
124
  * available to all Slice components
90
125
  */
91
126
  export type DefineComponentSliceComponentProps<
92
- TSlice extends SliceLike = SliceLike,
127
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
128
+ TSlice extends SliceLike = any,
93
129
  TContext = unknown,
94
130
  > = {
95
131
  slice: {
@@ -178,7 +214,8 @@ export const getSliceComponentProps = <
178
214
  * @typeParam TContext - Arbitrary data made available to all Slice components
179
215
  */
180
216
  export type SliceComponentType<
181
- TSlice extends SliceLike = SliceLike,
217
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
218
+ TSlice extends SliceLike = any,
182
219
  TContext = unknown,
183
220
  > =
184
221
  | DefineComponent<SliceComponentProps<TSlice, TContext>>
@@ -196,9 +233,15 @@ export const TODOSliceComponent = __PRODUCTION__
196
233
  name: "TODOSliceComponent",
197
234
  props: getSliceComponentProps(),
198
235
  setup(props) {
236
+ const type = computed(() =>
237
+ "slice_type" in props.slice
238
+ ? props.slice.slice_type
239
+ : props.slice.type,
240
+ );
241
+
199
242
  watchEffect(() => {
200
243
  console.warn(
201
- `[SliceZone] Could not find a component for Slice type "${props.slice.slice_type}"`,
244
+ `[SliceZone] Could not find a component for Slice type "${type.value}"`,
202
245
  props.slice,
203
246
  );
204
247
  });
@@ -208,11 +251,9 @@ export const TODOSliceComponent = __PRODUCTION__
208
251
  "section",
209
252
  {
210
253
  "data-slice-zone-todo-component": "",
211
- "data-slice-type": props.slice.slice_type,
254
+ "data-slice-type": type.value,
212
255
  },
213
- [
214
- `Could not find a component for Slice type "${props.slice.slice_type}"`,
215
- ],
256
+ [`Could not find a component for Slice type "${type.value}"`],
216
257
  );
217
258
  };
218
259
  },
@@ -239,7 +280,7 @@ export type SliceZoneComponents<
239
280
  // signals to future developers that it is a placeholder and should be
240
281
  // implemented.
241
282
  {
242
- [SliceType in keyof Record<TSlice["slice_type"], never>]:
283
+ [SliceType in ExtractSliceType<TSlice>]:
243
284
  | SliceComponentType<Extract<TSlice, SliceLike<SliceType>>, TContext>
244
285
  | string;
245
286
  };
@@ -277,7 +318,8 @@ export type SliceZoneComponents<
277
318
  * @returns A new optimized record of {@link SliceZoneComponents}
278
319
  */
279
320
  export const defineSliceZoneComponents = <
280
- TSlice extends SliceLike = SliceLike,
321
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
322
+ TSlice extends SliceLike = any,
281
323
  TContext = unknown,
282
324
  >(
283
325
  components: SliceZoneComponents<TSlice, TContext>,
@@ -313,7 +355,7 @@ export type SliceZoneResolverArgs<TSlice extends SliceLike = SliceLike> = {
313
355
  /**
314
356
  * The name of the Slice.
315
357
  */
316
- sliceName: TSlice["slice_type"];
358
+ sliceName: ExtractSliceType<TSlice>;
317
359
 
318
360
  /**
319
361
  * The index of the Slice in the Slice Zone.
@@ -333,26 +375,24 @@ export type SliceZoneResolverArgs<TSlice extends SliceLike = SliceLike> = {
333
375
  * @returns The Vue component to render for a Slice.
334
376
  */
335
377
  export type SliceZoneResolver<
336
- TSlice extends SliceLike = SliceLike,
378
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
379
+ TSlice extends SliceLike = any,
337
380
  TContext = unknown,
338
381
  > = (
339
382
  args: SliceZoneResolverArgs<TSlice>,
340
- ) => SliceComponentType<TSlice, TContext> | string | undefined | null;
383
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
384
+ ) => SliceComponentType<any, TContext> | string | undefined | null;
341
385
 
342
386
  /**
343
387
  * Props for `<SliceZone />`.
344
388
  *
345
- * @typeParam TSlice - The type(s) of slices in the Slice Zone
346
389
  * @typeParam TContext - Arbitrary data made available to all Slice components
347
390
  */
348
- export type SliceZoneProps<
349
- TSlice extends SliceLike = SliceLike,
350
- TContext = unknown,
351
- > = {
391
+ export type SliceZoneProps<TContext = unknown> = {
352
392
  /**
353
393
  * List of Slice data from the Slice Zone.
354
394
  */
355
- slices: SliceZoneLike<TSlice>;
395
+ slices: SliceZoneLike;
356
396
 
357
397
  /**
358
398
  * A record mapping Slice types to Vue components.
@@ -369,7 +409,8 @@ export type SliceZoneProps<
369
409
  *
370
410
  * @returns The Vue component to render for a Slice.
371
411
  */
372
- resolver?: SliceZoneResolver<TSlice, TContext>;
412
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
413
+ resolver?: SliceZoneResolver<any, TContext>;
373
414
 
374
415
  /**
375
416
  * Arbitrary data made available to all Slice components.
@@ -385,7 +426,8 @@ export type SliceZoneProps<
385
426
  *
386
427
  * @defaultValue The Slice Zone default component provided to `@prismicio/vue` plugin if configured, otherwise `null` when `process.env.NODE_ENV === "production"` else {@link TODOSliceComponent}.
387
428
  */
388
- defaultComponent?: SliceComponentType<TSlice, TContext>;
429
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
430
+ defaultComponent?: SliceComponentType<any, TContext>;
389
431
 
390
432
  /**
391
433
  * An HTML tag name, a component, or a functional component used to wrap the
@@ -403,7 +445,7 @@ export const SliceZoneImpl = /*#__PURE__*/ defineComponent({
403
445
  name: "SliceZone",
404
446
  props: {
405
447
  slices: {
406
- type: Array as PropType<SliceZoneLike<SliceLike>>,
448
+ type: Array as PropType<SliceZoneLike>,
407
449
  required: true,
408
450
  },
409
451
  components: {
@@ -442,9 +484,11 @@ export const SliceZoneImpl = /*#__PURE__*/ defineComponent({
442
484
 
443
485
  const renderedSlices = computed(() => {
444
486
  return props.slices.map((slice, index) => {
487
+ const type = "slice_type" in slice ? slice.slice_type : slice.type;
488
+
445
489
  let component =
446
- props.components && slice.slice_type in props.components
447
- ? props.components[slice.slice_type]
490
+ props.components && type in props.components
491
+ ? props.components[type]
448
492
  : props.defaultComponent ||
449
493
  options.components?.sliceZoneDefaultComponent ||
450
494
  TODOSliceComponent;
@@ -453,7 +497,7 @@ export const SliceZoneImpl = /*#__PURE__*/ defineComponent({
453
497
  if (props.resolver) {
454
498
  const resolvedComponent = props.resolver({
455
499
  slice,
456
- sliceName: slice.slice_type,
500
+ sliceName: type,
457
501
  i: index,
458
502
  });
459
503
 
@@ -463,7 +507,7 @@ export const SliceZoneImpl = /*#__PURE__*/ defineComponent({
463
507
  }
464
508
 
465
509
  const p = {
466
- key: `${slice.slice_type}-${index}`,
510
+ key: `${index}-${JSON.stringify(slice)}`,
467
511
  slice,
468
512
  index,
469
513
  context: props.context,
@@ -35,6 +35,8 @@ export type {
35
35
  DefineComponentSliceComponentProps,
36
36
  SliceComponentProps,
37
37
  SliceComponentType,
38
+ SliceLikeRestV2,
39
+ SliceLikeGraphQL,
38
40
  SliceLike,
39
41
  SliceZoneComponents,
40
42
  SliceZoneResolverArgs,
package/src/index.ts CHANGED
@@ -35,6 +35,8 @@ export type {
35
35
  DefineComponentSliceComponentProps,
36
36
  SliceComponentProps,
37
37
  SliceComponentType,
38
+ SliceLikeRestV2,
39
+ SliceLikeGraphQL,
38
40
  SliceLike,
39
41
  SliceZoneComponents,
40
42
  SliceZoneResolver,
@@ -74,6 +74,10 @@
74
74
  "type": "string | object | function",
75
75
  "description": "An HTML tag name, a component, or a functional component used to wrap the output. Defaults to `\"div\"`."
76
76
  },
77
+ "prismic-rich-text/fallback": {
78
+ "type": "string",
79
+ "description": "The HTML value to be rendered when the field is empty. If a fallback is not given, `\"\"` (nothing) will be rendered."
80
+ },
77
81
 
78
82
  "prismic-text/field": {
79
83
  "type": "array",
@@ -87,6 +91,10 @@
87
91
  "type": "string | object | function",
88
92
  "description": "An HTML tag name, a component, or a functional component used to wrap the output. Defaults to `\"div\"`."
89
93
  },
94
+ "prismic-text/fallback": {
95
+ "type": "string",
96
+ "description": "The string value to be rendered when the field is empty. If a fallback is not given, `\"\"` (nothing) will be rendered."
97
+ },
90
98
 
91
99
  "slice-zone/slices": {
92
100
  "type": "array",
package/vetur/tags.json CHANGED
@@ -26,11 +26,11 @@
26
26
  "description": "Component to render a Prismic link field."
27
27
  },
28
28
  "prismic-rich-text": {
29
- "attributes": ["field", "link-resolver", "html-serializer", "wrapper"],
29
+ "attributes": ["field", "link-resolver", "html-serializer", "wrapper", "fallback"],
30
30
  "description": "Component to render a Prismic rich text field as HTML."
31
31
  },
32
32
  "prismic-text": {
33
- "attributes": ["field", "separator", "wrapper"],
33
+ "attributes": ["field", "separator", "wrapper", "fallback"],
34
34
  "description": "Component to render a Prismic rich text field as plain text."
35
35
  },
36
36
  "slice-zone": {