@prismicio/react 3.2.1 → 3.2.2-canary.8d3ad6d

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 (47) hide show
  1. package/dist/PrismicImage.d.ts +66 -72
  2. package/dist/PrismicImage.d.ts.map +1 -0
  3. package/dist/PrismicImage.js +54 -47
  4. package/dist/PrismicImage.js.map +1 -1
  5. package/dist/PrismicLink.d.ts +71 -64
  6. package/dist/PrismicLink.d.ts.map +1 -0
  7. package/dist/PrismicLink.js +59 -40
  8. package/dist/PrismicLink.js.map +1 -1
  9. package/dist/PrismicRichText.d.ts +79 -100
  10. package/dist/PrismicRichText.d.ts.map +1 -0
  11. package/dist/PrismicRichText.js +125 -71
  12. package/dist/PrismicRichText.js.map +1 -1
  13. package/dist/PrismicTable.d.ts +58 -76
  14. package/dist/PrismicTable.d.ts.map +1 -0
  15. package/dist/PrismicTable.js +68 -21
  16. package/dist/PrismicTable.js.map +1 -1
  17. package/dist/PrismicText.d.ts +21 -25
  18. package/dist/PrismicText.d.ts.map +1 -0
  19. package/dist/PrismicText.js +30 -23
  20. package/dist/PrismicText.js.map +1 -1
  21. package/dist/PrismicToolbar.d.ts +21 -9
  22. package/dist/PrismicToolbar.d.ts.map +1 -0
  23. package/dist/PrismicToolbar.js +32 -19
  24. package/dist/PrismicToolbar.js.map +1 -1
  25. package/dist/SliceZone.d.ts +84 -83
  26. package/dist/SliceZone.d.ts.map +1 -0
  27. package/dist/SliceZone.js +54 -27
  28. package/dist/SliceZone.js.map +1 -1
  29. package/dist/index.d.ts +9 -15
  30. package/dist/index.js +4 -14
  31. package/dist/lib/devMsg.js +23 -6
  32. package/dist/lib/devMsg.js.map +1 -1
  33. package/dist/package.js +6 -0
  34. package/dist/package.js.map +1 -0
  35. package/package.json +21 -41
  36. package/src/PrismicImage.tsx +17 -25
  37. package/src/PrismicLink.tsx +21 -10
  38. package/src/PrismicRichText.tsx +26 -53
  39. package/src/PrismicTable.tsx +14 -36
  40. package/src/PrismicText.tsx +9 -18
  41. package/src/PrismicToolbar.tsx +10 -3
  42. package/src/SliceZone.tsx +46 -50
  43. package/src/lib/devMsg.ts +1 -1
  44. package/dist/index.js.map +0 -1
  45. package/dist/lib/devMsg.d.ts +0 -16
  46. package/dist/package.json.js +0 -5
  47. package/dist/package.json.js.map +0 -1
package/dist/SliceZone.js CHANGED
@@ -1,32 +1,59 @@
1
- import { jsxs, jsx, Fragment } from "react/jsx-runtime";
2
1
  import { DEV } from "esm-env";
2
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
+
4
+ //#region src/SliceZone.tsx
5
+ /**
6
+ * This slice component can be used as a reminder to provide a proper
7
+ * implementation.
8
+ *
9
+ * This is also the default React component rendered when a component mapping
10
+ * cannot be found in `<SliceZone>`.
11
+ */
3
12
  const TODOSliceComponent = ({ slice }) => {
4
- if (!DEV) {
5
- return null;
6
- }
7
- const type = "slice_type" in slice ? slice.slice_type : slice.type;
8
- console.warn(`[SliceZone] Could not find a component for Slice type "${type}"`, slice);
9
- return jsxs("section", { "data-slice-zone-todo-component": "", "data-slice-type": type, children: ["Could not find a component for Slice type “", type, "”"] });
13
+ if (!DEV) return null;
14
+ const type = "slice_type" in slice ? slice.slice_type : slice.type;
15
+ console.warn(`[SliceZone] Could not find a component for slice type "${type}"`, slice);
16
+ return /* @__PURE__ */ jsxs("section", {
17
+ "data-slice-zone-todo-component": "",
18
+ "data-slice-type": type,
19
+ children: [
20
+ "Could not find a component for slice type “",
21
+ type,
22
+ "”"
23
+ ]
24
+ });
10
25
  };
26
+ /**
27
+ * Renders slices in a slice zone as React components.
28
+ *
29
+ * @example
30
+ *
31
+ * ```tsx
32
+ * <SliceZone slices={page.data.slices} components={components} />;
33
+ * ```
34
+ *
35
+ * @see Learn how to create slices, use slice variations, and display slices: {@link https://prismic.io/docs/slices}
36
+ */
11
37
  const SliceZone = (props) => {
12
- const { slices = [], components = {}, defaultComponent, context = {} } = props;
13
- const renderedSlices = slices.map((slice, index) => {
14
- const type = "slice_type" in slice ? slice.slice_type : slice.type;
15
- const key = "id" in slice && slice.id ? slice.id : `${index}-${JSON.stringify(slice)}`;
16
- const Comp = components[type] || defaultComponent;
17
- if (!Comp) {
18
- return jsx(TODOSliceComponent, { slice }, key);
19
- }
20
- if (slice.__mapped) {
21
- const { __mapped, ...mappedProps } = slice;
22
- return jsx(Comp, { ...mappedProps }, key);
23
- }
24
- return jsx(Comp, { slice, index, slices, context }, key);
25
- });
26
- return jsx(Fragment, { children: renderedSlices });
38
+ const { slices = [], components = {}, defaultComponent, context = {} } = props;
39
+ return /* @__PURE__ */ jsx(Fragment, { children: slices.map((slice, index) => {
40
+ const type = "slice_type" in slice ? slice.slice_type : slice.type;
41
+ const key = "id" in slice && slice.id ? slice.id : `${index}-${JSON.stringify(slice)}`;
42
+ const Comp = components[type] || defaultComponent;
43
+ if (!Comp) return /* @__PURE__ */ jsx(TODOSliceComponent, { slice }, key);
44
+ if (slice.__mapped) {
45
+ const { __mapped, ...mappedProps } = slice;
46
+ return /* @__PURE__ */ jsx(Comp, { ...mappedProps }, key);
47
+ }
48
+ return /* @__PURE__ */ jsx(Comp, {
49
+ slice,
50
+ index,
51
+ slices,
52
+ context
53
+ }, key);
54
+ }) });
27
55
  };
