@prismicio/react 2.6.1 → 2.7.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.
Files changed (60) hide show
  1. package/dist/PrismicImage.cjs +1 -1
  2. package/dist/PrismicImage.cjs.map +1 -1
  3. package/dist/PrismicImage.js +1 -1
  4. package/dist/PrismicImage.js.map +1 -1
  5. package/dist/PrismicRichText.d.ts +1 -1
  6. package/dist/PrismicText.cjs +1 -1
  7. package/dist/PrismicText.cjs.map +1 -1
  8. package/dist/PrismicText.js +1 -1
  9. package/dist/PrismicText.js.map +1 -1
  10. package/dist/PrismicToolbar.cjs +1 -1
  11. package/dist/PrismicToolbar.cjs.map +1 -1
  12. package/dist/PrismicToolbar.js +1 -1
  13. package/dist/PrismicToolbar.js.map +1 -1
  14. package/dist/SliceZone.cjs +27 -37
  15. package/dist/SliceZone.cjs.map +1 -1
  16. package/dist/SliceZone.d.ts +36 -33
  17. package/dist/SliceZone.js +27 -20
  18. package/dist/SliceZone.js.map +1 -1
  19. package/dist/_node_modules/@prismicio/client/dist/helpers/asImagePixelDensitySrcSet.cjs +2 -2
  20. package/dist/_node_modules/@prismicio/client/dist/helpers/asImagePixelDensitySrcSet.cjs.map +1 -1
  21. package/dist/_node_modules/@prismicio/client/dist/helpers/asImagePixelDensitySrcSet.js +2 -2
  22. package/dist/_node_modules/@prismicio/client/dist/helpers/asImagePixelDensitySrcSet.js.map +1 -1
  23. package/dist/_node_modules/@prismicio/client/dist/helpers/asImageWidthSrcSet.cjs +2 -2
  24. package/dist/_node_modules/@prismicio/client/dist/helpers/asImageWidthSrcSet.cjs.map +1 -1
  25. package/dist/_node_modules/@prismicio/client/dist/helpers/asImageWidthSrcSet.js +2 -2
  26. package/dist/_node_modules/@prismicio/client/dist/helpers/asImageWidthSrcSet.js.map +1 -1
  27. package/dist/_node_modules/@prismicio/client/dist/helpers/asLink.cjs +12 -3
  28. package/dist/_node_modules/@prismicio/client/dist/helpers/asLink.cjs.map +1 -1
  29. package/dist/_node_modules/@prismicio/client/dist/helpers/asLink.js +12 -3
  30. package/dist/_node_modules/@prismicio/client/dist/helpers/asLink.js.map +1 -1
  31. package/dist/_node_modules/@prismicio/client/dist/helpers/asText.cjs +11 -2
  32. package/dist/_node_modules/@prismicio/client/dist/helpers/asText.cjs.map +1 -1
  33. package/dist/_node_modules/@prismicio/client/dist/helpers/asText.js +11 -2
  34. package/dist/_node_modules/@prismicio/client/dist/helpers/asText.js.map +1 -1
  35. package/dist/_node_modules/@prismicio/client/dist/helpers/isFilled.cjs.map +1 -1
  36. package/dist/_node_modules/@prismicio/client/dist/helpers/isFilled.js.map +1 -1
  37. package/dist/clientHooks.cjs.map +1 -1
  38. package/dist/clientHooks.d.ts +44 -116
  39. package/dist/clientHooks.js.map +1 -1
  40. package/dist/index.d.ts +0 -1
  41. package/dist/package.json.cjs +1 -1
  42. package/dist/package.json.js +1 -1
  43. package/dist/react-server/PrismicLink.cjs +1 -1
  44. package/dist/react-server/PrismicLink.cjs.map +1 -1
  45. package/dist/react-server/PrismicLink.js +1 -1
  46. package/dist/react-server/PrismicLink.js.map +1 -1
  47. package/dist/react-server/PrismicRichText.cjs +1 -1
  48. package/dist/react-server/PrismicRichText.cjs.map +1 -1
  49. package/dist/react-server/PrismicRichText.js +1 -1
  50. package/dist/react-server/PrismicRichText.js.map +1 -1
  51. package/package.json +30 -18
  52. package/src/PrismicImage.tsx +4 -1
  53. package/src/PrismicText.tsx +4 -1
  54. package/src/PrismicToolbar.tsx +1 -1
  55. package/src/SliceZone.tsx +111 -93
  56. package/src/clientHooks.ts +26 -26
  57. package/src/index.ts +0 -2
  58. package/src/react-server/PrismicLink.tsx +4 -1
  59. package/src/react-server/PrismicRichText.tsx +4 -1
  60. package/src/lib/processPolyfill.ts +0 -4
@@ -1,4 +1,4 @@
1
- import type * as prismicT from "@prismicio/types";
1
+ import type * as prismic from "@prismicio/client";
2
2
  import { ClientHookReturnType, HookOnlyParameters } from "./useStatefulPrismicClientMethod";
3
3
  /**
4
4
  * A hook that queries content from the Prismic repository.
@@ -14,14 +14,10 @@ import { ClientHookReturnType, HookOnlyParameters } from "./useStatefulPrismicCl
14
14
  *
15
15
  * @see Underlying `@prismicio/client` method {@link proto.get}
16
16
  */
17
- export declare const usePrismicDocuments: <TDocument extends prismicT.PrismicDocument<Record<string, any>, string, string>>(params?: (Partial<import("@prismicio/client").BuildQueryURLArgs> & {
17
+ export declare const usePrismicDocuments: <TDocument extends prismic.PrismicDocument<Record<string, any>, string, string>>(params?: (Partial<prismic.BuildQueryURLArgs> & {
18
+ fetchOptions?: prismic.RequestInitLike | undefined;
18
19
  signal?: any;
19
- } & {
20
- optimize?: {
21
- repositoryRequests?: boolean | undefined;
22
- concurrentRequests?: boolean | undefined;
23
- } | undefined;
24
- } & HookOnlyParameters) | undefined) => ClientHookReturnType<prismicT.Query<TDocument>>;
20
+ } & HookOnlyParameters) | undefined) => ClientHookReturnType<prismic.Query<TDocument>>;
25
21
  /**
26
22
  * A hook that queries content from the Prismic repository and returns only the
27
23
  * first result, if any.
@@ -37,13 +33,9 @@ export declare const usePrismicDocuments: <TDocument extends prismicT.PrismicDoc
37
33
  *
38
34
  * @see Underlying `@prismicio/client` method {@link proto.getFirst}
39
35
  */
