@prismicio/react 3.2.2-pr.236.d65a0c3 → 3.2.2-pr.242.afe79ea

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 (69) hide show
  1. package/dist/index.d.ts +9 -15
  2. package/dist/index.js +9 -19
  3. package/dist/package.js +6 -0
  4. package/dist/package.js.map +1 -0
  5. package/dist/src/PrismicImage.d.ts +76 -0
  6. package/dist/src/PrismicImage.d.ts.map +1 -0
  7. package/dist/src/PrismicImage.js +57 -0
  8. package/dist/src/PrismicImage.js.map +1 -0
  9. package/dist/src/PrismicLink.d.ts +84 -0
  10. package/dist/src/PrismicLink.d.ts.map +1 -0
  11. package/dist/src/PrismicLink.js +66 -0
  12. package/dist/src/PrismicLink.js.map +1 -0
  13. package/dist/src/PrismicRichText.d.ts +96 -0
  14. package/dist/src/PrismicRichText.d.ts.map +1 -0
  15. package/dist/src/PrismicRichText.js +133 -0
  16. package/dist/src/PrismicRichText.js.map +1 -0
  17. package/dist/src/PrismicTable.d.ts +69 -0
  18. package/dist/src/PrismicTable.d.ts.map +1 -0
  19. package/dist/src/PrismicTable.js +75 -0
  20. package/dist/src/PrismicTable.js.map +1 -0
  21. package/dist/src/PrismicText.d.ts +31 -0
  22. package/dist/src/PrismicText.d.ts.map +1 -0
  23. package/dist/src/PrismicText.js +33 -0
  24. package/dist/src/PrismicText.js.map +1 -0
  25. package/dist/src/PrismicToolbar.d.ts +26 -0
  26. package/dist/src/PrismicToolbar.d.ts.map +1 -0
  27. package/dist/src/PrismicToolbar.js +37 -0
  28. package/dist/src/PrismicToolbar.js.map +1 -0
  29. package/dist/{SliceZone.d.ts → src/SliceZone.d.ts} +52 -47
  30. package/dist/src/SliceZone.d.ts.map +1 -0
  31. package/dist/src/SliceZone.js +59 -0
  32. package/dist/src/SliceZone.js.map +1 -0
  33. package/dist/src/lib/devMsg.js +25 -0
  34. package/dist/src/lib/devMsg.js.map +1 -0
  35. package/package.json +17 -35
  36. package/src/PrismicImage.tsx +3 -3
  37. package/src/PrismicLink.tsx +5 -5
  38. package/src/PrismicRichText.tsx +9 -9
  39. package/src/PrismicTable.tsx +9 -9
  40. package/src/PrismicText.tsx +2 -2
  41. package/src/PrismicToolbar.tsx +1 -1
  42. package/src/SliceZone.tsx +2 -2
  43. package/src/lib/devMsg.ts +1 -1
  44. package/dist/PrismicImage.d.ts +0 -74
  45. package/dist/PrismicImage.js +0 -50
  46. package/dist/PrismicImage.js.map +0 -1
  47. package/dist/PrismicLink.d.ts +0 -88
  48. package/dist/PrismicLink.js +0 -47
  49. package/dist/PrismicLink.js.map +0 -1
  50. package/dist/PrismicRichText.d.ts +0 -90
  51. package/dist/PrismicRichText.js +0 -79
  52. package/dist/PrismicRichText.js.map +0 -1
  53. package/dist/PrismicTable.d.ts +0 -65
  54. package/dist/PrismicTable.js +0 -28
  55. package/dist/PrismicTable.js.map +0 -1
  56. package/dist/PrismicText.d.ts +0 -26
  57. package/dist/PrismicText.js +0 -26
  58. package/dist/PrismicText.js.map +0 -1
  59. package/dist/PrismicToolbar.d.ts +0 -21
  60. package/dist/PrismicToolbar.js +0 -24
  61. package/dist/PrismicToolbar.js.map +0 -1
  62. package/dist/SliceZone.js +0 -32
  63. package/dist/SliceZone.js.map +0 -1
  64. package/dist/index.js.map +0 -1
  65. package/dist/lib/devMsg.d.ts +0 -16
  66. package/dist/lib/devMsg.js +0 -8
  67. package/dist/lib/devMsg.js.map +0 -1
  68. package/dist/package.json.js +0 -5
  69. package/dist/package.json.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismicio/react",
3
- "version": "3.2.2-pr.236.d65a0c3",
3
+ "version": "3.2.2-pr.242.afe79ea",
4
4
  "description": "React components and hooks to fetch and present Prismic content",