28
- export {
29
- SliceZone,
30
- TODOSliceComponent
31
- };
32
- //# sourceMappingURL=SliceZone.js.map
56
+
57
+ //#endregion
58
+ export { SliceZone, TODOSliceComponent };
59
+ //# sourceMappingURL=SliceZone.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SliceZone.js","sources":["../src/SliceZone.tsx"],"sourcesContent":["import type { ComponentType, FC } from \"react\";\nimport type { Slice } from \"@prismicio/client\";\nimport { DEV } from \"esm-env\";\n\n/**\n * Returns the type of a `SliceLike` type.\n *\n * @typeParam Slice - The Slice from which the type will be extracted.\n */\ntype ExtractSliceType<TSlice extends SliceLike> = TSlice extends Slice\n\t? TSlice[\"slice_type\"]\n\t: TSlice extends SliceLikeGraphQL\n\t\t? TSlice[\"type\"]\n\t\t: never;\n\n/**\n * The minimum required properties to represent a Prismic Slice from the Prismic\n * Rest API V2 for the `unstable_mapSliceZone()` helper.\n *\n * @typeParam SliceType - Type name of the Slice.\n */\nexport type SliceLikeRestV2<TSliceType extends string = string> = Pick<\n\tSlice<TSliceType>,\n\t\"id\" | \"slice_type\"\n>;\n\n/**\n * The minimum required properties to represent a Prismic Slice from the Prismic\n * GraphQL API for the `unstable_mapSliceZone()` helper.\n *\n * @typeParam SliceType - Type name of the Slice.\n */\nexport type SliceLikeGraphQL<TSliceType extends string = string> = {\n\ttype: Slice<TSliceType>[\"slice_type\"];\n};\n\n/**\n * The minimum required properties to represent a Prismic Slice for the\n * `unstable_mapSliceZone()` helper.\n *\n * If using Prismic's Rest API V2, use the `Slice` export from\n * `@prismicio/client` for a full interface.\n *\n * @typeParam SliceType - Type name of the Slice.\n */\nexport type SliceLike<TSliceType extends string = string> = (\n\t| SliceLikeRestV2<TSliceType>\n\t| SliceLikeGraphQL<TSliceType>\n) & {\n\t/**\n\t * If `true`, this Slice has been modified from its original value using a\n\t * mapper and `@prismicio/client`'s `mapSliceZone()`.\n\t *\n\t * @internal\n\t */\n\t__mapped?: true;\n};\n\n/**\n * A looser version of the `SliceZone` type from `@prismicio/client` using\n * `SliceLike`.\n *\n * If using Prismic's Rest API V2, use the `SliceZone` export from\n * `@prismicio/client` for the full type.\n *\n * @typeParam TSlice - The type(s) of a Slice in the Slice Zone.\n */\nexport type SliceZoneLike<TSlice extends SliceLike = SliceLike> =\n\treadonly TSlice[];\n\n/**\n * React props for a component rendering content from a Prismic Slice using the\n * `<SliceZone>` component.\n *\n * @typeParam TSlice - The Slice passed as a prop.\n * @typeParam TContext - Arbitrary data passed to `<SliceZone>` and made\n * available to all Slice components.\n */\nexport type SliceComponentProps<\n\tTSlice extends SliceLike = SliceLike,\n\tTContext = unknown,\n> = {\n\t/** Slice data for this component. */\n\tslice: TSlice;\n\n\t/** The index of the Slice in the Slice Zone. */\n\tindex: number;\n\n\t/** All Slices from the Slice Zone to which the Slice belongs. */\n\t// TODO: We have to keep this list of Slices general due to circular\n\t// reference limtiations. If we had another generic to determine the full\n\t// union of Slice types, it would include TSlice. This causes TypeScript to\n\t// throw a compilation error.\n\tslices: SliceZoneLike<\n\t\tTSlice extends SliceLikeGraphQL ? SliceLikeGraphQL : SliceLikeRestV2\n\t>;\n\n\t/**\n\t * Arbitrary data passed to `<SliceZone>` and made available to all Slice\n\t * components.\n\t */\n\tcontext: TContext;\n};\n\n/**\n * A React component to be rendered for each instance of its Slice.\n *\n * @typeParam TSlice - The type(s) of a Slice in the Slice Zone.\n * @typeParam TContext - Arbitrary data made available to all Slice components.\n */\nexport type SliceComponentType<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n> = ComponentType<SliceComponentProps<TSlice, TContext>>;\n\n/**\n * A record of Slice types mapped to a React component. The component will be\n * rendered for each instance of its Slice.\n *\n * @deprecated This type is no longer used by `@prismicio/react`. Prefer using\n * `Record<string, SliceComponentType<any>>` instead.\n *\n * @typeParam TSlice - The type(s) of a Slice in the Slice Zone.\n * @typeParam TContext - Arbitrary data made available to all Slice components.\n */\nexport type SliceZoneComponents<\n\tTSlice extends SliceLike = SliceLike,\n\tTContext = unknown,\n> =\n\t// This is purposely not wrapped in Partial to ensure a component is provided\n\t// for all Slice types. <SliceZone> will render a default component if one is\n\t// not provided, but it *should* be a type error if an explicit component is\n\t// missing.\n\t//\n\t// If a developer purposely does not want to provide a component, they can\n\t// assign it to the TODOSliceComponent exported from this package. This\n\t// signals to future developers that it is a placeholder and should be\n\t// implemented.\n\t{\n\t\t[SliceType in ExtractSliceType<TSlice>]: SliceComponentType<\n\t\t\tExtract<TSlice, SliceLike<SliceType>> extends never\n\t\t\t\t? SliceLike\n\t\t\t\t: Extract<TSlice, SliceLike<SliceType>>,\n\t\t\tTContext\n\t\t>;\n\t};\n\n/**\n * React props for the `<SliceZone>` component.\n *\n * @typeParam TSlice - The type(s) of a Slice in the Slice Zone.\n * @typeParam TContext - Arbitrary data made available to all Slice components.\n */\nexport type SliceZoneProps<TContext = unknown> = {\n\t/** List of Slice data from the Slice Zone. */\n\tslices?: SliceZoneLike;\n\n\t/** A record mapping Slice types to React components. */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tcomponents?: Record<string, ComponentType<any>>;\n\n\t/**\n\t * The React component rendered if a component mapping from the `components`\n\t * prop cannot be found.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tdefaultComponent?: ComponentType<SliceComponentProps<any, TContext>>;\n\n\t/** Arbitrary data made available to all Slice components. */\n\tcontext?: TContext;\n};\n\n/**\n * This Slice component can be used as a reminder to provide a proper\n * implementation.\n *\n * This is also the default React component rendered when a component mapping\n * cannot be found in `<SliceZone>`.\n */\nexport const TODOSliceComponent = <TSlice extends SliceLike>({\n\tslice,\n}: {\n\tslice: TSlice;\n}) => {\n\tif (!DEV) {\n\t\treturn null;\n\t}\n\n\tconst type = \"slice_type\" in slice ? slice.slice_type : slice.type;\n\n\tconsole.warn(\n\t\t`[SliceZone] Could not find a component for Slice type \"${type}\"`,\n\t\tslice,\n\t);\n\n\treturn (\n\t\t<section data-slice-zone-todo-component=\"\" data-slice-type={type}>\n\t\t\tCould not find a component for Slice type &ldquo;{type}\n\t\t\t&rdquo;\n\t\t</section>\n\t);\n};\n\n/**\n * Renders content from a Prismic Slice Zone using React components for each\n * type of Slice.\n *\n * If a component is not provided for a type of Slice, a default component can\n * be provided. A fallback component is provided by default that will not be\n * rendered in a production build of your app.\n *\n * @typeParam TSlice - The type(s) of a Slice in the Slice Zone.\n * @typeParam TContext - Arbitrary data made available to all Slice components.\n *\n * @returns The Slice Zone's content as React components.\n *\n * @see Learn about Prismic Slices and Slice Zones {@link https://prismic.io/docs/core-concepts/slices}\n */\nexport const SliceZone: FC<SliceZoneProps> = (props) => {\n\tconst {\n\t\tslices = [],\n\t\tcomponents = {},\n\t\tdefaultComponent,\n\t\tcontext = {},\n\t} = props;\n\n\tconst renderedSlices = slices.map((slice, index) => {\n\t\tconst type = \"slice_type\" in slice ? slice.slice_type : slice.type;\n\n\t\tconst key =\n\t\t\t\"id\" in slice && slice.id\n\t\t\t\t? slice.id\n\t\t\t\t: `${index}-${JSON.stringify(slice)}`;\n\n\t\tconst Comp =\n\t\t\tcomponents[type as keyof typeof components] || defaultComponent;\n\n\t\tif (!Comp) {\n\t\t\treturn <TODOSliceComponent key={key} slice={slice} />;\n\t\t}\n\n\t\tif (slice.__mapped) {\n\t\t\tconst { __mapped, ...mappedProps } = slice;\n\n\t\t\treturn <Comp key={key} {...mappedProps} />;\n\t\t}\n\n\t\treturn (\n\t\t\t<Comp\n\t\t\t\tkey={key}\n\t\t\t\tslice={slice}\n\t\t\t\tindex={index}\n\t\t\t\tslices={slices}\n\t\t\t\tcontext={context}\n\t\t\t/>\n\t\t);\n\t});\n\n\treturn <>{renderedSlices}</>;\n};\n"],"names":["_jsxs","_jsx","_Fragment"],"mappings":";;AAoLO,MAAM,qBAAqB,CAA2B,EAC5D,YAGI;AACJ,MAAI,CAAC,KAAK;AACF,WAAA;AAAA,EAAA;AAGR,QAAM,OAAO,gBAAgB,QAAQ,MAAM,aAAa,MAAM;AAE9D,UAAQ,KACP,0DAA0D,IAAI,KAC9D,KAAK;AAGN,SACCA,oDAAwC,IAAE,mBAAkB,MACT,UAAA,CAAA,+CAAA,MAEzC,GAAA,GAAA;AAEZ;AAiBa,MAAA,YAAgC,CAAC,UAAS;AAChD,QAAA,EACL,SAAS,CAAA,GACT,aAAa,CAAA,GACb,kBACA,UAAU,OACP;AAEJ,QAAM,iBAAiB,OAAO,IAAI,CAAC,OAAO,UAAS;AAClD,UAAM,OAAO,gBAAgB,QAAQ,MAAM,aAAa,MAAM;AAE9D,UAAM,MACL,QAAQ,SAAS,MAAM,KACpB,MAAM,KACN,GAAG,KAAK,IAAI,KAAK,UAAU,KAAK,CAAC;AAE/B,UAAA,OACL,WAAW,IAA+B,KAAK;AAEhD,QAAI,CAAC,MAAM;AACV,aAAOC,IAAC,oBAA6B,EAAA,MAAA,GAAL,GAAG;AAAA,IAAA;AAGpC,QAAI,MAAM,UAAU;AACnB,YAAM,EAAE,UAAU,GAAG,YAAA,IAAgB;AAErC,aAAOA,IAAC,MAAI,EAAA,GAAe,YAAA,GAAT,GAAG;AAAA,IAAA;AAIrB,WAAAA,IAAC,MAAI,EAEJ,OACA,OACA,QACA,WAJK,GAAG;AAAA,EAAA,CAOV;AAED,SAAOA,IAAAC,UAAA,EAAA,UAAG,gBAAc;AACzB;"}
1
+ {"version":3,"file":"SliceZone.js","names":[],"sources":["../src/SliceZone.tsx"],"sourcesContent":["import type { ComponentType, FC, ReactNode } from \"react\";\nimport type { Slice } from \"@prismicio/client\";\nimport { DEV } from \"esm-env\";\n\n/**\n * Returns the type of a `SliceLike` type.\n *\n * @typeParam TSlice - The slice from which the type will be extracted.\n */\ntype ExtractSliceType<TSlice extends SliceLike> = TSlice extends Slice\n\t? TSlice[\"slice_type\"]\n\t: TSlice extends SliceLikeGraphQL\n\t\t? TSlice[\"type\"]\n\t\t: never;\n\n/**\n * The minimum required properties to represent a Prismic slice from the Prismic\n * Content API for the `mapSliceZone()` helper.\n *\n * @typeParam SliceType - Type name of the slice.\n */\nexport type SliceLikeRestV2<TSliceType extends string = string> = Pick<\n\tSlice<TSliceType>,\n\t\"id\" | \"slice_type\"\n>;\n\n/**\n * The minimum required properties to represent a Prismic slice from the Prismic\n * GraphQL API for the `mapSliceZone()` helper.\n *\n * @typeParam SliceType - Type name of the slice.\n */\nexport type SliceLikeGraphQL<TSliceType extends string = string> = {\n\ttype: Slice<TSliceType>[\"slice_type\"];\n};\n\n/**\n * The minimum required properties to represent a Prismic slice for the\n * `mapSliceZone()` helper.\n *\n * If using Prismic's Content API, use the `Slice` export from\n * `@prismicio/client` for a full interface.\n *\n * @typeParam SliceType - Type name of the slice.\n */\nexport type SliceLike<TSliceType extends string = string> = (\n\t| SliceLikeRestV2<TSliceType>\n\t| SliceLikeGraphQL<TSliceType>\n) & {\n\t/**\n\t * If `true`, this slice has been modified from its original value using a\n\t * mapper and `@prismicio/client`'s `mapSliceZone()`.\n\t *\n\t * @internal\n\t */\n\t__mapped?: true;\n};\n\n/**\n * A looser version of the `SliceZone` type from `@prismicio/client` using\n * `SliceLike`.\n *\n * If using Prismic's Content API, use the `SliceZone` export from\n * `@prismicio/client` for the full type.\n *\n * @typeParam TSlice - The type(s) of a slice in the slice zone.\n */\nexport type SliceZoneLike<TSlice extends SliceLike = SliceLike> =\n\treadonly TSlice[];\n\n/**\n * React props for a component rendering content from a Prismic slice using the\n * `<SliceZone>` component.\n *\n * @typeParam TSlice - The slice passed as a prop.\n * @typeParam TContext - Arbitrary data passed to `<SliceZone>` and made\n * available to all slice components.\n */\nexport type SliceComponentProps<\n\tTSlice extends SliceLike = SliceLike,\n\tTContext = unknown,\n> = {\n\t/** Slice data for this component. */\n\tslice: TSlice;\n\n\t/** The index of the slice in the slice zone. */\n\tindex: number;\n\n\t/** All slices from the slice zone to which the slice belongs. */\n\t// TODO: We have to keep this list of slices general due to circular\n\t// reference limtiations. If we had another generic to determine the full\n\t// union of slice types, it would include TSlice. This causes TypeScript to\n\t// throw a compilation error.\n\tslices: SliceZoneLike<\n\t\tTSlice extends SliceLikeGraphQL ? SliceLikeGraphQL : SliceLikeRestV2\n\t>;\n\n\t/**\n\t * Arbitrary data passed to `<SliceZone>` and made available to all slice\n\t * components.\n\t */\n\tcontext: TContext;\n};\n\n/**\n * A React component to be rendered for each instance of its slice.\n *\n * @typeParam TSlice - The type(s) of a slice in the slice zone.\n * @typeParam TContext - Arbitrary data made available to all slice components.\n */\nexport type SliceComponentType<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n> = ComponentType<SliceComponentProps<TSlice, TContext>>;\n\n/**\n * A record of slice types mapped to a React component. The component will be\n * rendered for each instance of its slice.\n *\n * @deprecated This type is no longer used by `@prismicio/react`. Prefer using\n * `Record<string, SliceComponentType<any>>` instead.\n *\n * @typeParam TSlice - The type(s) of a slice in the slice zone.\n * @typeParam TContext - Arbitrary data made available to all slice components.\n */\nexport type SliceZoneComponents<\n\tTSlice extends SliceLike = SliceLike,\n\tTContext = unknown,\n> =\n\t// This is purposely not wrapped in Partial to ensure a component is provided\n\t// for all slice types. <SliceZone> will render a default component if one is\n\t// not provided, but it *should* be a type error if an explicit component is\n\t// missing.\n\t//\n\t// If a developer purposely does not want to provide a component, they can\n\t// assign it to the TODOSliceComponent exported from this package. This\n\t// signals to future developers that it is a placeholder and should be\n\t// implemented.\n\t{\n\t\t[SliceType in ExtractSliceType<TSlice>]: SliceComponentType<\n\t\t\tExtract<TSlice, SliceLike<SliceType>> extends never\n\t\t\t\t? SliceLike\n\t\t\t\t: Extract<TSlice, SliceLike<SliceType>>,\n\t\t\tTContext\n\t\t>;\n\t};\n\n/**\n * React props for the `<SliceZone>` component.\n *\n * @typeParam TSlice - The type(s) of a slice in the slice zone.\n * @typeParam TContext - Arbitrary data made available to all slice components.\n */\nexport type SliceZoneProps<TContext = unknown> = {\n\t/** List of slice data from the slice zone. */\n\tslices?: SliceZoneLike;\n\n\t/** A record mapping slice types to React components. */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tcomponents?: Record<string, ComponentType<any>>;\n\n\t/**\n\t * The React component rendered if a component mapping from the `components`\n\t * prop cannot be found.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tdefaultComponent?: ComponentType<SliceComponentProps<any, TContext>>;\n\n\t/** Arbitrary data made available to all slice components. */\n\tcontext?: TContext;\n};\n\n/**\n * This slice component can be used as a reminder to provide a proper\n * implementation.\n *\n * This is also the default React component rendered when a component mapping\n * cannot be found in `<SliceZone>`.\n */\nexport const TODOSliceComponent = <TSlice extends SliceLike>({\n\tslice,\n}: {\n\tslice: TSlice;\n}): ReactNode => {\n\tif (!DEV) {\n\t\treturn null;\n\t}\n\n\tconst type = \"slice_type\" in slice ? slice.slice_type : slice.type;\n\n\tconsole.warn(\n\t\t`[SliceZone] Could not find a component for slice type \"${type}\"`,\n\t\tslice,\n\t);\n\n\treturn (\n\t\t<section data-slice-zone-todo-component=\"\" data-slice-type={type}>\n\t\t\tCould not find a component for slice type &ldquo;{type}\n\t\t\t&rdquo;\n\t\t</section>\n\t);\n};\n\n/**\n * Renders slices in a slice zone as React components.\n *\n * @example\n *\n * ```tsx\n * <SliceZone slices={page.data.slices} components={components} />;\n * ```\n *\n * @see Learn how to create slices, use slice variations, and display slices: {@link https://prismic.io/docs/slices}\n */\nexport const SliceZone: FC<SliceZoneProps> = (props) => {\n\tconst {\n\t\tslices = [],\n\t\tcomponents = {},\n\t\tdefaultComponent,\n\t\tcontext = {},\n\t} = props;\n\n\tconst renderedSlices = slices.map((slice, index) => {\n\t\tconst type = \"slice_type\" in slice ? slice.slice_type : slice.type;\n\n\t\tconst key =\n\t\t\t\"id\" in slice && slice.id\n\t\t\t\t? slice.id\n\t\t\t\t: `${index}-${JSON.stringify(slice)}`;\n\n\t\tconst Comp =\n\t\t\tcomponents[type as keyof typeof components] || defaultComponent;\n\n\t\tif (!Comp) {\n\t\t\treturn <TODOSliceComponent key={key} slice={slice} />;\n\t\t}\n\n\t\tif (slice.__mapped) {\n\t\t\tconst { __mapped, ...mappedProps } = slice;\n\n\t\t\treturn <Comp key={key} {...mappedProps} />;\n\t\t}\n\n\t\treturn (\n\t\t\t<Comp\n\t\t\t\tkey={key}\n\t\t\t\tslice={slice}\n\t\t\t\tindex={index}\n\t\t\t\tslices={slices}\n\t\t\t\tcontext={context}\n\t\t\t/>\n\t\t);\n\t});\n\n\treturn <>{renderedSlices}</>;\n};\n"],"mappings":";;;;;;;;;;;AAoLA,MAAa,sBAAgD,EAC5D,YAGgB;AAChB,KAAI,CAAC,IACJ,QAAO;CAGR,MAAM,OAAO,gBAAgB,QAAQ,MAAM,aAAa,MAAM;AAE9D,SAAQ,KACP,0DAA0D,KAAK,IAC/D,MACA;AAED,QACC,qBAAC;EAAQ,kCAA+B;EAAG,mBAAiB;;GAAM;GACf;GAAK;;GAE9C;;;;;;;;;;;;;AAeZ,MAAa,aAAiC,UAAU;CACvD,MAAM,EACL,SAAS,EAAE,EACX,aAAa,EAAE,EACf,kBACA,UAAU,EAAE,KACT;AAkCJ,QAAO,0CAhCgB,OAAO,KAAK,OAAO,UAAU;EACnD,MAAM,OAAO,gBAAgB,QAAQ,MAAM,aAAa,MAAM;EAE9D,MAAM,MACL,QAAQ,SAAS,MAAM,KACpB,MAAM,KACN,GAAG,MAAM,GAAG,KAAK,UAAU,MAAM;EAErC,MAAM,OACL,WAAW,SAAoC;AAEhD,MAAI,CAAC,KACJ,QAAO,oBAAC,sBAAoC,SAAZ,IAAqB;AAGtD,MAAI,MAAM,UAAU;GACnB,MAAM,EAAE,UAAU,GAAG,gBAAgB;AAErC,UAAO,oBAAC,QAAe,GAAI,eAAT,IAAwB;;AAG3C,SACC,oBAAC;GAEO;GACA;GACC;GACC;KAJJ,IAKJ;GAEF,GAE0B"}
package/dist/index.d.ts CHANGED
@@ -1,15 +1,9 @@
1
- export { PrismicLink } from "./PrismicLink.js";
2
- export type { PrismicLinkProps, LinkProps } from "./PrismicLink.js";
3
- export { PrismicTable } from "./PrismicTable.js";
4
- export type { PrismicTableProps } from "./PrismicTable.js";
5
- export { PrismicText } from "./PrismicText.js";
6
- export type { PrismicTextProps } from "./PrismicText.js";
7
- export { PrismicRichText } from "./PrismicRichText.js";
8
- export type { PrismicRichTextProps, JSXMapSerializer, JSXFunctionSerializer, } from "./PrismicRichText.js";
9
- export { Element } from "@prismicio/client/richtext";
10
- export { PrismicImage } from "./PrismicImage.js";
11
- export type { PrismicImageProps } from "./PrismicImage.js";
12
- export { SliceZone, TODOSliceComponent } from "./SliceZone.js";
13
- export type { SliceComponentProps, SliceComponentType, SliceLike, SliceLikeGraphQL, SliceLikeRestV2, SliceZoneComponents, SliceZoneLike, SliceZoneProps, } from "./SliceZone.js";
14
- export { PrismicToolbar } from "./PrismicToolbar.js";
15
- export type { PrismicToolbarProps } from "./PrismicToolbar.js";
1
+ import { LinkProps, PrismicLink, PrismicLinkProps } from "./PrismicLink.js";
2
+ import { JSXFunctionSerializer, JSXMapSerializer, PrismicRichText, PrismicRichTextProps } from "./PrismicRichText.js";
3
+ import { PrismicTable, PrismicTableProps } from "./PrismicTable.js";
4
+ import { PrismicText, PrismicTextProps } from "./PrismicText.js";
5
+ import { PrismicImage, PrismicImageProps } from "./PrismicImage.js";
6
+ import { SliceComponentProps, SliceComponentType, SliceLike, SliceLikeGraphQL, SliceLikeRestV2, SliceZone, SliceZoneComponents, SliceZoneLike, SliceZoneProps, TODOSliceComponent } from "./SliceZone.js";
7
+ import { PrismicToolbar, PrismicToolbarProps } from "./PrismicToolbar.js";
8
+ import { Element } from "@prismicio/client/richtext";
9
+ export { Element, type JSXFunctionSerializer, type JSXMapSerializer, type LinkProps, PrismicImage, type PrismicImageProps, PrismicLink, type PrismicLinkProps, PrismicRichText, type PrismicRichTextProps, PrismicTable, type PrismicTableProps, PrismicText, type PrismicTextProps, PrismicToolbar, type PrismicToolbarProps, type SliceComponentProps, type SliceComponentType, type SliceLike, type SliceLikeGraphQL, type SliceLikeRestV2, SliceZone, type SliceZoneComponents, type SliceZoneLike, type SliceZoneProps, TODOSliceComponent };
package/dist/index.js CHANGED
@@ -1,20 +1,10 @@
1
1
  import { PrismicLink } from "./PrismicLink.js";
