@prismicio/next 2.2.0-pr.123.0d5ddd7 → 2.2.0-pr.123.1c009e2

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.
@@ -2,14 +2,14 @@
2
2
 
3
3
  const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
4
4
  const require_resolveDefaultExport = require('./lib/resolveDefaultExport.cjs');
5
- const require_devMsg = require('./lib/devMsg.cjs');
6
5
  const require_imgixLoader = require('./imgixLoader.cjs');
6
+ const require_devMsg = require('./lib/devMsg.cjs');
7
7
  let _prismicio_client = require("@prismicio/client");
8
8
  let react = require("react");
9
9
  let react_jsx_runtime = require("react/jsx-runtime");
10
+ let imgix_url_builder = require("imgix-url-builder");
10
11
  let next_image = require("next/image");
11
12
  next_image = require_rolldown_runtime.__toESM(next_image);
12
- let imgix_url_builder = require("imgix-url-builder");
13
13
 
14
14
  //#region src/PrismicImage.tsx
15
15
  const castInt = (input) => {
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicImage.cjs","names":["PrismicImage","imgixLoader","devMsg","isFilled","resolveDefaultExport","Image"],"sources":["../src/PrismicImage.tsx"],"sourcesContent":["\"use client\";\n\nimport type {\n\tForwardRefExoticComponent,\n\tPropsWithoutRef,\n\tRefAttributes} from \"react\";\nimport {\n\tforwardRef\n} from \"react\";\nimport type { ImageProps } from \"next/image\";\nimport Image from \"next/image\";\nimport type { ImgixURLParams } from \"imgix-url-builder\";\nimport { buildURL } from \"imgix-url-builder\";\nimport type { ImageFieldImage} from \"@prismicio/client\";\nimport { isFilled } from \"@prismicio/client\";\n\nimport { devMsg } from \"./lib/devMsg\";\nimport { resolveDefaultExport } from \"./lib/resolveDefaultExport\";\n\nimport { imgixLoader } from \"./imgixLoader\";\n\nconst castInt = (input: string | number | undefined): number | undefined => {\n\tif (typeof input === \"number\" || typeof input === \"undefined\") {\n\t\treturn input;\n\t} else {\n\t\tconst parsed = Number.parseInt(input);\n\n\t\tif (Number.isNaN(parsed)) {\n\t\t\treturn undefined;\n\t\t} else {\n\t\t\treturn parsed;\n\t\t}\n\t}\n};\n\nexport type PrismicImageProps = Omit<\n\tImageProps,\n\t\"src\" | \"alt\" | \"loader\"\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 * Rendered when the field is empty. If a fallback is not given, `null` will\n\t * be rendered.\n\t */\n\tfallback?: React.ReactNode;\n\n\tloader?: ImageProps[\"loader\"] | null;\n};\n\n/**\n * React component that renders an image from a Prismic Image field or one of\n * its thumbnails using `next/image`. It will automatically set the `alt`\n * attribute using the Image field's `alt` property.\n *\n * It uses an Imgix URL-based loader by default. A custom loader can be provided\n * with the `loader` prop. If you would like to use the Next.js Image\n * Optimization API instead, set `loader={undefined}`.\n *\n * @param props - Props for the component.\n *\n * @returns A responsive image component using `next/image` for the given Image\n * field.\n *\n * @see To learn more about `next/image`, see: https://nextjs.org/docs/api-reference/next/image\n */\n// The type annotation is necessary to avoid a type reference issue.\nexport const PrismicImage: ForwardRefExoticComponent<\n\tPropsWithoutRef<PrismicImageProps> & RefAttributes<HTMLImageElement>\n> = forwardRef<HTMLImageElement, PrismicImageProps>(\n\tfunction PrismicImage(\n\t\t{\n\t\t\tfield,\n\t\t\timgixParams = {},\n\t\t\talt,\n\t\t\tfallbackAlt,\n\t\t\tfill,\n\t\t\twidth,\n\t\t\theight,\n\t\t\tfallback = null,\n\t\t\tloader = imgixLoader,\n\t\t\t...restProps\n\t\t},\n\t\tref,\n\t) {\n\t\tif (process.env.NODE_ENV === \"development\") {\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\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\tconst src = buildURL(field.url, imgixParams as ImgixURLParams);\n\n\t\tconst ar = field.dimensions.width / field.dimensions.height;\n\n\t\tconst castedWidth = castInt(width);\n\t\tconst castedHeight = castInt(height);\n\n\t\tlet resolvedWidth = castedWidth ?? field.dimensions.width;\n\t\tlet resolvedHeight = castedHeight ?? field.dimensions.height;\n\n\t\tif (castedWidth != null && castedHeight == null) {\n\t\t\tresolvedHeight = castedWidth / ar;\n\t\t} else if (castedWidth == null && castedHeight != null) {\n\t\t\tresolvedWidth = castedHeight * ar;\n\t\t}\n\n\t\t// A non-null assertion is required since we can't statically\n\t\t// know if an alt attribute is available.\n\t\tconst resolvedAlt = (alt ?? (field.alt || fallbackAlt))!;\n\n\t\tif (\n\t\t\tprocess.env.NODE_ENV === \"development\" &&\n\t\t\ttypeof resolvedAlt !== \"string\"\n\t\t) {\n\t\t\tconsole.error(\n\t\t\t\t`[PrismicImage] The following image is missing an \"alt\" property. Please add Alternative Text to the image in Prismic. To mark the image as decorative instead, add one of \\`alt=\"\"\\` or \\`fallbackAlt=\"\"\\`.`,\n\t\t\t\tsrc,\n\t\t\t);\n\t\t}\n\n\t\tconst ResolvedImage = resolveDefaultExport(Image);\n\n\t\treturn (\n\t\t\t<ResolvedImage\n\t\t\t\tref={ref}\n\t\t\t\tsrc={src}\n\t\t\t\twidth={fill ? undefined : resolvedWidth}\n\t\t\t\theight={fill ? undefined : resolvedHeight}\n\t\t\t\talt={resolvedAlt}\n\t\t\t\tfill={fill}\n\t\t\t\tloader={loader === null ? undefined : loader}\n\t\t\t\t{...restProps}\n\t\t\t/>\n\t\t);\n\t},\n);\n"],"mappings":";;;;;;;;;;;;;;AAqBA,MAAM,WAAW,UAA2D;AAC3E,KAAI,OAAO,UAAU,YAAY,OAAO,UAAU,YACjD,QAAO;MACD;EACN,MAAM,SAAS,OAAO,SAAS,MAAM;AAErC,MAAI,OAAO,MAAM,OAAO,CACvB;MAEA,QAAO;;;;;;;;;;;;;;;;;;;AA8DV,MAAa,qCAGZ,SAASA,eACR,EACC,OACA,cAAc,EAAE,EAChB,KACA,aACA,MACA,OACA,QACA,WAAW,MACX,SAASC,iCACT,GAAG,aAEJ,KACC;AACD,KAAI,QAAQ,IAAI,aAAa,eAAe;AAC3C,MAAI,OAAO,QAAQ,YAAY,QAAQ,GACtC,SAAQ,KACP,qQAAqQC,sBACpQ,8BACA,GACD;AAGF,MAAI,OAAO,gBAAgB,YAAY,gBAAgB,GACtD,SAAQ,KACP,qSAAqSA,sBACpS,8BACA,GACD;;AAIH,KAAI,CAACC,2BAAS,eAAe,MAAM,CAClC,QAAO,mFAAG,WAAY;CAGvB,MAAM,sBAAsB;AAC5B,MAAK,MAAM,KAAK,YACf,KAAI,oBAAoB,OAA2C,KAClE,qBAAoB,KAAyC;CAI/D,MAAM,sCAAe,MAAM,KAAK,YAA8B;CAE9D,MAAM,KAAK,MAAM,WAAW,QAAQ,MAAM,WAAW;CAErD,MAAM,cAAc,QAAQ,MAAM;CAClC,MAAM,eAAe,QAAQ,OAAO;CAEpC,IAAI,gBAAgB,eAAe,MAAM,WAAW;CACpD,IAAI,iBAAiB,gBAAgB,MAAM,WAAW;AAEtD,KAAI,eAAe,QAAQ,gBAAgB,KAC1C,kBAAiB,cAAc;UACrB,eAAe,QAAQ,gBAAgB,KACjD,iBAAgB,eAAe;CAKhC,MAAM,cAAe,QAAQ,MAAM,OAAO;AAE1C,KACC,QAAQ,IAAI,aAAa,iBACzB,OAAO,gBAAgB,SAEvB,SAAQ,MACP,+MACA,IACA;AAKF,QACC,2CAHqBC,kDAAqBC,mBAAM;EAI1C;EACA;EACL,OAAO,OAAO,SAAY;EAC1B,QAAQ,OAAO,SAAY;EAC3B,KAAK;EACC;EACN,QAAQ,WAAW,OAAO,SAAY;EACtC,GAAI;GACH;EAGJ"}
1
+ {"version":3,"file":"PrismicImage.cjs","names":["PrismicImage","imgixLoader","devMsg","isFilled","resolveDefaultExport","Image"],"sources":["../src/PrismicImage.tsx"],"sourcesContent":["\"use client\";\n\nimport { imgixLoader } from \"./imgixLoader\";\nimport { devMsg } from \"./lib/devMsg\";\nimport { resolveDefaultExport } from \"./lib/resolveDefaultExport\";\nimport type { ImageFieldImage } from \"@prismicio/client\";\nimport { isFilled } from \"@prismicio/client\";\nimport type { ImgixURLParams } from \"imgix-url-builder\";\nimport { buildURL } from \"imgix-url-builder\";\nimport type { ImageProps } from \"next/image\";\nimport Image from \"next/image\";\nimport type {\n\tForwardRefExoticComponent,\n\tPropsWithoutRef,\n\tRefAttributes,\n} from \"react\";\nimport { forwardRef } from \"react\";\n\n/**\n * @deprecated Use `PrismicImage` instead.\n */\nexport { PrismicImage as PrismicNextImage };\n\n/**\n * @deprecated Use `PrismicImageProps` instead.\n */\nexport type { PrismicImageProps as PrismicNextImageProps };\n\nconst castInt = (input: string | number | undefined): number | undefined => {\n\tif (typeof input === \"number\" || typeof input === \"undefined\") {\n\t\treturn input;\n\t} else {\n\t\tconst parsed = Number.parseInt(input);\n\n\t\tif (Number.isNaN(parsed)) {\n\t\t\treturn undefined;\n\t\t} else {\n\t\t\treturn parsed;\n\t\t}\n\t}\n};\n\nexport type PrismicImageProps = Omit<ImageProps, \"src\" | \"alt\" | \"loader\"> & {\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 * Rendered when the field is empty. If a fallback is not given, `null` will\n\t * be rendered.\n\t */\n\tfallback?: React.ReactNode;\n\n\tloader?: ImageProps[\"loader\"] | null;\n};\n\n/**\n * React component that renders an image from a Prismic Image field or one of\n * its thumbnails using `next/image`. It will automatically set the `alt`\n * attribute using the Image field's `alt` property.\n *\n * It uses an Imgix URL-based loader by default. A custom loader can be provided\n * with the `loader` prop. If you would like to use the Next.js Image\n * Optimization API instead, set `loader={undefined}`.\n *\n * @param props - Props for the component.\n *\n * @returns A responsive image component using `next/image` for the given Image\n * field.\n *\n * @see To learn more about `next/image`, see: https://nextjs.org/docs/api-reference/next/image\n */\n// The type annotation is necessary to avoid a type reference issue.\nexport const PrismicImage: ForwardRefExoticComponent<\n\tPropsWithoutRef<PrismicImageProps> & RefAttributes<HTMLImageElement>\n> = forwardRef<HTMLImageElement, PrismicImageProps>(function PrismicImage(\n\t{\n\t\tfield,\n\t\timgixParams = {},\n\t\talt,\n\t\tfallbackAlt,\n\t\tfill,\n\t\twidth,\n\t\theight,\n\t\tfallback = null,\n\t\tloader = imgixLoader,\n\t\t...restProps\n\t},\n\tref,\n) {\n\tif (process.env.NODE_ENV === \"development\") {\n\t\tif (typeof alt === \"string\" && alt !== \"\") {\n\t\t\tconsole.warn(\n\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\"alt-must-be-an-empty-string\",\n\t\t\t\t)}`,\n\t\t\t);\n\t\t}\n\n\t\tif (typeof fallbackAlt === \"string\" && fallbackAlt !== \"\") {\n\t\t\tconsole.warn(\n\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\"alt-must-be-an-empty-string\",\n\t\t\t\t)}`,\n\t\t\t);\n\t\t}\n\t}\n\n\tif (!isFilled.imageThumbnail(field)) {\n\t\treturn <>{fallback}</>;\n\t}\n\n\tconst resolvedImgixParams = imgixParams;\n\tfor (const x in imgixParams) {\n\t\tif (resolvedImgixParams[x as keyof typeof resolvedImgixParams] === null) {\n\t\t\tresolvedImgixParams[x as keyof typeof resolvedImgixParams] = undefined;\n\t\t}\n\t}\n\n\tconst src = buildURL(field.url, imgixParams as ImgixURLParams);\n\n\tconst ar = field.dimensions.width / field.dimensions.height;\n\n\tconst castedWidth = castInt(width);\n\tconst castedHeight = castInt(height);\n\n\tlet resolvedWidth = castedWidth ?? field.dimensions.width;\n\tlet resolvedHeight = castedHeight ?? field.dimensions.height;\n\n\tif (castedWidth != null && castedHeight == null) {\n\t\tresolvedHeight = castedWidth / ar;\n\t} else if (castedWidth == null && castedHeight != null) {\n\t\tresolvedWidth = castedHeight * ar;\n\t}\n\n\t// A non-null assertion is required since we can't statically\n\t// know if an alt attribute is available.\n\tconst resolvedAlt = (alt ?? (field.alt || fallbackAlt))!;\n\n\tif (\n\t\tprocess.env.NODE_ENV === \"development\" &&\n\t\ttypeof resolvedAlt !== \"string\"\n\t) {\n\t\tconsole.error(\n\t\t\t`[PrismicImage] The following image is missing an \"alt\" property. Please add Alternative Text to the image in Prismic. To mark the image as decorative instead, add one of \\`alt=\"\"\\` or \\`fallbackAlt=\"\"\\`.`,\n\t\t\tsrc,\n\t\t);\n\t}\n\n\tconst ResolvedImage = resolveDefaultExport(Image);\n\n\treturn (\n\t\t<ResolvedImage\n\t\t\tref={ref}\n\t\t\tsrc={src}\n\t\t\twidth={fill ? undefined : resolvedWidth}\n\t\t\theight={fill ? undefined : resolvedHeight}\n\t\t\talt={resolvedAlt}\n\t\t\tfill={fill}\n\t\t\tloader={loader === null ? undefined : loader}\n\t\t\t{...restProps}\n\t\t/>\n\t);\n});\n"],"mappings":";;;;;;;;;;;;;;AA4BA,MAAM,WAAW,UAA2D;AAC3E,KAAI,OAAO,UAAU,YAAY,OAAO,UAAU,YACjD,QAAO;MACD;EACN,MAAM,SAAS,OAAO,SAAS,MAAM;AAErC,MAAI,OAAO,MAAM,OAAO,CACvB;MAEA,QAAO;;;;;;;;;;;;;;;;;;;AA2DV,MAAa,qCAEuC,SAASA,eAC5D,EACC,OACA,cAAc,EAAE,EAChB,KACA,aACA,MACA,OACA,QACA,WAAW,MACX,SAASC,iCACT,GAAG,aAEJ,KACC;AACD,KAAI,QAAQ,IAAI,aAAa,eAAe;AAC3C,MAAI,OAAO,QAAQ,YAAY,QAAQ,GACtC,SAAQ,KACP,qQAAqQC,sBACpQ,8BACA,GACD;AAGF,MAAI,OAAO,gBAAgB,YAAY,gBAAgB,GACtD,SAAQ,KACP,qSAAqSA,sBACpS,8BACA,GACD;;AAIH,KAAI,CAACC,2BAAS,eAAe,MAAM,CAClC,QAAO,mFAAG,WAAY;CAGvB,MAAM,sBAAsB;AAC5B,MAAK,MAAM,KAAK,YACf,KAAI,oBAAoB,OAA2C,KAClE,qBAAoB,KAAyC;CAI/D,MAAM,sCAAe,MAAM,KAAK,YAA8B;CAE9D,MAAM,KAAK,MAAM,WAAW,QAAQ,MAAM,WAAW;CAErD,MAAM,cAAc,QAAQ,MAAM;CAClC,MAAM,eAAe,QAAQ,OAAO;CAEpC,IAAI,gBAAgB,eAAe,MAAM,WAAW;CACpD,IAAI,iBAAiB,gBAAgB,MAAM,WAAW;AAEtD,KAAI,eAAe,QAAQ,gBAAgB,KAC1C,kBAAiB,cAAc;UACrB,eAAe,QAAQ,gBAAgB,KACjD,iBAAgB,eAAe;CAKhC,MAAM,cAAe,QAAQ,MAAM,OAAO;AAE1C,KACC,QAAQ,IAAI,aAAa,iBACzB,OAAO,gBAAgB,SAEvB,SAAQ,MACP,+MACA,IACA;AAKF,QACC,2CAHqBC,kDAAqBC,mBAAM;EAI1C;EACA;EACL,OAAO,OAAO,SAAY;EAC1B,QAAQ,OAAO,SAAY;EAC3B,KAAK;EACC;EACN,QAAQ,WAAW,OAAO,SAAY;EACtC,GAAI;GACH;EAEF"}
@@ -1,9 +1,10 @@
1
1
  import { ForwardRefExoticComponent, PropsWithoutRef, RefAttributes } from "react";
