@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.d.ts CHANGED
@@ -5,6 +5,33 @@ import { Client, ClientConfig, predicate, cookie, PrismicError, ParsingError, Fo
5
5
  import { asText, asHTML, asLink, LinkResolverFunction, asDate, asImageSrc, asImageWidthSrcSet, asImagePixelDensitySrcSet, documentToLinkField, HTMLFunctionSerializer, HTMLMapSerializer } from '@prismicio/helpers';
6
6
  import { Slice, EmbedField, ImageField, LinkField, PrismicDocument, RichTextField, Query } from '@prismicio/types';
7
7
 
8
+ /**
9
+ * Returns the type of a `SliceLike` type.
10
+ *
11
+ * @typeParam TSlice - The Slice from which the type will be extracted.
12
+ */
13
+ declare type ExtractSliceType<TSlice extends SliceLike> = TSlice extends SliceLikeRestV2 ? TSlice["slice_type"] : TSlice extends SliceLikeGraphQL ? TSlice["type"] : never;
14
+ /**
15
+ * The minimum required properties to represent a Prismic Slice from the Prismic
16
+ * Rest API V2 for the `<SliceZone>` component.
17
+ *
18
+ * If using Prismic's Rest API V2, use the `Slice` export from
19
+ * `@prismicio/types` for a full interface.
20
+ *
21
+ * @typeParam TSliceType - Type name of the Slice.
22
+ */
23
+ declare type SliceLikeRestV2<TSliceType extends string = string> = {
24
+ slice_type: Slice<TSliceType>["slice_type"];
25
+ };
26
+ /**
27
+ * The minimum required properties to represent a Prismic Slice from the Prismic
28
+ * GraphQL API for the `<SliceZone>` component.
29
+ *
30
+ * @typeParam TSliceType - Type name of the Slice.
31
+ */
32
+ declare type SliceLikeGraphQL<TSliceType extends string = string> = {
33
+ type: Slice<TSliceType>["slice_type"];
34
+ };
8
35
  /**
9
36
  * The minimum required properties to represent a Prismic Slice for the
10
37
  * `<SliceZone />` component.
@@ -14,7 +41,7 @@ import { Slice, EmbedField, ImageField, LinkField, PrismicDocument, RichTextFiel
14
41
  *
15
42
  * @typeParam TSliceType - Type name of the Slice
16
43
  */
17
- declare type SliceLike<TSliceType extends string = string> = Pick<Slice<TSliceType>, "slice_type">;
44
+ declare type SliceLike<TSliceType extends string = string> = SliceLikeRestV2<TSliceType> | SliceLikeGraphQL<TSliceType>;
18
45
  /**
19
46
  * A looser version of the `SliceZone` type from `@prismicio/types` using `SliceLike`.
20
47
  *
@@ -23,7 +50,7 @@ declare type SliceLike<TSliceType extends string = string> = Pick<Slice<TSliceTy
23
50
  *
24
51
  * @typeParam TSlice - The type(s) of slices in the Slice Zone
25
52
  */
26
- declare type SliceZoneLike<TSlice extends SliceLike> = readonly TSlice[];
53
+ declare type SliceZoneLike<TSlice extends SliceLike = SliceLike> = readonly TSlice[];
27
54
  /**
28
55
  * Vue props for a component rendering content from a Prismic Slice using the
29
56
  * `<SliceZone />` component.
@@ -32,7 +59,7 @@ declare type SliceZoneLike<TSlice extends SliceLike> = readonly TSlice[];
32
59
  * @typeParam TContext - Arbitrary data passed to `<SliceZone />` and made
33
60
  * available to all Slice components
34
61
  */
35
- declare type SliceComponentProps<TSlice extends SliceLike = SliceLike, TContext = unknown> = {
62
+ declare type SliceComponentProps<TSlice extends SliceLike = any, TContext = unknown> = {
36
63
  /**
37
64
  * Slice data for this component.
38
65
  */
@@ -58,7 +85,7 @@ declare type SliceComponentProps<TSlice extends SliceLike = SliceLike, TContext
58
85
  * @typeParam TContext - Arbitrary data passed to `<SliceZone />` and made
59
86
  * available to all Slice components
60
87
  */
61
- declare type DefineComponentSliceComponentProps<TSlice extends SliceLike = SliceLike, TContext = unknown> = {
88
+ declare type DefineComponentSliceComponentProps<TSlice extends SliceLike = any, TContext = unknown> = {
62
89
  slice: {
63
90
  type: PropType<SliceComponentProps<TSlice, TContext>["slice"]>;
64
91
  required: true;
@@ -110,21 +137,23 @@ declare type DefineComponentSliceComponentProps<TSlice extends SliceLike = Slice
110
137
  *
111
138
  * @returns Props object to use with {@link defineComponent}
112
139
  */
113
- declare const getSliceComponentProps: <TSlice extends SliceLike<string> = SliceLike<string>, TContext = unknown>(propsHint?: ["slice", "index", "slices", "context"] | undefined) => DefineComponentSliceComponentProps<TSlice, TContext>;
140
+ declare const getSliceComponentProps: <TSlice extends SliceLike<string> = SliceLike<string>, TContext = unknown>(propsHint?: ["slice", "index", "slices", "context"]) => DefineComponentSliceComponentProps<TSlice, TContext>;
114
141
  /**
115
142
  * A Vue component to be rendered for each instance of its Slice.
116
143
  *
117
144
  * @typeParam TSlice - The type(s) of slices in the Slice Zone
118
145
  * @typeParam TContext - Arbitrary data made available to all Slice components
119
146
  */
120
- declare type SliceComponentType<TSlice extends SliceLike = SliceLike, TContext = unknown> = DefineComponent<SliceComponentProps<TSlice, TContext>> | FunctionalComponent<SliceComponentProps<TSlice, TContext>>;
147
+ declare type SliceComponentType<TSlice extends SliceLike = any, TContext = unknown> = DefineComponent<SliceComponentProps<TSlice, TContext>> | FunctionalComponent<SliceComponentProps<TSlice, TContext>>;
121
148
  /**
122
149
  * This Slice component can be used as a reminder to provide a proper implementation.
123
150
  *
124
151
  * This is also the default Vue component rendered when a component mapping
125
152
  * cannot be found in `<SliceZone />`.
126
153
  */
127
- declare const TODOSliceComponent: FunctionalComponent<SliceComponentProps<SliceLike<string>, unknown>, {}> | DefineComponent<SliceComponentProps<SliceLike<string>, unknown>, {}, {}, vue.ComputedOptions, vue.MethodOptions, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<SliceComponentProps<SliceLike<string>, unknown>>, {}>;
154
+ declare const TODOSliceComponent: FunctionalComponent<SliceComponentProps<any, unknown>, {}> | DefineComponent<SliceComponentProps<any, unknown>, {}, {}, vue.ComputedOptions, vue.MethodOptions, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<SliceComponentProps<any, unknown>>, {
155
+ slice: any;
156
+ }>;
128
157
  /**
129
158
  * A record of Slice types mapped to Vue components. Each components will be
130
159
  * rendered for each instance of their Slice type.
@@ -133,7 +162,7 @@ declare const TODOSliceComponent: FunctionalComponent<SliceComponentProps<SliceL
133
162
  * @typeParam TContext - Arbitrary data made available to all Slice components
134
163
  */
135
164
  declare type SliceZoneComponents<TSlice extends SliceLike = SliceLike, TContext = unknown> = {
136
- [SliceType in keyof Record<TSlice["slice_type"], never>]: SliceComponentType<Extract<TSlice, SliceLike<SliceType>>, TContext> | string;
165
+ [SliceType in ExtractSliceType<TSlice>]: SliceComponentType<Extract<TSlice, SliceLike<SliceType>>, TContext> | string;
137
166
  };
138
167
  /**
139
168
  * Gets an optimized record of Slice types mapped to Vue components. Each
@@ -167,7 +196,7 @@ declare type SliceZoneComponents<TSlice extends SliceLike = SliceLike, TContext
167
196
  *
168
197
  * @returns A new optimized record of {@link SliceZoneComponents}
169
198
  */
170
- declare const defineSliceZoneComponents: <TSlice extends SliceLike<string> = SliceLike<string>, TContext = unknown>(components: SliceZoneComponents<TSlice, TContext>) => SliceZoneComponents<TSlice, TContext>;
199
+ declare const defineSliceZoneComponents: <TSlice extends SliceLike<string> = any, TContext = unknown>(components: SliceZoneComponents<TSlice, TContext>) => SliceZoneComponents<TSlice, TContext>;
171
200
  /**
172
201
  * Arguments for a `<SliceZone>` `resolver` function.
173
202
  */
@@ -179,7 +208,7 @@ declare type SliceZoneResolverArgs<TSlice extends SliceLike = SliceLike> = {
179
208
  /**
180
209
  * The name of the Slice.
181
210
  */
182
- sliceName: TSlice["slice_type"];
211
+ sliceName: ExtractSliceType<TSlice>;
183
212
  /**
184
213
  * The index of the Slice in the Slice Zone.
185
214
  */
@@ -196,18 +225,17 @@ declare type SliceZoneResolverArgs<TSlice extends SliceLike = SliceLike> = {
196
225
  *
197
226
  * @returns The Vue component to render for a Slice.
198
227
  */
199
- declare type SliceZoneResolver<TSlice extends SliceLike = SliceLike, TContext = unknown> = (args: SliceZoneResolverArgs<TSlice>) => SliceComponentType<TSlice, TContext> | string | undefined | null;
228
+ declare type SliceZoneResolver<TSlice extends SliceLike = any, TContext = unknown> = (args: SliceZoneResolverArgs<TSlice>) => SliceComponentType<any, TContext> | string | undefined | null;
200
229
  /**
201
230
  * Props for `<SliceZone />`.
202
231
  *
203
- * @typeParam TSlice - The type(s) of slices in the Slice Zone
204
232
  * @typeParam TContext - Arbitrary data made available to all Slice components
205
233
  */
206
- declare type SliceZoneProps<TSlice extends SliceLike = SliceLike, TContext = unknown> = {
234
+ declare type SliceZoneProps<TContext = unknown> = {
207
235
  /**
208
236
  * List of Slice data from the Slice Zone.
209
237
  */
210
- slices: SliceZoneLike<TSlice>;
238
+ slices: SliceZoneLike;
211
239
  /**
212
240
  * A record mapping Slice types to Vue components.
213
241
  */
@@ -222,7 +250,7 @@ declare type SliceZoneProps<TSlice extends SliceLike = SliceLike, TContext = unk
222
250
  *
223
251
  * @returns The Vue component to render for a Slice.
224
252
  */
225
- resolver?: SliceZoneResolver<TSlice, TContext>;
253
+ resolver?: SliceZoneResolver<any, TContext>;
226
254
  /**
227
255
  * Arbitrary data made available to all Slice components.
228
256
  */
@@ -236,7 +264,7 @@ declare type SliceZoneProps<TSlice extends SliceLike = SliceLike, TContext = unk
236
264
  *
237
265
  * @defaultValue The Slice Zone default component provided to `@prismicio/vue` plugin if configured, otherwise `null` when `process.env.NODE_ENV === "production"` else {@link TODOSliceComponent}.
238
266
  */
239
- defaultComponent?: SliceComponentType<TSlice, TContext>;
267
+ defaultComponent?: SliceComponentType<any, TContext>;
240
268
  /**
241
269
  * An HTML tag name, a component, or a functional component used to wrap the
242
270
  * output. The Slice Zone is not wrapped by default.
@@ -850,7 +878,7 @@ declare type PrismicTextProps = {
850
878
  /**
851
879
  * The Prismic rich text or title field to render.
852
880
  */
853
- field: RichTextField;
881
+ field: RichTextField | null | undefined;
854
882
  /**
855
883
  * Separator used to join each element.
856
884
  *
@@ -863,6 +891,11 @@ declare type PrismicTextProps = {
863
891
  * @defaultValue `"div"`
864
892
  */
865
893
  wrapper?: string | ConcreteComponent;
894
+ /**
895
+ * The string value to be rendered when the field is empty. If a fallback is
896
+ * not given, `""` (nothing) will be rendered.
897
+ */
898
+ fallback?: string;
866
899
  };
867
900
  /**
868
901
  * Options for {@link usePrismicText}.
@@ -902,7 +935,7 @@ declare type PrismicRichTextProps = {
902
935
  /**
903
936
  * The Prismic rich text or title field to render.
904
937
  */
905
- field: RichTextField;
938
+ field: RichTextField | null | undefined;
906
939
  /**
907
940
  * A link resolver function used to resolve link when not using the route
908
941
  * resolver parameter with `@prismicio/client`.
@@ -926,6 +959,11 @@ declare type PrismicRichTextProps = {
926
959
  * @defaultValue `"div"`
927
960
  */
928
961
  wrapper?: string | ConcreteComponent;
962
+ /**
963
+ * The HTML value to be rendered when the field is empty. If a fallback is not
964
+ * given, `""` (nothing) will be rendered.
965
+ */
966
+ fallback?: string;
929
967
  };
930
968
  /**
931
969
  * Options for {@link usePrismicRichText}.
@@ -1010,6 +1048,8 @@ declare const usePrismicDocuments: <TDocument extends PrismicDocument<Record<str
1010
1048
  removeEventListener: any;
1011
1049
  dispatchEvent: any;
1012
1050
  onabort: any;
1051
+ reason: any;
1052
+ throwIfAborted: any;
1013
1053
  } | undefined;
1014
1054
  } & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<Query<TDocument>>;
1015
1055
  /**
@@ -1034,6 +1074,8 @@ declare const useFirstPrismicDocument: <TDocument extends PrismicDocument<Record
1034
1074
  removeEventListener: any;
1035
1075
  dispatchEvent: any;
1036
1076
  onabort: any;
1077
+ reason: any;
1078
+ throwIfAborted: any;
1037
1079
  } | undefined;
1038
1080
  } & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<TDocument>;
1039
1081
  /**
@@ -1058,6 +1100,8 @@ declare const usePrismicDocumentByID: <TDocument extends PrismicDocument<Record<
1058
1100
  removeEventListener: any;
1059
1101
  dispatchEvent: any;
1060
1102
  onabort: any;
1103
+ reason: any;
1104
+ throwIfAborted: any;
1061
1105
  } | undefined;
1062
1106
  } & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<TDocument>;
1063
1107
  /**
@@ -1082,6 +1126,8 @@ declare const usePrismicDocumentsByIDs: <TDocument extends PrismicDocument<Recor
1082
1126
  removeEventListener: any;
1083
1127
  dispatchEvent: any;
1084
1128
  onabort: any;
1129
+ reason: any;
1130
+ throwIfAborted: any;
1085
1131
  } | undefined;
1086
1132
  } & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<Query<TDocument>>;
1087
1133
  /**
@@ -1108,6 +1154,8 @@ declare const useAllPrismicDocumentsByIDs: <TDocument extends PrismicDocument<Re
1108
1154
  removeEventListener: any;
1109
1155
  dispatchEvent: any;
1110
1156
  onabort: any;
1157
+ reason: any;
1158
+ throwIfAborted: any;
1111
1159
  } | undefined;
1112
1160
  } & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<TDocument[]>;
1113
1161
  /**
@@ -1134,6 +1182,8 @@ declare const usePrismicDocumentByUID: <TDocument extends PrismicDocument<Record
1134
1182
  removeEventListener: any;
1135
1183
  dispatchEvent: any;
1136
1184
  onabort: any;
1185
+ reason: any;
1186
+ throwIfAborted: any;
1137
1187
  } | undefined;
1138
1188
  } & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<TDocument>;
1139
1189
  /**
@@ -1159,6 +1209,8 @@ declare const usePrismicDocumentsByUIDs: <TDocument extends PrismicDocument<Reco
1159
1209
  removeEventListener: any;
1160
1210
  dispatchEvent: any;
1161
1211
  onabort: any;
1212
+ reason: any;
1213
+ throwIfAborted: any;
1162
1214
  } | undefined;
1163
1215
  } & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<Query<TDocument>>;
1164
1216
  /**
@@ -1186,6 +1238,8 @@ declare const useAllPrismicDocumentsByUIDs: <TDocument extends PrismicDocument<R
1186
1238
  removeEventListener: any;
1187
1239
  dispatchEvent: any;
1188
1240
  onabort: any;
1241
+ reason: any;
1242
+ throwIfAborted: any;
1189
1243
  } | undefined;
1190
1244
  } & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<TDocument[]>;
1191
1245
  /**
@@ -1211,6 +1265,8 @@ declare const useSinglePrismicDocument: <TDocument extends PrismicDocument<Recor
1211
1265
  removeEventListener: any;
1212
1266
  dispatchEvent: any;
1213
1267
  onabort: any;
1268
+ reason: any;
1269
+ throwIfAborted: any;
1214
1270
  } | undefined;
1215
1271
  } & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<TDocument>;
1216
1272
  /**
@@ -1236,6 +1292,8 @@ declare const usePrismicDocumentsByType: <TDocument extends PrismicDocument<Reco
1236
1292
  removeEventListener: any;
1237
1293
  dispatchEvent: any;
1238
1294
  onabort: any;
1295
+ reason: any;
1296
+ throwIfAborted: any;
1239
1297
  } | undefined;
1240
1298
  } & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<Query<TDocument>>;
1241
1299
  /**
@@ -1263,6 +1321,8 @@ declare const useAllPrismicDocumentsByType: <TDocument extends PrismicDocument<R
1263
1321
  removeEventListener: any;
1264
1322
  dispatchEvent: any;
1265
1323
  onabort: any;
1324
+ reason: any;
1325
+ throwIfAborted: any;
1266
1326
  } | undefined;
1267
1327
  } & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<TDocument[]>;
1268
1328
  /**
@@ -1287,6 +1347,8 @@ declare const usePrismicDocumentsByTag: <TDocument extends PrismicDocument<Recor
1287
1347
  removeEventListener: any;
1288
1348
  dispatchEvent: any;
1289
1349
  onabort: any;
1350
+ reason: any;
1351
+ throwIfAborted: any;
1290
1352
  } | undefined;
1291
1353
  } & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<Query<TDocument>>;
1292
1354
  /**
@@ -1314,6 +1376,8 @@ declare const useAllPrismicDocumentsByTag: <TDocument extends PrismicDocument<Re
1314
1376
  removeEventListener: any;
1315
1377
  dispatchEvent: any;
1316
1378
  onabort: any;
1379
+ reason: any;
1380
+ throwIfAborted: any;
1317
1381
  } | undefined;
1318
1382
  } & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<TDocument[]>;
1319
1383
  /**
@@ -1339,6 +1403,8 @@ declare const usePrismicDocumentsByEveryTag: <TDocument extends PrismicDocument<
1339
1403
  removeEventListener: any;
1340
1404
  dispatchEvent: any;
1341
1405
  onabort: any;
1406
+ reason: any;
1407
+ throwIfAborted: any;
1342
1408
  } | undefined;
1343
1409
  } & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<Query<TDocument>>;
1344
1410
  /**
@@ -1366,6 +1432,8 @@ declare const useAllPrismicDocumentsByEveryTag: <TDocument extends PrismicDocume
1366
1432
  removeEventListener: any;
1367
1433
  dispatchEvent: any;
1368
1434
  onabort: any;
1435
+ reason: any;
1436
+ throwIfAborted: any;
1369
1437
  } | undefined;
1370
1438
  } & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<TDocument[]>;
1371
1439
  /**
@@ -1391,6 +1459,8 @@ declare const usePrismicDocumentsBySomeTags: <TDocument extends PrismicDocument<
1391
1459
  removeEventListener: any;
1392
1460
  dispatchEvent: any;
1393
1461
  onabort: any;
1462
+ reason: any;
1463
+ throwIfAborted: any;
1394
1464
  } | undefined;
1395
1465
  } & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<Query<TDocument>>;
1396
1466
  /**
@@ -1419,6 +1489,8 @@ declare const useAllPrismicDocumentsBySomeTags: <TDocument extends PrismicDocume
1419
1489
  removeEventListener: any;
1420
1490
  dispatchEvent: any;
1421
1491
  onabort: any;
1492
+ reason: any;
1493
+ throwIfAborted: any;
1422
1494
  } | undefined;
1423
1495
  } & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<TDocument[]>;
1424
1496
  /**
@@ -1449,6 +1521,8 @@ declare const dangerouslyUseAllPrismicDocuments: <TDocument extends PrismicDocum
1449
1521
  removeEventListener: any;
1450
1522
  dispatchEvent: any;
1451
1523
  onabort: any;
1524
+ reason: any;
1525
+ throwIfAborted: any;
1452
1526
  } | undefined;
1453
1527
  } & ComposableOnlyParameters) | undefined) => ClientComposableReturnType<TDocument[]>;
1454
1528
 
@@ -1470,4 +1544,4 @@ declare module "@vue/runtime-core" {
1470
1544
  }
1471
1545
  }
1472
1546
 
1473
- export { ClientComposableReturnType, DefineComponentSliceComponentProps, PrismicClientComposableState, PrismicEmbed, PrismicEmbedProps, PrismicImage, PrismicImageProps, PrismicLink, PrismicLinkProps, PrismicPlugin, PrismicPluginOptions, PrismicRichText, PrismicRichTextProps, PrismicText, PrismicTextProps, SliceComponentProps, SliceComponentType, SliceLike, SliceZone, SliceZoneComponents, SliceZoneLike, SliceZoneProps, SliceZoneResolver, TODOSliceComponent, UsePrismicImageOptions, UsePrismicLinkOptions, UsePrismicRichTextOptions, UsePrismicTextOptions, createPrismic, dangerouslyUseAllPrismicDocuments, defineSliceZoneComponents, getSliceComponentProps, prismicKey, useAllPrismicDocumentsByEveryTag, useAllPrismicDocumentsByIDs, useAllPrismicDocumentsBySomeTags, useAllPrismicDocumentsByTag, useAllPrismicDocumentsByType, useAllPrismicDocumentsByUIDs, useFirstPrismicDocument, usePrismic, usePrismicDocumentByID, usePrismicDocumentByUID, usePrismicDocuments, usePrismicDocumentsByEveryTag, usePrismicDocumentsByIDs, usePrismicDocumentsBySomeTags, usePrismicDocumentsByTag, usePrismicDocumentsByType, usePrismicDocumentsByUIDs, usePrismicImage, usePrismicLink, usePrismicRichText, usePrismicText, useSinglePrismicDocument };
1547
+ export { ClientComposableReturnType, DefineComponentSliceComponentProps, PrismicClientComposableState, PrismicEmbed, PrismicEmbedProps, PrismicImage, PrismicImageProps, PrismicLink, PrismicLinkProps, PrismicPlugin, PrismicPluginOptions, PrismicRichText, PrismicRichTextProps, PrismicText, PrismicTextProps, SliceComponentProps, SliceComponentType, SliceLike, SliceLikeGraphQL, SliceLikeRestV2, SliceZone, SliceZoneComponents, SliceZoneLike, SliceZoneProps, SliceZoneResolver, TODOSliceComponent, UsePrismicImageOptions, UsePrismicLinkOptions, UsePrismicRichTextOptions, UsePrismicTextOptions, createPrismic, dangerouslyUseAllPrismicDocuments, defineSliceZoneComponents, getSliceComponentProps, prismicKey, useAllPrismicDocumentsByEveryTag, useAllPrismicDocumentsByIDs, useAllPrismicDocumentsBySomeTags, useAllPrismicDocumentsByTag, useAllPrismicDocumentsByType, useAllPrismicDocumentsByUIDs, useFirstPrismicDocument, usePrismic, usePrismicDocumentByID, usePrismicDocumentByUID, usePrismicDocuments, usePrismicDocumentsByEveryTag, usePrismicDocumentsByIDs, usePrismicDocumentsBySomeTags, usePrismicDocumentsByTag, usePrismicDocumentsByType, usePrismicDocumentsByUIDs, usePrismicImage, usePrismicLink, usePrismicRichText, usePrismicText, useSinglePrismicDocument };
package/dist/index.js CHANGED
@@ -37,6 +37,11 @@ const PrismicEmbedImpl = /* @__PURE__ */ defineComponent({
37
37
  });
38
38
  const PrismicEmbed = PrismicEmbedImpl;
39
39
 
40
+ if (typeof process === "undefined") {
41
+ globalThis.process = { env: {} };
42
+ }
43
+ const __PRODUCTION__ = process.env.NODE_ENV === "production";
44
+
40
45
  const prismicKey = Symbol("prismic");
41
46
 
42
47
  const usePrismic = () => {
@@ -59,8 +64,8 @@ const usePrismicImage = (props) => {
59
64
  const widths = unref(props.widths);
60
65
  const pixelDensities = unref(props.pixelDensities);
61
66
  if (widths) {
62
- if (pixelDensities) {
63
- console.warn("[PrismicImage] `widths` and `pixelDensities` props should not be use alongside each others, only `widths` will be applied", props);
67
+ if (!__PRODUCTION__ && pixelDensities) {
68
+ 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);
64
69
  }
65
70
  return asImageWidthSrcSet(field, {
66
71
  ...imgixParams,
@@ -285,7 +290,12 @@ const PrismicLink = PrismicLinkImpl;
285
290
  const defaultWrapper$1 = "div";
286
291
  const usePrismicText = (props) => {
287
292
  const text = computed(() => {
288
- return asText(unref(props.field), unref(props.separator));
293
+ var _a;
294
+ const field = unref(props.field);
295
+ if (!isFilled.richText(field)) {
296
+ return (_a = unref(props.fallback)) != null ? _a : "";
297
+ }
298
+ return asText(unref(field), unref(props.separator));
289
299
  });
290
300
  return {
291
301
  text
@@ -296,7 +306,8 @@ const PrismicTextImpl = /* @__PURE__ */ defineComponent({
296
306
  props: {
297
307
  field: {
298
308
  type: Array,
299
- required: true
309
+ default: void 0,
310
+ required: false
300
311
  },
301
312
  separator: {
302
313
  type: String,
@@ -307,12 +318,14 @@ const PrismicTextImpl = /* @__PURE__ */ defineComponent({
307
318
  type: [String, Object, Function],
308
319
  default: void 0,
309
320
  required: false
321
+ },
322
+ fallback: {
323
+ type: String,
324
+ default: void 0,
325
+ required: false
310
326
  }
311
327
  },
312
328
  setup(props) {
313
- if (!props.field) {
314
- return () => null;
315
- }
316
329
  const { text } = usePrismicText(props);
317
330
  return () => {
318
331
  const parent = simplyResolveComponent(props.wrapper || defaultWrapper$1);
@@ -328,10 +341,14 @@ const defaultWrapper = "div";
328
341
  const usePrismicRichText = (props) => {
329
342
  const { options } = usePrismic();
330
343
  const html = computed(() => {
331
- var _a, _b;
332
- const linkResolver = (_a = unref(props.linkResolver)) != null ? _a : options.linkResolver;
333
- const htmlSerializer = (_b = unref(props.htmlSerializer)) != null ? _b : options.htmlSerializer;
334
- return asHTML(unref(props.field), linkResolver, htmlSerializer);
344
+ var _a, _b, _c;
345
+ const field = unref(props.field);
346
+ if (!isFilled.richText(field)) {
347
+ return (_a = unref(props.fallback)) != null ? _a : "";
348
+ }
349
+ const linkResolver = (_b = unref(props.linkResolver)) != null ? _b : options.linkResolver;
350
+ const htmlSerializer = (_c = unref(props.htmlSerializer)) != null ? _c : options.htmlSerializer;
351
+ return asHTML(unref(field), linkResolver, htmlSerializer);
335
352
  });
336
353
  return {
337
354
  html
@@ -342,7 +359,8 @@ const PrismicRichTextImpl = /* @__PURE__ */ defineComponent({
342
359
  props: {
343
360
  field: {
344
361
  type: Array,
345
- required: true
362
+ default: void 0,
363
+ required: false
346
364
  },
347
365
  linkResolver: {
348
366
  type: Function,
@@ -358,12 +376,14 @@ const PrismicRichTextImpl = /* @__PURE__ */ defineComponent({
358
376
  type: [String, Object, Function],
359
377
  default: void 0,
360
378
  required: false
379
+ },
380
+ fallback: {
381
+ type: String,
382
+ default: void 0,
383
+ required: false
361
384
  }
362
385
  },
363
386
  setup(props) {
364
- if (!props.field) {
365
- return () => null;
366
- }
367
387
  const { html } = usePrismicRichText(props);
368
388
  const root = ref(null);
369
389
  const maybeRouter = inject(routerKey, null);
@@ -410,11 +430,6 @@ const PrismicRichTextImpl = /* @__PURE__ */ defineComponent({
410
430
  });
411
431
  const PrismicRichText = PrismicRichTextImpl;
412
432
 
413
- if (typeof process === "undefined") {
414
- globalThis.process = { env: {} };
415
- }
416
- const __PRODUCTION__ = process.env.NODE_ENV === "production";
417
-
418
433
  const getSliceComponentProps = (propsHint) => ({
419
434
  slice: {
420
435
  type: Object,
@@ -437,16 +452,15 @@ const TODOSliceComponent = __PRODUCTION__ ? () => null : /* @__PURE__ */ defineC
437
452
  name: "TODOSliceComponent",
438
453
  props: getSliceComponentProps(),
439
454
  setup(props) {
455
+ const type = computed(() => "slice_type" in props.slice ? props.slice.slice_type : props.slice.type);
440
456
  watchEffect(() => {
441
- console.warn(`[SliceZone] Could not find a component for Slice type "${props.slice.slice_type}"`, props.slice);
457
+ console.warn(`[SliceZone] Could not find a component for Slice type "${type.value}"`, props.slice);
442
458
  });
443
459
  return () => {
444
460
  return h("section", {
445
461
  "data-slice-zone-todo-component": "",
446
- "data-slice-type": props.slice.slice_type
447
- }, [
448
- `Could not find a component for Slice type "${props.slice.slice_type}"`
449
- ]);
462
+ "data-slice-type": type.value
463
+ }, [`Could not find a component for Slice type "${type.value}"`]);
450
464
  };
451
465
  }
452
466
  });
@@ -500,11 +514,12 @@ const SliceZoneImpl = /* @__PURE__ */ defineComponent({
500
514
  const renderedSlices = computed(() => {
501
515
  return props.slices.map((slice, index) => {
502
516
  var _a;
503
- let component = props.components && slice.slice_type in props.components ? props.components[slice.slice_type] : props.defaultComponent || ((_a = options.components) == null ? void 0 : _a.sliceZoneDefaultComponent) || TODOSliceComponent;
517
+ const type = "slice_type" in slice ? slice.slice_type : slice.type;
518
+ let component = props.components && type in props.components ? props.components[type] : props.defaultComponent || ((_a = options.components) == null ? void 0 : _a.sliceZoneDefaultComponent) || TODOSliceComponent;
504
519
  if (props.resolver) {
505
520
  const resolvedComponent = props.resolver({
506
521
  slice,
507
- sliceName: slice.slice_type,
522
+ sliceName: type,
508
523
  i: index
509
524
  });
510
525
  if (resolvedComponent) {
@@ -512,7 +527,7 @@ const SliceZoneImpl = /* @__PURE__ */ defineComponent({
512
527
  }
513
528
  }
514
529
  const p = {
515
- key: `${slice.slice_type}-${index}`,
530
+ key: `${index}-${JSON.stringify(slice)}`,
516
531
  slice,
517
532
  index,
518
533
  context: props.context,