2
+ import { PrismicRichText } from "./PrismicRichText.js";
2
3
  import { PrismicTable } from "./PrismicTable.js";
3
4
  import { PrismicText } from "./PrismicText.js";
4
- import { PrismicRichText } from "./PrismicRichText.js";
5
- import { Element } from "@prismicio/client/richtext";
6
5
  import { PrismicImage } from "./PrismicImage.js";
7
6
  import { SliceZone, TODOSliceComponent } from "./SliceZone.js";
8
7
  import { PrismicToolbar } from "./PrismicToolbar.js";
9
- export {
10
- Element,
11
- PrismicImage,
12
- PrismicLink,
13
- PrismicRichText,
14
- PrismicTable,
15
- PrismicText,
16
- PrismicToolbar,
17
- SliceZone,
18
- TODOSliceComponent
19
- };
20
- //# sourceMappingURL=index.js.map
8
+ import { Element } from "@prismicio/client/richtext";
9
+
10
+ export { Element, PrismicImage, PrismicLink, PrismicRichText, PrismicTable, PrismicText, PrismicToolbar, SliceZone, TODOSliceComponent };
@@ -1,8 +1,25 @@
1
- import { version } from "../package.json.js";
1
+ import { version } from "../package.js";
2
+
3
+ //#region src/lib/devMsg.ts
4
+ /**
5
+ * Returns a `prismic.dev/msg` URL for a given message slug.
6
+ *
7
+ * @example
8
+ *
9
+ * ```ts
10
+ * devMsg("missing-param");
11
+ * // => "https://prismic.dev/msg/react/v1.2.3/missing-param"
12
+ * ```
13
+ *
14
+ * @param slug - Slug for the message. This corresponds to a Markdown file in
15
+ * the Git repository's `/messages` directory.
16
+ *
17
+ * @returns The `prismic.dev/msg` URL for the given slug.
18
+ */
2
19
  function devMsg(slug) {
3
- return `https://prismic.dev/msg/react/v${version}/${slug}`;
20
+ return `https://prismic.dev/msg/react/v${version}/${slug}`;
4
21
  }