2
- import { ImageProps } from "next/image";
3
- import { ImgixURLParams } from "imgix-url-builder";
4
2
  import { ImageFieldImage } from "@prismicio/client";
3
+ import { ImgixURLParams } from "imgix-url-builder";
4
+ import { ImageProps } from "next/image";
5
5
 
6
6
  //#region src/PrismicImage.d.ts
7
+
7
8
  type PrismicImageProps = Omit<ImageProps, "src" | "alt" | "loader"> & {
8
9
  /** The Prismic Image field or thumbnail to render. */
9
10
  field: ImageFieldImage | null | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicLink.cjs","names":["PrismicLink","resolveDefaultExport","Link"],"sources":["../src/PrismicLink.tsx"],"sourcesContent":["import type { ComponentProps} from \"react\";\nimport { forwardRef } from \"react\";\nimport Link from \"next/link\";\nimport type {\n\tAsLinkAttrsConfig,\n\tLinkField,\n\tLinkResolverFunction,\n\tPrismicDocument} from \"@prismicio/client\";\nimport {\n\tasLinkAttrs,\n} from \"@prismicio/client\";\n\nimport { resolveDefaultExport } from \"./lib/resolveDefaultExport\";\n\nexport type PrismicLinkProps = Omit<\n\tComponentProps<typeof Link>,\n\t\"field\" | \"document\" | \"href\" | \"rel\"\n> & {\n\tlinkResolver?: LinkResolverFunction;\n\trel?: string | AsLinkAttrsConfig[\"rel\"];\n} & (\n\t\t| {\n\t\t\t\tfield: LinkField | null | undefined;\n\t\t\t\tdocument?: never;\n\t\t\t\thref?: never;\n\t\t }\n\t\t| {\n\t\t\t\tfield?: never;\n\t\t\t\tdocument: PrismicDocument | null | undefined;\n\t\t\t\thref?: never;\n\t\t }\n\t\t| {\n\t\t\t\tfield?: never;\n\t\t\t\tdocument?: never;\n\t\t\t\thref: ComponentProps<typeof Link>[\"href\"];\n\t\t }\n\t);\n\nexport const PrismicLink = forwardRef<\n\tHTMLAnchorElement,\n\tPrismicLinkProps\n>(function PrismicLink(props, ref) {\n\tconst { field, document, linkResolver, children, ...restProps } = props;\n\tconst {\n\t\thref: computedHref,\n\t\trel: computedRel,\n\t\t...attrs\n\t} = asLinkAttrs(field ?? document, {\n\t\tlinkResolver,\n\t\trel: typeof restProps.rel === \"function\" ? restProps.rel : undefined,\n\t});\n\n\tconst href = (\"href\" in restProps ? restProps.href : computedHref) || \"\";\n\n\tlet rel = computedRel;\n\tif (\"rel\" in restProps && typeof restProps.rel !== \"function\") {\n\t\trel = restProps.rel;\n\t}\n\n\tconst ResolvedLink = resolveDefaultExport(Link);\n\n\treturn (\n\t\t<ResolvedLink ref={ref} {...attrs} {...restProps} href={href} rel={rel}>\n\t\t\t{\"children\" in props ? children : field?.text}\n\t\t</ResolvedLink>\n\t);\n});\n"],"mappings":";;;;;;;;;AAsCA,MAAa,oCAGX,SAASA,cAAY,OAAO,KAAK;CAClC,MAAM,EAAE,OAAO,UAAU,cAAc,UAAU,GAAG,cAAc;CAClE,MAAM,EACL,MAAM,cACN,KAAK,aACL,GAAG,6CACY,SAAS,UAAU;EAClC;EACA,KAAK,OAAO,UAAU,QAAQ,aAAa,UAAU,MAAM;EAC3D,CAAC;CAEF,MAAM,QAAQ,UAAU,YAAY,UAAU,OAAO,iBAAiB;CAEtE,IAAI,MAAM;AACV,KAAI,SAAS,aAAa,OAAO,UAAU,QAAQ,WAClD,OAAM,UAAU;AAKjB,QACC,2CAHoBC,kDAAqBC,kBAAK;EAG3B;EAAK,GAAI;EAAO,GAAI;EAAiB;EAAW;YACjE,cAAc,QAAQ,WAAW,OAAO;GAC3B;EAEf"}
