@prismicio/react 3.4.0-canary.e2a0168 → 3.4.0-pr.257.68f2f80

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 (41) hide show
  1. package/dist/PrismicImage.d.ts +20 -28
  2. package/dist/PrismicImage.d.ts.map +1 -1
  3. package/dist/PrismicImage.js +6 -8
  4. package/dist/PrismicImage.js.map +1 -1
  5. package/dist/PrismicLink.d.ts +18 -21
  6. package/dist/PrismicLink.d.ts.map +1 -1
  7. package/dist/PrismicLink.js +6 -9
  8. package/dist/PrismicLink.js.map +1 -1
  9. package/dist/PrismicRichText.d.ts +31 -37
  10. package/dist/PrismicRichText.d.ts.map +1 -1
  11. package/dist/PrismicRichText.js +5 -7
  12. package/dist/PrismicRichText.js.map +1 -1
  13. package/dist/PrismicTable.d.ts +15 -16
  14. package/dist/PrismicTable.d.ts.map +1 -1
  15. package/dist/PrismicTable.js +4 -6
  16. package/dist/PrismicTable.js.map +1 -1
  17. package/dist/PrismicText.d.ts +8 -11
  18. package/dist/PrismicText.d.ts.map +1 -1
  19. package/dist/PrismicText.js +4 -6
  20. package/dist/PrismicText.js.map +1 -1
  21. package/dist/PrismicToolbar.d.ts +11 -14
  22. package/dist/PrismicToolbar.d.ts.map +1 -1
  23. package/dist/PrismicToolbar.js +5 -8
  24. package/dist/PrismicToolbar.js.map +1 -1
  25. package/dist/SliceZone.d.ts +31 -51
  26. package/dist/SliceZone.d.ts.map +1 -1
  27. package/dist/SliceZone.js +7 -10
  28. package/dist/SliceZone.js.map +1 -1
  29. package/dist/index.js +1 -2
  30. package/dist/lib/devMsg.js +7 -10
  31. package/dist/lib/devMsg.js.map +1 -1
  32. package/dist/package.js +2 -2
  33. package/package.json +32 -34
  34. package/src/PrismicImage.tsx +95 -122
  35. package/src/PrismicLink.tsx +28 -38
  36. package/src/PrismicRichText.tsx +41 -49
  37. package/src/PrismicTable.tsx +15 -19
  38. package/src/PrismicText.tsx +6 -7
  39. package/src/PrismicToolbar.tsx +12 -16
  40. package/src/SliceZone.tsx +36 -76
  41. package/src/lib/devMsg.ts +6 -8