5
- export {
6
- devMsg
7
- };
8
- //# sourceMappingURL=devMsg.js.map
22
+
23
+ //#endregion
24
+ export { devMsg };
25
+ //# sourceMappingURL=devMsg.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"devMsg.js","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) {\n\treturn `https://prismic.dev/msg/react/v${version}/${slug}`;\n}\n"],"names":[],"mappings":";AAiBM,SAAU,OAAO,MAAY;AAC3B,SAAA,kCAAkC,OAAO,IAAI,IAAI;AACzD;"}
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"}
@@ -0,0 +1,6 @@
1
+ //#region package.json
2
+ var version = "3.2.2-canary.8d3ad6d";
3
+
4
+ //#endregion
5
+ export { version };
6
+ //# sourceMappingURL=package.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package.js","names":[],"sources":["../package.json"],"sourcesContent":[""],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismicio/react",
3
- "version": "3.2.1",
3
+ "version": "3.2.2-canary.8d3ad6d",
4
4
  "description": "React components and hooks to fetch and present Prismic content",
5
5
  "keywords": [
6
6
  "typescript",
@@ -16,12 +16,10 @@
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
  },
22
+ "types": "./dist/index.d.ts",
25
23
  "typesVersions": {
26
24
  "*": {
27
25
  "*": [
@@ -38,59 +36,41 @@
38
36
  "e2e-projects/*"
39
37
  ],
40
38
  "scripts": {
41
- "build": "vite build",
42
- "dev": "vite build --watch",
39
+ "build": "tsdown",
40
+ "dev": "tsdown --watch",
43
41
  "e2e": "playwright test",
44
42
  "e2e:ui": "npm run e2e -- --ui",
45
43
  "format": "prettier --write .",
46
- "lint": "eslint",
44
+ "lint": "oxlint --deny-warnings",
47
45
  "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",
46
+ "test": "npm run lint && npm run types && npm run build && npm run e2e",
54
47
  "types": "tsc --noEmit"
55
48
  },
56
49
  "dependencies": {
57
50
  "esm-env": "^1.2.2"
58
51
  },
59
52
  "devDependencies": {
60
- "@eslint/js": "^9.19.0",
61
- "@playwright/test": "^1.50.0",
53
+ "@playwright/test": "^1.57.0",
62
54
  "@prismicio/client": "^7.17.0",
63
- "@rollup/plugin-typescript": "^12.1.2",
64
- "@size-limit/preset-small-lib": "^11.1.6",
65
- "@types/react": "^19.0.8",
66
- "@types/react-dom": "^19.0.3",
67
- "@vitejs/plugin-react": "^4.3.4",
68
- "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",
75
- "playwright": "^1.50.0",
76
- "prettier": "^3.4.2",
77
- "prettier-plugin-jsdoc": "^1.3.2",
78
- "react": "^19.0.0",
79
- "react-dom": "^19.0.0",
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"
55
+ "@trivago/prettier-plugin-sort-imports": "^6.0.2",
56
+ "@types/react": "^19.2.8",
57
+ "@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"
87
67
  },
88
68
  "peerDependencies": {
89
69
  "@prismicio/client": "^7",
90
70
  "react": "^18 || ^19"
91
71
  },
92
72
  "engines": {
93
- "node": ">=18"
73
+ "node": ">=20"
94
74
  },
95
75
  "publishConfig": {
96
76
  "access": "public"
@@ -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,
@@ -29,7 +29,7 @@ export type PrismicImageProps = Omit<
29
29
  ComponentProps<"img">,
30
30
  "src" | "srcset" | "alt"
31
31
  > & {
32
- /** The Prismic Image field or thumbnail to render. */
32
+ /** The Prismic image field or thumbnail to render. */
33
33
  field: ImageFieldImage | null | undefined;
34
34
 
35
35
  /**
@@ -48,7 +48,7 @@ export type PrismicImageProps = Omit<
48
48
  alt?: "";
49
49
 
50
50
  /**
51
- * Declare an image as decorative only if the Image field does not have
51
+ * Declare an image as decorative only if the image field does not have
52
52
  * alternative text by providing `fallbackAlt=""`.
53
53
  *
54
54
  * See:
@@ -64,13 +64,13 @@ export type PrismicImageProps = Omit<
64
64
  } & (
65
65
  | {
66
66
  /**
67
- * Widths used to build a `srcset` value for the Image field.
67
+ * Widths (in pixels) used to build a `srcset` value for the image
68
+ * field.
68
69
  *
69
- * If a `widths` prop is not given or `"defaults"` is passed, the
70
- * following widths will be used: 640, 750, 828, 1080, 1200, 1920, 2048,
71
- * 3840.
70
+ * If omitted or set to `"defaults"`, the following widths will be used:
71
+ * 640, 750, 828, 1080, 1200, 1920, 2048, 3840.
72
72
  *
73
- * If the Image field contains responsive views, each responsive view
73
+ * If the image field contains responsive views, each responsive view
74
74
  * can be used as a width in the resulting `srcset` by passing
75
75
  * `"thumbnails"` as the `widths` prop.
76
76
  */
@@ -84,7 +84,7 @@ export type PrismicImageProps = Omit<
84
84
  /** Not used when the `widths` prop is used. */
85
85
  widths?: never;
86
86
  /**
87
- * Pixel densities used to build a `srcset` value for the Image field.
87
+ * Pixel densities used to build a `srcset` value for the image field.
88
88
  *
89
89
  * If a `pixelDensities` prop is passed `"defaults"`, the following
90
90
  * pixel densities will be used: 1, 2, 3.
@@ -98,23 +98,15 @@ export type PrismicImageProps = Omit<
98
98
  );
99
99
 
100
100
  /**
101
- * React component that renders an image from a Prismic Image field or one of
102
- * its thumbnails. It will automatically set the `alt` attribute using the Image
103
- * field's `alt` property.
101
+ * Renders an optimized image from a Prismic image field.
104
102
  *
105
- * By default, a widths-based srcset will be used to support responsive images.
106
- * This ensures only the smallest image needed for a browser is downloaded.
103
+ * @example
107
104
  *
108
- * To use a pixel-density-based srcset, use the `pixelDensities` prop. Default
109
- * pixel densities can be used by using `pixelDensities="defaults"`.
105
+ * ```tsx
106
+ * <PrismicImage field={slice.primary.photo} />;
107
+ * ```
110
108
  *
111
- * **Note**: If you are using a framework that has a native image component,
112
- * such as Next.js and Gatsby, prefer using those image components instead. They
113
- * can provide deeper framework integration than `<PrismicImage>`.
114
- *
115
- * @param props - Props for the component.
116
- *
117
- * @returns A responsive image component for the given Image field.
109
+ * @see Learn how to optimize images with imgix, use responsive images, and use framework-specific image components: {@link https://prismic.io/docs/fields/image}
118
110
  */
119
111
  export const PrismicImage: FC<PrismicImageProps> = forwardRef(
120
112
  function PrismicImage(
@@ -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 {
@@ -37,7 +37,7 @@ export interface LinkProps {
37
37
  */
38
38
  rel?: string;
39
39
 
40
- /** Children for the component. * */
40
+ /** Children for the component. */
41
41
  children?: ReactNode;
42
42
  }
43
43
 
@@ -56,13 +56,13 @@ export type PrismicLinkProps<
56
56
  rel?: string | AsLinkAttrsConfig["rel"];
57
57
 
58
58
  /**
59
- * The Link Resolver used to resolve links.
59
+ * The link resolver used to resolve links.
60
60
  *
61
61
  * @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.
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
64
  *
65
- * @see Learn about Link Resolvers and Route Resolvers {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver}
65
+ * @see Learn about link resolvers and route resolvers {@link https://prismic.io/docs/routes}
66
66
  */
67
67
  linkResolver?: LinkResolverFunction;
68
68
 
@@ -100,6 +100,17 @@ export type PrismicLinkProps<
100
100
  }
101
101
  );
102
102
 
103
+ /**
104
+ * Renders a link from a Prismic link field or page.
105
+ *
106
+ * @example
107
+ *
108
+ * ```tsx
109
+ * <PrismicLink field={slice.primary.link}>Click here</PrismicLink>;
110
+ * ```
111
+ *
112
+ * @see Learn how to display links and use variants for styling: {@link https://prismic.io/docs/fields/link}
113
+ */
103
114
  export const PrismicLink = forwardRef(function PrismicLink<
104
115
  InternalComponentProps = ComponentProps<typeof defaultComponent>,
105
116
  ExternalComponentProps = ComponentProps<typeof defaultComponent>,
@@ -1,64 +1,64 @@
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
- * A function mapping Rich Text block types to React Components. It is used to
30
- * render Rich Text or Title fields.
29
+ * A function mapping rich text block types to React Components. It is used to
30
+ * render rich text fields.
31
31
  *
32
- * @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/technologies/templating-rich-text-and-title-fields-javascript}
32
+ * @see Templating rich text fields {@link https://prismic.io/docs/fields/rich-text}
33
33
  */
34
34
  export type JSXFunctionSerializer = RichTextFunctionSerializer<ReactNode>;
35
35
 
36
36
  /**
37
- * A map of Rich Text block types to React Components. It is used to render Rich
38
- * Text or Title fields.
37
+ * A map of rich text block types to React Components. It is used to render rich
38
+ * text fields.
39
39
  *
40
- * @see Templating Rich Text and Title fields from Prismic {@link https://prismic.io/docs/technologies/templating-rich-text-and-title-fields-javascript}
40
+ * @see Templating rich text fields {@link https://prismic.io/docs/fields/rich-text}
41
41
  */
42
42
  export type JSXMapSerializer = RichTextMapSerializer<ReactNode>;
43
43
 
44
44
  /** Props for `<PrismicRichText>`. */
45
45
  export type PrismicRichTextProps = {
46
- /** The Prismic Rich Text field to render. */
46
+ /** The Prismic rich text field to render. */
47
47
  field: RichTextField | null | undefined;
48
48
 
49
49
  /**
50
- * The Link Resolver used to resolve links.
50
+ * The link resolver used to resolve links.
51
51
  *
52
52
  * @remarks
53
- * If your app uses Route Resolvers when querying for your Prismic
54
- * repository's content, a Link Resolver does not need to be provided.
53
+ * If your app uses route resolvers when querying for your Prismic
54
+ * repository's content, a link resolver does not need to be provided.
55
55
  *
56
- * @see Learn about Link Resolvers and Route Resolvers {@link https://io/docs/core-concepts/link-resolver-route-resolver}
56
+ * @see Learn about link resolvers and route resolvers {@link https://prismic.io/docs/routes}
57
57
  */
58
58
  linkResolver?: LinkResolverFunction;
59
59
 
60
60
  /**
61
- * A map or function that maps a Rich Text block to a React component.
61
+ * A map or function that maps a rich text block to a React component.
62
62
  *
63
63
  * @remarks
64
64
  * Prefer using a map serializer over the function serializer when possible.
@@ -243,42 +243,15 @@ const createDefaultSerializer = (
243
243
  });
244
244
 
245
245
  /**
246
- * React component that renders content from a Prismic Rich Text field. By
247
- * default, HTML elements are rendered for each piece of content. A `heading1`
248
- * block will render an `<h1>` HTML element, for example. Links will use
249
- * `<PrismicLink>` by default which can be customized using the
250
- * `internalLinkComponent` and `externalLinkComponent` props.
246
+ * Renders content from a Prismic rich text field as React components.
251
247
  *
252
- * To customize the components that are rendered, provide a map or function
253
- * serializer to the `components` prop.
248
+ * @example
254
249
  *
255
- * @remarks
256
- * This component returns a React fragment with no wrapping element around the
257
- * content. If you need a wrapper, add a component around `<PrismicRichText>`.
258
- *
259
- * @example Rendering a Rich Text field using the default HTMl elements.
260
- *
261
- * ```jsx
262
- * <PrismicRichText field={document.data.content} />;
250
+ * ```tsx
251
+ * <PrismicRichText field={slice.primary.text} />;
263
252
  * ```
264
253
  *
265
- * @example Rendering a Rich Text field using a custom set of React components.
266
- *
267
- * ```jsx
268
- * <PrismicRichText
269
- * field={document.data.content}
270
- * components={{
271
- * heading1: ({ children }) => <Heading>{children}</Heading>,
272
- * }}
273
- * />;
274
- * ```
275
- *
276
- * @param props - Props for the component.
277
- *
278
- * @returns The Rich Text field's content as React components.
279
- *
280
- * @see Learn about Rich Text fields {@link https://io/docs/core-concepts/rich-text-title}
281
- * @see Learn about Rich Text serializers {@link https://io/docs/core-concepts/html-serializer}
254
+ * @see Learn how to style rich text, use custom components, and use labels for custom formatting: {@link https://prismic.io/docs/fields/rich-text}
282
255
  */
283
256
  export const PrismicRichText: FC<PrismicRichTextProps> = (props) => {
284
257
  const {