1
+ {"version":3,"file":"PrismicLink.cjs","names":["PrismicLink","resolveDefaultExport","Link"],"sources":["../src/PrismicLink.tsx"],"sourcesContent":["import { resolveDefaultExport } from \"./lib/resolveDefaultExport\";\nimport type {\n\tAsLinkAttrsConfig,\n\tLinkField,\n\tLinkResolverFunction,\n\tPrismicDocument,\n} from \"@prismicio/client\";\nimport { asLinkAttrs } from \"@prismicio/client\";\nimport Link from \"next/link\";\nimport type { ComponentProps } from \"react\";\nimport { forwardRef } from \"react\";\n\n/**\n * @deprecated Use `PrismicLink` instead.\n */\nexport { PrismicLink as PrismicNextLink } from \"./PrismicLink\";\n\n/**\n * @deprecated Use `PrismicLinkProps` instead.\n */\nexport type { PrismicLinkProps as PrismicNextLinkProps } from \"./PrismicLink\";\n\nexport type PrismicLinkProps = Omit<\n\tComponentProps<typeof Link>,\n\t\"field\" | \"document\" | \"href\" | \"rel\"\n> & {\n\tlinkResolver?: LinkResolverFunction;\n\trel?: string | AsLinkAttrsConfig[\"rel\"];\n} & (\n\t\t| {\n\t\t\t\tfield: LinkField | null | undefined;\n\t\t\t\tdocument?: never;\n\t\t\t\thref?: never;\n\t\t }\n\t\t| {\n\t\t\t\tfield?: never;\n\t\t\t\tdocument: PrismicDocument | null | undefined;\n\t\t\t\thref?: never;\n\t\t }\n\t\t| {\n\t\t\t\tfield?: never;\n\t\t\t\tdocument?: never;\n\t\t\t\thref: ComponentProps<typeof Link>[\"href\"];\n\t\t }\n\t);\n\nexport const PrismicLink = forwardRef<HTMLAnchorElement, PrismicLinkProps>(\n\tfunction PrismicLink(props, ref) {\n\t\tconst { field, document, linkResolver, children, ...restProps } = props;\n\t\tconst {\n\t\t\thref: computedHref,\n\t\t\trel: computedRel,\n\t\t\t...attrs\n\t\t} = asLinkAttrs(field ?? document, {\n\t\t\tlinkResolver,\n\t\t\trel: typeof restProps.rel === \"function\" ? restProps.rel : undefined,\n\t\t});\n\n\t\tconst href = (\"href\" in restProps ? restProps.href : computedHref) || \"\";\n\n\t\tlet rel = computedRel;\n\t\tif (\"rel\" in restProps && typeof restProps.rel !== \"function\") {\n\t\t\trel = restProps.rel;\n\t\t}\n\n\t\tconst ResolvedLink = resolveDefaultExport(Link);\n\n\t\treturn (\n\t\t\t<ResolvedLink ref={ref} {...attrs} {...restProps} href={href} rel={rel}>\n\t\t\t\t{\"children\" in props ? children : field?.text}\n\t\t\t</ResolvedLink>\n\t\t);\n\t},\n);\n"],"mappings":";;;;;;;;;AA8CA,MAAa,oCACZ,SAASA,cAAY,OAAO,KAAK;CAChC,MAAM,EAAE,OAAO,UAAU,cAAc,UAAU,GAAG,cAAc;CAClE,MAAM,EACL,MAAM,cACN,KAAK,aACL,GAAG,6CACY,SAAS,UAAU;EAClC;EACA,KAAK,OAAO,UAAU,QAAQ,aAAa,UAAU,MAAM;EAC3D,CAAC;CAEF,MAAM,QAAQ,UAAU,YAAY,UAAU,OAAO,iBAAiB;CAEtE,IAAI,MAAM;AACV,KAAI,SAAS,aAAa,OAAO,UAAU,QAAQ,WAClD,OAAM,UAAU;AAKjB,QACC,2CAHoBC,kDAAqBC,kBAAK;EAG3B;EAAK,GAAI;EAAO,GAAI;EAAiB;EAAW;YACjE,cAAc,QAAQ,WAAW,OAAO;GAC3B;EAGjB"}
@@ -5,6 +5,7 @@ import * as next_link0 from "next/link";
5
5
  import Link from "next/link";
6
6
 
7
7
  //#region src/PrismicLink.d.ts
8
+
8
9
  type PrismicLinkProps = Omit<ComponentProps<typeof Link>, "field" | "document" | "href" | "rel"> & {
9
10
  linkResolver?: LinkResolverFunction;
10
11
  rel?: string | AsLinkAttrsConfig["rel"];
@@ -23,7 +24,7 @@ type PrismicLinkProps = Omit<ComponentProps<typeof Link>, "field" | "document" |
23
24
  });
24
25
  declare const PrismicLink: react0.ForwardRefExoticComponent<(Omit<Omit<Omit<react0.AnchorHTMLAttributes<HTMLAnchorElement>, keyof next_link0.LinkProps<any>> & next_link0.LinkProps<any> & {
25
26
  children?: React.ReactNode | undefined;
26
- } & react0.RefAttributes<HTMLAnchorElement>, "rel" | "field" | "href" | "document"> & {
27
+ } & react0.RefAttributes<HTMLAnchorElement>, "href" | "rel" | "field" | "document"> & {
27
28
  linkResolver?: LinkResolverFunction;
28
29
  rel?: string | AsLinkAttrsConfig["rel"];
29
30
  } & {
@@ -32,7 +33,7 @@ declare const PrismicLink: react0.ForwardRefExoticComponent<(Omit<Omit<Omit<reac
32
33
  href?: never;
33
34
  }, "ref"> | Omit<Omit<Omit<react0.AnchorHTMLAttributes<HTMLAnchorElement>, keyof next_link0.LinkProps<any>> & next_link0.LinkProps<any> & {
34
35
  children?: React.ReactNode | undefined;
35
- } & react0.RefAttributes<HTMLAnchorElement>, "rel" | "field" | "href" | "document"> & {
36
+ } & react0.RefAttributes<HTMLAnchorElement>, "href" | "rel" | "field" | "document"> & {
36
37
  linkResolver?: LinkResolverFunction;
37
38
  rel?: string | AsLinkAttrsConfig["rel"];
38
39
  } & {
@@ -41,7 +42,7 @@ declare const PrismicLink: react0.ForwardRefExoticComponent<(Omit<Omit<Omit<reac
41
42
  href?: never;
42
43
  }, "ref"> | Omit<Omit<Omit<react0.AnchorHTMLAttributes<HTMLAnchorElement>, keyof next_link0.LinkProps<any>> & next_link0.LinkProps<any> & {
43
44
  children?: React.ReactNode | undefined;
44
- } & react0.RefAttributes<HTMLAnchorElement>, "rel" | "field" | "href" | "document"> & {
45
+ } & react0.RefAttributes<HTMLAnchorElement>, "href" | "rel" | "field" | "document"> & {
45
46
  linkResolver?: LinkResolverFunction;
46
47
  rel?: string | AsLinkAttrsConfig["rel"];
47
48
  } & {
@@ -7,45 +7,20 @@ let react_jsx_runtime = require("react/jsx-runtime");
7
7
  let _prismicio_react = require("@prismicio/react");
8
8
 
9
9
  //#region src/PrismicRichText.tsx
10
- /**
11
- * Default Next.js-optimized components for rich text rendering.
12
- *
13
- * These components use `<PrismicImage>` and `<PrismicLink>` from
14
- * `@prismicio/next` for optimized image and link rendering.
15
- */
16
10
  const defaultComponents = {
17
11
  image: ({ node, key }) => {
18
- const field = {
19
- url: node.url,
20
- alt: node.alt,
21
- dimensions: node.dimensions,
22
- id: "",
23
- copyright: node.copyright ?? null,
24
- edit: {
25
- x: 0,
26
- y: 0,
27
- zoom: 1,
28
- background: "transparent"
29
- }
30
- };
31
12
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
32
13
  className: "block-img",
33
14
  children: node.linkTo ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PrismicLink.PrismicLink, {
34
15
  field: node.linkTo,
35
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PrismicImage.PrismicImage, {
36
- field,
37
- fallbackAlt: ""
38
- })
39
- }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PrismicImage.PrismicImage, {
40
- field,
41
- fallbackAlt: ""
42
- })
16
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PrismicImage.PrismicImage, { field: node })
17
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PrismicImage.PrismicImage, { field: node })
43
18
  }, key);
44
19
  },
45
- hyperlink: ({ node, children, key }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PrismicLink.PrismicLink, {
20
+ hyperlink: ({ node, children }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PrismicLink.PrismicLink, {
46
21
  field: node.data,
47
22
  children
48
- }, key)
23
+ })
49
24
  };
50
25
  /**
51
26
  * Renders content from a Prismic rich text field as React components with
@@ -57,17 +32,15 @@ const defaultComponents = {
57
32
  * <PrismicRichText field={slice.primary.text} />;
58
33
  * ```
59
34
  *
60
- * @see Learn how to style rich text, use custom components, and use labels for
61
- * custom formatting: {@link https://prismic.io/docs/fields/rich-text}
35
+ * @see {@link https://prismic.io/docs/fields/rich-text}
62
36
  */
63
37
  const PrismicRichText = ({ components, ...restProps }) => {
64
- const mergedComponents = {
65
- ...defaultComponents,
66
- ...components
67
- };
68
38
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_prismicio_react.PrismicRichText, {
69
- ...restProps,
70
- components: mergedComponents
39
+ components: {
40
+ ...defaultComponents,
41
+ ...components
42
+ },
43
+ ...restProps
71
44
  });
72
45
  };