5
5
  "keywords": [
6
6
  "typescript",
@@ -16,10 +16,7 @@
16
16
  "sideEffects": false,
17
17
  "type": "module",
18
18
  "exports": {
19
- ".": {
20
- "types": "./dist/index.d.ts",
21
- "default": "./dist/index.js"
22
- },
19
+ ".": "./dist/index.js",
23
20
  "./package.json": "./package.json"
24
21
  },
25
22
  "typesVersions": {
@@ -38,61 +35,46 @@
38
35
  "e2e-projects/*"
39
36
  ],
40
37
  "scripts": {
41
- "build": "vite build",
42
- "dev": "vite build --watch",
38
+ "build": "tsdown",
39
+ "dev": "tsdown --watch",
43
40
  "e2e": "playwright test",
44
41
  "e2e:ui": "npm run e2e -- --ui",
45
42
  "format": "prettier --write .",
46
- "lint": "eslint",
43
+ "lint": "oxlint --deny-warnings",
47
44
  "prepare": "npm run build",
48
- "release": "npm run build && npm run test && standard-version && git push --follow-tags && npm run build && npm publish",
49
- "release:alpha": "npm run build && npm run test && standard-version --prerelease alpha && git push --follow-tags && npm run build && npm publish --tag alpha",
50
- "release:alpha:dry": "standard-version --prerelease alpha --dry-run",
51
- "release:dry": "standard-version --dry-run",
52
- "size": "size-limit",
53
- "test": "npm run lint && npm run types && npm run build && npm run e2e && npm run size && npm run e2e",
45
+ "test": "npm run lint && npm run types && npm run build && npm run e2e",
54
46
  "types": "tsc --noEmit"
55
47
  },
56
48
  "dependencies": {
57
49
  "esm-env": "^1.2.2"
58
50
  },
59
51
  "devDependencies": {
60
- "@eslint/js": "^9.19.0",
61
52
  "@playwright/test": "^1.50.0",
62
53
  "@prismicio/client": "^7.17.0",
63
- "@rollup/plugin-typescript": "^12.1.2",
64
- "@size-limit/preset-small-lib": "^11.1.6",
54
+ "@trivago/prettier-plugin-sort-imports": "^6.0.0",
65
55
  "@types/react": "^19.2.7",
66
56
  "@types/react-dom": "^19.2.3",
67
- "@vitejs/plugin-react": "^4.7.0",
68
57
  "dotenv": "^16.4.7",
69
- "eslint": "^9.19.0",
70
- "eslint-config-prettier": "^10.0.1",
71
- "eslint-plugin-prettier": "^5.2.3",
72
- "eslint-plugin-react": "^7.37.4",
73
- "eslint-plugin-react-hooks": "^5.1.0",
74
- "eslint-plugin-tsdoc": "^0.4.0",
58
+ "oxlint": "^1.31.0",
75
59
  "playwright": "^1.50.0",
76
- "prettier": "^3.4.2",
77
- "prettier-plugin-jsdoc": "^1.3.2",
60
+ "prettier": "^3.7.4",
61
+ "prettier-plugin-jsdoc": "^1.7.0",
78
62
  "react": "^19.2.1",
79
63
  "react-dom": "^19.2.1",
80
- "rollup-plugin-preserve-directives": "^0.4.0",
81
- "rollup-preserve-directives": "^1.1.3",
82
- "size-limit": "^11.1.6",
83
- "standard-version": "^9.5.0",
84
- "typescript": "^5.7.3",
85
- "typescript-eslint": "^8.22.0",
86
- "vite": "^6.0.11"
64
+ "tsdown": "^0.16.8",
65
+ "typescript": "^5.9.3"
87
66
  },
88
67
  "peerDependencies": {
89
68
  "@prismicio/client": "^7",
90
69
  "react": "^18 || ^19"
91
70
  },
92
71
  "engines": {
93
- "node": ">=18"
72
+ "node": ">=20"
94
73
  },
95
74
  "publishConfig": {
96
75
  "access": "public"
97
- }
76
+ },
77
+ "main": "./dist/index.js",
78
+ "module": "./dist/index.js",
79
+ "types": "./dist/index.d.ts"
98
80
  }
@@ -1,9 +1,9 @@
1
1
  import {
2
- ForwardedRef,
2
+ type ForwardedRef,
3
3
  forwardRef,
4
4
  type ComponentProps,
5
- FC,
6
- ReactNode,
5
+ type FC,
6
+ type ReactNode,
7
7
  } from "react";