40
- export declare const useFirstPrismicDocument: <TDocument extends prismicT.PrismicDocument<Record<string, any>, string, string>>(params?: (Partial<import("@prismicio/client").BuildQueryURLArgs> & {
36
+ export declare const useFirstPrismicDocument: <TDocument extends prismic.PrismicDocument<Record<string, any>, string, string>>(params?: (Partial<prismic.BuildQueryURLArgs> & {
37
+ fetchOptions?: prismic.RequestInitLike | undefined;
41
38
  signal?: any;
42
- } & {
43
- optimize?: {
44
- repositoryRequests?: boolean | undefined;
45
- concurrentRequests?: boolean | undefined;
46
- } | undefined;
47
39
  } & HookOnlyParameters) | undefined) => ClientHookReturnType<TDocument>;
48
40
  /**
49
41
  * A hook that queries content from the Prismic repository and returns all
@@ -61,15 +53,11 @@ export declare const useFirstPrismicDocument: <TDocument extends prismicT.Prismi
61
53
  *
62
54
  * @see Underlying `@prismicio/client` method {@link proto.getAll}
63
55
  */
64
- export declare const useAllPrismicDocumentsDangerously: <TDocument extends prismicT.PrismicDocument<Record<string, any>, string, string>>(params?: (Partial<Omit<import("@prismicio/client").BuildQueryURLArgs, "page">> & {
56
+ export declare const useAllPrismicDocumentsDangerously: <TDocument extends prismic.PrismicDocument<Record<string, any>, string, string>>(params?: (Partial<Omit<prismic.BuildQueryURLArgs, "page">> & {
65
57
  limit?: number | undefined;
66
58
  } & {
59
+ fetchOptions?: prismic.RequestInitLike | undefined;
67
60
  signal?: any;
68
- } & {
69
- optimize?: {
70
- repositoryRequests?: boolean | undefined;
71
- concurrentRequests?: boolean | undefined;
72
- } | undefined;
73
61
  } & HookOnlyParameters) | undefined) => ClientHookReturnType<TDocument[]>;
74
62
  /**
75
63
  * A hook that queries a document from the Prismic repository with a specific
@@ -87,13 +75,9 @@ export declare const useAllPrismicDocumentsDangerously: <TDocument extends prism
87
75
  *
88
76
  * @see Underlying `@prismicio/client` method {@link proto.getByID}
89
77
  */
90
- export declare const usePrismicDocumentByID: <TDocument extends prismicT.PrismicDocument<Record<string, any>, string, string>>(id: string, params?: (Partial<import("@prismicio/client").BuildQueryURLArgs> & {
78
+ export declare const usePrismicDocumentByID: <TDocument extends prismic.PrismicDocument<Record<string, any>, string, string>>(id: string, params?: (Partial<prismic.BuildQueryURLArgs> & {
79
+ fetchOptions?: prismic.RequestInitLike | undefined;
91
80
  signal?: any;
92
- } & {
93
- optimize?: {
94
- repositoryRequests?: boolean | undefined;
95
- concurrentRequests?: boolean | undefined;
96
- } | undefined;
97
81
  } & HookOnlyParameters) | undefined) => ClientHookReturnType<TDocument>;
98
82
  /**
99
83
  * A hook that queries documents from the Prismic repository with specific IDs.
@@ -110,14 +94,10 @@ export declare const usePrismicDocumentByID: <TDocument extends prismicT.Prismic
110
94
  *
111
95
  * @see Underlying `@prismicio/client` method {@link proto.getByIDs}
112
96
  */
113
- export declare const usePrismicDocumentsByIDs: <TDocument extends prismicT.PrismicDocument<Record<string, any>, string, string>>(id: string[], params?: (Partial<import("@prismicio/client").BuildQueryURLArgs> & {
97
+ export declare const usePrismicDocumentsByIDs: <TDocument extends prismic.PrismicDocument<Record<string, any>, string, string>>(id: string[], params?: (Partial<prismic.BuildQueryURLArgs> & {
98
+ fetchOptions?: prismic.RequestInitLike | undefined;
114
99
  signal?: any;
115
- } & {
116
- optimize?: {
117
- repositoryRequests?: boolean | undefined;
118
- concurrentRequests?: boolean | undefined;
119
- } | undefined;
120
- } & HookOnlyParameters) | undefined) => ClientHookReturnType<prismicT.Query<TDocument>>;
100
+ } & HookOnlyParameters) | undefined) => ClientHookReturnType<prismic.Query<TDocument>>;
121
101
  /**
122
102
  * A hook that queries all documents from the Prismic repository with specific
123
103
  * IDs.
@@ -134,15 +114,11 @@ export declare const usePrismicDocumentsByIDs: <TDocument extends prismicT.Prism
134
114
  *
135
115
  * @see Underlying `@prismicio/client` method {@link proto.getAllByIDs}
136
116
  */
137
- export declare const useAllPrismicDocumentsByIDs: <TDocument extends prismicT.PrismicDocument<Record<string, any>, string, string>>(id: string[], params?: (Partial<import("@prismicio/client").BuildQueryURLArgs> & {
117
+ export declare const useAllPrismicDocumentsByIDs: <TDocument extends prismic.PrismicDocument<Record<string, any>, string, string>>(id: string[], params?: (Partial<prismic.BuildQueryURLArgs> & {
138
118
  limit?: number | undefined;
139
119
  } & {
120
+ fetchOptions?: prismic.RequestInitLike | undefined;
140
121
  signal?: any;
141
- } & {
142
- optimize?: {
143
- repositoryRequests?: boolean | undefined;
144
- concurrentRequests?: boolean | undefined;
145
- } | undefined;
146
122
  } & HookOnlyParameters) | undefined) => ClientHookReturnType<TDocument[]>;
147
123
  /**
148
124
  * A hook that queries a document from the Prismic repository with a specific
@@ -161,13 +137,9 @@ export declare const useAllPrismicDocumentsByIDs: <TDocument extends prismicT.Pr
161
137
  *
162
138
  * @see Underlying `@prismicio/client` method {@link proto.getByUID}
163
139
  */
164
- export declare const usePrismicDocumentByUID: <TDocument extends prismicT.PrismicDocument<Record<string, any>, string, string>>(documentType: any, uid: string, params?: (Partial<import("@prismicio/client").BuildQueryURLArgs> & {
140
+ export declare const usePrismicDocumentByUID: <TDocument extends prismic.PrismicDocument<Record<string, any>, string, string>>(documentType: any, uid: string, params?: (Partial<prismic.BuildQueryURLArgs> & {
141
+ fetchOptions?: prismic.RequestInitLike | undefined;
165
142
  signal?: any;
166
- } & {
167
- optimize?: {
168
- repositoryRequests?: boolean | undefined;
169
- concurrentRequests?: boolean | undefined;
170
- } | undefined;
171
143
  } & HookOnlyParameters) | undefined) => ClientHookReturnType<TDocument>;
172
144
  /**
173
145
  * A hook that queries documents from the Prismic repository with specific UIDs
@@ -186,14 +158,10 @@ export declare const usePrismicDocumentByUID: <TDocument extends prismicT.Prismi
186
158
  *
187
159
  * @see Underlying `@prismicio/client` method {@link proto.getByUID}
188
160
  */
189
- export declare const usePrismicDocumentsByUIDs: <TDocument extends prismicT.PrismicDocument<Record<string, any>, string, string>>(documentType: any, uids: string[], params?: (Partial<import("@prismicio/client").BuildQueryURLArgs> & {
161
+ export declare const usePrismicDocumentsByUIDs: <TDocument extends prismic.PrismicDocument<Record<string, any>, string, string>>(documentType: any, uids: string[], params?: (Partial<prismic.BuildQueryURLArgs> & {
162
+ fetchOptions?: prismic.RequestInitLike | undefined;
190
163
  signal?: any;
191
- } & {
192
- optimize?: {
193
- repositoryRequests?: boolean | undefined;
194
- concurrentRequests?: boolean | undefined;
195
- } | undefined;
196
- } & HookOnlyParameters) | undefined) => ClientHookReturnType<prismicT.Query<TDocument>>;
164
+ } & HookOnlyParameters) | undefined) => ClientHookReturnType<prismic.Query<TDocument>>;
197
165
  /**
198
166
  * A hook that queries all documents from the Prismic repository with specific
199
167
  * UIDs of a Custom Type.
@@ -211,13 +179,9 @@ export declare const usePrismicDocumentsByUIDs: <TDocument extends prismicT.Pris
211
179
  *
212
180
  * @see Underlying `@prismicio/client` method {@link proto.getByUID}
213
181
  */
214
- export declare const useAllPrismicDocumentsByUIDs: <TDocument extends prismicT.PrismicDocument<Record<string, any>, string, string>>(documentType: any, uids: string[], params?: (Partial<import("@prismicio/client").BuildQueryURLArgs> & {
182
+ export declare const useAllPrismicDocumentsByUIDs: <TDocument extends prismic.PrismicDocument<Record<string, any>, string, string>>(documentType: any, uids: string[], params?: (Partial<prismic.BuildQueryURLArgs> & {
183
+ fetchOptions?: prismic.RequestInitLike | undefined;
215
184
  signal?: any;
216
- } & {
217
- optimize?: {
218
- repositoryRequests?: boolean | undefined;
219
- concurrentRequests?: boolean | undefined;
220
- } | undefined;
221
185
  } & HookOnlyParameters) | undefined) => ClientHookReturnType<TDocument[]>;
222
186
  /**
223
187
  * A hook that queries a singleton document from the Prismic repository for a
@@ -235,13 +199,9 @@ export declare const useAllPrismicDocumentsByUIDs: <TDocument extends prismicT.P
235
199
  *
236
200
  * @see Underlying `@prismicio/client` method {@link proto.getSingle}
237
201
  */
238
- export declare const useSinglePrismicDocument: <TDocument extends prismicT.PrismicDocument<Record<string, any>, string, string>>(documentType: any, params?: (Partial<import("@prismicio/client").BuildQueryURLArgs> & {
202
+ export declare const useSinglePrismicDocument: <TDocument extends prismic.PrismicDocument<Record<string, any>, string, string>>(documentType: any, params?: (Partial<prismic.BuildQueryURLArgs> & {
203
+ fetchOptions?: prismic.RequestInitLike | undefined;
239
204
  signal?: any;
240
- } & {
241
- optimize?: {
242
- repositoryRequests?: boolean | undefined;
243
- concurrentRequests?: boolean | undefined;
244
- } | undefined;
245
205
  } & HookOnlyParameters) | undefined) => ClientHookReturnType<TDocument>;
246
206
  /**
247
207
  * A hook that queries documents from the Prismic repository for a specific
@@ -259,14 +219,10 @@ export declare const useSinglePrismicDocument: <TDocument extends prismicT.Prism
259
219
  *
260
220
  * @see Underlying `@prismicio/client` method {@link proto.getByType}
261
221
  */
262
- export declare const usePrismicDocumentsByType: <TDocument extends prismicT.PrismicDocument<Record<string, any>, string, string>>(documentType: any, params?: (Partial<import("@prismicio/client").BuildQueryURLArgs> & {
222
+ export declare const usePrismicDocumentsByType: <TDocument extends prismic.PrismicDocument<Record<string, any>, string, string>>(documentType: any, params?: (Partial<prismic.BuildQueryURLArgs> & {
223
+ fetchOptions?: prismic.RequestInitLike | undefined;
263
224
  signal?: any;
264
- } & {
265
- optimize?: {
266
- repositoryRequests?: boolean | undefined;
267
- concurrentRequests?: boolean | undefined;
268
- } | undefined;
269
- } & HookOnlyParameters) | undefined) => ClientHookReturnType<prismicT.Query<TDocument>>;
225
+ } & HookOnlyParameters) | undefined) => ClientHookReturnType<prismic.Query<TDocument>>;
270
226
  /**
271
227
  * A hook that queries all documents from the Prismic repository for a specific
272
228
  * Custom Type.
@@ -283,15 +239,11 @@ export declare const usePrismicDocumentsByType: <TDocument extends prismicT.Pris
283
239
  *
284
240
  * @see Underlying `@prismicio/client` method {@link proto.getAllByType}
285
241
  */
286
- export declare const useAllPrismicDocumentsByType: <TDocument extends prismicT.PrismicDocument<Record<string, any>, string, string>>(documentType: any, params?: (Partial<Omit<import("@prismicio/client").BuildQueryURLArgs, "page">> & {
242
+ export declare const useAllPrismicDocumentsByType: <TDocument extends prismic.PrismicDocument<Record<string, any>, string, string>>(documentType: any, params?: (Partial<Omit<prismic.BuildQueryURLArgs, "page">> & {
287
243
  limit?: number | undefined;
288
244
  } & {
245
+ fetchOptions?: prismic.RequestInitLike | undefined;
289
246
  signal?: any;
290
- } & {
291
- optimize?: {
292
- repositoryRequests?: boolean | undefined;
293
- concurrentRequests?: boolean | undefined;
294
- } | undefined;
295
247
  } & HookOnlyParameters) | undefined) => ClientHookReturnType<TDocument[]>;
296
248
  /**
297
249
  * A hook that queries documents from the Prismic repository with a specific
@@ -309,14 +261,10 @@ export declare const useAllPrismicDocumentsByType: <TDocument extends prismicT.P
309
261
  *
310
262
  * @see Underlying `@prismicio/client` method {@link proto.getByTag}
311
263
  */
312
- export declare const usePrismicDocumentsByTag: <TDocument extends prismicT.PrismicDocument<Record<string, any>, string, string>>(tag: string, params?: (Partial<import("@prismicio/client").BuildQueryURLArgs> & {
264
+ export declare const usePrismicDocumentsByTag: <TDocument extends prismic.PrismicDocument<Record<string, any>, string, string>>(tag: string, params?: (Partial<prismic.BuildQueryURLArgs> & {
265
+ fetchOptions?: prismic.RequestInitLike | undefined;
313
266
  signal?: any;
314
- } & {
315
- optimize?: {
316
- repositoryRequests?: boolean | undefined;
317
- concurrentRequests?: boolean | undefined;
318
- } | undefined;
319
- } & HookOnlyParameters) | undefined) => ClientHookReturnType<prismicT.Query<TDocument>>;
267
+ } & HookOnlyParameters) | undefined) => ClientHookReturnType<prismic.Query<TDocument>>;
320
268
  /**
321
269
  * A hook that queries all documents from the Prismic repository with a specific
322
270
  * tag.
@@ -333,15 +281,11 @@ export declare const usePrismicDocumentsByTag: <TDocument extends prismicT.Prism
333
281
  *
334
282
  * @see Underlying `@prismicio/client` method {@link proto.getAllByTag}
335
283
  */
336
- export declare const useAllPrismicDocumentsByTag: <TDocument extends prismicT.PrismicDocument<Record<string, any>, string, string>>(tag: string, params?: (Partial<Omit<import("@prismicio/client").BuildQueryURLArgs, "page">> & {
284
+ export declare const useAllPrismicDocumentsByTag: <TDocument extends prismic.PrismicDocument<Record<string, any>, string, string>>(tag: string, params?: (Partial<Omit<prismic.BuildQueryURLArgs, "page">> & {
337
285
  limit?: number | undefined;
338
286
  } & {
287
+ fetchOptions?: prismic.RequestInitLike | undefined;
339
288
  signal?: any;
340
- } & {
341
- optimize?: {
342
- repositoryRequests?: boolean | undefined;
343
- concurrentRequests?: boolean | undefined;
344
- } | undefined;
345
289
  } & HookOnlyParameters) | undefined) => ClientHookReturnType<TDocument[]>;
346
290
  /**
347
291
  * A hook that queries documents from the Prismic repository with specific tags.
@@ -360,14 +304,10 @@ export declare const useAllPrismicDocumentsByTag: <TDocument extends prismicT.Pr
360
304
  *
361
305
  * @see Underlying `@prismicio/client` method {@link proto.getByTags}
362
306
  */
363
- export declare const usePrismicDocumentsBySomeTags: <TDocument extends prismicT.PrismicDocument<Record<string, any>, string, string>>(tag: string[], params?: (Partial<import("@prismicio/client").BuildQueryURLArgs> & {
307
+ export declare const usePrismicDocumentsBySomeTags: <TDocument extends prismic.PrismicDocument<Record<string, any>, string, string>>(tag: string[], params?: (Partial<prismic.BuildQueryURLArgs> & {
308
+ fetchOptions?: prismic.RequestInitLike | undefined;
364
309
  signal?: any;
365
- } & {
366
- optimize?: {
367
- repositoryRequests?: boolean | undefined;
368
- concurrentRequests?: boolean | undefined;
369
- } | undefined;
370
- } & HookOnlyParameters) | undefined) => ClientHookReturnType<prismicT.Query<TDocument>>;
310
+ } & HookOnlyParameters) | undefined) => ClientHookReturnType<prismic.Query<TDocument>>;
371
311
  /**
372
312
  * A hook that queries all documents from the Prismic repository with specific
373
313
  * tags. A document must be tagged with at least one of the queried tags to be
@@ -385,15 +325,11 @@ export declare const usePrismicDocumentsBySomeTags: <TDocument extends prismicT.
385
325
  *
386
326
  * @see Underlying `@prismicio/client` method {@link proto.getAllByTags}
387
327
  */
388
- export declare const useAllPrismicDocumentsBySomeTags: <TDocument extends prismicT.PrismicDocument<Record<string, any>, string, string>>(tag: string[], params?: (Partial<Omit<import("@prismicio/client").BuildQueryURLArgs, "page">> & {
328
+ export declare const useAllPrismicDocumentsBySomeTags: <TDocument extends prismic.PrismicDocument<Record<string, any>, string, string>>(tag: string[], params?: (Partial<Omit<prismic.BuildQueryURLArgs, "page">> & {
389
329
  limit?: number | undefined;
390
330
  } & {
331
+ fetchOptions?: prismic.RequestInitLike | undefined;
391
332
  signal?: any;
392
- } & {
393
- optimize?: {
394
- repositoryRequests?: boolean | undefined;
395
- concurrentRequests?: boolean | undefined;
396
- } | undefined;
397
333
  } & HookOnlyParameters) | undefined) => ClientHookReturnType<TDocument[]>;
398
334
  /**
399
335
  * A hook that queries documents from the Prismic repository with specific tags.
@@ -411,14 +347,10 @@ export declare const useAllPrismicDocumentsBySomeTags: <TDocument extends prismi
411
347
  *
412
348
  * @see Underlying `@prismicio/client` method {@link proto.getByTags}
413
349
  */
414
- export declare const usePrismicDocumentsByEveryTag: <TDocument extends prismicT.PrismicDocument<Record<string, any>, string, string>>(tag: string[], params?: (Partial<import("@prismicio/client").BuildQueryURLArgs> & {
350
+ export declare const usePrismicDocumentsByEveryTag: <TDocument extends prismic.PrismicDocument<Record<string, any>, string, string>>(tag: string[], params?: (Partial<prismic.BuildQueryURLArgs> & {
351
+ fetchOptions?: prismic.RequestInitLike | undefined;
415
352
  signal?: any;
416
- } & {
417
- optimize?: {
418
- repositoryRequests?: boolean | undefined;
419
- concurrentRequests?: boolean | undefined;
420
- } | undefined;
421
- } & HookOnlyParameters) | undefined) => ClientHookReturnType<prismicT.Query<TDocument>>;
353
+ } & HookOnlyParameters) | undefined) => ClientHookReturnType<prismic.Query<TDocument>>;
422
354
  /**
423
355
  * A hook that queries all documents from the Prismic repository with specific
424
356
  * tags. A document must be tagged with all of the queried tags to be included.
@@ -435,13 +367,9 @@ export declare const usePrismicDocumentsByEveryTag: <TDocument extends prismicT.
435
367
  *
436
368
  * @see Underlying `@prismicio/client` method {@link proto.getAllByTags}
437
369
  */
438
- export declare const useAllPrismicDocumentsByEveryTag: <TDocument extends prismicT.PrismicDocument<Record<string, any>, string, string>>(tag: string[], params?: (Partial<Omit<import("@prismicio/client").BuildQueryURLArgs, "page">> & {
370
+ export declare const useAllPrismicDocumentsByEveryTag: <TDocument extends prismic.PrismicDocument<Record<string, any>, string, string>>(tag: string[], params?: (Partial<Omit<prismic.BuildQueryURLArgs, "page">> & {
439
371
  limit?: number | undefined;
440
372
  } & {
373
+ fetchOptions?: prismic.RequestInitLike | undefined;
441
374
  signal?: any;
442
- } & {
443
- optimize?: {
444
- repositoryRequests?: boolean | undefined;
445
- concurrentRequests?: boolean | undefined;
446
- } | undefined;
447
375
  } & HookOnlyParameters) | undefined) => ClientHookReturnType<TDocument[]>;
@@ -1 +1 @@
1
- {"version":3,"file":"clientHooks.js","sources":["../../src/clientHooks.ts"],"sourcesContent":["import type * as prismicT from \"@prismicio/types\";\n\nimport {\n\tClientHookReturnType,\n\tClientMethodParameters,\n\tHookOnlyParameters,\n\tuseStatefulPrismicClientMethod,\n} from \"./useStatefulPrismicClientMethod\";\n\n/**\n * A hook that queries content from the Prismic repository.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientHookReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link proto.get}\n */\nexport const usePrismicDocuments = <TDocument extends prismicT.PrismicDocument>(\n\t...args: [params?: ClientMethodParameters<\"get\">[0] & HookOnlyParameters]\n): ClientHookReturnType<prismicT.Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"get\", args);\n\n/**\n * A hook that queries content from the Prismic repository and returns only the\n * first result, if any.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of the Prismic document returned\n *\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientHookReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link proto.getFirst}\n */\nexport const useFirstPrismicDocument = <\n\tTDocument extends prismicT.PrismicDocument,\n>(\n\t...args: [params?: ClientMethodParameters<\"getFirst\">[0] & HookOnlyParameters]\n): ClientHookReturnType<TDocument> =>\n\tuseStatefulPrismicClientMethod(\"getFirst\", args);\n\n/**\n * A hook that queries content from the Prismic repository and returns all\n * matching content. If no predicates are provided, all documents will be\n * fetched.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param params - Parameters to filter and sort results\n *\n * @returns The composable payload {@link ClientHookReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link proto.getAll}\n */\nexport const useAllPrismicDocumentsDangerously = <\n\tTDocument extends prismicT.PrismicDocument,\n>(\n\t...args: [\n\t\tparams?: ClientMethodParameters<\"dangerouslyGetAll\">[0] &\n\t\t\tHookOnlyParameters,\n\t]\n): ClientHookReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"dangerouslyGetAll\", args);\n\n/**\n * A hook that queries a document from the Prismic repository with a specific\n * ID.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of the Prismic document returned\n *\n * @param id - ID of the document\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientHookReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link proto.getByID}\n */\nexport const usePrismicDocumentByID = <\n\tTDocument extends prismicT.PrismicDocument,\n>(\n\t...args: [\n\t\tid: ClientMethodParameters<\"getByID\">[0],\n\t\tparams?: ClientMethodParameters<\"getByID\">[1] & HookOnlyParameters,\n\t]\n): ClientHookReturnType<TDocument> =>\n\tuseStatefulPrismicClientMethod(\"getByID\", args);\n\n/**\n * A hook that queries documents from the Prismic repository with specific IDs.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param ids - A list of document IDs\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientHookReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link proto.getByIDs}\n */\nexport const usePrismicDocumentsByIDs = <\n\tTDocument extends prismicT.PrismicDocument,\n>(\n\t...args: [\n\t\tid: ClientMethodParameters<\"getByIDs\">[0],\n\t\tparams?: ClientMethodParameters<\"getByIDs\">[1] & HookOnlyParameters,\n\t]\n): ClientHookReturnType<prismicT.Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"getByIDs\", args);\n\n/**\n * A hook that queries all documents from the Prismic repository with specific\n * IDs.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param ids - A list of document IDs\n * @param params - Parameters to filter and sort results\n *\n * @returns The composable payload {@link ClientHookReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link proto.getAllByIDs}\n */\nexport const useAllPrismicDocumentsByIDs = <\n\tTDocument extends prismicT.PrismicDocument,\n>(\n\t...args: [\n\t\tid: ClientMethodParameters<\"getAllByIDs\">[0],\n\t\tparams?: ClientMethodParameters<\"getAllByIDs\">[1] & HookOnlyParameters,\n\t]\n): ClientHookReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"getAllByIDs\", args);\n\n/**\n * A hook that queries a document from the Prismic repository with a specific\n * UID and Custom Type.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of the Prismic document returned\n *\n * @param documentType - The API ID of the document's Custom Type\n * @param uid - UID of the document\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientHookReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link proto.getByUID}\n */\nexport const usePrismicDocumentByUID = <\n\tTDocument extends prismicT.PrismicDocument,\n>(\n\t...args: [\n\t\tdocumentType: ClientMethodParameters<\"getByUID\">[0],\n\t\tuid: ClientMethodParameters<\"getByUID\">[1],\n\t\tparams?: ClientMethodParameters<\"getByUID\">[2] & HookOnlyParameters,\n\t]\n): ClientHookReturnType<TDocument> =>\n\tuseStatefulPrismicClientMethod(\"getByUID\", args);\n\n/**\n * A hook that queries documents from the Prismic repository with specific UIDs\n * of a Custom Type.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of the Prismic document returned\n *\n * @param documentType - The API ID of the document's Custom Type\n * @param uids - A list of document UIDs.\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientHookReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link proto.getByUID}\n */\nexport const usePrismicDocumentsByUIDs = <\n\tTDocument extends prismicT.PrismicDocument,\n>(\n\t...args: [\n\t\tdocumentType: ClientMethodParameters<\"getByUIDs\">[0],\n\t\tuids: ClientMethodParameters<\"getByUIDs\">[1],\n\t\tparams?: ClientMethodParameters<\"getByUIDs\">[2] & HookOnlyParameters,\n\t]\n): ClientHookReturnType<prismicT.Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"getByUIDs\", args);\n\n/**\n * A hook that queries all documents from the Prismic repository with specific\n * UIDs of a Custom Type.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of the Prismic document returned\n *\n * @param documentType - The API ID of the document's Custom Type\n * @param uids - A list of document UIDs.\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientHookReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link proto.getByUID}\n */\nexport const useAllPrismicDocumentsByUIDs = <\n\tTDocument extends prismicT.PrismicDocument,\n>(\n\t...args: [\n\t\tdocumentType: ClientMethodParameters<\"getByUIDs\">[0],\n\t\tuids: ClientMethodParameters<\"getByUIDs\">[1],\n\t\tparams?: ClientMethodParameters<\"getByUIDs\">[2] & HookOnlyParameters,\n\t]\n): ClientHookReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"getAllByUIDs\", args);\n\n/**\n * A hook that queries a singleton document from the Prismic repository for a\n * specific Custom Type.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of the Prismic document returned\n *\n * @param documentType - The API ID of the singleton Custom Type\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientHookReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link proto.getSingle}\n */\nexport const useSinglePrismicDocument = <\n\tTDocument extends prismicT.PrismicDocument,\n>(\n\t...args: [\n\t\tdocumentType: ClientMethodParameters<\"getSingle\">[0],\n\t\tparams?: ClientMethodParameters<\"getSingle\">[1] & HookOnlyParameters,\n\t]\n): ClientHookReturnType<TDocument> =>\n\tuseStatefulPrismicClientMethod(\"getSingle\", args);\n\n/**\n * A hook that queries documents from the Prismic repository for a specific\n * Custom Type.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param documentType - The API ID of the Custom Type\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientHookReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link proto.getByType}\n */\nexport const usePrismicDocumentsByType = <\n\tTDocument extends prismicT.PrismicDocument,\n>(\n\t...args: [\n\t\tdocumentType: ClientMethodParameters<\"getByType\">[0],\n\t\tparams?: ClientMethodParameters<\"getByType\">[1] & HookOnlyParameters,\n\t]\n): ClientHookReturnType<prismicT.Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"getByType\", args);\n\n/**\n * A hook that queries all documents from the Prismic repository for a specific\n * Custom Type.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param documentType - The API ID of the Custom Type\n * @param params - Parameters to filter and sort results\n *\n * @returns The composable payload {@link ClientHookReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link proto.getAllByType}\n */\nexport const useAllPrismicDocumentsByType = <\n\tTDocument extends prismicT.PrismicDocument,\n>(\n\t...args: [\n\t\tdocumentType: ClientMethodParameters<\"getAllByType\">[0],\n\t\tparams?: ClientMethodParameters<\"getAllByType\">[1] & HookOnlyParameters,\n\t]\n): ClientHookReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"getAllByType\", args);\n\n/**\n * A hook that queries documents from the Prismic repository with a specific\n * tag.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param tag - The tag that must be included on a document\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientHookReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link proto.getByTag}\n */\nexport const usePrismicDocumentsByTag = <\n\tTDocument extends prismicT.PrismicDocument,\n>(\n\t...args: [\n\t\ttag: ClientMethodParameters<\"getByTag\">[0],\n\t\tparams?: ClientMethodParameters<\"getByTag\">[1] & HookOnlyParameters,\n\t]\n): ClientHookReturnType<prismicT.Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"getByTag\", args);\n\n/**\n * A hook that queries all documents from the Prismic repository with a specific\n * tag.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param tag - The tag that must be included on a document\n * @param params - Parameters to filter and sort results\n *\n * @returns The composable payload {@link ClientHookReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link proto.getAllByTag}\n */\nexport const useAllPrismicDocumentsByTag = <\n\tTDocument extends prismicT.PrismicDocument,\n>(\n\t...args: [\n\t\ttag: ClientMethodParameters<\"getAllByTag\">[0],\n\t\tparams?: ClientMethodParameters<\"getAllByTag\">[1] & HookOnlyParameters,\n\t]\n): ClientHookReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"getAllByTag\", args);\n\n/**\n * A hook that queries documents from the Prismic repository with specific tags.\n * A document must be tagged with at least one of the queried tags to be\n * included.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param tags - A list of tags that must be included on a document\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientHookReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link proto.getByTags}\n */\nexport const usePrismicDocumentsBySomeTags = <\n\tTDocument extends prismicT.PrismicDocument,\n>(\n\t...args: [\n\t\ttag: ClientMethodParameters<\"getBySomeTags\">[0],\n\t\tparams?: ClientMethodParameters<\"getBySomeTags\">[1] & HookOnlyParameters,\n\t]\n): ClientHookReturnType<prismicT.Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"getBySomeTags\", args);\n\n/**\n * A hook that queries all documents from the Prismic repository with specific\n * tags. A document must be tagged with at least one of the queried tags to be\n * included.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param tags - A list of tags that must be included on a document\n * @param params - Parameters to filter and sort results\n *\n * @returns The composable payload {@link ClientHookReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link proto.getAllByTags}\n */\nexport const useAllPrismicDocumentsBySomeTags = <\n\tTDocument extends prismicT.PrismicDocument,\n>(\n\t...args: [\n\t\ttag: ClientMethodParameters<\"getAllBySomeTags\">[0],\n\t\tparams?: ClientMethodParameters<\"getAllBySomeTags\">[1] & HookOnlyParameters,\n\t]\n): ClientHookReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"getAllBySomeTags\", args);\n\n/**\n * A hook that queries documents from the Prismic repository with specific tags.\n * A document must be tagged with all of the queried tags to be included.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param tags - A list of tags that must be included on a document\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientHookReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link proto.getByTags}\n */\nexport const usePrismicDocumentsByEveryTag = <\n\tTDocument extends prismicT.PrismicDocument,\n>(\n\t...args: [\n\t\ttag: ClientMethodParameters<\"getByEveryTag\">[0],\n\t\tparams?: ClientMethodParameters<\"getByEveryTag\">[1] & HookOnlyParameters,\n\t]\n): ClientHookReturnType<prismicT.Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"getByEveryTag\", args);\n\n/**\n * A hook that queries all documents from the Prismic repository with specific\n * tags. A document must be tagged with all of the queried tags to be included.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param tags - A list of tags that must be included on a document\n * @param params - Parameters to filter and sort results\n *\n * @returns The composable payload {@link ClientHookReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link proto.getAllByTags}\n */\nexport const useAllPrismicDocumentsByEveryTag = <\n\tTDocument extends prismicT.PrismicDocument,\n>(\n\t...args: [\n\t\ttag: ClientMethodParameters<\"getAllByEveryTag\">[0],\n\t\tparams?: ClientMethodParameters<\"getAllByEveryTag\">[1] & HookOnlyParameters,\n\t]\n): ClientHookReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"getAllByEveryTag\", args);\n"],"names":[],"mappings":";AAuBO,MAAM,sBAAsB,IAC/B,SAEH,+BAA+B,OAAO,IAAI;AAiBpC,MAAM,0BAA0B,IAGnC,SAEH,+BAA+B,YAAY,IAAI;AAkBzC,MAAM,oCAAoC,IAG7C,SAKH,+BAA+B,qBAAqB,IAAI;AAkBlD,MAAM,yBAAyB,IAGlC,SAKH,+BAA+B,WAAW,IAAI;AAiBxC,MAAM,2BAA2B,IAGpC,SAKH,+BAA+B,YAAY,IAAI;AAkBzC,MAAM,8BAA8B,IAGvC,SAKH,+BAA+B,eAAe,IAAI;AAmB5C,MAAM,0BAA0B,IAGnC,SAMH,+BAA+B,YAAY,IAAI;AAmBzC,MAAM,4BAA4B,IAGrC,SAMH,+BAA+B,aAAa,IAAI;AAmB1C,MAAM,+BAA+B,IAGxC,SAMH,+BAA+B,gBAAgB,IAAI;AAkB7C,MAAM,2BAA2B,IAGpC,SAKH,+BAA+B,aAAa,IAAI;AAkB1C,MAAM,4BAA4B,IAGrC,SAKH,+BAA+B,aAAa,IAAI;AAkB1C,MAAM,+BAA+B,IAGxC,SAKH,+BAA+B,gBAAgB,IAAI;AAkB7C,MAAM,2BAA2B,IAGpC,SAKH,+BAA+B,YAAY,IAAI;AAkBzC,MAAM,8BAA8B,IAGvC,SAKH,+BAA+B,eAAe,IAAI;AAmB5C,MAAM,gCAAgC,IAGzC,SAKH,+BAA+B,iBAAiB,IAAI;AAmB9C,MAAM,mCAAmC,IAG5C,SAKH,+BAA+B,oBAAoB,IAAI;AAkBjD,MAAM,gCAAgC,IAGzC,SAKH,+BAA+B,iBAAiB,IAAI;AAkB9C,MAAM,mCAAmC,IAG5C,SAKH,+BAA+B,oBAAoB,IAAI;"}
1
+ {"version":3,"file":"clientHooks.js","sources":["../../src/clientHooks.ts"],"sourcesContent":["import type * as prismic from \"@prismicio/client\";\n\nimport {\n\tClientHookReturnType,\n\tClientMethodParameters,\n\tHookOnlyParameters,\n\tuseStatefulPrismicClientMethod,\n} from \"./useStatefulPrismicClientMethod\";\n\n/**\n * A hook that queries content from the Prismic repository.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientHookReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link proto.get}\n */\nexport const usePrismicDocuments = <TDocument extends prismic.PrismicDocument>(\n\t...args: [params?: ClientMethodParameters<\"get\">[0] & HookOnlyParameters]\n): ClientHookReturnType<prismic.Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"get\", args);\n\n/**\n * A hook that queries content from the Prismic repository and returns only the\n * first result, if any.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of the Prismic document returned\n *\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientHookReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link proto.getFirst}\n */\nexport const useFirstPrismicDocument = <\n\tTDocument extends prismic.PrismicDocument,\n>(\n\t...args: [params?: ClientMethodParameters<\"getFirst\">[0] & HookOnlyParameters]\n): ClientHookReturnType<TDocument> =>\n\tuseStatefulPrismicClientMethod(\"getFirst\", args);\n\n/**\n * A hook that queries content from the Prismic repository and returns all\n * matching content. If no predicates are provided, all documents will be\n * fetched.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param params - Parameters to filter and sort results\n *\n * @returns The composable payload {@link ClientHookReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link proto.getAll}\n */\nexport const useAllPrismicDocumentsDangerously = <\n\tTDocument extends prismic.PrismicDocument,\n>(\n\t...args: [\n\t\tparams?: ClientMethodParameters<\"dangerouslyGetAll\">[0] &\n\t\t\tHookOnlyParameters,\n\t]\n): ClientHookReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"dangerouslyGetAll\", args);\n\n/**\n * A hook that queries a document from the Prismic repository with a specific\n * ID.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of the Prismic document returned\n *\n * @param id - ID of the document\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientHookReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link proto.getByID}\n */\nexport const usePrismicDocumentByID = <\n\tTDocument extends prismic.PrismicDocument,\n>(\n\t...args: [\n\t\tid: ClientMethodParameters<\"getByID\">[0],\n\t\tparams?: ClientMethodParameters<\"getByID\">[1] & HookOnlyParameters,\n\t]\n): ClientHookReturnType<TDocument> =>\n\tuseStatefulPrismicClientMethod(\"getByID\", args);\n\n/**\n * A hook that queries documents from the Prismic repository with specific IDs.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param ids - A list of document IDs\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientHookReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link proto.getByIDs}\n */\nexport const usePrismicDocumentsByIDs = <\n\tTDocument extends prismic.PrismicDocument,\n>(\n\t...args: [\n\t\tid: ClientMethodParameters<\"getByIDs\">[0],\n\t\tparams?: ClientMethodParameters<\"getByIDs\">[1] & HookOnlyParameters,\n\t]\n): ClientHookReturnType<prismic.Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"getByIDs\", args);\n\n/**\n * A hook that queries all documents from the Prismic repository with specific\n * IDs.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param ids - A list of document IDs\n * @param params - Parameters to filter and sort results\n *\n * @returns The composable payload {@link ClientHookReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link proto.getAllByIDs}\n */\nexport const useAllPrismicDocumentsByIDs = <\n\tTDocument extends prismic.PrismicDocument,\n>(\n\t...args: [\n\t\tid: ClientMethodParameters<\"getAllByIDs\">[0],\n\t\tparams?: ClientMethodParameters<\"getAllByIDs\">[1] & HookOnlyParameters,\n\t]\n): ClientHookReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"getAllByIDs\", args);\n\n/**\n * A hook that queries a document from the Prismic repository with a specific\n * UID and Custom Type.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of the Prismic document returned\n *\n * @param documentType - The API ID of the document's Custom Type\n * @param uid - UID of the document\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientHookReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link proto.getByUID}\n */\nexport const usePrismicDocumentByUID = <\n\tTDocument extends prismic.PrismicDocument,\n>(\n\t...args: [\n\t\tdocumentType: ClientMethodParameters<\"getByUID\">[0],\n\t\tuid: ClientMethodParameters<\"getByUID\">[1],\n\t\tparams?: ClientMethodParameters<\"getByUID\">[2] & HookOnlyParameters,\n\t]\n): ClientHookReturnType<TDocument> =>\n\tuseStatefulPrismicClientMethod(\"getByUID\", args);\n\n/**\n * A hook that queries documents from the Prismic repository with specific UIDs\n * of a Custom Type.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of the Prismic document returned\n *\n * @param documentType - The API ID of the document's Custom Type\n * @param uids - A list of document UIDs.\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientHookReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link proto.getByUID}\n */\nexport const usePrismicDocumentsByUIDs = <\n\tTDocument extends prismic.PrismicDocument,\n>(\n\t...args: [\n\t\tdocumentType: ClientMethodParameters<\"getByUIDs\">[0],\n\t\tuids: ClientMethodParameters<\"getByUIDs\">[1],\n\t\tparams?: ClientMethodParameters<\"getByUIDs\">[2] & HookOnlyParameters,\n\t]\n): ClientHookReturnType<prismic.Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"getByUIDs\", args);\n\n/**\n * A hook that queries all documents from the Prismic repository with specific\n * UIDs of a Custom Type.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of the Prismic document returned\n *\n * @param documentType - The API ID of the document's Custom Type\n * @param uids - A list of document UIDs.\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientHookReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link proto.getByUID}\n */\nexport const useAllPrismicDocumentsByUIDs = <\n\tTDocument extends prismic.PrismicDocument,\n>(\n\t...args: [\n\t\tdocumentType: ClientMethodParameters<\"getByUIDs\">[0],\n\t\tuids: ClientMethodParameters<\"getByUIDs\">[1],\n\t\tparams?: ClientMethodParameters<\"getByUIDs\">[2] & HookOnlyParameters,\n\t]\n): ClientHookReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"getAllByUIDs\", args);\n\n/**\n * A hook that queries a singleton document from the Prismic repository for a\n * specific Custom Type.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of the Prismic document returned\n *\n * @param documentType - The API ID of the singleton Custom Type\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientHookReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link proto.getSingle}\n */\nexport const useSinglePrismicDocument = <\n\tTDocument extends prismic.PrismicDocument,\n>(\n\t...args: [\n\t\tdocumentType: ClientMethodParameters<\"getSingle\">[0],\n\t\tparams?: ClientMethodParameters<\"getSingle\">[1] & HookOnlyParameters,\n\t]\n): ClientHookReturnType<TDocument> =>\n\tuseStatefulPrismicClientMethod(\"getSingle\", args);\n\n/**\n * A hook that queries documents from the Prismic repository for a specific\n * Custom Type.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param documentType - The API ID of the Custom Type\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientHookReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link proto.getByType}\n */\nexport const usePrismicDocumentsByType = <\n\tTDocument extends prismic.PrismicDocument,\n>(\n\t...args: [\n\t\tdocumentType: ClientMethodParameters<\"getByType\">[0],\n\t\tparams?: ClientMethodParameters<\"getByType\">[1] & HookOnlyParameters,\n\t]\n): ClientHookReturnType<prismic.Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"getByType\", args);\n\n/**\n * A hook that queries all documents from the Prismic repository for a specific\n * Custom Type.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param documentType - The API ID of the Custom Type\n * @param params - Parameters to filter and sort results\n *\n * @returns The composable payload {@link ClientHookReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link proto.getAllByType}\n */\nexport const useAllPrismicDocumentsByType = <\n\tTDocument extends prismic.PrismicDocument,\n>(\n\t...args: [\n\t\tdocumentType: ClientMethodParameters<\"getAllByType\">[0],\n\t\tparams?: ClientMethodParameters<\"getAllByType\">[1] & HookOnlyParameters,\n\t]\n): ClientHookReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"getAllByType\", args);\n\n/**\n * A hook that queries documents from the Prismic repository with a specific\n * tag.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param tag - The tag that must be included on a document\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientHookReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link proto.getByTag}\n */\nexport const usePrismicDocumentsByTag = <\n\tTDocument extends prismic.PrismicDocument,\n>(\n\t...args: [\n\t\ttag: ClientMethodParameters<\"getByTag\">[0],\n\t\tparams?: ClientMethodParameters<\"getByTag\">[1] & HookOnlyParameters,\n\t]\n): ClientHookReturnType<prismic.Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"getByTag\", args);\n\n/**\n * A hook that queries all documents from the Prismic repository with a specific\n * tag.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param tag - The tag that must be included on a document\n * @param params - Parameters to filter and sort results\n *\n * @returns The composable payload {@link ClientHookReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link proto.getAllByTag}\n */\nexport const useAllPrismicDocumentsByTag = <\n\tTDocument extends prismic.PrismicDocument,\n>(\n\t...args: [\n\t\ttag: ClientMethodParameters<\"getAllByTag\">[0],\n\t\tparams?: ClientMethodParameters<\"getAllByTag\">[1] & HookOnlyParameters,\n\t]\n): ClientHookReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"getAllByTag\", args);\n\n/**\n * A hook that queries documents from the Prismic repository with specific tags.\n * A document must be tagged with at least one of the queried tags to be\n * included.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param tags - A list of tags that must be included on a document\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientHookReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link proto.getByTags}\n */\nexport const usePrismicDocumentsBySomeTags = <\n\tTDocument extends prismic.PrismicDocument,\n>(\n\t...args: [\n\t\ttag: ClientMethodParameters<\"getBySomeTags\">[0],\n\t\tparams?: ClientMethodParameters<\"getBySomeTags\">[1] & HookOnlyParameters,\n\t]\n): ClientHookReturnType<prismic.Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"getBySomeTags\", args);\n\n/**\n * A hook that queries all documents from the Prismic repository with specific\n * tags. A document must be tagged with at least one of the queried tags to be\n * included.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param tags - A list of tags that must be included on a document\n * @param params - Parameters to filter and sort results\n *\n * @returns The composable payload {@link ClientHookReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link proto.getAllByTags}\n */\nexport const useAllPrismicDocumentsBySomeTags = <\n\tTDocument extends prismic.PrismicDocument,\n>(\n\t...args: [\n\t\ttag: ClientMethodParameters<\"getAllBySomeTags\">[0],\n\t\tparams?: ClientMethodParameters<\"getAllBySomeTags\">[1] & HookOnlyParameters,\n\t]\n): ClientHookReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"getAllBySomeTags\", args);\n\n/**\n * A hook that queries documents from the Prismic repository with specific tags.\n * A document must be tagged with all of the queried tags to be included.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param tags - A list of tags that must be included on a document\n * @param params - Parameters to filter, sort, and paginate results\n *\n * @returns The composable payload {@link ClientHookReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link proto.getByTags}\n */\nexport const usePrismicDocumentsByEveryTag = <\n\tTDocument extends prismic.PrismicDocument,\n>(\n\t...args: [\n\t\ttag: ClientMethodParameters<\"getByEveryTag\">[0],\n\t\tparams?: ClientMethodParameters<\"getByEveryTag\">[1] & HookOnlyParameters,\n\t]\n): ClientHookReturnType<prismic.Query<TDocument>> =>\n\tuseStatefulPrismicClientMethod(\"getByEveryTag\", args);\n\n/**\n * A hook that queries all documents from the Prismic repository with specific\n * tags. A document must be tagged with all of the queried tags to be included.\n *\n * @remarks\n * An additional `@prismicio/client` instance can be provided at\n * `params.client`.\n * @typeParam TDocument - Type of Prismic documents returned\n *\n * @param tags - A list of tags that must be included on a document\n * @param params - Parameters to filter and sort results\n *\n * @returns The composable payload {@link ClientHookReturnType}\n *\n * @see Underlying `@prismicio/client` method {@link proto.getAllByTags}\n */\nexport const useAllPrismicDocumentsByEveryTag = <\n\tTDocument extends prismic.PrismicDocument,\n>(\n\t...args: [\n\t\ttag: ClientMethodParameters<\"getAllByEveryTag\">[0],\n\t\tparams?: ClientMethodParameters<\"getAllByEveryTag\">[1] & HookOnlyParameters,\n\t]\n): ClientHookReturnType<TDocument[]> =>\n\tuseStatefulPrismicClientMethod(\"getAllByEveryTag\", args);\n"],"names":[],"mappings":";AAuBO,MAAM,sBAAsB,IAC/B,SAEH,+BAA+B,OAAO,IAAI;AAiBpC,MAAM,0BAA0B,IAGnC,SAEH,+BAA+B,YAAY,IAAI;AAkBzC,MAAM,oCAAoC,IAG7C,SAKH,+BAA+B,qBAAqB,IAAI;AAkBlD,MAAM,yBAAyB,IAGlC,SAKH,+BAA+B,WAAW,IAAI;AAiBxC,MAAM,2BAA2B,IAGpC,SAKH,+BAA+B,YAAY,IAAI;AAkBzC,MAAM,8BAA8B,IAGvC,SAKH,+BAA+B,eAAe,IAAI;AAmB5C,MAAM,0BAA0B,IAGnC,SAMH,+BAA+B,YAAY,IAAI;AAmBzC,MAAM,4BAA4B,IAGrC,SAMH,+BAA+B,aAAa,IAAI;AAmB1C,MAAM,+BAA+B,IAGxC,SAMH,+BAA+B,gBAAgB,IAAI;AAkB7C,MAAM,2BAA2B,IAGpC,SAKH,+BAA+B,aAAa,IAAI;AAkB1C,MAAM,4BAA4B,IAGrC,SAKH,+BAA+B,aAAa,IAAI;AAkB1C,MAAM,+BAA+B,IAGxC,SAKH,+BAA+B,gBAAgB,IAAI;AAkB7C,MAAM,2BAA2B,IAGpC,SAKH,+BAA+B,YAAY,IAAI;AAkBzC,MAAM,8BAA8B,IAGvC,SAKH,+BAA+B,eAAe,IAAI;AAmB5C,MAAM,gCAAgC,IAGzC,SAKH,+BAA+B,iBAAiB,IAAI;AAmB9C,MAAM,mCAAmC,IAG5C,SAKH,+BAA+B,oBAAoB,IAAI;AAkBjD,MAAM,gCAAgC,IAGzC,SAKH,+BAA+B,iBAAiB,IAAI;AAkB9C,MAAM,mCAAmC,IAG5C,SAKH,+BAA+B,oBAAoB,IAAI;"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import "./lib/processPolyfill";
2
1
  export { PrismicProvider } from "./PrismicProvider";
3
2
  export type { PrismicProviderProps, PrismicContextValue, } from "./PrismicProvider";
4
3
  export { usePrismicContext } from "./usePrismicContext";
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const version = "2.6.1";
3
+ const version = "2.7.0";
4
4
  exports.version = version;
5
5
  //# sourceMappingURL=package.json.cjs.map
@@ -1,4 +1,4 @@
1
- const version = "2.6.1";
1
+ const version = "2.7.0";
2
2
  export {
3
3
  version
4
4
  };
@@ -25,7 +25,7 @@ function _interopNamespaceDefault(e) {
25
25
  const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
26
26
  const defaultComponent = "a";
27
27
  const PrismicLink = React__namespace.forwardRef(function PrismicLink2({ field, document: doc, linkResolver, internalComponent, externalComponent, ...restProps }, ref) {
28
- if (process.env.NODE_ENV === "development") {
28
+ if (typeof process !== "undefined" && process.env.NODE_ENV === "development") {
29
29
  if (field) {
30
30
  if (!field.link_type) {
31
31
  console.error(`[PrismicLink] This "field" prop value caused an error to be thrown.
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicLink.cjs","sources":["../../../src/react-server/PrismicLink.tsx"],"sourcesContent":["import * as React from \"react\";\nimport {\n\tLinkField,\n\tLinkResolverFunction,\n\tPrismicDocument,\n\tasLinkAttrs,\n\tAsLinkAttrsConfig,\n} from \"@prismicio/client\";\n\nimport { devMsg } from \"../lib/devMsg\";\nimport { isInternalURL } from \"../lib/isInternalURL\";\n\n/**\n * The default component rendered for internal and external links.\n */\nexport const defaultComponent = \"a\";\n\n/**\n * Props provided to a component when rendered with `<PrismicLink>`.\n */\nexport interface LinkProps {\n\t/**\n\t * The URL to link.\n\t */\n\thref: string;\n\n\t/**\n\t * The `target` attribute for anchor elements. If the Prismic field is\n\t * configured to open in a new window, this prop defaults to `_blank`.\n\t */\n\ttarget?: React.HTMLAttributeAnchorTarget;\n\n\t/**\n\t * The `rel` attribute for anchor elements. If the `target` prop is set to\n\t * `\"_blank\"`, this prop defaults to `\"noopener noreferrer\"`.\n\t */\n\trel?: string;\n\n\t/**\n\t * Children for the component. *\n\t */\n\tchildren?: React.ReactNode;\n}\n\nexport type PrismicLinkProps<\n\tInternalComponentProps = React.ComponentProps<typeof defaultComponent>,\n\tExternalComponentProps = React.ComponentProps<typeof defaultComponent>,\n> = Omit<InternalComponentProps & ExternalComponentProps, \"rel\" | \"href\"> & {\n\t/**\n\t * The `rel` attribute for the link. By default, `\"noreferrer\"` is provided if\n\t * the link's URL is external. This prop can be provided a function to use the\n\t * link's metadata to determine the `rel` value.\n\t */\n\trel?: string | AsLinkAttrsConfig[\"rel\"];\n\n\t/**\n\t * The Link Resolver used to resolve links.\n\t *\n\t * @remarks\n\t * If your app uses Route Resolvers when querying for your Prismic\n\t * repository's content, a Link Resolver does not need to be provided.\n\t * @see Learn about Link Resolvers and Route Resolvers {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver}\n\t */\n\tlinkResolver?: LinkResolverFunction;\n\n\t/**\n\t * The component rendered for internal URLs. Defaults to `<a>`.\n\t *\n\t * If your app uses a client-side router that requires a special Link\n\t * component, provide the Link component to this prop.\n\t */\n\tinternalComponent?: React.ElementType<InternalComponentProps>;\n\n\t/**\n\t * The component rendered for external URLs. Defaults to `<a>`.\n\t */\n\texternalComponent?: React.ComponentType<ExternalComponentProps>;\n} & (\n\t\t| {\n\t\t\t\tdocument: PrismicDocument | null | undefined;\n\t\t\t\thref?: never;\n\t\t\t\tfield?: never;\n\t\t }\n\t\t| {\n\t\t\t\tfield: LinkField | null | undefined;\n\t\t\t\thref?: never;\n\t\t\t\tdocument?: never;\n\t\t }\n\t\t| {\n\t\t\t\thref: LinkProps[\"href\"];\n\t\t\t\tfield?: LinkField | null | undefined;\n\t\t\t\tdocument?: never;\n\t\t }\n\t);\n\nexport const PrismicLink = React.forwardRef(function PrismicLink<\n\tInternalComponentProps = React.ComponentProps<typeof defaultComponent>,\n\tExternalComponentProps = React.ComponentProps<typeof defaultComponent>,\n>(\n\t{\n\t\tfield,\n\t\tdocument: doc,\n\t\tlinkResolver,\n\t\tinternalComponent,\n\t\texternalComponent,\n\t\t...restProps\n\t}: PrismicLinkProps<InternalComponentProps, ExternalComponentProps>,\n\tref: React.ForwardedRef<Element>,\n): JSX.Element {\n\tif (process.env.NODE_ENV === \"development\") {\n\t\tif (field) {\n\t\t\tif (!field.link_type) {\n\t\t\t\tconsole.error(\n\t\t\t\t\t`[PrismicLink] This \"field\" prop value caused an error to be thrown.\\n`,\n\t\t\t\t\tfield,\n\t\t\t\t);\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`[PrismicLink] The provided field is missing required properties to properly render a link. The link will not render. For more details, see ${devMsg(\n\t\t\t\t\t\t\"missing-link-properties\",\n\t\t\t\t\t)}`,\n\t\t\t\t);\n\t\t\t} else if (\n\t\t\t\tObject.keys(field).length > 1 &&\n\t\t\t\t!(\"url\" in field || \"uid\" in field || \"id\" in field)\n\t\t\t) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`[PrismicLink] The provided field is missing required properties to properly render a link. The link may not render correctly. For more details, see ${devMsg(\n\t\t\t\t\t\t\"missing-link-properties\",\n\t\t\t\t\t)}`,\n\t\t\t\t\tfield,\n\t\t\t\t);\n\t\t\t}\n\t\t} else if (doc) {\n\t\t\tif (!(\"url\" in doc || \"id\" in doc)) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`[PrismicLink] The provided document is missing required properties to properly render a link. The link may not render correctly. For more details, see ${devMsg(\n\t\t\t\t\t\t\"missing-link-properties\",\n\t\t\t\t\t)}`,\n\t\t\t\t\tdoc,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst {\n\t\thref: computedHref,\n\t\trel: computedRel,\n\t\t...attrs\n\t} = asLinkAttrs(field ?? doc, {\n\t\tlinkResolver,\n\t\trel: typeof restProps.rel === \"function\" ? restProps.rel : undefined,\n\t});\n\n\tlet rel: string | undefined = computedRel;\n\tif (\"rel\" in restProps && typeof restProps.rel !== \"function\") {\n\t\trel = restProps.rel;\n\t}\n\n\tconst href = (\"href\" in restProps ? restProps.href : computedHref) || \"\";\n\n\tconst InternalComponent = (internalComponent ||\n\t\tdefaultComponent) as React.ComponentType<LinkProps>;\n\tconst ExternalComponent = (externalComponent ||\n\t\tdefaultComponent) as React.ComponentType<LinkProps>;\n\tconst Component =\n\t\thref && isInternalURL(href) ? InternalComponent : ExternalComponent;\n\n\treturn (\n\t\t<Component ref={ref} {...attrs} {...restProps} href={href} rel={rel} />\n\t);\n}) as <\n\tInternalComponentProps = React.ComponentProps<typeof defaultComponent>,\n\tExternalComponentProps = React.ComponentProps<typeof defaultComponent>,\n>(\n\tprops: PrismicLinkProps<InternalComponentProps, ExternalComponentProps> & {\n\t\tref?: React.ForwardedRef<Element>;\n\t},\n) => JSX.Element;\n"],"names":["React","PrismicLink","devMsg","asLinkAttrs","isInternalURL","jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAeO,MAAM,mBAAmB;AAgFzB,MAAM,cAAcA,iBAAM,WAAW,SAASC,aAIpD,EACC,OACA,UAAU,KACV,cACA,mBACA,mBACA,GAAG,UAAA,GAEJ,KAAgC;AAE5B,MAAA,QAAQ,IAAI,aAAa,eAAe;AAC3C,QAAI,OAAO;AACN,UAAA,CAAC,MAAM,WAAW;AACrB,gBAAQ,MACP;AAAA,GACA,KAAK;AAEN,cAAM,IAAI,MACT,8IAA8IC,OAAA,OAC7I,yBAAyB,GACvB;AAAA,MAGJ,WAAA,OAAO,KAAK,KAAK,EAAE,SAAS,KAC5B,EAAE,SAAS,SAAS,SAAS,SAAS,QAAQ,QAC7C;AACD,gBAAQ,KACP,uJAAuJA,OAAAA,OACtJ,yBAAyB,KAE1B,KAAK;AAAA,MAEN;AAAA,eACS,KAAK;AACf,UAAI,EAAE,SAAS,OAAO,QAAQ,MAAM;AACnC,gBAAQ,KACP,0JAA0JA,OAAAA,OACzJ,yBAAyB,KAE1B,GAAG;AAAA,MAEJ;AAAA,IACD;AAAA,EACD;AAEK,QAAA,EACL,MAAM,cACN,KAAK,aACL,GAAG,UACAC,YAAAA,YAAY,SAAS,KAAK;AAAA,IAC7B;AAAA,IACA,KAAK,OAAO,UAAU,QAAQ,aAAa,UAAU,MAAM;AAAA,EAAA,CAC3D;AAED,MAAI,MAA0B;AAC9B,MAAI,SAAS,aAAa,OAAO,UAAU,QAAQ,YAAY;AAC9D,UAAM,UAAU;AAAA,EAChB;AAED,QAAM,QAAQ,UAAU,YAAY,UAAU,OAAO,iBAAiB;AAEtE,QAAM,oBAAqB,qBAC1B;AACD,QAAM,oBAAqB,qBAC1B;AACD,QAAM,YACL,QAAQC,cAAAA,cAAc,IAAI,IAAI,oBAAoB;AAGlD,SAAAC,2BAAA,IAAC,aAAU,KAAc,GAAA,OAAO,GAAI,WAAW,MAAY,IAAS,CAAA;AAEtE,CAAC;;;"}
1
+ {"version":3,"file":"PrismicLink.cjs","sources":["../../../src/react-server/PrismicLink.tsx"],"sourcesContent":["import * as React from \"react\";\nimport {\n\tLinkField,\n\tLinkResolverFunction,\n\tPrismicDocument,\n\tasLinkAttrs,\n\tAsLinkAttrsConfig,\n} from \"@prismicio/client\";\n\nimport { devMsg } from \"../lib/devMsg\";\nimport { isInternalURL } from \"../lib/isInternalURL\";\n\n/**\n * The default component rendered for internal and external links.\n */\nexport const defaultComponent = \"a\";\n\n/**\n * Props provided to a component when rendered with `<PrismicLink>`.\n */\nexport interface LinkProps {\n\t/**\n\t * The URL to link.\n\t */\n\thref: string;\n\n\t/**\n\t * The `target` attribute for anchor elements. If the Prismic field is\n\t * configured to open in a new window, this prop defaults to `_blank`.\n\t */\n\ttarget?: React.HTMLAttributeAnchorTarget;\n\n\t/**\n\t * The `rel` attribute for anchor elements. If the `target` prop is set to\n\t * `\"_blank\"`, this prop defaults to `\"noopener noreferrer\"`.\n\t */\n\trel?: string;\n\n\t/**\n\t * Children for the component. *\n\t */\n\tchildren?: React.ReactNode;\n}\n\nexport type PrismicLinkProps<\n\tInternalComponentProps = React.ComponentProps<typeof defaultComponent>,\n\tExternalComponentProps = React.ComponentProps<typeof defaultComponent>,\n> = Omit<InternalComponentProps & ExternalComponentProps, \"rel\" | \"href\"> & {\n\t/**\n\t * The `rel` attribute for the link. By default, `\"noreferrer\"` is provided if\n\t * the link's URL is external. This prop can be provided a function to use the\n\t * link's metadata to determine the `rel` value.\n\t */\n\trel?: string | AsLinkAttrsConfig[\"rel\"];\n\n\t/**\n\t * The Link Resolver used to resolve links.\n\t *\n\t * @remarks\n\t * If your app uses Route Resolvers when querying for your Prismic\n\t * repository's content, a Link Resolver does not need to be provided.\n\t * @see Learn about Link Resolvers and Route Resolvers {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver}\n\t */\n\tlinkResolver?: LinkResolverFunction;\n\n\t/**\n\t * The component rendered for internal URLs. Defaults to `<a>`.\n\t *\n\t * If your app uses a client-side router that requires a special Link\n\t * component, provide the Link component to this prop.\n\t */\n\tinternalComponent?: React.ElementType<InternalComponentProps>;\n\n\t/**\n\t * The component rendered for external URLs. Defaults to `<a>`.\n\t */\n\texternalComponent?: React.ComponentType<ExternalComponentProps>;\n} & (\n\t\t| {\n\t\t\t\tdocument: PrismicDocument | null | undefined;\n\t\t\t\thref?: never;\n\t\t\t\tfield?: never;\n\t\t }\n\t\t| {\n\t\t\t\tfield: LinkField | null | undefined;\n\t\t\t\thref?: never;\n\t\t\t\tdocument?: never;\n\t\t }\n\t\t| {\n\t\t\t\thref: LinkProps[\"href\"];\n\t\t\t\tfield?: LinkField | null | undefined;\n\t\t\t\tdocument?: never;\n\t\t }\n\t);\n\nexport const PrismicLink = React.forwardRef(function PrismicLink<\n\tInternalComponentProps = React.ComponentProps<typeof defaultComponent>,\n\tExternalComponentProps = React.ComponentProps<typeof defaultComponent>,\n>(\n\t{\n\t\tfield,\n\t\tdocument: doc,\n\t\tlinkResolver,\n\t\tinternalComponent,\n\t\texternalComponent,\n\t\t...restProps\n\t}: PrismicLinkProps<InternalComponentProps, ExternalComponentProps>,\n\tref: React.ForwardedRef<Element>,\n): JSX.Element {\n\tif (\n\t\ttypeof process !== \"undefined\" &&\n\t\tprocess.env.NODE_ENV === \"development\"\n\t) {\n\t\tif (field) {\n\t\t\tif (!field.link_type) {\n\t\t\t\tconsole.error(\n\t\t\t\t\t`[PrismicLink] This \"field\" prop value caused an error to be thrown.\\n`,\n\t\t\t\t\tfield,\n\t\t\t\t);\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`[PrismicLink] The provided field is missing required properties to properly render a link. The link will not render. For more details, see ${devMsg(\n\t\t\t\t\t\t\"missing-link-properties\",\n\t\t\t\t\t)}`,\n\t\t\t\t);\n\t\t\t} else if (\n\t\t\t\tObject.keys(field).length > 1 &&\n\t\t\t\t!(\"url\" in field || \"uid\" in field || \"id\" in field)\n\t\t\t) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`[PrismicLink] The provided field is missing required properties to properly render a link. The link may not render correctly. For more details, see ${devMsg(\n\t\t\t\t\t\t\"missing-link-properties\",\n\t\t\t\t\t)}`,\n\t\t\t\t\tfield,\n\t\t\t\t);\n\t\t\t}\n\t\t} else if (doc) {\n\t\t\tif (!(\"url\" in doc || \"id\" in doc)) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`[PrismicLink] The provided document is missing required properties to properly render a link. The link may not render correctly. For more details, see ${devMsg(\n\t\t\t\t\t\t\"missing-link-properties\",\n\t\t\t\t\t)}`,\n\t\t\t\t\tdoc,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst {\n\t\thref: computedHref,\n\t\trel: computedRel,\n\t\t...attrs\n\t} = asLinkAttrs(field ?? doc, {\n\t\tlinkResolver,\n\t\trel: typeof restProps.rel === \"function\" ? restProps.rel : undefined,\n\t});\n\n\tlet rel: string | undefined = computedRel;\n\tif (\"rel\" in restProps && typeof restProps.rel !== \"function\") {\n\t\trel = restProps.rel;\n\t}\n\n\tconst href = (\"href\" in restProps ? restProps.href : computedHref) || \"\";\n\n\tconst InternalComponent = (internalComponent ||\n\t\tdefaultComponent) as React.ComponentType<LinkProps>;\n\tconst ExternalComponent = (externalComponent ||\n\t\tdefaultComponent) as React.ComponentType<LinkProps>;\n\tconst Component =\n\t\thref && isInternalURL(href) ? InternalComponent : ExternalComponent;\n\n\treturn (\n\t\t<Component ref={ref} {...attrs} {...restProps} href={href} rel={rel} />\n\t);\n}) as <\n\tInternalComponentProps = React.ComponentProps<typeof defaultComponent>,\n\tExternalComponentProps = React.ComponentProps<typeof defaultComponent>,\n>(\n\tprops: PrismicLinkProps<InternalComponentProps, ExternalComponentProps> & {\n\t\tref?: React.ForwardedRef<Element>;\n\t},\n) => JSX.Element;\n"],"names":["React","PrismicLink","devMsg","asLinkAttrs","isInternalURL","jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAeO,MAAM,mBAAmB;AAgFzB,MAAM,cAAcA,iBAAM,WAAW,SAASC,aAIpD,EACC,OACA,UAAU,KACV,cACA,mBACA,mBACA,GAAG,UAAA,GAEJ,KAAgC;AAEhC,MACC,OAAO,YAAY,eACnB,QAAQ,IAAI,aAAa,eACxB;AACD,QAAI,OAAO;AACN,UAAA,CAAC,MAAM,WAAW;AACrB,gBAAQ,MACP;AAAA,GACA,KAAK;AAEN,cAAM,IAAI,MACT,8IAA8IC,OAAA,OAC7I,yBAAyB,GACvB;AAAA,MAGJ,WAAA,OAAO,KAAK,KAAK,EAAE,SAAS,KAC5B,EAAE,SAAS,SAAS,SAAS,SAAS,QAAQ,QAC7C;AACD,gBAAQ,KACP,uJAAuJA,OAAAA,OACtJ,yBAAyB,KAE1B,KAAK;AAAA,MAEN;AAAA,eACS,KAAK;AACf,UAAI,EAAE,SAAS,OAAO,QAAQ,MAAM;AACnC,gBAAQ,KACP,0JAA0JA,OAAAA,OACzJ,yBAAyB,KAE1B,GAAG;AAAA,MAEJ;AAAA,IACD;AAAA,EACD;AAEK,QAAA,EACL,MAAM,cACN,KAAK,aACL,GAAG,UACAC,YAAAA,YAAY,SAAS,KAAK;AAAA,IAC7B;AAAA,IACA,KAAK,OAAO,UAAU,QAAQ,aAAa,UAAU,MAAM;AAAA,EAAA,CAC3D;AAED,MAAI,MAA0B;AAC9B,MAAI,SAAS,aAAa,OAAO,UAAU,QAAQ,YAAY;AAC9D,UAAM,UAAU;AAAA,EAChB;AAED,QAAM,QAAQ,UAAU,YAAY,UAAU,OAAO,iBAAiB;AAEtE,QAAM,oBAAqB,qBAC1B;AACD,QAAM,oBAAqB,qBAC1B;AACD,QAAM,YACL,QAAQC,cAAAA,cAAc,IAAI,IAAI,oBAAoB;AAGlD,SAAAC,2BAAA,IAAC,aAAU,KAAc,GAAA,OAAO,GAAI,WAAW,MAAY,IAAS,CAAA;AAEtE,CAAC;;;"}
@@ -6,7 +6,7 @@ import { devMsg } from "../lib/devMsg.js";
6
6
  import { isInternalURL } from "../lib/isInternalURL.js";
7
7
  const defaultComponent = "a";
8
8
  const PrismicLink = React.forwardRef(function PrismicLink2({ field, document: doc, linkResolver, internalComponent, externalComponent, ...restProps }, ref) {
9
- if (process.env.NODE_ENV === "development") {
9
+ if (typeof process !== "undefined" && process.env.NODE_ENV === "development") {
10
10
  if (field) {
11
11
  if (!field.link_type) {
12
12
  console.error(`[PrismicLink] This "field" prop value caused an error to be thrown.
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicLink.js","sources":["../../../src/react-server/PrismicLink.tsx"],"sourcesContent":["import * as React from \"react\";\nimport {\n\tLinkField,\n\tLinkResolverFunction,\n\tPrismicDocument,\n\tasLinkAttrs,\n\tAsLinkAttrsConfig,\n} from \"@prismicio/client\";\n\nimport { devMsg } from \"../lib/devMsg\";\nimport { isInternalURL } from \"../lib/isInternalURL\";\n\n/**\n * The default component rendered for internal and external links.\n */\nexport const defaultComponent = \"a\";\n\n/**\n * Props provided to a component when rendered with `<PrismicLink>`.\n */\nexport interface LinkProps {\n\t/**\n\t * The URL to link.\n\t */\n\thref: string;\n\n\t/**\n\t * The `target` attribute for anchor elements. If the Prismic field is\n\t * configured to open in a new window, this prop defaults to `_blank`.\n\t */\n\ttarget?: React.HTMLAttributeAnchorTarget;\n\n\t/**\n\t * The `rel` attribute for anchor elements. If the `target` prop is set to\n\t * `\"_blank\"`, this prop defaults to `\"noopener noreferrer\"`.\n\t */\n\trel?: string;\n\n\t/**\n\t * Children for the component. *\n\t */\n\tchildren?: React.ReactNode;\n}\n\nexport type PrismicLinkProps<\n\tInternalComponentProps = React.ComponentProps<typeof defaultComponent>,\n\tExternalComponentProps = React.ComponentProps<typeof defaultComponent>,\n> = Omit<InternalComponentProps & ExternalComponentProps, \"rel\" | \"href\"> & {\n\t/**\n\t * The `rel` attribute for the link. By default, `\"noreferrer\"` is provided if\n\t * the link's URL is external. This prop can be provided a function to use the\n\t * link's metadata to determine the `rel` value.\n\t */\n\trel?: string | AsLinkAttrsConfig[\"rel\"];\n\n\t/**\n\t * The Link Resolver used to resolve links.\n\t *\n\t * @remarks\n\t * If your app uses Route Resolvers when querying for your Prismic\n\t * repository's content, a Link Resolver does not need to be provided.\n\t * @see Learn about Link Resolvers and Route Resolvers {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver}\n\t */\n\tlinkResolver?: LinkResolverFunction;\n\n\t/**\n\t * The component rendered for internal URLs. Defaults to `<a>`.\n\t *\n\t * If your app uses a client-side router that requires a special Link\n\t * component, provide the Link component to this prop.\n\t */\n\tinternalComponent?: React.ElementType<InternalComponentProps>;\n\n\t/**\n\t * The component rendered for external URLs. Defaults to `<a>`.\n\t */\n\texternalComponent?: React.ComponentType<ExternalComponentProps>;\n} & (\n\t\t| {\n\t\t\t\tdocument: PrismicDocument | null | undefined;\n\t\t\t\thref?: never;\n\t\t\t\tfield?: never;\n\t\t }\n\t\t| {\n\t\t\t\tfield: LinkField | null | undefined;\n\t\t\t\thref?: never;\n\t\t\t\tdocument?: never;\n\t\t }\n\t\t| {\n\t\t\t\thref: LinkProps[\"href\"];\n\t\t\t\tfield?: LinkField | null | undefined;\n\t\t\t\tdocument?: never;\n\t\t }\n\t);\n\nexport const PrismicLink = React.forwardRef(function PrismicLink<\n\tInternalComponentProps = React.ComponentProps<typeof defaultComponent>,\n\tExternalComponentProps = React.ComponentProps<typeof defaultComponent>,\n>(\n\t{\n\t\tfield,\n\t\tdocument: doc,\n\t\tlinkResolver,\n\t\tinternalComponent,\n\t\texternalComponent,\n\t\t...restProps\n\t}: PrismicLinkProps<InternalComponentProps, ExternalComponentProps>,\n\tref: React.ForwardedRef<Element>,\n): JSX.Element {\n\tif (process.env.NODE_ENV === \"development\") {\n\t\tif (field) {\n\t\t\tif (!field.link_type) {\n\t\t\t\tconsole.error(\n\t\t\t\t\t`[PrismicLink] This \"field\" prop value caused an error to be thrown.\\n`,\n\t\t\t\t\tfield,\n\t\t\t\t);\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`[PrismicLink] The provided field is missing required properties to properly render a link. The link will not render. For more details, see ${devMsg(\n\t\t\t\t\t\t\"missing-link-properties\",\n\t\t\t\t\t)}`,\n\t\t\t\t);\n\t\t\t} else if (\n\t\t\t\tObject.keys(field).length > 1 &&\n\t\t\t\t!(\"url\" in field || \"uid\" in field || \"id\" in field)\n\t\t\t) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`[PrismicLink] The provided field is missing required properties to properly render a link. The link may not render correctly. For more details, see ${devMsg(\n\t\t\t\t\t\t\"missing-link-properties\",\n\t\t\t\t\t)}`,\n\t\t\t\t\tfield,\n\t\t\t\t);\n\t\t\t}\n\t\t} else if (doc) {\n\t\t\tif (!(\"url\" in doc || \"id\" in doc)) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`[PrismicLink] The provided document is missing required properties to properly render a link. The link may not render correctly. For more details, see ${devMsg(\n\t\t\t\t\t\t\"missing-link-properties\",\n\t\t\t\t\t)}`,\n\t\t\t\t\tdoc,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst {\n\t\thref: computedHref,\n\t\trel: computedRel,\n\t\t...attrs\n\t} = asLinkAttrs(field ?? doc, {\n\t\tlinkResolver,\n\t\trel: typeof restProps.rel === \"function\" ? restProps.rel : undefined,\n\t});\n\n\tlet rel: string | undefined = computedRel;\n\tif (\"rel\" in restProps && typeof restProps.rel !== \"function\") {\n\t\trel = restProps.rel;\n\t}\n\n\tconst href = (\"href\" in restProps ? restProps.href : computedHref) || \"\";\n\n\tconst InternalComponent = (internalComponent ||\n\t\tdefaultComponent) as React.ComponentType<LinkProps>;\n\tconst ExternalComponent = (externalComponent ||\n\t\tdefaultComponent) as React.ComponentType<LinkProps>;\n\tconst Component =\n\t\thref && isInternalURL(href) ? InternalComponent : ExternalComponent;\n\n\treturn (\n\t\t<Component ref={ref} {...attrs} {...restProps} href={href} rel={rel} />\n\t);\n}) as <\n\tInternalComponentProps = React.ComponentProps<typeof defaultComponent>,\n\tExternalComponentProps = React.ComponentProps<typeof defaultComponent>,\n>(\n\tprops: PrismicLinkProps<InternalComponentProps, ExternalComponentProps> & {\n\t\tref?: React.ForwardedRef<Element>;\n\t},\n) => JSX.Element;\n"],"names":["PrismicLink"],"mappings":";;;;;;AAeO,MAAM,mBAAmB;AAgFzB,MAAM,cAAc,MAAM,WAAW,SAASA,aAIpD,EACC,OACA,UAAU,KACV,cACA,mBACA,mBACA,GAAG,UAAA,GAEJ,KAAgC;AAE5B,MAAA,QAAQ,IAAI,aAAa,eAAe;AAC3C,QAAI,OAAO;AACN,UAAA,CAAC,MAAM,WAAW;AACrB,gBAAQ,MACP;AAAA,GACA,KAAK;AAEN,cAAM,IAAI,MACT,8IAA8I,OAC7I,yBAAyB,GACvB;AAAA,MAGJ,WAAA,OAAO,KAAK,KAAK,EAAE,SAAS,KAC5B,EAAE,SAAS,SAAS,SAAS,SAAS,QAAQ,QAC7C;AACD,gBAAQ,KACP,uJAAuJ,OACtJ,yBAAyB,KAE1B,KAAK;AAAA,MAEN;AAAA,eACS,KAAK;AACf,UAAI,EAAE,SAAS,OAAO,QAAQ,MAAM;AACnC,gBAAQ,KACP,0JAA0J,OACzJ,yBAAyB,KAE1B,GAAG;AAAA,MAEJ;AAAA,IACD;AAAA,EACD;AAEK,QAAA,EACL,MAAM,cACN,KAAK,aACL,GAAG,UACA,YAAY,SAAS,KAAK;AAAA,IAC7B;AAAA,IACA,KAAK,OAAO,UAAU,QAAQ,aAAa,UAAU,MAAM;AAAA,EAAA,CAC3D;AAED,MAAI,MAA0B;AAC9B,MAAI,SAAS,aAAa,OAAO,UAAU,QAAQ,YAAY;AAC9D,UAAM,UAAU;AAAA,EAChB;AAED,QAAM,QAAQ,UAAU,YAAY,UAAU,OAAO,iBAAiB;AAEtE,QAAM,oBAAqB,qBAC1B;AACD,QAAM,oBAAqB,qBAC1B;AACD,QAAM,YACL,QAAQ,cAAc,IAAI,IAAI,oBAAoB;AAGlD,SAAA,oBAAC,aAAU,KAAc,GAAA,OAAO,GAAI,WAAW,MAAY,IAAS,CAAA;AAEtE,CAAC;"}
1
+ {"version":3,"file":"PrismicLink.js","sources":["../../../src/react-server/PrismicLink.tsx"],"sourcesContent":["import * as React from \"react\";\nimport {\n\tLinkField,\n\tLinkResolverFunction,\n\tPrismicDocument,\n\tasLinkAttrs,\n\tAsLinkAttrsConfig,\n} from \"@prismicio/client\";\n\nimport { devMsg } from \"../lib/devMsg\";\nimport { isInternalURL } from \"../lib/isInternalURL\";\n\n/**\n * The default component rendered for internal and external links.\n */\nexport const defaultComponent = \"a\";\n\n/**\n * Props provided to a component when rendered with `<PrismicLink>`.\n */\nexport interface LinkProps {\n\t/**\n\t * The URL to link.\n\t */\n\thref: string;\n\n\t/**\n\t * The `target` attribute for anchor elements. If the Prismic field is\n\t * configured to open in a new window, this prop defaults to `_blank`.\n\t */\n\ttarget?: React.HTMLAttributeAnchorTarget;\n\n\t/**\n\t * The `rel` attribute for anchor elements. If the `target` prop is set to\n\t * `\"_blank\"`, this prop defaults to `\"noopener noreferrer\"`.\n\t */\n\trel?: string;\n\n\t/**\n\t * Children for the component. *\n\t */\n\tchildren?: React.ReactNode;\n}\n\nexport type PrismicLinkProps<\n\tInternalComponentProps = React.ComponentProps<typeof defaultComponent>,\n\tExternalComponentProps = React.ComponentProps<typeof defaultComponent>,\n> = Omit<InternalComponentProps & ExternalComponentProps, \"rel\" | \"href\"> & {\n\t/**\n\t * The `rel` attribute for the link. By default, `\"noreferrer\"` is provided if\n\t * the link's URL is external. This prop can be provided a function to use the\n\t * link's metadata to determine the `rel` value.\n\t */\n\trel?: string | AsLinkAttrsConfig[\"rel\"];\n\n\t/**\n\t * The Link Resolver used to resolve links.\n\t *\n\t * @remarks\n\t * If your app uses Route Resolvers when querying for your Prismic\n\t * repository's content, a Link Resolver does not need to be provided.\n\t * @see Learn about Link Resolvers and Route Resolvers {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver}\n\t */\n\tlinkResolver?: LinkResolverFunction;\n\n\t/**\n\t * The component rendered for internal URLs. Defaults to `<a>`.\n\t *\n\t * If your app uses a client-side router that requires a special Link\n\t * component, provide the Link component to this prop.\n\t */\n\tinternalComponent?: React.ElementType<InternalComponentProps>;\n\n\t/**\n\t * The component rendered for external URLs. Defaults to `<a>`.\n\t */\n\texternalComponent?: React.ComponentType<ExternalComponentProps>;\n} & (\n\t\t| {\n\t\t\t\tdocument: PrismicDocument | null | undefined;\n\t\t\t\thref?: never;\n\t\t\t\tfield?: never;\n\t\t }\n\t\t| {\n\t\t\t\tfield: LinkField | null | undefined;\n\t\t\t\thref?: never;\n\t\t\t\tdocument?: never;\n\t\t }\n\t\t| {\n\t\t\t\thref: LinkProps[\"href\"];\n\t\t\t\tfield?: LinkField | null | undefined;\n\t\t\t\tdocument?: never;\n\t\t }\n\t);\n\nexport const PrismicLink = React.forwardRef(function PrismicLink<\n\tInternalComponentProps = React.ComponentProps<typeof defaultComponent>,\n\tExternalComponentProps = React.ComponentProps<typeof defaultComponent>,\n>(\n\t{\n\t\tfield,\n\t\tdocument: doc,\n\t\tlinkResolver,\n\t\tinternalComponent,\n\t\texternalComponent,\n\t\t...restProps\n\t}: PrismicLinkProps<InternalComponentProps, ExternalComponentProps>,\n\tref: React.ForwardedRef<Element>,\n): JSX.Element {\n\tif (\n\t\ttypeof process !== \"undefined\" &&\n\t\tprocess.env.NODE_ENV === \"development\"\n\t) {\n\t\tif (field) {\n\t\t\tif (!field.link_type) {\n\t\t\t\tconsole.error(\n\t\t\t\t\t`[PrismicLink] This \"field\" prop value caused an error to be thrown.\\n`,\n\t\t\t\t\tfield,\n\t\t\t\t);\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`[PrismicLink] The provided field is missing required properties to properly render a link. The link will not render. For more details, see ${devMsg(\n\t\t\t\t\t\t\"missing-link-properties\",\n\t\t\t\t\t)}`,\n\t\t\t\t);\n\t\t\t} else if (\n\t\t\t\tObject.keys(field).length > 1 &&\n\t\t\t\t!(\"url\" in field || \"uid\" in field || \"id\" in field)\n\t\t\t) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`[PrismicLink] The provided field is missing required properties to properly render a link. The link may not render correctly. For more details, see ${devMsg(\n\t\t\t\t\t\t\"missing-link-properties\",\n\t\t\t\t\t)}`,\n\t\t\t\t\tfield,\n\t\t\t\t);\n\t\t\t}\n\t\t} else if (doc) {\n\t\t\tif (!(\"url\" in doc || \"id\" in doc)) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`[PrismicLink] The provided document is missing required properties to properly render a link. The link may not render correctly. For more details, see ${devMsg(\n\t\t\t\t\t\t\"missing-link-properties\",\n\t\t\t\t\t)}`,\n\t\t\t\t\tdoc,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst {\n\t\thref: computedHref,\n\t\trel: computedRel,\n\t\t...attrs\n\t} = asLinkAttrs(field ?? doc, {\n\t\tlinkResolver,\n\t\trel: typeof restProps.rel === \"function\" ? restProps.rel : undefined,\n\t});\n\n\tlet rel: string | undefined = computedRel;\n\tif (\"rel\" in restProps && typeof restProps.rel !== \"function\") {\n\t\trel = restProps.rel;\n\t}\n\n\tconst href = (\"href\" in restProps ? restProps.href : computedHref) || \"\";\n\n\tconst InternalComponent = (internalComponent ||\n\t\tdefaultComponent) as React.ComponentType<LinkProps>;\n\tconst ExternalComponent = (externalComponent ||\n\t\tdefaultComponent) as React.ComponentType<LinkProps>;\n\tconst Component =\n\t\thref && isInternalURL(href) ? InternalComponent : ExternalComponent;\n\n\treturn (\n\t\t<Component ref={ref} {...attrs} {...restProps} href={href} rel={rel} />\n\t);\n}) as <\n\tInternalComponentProps = React.ComponentProps<typeof defaultComponent>,\n\tExternalComponentProps = React.ComponentProps<typeof defaultComponent>,\n>(\n\tprops: PrismicLinkProps<InternalComponentProps, ExternalComponentProps> & {\n\t\tref?: React.ForwardedRef<Element>;\n\t},\n) => JSX.Element;\n"],"names":["PrismicLink"],"mappings":";;;;;;AAeO,MAAM,mBAAmB;AAgFzB,MAAM,cAAc,MAAM,WAAW,SAASA,aAIpD,EACC,OACA,UAAU,KACV,cACA,mBACA,mBACA,GAAG,UAAA,GAEJ,KAAgC;AAEhC,MACC,OAAO,YAAY,eACnB,QAAQ,IAAI,aAAa,eACxB;AACD,QAAI,OAAO;AACN,UAAA,CAAC,MAAM,WAAW;AACrB,gBAAQ,MACP;AAAA,GACA,KAAK;AAEN,cAAM,IAAI,MACT,8IAA8I,OAC7I,yBAAyB,GACvB;AAAA,MAGJ,WAAA,OAAO,KAAK,KAAK,EAAE,SAAS,KAC5B,EAAE,SAAS,SAAS,SAAS,SAAS,QAAQ,QAC7C;AACD,gBAAQ,KACP,uJAAuJ,OACtJ,yBAAyB,KAE1B,KAAK;AAAA,MAEN;AAAA,eACS,KAAK;AACf,UAAI,EAAE,SAAS,OAAO,QAAQ,MAAM;AACnC,gBAAQ,KACP,0JAA0J,OACzJ,yBAAyB,KAE1B,GAAG;AAAA,MAEJ;AAAA,IACD;AAAA,EACD;AAEK,QAAA,EACL,MAAM,cACN,KAAK,aACL,GAAG,UACA,YAAY,SAAS,KAAK;AAAA,IAC7B;AAAA,IACA,KAAK,OAAO,UAAU,QAAQ,aAAa,UAAU,MAAM;AAAA,EAAA,CAC3D;AAED,MAAI,MAA0B;AAC9B,MAAI,SAAS,aAAa,OAAO,UAAU,QAAQ,YAAY;AAC9D,UAAM,UAAU;AAAA,EAChB;AAED,QAAM,QAAQ,UAAU,YAAY,UAAU,OAAO,iBAAiB;AAEtE,QAAM,oBAAqB,qBAC1B;AACD,QAAM,oBAAqB,qBAC1B;AACD,QAAM,YACL,QAAQ,cAAc,IAAI,IAAI,oBAAoB;AAGlD,SAAA,oBAAC,aAAU,KAAc,GAAA,OAAO,GAAI,WAAW,MAAY,IAAS,CAAA;AAEtE,CAAC;"}
@@ -61,7 +61,7 @@ const createDefaultSerializer = (args) => prismicR__namespace.wrapMapSerializer(
61
61
  });
62
62
  function PrismicRichText({ linkResolver, field, fallback, components, externalLinkComponent, internalLinkComponent, ...restProps }) {
63
63
  return React__namespace.useMemo(() => {
64
- if (process.env.NODE_ENV === "development") {
64
+ if (typeof process !== "undefined" && process.env.NODE_ENV === "development") {
65
65
  if ("className" in restProps) {
66
66
  console.warn(`[PrismicRichText] className cannot be passed to <PrismicRichText> since it renders an array without a wrapping component. For more details, see ${devMsg.devMsg("classname-is-not-a-valid-prop")}.`, field);
67
67
  }
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicRichText.cjs","sources":["../../../src/react-server/PrismicRichText.tsx"],"sourcesContent":["import * as React from \"react\";\nimport * as prismic from \"@prismicio/client\";\nimport * as prismicR from \"@prismicio/richtext\";\n\nimport { JSXFunctionSerializer, JSXMapSerializer } from \"../types\";\nimport { LinkProps, PrismicLink } from \"./PrismicLink\";\nimport { devMsg } from \"../lib/devMsg\";\n\n/**\n * Props for `<PrismicRichText>`.\n */\nexport type PrismicRichTextProps<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tLinkResolverFunction extends prismic.LinkResolverFunction<any> = prismic.LinkResolverFunction,\n> = {\n\t/**\n\t * The Prismic Rich Text field to render.\n\t */\n\tfield: prismic.RichTextField | null | undefined;\n\n\t/**\n\t * The Link Resolver used to resolve links.\n\t *\n\t * @remarks\n\t * If your app uses Route Resolvers when querying for your Prismic\n\t * repository's content, a Link Resolver does not need to be provided.\n\t * @see Learn about Link Resolvers and Route Resolvers {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver}\n\t */\n\tlinkResolver?: LinkResolverFunction;\n\n\t/**\n\t * A map or function that maps a Rich Text block to a React component.\n\t *\n\t * @remarks\n\t * Prefer using a map serializer over the function serializer when possible.\n\t * The map serializer is simpler to maintain.\n\t * @example A map serializer.\n\t *\n\t * ```jsx\n\t * {\n\t * heading1: ({children}) => <Heading>{children}</Heading>\n\t * }\n\t * ```\n\t *\n\t * @example A function serializer.\n\t *\n\t * ```jsx\n\t * (type, node, content, children) => {\n\t * \tswitch (type) {\n\t * \t\tcase \"heading1\": {\n\t * \t\t\treturn <Heading>{children}</Heading>;\n\t * \t\t}\n\t * \t}\n\t * };\n\t * ```\n\t */\n\tcomponents?: JSXMapSerializer | JSXFunctionSerializer;\n\n\t/**\n\t * The React component rendered for links when the URL is internal.\n\t *\n\t * @defaultValue `<a>`\n\t */\n\tinternalLinkComponent?: React.ComponentType<LinkProps>;\n\n\t/**\n\t * The React component rendered for links when the URL is external.\n\t *\n\t * @defaultValue `<a>`\n\t */\n\texternalLinkComponent?: React.ComponentType<LinkProps>;\n\n\t/**\n\t * The value to be rendered when the field is empty. If a fallback is not\n\t * given, `null` will be rendered.\n\t */\n\tfallback?: React.ReactNode;\n};\n\ntype CreateDefaultSerializerArgs<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tLinkResolverFunction extends prismic.LinkResolverFunction<any> = prismic.LinkResolverFunction,\n> = {\n\tlinkResolver: LinkResolverFunction | undefined;\n\tinternalLinkComponent?: React.ComponentType<LinkProps>;\n\texternalLinkComponent?: React.ComponentType<LinkProps>;\n};\n\nconst createDefaultSerializer = <\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tLinkResolverFunction extends prismic.LinkResolverFunction<any>,\n>(\n\targs: CreateDefaultSerializerArgs<LinkResolverFunction>,\n): JSXFunctionSerializer =>\n\tprismicR.wrapMapSerializer({\n\t\theading1: ({ children, key }) => <h1 key={key}>{children}</h1>,\n\t\theading2: ({ children, key }) => <h2 key={key}>{children}</h2>,\n\t\theading3: ({ children, key }) => <h3 key={key}>{children}</h3>,\n\t\theading4: ({ children, key }) => <h4 key={key}>{children}</h4>,\n\t\theading5: ({ children, key }) => <h5 key={key}>{children}</h5>,\n\t\theading6: ({ children, key }) => <h6 key={key}>{children}</h6>,\n\t\tparagraph: ({ children, key }) => <p key={key}>{children}</p>,\n\t\tpreformatted: ({ node, key }) => <pre key={key}>{node.text}</pre>,\n\t\tstrong: ({ children, key }) => <strong key={key}>{children}</strong>,\n\t\tem: ({ children, key }) => <em key={key}>{children}</em>,\n\t\tlistItem: ({ children, key }) => <li key={key}>{children}</li>,\n\t\toListItem: ({ children, key }) => <li key={key}>{children}</li>,\n\t\tlist: ({ children, key }) => <ul key={key}>{children}</ul>,\n\t\toList: ({ children, key }) => <ol key={key}>{children}</ol>,\n\t\timage: ({ node, key }) => {\n\t\t\tconst img = (\n\t\t\t\t<img\n\t\t\t\t\tsrc={node.url}\n\t\t\t\t\talt={node.alt ?? undefined}\n\t\t\t\t\tdata-copyright={node.copyright ? node.copyright : undefined}\n\t\t\t\t/>\n\t\t\t);\n\n\t\t\treturn (\n\t\t\t\t<p key={key} className=\"block-img\">\n\t\t\t\t\t{node.linkTo ? (\n\t\t\t\t\t\t<PrismicLink\n\t\t\t\t\t\t\tlinkResolver={args.linkResolver}\n\t\t\t\t\t\t\tinternalComponent={args.internalLinkComponent}\n\t\t\t\t\t\t\texternalComponent={args.externalLinkComponent}\n\t\t\t\t\t\t\tfield={node.linkTo}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{img}\n\t\t\t\t\t\t</PrismicLink>\n\t\t\t\t\t) : (\n\t\t\t\t\t\timg\n\t\t\t\t\t)}\n\t\t\t\t</p>\n\t\t\t);\n\t\t},\n\t\tembed: ({ node, key }) => (\n\t\t\t<div\n\t\t\t\tkey={key}\n\t\t\t\tdata-oembed={node.oembed.embed_url}\n\t\t\t\tdata-oembed-type={node.oembed.type}\n\t\t\t\tdata-oembed-provider={node.oembed.provider_name}\n\t\t\t\tdangerouslySetInnerHTML={{ __html: node.oembed.html ?? \"\" }}\n\t\t\t/>\n\t\t),\n\t\thyperlink: ({ node, children, key }) => (\n\t\t\t<PrismicLink\n\t\t\t\tkey={key}\n\t\t\t\tfield={node.data}\n\t\t\t\tlinkResolver={args.linkResolver}\n\t\t\t\tinternalComponent={args.internalLinkComponent}\n\t\t\t\texternalComponent={args.externalLinkComponent}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</PrismicLink>\n\t\t),\n\t\tlabel: ({ node, children, key }) => (\n\t\t\t<span key={key} className={node.data.label}>\n\t\t\t\t{children}\n\t\t\t</span>\n\t\t),\n\t\tspan: ({ text, key }) => {\n\t\t\tconst result: React.ReactNode[] = [];\n\n\t\t\tlet i = 0;\n\t\t\tfor (const line of text.split(\"\\n\")) {\n\t\t\t\tif (i > 0) {\n\t\t\t\t\tresult.push(<br key={`${i}__break`} />);\n\t\t\t\t}\n\n\t\t\t\tresult.push(<React.Fragment key={`${i}__line`}>{line}</React.Fragment>);\n\n\t\t\t\ti++;\n\t\t\t}\n\n\t\t\treturn <React.Fragment key={key}>{result}</React.Fragment>;\n\t\t},\n\t});\n\n/**\n * React component that renders content from a Prismic Rich Text field. By\n * default, HTML elements are rendered for each piece of content. A `heading1`\n * block will render an `<h1>` HTML element, for example. Links will use\n * `<PrismicLink>` by default which can be customized using the\n * `internalLinkComponent` and `externalLinkComponent` props.\n *\n * To customize the components that are rendered, provide a map or function\n * serializer to the `components` prop.\n *\n * @remarks\n * This component returns a React fragment with no wrapping element around the\n * content. If you need a wrapper, add a component around `<PrismicRichText>`.\n * @example Rendering a Rich Text field using the default HTMl elements.\n *\n * ```jsx\n * <PrismicRichText field={document.data.content} />;\n * ```\n *\n * @example Rendering a Rich Text field using a custom set of React components.\n *\n * ```jsx\n * <PrismicRichText\n * \tfield={document.data.content}\n * \tcomponents={{\n * \t\theading1: ({ children }) => <Heading>{children}</Heading>,\n * \t}}\n * />;\n * ```\n *\n * @param props - Props for the component.\n *\n * @returns The Rich Text field's content as React components.\n *\n * @see Learn about Rich Text fields {@link https://prismic.io/docs/core-concepts/rich-text-title}\n * @see Learn about Rich Text serializers {@link https://prismic.io/docs/core-concepts/html-serializer}\n */\nexport function PrismicRichText<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tLinkResolverFunction extends prismic.LinkResolverFunction<any>,\n>({\n\tlinkResolver,\n\tfield,\n\tfallback,\n\tcomponents,\n\texternalLinkComponent,\n\tinternalLinkComponent,\n\t...restProps\n}: PrismicRichTextProps<LinkResolverFunction>): JSX.Element | null {\n\treturn React.useMemo(() => {\n\t\tif (process.env.NODE_ENV === \"development\") {\n\t\t\tif (\"className\" in restProps) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`[PrismicRichText] className cannot be passed to <PrismicRichText> since it renders an array without a wrapping component. For more details, see ${devMsg(\n\t\t\t\t\t\t\"classname-is-not-a-valid-prop\",\n\t\t\t\t\t)}.`,\n\t\t\t\t\tfield,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tif (prismic.isFilled.richText(field)) {\n\t\t\tconst serializer = prismicR.composeSerializers(\n\t\t\t\ttypeof components === \"object\"\n\t\t\t\t\t? prismicR.wrapMapSerializer(components)\n\t\t\t\t\t: components,\n\t\t\t\tcreateDefaultSerializer({\n\t\t\t\t\tlinkResolver,\n\t\t\t\t\tinternalLinkComponent,\n\t\t\t\t\texternalLinkComponent,\n\t\t\t\t}),\n\t\t\t);\n\n\t\t\t// The serializer is wrapped in a higher-order function\n\t\t\t// that automatically applies a key to React Elements\n\t\t\t// if one is not already given.\n\t\t\tconst serialized = prismicR.serialize<JSX.Element>(\n\t\t\t\tfield,\n\t\t\t\t(type, node, text, children, key) => {\n\t\t\t\t\tconst result = serializer(type, node, text, children, key);\n\n\t\t\t\t\tif (React.isValidElement(result) && result.key == null) {\n\t\t\t\t\t\treturn React.cloneElement(result, { key });\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn result;\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t);\n\n\t\t\treturn <>{serialized}</>;\n\t\t} else {\n\t\t\treturn fallback != null ? <>{fallback}</> : null;\n\t\t}\n\t}, [\n\t\tfield,\n\t\tinternalLinkComponent,\n\t\texternalLinkComponent,\n\t\tcomponents,\n\t\tlinkResolver,\n\t\tfallback,\n\t]);\n}\n"],"names":["prismicR","jsx","PrismicLink","React","devMsg","prismic.isFilled.richText","Fragment"],"mappings":"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"}
1
+ {"version":3,"file":"PrismicRichText.cjs","sources":["../../../src/react-server/PrismicRichText.tsx"],"sourcesContent":["import * as React from \"react\";\nimport * as prismic from \"@prismicio/client\";\nimport * as prismicR from \"@prismicio/richtext\";\n\nimport { JSXFunctionSerializer, JSXMapSerializer } from \"../types\";\nimport { LinkProps, PrismicLink } from \"./PrismicLink\";\nimport { devMsg } from \"../lib/devMsg\";\n\n/**\n * Props for `<PrismicRichText>`.\n */\nexport type PrismicRichTextProps<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tLinkResolverFunction extends prismic.LinkResolverFunction<any> = prismic.LinkResolverFunction,\n> = {\n\t/**\n\t * The Prismic Rich Text field to render.\n\t */\n\tfield: prismic.RichTextField | null | undefined;\n\n\t/**\n\t * The Link Resolver used to resolve links.\n\t *\n\t * @remarks\n\t * If your app uses Route Resolvers when querying for your Prismic\n\t * repository's content, a Link Resolver does not need to be provided.\n\t * @see Learn about Link Resolvers and Route Resolvers {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver}\n\t */\n\tlinkResolver?: LinkResolverFunction;\n\n\t/**\n\t * A map or function that maps a Rich Text block to a React component.\n\t *\n\t * @remarks\n\t * Prefer using a map serializer over the function serializer when possible.\n\t * The map serializer is simpler to maintain.\n\t * @example A map serializer.\n\t *\n\t * ```jsx\n\t * {\n\t * heading1: ({children}) => <Heading>{children}</Heading>\n\t * }\n\t * ```\n\t *\n\t * @example A function serializer.\n\t *\n\t * ```jsx\n\t * (type, node, content, children) => {\n\t * \tswitch (type) {\n\t * \t\tcase \"heading1\": {\n\t * \t\t\treturn <Heading>{children}</Heading>;\n\t * \t\t}\n\t * \t}\n\t * };\n\t * ```\n\t */\n\tcomponents?: JSXMapSerializer | JSXFunctionSerializer;\n\n\t/**\n\t * The React component rendered for links when the URL is internal.\n\t *\n\t * @defaultValue `<a>`\n\t */\n\tinternalLinkComponent?: React.ComponentType<LinkProps>;\n\n\t/**\n\t * The React component rendered for links when the URL is external.\n\t *\n\t * @defaultValue `<a>`\n\t */\n\texternalLinkComponent?: React.ComponentType<LinkProps>;\n\n\t/**\n\t * The value to be rendered when the field is empty. If a fallback is not\n\t * given, `null` will be rendered.\n\t */\n\tfallback?: React.ReactNode;\n};\n\ntype CreateDefaultSerializerArgs<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tLinkResolverFunction extends prismic.LinkResolverFunction<any> = prismic.LinkResolverFunction,\n> = {\n\tlinkResolver: LinkResolverFunction | undefined;\n\tinternalLinkComponent?: React.ComponentType<LinkProps>;\n\texternalLinkComponent?: React.ComponentType<LinkProps>;\n};\n\nconst createDefaultSerializer = <\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tLinkResolverFunction extends prismic.LinkResolverFunction<any>,\n>(\n\targs: CreateDefaultSerializerArgs<LinkResolverFunction>,\n): JSXFunctionSerializer =>\n\tprismicR.wrapMapSerializer({\n\t\theading1: ({ children, key }) => <h1 key={key}>{children}</h1>,\n\t\theading2: ({ children, key }) => <h2 key={key}>{children}</h2>,\n\t\theading3: ({ children, key }) => <h3 key={key}>{children}</h3>,\n\t\theading4: ({ children, key }) => <h4 key={key}>{children}</h4>,\n\t\theading5: ({ children, key }) => <h5 key={key}>{children}</h5>,\n\t\theading6: ({ children, key }) => <h6 key={key}>{children}</h6>,\n\t\tparagraph: ({ children, key }) => <p key={key}>{children}</p>,\n\t\tpreformatted: ({ node, key }) => <pre key={key}>{node.text}</pre>,\n\t\tstrong: ({ children, key }) => <strong key={key}>{children}</strong>,\n\t\tem: ({ children, key }) => <em key={key}>{children}</em>,\n\t\tlistItem: ({ children, key }) => <li key={key}>{children}</li>,\n\t\toListItem: ({ children, key }) => <li key={key}>{children}</li>,\n\t\tlist: ({ children, key }) => <ul key={key}>{children}</ul>,\n\t\toList: ({ children, key }) => <ol key={key}>{children}</ol>,\n\t\timage: ({ node, key }) => {\n\t\t\tconst img = (\n\t\t\t\t<img\n\t\t\t\t\tsrc={node.url}\n\t\t\t\t\talt={node.alt ?? undefined}\n\t\t\t\t\tdata-copyright={node.copyright ? node.copyright : undefined}\n\t\t\t\t/>\n\t\t\t);\n\n\t\t\treturn (\n\t\t\t\t<p key={key} className=\"block-img\">\n\t\t\t\t\t{node.linkTo ? (\n\t\t\t\t\t\t<PrismicLink\n\t\t\t\t\t\t\tlinkResolver={args.linkResolver}\n\t\t\t\t\t\t\tinternalComponent={args.internalLinkComponent}\n\t\t\t\t\t\t\texternalComponent={args.externalLinkComponent}\n\t\t\t\t\t\t\tfield={node.linkTo}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{img}\n\t\t\t\t\t\t</PrismicLink>\n\t\t\t\t\t) : (\n\t\t\t\t\t\timg\n\t\t\t\t\t)}\n\t\t\t\t</p>\n\t\t\t);\n\t\t},\n\t\tembed: ({ node, key }) => (\n\t\t\t<div\n\t\t\t\tkey={key}\n\t\t\t\tdata-oembed={node.oembed.embed_url}\n\t\t\t\tdata-oembed-type={node.oembed.type}\n\t\t\t\tdata-oembed-provider={node.oembed.provider_name}\n\t\t\t\tdangerouslySetInnerHTML={{ __html: node.oembed.html ?? \"\" }}\n\t\t\t/>\n\t\t),\n\t\thyperlink: ({ node, children, key }) => (\n\t\t\t<PrismicLink\n\t\t\t\tkey={key}\n\t\t\t\tfield={node.data}\n\t\t\t\tlinkResolver={args.linkResolver}\n\t\t\t\tinternalComponent={args.internalLinkComponent}\n\t\t\t\texternalComponent={args.externalLinkComponent}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</PrismicLink>\n\t\t),\n\t\tlabel: ({ node, children, key }) => (\n\t\t\t<span key={key} className={node.data.label}>\n\t\t\t\t{children}\n\t\t\t</span>\n\t\t),\n\t\tspan: ({ text, key }) => {\n\t\t\tconst result: React.ReactNode[] = [];\n\n\t\t\tlet i = 0;\n\t\t\tfor (const line of text.split(\"\\n\")) {\n\t\t\t\tif (i > 0) {\n\t\t\t\t\tresult.push(<br key={`${i}__break`} />);\n\t\t\t\t}\n\n\t\t\t\tresult.push(<React.Fragment key={`${i}__line`}>{line}</React.Fragment>);\n\n\t\t\t\ti++;\n\t\t\t}\n\n\t\t\treturn <React.Fragment key={key}>{result}</React.Fragment>;\n\t\t},\n\t});\n\n/**\n * React component that renders content from a Prismic Rich Text field. By\n * default, HTML elements are rendered for each piece of content. A `heading1`\n * block will render an `<h1>` HTML element, for example. Links will use\n * `<PrismicLink>` by default which can be customized using the\n * `internalLinkComponent` and `externalLinkComponent` props.\n *\n * To customize the components that are rendered, provide a map or function\n * serializer to the `components` prop.\n *\n * @remarks\n * This component returns a React fragment with no wrapping element around the\n * content. If you need a wrapper, add a component around `<PrismicRichText>`.\n * @example Rendering a Rich Text field using the default HTMl elements.\n *\n * ```jsx\n * <PrismicRichText field={document.data.content} />;\n * ```\n *\n * @example Rendering a Rich Text field using a custom set of React components.\n *\n * ```jsx\n * <PrismicRichText\n * \tfield={document.data.content}\n * \tcomponents={{\n * \t\theading1: ({ children }) => <Heading>{children}</Heading>,\n * \t}}\n * />;\n * ```\n *\n * @param props - Props for the component.\n *\n * @returns The Rich Text field's content as React components.\n *\n * @see Learn about Rich Text fields {@link https://prismic.io/docs/core-concepts/rich-text-title}\n * @see Learn about Rich Text serializers {@link https://prismic.io/docs/core-concepts/html-serializer}\n */\nexport function PrismicRichText<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tLinkResolverFunction extends prismic.LinkResolverFunction<any>,\n>({\n\tlinkResolver,\n\tfield,\n\tfallback,\n\tcomponents,\n\texternalLinkComponent,\n\tinternalLinkComponent,\n\t...restProps\n}: PrismicRichTextProps<LinkResolverFunction>): JSX.Element | null {\n\treturn React.useMemo(() => {\n\t\tif (\n\t\t\ttypeof process !== \"undefined\" &&\n\t\t\tprocess.env.NODE_ENV === \"development\"\n\t\t) {\n\t\t\tif (\"className\" in restProps) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`[PrismicRichText] className cannot be passed to <PrismicRichText> since it renders an array without a wrapping component. For more details, see ${devMsg(\n\t\t\t\t\t\t\"classname-is-not-a-valid-prop\",\n\t\t\t\t\t)}.`,\n\t\t\t\t\tfield,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tif (prismic.isFilled.richText(field)) {\n\t\t\tconst serializer = prismicR.composeSerializers(\n\t\t\t\ttypeof components === \"object\"\n\t\t\t\t\t? prismicR.wrapMapSerializer(components)\n\t\t\t\t\t: components,\n\t\t\t\tcreateDefaultSerializer({\n\t\t\t\t\tlinkResolver,\n\t\t\t\t\tinternalLinkComponent,\n\t\t\t\t\texternalLinkComponent,\n\t\t\t\t}),\n\t\t\t);\n\n\t\t\t// The serializer is wrapped in a higher-order function\n\t\t\t// that automatically applies a key to React Elements\n\t\t\t// if one is not already given.\n\t\t\tconst serialized = prismicR.serialize<JSX.Element>(\n\t\t\t\tfield,\n\t\t\t\t(type, node, text, children, key) => {\n\t\t\t\t\tconst result = serializer(type, node, text, children, key);\n\n\t\t\t\t\tif (React.isValidElement(result) && result.key == null) {\n\t\t\t\t\t\treturn React.cloneElement(result, { key });\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn result;\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t);\n\n\t\t\treturn <>{serialized}</>;\n\t\t} else {\n\t\t\treturn fallback != null ? <>{fallback}</> : null;\n\t\t}\n\t}, [\n\t\tfield,\n\t\tinternalLinkComponent,\n\t\texternalLinkComponent,\n\t\tcomponents,\n\t\tlinkResolver,\n\t\tfallback,\n\t]);\n}\n"],"names":["prismicR","jsx","PrismicLink","React","devMsg","prismic.isFilled.richText","Fragment"],"mappings":"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"}
@@ -41,7 +41,7 @@ const createDefaultSerializer = (args) => prismicR.wrapMapSerializer({
41
41
  });
42
42
  function PrismicRichText({ linkResolver, field, fallback, components, externalLinkComponent, internalLinkComponent, ...restProps }) {
43
43
  return React.useMemo(() => {
44
- if (process.env.NODE_ENV === "development") {
44
+ if (typeof process !== "undefined" && process.env.NODE_ENV === "development") {
45
45
  if ("className" in restProps) {
46
46
  console.warn(`[PrismicRichText] className cannot be passed to <PrismicRichText> since it renders an array without a wrapping component. For more details, see ${devMsg("classname-is-not-a-valid-prop")}.`, field);
47
47
  }