73
46
 
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicRichText.cjs","names":["PrismicLink","PrismicImage","BasePrismicRichText"],"sources":["../src/PrismicRichText.tsx"],"sourcesContent":["\"use client\";\n\nimport type { FC } from \"react\";\nimport {\n\tPrismicRichText as BasePrismicRichText,\n\ttype PrismicRichTextProps as BasePrismicRichTextProps,\n\ttype JSXMapSerializer,\n} from \"@prismicio/react\";\n\nimport { PrismicImage } from \"./PrismicImage\";\nimport { PrismicLink } from \"./PrismicLink\";\n\n/**\n * A map of rich text block types to React Components. It is used to render\n * rich text fields.\n *\n * @see Templating rich text fields {@link https://prismic.io/docs/fields/rich-text}\n */\nexport type RichTextComponents = JSXMapSerializer;\n\n/**\n * Props for `<PrismicRichText>`.\n *\n * This component wraps `@prismicio/react`'s `<PrismicRichText>` with Next.js\n * optimized defaults for images and links.\n */\nexport type PrismicRichTextProps = Omit<\n\tBasePrismicRichTextProps,\n\t\"components\"\n> & {\n\tcomponents?: RichTextComponents;\n};\n\n/**\n * Default Next.js-optimized components for rich text rendering.\n *\n * These components use `<PrismicImage>` and `<PrismicLink>` from\n * `@prismicio/next` for optimized image and link rendering.\n */\nexport const defaultComponents: RichTextComponents = {\n\timage: ({ node, key }) => {\n\t\tconst field = {\n\t\t\turl: node.url,\n\t\t\talt: node.alt,\n\t\t\tdimensions: node.dimensions,\n\t\t\tid: \"\",\n\t\t\tcopyright: node.copyright ?? null,\n\t\t\tedit: { x: 0, y: 0, zoom: 1, background: \"transparent\" },\n\t\t};\n\n\t\treturn (\n\t\t\t<p key={key} className=\"block-img\">\n\t\t\t\t{node.linkTo ? (\n\t\t\t\t\t<PrismicLink field={node.linkTo}>\n\t\t\t\t\t\t<PrismicImage field={field} fallbackAlt=\"\" />\n\t\t\t\t\t</PrismicLink>\n\t\t\t\t) : (\n\t\t\t\t\t<PrismicImage field={field} fallbackAlt=\"\" />\n\t\t\t\t)}\n\t\t\t</p>\n\t\t);\n\t},\n\thyperlink: ({ node, children, key }) => (\n\t\t<PrismicLink key={key} field={node.data}>\n\t\t\t{children}\n\t\t</PrismicLink>\n\t),\n};\n\n/**\n * Renders content from a Prismic rich text field as React components with\n * Next.js-optimized defaults for images and links.\n *\n * @example\n *\n * ```tsx\n * <PrismicRichText field={slice.primary.text} />;\n * ```\n *\n * @see Learn how to style rich text, use custom components, and use labels for\n * custom formatting: {@link https://prismic.io/docs/fields/rich-text}\n */\nexport const PrismicRichText: FC<PrismicRichTextProps> = ({\n\tcomponents,\n\t...restProps\n}) => {\n\tconst mergedComponents = { ...defaultComponents, ...components };\n\treturn <BasePrismicRichText {...restProps} components={mergedComponents} />;\n};\n"],"mappings":";;;;;;;;;;;;;;;AAuCA,MAAa,oBAAwC;CACpD,QAAQ,EAAE,MAAM,UAAU;EACzB,MAAM,QAAQ;GACb,KAAK,KAAK;GACV,KAAK,KAAK;GACV,YAAY,KAAK;GACjB,IAAI;GACJ,WAAW,KAAK,aAAa;GAC7B,MAAM;IAAE,GAAG;IAAG,GAAG;IAAG,MAAM;IAAG,YAAY;IAAe;GACxD;AAED,SACC,2CAAC;GAAY,WAAU;aACrB,KAAK,SACL,2CAACA;IAAY,OAAO,KAAK;cACxB,2CAACC;KAAoB;KAAO,aAAY;MAAK;KAChC,GAEd,2CAACA;IAAoB;IAAO,aAAY;KAAK;KANvC,IAQJ;;CAGN,YAAY,EAAE,MAAM,UAAU,UAC7B,2CAACD;EAAsB,OAAO,KAAK;EACjC;IADgB,IAEJ;CAEf;;;;;;;;;;;;;;AAeD,MAAa,mBAA6C,EACzD,YACA,GAAG,gBACE;CACL,MAAM,mBAAmB;EAAE,GAAG;EAAmB,GAAG;EAAY;AAChE,QAAO,2CAACE;EAAoB,GAAI;EAAW,YAAY;GAAoB"}
1
+ {"version":3,"file":"PrismicRichText.cjs","names":["PrismicLink","PrismicImage","BasePrismicRichText"],"sources":["../src/PrismicRichText.tsx"],"sourcesContent":["\"use client\";\n\nimport { PrismicImage } from \"./PrismicImage\";\nimport { PrismicLink } from \"./PrismicLink\";\nimport {\n\tPrismicRichText as BasePrismicRichText,\n\ttype PrismicRichTextProps as BasePrismicRichTextProps,\n\ttype RichTextComponents,\n} from \"@prismicio/react\";\nimport type { FC } from \"react\";\n\n/**\n * Props for `<PrismicRichText>`.\n */\nexport type PrismicRichTextProps = Omit<\n\tBasePrismicRichTextProps,\n\t\"components\"\n> & {\n\tcomponents?: RichTextComponents;\n};\n\nexport const defaultComponents: RichTextComponents = {\n\timage: ({ node, key }) => {\n\t\treturn (\n\t\t\t<p key={key} className=\"block-img\">\n\t\t\t\t{node.linkTo ? (\n\t\t\t\t\t<PrismicLink field={node.linkTo}>\n\t\t\t\t\t\t<PrismicImage field={node} />\n\t\t\t\t\t</PrismicLink>\n\t\t\t\t) : (\n\t\t\t\t\t<PrismicImage field={node} />\n\t\t\t\t)}\n\t\t\t</p>\n\t\t);\n\t},\n\thyperlink: ({ node, children }) => (\n\t\t<PrismicLink field={node.data}>{children}</PrismicLink>\n\t),\n};\n\n/**\n * Renders content from a Prismic rich text field as React components with\n * Next.js-optimized defaults for images and links.\n *\n * @example\n *\n * ```tsx\n * <PrismicRichText field={slice.primary.text} />;\n * ```\n *\n * @see {@link https://prismic.io/docs/fields/rich-text}\n */\nexport const PrismicRichText: FC<PrismicRichTextProps> = ({\n\tcomponents,\n\t...restProps\n}) => {\n\treturn (\n\t\t<BasePrismicRichText\n\t\t\tcomponents={{ ...defaultComponents, ...components }}\n\t\t\t{...restProps}\n\t\t/>\n\t);\n};\n"],"mappings":";;;;;;;;;AAqBA,MAAa,oBAAwC;CACpD,QAAQ,EAAE,MAAM,UAAU;AACzB,SACC,2CAAC;GAAY,WAAU;aACrB,KAAK,SACL,2CAACA;IAAY,OAAO,KAAK;cACxB,2CAACC,qCAAa,OAAO,OAAQ;KAChB,GAEd,2CAACA,qCAAa,OAAO,OAAQ;KANvB,IAQJ;;CAGN,YAAY,EAAE,MAAM,eACnB,2CAACD;EAAY,OAAO,KAAK;EAAO;GAAuB;CAExD;;;;;;;;;;;;;AAcD,MAAa,mBAA6C,EACzD,YACA,GAAG,gBACE;AACL,QACC,2CAACE;EACA,YAAY;GAAE,GAAG;GAAmB,GAAG;GAAY;EACnD,GAAI;GACH"}
@@ -1,31 +1,14 @@
1
1
  import { FC } from "react";
2
- import { JSXMapSerializer, PrismicRichTextProps } from "@prismicio/react";
2
+ import { PrismicRichTextProps, RichTextComponents } from "@prismicio/react";
3
3
 
4
4
  //#region src/PrismicRichText.d.ts
5
5
 
6
- /**
7
- * A map of rich text block types to React Components. It is used to render
8
- * rich text fields.
9
- *
10
- * @see Templating rich text fields {@link https://prismic.io/docs/fields/rich-text}
11
- */
12
- type RichTextComponents = JSXMapSerializer;
13
6
  /**
14
7
  * Props for `<PrismicRichText>`.
15
- *
16
- * This component wraps `@prismicio/react`'s `<PrismicRichText>` with Next.js
17
- * optimized defaults for images and links.
18
8
  */
19
9
  type PrismicRichTextProps$1 = Omit<PrismicRichTextProps, "components"> & {
20
10
  components?: RichTextComponents;
21
11
  };
22
- /**
23
- * Default Next.js-optimized components for rich text rendering.
24
- *
25
- * These components use `<PrismicImage>` and `<PrismicLink>` from
26
- * `@prismicio/next` for optimized image and link rendering.
27
- */
28
- declare const defaultComponents: RichTextComponents;
29
12
  /**
30
13
  * Renders content from a Prismic rich text field as React components with
31
14
  * Next.js-optimized defaults for images and links.
@@ -36,10 +19,9 @@ declare const defaultComponents: RichTextComponents;
36
19
  * <PrismicRichText field={slice.primary.text} />;
37
20
  * ```
38
21
  *
39
- * @see Learn how to style rich text, use custom components, and use labels for
40
- * custom formatting: {@link https://prismic.io/docs/fields/rich-text}
22
+ * @see {@link https://prismic.io/docs/fields/rich-text}
41
23
  */
42
24
  declare const PrismicRichText: FC<PrismicRichTextProps$1>;
43
25
  //#endregion
44
- export { PrismicRichText, PrismicRichTextProps$1 as PrismicRichTextProps, RichTextComponents, defaultComponents };
26
+ export { PrismicRichText, PrismicRichTextProps$1 as PrismicRichTextProps };
45
27
  //# sourceMappingURL=PrismicRichText.d.cts.map
@@ -20,13 +20,12 @@ let _prismicio_react = require("@prismicio/react");
20
20
  * {@link https://prismic.io/docs/fields/table}
21
21
  */
22
22
  const PrismicTable = ({ components, ...restProps }) => {
23
- const mergedComponents = {
24
- ...require_PrismicRichText.defaultComponents,
25
- ...components
26
- };
27
23
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_prismicio_react.PrismicTable, {
28
- ...restProps,
29
- components: mergedComponents
24
+ components: {
25
+ ...require_PrismicRichText.defaultComponents,
26
+ ...components
27
+ },
28
+ ...restProps
30
29
  });
31
30
  };
32
31
 