8
8
  import {
9
9
  type ImageFieldImage,
@@ -1,9 +1,9 @@
1
1
  import {
2
- ComponentProps,
3
- ComponentType,
4
- ForwardedRef,
5
- HTMLAttributeAnchorTarget,
6
- ReactNode,
2
+ type ComponentProps,
3
+ type ComponentType,
4
+ type ForwardedRef,
5
+ type HTMLAttributeAnchorTarget,
6
+ type ReactNode,
7
7
  forwardRef,
8
8
  } from "react";
9
9
  import {
@@ -1,29 +1,29 @@
1
1
  import {
2
2
  cloneElement,
3
- ComponentType,
4
- FC,
3
+ type ComponentType,
4
+ type FC,
5
5
  Fragment,
6
6
  isValidElement,
7
- ReactNode,
7
+ type ReactNode,
8
8
  } from "react";
9
9
  import {
10
10
  isFilled,
11
- LinkResolverFunction,
12
- RichTextField,
13
- RTAnyNode,
11
+ type LinkResolverFunction,
12
+ type RichTextField,
13
+ type RTAnyNode,
14
14
  } from "@prismicio/client";
15
15
  import {
16
16
  composeSerializers,
17
17
  serialize,
18
18
  wrapMapSerializer,
19
- RichTextFunctionSerializer,
20
- RichTextMapSerializer,
19
+ type RichTextFunctionSerializer,
20
+ type RichTextMapSerializer,
21
21
  } from "@prismicio/client/richtext";
22
22
  import { DEV } from "esm-env";
23
23
 
24
24
  import { devMsg } from "./lib/devMsg.js";
25
25
 
26
- import { LinkProps, PrismicLink } from "./PrismicLink.js";
26
+ import { type LinkProps, PrismicLink } from "./PrismicLink.js";
27
27
 
28
28
  /**
29
29
  * A function mapping rich text block types to React Components. It is used to
@@ -1,16 +1,16 @@
1
- import { ComponentType, FC, ReactNode } from "react";
1
+ import type { ComponentType, FC, ReactNode } from "react";
2
2
  import {
3
3
  isFilled,
4
- TableField,
5
- TableFieldHead,
6
- TableFieldHeadRow,
7
- TableFieldBody,
8
- TableFieldBodyRow,
9
- TableFieldHeaderCell,
10
- TableFieldDataCell,
4
+ type TableField,
5
+ type TableFieldHead,
6
+ type TableFieldHeadRow,
7
+ type TableFieldBody,
8
+ type TableFieldBodyRow,
9
+ type TableFieldHeaderCell,
10
+ type TableFieldDataCell,
11
11
  } from "@prismicio/client";
12
12
 
13
- import { JSXMapSerializer, PrismicRichText } from "./PrismicRichText.js";
13
+ import { type JSXMapSerializer, PrismicRichText } from "./PrismicRichText.js";
14
14
 
15
15
  type TableComponents = {
16
16
  table?: ComponentType<{ table: TableField<"filled">; children: ReactNode }>;
@@ -1,5 +1,5 @@
1
- import { FC } from "react";
2
- import { asText, isFilled, RichTextField } from "@prismicio/client";
1
+ import type { FC } from "react";
2
+ import { asText, isFilled, type RichTextField } from "@prismicio/client";
3
3
  import { DEV } from "esm-env";
4
4
 
5
5
  import { devMsg } from "./lib/devMsg.js";
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
 
3
- import { FC, useEffect } from "react";
3
+ import { type FC, useEffect } from "react";
4
4
  import { getToolbarSrc } from "@prismicio/client";
5
5
 
6
6
  /** Props for `<PrismicToolbar>`. */
package/src/SliceZone.tsx CHANGED
@@ -1,4 +1,4 @@
1
- import type { ComponentType, FC } from "react";
1
+ import type { ComponentType, FC, ReactNode } from "react";
2
2
  import type { Slice } from "@prismicio/client";
3
3
  import { DEV } from "esm-env";
4
4
 
@@ -182,7 +182,7 @@ export const TODOSliceComponent = <TSlice extends SliceLike>({
182
182
  slice,
183
183
  }: {
184
184
  slice: TSlice;
185
- }) => {
185
+ }): ReactNode => {
186
186
  if (!DEV) {
187
187
  return null;
188
188
  }
package/src/lib/devMsg.ts CHANGED
@@ -15,6 +15,6 @@ import { version } from "../../package.json";
15
15
  *
16
16
  * @returns The `prismic.dev/msg` URL for the given slug.
17
17
  */
18
- export function devMsg(slug: string) {
18
+ export function devMsg(slug: string): string {
19
19
  return `https://prismic.dev/msg/react/v${version}/${slug}`;
20
20
  }
@@ -1,74 +0,0 @@
1
- import { type ComponentProps, FC, ReactNode } from "react";
2
- import { type ImageFieldImage, asImagePixelDensitySrcSet, asImageWidthSrcSet } from "@prismicio/client";
3
- type ImgixURLParams = Omit<NonNullable<Parameters<typeof asImageWidthSrcSet>[1]>, "widths"> & Omit<NonNullable<Parameters<typeof asImagePixelDensitySrcSet>[1]>, "pixelDensities">;
4
- /** Props for `<PrismicImage>`. */
5
- export type PrismicImageProps = Omit<ComponentProps<"img">, "src" | "srcset" | "alt"> & {
6
- /** The Prismic image field or thumbnail to render. */
7
- field: ImageFieldImage | null | undefined;
8
- /**
9
- * An object of Imgix URL API parameters to transform the image.
10
- *
11
- * See: https://docs.imgix.com/apis/rendering
12
- */
13
- imgixParams?: {
14
- [P in keyof ImgixURLParams]: ImgixURLParams[P] | null;
15
- };
16
- /**
17
- * Declare an image as decorative by providing `alt=""`.
18
- *
19
- * See:
20
- * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
21
- */
22
- alt?: "";
23
- /**
24
- * Declare an image as decorative only if the image field does not have
25
- * alternative text by providing `fallbackAlt=""`.
26
- *
27
- * See:
28
- * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
29
- */
30
- fallbackAlt?: "";
31
- /**
32
- * The value to be rendered when the field is empty. If a fallback is not
33
- * given, `null` will be rendered.
34
- */
35
- fallback?: ReactNode;
36
- } & ({
37
- /**
38
- * Widths (in pixels) used to build a `srcset` value for the image
39
- * field.
40
- *
41
- * If omitted or set to `"defaults"`, the following widths will be used:
42
- * 640, 750, 828, 1080, 1200, 1920, 2048, 3840.
43
- *
44
- * If the image field contains responsive views, each responsive view
45
- * can be used as a width in the resulting `srcset` by passing
46
- * `"thumbnails"` as the `widths` prop.
47
- */
48
- widths?: NonNullable<Parameters<typeof asImageWidthSrcSet>[1]>["widths"] | "defaults";
49
- /** Not used when the `widths` prop is used. */
50
- pixelDensities?: never;
51
- } | {
52
- /** Not used when the `widths` prop is used. */
53
- widths?: never;
54
- /**
55
- * Pixel densities used to build a `srcset` value for the image field.
56
- *
57
- * If a `pixelDensities` prop is passed `"defaults"`, the following
58
- * pixel densities will be used: 1, 2, 3.
59
- */
60
- pixelDensities: NonNullable<Parameters<typeof asImagePixelDensitySrcSet>[1]>["pixelDensities"] | "defaults";
61
- });
62
- /**
63
- * Renders an optimized image from a Prismic image field.
64
- *
65
- * @example
66
- *
67
- * ```tsx
68
- * <PrismicImage field={slice.primary.photo} />;
69
- * ```
70
- *
71
- * @see Learn how to optimize images with imgix, use responsive images, and use framework-specific image components: {@link https://prismic.io/docs/fields/image}
72
- */
73
- export declare const PrismicImage: FC<PrismicImageProps>;
74
- export {};
@@ -1,50 +0,0 @@
1
- import { jsx, Fragment } from "react/jsx-runtime";
2
- import { forwardRef } from "react";
3
- import { isFilled, asImageWidthSrcSet, asImagePixelDensitySrcSet } from "@prismicio/client";
4
- import { DEV } from "esm-env";
5
- import { devMsg } from "./lib/devMsg.js";
6
- const PrismicImage = forwardRef(function PrismicImage2(props, ref) {
7
- const { field, alt, fallbackAlt, imgixParams = {}, widths, pixelDensities, fallback, ...restProps } = props;
8
- if (DEV) {
9
- if (typeof alt === "string" && alt !== "") {
10
- console.warn(`[PrismicImage] The "alt" prop can only be used to declare an image as decorative by passing an empty string (alt="") but was provided a non-empty string. You can resolve this warning by removing the "alt" prop or changing it to alt="". For more details, see ${devMsg("alt-must-be-an-empty-string")}`);
11
- }
12
- if (typeof fallbackAlt === "string" && fallbackAlt !== "") {
13
- console.warn(`[PrismicImage] The "fallbackAlt" prop can only be used to declare an image as decorative by passing an empty string (fallbackAlt="") but was provided a non-empty string. You can resolve this warning by removing the "fallbackAlt" prop or changing it to fallbackAlt="". For more details, see ${devMsg("alt-must-be-an-empty-string")}`);
14
- }
15
- if (widths && pixelDensities) {
16
- console.warn(`[PrismicImage] Only one of "widths" or "pixelDensities" props can be provided. You can resolve this warning by removing either the "widths" or "pixelDensities" prop. "widths" will be used in this case.`);
17
- }
18
- }
19
- if (!isFilled.imageThumbnail(field)) {
20
- return jsx(Fragment, { children: fallback });
21
- }
22
- const resolvedImgixParams = imgixParams;
23
- for (const x in imgixParams) {
24
- if (resolvedImgixParams[x] === null) {
25
- resolvedImgixParams[x] = void 0;
26
- }
27
- }
28
- let src;
29
- let srcSet;
30
- if (widths || !pixelDensities) {
31
- const res = asImageWidthSrcSet(field, {
32
- ...resolvedImgixParams,
33
- widths: widths === "defaults" ? void 0 : widths
34
- });
35
- src = res.src;
36
- srcSet = res.srcset;
37
- } else if (pixelDensities) {
38
- const res = asImagePixelDensitySrcSet(field, {
39
- ...resolvedImgixParams,
40
- pixelDensities: pixelDensities === "defaults" ? void 0 : pixelDensities
41
- });
42
- src = res.src;
43
- srcSet = res.srcset;
44
- }
45
- return jsx("img", { ref, src, srcSet, alt: alt ?? (field.alt || fallbackAlt), ...restProps });
46
- });
47
- export {
48
- PrismicImage
49
- };
50
- //# sourceMappingURL=PrismicImage.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PrismicImage.js","sources":["../src/PrismicImage.tsx"],"sourcesContent":["import {\n\tForwardedRef,\n\tforwardRef,\n\ttype ComponentProps,\n\tFC,\n\tReactNode,\n} from \"react\";\nimport {\n\ttype ImageFieldImage,\n\tasImagePixelDensitySrcSet,\n\tasImageWidthSrcSet,\n\tisFilled,\n} from \"@prismicio/client\";\nimport { DEV } from \"esm-env\";\n\nimport { devMsg } from \"./lib/devMsg.js\";\n\ntype ImgixURLParams = Omit<\n\tNonNullable<Parameters<typeof asImageWidthSrcSet>[1]>,\n\t\"widths\"\n> &\n\tOmit<\n\t\tNonNullable<Parameters<typeof asImagePixelDensitySrcSet>[1]>,\n\t\t\"pixelDensities\"\n\t>;\n\n/** Props for `<PrismicImage>`. */\nexport type PrismicImageProps = Omit<\n\tComponentProps<\"img\">,\n\t\"src\" | \"srcset\" | \"alt\"\n> & {\n\t/** The Prismic image field or thumbnail to render. */\n\tfield: ImageFieldImage | null | undefined;\n\n\t/**\n\t * An object of Imgix URL API parameters to transform the image.\n\t *\n\t * See: https://docs.imgix.com/apis/rendering\n\t */\n\timgixParams?: { [P in keyof ImgixURLParams]: ImgixURLParams[P] | null };\n\n\t/**\n\t * Declare an image as decorative by providing `alt=\"\"`.\n\t *\n\t * See:\n\t * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images\n\t */\n\talt?: \"\";\n\n\t/**\n\t * Declare an image as decorative only if the image field does not have\n\t * alternative text by providing `fallbackAlt=\"\"`.\n\t *\n\t * See:\n\t * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images\n\t */\n\tfallbackAlt?: \"\";\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?: ReactNode;\n} & (\n\t\t| {\n\t\t\t\t/**\n\t\t\t\t * Widths (in pixels) used to build a `srcset` value for the image\n\t\t\t\t * field.\n\t\t\t\t *\n\t\t\t\t * If omitted or set to `\"defaults\"`, the following widths will be used:\n\t\t\t\t * 640, 750, 828, 1080, 1200, 1920, 2048, 3840.\n\t\t\t\t *\n\t\t\t\t * If the image field contains responsive views, each responsive view\n\t\t\t\t * can be used as a width in the resulting `srcset` by passing\n\t\t\t\t * `\"thumbnails\"` as the `widths` prop.\n\t\t\t\t */\n\t\t\t\twidths?:\n\t\t\t\t\t| NonNullable<Parameters<typeof asImageWidthSrcSet>[1]>[\"widths\"]\n\t\t\t\t\t| \"defaults\";\n\t\t\t\t/** Not used when the `widths` prop is used. */\n\t\t\t\tpixelDensities?: never;\n\t\t }\n\t\t| {\n\t\t\t\t/** Not used when the `widths` prop is used. */\n\t\t\t\twidths?: never;\n\t\t\t\t/**\n\t\t\t\t * Pixel densities used to build a `srcset` value for the image field.\n\t\t\t\t *\n\t\t\t\t * If a `pixelDensities` prop is passed `\"defaults\"`, the following\n\t\t\t\t * pixel densities will be used: 1, 2, 3.\n\t\t\t\t */\n\t\t\t\tpixelDensities:\n\t\t\t\t\t| NonNullable<\n\t\t\t\t\t\t\tParameters<typeof asImagePixelDensitySrcSet>[1]\n\t\t\t\t\t >[\"pixelDensities\"]\n\t\t\t\t\t| \"defaults\";\n\t\t }\n\t);\n\n/**\n * Renders an optimized image from a Prismic image field.\n *\n * @example\n *\n * ```tsx\n * <PrismicImage field={slice.primary.photo} />;\n * ```\n *\n * @see Learn how to optimize images with imgix, use responsive images, and use framework-specific image components: {@link https://prismic.io/docs/fields/image}\n */\nexport const PrismicImage: FC<PrismicImageProps> = forwardRef(\n\tfunction PrismicImage(\n\t\tprops: PrismicImageProps,\n\t\tref: ForwardedRef<HTMLImageElement>,\n\t) {\n\t\tconst {\n\t\t\tfield,\n\t\t\talt,\n\t\t\tfallbackAlt,\n\t\t\timgixParams = {},\n\t\t\twidths,\n\t\t\tpixelDensities,\n\t\t\tfallback,\n\t\t\t...restProps\n\t\t} = props;\n\n\t\tif (DEV) {\n\t\t\tif (typeof alt === \"string\" && alt !== \"\") {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`[PrismicImage] The \"alt\" prop can only be used to declare an image as decorative by passing an empty string (alt=\"\") but was provided a non-empty string. You can resolve this warning by removing the \"alt\" prop or changing it to alt=\"\". For more details, see ${devMsg(\n\t\t\t\t\t\t\"alt-must-be-an-empty-string\",\n\t\t\t\t\t)}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (typeof fallbackAlt === \"string\" && fallbackAlt !== \"\") {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`[PrismicImage] The \"fallbackAlt\" prop can only be used to declare an image as decorative by passing an empty string (fallbackAlt=\"\") but was provided a non-empty string. You can resolve this warning by removing the \"fallbackAlt\" prop or changing it to fallbackAlt=\"\". For more details, see ${devMsg(\n\t\t\t\t\t\t\"alt-must-be-an-empty-string\",\n\t\t\t\t\t)}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (widths && pixelDensities) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`[PrismicImage] Only one of \"widths\" or \"pixelDensities\" props can be provided. You can resolve this warning by removing either the \"widths\" or \"pixelDensities\" prop. \"widths\" will be used in this case.`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tif (!isFilled.imageThumbnail(field)) {\n\t\t\treturn <>{fallback}</>;\n\t\t}\n\n\t\tconst resolvedImgixParams = imgixParams;\n\t\tfor (const x in imgixParams) {\n\t\t\tif (resolvedImgixParams[x as keyof typeof resolvedImgixParams] === null) {\n\t\t\t\tresolvedImgixParams[x as keyof typeof resolvedImgixParams] = undefined;\n\t\t\t}\n\t\t}\n\n\t\tlet src: string | undefined;\n\t\tlet srcSet: string | undefined;\n\n\t\tif (widths || !pixelDensities) {\n\t\t\tconst res = asImageWidthSrcSet(field, {\n\t\t\t\t...resolvedImgixParams,\n\t\t\t\twidths: widths === \"defaults\" ? undefined : widths,\n\t\t\t} as ImgixURLParams);\n\n\t\t\tsrc = res.src;\n\t\t\tsrcSet = res.srcset;\n\t\t} else if (pixelDensities) {\n\t\t\tconst res = asImagePixelDensitySrcSet(field, {\n\t\t\t\t...resolvedImgixParams,\n\t\t\t\tpixelDensities:\n\t\t\t\t\tpixelDensities === \"defaults\" ? undefined : pixelDensities,\n\t\t\t} as ImgixURLParams);\n\n\t\t\tsrc = res.src;\n\t\t\tsrcSet = res.srcset;\n\t\t}\n\n\t\treturn (\n\t\t\t<img\n\t\t\t\tref={ref}\n\t\t\t\tsrc={src}\n\t\t\t\tsrcSet={srcSet}\n\t\t\t\talt={alt ?? (field.alt || fallbackAlt)}\n\t\t\t\t{...restProps}\n\t\t\t/>\n\t\t);\n\t},\n);\n"],"names":["PrismicImage","_jsx","_Fragment"],"mappings":";;;;;AA8GO,MAAM,eAAsC,WAClD,SAASA,cACR,OACA,KAAmC;AAEnC,QAAM,EACL,OACA,KACA,aACA,cAAc,CAAA,GACd,QACA,gBACA,UACA,GAAG,UACA,IAAA;AAEJ,MAAI,KAAK;AACR,QAAI,OAAO,QAAQ,YAAY,QAAQ,IAAI;AAC1C,cAAQ,KACP,qQAAqQ,OACpQ,6BAA6B,CAC7B,EAAE;AAAA,IAAA;AAIL,QAAI,OAAO,gBAAgB,YAAY,gBAAgB,IAAI;AAC1D,cAAQ,KACP,qSAAqS,OACpS,6BAA6B,CAC7B,EAAE;AAAA,IAAA;AAIL,QAAI,UAAU,gBAAgB;AAC7B,cAAQ,KACP,2MAA2M;AAAA,IAAA;AAAA,EAE7M;AAGD,MAAI,CAAC,SAAS,eAAe,KAAK,GAAG;AACpC,WAAOC,IAAAC,UAAA,EAAA,UAAG,UAAQ;AAAA,EAAA;AAGnB,QAAM,sBAAsB;AAC5B,aAAW,KAAK,aAAa;AACxB,QAAA,oBAAoB,CAAqC,MAAM,MAAM;AACxE,0BAAoB,CAAqC,IAAI;AAAA,IAAA;AAAA,EAC9D;AAGG,MAAA;AACA,MAAA;AAEA,MAAA,UAAU,CAAC,gBAAgB;AACxB,UAAA,MAAM,mBAAmB,OAAO;AAAA,MACrC,GAAG;AAAA,MACH,QAAQ,WAAW,aAAa,SAAY;AAAA,IAAA,CAC1B;AAEnB,UAAM,IAAI;AACV,aAAS,IAAI;AAAA,aACH,gBAAgB;AACpB,UAAA,MAAM,0BAA0B,OAAO;AAAA,MAC5C,GAAG;AAAA,MACH,gBACC,mBAAmB,aAAa,SAAY;AAAA,IAAA,CAC3B;AAEnB,UAAM,IAAI;AACV,aAAS,IAAI;AAAA,EAAA;AAGd,SACCD,IAAA,OAAA,EACC,KACA,KACA,QACA,KAAK,QAAQ,MAAM,OAAO,cAAY,GAClC,WAAS;AAGhB,CAAC;"}
@@ -1,88 +0,0 @@
1
- import { ComponentProps, ComponentType, ForwardedRef, HTMLAttributeAnchorTarget, ReactNode } from "react";
2
- import { type LinkField, type LinkResolverFunction, type PrismicDocument, type AsLinkAttrsConfig } from "@prismicio/client";
3
- /** The default component rendered for internal and external links. */
4
- declare const defaultComponent = "a";
5
- /** Props provided to a component when rendered with `<PrismicLink>`. */
6
- export interface LinkProps {
7
- /** The URL to link. */
8
- href: string;
9
- /**
10
- * The `target` attribute for anchor elements. If the Prismic field is
11
- * configured to open in a new window, this prop defaults to `_blank`.
12
- */
13
- target?: HTMLAttributeAnchorTarget;
14
- /**
15
- * The `rel` attribute for anchor elements. If the `target` prop is set to
16
- * `"_blank"`, this prop defaults to `"noopener noreferrer"`.
17
- */
18
- rel?: string;
19
- /** Children for the component. */
20
- children?: ReactNode;
21
- }
22
- export type PrismicLinkProps<InternalComponentProps = ComponentProps<typeof defaultComponent>, ExternalComponentProps = ComponentProps<typeof defaultComponent>> = Omit<InternalComponentProps & ExternalComponentProps, "rel" | "href" | "children"> & {
23
- /**
24
- * The `rel` attribute for the link. By default, `"noreferrer"` is provided if
25
- * the link's URL is external. This prop can be provided a function to use the
26
- * link's metadata to determine the `rel` value.
27
- */
28
- rel?: string | AsLinkAttrsConfig["rel"];
29
- /**
30
- * The link resolver used to resolve links.
31
- *
32
- * @remarks
33
- * If your app uses route resolvers when querying for your Prismic
34
- * repository's content, a link resolver does not need to be provided.
35
- *
36
- * @see Learn about link resolvers and route resolvers {@link https://prismic.io/docs/routes}
37
- */
38
- linkResolver?: LinkResolverFunction;
39
- /**
40
- * The component rendered for internal URLs. Defaults to `<a>`.
41
- *
42
- * If your app uses a client-side router that requires a special Link
43
- * component, provide the Link component to this prop.
44
- */
45
- internalComponent?: ComponentType<InternalComponentProps>;
46
- /** The component rendered for external URLs. Defaults to `<a>`. */
47
- externalComponent?: ComponentType<ExternalComponentProps>;
48
- /**
49
- * The children to render for the link. If no children are provided, the
50
- * link's `text` property will be used.
51
- */
52
- children?: ReactNode;
53
- } & ({
54
- document: PrismicDocument | null | undefined;
55
- href?: never;
56
- field?: never;
57
- } | {
58
- field: LinkField | null | undefined;
59
- href?: never;
60
- document?: never;
61
- } | {
62
- href: LinkProps["href"];
63
- field?: LinkField | null | undefined;
64
- document?: never;
65
- });
66
- /**
67
- * Renders a link from a Prismic link field or page.
68
- *
69
- * @example
70
- *
71
- * ```tsx
72
- * <PrismicLink field={slice.primary.link}>Click here</PrismicLink>;
73
- * ```
74
- *
75
- * @see Learn how to display links and use variants for styling: {@link https://prismic.io/docs/fields/link}
76
- */
77
- export declare const PrismicLink: <InternalComponentProps = ComponentProps<typeof defaultComponent>, ExternalComponentProps = ComponentProps<typeof defaultComponent>>(props: PrismicLinkProps<InternalComponentProps, ExternalComponentProps> & {
78
- ref?: ForwardedRef<Element>;
79
- }) => ReactNode;
80
- /**
81
- * Determines if a URL is internal or external.
82
- *
83
- * @param url - The URL to check if internal or external.
84
- *
85
- * @returns `true` if `url` is internal, `false` otherwise.
86
- */
87
- export declare function isInternalURL(url: string): boolean;
88
- export {};
@@ -1,47 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { forwardRef } from "react";
3
- import { asLinkAttrs } from "@prismicio/client";
4
- import { DEV } from "esm-env";
5
- import { devMsg } from "./lib/devMsg.js";
6
- const defaultComponent = "a";
7
- const PrismicLink = forwardRef(function PrismicLink2(props, ref) {
8
- const { field, document: doc, linkResolver, internalComponent, externalComponent, children, ...restProps } = props;
9
- if (DEV) {
10
- if (field) {
11
- if (!field.link_type) {
12
- console.error(`[PrismicLink] This "field" prop value caused an error to be thrown.
13
- `, field);
14
- throw new Error(`[PrismicLink] The provided field is missing required properties to properly render a link. The link will not render. For more details, see ${devMsg("missing-link-properties")}`);
15
- } else if (("text" in field ? Object.keys(field).length > 2 : Object.keys(field).length > 1) && !("url" in field || "uid" in field || "id" in field)) {
16
- console.warn(`[PrismicLink] The provided field is missing required properties to properly render a link. The link may not render correctly. For more details, see ${devMsg("missing-link-properties")}`, field);
17
- }
18
- } else if (doc) {
19
- if (!("url" in doc || "id" in doc)) {
20
- console.warn(`[PrismicLink] The provided document is missing required properties to properly render a link. The link may not render correctly. For more details, see ${devMsg("missing-link-properties")}`, doc);
21
- }
22
- }
23
- }
24
- const { href: computedHref, rel: computedRel, ...attrs } = asLinkAttrs(field ?? doc, {
25
- linkResolver,
26
- rel: typeof restProps.rel === "function" ? restProps.rel : void 0
27
- });
28
- let rel = computedRel;
29
- if ("rel" in restProps && typeof restProps.rel !== "function") {
30
- rel = restProps.rel;
31
- }
32
- const href = ("href" in restProps ? restProps.href : computedHref) || "";
33
- const InternalComponent = internalComponent || defaultComponent;
34
- const ExternalComponent = externalComponent || defaultComponent;
35
- const Component = href ? isInternalURL(href) ? InternalComponent : ExternalComponent : InternalComponent;
36
- return jsx(Component, { ref, ...attrs, ...restProps, href, rel, children: "children" in props ? children : field == null ? void 0 : field.text });
37
- });
38
- function isInternalURL(url) {
39
- const isInternal = /^(\/(?!\/)|#)/.test(url);
40
- const isSpecialLink = !isInternal && !/^https?:\/\//.test(url);
41
- return isInternal && !isSpecialLink;
42
- }
43
- export {
44
- PrismicLink,
45
- isInternalURL
46
- };
47
- //# sourceMappingURL=PrismicLink.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PrismicLink.js","sources":["../src/PrismicLink.tsx"],"sourcesContent":["import {\n\tComponentProps,\n\tComponentType,\n\tForwardedRef,\n\tHTMLAttributeAnchorTarget,\n\tReactNode,\n\tforwardRef,\n} from \"react\";\nimport {\n\ttype LinkField,\n\ttype LinkResolverFunction,\n\ttype PrismicDocument,\n\tasLinkAttrs,\n\ttype AsLinkAttrsConfig,\n} from \"@prismicio/client\";\nimport { DEV } from \"esm-env\";\n\nimport { devMsg } from \"./lib/devMsg.js\";\n\n/** The default component rendered for internal and external links. */\nconst defaultComponent = \"a\";\n\n/** Props provided to a component when rendered with `<PrismicLink>`. */\nexport interface LinkProps {\n\t/** The URL to link. */\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?: 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/** Children for the component. */\n\tchildren?: ReactNode;\n}\n\nexport type PrismicLinkProps<\n\tInternalComponentProps = ComponentProps<typeof defaultComponent>,\n\tExternalComponentProps = ComponentProps<typeof defaultComponent>,\n> = Omit<\n\tInternalComponentProps & ExternalComponentProps,\n\t\"rel\" | \"href\" | \"children\"\n> & {\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 *\n\t * @see Learn about link resolvers and route resolvers {@link https://prismic.io/docs/routes}\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?: ComponentType<InternalComponentProps>;\n\n\t/** The component rendered for external URLs. Defaults to `<a>`. */\n\texternalComponent?: ComponentType<ExternalComponentProps>;\n\n\t/**\n\t * The children to render for the link. If no children are provided, the\n\t * link's `text` property will be used.\n\t */\n\tchildren?: ReactNode;\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\n/**\n * Renders a link from a Prismic link field or page.\n *\n * @example\n *\n * ```tsx\n * <PrismicLink field={slice.primary.link}>Click here</PrismicLink>;\n * ```\n *\n * @see Learn how to display links and use variants for styling: {@link https://prismic.io/docs/fields/link}\n */\nexport const PrismicLink = forwardRef(function PrismicLink<\n\tInternalComponentProps = ComponentProps<typeof defaultComponent>,\n\tExternalComponentProps = ComponentProps<typeof defaultComponent>,\n>(\n\tprops: PrismicLinkProps<InternalComponentProps, ExternalComponentProps>,\n\tref: ForwardedRef<Element>,\n) {\n\tconst {\n\t\tfield,\n\t\tdocument: doc,\n\t\tlinkResolver,\n\t\tinternalComponent,\n\t\texternalComponent,\n\t\tchildren,\n\t\t...restProps\n\t} = props;\n\n\tif (DEV) {\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\t(\"text\" in field\n\t\t\t\t\t? Object.keys(field).length > 2\n\t\t\t\t\t: Object.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 ComponentType<LinkProps>;\n\tconst ExternalComponent = (externalComponent ||\n\t\tdefaultComponent) as ComponentType<LinkProps>;\n\tconst Component = href\n\t\t? isInternalURL(href)\n\t\t\t? InternalComponent\n\t\t\t: ExternalComponent\n\t\t: InternalComponent;\n\n\treturn (\n\t\t<Component ref={ref} {...attrs} {...restProps} href={href} rel={rel}>\n\t\t\t{\"children\" in props ? children : field?.text}\n\t\t</Component>\n\t);\n}) as <\n\tInternalComponentProps = ComponentProps<typeof defaultComponent>,\n\tExternalComponentProps = ComponentProps<typeof defaultComponent>,\n>(\n\tprops: PrismicLinkProps<InternalComponentProps, ExternalComponentProps> & {\n\t\tref?: ForwardedRef<Element>;\n\t},\n) => ReactNode;\n\n/**\n * Determines if a URL is internal or external.\n *\n * @param url - The URL to check if internal or external.\n *\n * @returns `true` if `url` is internal, `false` otherwise.\n */\n// TODO: This does not detect all relative URLs as internal such as `about` or `./about`. This function assumes relative URLs start with a \"/\" or \"#\"`.\nexport function isInternalURL(url: string): boolean {\n\tconst isInternal = /^(\\/(?!\\/)|#)/.test(url);\n\tconst isSpecialLink = !isInternal && !/^https?:\\/\\//.test(url);\n\n\treturn isInternal && !isSpecialLink;\n}\n"],"names":["PrismicLink","_jsx"],"mappings":";;;;;AAoBA,MAAM,mBAAmB;AA6FlB,MAAM,cAAc,WAAW,SAASA,aAI9C,OACA,KAA0B;AAEpB,QAAA,EACL,OACA,UAAU,KACV,cACA,mBACA,mBACA,UACA,GAAG,UAAA,IACA;AAEJ,MAAI,KAAK;AACR,QAAI,OAAO;AACN,UAAA,CAAC,MAAM,WAAW;AACrB,gBAAQ,MACP;AAAA,GACA,KAAK;AAEN,cAAM,IAAI,MACT,8IAA8I,OAC7I,yBAAyB,CACzB,EAAE;AAAA,MAAA,YAGH,UAAU,QACR,OAAO,KAAK,KAAK,EAAE,SAAS,IAC5B,OAAO,KAAK,KAAK,EAAE,SAAS,MAC/B,EAAE,SAAS,SAAS,SAAS,SAAS,QAAQ,QAC7C;AACD,gBAAQ,KACP,uJAAuJ,OACtJ,yBAAyB,CACzB,IACD,KAAK;AAAA,MAAA;AAAA,eAGG,KAAK;AACf,UAAI,EAAE,SAAS,OAAO,QAAQ,MAAM;AACnC,gBAAQ,KACP,0JAA0J,OACzJ,yBAAyB,CACzB,IACD,GAAG;AAAA,MAAA;AAAA,IAEL;AAAA,EACD;AAGK,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,EAAA;AAGjB,QAAM,QAAQ,UAAU,YAAY,UAAU,OAAO,iBAAiB;AAEtE,QAAM,oBAAqB,qBAC1B;AACD,QAAM,oBAAqB,qBAC1B;AACD,QAAM,YAAY,OACf,cAAc,IAAI,IACjB,oBACA,oBACD;AAEH,SACCC,IAAC,WAAS,EAAC,KAAc,GAAA,UAAW,WAAW,MAAY,eACzD,cAAc,QAAQ,WAAW,+BAAO,MAAI;AAGhD,CAAC;AAiBK,SAAU,cAAc,KAAW;AAClC,QAAA,aAAa,gBAAgB,KAAK,GAAG;AAC3C,QAAM,gBAAgB,CAAC,cAAc,CAAC,eAAe,KAAK,GAAG;AAE7D,SAAO,cAAc,CAAC;AACvB;"}
@@ -1,90 +0,0 @@
1
- import { ComponentType, FC, ReactNode } from "react";
2
- import { LinkResolverFunction, RichTextField } from "@prismicio/client";
3
- import { RichTextFunctionSerializer, RichTextMapSerializer } from "@prismicio/client/richtext";
4
- import { LinkProps } from "./PrismicLink.js";
5
- /**
6
- * A function mapping rich text block types to React Components. It is used to
7
- * render rich text fields.
8
- *
9
- * @see Templating rich text fields {@link https://prismic.io/docs/fields/rich-text}
10
- */
11
- export type JSXFunctionSerializer = RichTextFunctionSerializer<ReactNode>;
12
- /**
13
- * A map of rich text block types to React Components. It is used to render rich
14
- * text fields.
15
- *
16
- * @see Templating rich text fields {@link https://prismic.io/docs/fields/rich-text}
17
- */
18
- export type JSXMapSerializer = RichTextMapSerializer<ReactNode>;
19
- /** Props for `<PrismicRichText>`. */
20
- export type PrismicRichTextProps = {
21
- /** The Prismic rich text field to render. */
22
- field: RichTextField | null | undefined;
23
- /**
24
- * The link resolver used to resolve links.
25
- *
26
- * @remarks
27
- * If your app uses route resolvers when querying for your Prismic
28
- * repository's content, a link resolver does not need to be provided.
29
- *
30
- * @see Learn about link resolvers and route resolvers {@link https://prismic.io/docs/routes}
31
- */
32
- linkResolver?: LinkResolverFunction;
33
- /**
34
- * A map or function that maps a rich text block to a React component.
35
- *
36
- * @remarks
37
- * Prefer using a map serializer over the function serializer when possible.
38
- * The map serializer is simpler to maintain.
39
- *
40
- * @example A map serializer.
41
- *
42
- * ```jsx
43
- * {
44
- * heading1: ({children}) => <Heading>{children}</Heading>
45
- * }
46
- * ```
47
- *
48
- * @example A function serializer.
49
- *
50
- * ```jsx
51
- * (type, node, content, children) => {
52
- * switch (type) {
53
- * case "heading1": {
54
- * return <Heading>{children}</Heading>;
55
- * }
56
- * }
57
- * };
58
- * ```
59
- */
60
- components?: JSXMapSerializer | JSXFunctionSerializer;
61
- /**
62
- * The React component rendered for links when the URL is internal.
63
- *
64
- * @defaultValue `<a>`
65
- */
66
- internalLinkComponent?: ComponentType<LinkProps>;
67
- /**
68
- * The React component rendered for links when the URL is external.
69
- *
70
- * @defaultValue `<a>`
71
- */
72
- externalLinkComponent?: ComponentType<LinkProps>;
73
- /**
74
- * The value to be rendered when the field is empty. If a fallback is not
75
- * given, `null` will be rendered.
76
- */
77
- fallback?: ReactNode;
78
- };
79
- /**
80
- * Renders content from a Prismic rich text field as React components.
81
- *
82
- * @example
83
- *
84
- * ```tsx
85
- * <PrismicRichText field={slice.primary.text} />;
86
- * ```
87
- *
88
- * @see Learn how to style rich text, use custom components, and use labels for custom formatting: {@link https://prismic.io/docs/fields/rich-text}
89
- */
90
- export declare const PrismicRichText: FC<PrismicRichTextProps>;