@@ -1 +1 @@
1
- {"version":3,"file":"devMsg.js","names":[],"sources":["../../src/lib/devMsg.ts"],"sourcesContent":["import { version } from \"../../package.json\";\n\n/**\n * Returns a `prismic.dev/msg` URL for a given message slug.\n *\n * @example\n *\n * ```ts\n * devMsg(\"missing-param\");\n * // => \"https://prismic.dev/msg/react/v1.2.3/missing-param\"\n * ```\n *\n * @param slug - Slug for the message. This corresponds to a Markdown file in\n * the Git repository's `/messages` directory.\n *\n * @returns The `prismic.dev/msg` URL for the given slug.\n */\nexport function devMsg(slug: string): string {\n\treturn `https://prismic.dev/msg/react/v${version}/${slug}`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAiBA,SAAgB,OAAO,MAAsB;AAC5C,QAAO,kCAAkC,QAAQ,GAAG"}
1
+ {"version":3,"file":"devMsg.js","names":[],"sources":["../../src/lib/devMsg.ts"],"sourcesContent":["import { version } from \"../../package.json\";\n\n/**\n * Returns a `prismic.dev/msg` URL for a given message slug.\n *\n * @example\n * \t```ts\n * \tdevMsg(\"missing-param\");\n * \t// => \"https://prismic.dev/msg/react/v1.2.3/missing-param\"\n * \t```\n *\n * @param slug - Slug for the message. This corresponds to a Markdown file in the Git repository's\n * `/messages` directory.\n * @returns The `prismic.dev/msg` URL for the given slug.\n */\nexport function devMsg(slug: string): string {\n\treturn `https://prismic.dev/msg/react/v${version}/${slug}`;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAeA,SAAgB,OAAO,MAAsB;AAC5C,QAAO,kCAAkC,QAAQ,GAAG"}
package/dist/package.js CHANGED
@@ -1,6 +1,6 @@
1
1
  //#region package.json
2
- var version = "3.4.0-canary.e2a0168";
3
-
2
+ var version = "3.4.0-pr.257.68f2f80";
4
3
  //#endregion
5
4
  export { version };
5
+
6
6
  //# sourceMappingURL=package.js.map
package/package.json CHANGED
@@ -1,24 +1,28 @@
1
1
  {
2
2
  "name": "@prismicio/react",
3
- "version": "3.4.0-canary.e2a0168",
3
+ "version": "3.4.0-pr.257.68f2f80",
4
4
  "description": "React components and hooks to fetch and present Prismic content",
5
5
  "keywords": [
6
- "typescript",
7
6
  "prismic",
8
- "react"
7
+ "react",
8
+ "typescript"
9
9
  ],
10
+ "license": "Apache-2.0",
11
+ "author": "Prismic <contact@prismic.io> (https://prismic.io)",
10
12
  "repository": {
11
13
  "type": "git",
12
14
  "url": "git+https://github.com/prismicio/prismic-react.git"
13
15
  },
14
- "license": "Apache-2.0",
15
- "author": "Prismic <contact@prismic.io> (https://prismic.io)",
16
- "sideEffects": false,
16
+ "workspaces": [
17
+ ".",
18
+ "e2e-projects/*"
19
+ ],
20
+ "files": [
21
+ "dist",
22
+ "src"
23
+ ],
17
24
  "type": "module",
18
- "exports": {
19
- ".": "./dist/index.js",
20
- "./package.json": "./package.json"
21
- },
25
+ "sideEffects": false,
22
26
  "types": "./dist/index.d.ts",
23
27
  "typesVersions": {
24
28
  "*": {
@@ -27,20 +31,19 @@
27
31
  ]
28
32
  }
29
33
  },
30
- "files": [
31
- "dist",
32
- "src"
33
- ],
34
- "workspaces": [
35
- ".",
36
- "e2e-projects/*"
37
- ],
34
+ "exports": {
35
+ ".": "./dist/index.js",
36
+ "./package.json": "./package.json"
37
+ },
38
+ "publishConfig": {
39
+ "access": "public"
40
+ },
38
41
  "scripts": {
39
42
  "build": "tsdown",
40
43
  "dev": "tsdown --watch",
41
44
  "e2e": "playwright test",
42
45
  "e2e:ui": "npm run e2e -- --ui",
43
- "format": "prettier --write .",
46
+ "format": "oxfmt",
44
47
  "lint": "oxlint --deny-warnings",
45
48
  "prepare": "npm run build",
46
49
  "test": "npm run lint && npm run types && npm run build && npm run e2e",
@@ -50,20 +53,18 @@
50
53
  "esm-env": "^1.2.2"
51
54
  },
52
55
  "devDependencies": {
53
- "@playwright/test": "^1.57.0",
56
+ "@playwright/test": "^1.59.1",
54
57
  "@prismicio/client": "^7.17.0",
55
- "@trivago/prettier-plugin-sort-imports": "^6.0.2",
56
- "@types/react": "^19.2.8",
58
+ "@types/react": "^19.2.14",
57
59
  "@types/react-dom": "^19.2.3",
58
- "dotenv": "^17.2.3",
59
- "oxlint": "^1.39.0",
60
- "playwright": "^1.57.0",
61
- "prettier": "^3.7.4",
62
- "prettier-plugin-jsdoc": "^1.8.0",
63
- "react": "^19.2.1",
64
- "react-dom": "^19.2.3",
65
- "tsdown": "^0.19.0",
66
- "typescript": "^5.9.3"
60
+ "dotenv": "^17.4.0",
61
+ "oxfmt": "^0.43.0",
62
+ "oxlint": "^1.58.0",
63
+ "playwright": "^1.59.1",
64
+ "react": "^19.2.4",
65
+ "react-dom": "^19.2.4",
66
+ "tsdown": "^0.21.7",
67
+ "typescript": "^6.0.2"
67
68
  },
68
69
  "peerDependencies": {
69
70
  "@prismicio/client": "^7",
@@ -71,8 +72,5 @@
71
72
  },
72
73
  "engines": {
73
74
  "node": ">=20"
74
- },
75
- "publishConfig": {
76
- "access": "public"
77
75
  }
78
76
  }
@@ -1,10 +1,3 @@
1
- import {
2
- type ForwardedRef,
3
- forwardRef,
4
- type ComponentProps,
5
- type FC,
6
- type ReactNode,
7
- } from "react";
8
1
  import {
9
2
  type ImageFieldImage,
10
3
  asImagePixelDensitySrcSet,
@@ -12,23 +5,15 @@ import {
12
5
  isFilled,
13
6
  } from "@prismicio/client";
14
7
  import { DEV } from "esm-env";
8
+ import { type ForwardedRef, forwardRef, type ComponentProps, type FC, type ReactNode } from "react";
15
9
 
16
10
  import { devMsg } from "./lib/devMsg.js";
17
11
 
18
- type ImgixURLParams = Omit<
19
- NonNullable<Parameters<typeof asImageWidthSrcSet>[1]>,
20
- "widths"
21
- > &
22
- Omit<
23
- NonNullable<Parameters<typeof asImagePixelDensitySrcSet>[1]>,
24
- "pixelDensities"
25
- >;
12
+ type ImgixURLParams = Omit<NonNullable<Parameters<typeof asImageWidthSrcSet>[1]>, "widths"> &
13
+ Omit<NonNullable<Parameters<typeof asImagePixelDensitySrcSet>[1]>, "pixelDensities">;
26
14
 
27
15
  /** Props for `<PrismicImage>`. */
28
- export type PrismicImageProps = Omit<
29
- ComponentProps<"img">,
30
- "src" | "srcset" | "alt"
31
- > & {
16
+ export type PrismicImageProps = Omit<ComponentProps<"img">, "src" | "srcset" | "alt"> & {
32
17
  /** The Prismic image field or thumbnail to render. */
33
18
  field: ImageFieldImage | null | undefined;
34
19
 
@@ -42,41 +27,35 @@ export type PrismicImageProps = Omit<
42
27
  /**
43
28
  * Declare an image as decorative by providing `alt=""`.
44
29
  *
45
- * See:
46
- * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
30
+ * See: https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
47
31
  */
48
32
  alt?: "";
49
33
 
50
34
  /**
51
- * Declare an image as decorative only if the image field does not have
52
- * alternative text by providing `fallbackAlt=""`.
35
+ * Declare an image as decorative only if the image field does not have alternative text by
36
+ * providing `fallbackAlt=""`.
53
37
  *
54
- * See:
55
- * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
38
+ * See: https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/alt#decorative_images
56
39
  */
57
40
  fallbackAlt?: "";
58
41
 
59
42
  /**
60
- * The value to be rendered when the field is empty. If a fallback is not
61
- * given, `null` will be rendered.
43
+ * The value to be rendered when the field is empty. If a fallback is not given, `null` will be
44
+ * rendered.
62
45
  */
63
46
  fallback?: ReactNode;
64
47
  } & (
65
48
  | {
66
49
  /**
67
- * Widths (in pixels) used to build a `srcset` value for the image
68
- * field.
50
+ * Widths (in pixels) used to build a `srcset` value for the image field.
69
51
  *
70
- * If omitted or set to `"defaults"`, the following widths will be used:
71
- * 640, 750, 828, 1080, 1200, 1920, 2048, 3840.
52
+ * If omitted or set to `"defaults"`, the following widths will be used: 640, 750, 828,
53
+ * 1080, 1200, 1920, 2048, 3840.
72
54
  *
73
- * If the image field contains responsive views, each responsive view
74
- * can be used as a width in the resulting `srcset` by passing
75
- * `"thumbnails"` as the `widths` prop.
55
+ * If the image field contains responsive views, each responsive view can be used as a width
56
+ * in the resulting `srcset` by passing `"thumbnails"` as the `widths` prop.
76
57
  */
77
- widths?:
78
- | NonNullable<Parameters<typeof asImageWidthSrcSet>[1]>["widths"]
79
- | "defaults";
58
+ widths?: NonNullable<Parameters<typeof asImageWidthSrcSet>[1]>["widths"] | "defaults";
80
59
  /** Not used when the `widths` prop is used. */
81
60
  pixelDensities?: never;
82
61
  }
@@ -86,13 +65,11 @@ export type PrismicImageProps = Omit<
86
65
  /**
87
66
  * Pixel densities used to build a `srcset` value for the image field.
88
67
  *
89
- * If a `pixelDensities` prop is passed `"defaults"`, the following
90
- * pixel densities will be used: 1, 2, 3.
68
+ * If a `pixelDensities` prop is passed `"defaults"`, the following pixel densities will be
69
+ * used: 1, 2, 3.
91
70
  */
92
71
  pixelDensities:
93
- | NonNullable<
94
- Parameters<typeof asImagePixelDensitySrcSet>[1]
95
- >["pixelDensities"]
72
+ | NonNullable<Parameters<typeof asImagePixelDensitySrcSet>[1]>["pixelDensities"]
96
73
  | "defaults";
97
74
  }
98
75
  );
@@ -101,94 +78,90 @@ export type PrismicImageProps = Omit<
101
78
  * Renders an optimized image from a Prismic image field.
102
79
  *
103
80
  * @example
104
- *
105
- * ```tsx
106
- * <PrismicImage field={slice.primary.photo} />;
107
- * ```
81
+ * ```tsx
82
+ * <PrismicImage field={slice.primary.photo} />;
83
+ * ```
108
84
  *
109
85
  * @see Learn how to optimize images with imgix, use responsive images, and use framework-specific image components: {@link https://prismic.io/docs/fields/image}
110
86
  */
111
- export const PrismicImage: FC<PrismicImageProps> = forwardRef(
112
- function PrismicImage(
113
- props: PrismicImageProps,
114
- ref: ForwardedRef<HTMLImageElement>,
115
- ) {
116
- const {
117
- field,
118
- alt,
119
- fallbackAlt,
120
- imgixParams = {},
121
- widths,
122
- pixelDensities,
123
- fallback,
124
- ...restProps
125
- } = props;
126
-
127
- if (DEV) {
128
- if (typeof alt === "string" && alt !== "") {
129
- console.warn(
130
- `[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(
131
- "alt-must-be-an-empty-string",
132
- )}`,
133
- );
134
- }
135
-
136
- if (typeof fallbackAlt === "string" && fallbackAlt !== "") {
137
- console.warn(
138
- `[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(
139
- "alt-must-be-an-empty-string",
140
- )}`,
141
- );
142
- }
143
-
144
- if (widths && pixelDensities) {
145
- console.warn(
146
- `[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.`,
147
- );
148
- }
87
+ export const PrismicImage: FC<PrismicImageProps> = forwardRef(function PrismicImage(
88
+ props: PrismicImageProps,
89
+ ref: ForwardedRef<HTMLImageElement>,
90
+ ) {
91
+ const {
92
+ field,
93
+ alt,
94
+ fallbackAlt,
95
+ imgixParams = {},
96
+ widths,
97
+ pixelDensities,
98
+ fallback,
99
+ ...restProps
100
+ } = props;
101
+
102
+ if (DEV) {
103
+ if (typeof alt === "string" && alt !== "") {
104
+ console.warn(
105
+ `[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(
106
+ "alt-must-be-an-empty-string",
107
+ )}`,
108
+ );
149
109
  }
150
110
 
151
- if (!isFilled.imageThumbnail(field)) {
152
- return <>{fallback}</>;
111
+ if (typeof fallbackAlt === "string" && fallbackAlt !== "") {
112
+ console.warn(
113
+ `[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(
114
+ "alt-must-be-an-empty-string",
115
+ )}`,
116
+ );
153
117
  }
154
118
 
155
- const resolvedImgixParams = imgixParams;
156
- for (const x in imgixParams) {
157
- if (resolvedImgixParams[x as keyof typeof resolvedImgixParams] === null) {
158
- resolvedImgixParams[x as keyof typeof resolvedImgixParams] = undefined;
159
- }
119
+ if (widths && pixelDensities) {
120
+ console.warn(
121
+ `[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.`,
122
+ );
160
123
  }
124
+ }
161
125
 
162
- let src: string | undefined;
163
- let srcSet: string | undefined;
164
-
165
- if (widths || !pixelDensities) {
166
- const res = asImageWidthSrcSet(field, {
167
- ...resolvedImgixParams,
168
- widths: widths === "defaults" ? undefined : widths,
169
- } as ImgixURLParams);
126
+ if (!isFilled.imageThumbnail(field)) {
127
+ return <>{fallback}</>;
128
+ }
170
129
 
171
- src = res.src;
172
- srcSet = res.srcset;
173
- } else if (pixelDensities) {
174
- const res = asImagePixelDensitySrcSet(field, {
175
- ...resolvedImgixParams,
176
- pixelDensities:
177
- pixelDensities === "defaults" ? undefined : pixelDensities,
178
- } as ImgixURLParams);
179
-
180
- src = res.src;
181
- srcSet = res.srcset;
130
+ const resolvedImgixParams = imgixParams;
131
+ for (const x in imgixParams) {
132
+ if (resolvedImgixParams[x as keyof typeof resolvedImgixParams] === null) {
133
+ resolvedImgixParams[x as keyof typeof resolvedImgixParams] = undefined;
182
134
  }
183
-
184
- return (
185
- <img
186
- ref={ref}
187
- src={src}
188
- srcSet={srcSet}
189
- alt={alt ?? (field.alt || fallbackAlt)}
190
- {...restProps}
191
- />
192
- );
193
- },
194
- );
135
+ }
136
+
137
+ let src: string | undefined;
138
+ let srcSet: string | undefined;
139
+
140
+ if (widths || !pixelDensities) {
141
+ const res = asImageWidthSrcSet(field, {
142
+ ...resolvedImgixParams,
143
+ widths: widths === "defaults" ? undefined : widths,
144
+ } as ImgixURLParams);
145
+
146
+ src = res.src;
147
+ srcSet = res.srcset;
148
+ } else if (pixelDensities) {
149
+ const res = asImagePixelDensitySrcSet(field, {
150
+ ...resolvedImgixParams,
151
+ pixelDensities: pixelDensities === "defaults" ? undefined : pixelDensities,
152
+ } as ImgixURLParams);
153
+
154
+ src = res.src;
155
+ srcSet = res.srcset;
156
+ }
157
+
158
+ return (
159
+ <img
160
+ ref={ref}
161
+ src={src}
162
+ srcSet={srcSet}
163
+ alt={alt ?? (field.alt || fallbackAlt)}
164
+ {...restProps}
165
+ />
166
+ );
167
+ });
@@ -1,11 +1,3 @@
1
- import {
2
- type ComponentProps,
3
- type ComponentType,
4
- type ForwardedRef,
5
- type HTMLAttributeAnchorTarget,
6
- type ReactNode,
7
- forwardRef,
8
- } from "react";
9
1
  import {
10
2
  type LinkField,
11
3
  type LinkResolverFunction,
@@ -14,6 +6,14 @@ import {
14
6
  type AsLinkAttrsConfig,
15
7
  } from "@prismicio/client";
16
8
  import { DEV } from "esm-env";
9
+ import {
10
+ type ComponentProps,
11
+ type ComponentType,
12
+ type ForwardedRef,
13
+ type HTMLAttributeAnchorTarget,
14
+ type ReactNode,
15
+ forwardRef,
16
+ } from "react";
17
17
 
18
18
  import { devMsg } from "./lib/devMsg.js";
19
19
 
@@ -26,14 +26,14 @@ export interface LinkProps {
26
26
  href: string;
27
27
 
28
28
  /**
29
- * The `target` attribute for anchor elements. If the Prismic field is
30
- * configured to open in a new window, this prop defaults to `_blank`.
29
+ * The `target` attribute for anchor elements. If the Prismic field is configured to open in a new
30
+ * window, this prop defaults to `_blank`.
31
31
  */
32
32
  target?: HTMLAttributeAnchorTarget;
33
33
 
34
34
  /**
35
- * The `rel` attribute for anchor elements. If the `target` prop is set to
36
- * `"_blank"`, this prop defaults to `"noopener noreferrer"`.
35
+ * The `rel` attribute for anchor elements. If the `target` prop is set to `"_blank"`, this prop
36
+ * defaults to `"noopener noreferrer"`.
37
37
  */
38
38
  rel?: string;
39
39
 
@@ -44,14 +44,11 @@ export interface LinkProps {
44
44
  export type PrismicLinkProps<
45
45
  InternalComponentProps = ComponentProps<typeof defaultComponent>,
46
46
  ExternalComponentProps = ComponentProps<typeof defaultComponent>,
47
- > = Omit<
48
- InternalComponentProps & ExternalComponentProps,
49
- "rel" | "href" | "children"
50
- > & {
47
+ > = Omit<InternalComponentProps & ExternalComponentProps, "rel" | "href" | "children"> & {
51
48
  /**
52
- * The `rel` attribute for the link. By default, `"noreferrer"` is provided if
53
- * the link's URL is external. This prop can be provided a function to use the
54
- * link's metadata to determine the `rel` value.
49
+ * The `rel` attribute for the link. By default, `"noreferrer"` is provided if the link's URL is
50
+ * external. This prop can be provided a function to use the link's metadata to determine the
51
+ * `rel` value.
55
52
  */
56
53
  rel?: string | AsLinkAttrsConfig["rel"];
57
54
 
@@ -59,9 +56,8 @@ export type PrismicLinkProps<
59
56
  * The link resolver used to resolve links.
60
57
  *
61
58
  * @remarks
62
- * If your app uses route resolvers when querying for your Prismic
63
- * repository's content, a link resolver does not need to be provided.
64
- *
59
+ * If your app uses route resolvers when querying for your Prismic repository's content, a link
60
+ * resolver does not need to be provided.
65
61
  * @see Learn about link resolvers and route resolvers {@link https://prismic.io/docs/routes}
66
62
  */
67
63
  linkResolver?: LinkResolverFunction;
@@ -69,8 +65,8 @@ export type PrismicLinkProps<
69
65
  /**
70
66
  * The component rendered for internal URLs. Defaults to `<a>`.
71
67
  *
72
- * If your app uses a client-side router that requires a special Link
73
- * component, provide the Link component to this prop.
68
+ * If your app uses a client-side router that requires a special Link component, provide the Link
69
+ * component to this prop.
74
70
  */
75
71
  internalComponent?: ComponentType<InternalComponentProps>;
76
72
 
@@ -78,8 +74,8 @@ export type PrismicLinkProps<
78
74
  externalComponent?: ComponentType<ExternalComponentProps>;
79
75
 
80
76
  /**
81
- * The children to render for the link. If no children are provided, the
82
- * link's `text` property will be used.
77
+ * The children to render for the link. If no children are provided, the link's `text` property
78
+ * will be used.
83
79
  */
84
80
  children?: ReactNode;
85
81
  } & (
@@ -104,10 +100,9 @@ export type PrismicLinkProps<
104
100
  * Renders a link from a Prismic link field or page.
105
101
  *
106
102
  * @example
107
- *
108
- * ```tsx
109
- * <PrismicLink field={slice.primary.link}>Click here</PrismicLink>;
110
- * ```
103
+ * ```tsx
104
+ * <PrismicLink field={slice.primary.link}>Click here</PrismicLink>;
105
+ * ```
111
106
  *
112
107
  * @see Learn how to display links and use variants for styling: {@link https://prismic.io/docs/fields/link}
113
108
  */
@@ -141,9 +136,7 @@ export const PrismicLink = forwardRef(function PrismicLink<
141
136
  )}`,
142
137
  );
143
138
  } else if (
144
- ("text" in field
145
- ? Object.keys(field).length > 2
146
- : Object.keys(field).length > 1) &&
139
+ ("text" in field ? Object.keys(field).length > 2 : Object.keys(field).length > 1) &&
147
140
  !("url" in field || "uid" in field || "id" in field)
148
141
  ) {
149
142
  console.warn(
@@ -181,10 +174,8 @@ export const PrismicLink = forwardRef(function PrismicLink<
181
174
 
182
175
  const href = ("href" in restProps ? restProps.href : computedHref) || "";
183
176
 
184
- const InternalComponent = (internalComponent ||
185
- defaultComponent) as ComponentType<LinkProps>;
186
- const ExternalComponent = (externalComponent ||
187
- defaultComponent) as ComponentType<LinkProps>;
177
+ const InternalComponent = (internalComponent || defaultComponent) as ComponentType<LinkProps>;
178
+ const ExternalComponent = (externalComponent || defaultComponent) as ComponentType<LinkProps>;
188
179
  const Component = href
189
180
  ? isInternalURL(href)
190
181
  ? InternalComponent
@@ -209,7 +200,6 @@ export const PrismicLink = forwardRef(function PrismicLink<
209
200
  * Determines if a URL is internal or external.
210
201
  *
211
202
  * @param url - The URL to check if internal or external.
212
- *
213
203
  * @returns `true` if `url` is internal, `false` otherwise.
214
204
  */
215
205
  // TODO: This does not detect all relative URLs as internal such as `about` or `./about`. This function assumes relative URLs start with a "/" or "#"`.