@@ -1 +1 @@
1
- {"version":3,"file":"PrismicTable.cjs","names":["defaultComponents","BasePrismicTable"],"sources":["../src/PrismicTable.tsx"],"sourcesContent":["\"use client\";\n\nimport type { ComponentType, FC, ReactNode } from \"react\";\nimport {\n\tPrismicTable as BasePrismicTable,\n\ttype PrismicTableProps as BasePrismicTableProps,\n} from \"@prismicio/react\";\nimport type {\n\tTableField,\n\tTableFieldHead,\n\tTableFieldBody,\n\tTableFieldHeadRow,\n\tTableFieldBodyRow,\n\tTableFieldHeaderCell,\n\tTableFieldDataCell,\n} from \"@prismicio/client\";\n\nimport type { RichTextComponents } from \"./PrismicRichText\";\nimport { defaultComponents } from \"./PrismicRichText\";\n\n/**\n * Custom components for rendering table elements.\n */\nexport type TableComponents = {\n\ttable?: ComponentType<{ table: TableField<\"filled\">; children: ReactNode }>;\n\tthead?: ComponentType<{ head: TableFieldHead; children: ReactNode }>;\n\ttbody?: ComponentType<{ body: TableFieldBody; children: ReactNode }>;\n\ttr?: ComponentType<{\n\t\trow: TableFieldHeadRow | TableFieldBodyRow;\n\t\tchildren: ReactNode;\n\t}>;\n\tth?: ComponentType<{ cell: TableFieldHeaderCell; children: ReactNode }>;\n\ttd?: ComponentType<{ cell: TableFieldDataCell; children: ReactNode }>;\n};\n\n/**\n * Props for `<PrismicTable>`.\n *\n * This component wraps `@prismicio/react`'s `<PrismicTable>` with Next.js\n * optimized defaults for images and links in cell content.\n */\nexport type PrismicTableProps = Omit<BasePrismicTableProps, \"components\"> & {\n\tcomponents?: RichTextComponents & TableComponents;\n};\n\n/**\n * Renders content from a Prismic table field as React components with\n * Next.js-optimized defaults for images and links in cell content.\n *\n * @example\n *\n * ```tsx\n * <PrismicTable field={slice.primary.pricing_table} />;\n * ```\n *\n * @see Learn how to style tables and customize table element components:\n * {@link https://prismic.io/docs/fields/table}\n */\nexport const PrismicTable: FC<PrismicTableProps> = ({\n\tcomponents,\n\t...restProps\n}) => {\n\tconst mergedComponents = { ...defaultComponents, ...components };\n\treturn <BasePrismicTable {...restProps} components={mergedComponents} />;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA0DA,MAAa,gBAAuC,EACnD,YACA,GAAG,gBACE;CACL,MAAM,mBAAmB;EAAE,GAAGA;EAAmB,GAAG;EAAY;AAChE,QAAO,2CAACC;EAAiB,GAAI;EAAW,YAAY;GAAoB"}
1
+ {"version":3,"file":"PrismicTable.cjs","names":["BasePrismicTable","defaultComponents"],"sources":["../src/PrismicTable.tsx"],"sourcesContent":["\"use client\";\n\nimport { defaultComponents } from \"./PrismicRichText\";\nimport {\n\tPrismicTable as BasePrismicTable,\n\ttype PrismicTableProps,\n} from \"@prismicio/react\";\nimport type { FC } from \"react\";\n\n/**\n * Renders content from a Prismic table field as React components with\n * Next.js-optimized defaults for images and links in cell content.\n *\n * @example\n *\n * ```tsx\n * <PrismicTable field={slice.primary.pricing_table} />;\n * ```\n *\n * @see Learn how to style tables and customize table element components:\n * {@link https://prismic.io/docs/fields/table}\n */\nexport const PrismicTable: FC<PrismicTableProps> = ({\n\tcomponents,\n\t...restProps\n}) => {\n\treturn (\n\t\t<BasePrismicTable\n\t\t\tcomponents={{ ...defaultComponents, ...components }}\n\t\t\t{...restProps}\n\t\t/>\n\t);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAsBA,MAAa,gBAAuC,EACnD,YACA,GAAG,gBACE;AACL,QACC,2CAACA;EACA,YAAY;GAAE,GAAGC;GAAmB,GAAG;GAAY;EACnD,GAAI;GACH"}
@@ -1,48 +1,8 @@
1
- import { RichTextComponents } from "./PrismicRichText.cjs";
2
- import { ComponentType, FC, ReactNode } from "react";
3
- import { TableField, TableFieldBody, TableFieldBodyRow, TableFieldDataCell, TableFieldHead, TableFieldHeadRow, TableFieldHeaderCell } from "@prismicio/client";
1
+ import { FC } from "react";
4
2
  import { PrismicTableProps } from "@prismicio/react";
5
3
 
6
4
  //#region src/PrismicTable.d.ts
7
5
 
8
- /**
9
- * Custom components for rendering table elements.
10
- */
11
- type TableComponents = {
12
- table?: ComponentType<{
13
- table: TableField<"filled">;
14
- children: ReactNode;
15
- }>;
16
- thead?: ComponentType<{
17
- head: TableFieldHead;
18
- children: ReactNode;
19
- }>;
20
- tbody?: ComponentType<{
21
- body: TableFieldBody;
22
- children: ReactNode;
23
- }>;
24
- tr?: ComponentType<{
25
- row: TableFieldHeadRow | TableFieldBodyRow;
26
- children: ReactNode;
27
- }>;
28
- th?: ComponentType<{
29
- cell: TableFieldHeaderCell;
30
- children: ReactNode;
31
- }>;
32
- td?: ComponentType<{
33
- cell: TableFieldDataCell;
34
- children: ReactNode;
35
- }>;
36
- };
37
- /**
38
- * Props for `<PrismicTable>`.
39
- *
40
- * This component wraps `@prismicio/react`'s `<PrismicTable>` with Next.js
41
- * optimized defaults for images and links in cell content.
42
- */
43
- type PrismicTableProps$1 = Omit<PrismicTableProps, "components"> & {
44
- components?: RichTextComponents & TableComponents;
45
- };
46
6
  /**
47
7
  * Renders content from a Prismic table field as React components with
48
8
  * Next.js-optimized defaults for images and links in cell content.
@@ -56,7 +16,7 @@ type PrismicTableProps$1 = Omit<PrismicTableProps, "components"> & {
56
16
  * @see Learn how to style tables and customize table element components:
57
17
  * {@link https://prismic.io/docs/fields/table}
58
18
  */
59
- declare const PrismicTable: FC<PrismicTableProps$1>;
19
+ declare const PrismicTable: FC<PrismicTableProps>;
60
20
  //#endregion
61
- export { PrismicTable, PrismicTableProps$1 as PrismicTableProps, TableComponents };
21
+ export { PrismicTable };
62
22
  //# sourceMappingURL=PrismicTable.d.cts.map
package/dist/index.cjs CHANGED
@@ -4,13 +4,13 @@ const require_PrismicPreview = require('./PrismicPreview.cjs');
4
4
  const require_imgixLoader = require('./imgixLoader.cjs');
5
5
  const require_PrismicImage = require('./PrismicImage.cjs');
6
6
  const require_PrismicLink = require('./PrismicLink.cjs');
7
+ const require_PrismicRichText = require('./PrismicRichText.cjs');
8
+ const require_PrismicTable = require('./PrismicTable.cjs');
7
9
  const require_enableAutoPreviews = require('./enableAutoPreviews.cjs');
8
10
  const require_redirectToPreviewURL = require('./redirectToPreviewURL.cjs');
9
11
  const require_getSlices = require('./getSlices.cjs');
10
12
  const require_SliceSimulator = require('./SliceSimulator.cjs');
11
13
  const require_createLocaleRedirect = require('./createLocaleRedirect.cjs');
12
- const require_PrismicRichText = require('./PrismicRichText.cjs');
13
- const require_PrismicTable = require('./PrismicTable.cjs');
14
14
  let _prismicio_react = require("@prismicio/react");
15
15
 
16
16
  exports.PrismicImage = require_PrismicImage.PrismicImage;
@@ -40,7 +40,6 @@ Object.defineProperty(exports, 'TODOSliceComponent', {
40
40
  }
41
41
  });
42
42
  exports.createLocaleRedirect = require_createLocaleRedirect.createLocaleRedirect;
43
- exports.defaultComponents = require_PrismicRichText.defaultComponents;
44
43
  exports.enableAutoPreviews = require_enableAutoPreviews.enableAutoPreviews;
45
44
  exports.exitPreview = require_exitPreview.exitPreview;
46
45
  exports.getSlices = require_getSlices.getSlices;
package/dist/index.d.cts CHANGED
@@ -2,6 +2,8 @@ import { exitPreview } from "./exitPreview.cjs";
2
2
  import { PrismicPreview, PrismicPreviewProps } from "./PrismicPreview.cjs";
3
3
  import { PrismicImage, PrismicImageProps } from "./PrismicImage.cjs";
4
4
  import { PrismicLink, PrismicLinkProps } from "./PrismicLink.cjs";
5
+ import { PrismicRichText, PrismicRichTextProps } from "./PrismicRichText.cjs";
6
+ import { PrismicTable } from "./PrismicTable.cjs";
5
7
  import { EnableAutoPreviewsConfig, enableAutoPreviews } from "./enableAutoPreviews.cjs";
6
8
  import { CreateClientConfig } from "./types.cjs";
7
9
  import { RedirectToPreviewURLConfig, redirectToPreviewURL } from "./redirectToPreviewURL.cjs";
@@ -9,7 +11,5 @@ import { SliceSimulator, SliceSimulatorParams, SliceSimulatorProps } from "./Sli
9
11
  import { getSlices } from "./getSlices.cjs";
10
12
  import { imgixLoader } from "./imgixLoader.cjs";
11
13
  import { CreateLocaleRedirectConfig, createLocaleRedirect } from "./createLocaleRedirect.cjs";
12
- import { PrismicRichText, PrismicRichTextProps, RichTextComponents, defaultComponents } from "./PrismicRichText.cjs";
13
- import { PrismicTable, PrismicTableProps, TableComponents } from "./PrismicTable.cjs";
14
- import { PrismicText, PrismicTextProps, SliceComponentProps, SliceComponentType, SliceLike, SliceLikeGraphQL, SliceLikeRestV2, SliceZone, SliceZoneLike, SliceZoneProps, TODOSliceComponent } from "@prismicio/react";
15
- export { type CreateClientConfig, type CreateLocaleRedirectConfig, type EnableAutoPreviewsConfig, PrismicImage, type PrismicImageProps, PrismicLink, type PrismicLinkProps, PrismicImage as PrismicNextImage, type PrismicImageProps as PrismicNextImageProps, PrismicLink as PrismicNextLink, type PrismicLinkProps as PrismicNextLinkProps, PrismicPreview, type PrismicPreviewProps, PrismicRichText, type PrismicRichTextProps, PrismicTable, type PrismicTableProps, PrismicText, type PrismicTextProps, type RedirectToPreviewURLConfig, type RichTextComponents, type SliceComponentProps, type SliceComponentType, type SliceLike, type SliceLikeGraphQL, type SliceLikeRestV2, SliceSimulator, type SliceSimulatorParams, type SliceSimulatorProps, SliceZone, type SliceZoneLike, type SliceZoneProps, TODOSliceComponent, type TableComponents, createLocaleRedirect, defaultComponents, enableAutoPreviews, exitPreview, getSlices, imgixLoader, redirectToPreviewURL };
14
+ import { PrismicTableProps, PrismicText, PrismicTextProps, RichTextComponents, SliceComponentProps, SliceComponentType, SliceZone, SliceZoneProps, TODOSliceComponent } from "@prismicio/react";
15
+ export { type CreateClientConfig, type CreateLocaleRedirectConfig, type EnableAutoPreviewsConfig, PrismicImage, type PrismicImageProps, PrismicLink, type PrismicLinkProps, PrismicImage as PrismicNextImage, type PrismicImageProps as PrismicNextImageProps, PrismicLink as PrismicNextLink, type PrismicLinkProps as PrismicNextLinkProps, PrismicPreview, type PrismicPreviewProps, PrismicRichText, type PrismicRichTextProps, PrismicTable, type PrismicTableProps, PrismicText, type PrismicTextProps, type RedirectToPreviewURLConfig, type RichTextComponents, type SliceComponentProps, type SliceComponentType, SliceSimulator, type SliceSimulatorParams, type SliceSimulatorProps, SliceZone, type SliceZoneProps, TODOSliceComponent, createLocaleRedirect, enableAutoPreviews, exitPreview, getSlices, imgixLoader, redirectToPreviewURL };
package/dist/package.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  //#region package.json
3
- var version = "2.2.0-pr.123.0d5ddd7";
3
+ var version = "2.2.0-pr.123.1c009e2";
4
4
 
5
5
  //#endregion
6
6
  Object.defineProperty(exports, 'version', {
package/dist/pages.cjs CHANGED
@@ -2,9 +2,9 @@ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
2
  const require_imgixLoader = require('./imgixLoader.cjs');
3
3
  const require_PrismicImage = require('./PrismicImage.cjs');
4
4
  const require_PrismicLink = require('./PrismicLink.cjs');
5
- const require_createLocaleRedirect = require('./createLocaleRedirect.cjs');
6
5
  const require_PrismicRichText = require('./PrismicRichText.cjs');
7
6
  const require_PrismicTable = require('./PrismicTable.cjs');
7
+ const require_createLocaleRedirect = require('./createLocaleRedirect.cjs');
8
8
  const require_SliceSimulator = require('./pages/SliceSimulator.cjs');
9
9
  const require_PrismicPreview = require('./pages/PrismicPreview.cjs');
10
10
  const require_enableAutoPreviews = require('./pages/enableAutoPreviews.cjs');
@@ -40,7 +40,6 @@ Object.defineProperty(exports, 'TODOSliceComponent', {
40
40
  }
41
41
  });
42
42
  exports.createLocaleRedirect = require_createLocaleRedirect.createLocaleRedirect;
43
- exports.defaultComponents = require_PrismicRichText.defaultComponents;
44
43
  exports.enableAutoPreviews = require_enableAutoPreviews.enableAutoPreviews;
45
44
  exports.exitPreview = require_exitPreview.exitPreview;
46
45
  exports.imgixLoader = require_imgixLoader.imgixLoader;
package/dist/pages.d.cts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { PrismicImage, PrismicImageProps } from "./PrismicImage.cjs";
2
2
  import { PrismicLink, PrismicLinkProps } from "./PrismicLink.cjs";
3
+ import { PrismicRichText, PrismicRichTextProps } from "./PrismicRichText.cjs";
4
+ import { PrismicTable } from "./PrismicTable.cjs";
3
5
  import { imgixLoader } from "./imgixLoader.cjs";
4
6
  import { CreateLocaleRedirectConfig, createLocaleRedirect } from "./createLocaleRedirect.cjs";
5
- import { PrismicRichText, PrismicRichTextProps, RichTextComponents, defaultComponents } from "./PrismicRichText.cjs";
6
- import { PrismicTable, PrismicTableProps, TableComponents } from "./PrismicTable.cjs";
7
7
  import { SliceSimulator, SliceSimulatorProps, SliceSimulatorSliceZoneProps } from "./pages/SliceSimulator.cjs";
8
8
  import { PrismicPreview, PrismicPreviewProps } from "./pages/PrismicPreview.cjs";
9
9
  import { CreateClientConfig } from "./pages/types.cjs";
@@ -11,5 +11,5 @@ import { EnableAutoPreviewsConfig, enableAutoPreviews } from "./pages/enableAuto
11
11
  import { RedirectToPreviewURLConfig, redirectToPreviewURL } from "./pages/redirectToPreviewURL.cjs";
12
12
  import { ExitPreviewAPIRouteConfig, exitPreview } from "./pages/exitPreview.cjs";
13
13
  import { SetPreviewDataConfig, setPreviewData } from "./pages/setPreviewData.cjs";
14
- import { PrismicText, PrismicTextProps, SliceComponentProps, SliceComponentType, SliceLike, SliceLikeGraphQL, SliceLikeRestV2, SliceZone, SliceZoneLike, SliceZoneProps, TODOSliceComponent } from "@prismicio/react";
15
- export { type CreateClientConfig, type CreateLocaleRedirectConfig, type EnableAutoPreviewsConfig, type ExitPreviewAPIRouteConfig, PrismicImage, type PrismicImageProps, PrismicLink, type PrismicLinkProps, PrismicImage as PrismicNextImage, type PrismicImageProps as PrismicNextImageProps, PrismicLink as PrismicNextLink, type PrismicLinkProps as PrismicNextLinkProps, PrismicPreview, type PrismicPreviewProps, PrismicRichText, type PrismicRichTextProps, PrismicTable, type PrismicTableProps, PrismicText, type PrismicTextProps, type RedirectToPreviewURLConfig, type RichTextComponents, type SetPreviewDataConfig, type SliceComponentProps, type SliceComponentType, type SliceLike, type SliceLikeGraphQL, type SliceLikeRestV2, SliceSimulator, type SliceSimulatorProps, type SliceSimulatorSliceZoneProps, SliceZone, type SliceZoneLike, type SliceZoneProps, TODOSliceComponent, type TableComponents, createLocaleRedirect, defaultComponents, enableAutoPreviews, exitPreview, imgixLoader, redirectToPreviewURL, setPreviewData };
14
+ import { PrismicTableProps, PrismicText, PrismicTextProps, RichTextComponents, SliceComponentProps, SliceComponentType, SliceZone, SliceZoneProps, TODOSliceComponent } from "@prismicio/react";
15
+ export { type CreateClientConfig, type CreateLocaleRedirectConfig, type EnableAutoPreviewsConfig, type ExitPreviewAPIRouteConfig, PrismicImage, type PrismicImageProps, PrismicLink, type PrismicLinkProps, PrismicImage as PrismicNextImage, type PrismicImageProps as PrismicNextImageProps, PrismicLink as PrismicNextLink, type PrismicLinkProps as PrismicNextLinkProps, PrismicPreview, type PrismicPreviewProps, PrismicRichText, type PrismicRichTextProps, PrismicTable, type PrismicTableProps, PrismicText, type PrismicTextProps, type RedirectToPreviewURLConfig, type RichTextComponents, type SetPreviewDataConfig, type SliceComponentProps, type SliceComponentType, SliceSimulator, type SliceSimulatorProps, type SliceSimulatorSliceZoneProps, SliceZone, type SliceZoneProps, TODOSliceComponent, createLocaleRedirect, enableAutoPreviews, exitPreview, imgixLoader, redirectToPreviewURL, setPreviewData };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismicio/next",
3
- "version": "2.2.0-pr.123.0d5ddd7",
3
+ "version": "2.2.0-pr.123.1c009e2",
4
4
  "description": "Helpers to integrate Prismic into Next.js apps",
5
5
  "keywords": [
6
6
  "typescript",
@@ -55,7 +55,7 @@
55
55
  "types": "tsc --noEmit"
56
56
  },
57
57
  "dependencies": {
58
- "@prismicio/react": "^3",
58
+ "@prismicio/react": "^3.3.0",
59
59
  "@prismicio/simulator": "^0.2.0",
60
60
  "imgix-url-builder": "^0.0.5",
61
61
  "lz-string": "^1.5.0"
@@ -1,23 +1,30 @@
1
1
  "use client";
2
2
 
3
+ import { imgixLoader } from "./imgixLoader";
4
+ import { devMsg } from "./lib/devMsg";
5
+ import { resolveDefaultExport } from "./lib/resolveDefaultExport";
6
+ import type { ImageFieldImage } from "@prismicio/client";
7
+ import { isFilled } from "@prismicio/client";
8
+ import type { ImgixURLParams } from "imgix-url-builder";
9
+ import { buildURL } from "imgix-url-builder";
10
+ import type { ImageProps } from "next/image";
11
+ import Image from "next/image";
3
12
  import type {
4
13
  ForwardRefExoticComponent,
5
14
  PropsWithoutRef,
6
- RefAttributes} from "react";
7
- import {
8
- forwardRef
15
+ RefAttributes,
9
16
  } from "react";
10
- import type { ImageProps } from "next/image";
11
- import Image from "next/image";
12
- import type { ImgixURLParams } from "imgix-url-builder";
13
- import { buildURL } from "imgix-url-builder";
14
- import type { ImageFieldImage} from "@prismicio/client";
15
- import { isFilled } from "@prismicio/client";
17
+ import { forwardRef } from "react";
16
18
 
17
- import { devMsg } from "./lib/devMsg";
18
- import { resolveDefaultExport } from "./lib/resolveDefaultExport";
19
+ /**
20
+ * @deprecated Use `PrismicImage` instead.
21
+ */
22
+ export { PrismicImage as PrismicNextImage };
19
23
 
20
- import { imgixLoader } from "./imgixLoader";
24
+ /**
25
+ * @deprecated Use `PrismicImageProps` instead.
26
+ */
27
+ export type { PrismicImageProps as PrismicNextImageProps };
21
28
 
22
29
  const castInt = (input: string | number | undefined): number | undefined => {
23
30
  if (typeof input === "number" || typeof input === "undefined") {
@@ -33,10 +40,7 @@ const castInt = (input: string | number | undefined): number | undefined => {
33
40
  }
34
41
  };
35
42
 
36
- export type PrismicImageProps = Omit<
37
- ImageProps,
38
- "src" | "alt" | "loader"
39
- > & {
43
+ export type PrismicImageProps = Omit<ImageProps, "src" | "alt" | "loader"> & {
40
44
  /** The Prismic Image field or thumbnail to render. */
41
45
  field: ImageFieldImage | null | undefined;
42
46
 
@@ -92,94 +96,92 @@ export type PrismicImageProps = Omit<
92
96
  // The type annotation is necessary to avoid a type reference issue.
93
97
  export const PrismicImage: ForwardRefExoticComponent<
94
98
  PropsWithoutRef<PrismicImageProps> & RefAttributes<HTMLImageElement>
95
- > = forwardRef<HTMLImageElement, PrismicImageProps>(
96
- function PrismicImage(
97
- {
98
- field,
99
- imgixParams = {},
100
- alt,
101
- fallbackAlt,
102
- fill,
103
- width,
104
- height,
105
- fallback = null,
106
- loader = imgixLoader,
107
- ...restProps
108
- },
109
- ref,
110
- ) {
111
- if (process.env.NODE_ENV === "development") {
112
- if (typeof alt === "string" && alt !== "") {
113
- console.warn(
114
- `[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(
115
- "alt-must-be-an-empty-string",
116
- )}`,
117
- );
118
- }
119
-
120
- if (typeof fallbackAlt === "string" && fallbackAlt !== "") {
121
- console.warn(
122
- `[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(
123
- "alt-must-be-an-empty-string",
124
- )}`,
125
- );
126
- }
99
+ > = forwardRef<HTMLImageElement, PrismicImageProps>(function PrismicImage(
100
+ {
101
+ field,
102
+ imgixParams = {},
103
+ alt,
104
+ fallbackAlt,
105
+ fill,
106
+ width,
107
+ height,
108
+ fallback = null,
109
+ loader = imgixLoader,
110
+ ...restProps
111
+ },
112
+ ref,
113
+ ) {
114
+ if (process.env.NODE_ENV === "development") {
115
+ if (typeof alt === "string" && alt !== "") {
116
+ console.warn(
117
+ `[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(
118
+ "alt-must-be-an-empty-string",
119
+ )}`,
120
+ );
127
121
  }
128
122
 
129
- if (!isFilled.imageThumbnail(field)) {
130
- return <>{fallback}</>;
123
+ if (typeof fallbackAlt === "string" && fallbackAlt !== "") {
124
+ console.warn(
125
+ `[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(
126
+ "alt-must-be-an-empty-string",
127
+ )}`,
128
+ );
131
129
  }
130
+ }
131
+
132
+ if (!isFilled.imageThumbnail(field)) {
133
+ return <>{fallback}</>;
134
+ }
132
135
 
133
- const resolvedImgixParams = imgixParams;
134
- for (const x in imgixParams) {
135
- if (resolvedImgixParams[x as keyof typeof resolvedImgixParams] === null) {
136
- resolvedImgixParams[x as keyof typeof resolvedImgixParams] = undefined;
137
- }
136
+ const resolvedImgixParams = imgixParams;
137
+ for (const x in imgixParams) {
138
+ if (resolvedImgixParams[x as keyof typeof resolvedImgixParams] === null) {
139
+ resolvedImgixParams[x as keyof typeof resolvedImgixParams] = undefined;
138
140
  }
141
+ }
139
142
 
140
- const src = buildURL(field.url, imgixParams as ImgixURLParams);
143
+ const src = buildURL(field.url, imgixParams as ImgixURLParams);
141
144
 
142
- const ar = field.dimensions.width / field.dimensions.height;
145
+ const ar = field.dimensions.width / field.dimensions.height;
143
146
 
144
- const castedWidth = castInt(width);
145
- const castedHeight = castInt(height);
147
+ const castedWidth = castInt(width);
148
+ const castedHeight = castInt(height);
146
149
 
147
- let resolvedWidth = castedWidth ?? field.dimensions.width;
148
- let resolvedHeight = castedHeight ?? field.dimensions.height;
150
+ let resolvedWidth = castedWidth ?? field.dimensions.width;
151
+ let resolvedHeight = castedHeight ?? field.dimensions.height;
149
152
 
150
- if (castedWidth != null && castedHeight == null) {
151
- resolvedHeight = castedWidth / ar;
152
- } else if (castedWidth == null && castedHeight != null) {
153
- resolvedWidth = castedHeight * ar;
154
- }
153
+ if (castedWidth != null && castedHeight == null) {
154
+ resolvedHeight = castedWidth / ar;
155
+ } else if (castedWidth == null && castedHeight != null) {
156
+ resolvedWidth = castedHeight * ar;
157
+ }
155
158
 
156
- // A non-null assertion is required since we can't statically
157
- // know if an alt attribute is available.
158
- const resolvedAlt = (alt ?? (field.alt || fallbackAlt))!;
159
-
160
- if (
161
- process.env.NODE_ENV === "development" &&
162
- typeof resolvedAlt !== "string"
163
- ) {
164
- console.error(
165
- `[PrismicImage] The following image is missing an "alt" property. Please add Alternative Text to the image in Prismic. To mark the image as decorative instead, add one of \`alt=""\` or \`fallbackAlt=""\`.`,
166
- src,
167
- );
168
- }
159
+ // A non-null assertion is required since we can't statically
160
+ // know if an alt attribute is available.
161
+ const resolvedAlt = (alt ?? (field.alt || fallbackAlt))!;
169
162
 
170
- const ResolvedImage = resolveDefaultExport(Image);
171
-
172
- return (
173
- <ResolvedImage
174
- ref={ref}
175
- src={src}
176
- width={fill ? undefined : resolvedWidth}
177
- height={fill ? undefined : resolvedHeight}
178
- alt={resolvedAlt}
179
- fill={fill}
180
- loader={loader === null ? undefined : loader}
181
- {...restProps}
182
- />
163
+ if (
164
+ process.env.NODE_ENV === "development" &&
165
+ typeof resolvedAlt !== "string"
166
+ ) {
167
+ console.error(
168
+ `[PrismicImage] The following image is missing an "alt" property. Please add Alternative Text to the image in Prismic. To mark the image as decorative instead, add one of \`alt=""\` or \`fallbackAlt=""\`.`,
169
+ src,
183
170
  );
184
- },
185
- );
171
+ }
172
+
173
+ const ResolvedImage = resolveDefaultExport(Image);
174
+
175
+ return (
176
+ <ResolvedImage
177
+ ref={ref}
178
+ src={src}
179
+ width={fill ? undefined : resolvedWidth}
180
+ height={fill ? undefined : resolvedHeight}
181
+ alt={resolvedAlt}
182
+ fill={fill}
183
+ loader={loader === null ? undefined : loader}
184
+ {...restProps}
185
+ />
186
+ );
187
+ });
@@ -1,16 +1,24 @@
1
- import type { ComponentProps} from "react";
2
- import { forwardRef } from "react";
3
- import Link from "next/link";
1
+ import { resolveDefaultExport } from "./lib/resolveDefaultExport";
4
2
  import type {
5
3
  AsLinkAttrsConfig,
6
4
  LinkField,
7
5
  LinkResolverFunction,
8
- PrismicDocument} from "@prismicio/client";
9
- import {
10
- asLinkAttrs,
6
+ PrismicDocument,
11
7
  } from "@prismicio/client";
8
+ import { asLinkAttrs } from "@prismicio/client";
9
+ import Link from "next/link";
10
+ import type { ComponentProps } from "react";
11
+ import { forwardRef } from "react";
12
12
 
13
- import { resolveDefaultExport } from "./lib/resolveDefaultExport";
13
+ /**
14
+ * @deprecated Use `PrismicLink` instead.
15
+ */
16
+ export { PrismicLink as PrismicNextLink } from "./PrismicLink";
17
+
18
+ /**
19
+ * @deprecated Use `PrismicLinkProps` instead.
20
+ */
21
+ export type { PrismicLinkProps as PrismicNextLinkProps } from "./PrismicLink";
14
22
 
15
23
  export type PrismicLinkProps = Omit<
16
24
  ComponentProps<typeof Link>,
@@ -36,32 +44,31 @@ export type PrismicLinkProps = Omit<
36
44
  }
37
45
  );
38
46
 
39
- export const PrismicLink = forwardRef<
40
- HTMLAnchorElement,
41
- PrismicLinkProps
42
- >(function PrismicLink(props, ref) {
43
- const { field, document, linkResolver, children, ...restProps } = props;
44
- const {
45
- href: computedHref,
46
- rel: computedRel,
47
- ...attrs
48
- } = asLinkAttrs(field ?? document, {
49
- linkResolver,
50
- rel: typeof restProps.rel === "function" ? restProps.rel : undefined,
51
- });
47
+ export const PrismicLink = forwardRef<HTMLAnchorElement, PrismicLinkProps>(
48
+ function PrismicLink(props, ref) {
49
+ const { field, document, linkResolver, children, ...restProps } = props;
50
+ const {
51
+ href: computedHref,
52
+ rel: computedRel,
53
+ ...attrs
54
+ } = asLinkAttrs(field ?? document, {
55
+ linkResolver,
56
+ rel: typeof restProps.rel === "function" ? restProps.rel : undefined,
57
+ });
52
58
 
53
- const href = ("href" in restProps ? restProps.href : computedHref) || "";
59
+ const href = ("href" in restProps ? restProps.href : computedHref) || "";
54
60
 
55
- let rel = computedRel;
56
- if ("rel" in restProps && typeof restProps.rel !== "function") {
57
- rel = restProps.rel;
58
- }
61
+ let rel = computedRel;
62
+ if ("rel" in restProps && typeof restProps.rel !== "function") {
63
+ rel = restProps.rel;
64
+ }
59
65
 
60
- const ResolvedLink = resolveDefaultExport(Link);
66
+ const ResolvedLink = resolveDefaultExport(Link);
61
67
 
62
- return (
63
- <ResolvedLink ref={ref} {...attrs} {...restProps} href={href} rel={rel}>
64
- {"children" in props ? children : field?.text}
65
- </ResolvedLink>
66
- );
67
- });
68
+ return (
69
+ <ResolvedLink ref={ref} {...attrs} {...restProps} href={href} rel={rel}>
70
+ {"children" in props ? children : field?.text}
71
+ </ResolvedLink>
72
+ );
73
+ },
74
+ );
@@ -1,28 +1,16 @@
1
1
  "use client";
2
2
 
3
- import type { FC } from "react";
3
+ import { PrismicImage } from "./PrismicImage";
4
+ import { PrismicLink } from "./PrismicLink";
4
5
  import {
5
6
  PrismicRichText as BasePrismicRichText,
6
7
  type PrismicRichTextProps as BasePrismicRichTextProps,
7
- type JSXMapSerializer,
8
+ type RichTextComponents,
8
9
  } from "@prismicio/react";
9
-
10
- import { PrismicImage } from "./PrismicImage";
11
- import { PrismicLink } from "./PrismicLink";
12
-
13
- /**
14
- * A map of rich text block types to React Components. It is used to render
15
- * rich text fields.
16
- *
17
- * @see Templating rich text fields {@link https://prismic.io/docs/fields/rich-text}
18
- */
19
- export type RichTextComponents = JSXMapSerializer;
10
+ import type { FC } from "react";
20
11
 
21
12
  /**
22
13
  * Props for `<PrismicRichText>`.
23
- *
24
- * This component wraps `@prismicio/react`'s `<PrismicRichText>` with Next.js
25
- * optimized defaults for images and links.
26
14
  */
27
15
  export type PrismicRichTextProps = Omit<
28
16
  BasePrismicRichTextProps,
@@ -31,39 +19,22 @@ export type PrismicRichTextProps = Omit<
31
19
  components?: RichTextComponents;
32
20
  };
33
21
 
34
- /**
35
- * Default Next.js-optimized components for rich text rendering.
36
- *
37
- * These components use `<PrismicImage>` and `<PrismicLink>` from
38
- * `@prismicio/next` for optimized image and link rendering.
39
- */
40
22
  export const defaultComponents: RichTextComponents = {
41
23
  image: ({ node, key }) => {
42
- const field = {
43
- url: node.url,
44
- alt: node.alt,
45
- dimensions: node.dimensions,
46
- id: "",
47
- copyright: node.copyright ?? null,
48
- edit: { x: 0, y: 0, zoom: 1, background: "transparent" },
49
- };
50
-
51
24
  return (
52
25
  <p key={key} className="block-img">
53
26
  {node.linkTo ? (
54
27
  <PrismicLink field={node.linkTo}>
55
- <PrismicImage field={field} fallbackAlt="" />
28
+ <PrismicImage field={node} />
56
29
  </PrismicLink>
57
30
  ) : (
58
- <PrismicImage field={field} fallbackAlt="" />
31
+ <PrismicImage field={node} />
59
32
  )}
60
33
  </p>
61
34
  );
62
35
  },
63
- hyperlink: ({ node, children, key }) => (
64
- <PrismicLink key={key} field={node.data}>
65
- {children}
66
- </PrismicLink>
36
+ hyperlink: ({ node, children }) => (
37
+ <PrismicLink field={node.data}>{children}</PrismicLink>
67
38
  ),
68
39
  };
69
40
 
@@ -77,13 +48,16 @@ export const defaultComponents: RichTextComponents = {
77
48
  * <PrismicRichText field={slice.primary.text} />;
78
49
  * ```
79
50
  *
80
- * @see Learn how to style rich text, use custom components, and use labels for
81
- * custom formatting: {@link https://prismic.io/docs/fields/rich-text}
51
+ * @see {@link https://prismic.io/docs/fields/rich-text}
82
52
  */
83
53
  export const PrismicRichText: FC<PrismicRichTextProps> = ({
84
54
  components,
85
55
  ...restProps
86
56
  }) => {
87
- const mergedComponents = { ...defaultComponents, ...components };
88
- return <BasePrismicRichText {...restProps} components={mergedComponents} />;
57
+ return (
58
+ <BasePrismicRichText
59
+ components={{ ...defaultComponents, ...components }}
60
+ {...restProps}
61
+ />
62
+ );
89
63
  };
@@ -1,47 +1,11 @@
1
1
  "use client";
2
2
 
3
- import type { ComponentType, FC, ReactNode } from "react";
3
+ import { defaultComponents } from "./PrismicRichText";
4
4
  import {
5
5
  PrismicTable as BasePrismicTable,
6
- type PrismicTableProps as BasePrismicTableProps,
6
+ type PrismicTableProps,
7
7
  } from "@prismicio/react";
8
- import type {
9
- TableField,
10
- TableFieldHead,
11
- TableFieldBody,
12
- TableFieldHeadRow,
13
- TableFieldBodyRow,
14
- TableFieldHeaderCell,
15
- TableFieldDataCell,
16
- } from "@prismicio/client";
17
-
18
- import type { RichTextComponents } from "./PrismicRichText";
19
- import { defaultComponents } from "./PrismicRichText";
20
-
21
- /**
22
- * Custom components for rendering table elements.
23
- */
24
- export type TableComponents = {
25
- table?: ComponentType<{ table: TableField<"filled">; children: ReactNode }>;
26
- thead?: ComponentType<{ head: TableFieldHead; children: ReactNode }>;
27
- tbody?: ComponentType<{ body: TableFieldBody; children: ReactNode }>;
28
- tr?: ComponentType<{
29
- row: TableFieldHeadRow | TableFieldBodyRow;
30
- children: ReactNode;
31
- }>;
32
- th?: ComponentType<{ cell: TableFieldHeaderCell; children: ReactNode }>;
33
- td?: ComponentType<{ cell: TableFieldDataCell; children: ReactNode }>;
34
- };
35
-
36
- /**
37
- * Props for `<PrismicTable>`.
38
- *
39
- * This component wraps `@prismicio/react`'s `<PrismicTable>` with Next.js
40
- * optimized defaults for images and links in cell content.
41
- */
42
- export type PrismicTableProps = Omit<BasePrismicTableProps, "components"> & {
43
- components?: RichTextComponents & TableComponents;
44
- };
8
+ import type { FC } from "react";
45
9
 
46
10
  /**
47
11
  * Renders content from a Prismic table field as React components with
@@ -60,6 +24,10 @@ export const PrismicTable: FC<PrismicTableProps> = ({
60
24
  components,
61
25
  ...restProps
62
26
  }) => {
63
- const mergedComponents = { ...defaultComponents, ...components };
64
- return <BasePrismicTable {...restProps} components={mergedComponents} />;
27
+ return (
28
+ <BasePrismicTable
29
+ components={{ ...defaultComponents, ...components }}
30
+ {...restProps}
31
+ />
32
+ );
65
33
  };
package/src/index.ts CHANGED
@@ -3,16 +3,17 @@ export { exitPreview } from "./exitPreview";
3
3
  export { PrismicPreview } from "./PrismicPreview";
4
4
  export type { PrismicPreviewProps } from "./PrismicPreview";
5
5
 
6
- // New names
7
- export { PrismicImage } from "./PrismicImage";
8
- export type { PrismicImageProps } from "./PrismicImage";
6
+ export { PrismicImage, PrismicNextImage } from "./PrismicImage";
7
+ export type { PrismicImageProps, PrismicNextImageProps } from "./PrismicImage";
9
8
 
10
- export { PrismicLink } from "./PrismicLink";
11
- export type { PrismicLinkProps } from "./PrismicLink";
9
+ export { PrismicLink, PrismicNextLink } from "./PrismicLink";
10
+ export type { PrismicLinkProps, PrismicNextLinkProps } from "./PrismicLink";
12
11
 
13
- // Deprecated aliases
14
- export { PrismicNextImage, PrismicNextLink } from "./deprecated";
15
- export type { PrismicNextImageProps, PrismicNextLinkProps } from "./deprecated";
12
+ export { PrismicRichText } from "./PrismicRichText";
13
+ export type { PrismicRichTextProps } from "./PrismicRichText";
14
+
15
+ export { PrismicTable } from "./PrismicTable";
16
+ export type { PrismicTableProps } from "@prismicio/react";
16
17
 
17
18
  export { enableAutoPreviews } from "./enableAutoPreviews";
18
19
  export type { EnableAutoPreviewsConfig } from "./enableAutoPreviews";
@@ -36,23 +37,11 @@ export { createLocaleRedirect } from "./createLocaleRedirect";
36
37
  export type { CreateLocaleRedirectConfig } from "./createLocaleRedirect";
37
38
 
38
39
  // Re-exports from @prismicio/react
39
- export { PrismicText } from "@prismicio/react";
40
- export type { PrismicTextProps } from "@prismicio/react";
41
-
42
- export { SliceZone, TODOSliceComponent } from "@prismicio/react";
40
+ export { PrismicText, SliceZone, TODOSliceComponent } from "@prismicio/react";
43
41
  export type {
44
42
  SliceComponentProps,
45
43
  SliceComponentType,
46
- SliceLike,
47
- SliceLikeGraphQL,
48
- SliceLikeRestV2,
49
- SliceZoneLike,
50
44
  SliceZoneProps,
45
+ RichTextComponents,
46
+ PrismicTextProps,
51
47
  } from "@prismicio/react";
52
-
53
- // Next.js-specific PrismicRichText and PrismicTable
54
- export { PrismicRichText, defaultComponents } from "./PrismicRichText";
55
- export type { PrismicRichTextProps, RichTextComponents } from "./PrismicRichText";
56
-
57
- export { PrismicTable } from "./PrismicTable";
58
- export type { PrismicTableProps, TableComponents } from "./PrismicTable";
@@ -1,13 +1,14 @@
1
- // New names
2
- export { PrismicImage } from "../PrismicImage";
3
- export type { PrismicImageProps } from "../PrismicImage";
1
+ export { PrismicImage, PrismicNextImage } from "../PrismicImage";
2
+ export type { PrismicImageProps, PrismicNextImageProps } from "../PrismicImage";
4
3
 
5
- export { PrismicLink } from "../PrismicLink";
6
- export type { PrismicLinkProps } from "../PrismicLink";
4
+ export { PrismicLink, PrismicNextLink } from "../PrismicLink";
5
+ export type { PrismicLinkProps, PrismicNextLinkProps } from "../PrismicLink";
7
6
 
8
- // Deprecated aliases
9
- export { PrismicNextImage, PrismicNextLink } from "../deprecated";
10
- export type { PrismicNextImageProps, PrismicNextLinkProps } from "../deprecated";
7
+ export { PrismicRichText } from "../PrismicRichText";
8
+ export type { PrismicRichTextProps } from "../PrismicRichText";
9
+
10
+ export { PrismicTable } from "../PrismicTable";
11
+ export type { PrismicTableProps } from "@prismicio/react";
11
12
 
12
13
  export { SliceSimulator } from "./SliceSimulator";
13
14
  export type {
@@ -38,23 +39,11 @@ export { createLocaleRedirect } from "../createLocaleRedirect";
38
39
  export type { CreateLocaleRedirectConfig } from "../createLocaleRedirect";
39
40
 
40
41
  // Re-exports from @prismicio/react
41
- export { PrismicText } from "@prismicio/react";
42
- export type { PrismicTextProps } from "@prismicio/react";
43
-
44
- export { SliceZone, TODOSliceComponent } from "@prismicio/react";
42
+ export { PrismicText, SliceZone, TODOSliceComponent } from "@prismicio/react";
45
43
  export type {
46
44
  SliceComponentProps,
47
45
  SliceComponentType,
48
- SliceLike,
49
- SliceLikeGraphQL,
50
- SliceLikeRestV2,
51
- SliceZoneLike,
52
46
  SliceZoneProps,
47
+ RichTextComponents,
48
+ PrismicTextProps,
53
49
  } from "@prismicio/react";
54
-
55
- // Next.js-specific PrismicRichText and PrismicTable
56
- export { PrismicRichText, defaultComponents } from "../PrismicRichText";
57
- export type { PrismicRichTextProps, RichTextComponents } from "../PrismicRichText";
58
-
59
- export { PrismicTable } from "../PrismicTable";
60
- export type { PrismicTableProps, TableComponents } from "../PrismicTable";
package/src/deprecated.ts DELETED
@@ -1,19 +0,0 @@
1
- /**
2
- * @deprecated Use `PrismicImage` instead.
3
- */
4
- export { PrismicImage as PrismicNextImage } from "./PrismicImage";
5
-
6
- /**
7
- * @deprecated Use `PrismicImageProps` instead.
8
- */
9
- export type { PrismicImageProps as PrismicNextImageProps } from "./PrismicImage";
10
-
11
- /**
12
- * @deprecated Use `PrismicLink` instead.
13
- */
14
- export { PrismicLink as PrismicNextLink } from "./PrismicLink";
15
-
16
- /**
17
- * @deprecated Use `PrismicLinkProps` instead.
18
- */
19
- export type { PrismicLinkProps as PrismicNextLinkProps } from "./PrismicLink";